about summary refs log tree commit diff stats
path: root/src/dynarec/dynarec_native.c
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2024-12-18 05:01:33 +0800
committerGitHub <noreply@github.com>2024-12-17 22:01:33 +0100
commit6e0f32f4ca4b35bda036caa6ad3abcae4ae64cdc (patch)
tree39a144624b528deba4421d7b71098db69d99eb80 /src/dynarec/dynarec_native.c
parent62eca11beef3f211a93235b18d556332fafc74de (diff)
downloadbox64-6e0f32f4ca4b35bda036caa6ad3abcae4ae64cdc.tar.gz
box64-6e0f32f4ca4b35bda036caa6ad3abcae4ae64cdc.zip
Added initial GDBJIT support (#2162)
* Added GDBJIT support

* fix

* fix
Diffstat (limited to 'src/dynarec/dynarec_native.c')
-rw-r--r--src/dynarec/dynarec_native.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dynarec/dynarec_native.c b/src/dynarec/dynarec_native.c
index ece7baa0..011815bc 100644
--- a/src/dynarec/dynarec_native.c
+++ b/src/dynarec/dynarec_native.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -22,6 +23,7 @@
 #include "dynarec_native.h"
 #include "dynarec_arch.h"
 #include "dynarec_next.h"
+#include "gdbjit.h"
 
 void printf_x64_instruction(zydis_dec_t* dec, instruction_x64_t* inst, const char* name) {
     uint8_t *ip = (uint8_t*)inst->addr;
@@ -574,6 +576,9 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
     protectDB(addr, 1);
     // init the helper
     dynarec_native_t helper = {0};
+#ifdef GDBJIT
+    helper.gdbjit_block = box_calloc(1, sizeof(gdbjit_block_t));
+#endif
     current_helper = &helper;
     helper.dynablock = block;
     helper.start = addr;
@@ -748,6 +753,9 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
         printFunctionAddr(helper.start, " => ");
         dynarec_log(LOG_NONE, "%s\n", (box64_dynarec_dump>1)?"\e[m":"");
     }
+    if (box64_dynarec_gdbjit) {
+        GdbJITNewBlock(helper.gdbjit_block, (GDB_CORE_ADDR)block->actual_block, (GDB_CORE_ADDR)block->actual_block + native_size);
+    }
     int oldtable64size = helper.table64size;
     size_t oldnativesize = helper.native_size;
     size_t oldinstsize = helper.insts_size;
@@ -782,6 +790,9 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr, int alternate, int is32bit
     //block->x64_addr = (void*)start;
     block->x64_size = end-start;
     // all done...
+    if (box64_dynarec_gdbjit) {
+        GdbJITBlockReady(helper.gdbjit_block);
+    }
     __clear_cache(actual_p, actual_p+sz);   // need to clear the cache before execution...
     block->hash = X31_hash_code(block->x64_addr, block->x64_size);
     // Check if something changed, to abort if it is