Automatically find dupa() address, fix plo() command
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
lif("Loading user init script for program ./test");
|
||||
ler("Test error message");
|
||||
|
||||
var offset = "0x0000000000001169"; // dupa(), objdump -d ./test
|
||||
var offset = "0x0000000000001145"; // dupa(), objdump -d ./test
|
||||
|
||||
// Testing...
|
||||
pf();
|
||||
|
||||
32
.debugusrc1.js.txt
Normal file
32
.debugusrc1.js.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
// User script
|
||||
|
||||
lif("Loading user init script for program ./test");
|
||||
ler("Test error message");
|
||||
|
||||
var offset = "@DUPA_ADDR"; // dupa(), objdump -d ./test
|
||||
|
||||
// Testing...
|
||||
pf();
|
||||
ppid();
|
||||
pplo();
|
||||
baddr(offset);
|
||||
lsbrk();
|
||||
|
||||
lif("1 --------------------------------------------");
|
||||
dr();
|
||||
var r14 = gr("r14");
|
||||
sr("r14", "0x0");
|
||||
lif("2 --------------------------------------------");
|
||||
dr();
|
||||
sr("r14", r14);
|
||||
lif("3 --------------------------------------------");
|
||||
dr();
|
||||
|
||||
var r14_mem = mrdr("r14");
|
||||
lif("Memory at r14 " + r14_mem);
|
||||
mwrr("r14", "0x696969");
|
||||
lif("Memory at r14 " + mrdr("r14"));
|
||||
mwrr("r14", r14_mem);
|
||||
lif("Memory at r14 " + mrdr("r14"));
|
||||
|
||||
// cont();
|
||||
7
Makefile
7
Makefile
@@ -5,7 +5,7 @@ SRCS=debugus.c linenoise.c hash.c pmparser.c
|
||||
OBJS=$(patsubst %.c,%.o,$(SRCS))
|
||||
DEPS=$(patsubst %.c,%.d,$(SRCS))
|
||||
|
||||
all: debugus test
|
||||
all: debugus .debugusrc1.js test
|
||||
|
||||
test: test.o
|
||||
$(CC) -gdwarf -o $@ $^
|
||||
@@ -13,12 +13,15 @@ test: test.o
|
||||
debugus: $(OBJS) ./mujs/build/debug/libmujs.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
.debugusrc1.js: test .debugusrc1.js.txt
|
||||
cat .debugusrc1.js.txt | sed "s/@DUPA_ADDR/0x$$(nm ./test | grep 'dupa' | awk '{ print $$1 }')/g" > .debugusrc1.js
|
||||
|
||||
./mujs/build/debug/libmujs.o:
|
||||
make -C mujs -j$(shell nproc)
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
clean: $(OBJS) $(DEPS)
|
||||
clean: $(OBJS) test.o $(DEPS)
|
||||
rm -f $^
|
||||
make -C mujs clean
|
||||
|
||||
|
||||
@@ -345,7 +345,9 @@ void dbg_js_splo(js_State *js)
|
||||
void dbg_js_plo(js_State *js)
|
||||
{
|
||||
Dbg *dbg = getdbg();
|
||||
js_pushnumber(js, dbg->program_load_offset);
|
||||
char buf[20];
|
||||
snprintf(buf, sizeof(buf), "0x%"PRIxPTR, dbg->program_load_offset);
|
||||
js_pushstring(js, buf);
|
||||
}
|
||||
|
||||
void dbg_js_lsbrk(js_State *js)
|
||||
|
||||
Reference in New Issue
Block a user