thermostat / itrace (http://cs.virginia.edu/~dww4s/tools/itrace/itrace.html)
Instuction Tracing Program
Clone this repository (size: 826.4 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/thermostat/itrace/
| commit 23: | 9ce9539611b4 |
| parent 22: | 25f709641fbe |
| branch: | itrace |
turned on caching by default
20 months ago
Changed (Δ132 bytes):
raw changeset »
itrace.c (13 lines added, 6 lines removed)
| … | … | @@ -73,7 +73,7 @@ unsigned short defer = 0; |
73 |
73 |
FILE* out = NULL; |
74 |
74 |
unsigned short print_hex = 1; |
75 |
75 |
insn_entry_t * disasm_cache = NULL; |
76 |
unsigned int cache_size |
|
76 |
unsigned int cache_size = DEFAULT_CACHE_SIZE;; |
|
77 |
77 |
#define CACHE_HASH(addr) (addr & (cache_size-1)) |
78 |
78 |
|
79 |
79 |
/* counts the total number of instructions. */ |
| … | … | @@ -414,7 +414,7 @@ void exit_usage(int rc) { |
414 |
414 |
"\n" |
415 |
415 |
"--last n Only print the last n instructions.\n" |
416 |
416 |
"\n" |
417 |
"-- |
|
417 |
"--no-cache Do not use the disassembly cache for performance.\n" |
|
418 |
418 |
"\n" |
419 |
419 |
"--help Print this message and exit\n" |
420 |
420 |
"-h\n" |
| … | … | @@ -455,10 +455,9 @@ char** set_opts(int argc, char* argv[]) |
455 |
455 |
circ_queue = malloc(sizeof(insn_entry_t) * circ_queue_size); |
456 |
456 |
defer = 1; |
457 |
457 |
} |
458 |
else if ( strcmp(cur_arg, "--cache") == 0 ) { |
|
459 |
cache_size = DEFAULT_CACHE_SIZE; |
|
460 |
disasm_cache = malloc(sizeof(insn_entry_t) * cache_size); |
|
461 |
memset( disasm_cache, 0x00, sizeof(insn_entry_t) * cache_size); |
|
458 |
else if ( strcmp(cur_arg, "--no-cache") == 0 ) { |
|
459 |
cache_size = 0; |
|
460 |
||
462 |
461 |
|
463 |
462 |
} |
464 |
463 |
else if ( strcmp(cur_arg, "-o") == 0 ) { |
| … | … | @@ -511,6 +510,14 @@ char** set_opts(int argc, char* argv[]) |
511 |
510 |
} |
512 |
511 |
} |
513 |
512 |
|
513 |
/* this arguably shouldn't be done here, but I don't |
|
514 |
have a better place for it.*/ |
|
515 |
if ( cache_size ) { |
|
516 |
disasm_cache = malloc(sizeof(insn_entry_t) * cache_size); |
|
517 |
memset( disasm_cache, 0x00, sizeof(insn_entry_t) * cache_size); |
|
518 |
} |
|
519 |
||
520 |
||
514 |
521 |
return &(argv[count+1]); |
515 |
522 |
|
516 |
523 |
} |
