Skip to content

Commit

Permalink
[TRACE] Fixed some issue with function name printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Jul 13, 2024
1 parent dcc0355 commit 21e9a43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/emu/x86run_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,10 @@ uintptr_t GetSegmentBaseEmu(x86emu_t* emu, int seg)

const char* getAddrFunctionName(uintptr_t addr)
{
static char ret[1000];
static char rets[8][1000];
static int idx = 0;
char* ret = rets[idx];
idx = (idx+1)&7;
uint32_t sz = 0;
uintptr_t start = 0;
elfheader_t* elf = FindElfAddress(my_context, addr);
Expand Down
9 changes: 4 additions & 5 deletions src/libtools/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,9 @@ exit(-1);
esp = (void*)p->uc_mcontext.arm_r8;
}
#endif
x86name = getAddrFunctionName(x86pc);
elfheader_t* elf = FindElfAddress(my_context, x86pc);
if(elf)
elfname = ElfName(elf);
x86name = getAddrFunctionName(x86pc);
if(jit_gdb) {
pid_t pid = getpid();
int v = fork(); // is this ok in a signal handler???
Expand Down Expand Up @@ -1039,8 +1038,8 @@ exit(-1);
uint32_t hash = 0;
if(db && ((addr<db->x86_addr || addr>(db->x86_addr+db->x86_size)) || (prot&PROT_READ)))
hash = X31_hash_code(db->x86_addr, db->x86_size);
printf_log(log_minimum, "%04d|%s @%p (%s) (x86pc=%p/%s:\"%s\", esp=%p, stack=%p:%p own=%p fp=%p), for accessing %p (code=%d/prot=%x), db=%p(%p:%p/%p:%p/%s:%s, hash:%x/%x)",
GetTID(), signame, pc, name, (void*)x86pc, elfname?elfname:"???", x86name?x86name:"???", esp,
printf_log(log_minimum, "%04d|%s @%p (%s) (x86pc=%p/\"%s\", esp=%p, stack=%p:%p own=%p fp=%p), for accessing %p (code=%d/prot=%x), db=%p(%p:%p/%p:%p/%s:%s, hash:%x/%x)",
GetTID(), signame, pc, name, (void*)x86pc, x86name?x86name:"???", esp,
emu->init_stack, emu->init_stack+emu->size_stack, emu->stack2free, (void*)R_EBP,
addr, info->si_code, prot, db, db?db->block:0, db?(db->block+db->size):0,
db?db->x86_addr:0, db?(db->x86_addr+db->x86_size):0,
Expand All @@ -1060,7 +1059,7 @@ exit(-1);
#warning TODO
#endif
#else
printf_log(log_minimum, "%04d|%s @%p (%s) (x86pc=%p/%s:\"%s\", esp=%p), for accessing %p (code=%d)", GetTID(), signame, pc, name, (void*)x86pc, elfname?elfname:"???", x86name?x86name:"???", esp, addr, info->si_code);
printf_log(log_minimum, "%04d|%s @%p (%s) (x86pc=%p/\"%s\", esp=%p), for accessing %p (code=%d)", GetTID(), signame, pc, name, (void*)x86pc, x86name?x86name:"???", esp, addr, info->si_code);
#endif
if(sig==SIGILL) {
printf_log(log_minimum, " opcode=%02X %02X %02X %02X %02X %02X %02X %02X", ((uint8_t*)pc)[0], ((uint8_t*)pc)[1], ((uint8_t*)pc)[2], ((uint8_t*)pc)[3], ((uint8_t*)pc)[4], ((uint8_t*)pc)[5], ((uint8_t*)pc)[6], ((uint8_t*)pc)[7]);
Expand Down

0 comments on commit 21e9a43

Please sign in to comment.