aboutsummaryrefslogtreecommitdiff
path: root/trace.c
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-06-20 14:24:18 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-06-20 14:24:18 +0000
commit4f48a490f9af51f22946af72d908777af1c1f148 (patch)
tree4b59268e161ed032aca4ba88222568017e442e0d /trace.c
parentc8d16a1660532531343da62074d7e22a8c0ba91a (diff)
indent
Diffstat (limited to 'trace.c')
-rw-r--r--trace.c92
1 files changed, 39 insertions, 53 deletions
diff --git a/trace.c b/trace.c
index d5975a4..31d01f7 100644
--- a/trace.c
+++ b/trace.c
@@ -15,58 +15,44 @@
#include "symbols.h"
#include "stack.h"
-
-int main( int argc, char *argv[] )
+int
+main(int argc, char *argv[])
{
- FILE *tracef;
- char type;
- unsigned int address;
-
- if (argc != 2) {
-
- printf("Usage: pvtrace <image>\n\n");
- exit(-1);
-
- }
-
- initSymbol( argv[1] );
- stackInit();
-
- tracef = fopen("trace.txt", "r");
-
- if (tracef == NULL) {
- printf("Can't open trace.txt\n");
- exit(-1);
- }
-
- while (!feof(tracef)) {
-
- fscanf( tracef, "%c0x%x\n", &type, &address );
-
- if (type == 'E') {
-
- /* Function Entry */
-
- addSymbol( address );
-
- addCallTrace( address );
-
- stackPush( address );
-
- } else if (type == 'X') {
-
- /* Function Exit */
-
- (void) stackPop();
-
- }
-
- }
-
- emitSymbols();
-
- fclose( tracef );
-
- return 0;
+ FILE *tracef;
+ char type;
+ unsigned int address;
+
+ if (argc != 2) {
+ printf("Usage: pvtrace <image>\n\n");
+ exit(-1);
+ }
+ initSymbol(argv[1]);
+ stackInit();
+
+ tracef = fopen("trace.txt", "r");
+
+ if (tracef == NULL) {
+ printf("Can't open trace.txt\n");
+ exit(-1);
+ }
+ while (!feof(tracef)) {
+ fscanf(tracef, "%c0x%x\n", &type, &address);
+ switch (type) {
+ case 'E':
+ /* Function Entry */
+ addSymbol(address);
+ addCallTrace(address);
+ stackPush(address);
+ break;
+ case 'X':
+ /* Function Exit */
+ (void) stackPop();
+ break;
+ }
+ }
+
+ emitSymbols();
+ fclose(tracef);
+
+ return 0;
}
-