From 93ebb28c47aa021378249dcb34f215be14360230 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 17 May 2008 16:03:18 +0000 Subject: pvtrace --- trace.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 trace.c (limited to 'trace.c') diff --git a/trace.c b/trace.c new file mode 100644 index 0000000..d5975a4 --- /dev/null +++ b/trace.c @@ -0,0 +1,72 @@ +/* $Id$ */ +/******************************************************************** + * File: trace.c + * + * main function for the pvtrace utility. + * + * Author: M. Tim Jones + * + */ + +#include +#include +#include +#include +#include "symbols.h" +#include "stack.h" + + +int main( int argc, char *argv[] ) +{ + FILE *tracef; + char type; + unsigned int address; + + if (argc != 2) { + + printf("Usage: pvtrace \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; +} + -- cgit v1.2.3