diff options
Diffstat (limited to 'main/cpu/arm/strace_arm.c')
-rw-r--r-- | main/cpu/arm/strace_arm.c | 203 |
1 files changed, 105 insertions, 98 deletions
diff --git a/main/cpu/arm/strace_arm.c b/main/cpu/arm/strace_arm.c index 8dd7456..f74b82e 100644 --- a/main/cpu/arm/strace_arm.c +++ b/main/cpu/arm/strace_arm.c @@ -53,104 +53,111 @@ char *StraceHelp[] = { int Strace(int argc,char *argv[]) { - TFILE *tfp; - char *symfile, *stopat, fname[64]; - ulong *framepointer, pc, fp, offset; - int tfd, opt, maxdepth, pass, verbose; - - tfd = fp = 0; - maxdepth = 20; - verbose = 0; - stopat = 0; - pc = ExceptionAddr; - while ((opt=getopt(argc,argv,"d:rs:v")) != -1) { - switch(opt) { - case 'd': - maxdepth = atoi(optarg); - break; - case 'r': - showregs(); - break; - case 's': - stopat = optarg; - break; - case 'v': - verbose = 1; - break; - default: - return(0); - } - } - - if (!fp) - getreg("R11", &fp); - - framepointer = (ulong *)fp; - - /* Start by detecting the presence of a symbol table file... */ - symfile = getenv("SYMFILE"); - if (!symfile) - symfile = SYMFILE; - - tfp = tfsstat(symfile); - if (tfp) { - tfd = tfsopen(symfile,TFS_RDONLY,0); - if (tfd < 0) - tfp = (TFILE *)0; - } - - /* Show current position: */ - printf(" 0x%08lx",pc); - if (tfp) { - AddrToSym(tfd,pc,fname,&offset); - printf(": %s()",fname); - if (offset) - printf(" + 0x%lx",offset); - } - putchar('\n'); - - /* Now step through the stack frame... */ - pass = 0; - while(maxdepth) { - if (pass != 0) - framepointer = (ulong *)*(framepointer - 3); - - pc = *(framepointer - 1); - - if (verbose) { - printf("fp=0x%lx,*fp=0x%lx,pc=%lx\n", (ulong)framepointer, - (ulong)*framepointer,pc); - } - - if (((ulong)framepointer & 3) || (!framepointer) || - (!*framepointer) || (!pc)) { - break; - } - - printf(" 0x%08lx",pc); - if (tfp) { - int match; - - match = AddrToSym(tfd,pc,fname,&offset); - printf(": %s()",fname); - if (offset) - printf(" + 0x%lx",offset); - if ((!match) || ((stopat != 0) && (strcmp(fname,stopat) == 0))) { - putchar('\n'); - break; - } - } - putchar('\n'); - maxdepth--; - pass++; - } - - if (!maxdepth) - printf("Max depth termination\n"); - - if (tfp) { - tfsclose(tfd,0); - } + TFILE *tfp; + char *symfile, *stopat, fname[64]; + ulong *framepointer, pc, fp, offset; + int tfd, opt, maxdepth, pass, verbose; + + tfd = fp = 0; + maxdepth = 20; + verbose = 0; + stopat = 0; + pc = ExceptionAddr; + while((opt=getopt(argc,argv,"d:rs:v")) != -1) { + switch(opt) { + case 'd': + maxdepth = atoi(optarg); + break; + case 'r': + showregs(); + break; + case 's': + stopat = optarg; + break; + case 'v': + verbose = 1; + break; + default: + return(0); + } + } + + if(!fp) { + getreg("R11", &fp); + } + + framepointer = (ulong *)fp; + + /* Start by detecting the presence of a symbol table file... */ + symfile = getenv("SYMFILE"); + if(!symfile) { + symfile = SYMFILE; + } + + tfp = tfsstat(symfile); + if(tfp) { + tfd = tfsopen(symfile,TFS_RDONLY,0); + if(tfd < 0) { + tfp = (TFILE *)0; + } + } + + /* Show current position: */ + printf(" 0x%08lx",pc); + if(tfp) { + AddrToSym(tfd,pc,fname,&offset); + printf(": %s()",fname); + if(offset) { + printf(" + 0x%lx",offset); + } + } + putchar('\n'); + + /* Now step through the stack frame... */ + pass = 0; + while(maxdepth) { + if(pass != 0) { + framepointer = (ulong *)*(framepointer - 3); + } + + pc = *(framepointer - 1); + + if(verbose) { + printf("fp=0x%lx,*fp=0x%lx,pc=%lx\n", (ulong)framepointer, + (ulong)*framepointer,pc); + } + + if(((ulong)framepointer & 3) || (!framepointer) || + (!*framepointer) || (!pc)) { + break; + } + + printf(" 0x%08lx",pc); + if(tfp) { + int match; + + match = AddrToSym(tfd,pc,fname,&offset); + printf(": %s()",fname); + if(offset) { + printf(" + 0x%lx",offset); + } + if((!match) || ((stopat != 0) && (strcmp(fname,stopat) == 0))) { + putchar('\n'); + break; + } + } + putchar('\n'); + maxdepth--; + pass++; + } + + if(!maxdepth) { + printf("Max depth termination\n"); + } + + if(tfp) { + tfsclose(tfd,0); + } return(0); } #endif |