Skip to content

Commit 3a34ee2

Browse files
committed
riscv(jit): add GDBJIT support
1 parent 00f750a commit 3a34ee2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lj_gdbjit.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ enum {
306306
#elif LJ_TARGET_MIPS
307307
DW_REG_SP = 29,
308308
DW_REG_RA = 31,
309+
#elif LJ_TARGET_RISCV64
310+
DW_REG_SP = 2,
311+
DW_REG_RA = 1,
309312
#else
310313
#error "Unsupported target architecture"
311314
#endif
@@ -383,6 +386,8 @@ static const ELFheader elfhdr_template = {
383386
.machine = 20,
384387
#elif LJ_TARGET_MIPS
385388
.machine = 8,
389+
#elif LJ_TARGET_RISCV64
390+
.machine = 243,
386391
#else
387392
#error "Unsupported target architecture"
388393
#endif
@@ -591,6 +596,16 @@ static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx)
591596
for (i = 23; i >= 16; i--) { DB(DW_CFA_offset|i); DUV(26-i); }
592597
for (i = 30; i >= 20; i -= 2) { DB(DW_CFA_offset|32|i); DUV(42-i); }
593598
}
599+
#elif LJ_TARGET_RISCV64
600+
{
601+
int i;
602+
for (i = 27; i >= 18; i--) { DB(DW_CFA_offset|i); DUV(27-i+7); }
603+
DB(DW_CFA_offset|9); DUV(17);
604+
DB(DW_CFA_offset|8); DUV(18);
605+
for (i = 27; i >= 18; i--) { DB(DW_CFA_offset|32|i); DUV(27-i+19); }
606+
DB(DW_CFA_offset|32|9); DUV(29);
607+
DB(DW_CFA_offset|32|8); DUV(30);
608+
}
594609
#else
595610
#error "Unsupported target architecture"
596611
#endif

0 commit comments

Comments
 (0)