about summary refs log tree commit diff stats
path: root/src/tools/perfmap.c
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-04-10 18:14:50 +0800
committerGitHub <noreply@github.com>2025-04-10 12:14:50 +0200
commitf9f082ee53ae0ab8e12b0c1bf1de339af8b92282 (patch)
treeb040c5f88bf691cc67f7fc1bd9c8b4914ea4758b /src/tools/perfmap.c
parent66bb1aeb89d7ee64cad83ab12208b221ce5e9731 (diff)
downloadbox64-f9f082ee53ae0ab8e12b0c1bf1de339af8b92282.tar.gz
box64-f9f082ee53ae0ab8e12b0c1bf1de339af8b92282.zip
[WOW64] More work on the PE wow64 build (#2518)
* [WOW64] More work on the PE wow64 build

* added a TODO
Diffstat (limited to 'src/tools/perfmap.c')
-rw-r--r--src/tools/perfmap.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/perfmap.c b/src/tools/perfmap.c
new file mode 100644
index 00000000..c3a9d0e3
--- /dev/null
+++ b/src/tools/perfmap.c
@@ -0,0 +1,21 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <assert.h>
+
+#include "debug.h"
+#include "box64context.h"
+#include "perfmap.h"
+#include "elfloader.h"
+
+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:%s\n", code_addr, code_size, symbname, inst_name);
+    write(BOX64ENV(dynarec_perf_map_fd), pbuf, strlen(pbuf));
+}