diff --git a/src/Makefile.dep b/src/Makefile.dep index aeeeeff5..22eb56b0 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -68,7 +68,7 @@ lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_state.h lj_frame.h lj_bc.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ lj_traceerr.h lj_vm.h lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ - lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_frame.h lj_bc.h lj_jit.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_frame.h lj_bc.h lj_jit.h \ lj_ir.h lj_dispatch.h lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ diff --git a/src/lj_gdbjit.c b/src/lj_gdbjit.c index dc85c076..30aab774 100644 --- a/src/lj_gdbjit.c +++ b/src/lj_gdbjit.c @@ -12,7 +12,6 @@ #include "lj_gc.h" #include "lj_err.h" -#include "lj_str.h" #include "lj_frame.h" #include "lj_jit.h" #include "lj_dispatch.h" @@ -385,7 +384,6 @@ typedef struct GDBJITctx { MSize spadj; /* Stack adjustment for trace itself. */ BCLine lineno; /* Starting line number. */ const char *filename; /* Starting file name. */ - const char *trname; /* Name of trace. */ size_t objsize; /* Final size of ELF object. */ GDBJITobj obj; /* In-memory ELF object. */ } GDBJITctx; @@ -402,6 +400,13 @@ static uint32_t gdbjit_strz(GDBJITctx *ctx, const char *str) return ofs; } +/* Append a decimal number. */ +static void gdbjit_catnum(GDBJITctx *ctx, uint32_t n) +{ + if (n >= 10) { uint32_t m = n / 10; n = n % 10; gdbjit_catnum(ctx, m); } + *ctx->p++ = '0' + n; +} + /* Add a ULEB128 value. */ static void gdbjit_uleb128(GDBJITctx *ctx, uint32_t v) { @@ -488,7 +493,8 @@ static void LJ_FASTCALL gdbjit_symtab(GDBJITctx *ctx) sym->info = ELFSYM_TYPE_FILE|ELFSYM_BIND_LOCAL; sym = &ctx->obj.sym[GDBJIT_SYM_FUNC]; - sym->name = gdbjit_strz(ctx, ctx->trname); + sym->name = gdbjit_strz(ctx, "TRACE_"); ctx->p--; + gdbjit_catnum(ctx, ctx->T->traceno); *ctx->p++ = '\0'; sym->sectidx = GDBJIT_SECT_text; sym->value = 0; sym->size = ctx->szmcode; @@ -701,7 +707,6 @@ static void gdbjit_newentry(lua_State *L, GDBJITctx *ctx) void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) { GDBJITctx ctx; - lua_State *L = J->L; GCproto *pt = &gcref(T->startpt)->pt; TraceNo parent = T->ir[REF_BASE].op1; uintptr_t pcofs = (uintptr_t)(T->snap[0].mapofs+T->snap[0].nent); @@ -721,10 +726,8 @@ void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) ctx.filename++; else ctx.filename = "(string)"; - ctx.trname = lj_str_pushf(L, "TRACE_%d", T->traceno); - L->top--; gdbjit_buildobj(&ctx); - gdbjit_newentry(L, &ctx); + gdbjit_newentry(J->L, &ctx); } /* Delete debug info for trace and notify GDB. */