Skip to content

Commit

Permalink
[DYNAREC] Appended instruction name to symbol (#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangzhai authored Jan 3, 2025
1 parent da6b799 commit 4065e61
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ void LoadLogEnv()
box64_dynarec_perf_map = p[0] - '0';
}
if (box64_dynarec_perf_map)
printf_log(LOG_INFO, "Dynarec will generate map file for Linux perf tool\n");
printf_log(LOG_INFO, "Dynarec will generate map file /tmp/perf-%d.map for Linux perf tool\n", getpid());
}
p = getenv("BOX64_DYNAREC_DF");
if(p) {
Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/arm64/dynarec_arm64_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void inst_name_pass3(dynarec_native_t* dyn, int ninst, const char* name, rex_t r
dyn->gdbjit_block = GdbJITBlockAddLine(dyn->gdbjit_block, (dyn->native_start + dyn->insts[ninst].address), inst_name);
}
if (box64_dynarec_perf_map && box64_dynarec_perf_map_fd != -1) {
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4);
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4, name);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/dynarec/dynarec_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,12 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
return (void*)block;
}

void writePerfMap(uintptr_t func_addr, uintptr_t code_addr, size_t code_size)
void writePerfMap(uintptr_t func_addr, uintptr_t code_addr, size_t code_size, const char* inst_name)
{
char pbuf[128];
uint64_t sz = 0;
uintptr_t start = 0;
const char* symbname = FindNearestSymbolName(FindElfAddress(my_context, func_addr), (void*)func_addr, &start, &sz);
snprintf(pbuf, sizeof(pbuf), "0x%lx %ld %s\n", code_addr, code_size, symbname);
snprintf(pbuf, sizeof(pbuf), "0x%lx %ld %s:%s\n", code_addr, code_size, symbname, inst_name);
write(box64_dynarec_perf_map_fd, pbuf, strlen(pbuf));
}
2 changes: 1 addition & 1 deletion src/dynarec/la64/dynarec_la64_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void inst_name_pass3(dynarec_native_t* dyn, int ninst, const char* name, rex_t r
dyn->gdbjit_block = GdbJITBlockAddLine(dyn->gdbjit_block, (dyn->native_start + dyn->insts[ninst].address), inst_name);
}
if (box64_dynarec_perf_map && box64_dynarec_perf_map_fd != -1) {
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4);
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4, name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dynarec/rv64/dynarec_rv64_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void inst_name_pass3(dynarec_native_t* dyn, int ninst, const char* name, rex_t r
dyn->gdbjit_block = GdbJITBlockAddLine(dyn->gdbjit_block, (dyn->native_start + dyn->insts[ninst].address), inst_name);
}
if (box64_dynarec_perf_map && box64_dynarec_perf_map_fd != -1) {
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4);
writePerfMap(dyn->insts[ninst].x64.addr, dyn->native_start + dyn->insts[ninst].address, dyn->insts[ninst].size / 4, name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/include/dynarec_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ void addInst(instsize_t* insts, size_t* size, int x64_size, int native_size);
void CancelBlock64(int need_lock);
void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bits);

void writePerfMap(uintptr_t func_addr, uintptr_t code_addr, size_t code_size);
void writePerfMap(uintptr_t func_addr, uintptr_t code_addr, size_t code_size, const char* inst_name);

#endif //__DYNAREC_ARM_H_

0 comments on commit 4065e61

Please sign in to comment.