ソースを参照

Add frame info for x64 GDB JIT API.

Mike Pall 15 年 前
コミット
956065fd04
2 ファイル変更12 行追加3 行削除
  1. 3 0
      src/lj_frame.h
  2. 9 3
      src/lj_gdbjit.c

+ 3 - 0
src/lj_frame.h

@@ -66,6 +66,7 @@ enum {
 #define CFRAME_OFS_PC		(6*4)
 #define CFRAME_OFS_PC		(6*4)
 #define CFRAME_OFS_MULTRES	(5*4)
 #define CFRAME_OFS_MULTRES	(5*4)
 #define CFRAME_SIZE		(12*4)
 #define CFRAME_SIZE		(12*4)
+#define CFRAME_SIZE_JIT		CFRAME_SIZE
 #elif LJ_TARGET_X64
 #elif LJ_TARGET_X64
 #if _WIN64
 #if _WIN64
 #define CFRAME_OFS_PREV		(13*8)
 #define CFRAME_OFS_PREV		(13*8)
@@ -75,6 +76,7 @@ enum {
 #define CFRAME_OFS_NRES		(22*4)
 #define CFRAME_OFS_NRES		(22*4)
 #define CFRAME_OFS_MULTRES	(21*4)
 #define CFRAME_OFS_MULTRES	(21*4)
 #define CFRAME_SIZE		(10*8)
 #define CFRAME_SIZE		(10*8)
+#define CFRAME_SIZE_JIT		(CFRAME_SIZE + 9*16 + 4*8)
 #else
 #else
 #define CFRAME_OFS_PREV		(4*8)
 #define CFRAME_OFS_PREV		(4*8)
 #define CFRAME_OFS_PC		(7*4)
 #define CFRAME_OFS_PC		(7*4)
@@ -83,6 +85,7 @@ enum {
 #define CFRAME_OFS_NRES		(4*4)
 #define CFRAME_OFS_NRES		(4*4)
 #define CFRAME_OFS_MULTRES	(1*4)
 #define CFRAME_OFS_MULTRES	(1*4)
 #define CFRAME_SIZE		(10*8)
 #define CFRAME_SIZE		(10*8)
+#define CFRAME_SIZE_JIT		(CFRAME_SIZE + 16)
 #endif
 #endif
 #else
 #else
 #error "Missing CFRAME_* definitions for this architecture"
 #error "Missing CFRAME_* definitions for this architecture"

+ 9 - 3
src/lj_gdbjit.c

@@ -528,7 +528,13 @@ static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx)
     DB(DW_CFA_offset|DW_REG_SI); DUV(4);
     DB(DW_CFA_offset|DW_REG_SI); DUV(4);
     DB(DW_CFA_offset|DW_REG_BX); DUV(5);
     DB(DW_CFA_offset|DW_REG_BX); DUV(5);
 #elif LJ_TARGET_X64
 #elif LJ_TARGET_X64
-    /* Add saved registers for x64 CFRAME. */
+    DB(DW_CFA_offset|DW_REG_BP); DUV(2);
+    DB(DW_CFA_offset|DW_REG_BX); DUV(3);
+    DB(DW_CFA_offset|DW_REG_15); DUV(4);
+    DB(DW_CFA_offset|DW_REG_14); DUV(5);
+    /* Extra registers saved for JIT-compiled code. */
+    DB(DW_CFA_offset|DW_REG_13); DUV(9);
+    DB(DW_CFA_offset|DW_REG_12); DUV(10);
 #else
 #else
 #error "Unsupported target architecture"
 #error "Unsupported target architecture"
 #endif
 #endif
@@ -703,8 +709,8 @@ void lj_gdbjit_addtrace(jit_State *J, Trace *T, TraceNo traceno)
   ctx.T = T;
   ctx.T = T;
   ctx.mcaddr = (uintptr_t)T->mcode;
   ctx.mcaddr = (uintptr_t)T->mcode;
   ctx.szmcode = T->szmcode;
   ctx.szmcode = T->szmcode;
-  ctx.spadjp = CFRAME_SIZE + (MSize)(parent ? J->trace[parent]->spadjust : 0);
-  ctx.spadj = CFRAME_SIZE + T->spadjust;
+  ctx.spadjp = CFRAME_SIZE_JIT + (MSize)(parent?J->trace[parent]->spadjust:0);
+  ctx.spadj = CFRAME_SIZE_JIT + T->spadjust;
   ctx.lineno = proto_line(pt, proto_bcpos(pt, startpc));
   ctx.lineno = proto_line(pt, proto_bcpos(pt, startpc));
   ctx.filename = strdata(proto_chunkname(pt));
   ctx.filename = strdata(proto_chunkname(pt));
   if (*ctx.filename == '@' || *ctx.filename == '=')
   if (*ctx.filename == '@' || *ctx.filename == '=')