mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[scripts] Improve gdb script stack handling
When setting a radix other than 10, the j6stack command will start adding the wrong values - make sure to specify a radix for the offset explicitly. Also show the frame pointer for each frame with the j6bt command, and don't throw exceptions if the name of the block is unknown.
This commit is contained in:
@@ -19,7 +19,7 @@ class PrintStackCommand(gdb.Command):
|
|||||||
try:
|
try:
|
||||||
offset = i * 8
|
offset = i * 8
|
||||||
base_addr = gdb.parse_and_eval(base)
|
base_addr = gdb.parse_and_eval(base)
|
||||||
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + {offset})")
|
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + 0x{offset:x})")
|
||||||
print("{:016x} (+{:04x}): {:016x}".format(int(base_addr) + offset, offset, int(value)))
|
print("{:016x} (+{:04x}): {:016x}".format(int(base_addr) + offset, offset, int(value)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
@@ -41,17 +41,22 @@ class PrintBacktraceCommand(gdb.Command):
|
|||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
frame = args[1]
|
frame = args[1]
|
||||||
|
|
||||||
|
frame = gdb.parse_and_eval(f"{frame}")
|
||||||
|
|
||||||
for i in range(depth-1, -1, -1):
|
for i in range(depth-1, -1, -1):
|
||||||
ret = gdb.parse_and_eval(f"*(uint64_t*)({frame} + 8)")
|
ret = gdb.parse_and_eval(f"*(uint64_t*)({frame} + 0x8)")
|
||||||
frame = gdb.parse_and_eval(f"*(uint64_t*)({frame})")
|
|
||||||
|
|
||||||
name = ""
|
name = ""
|
||||||
|
try:
|
||||||
block = gdb.block_for_pc(int(ret))
|
block = gdb.block_for_pc(int(ret))
|
||||||
if block:
|
if block:
|
||||||
name = block.function or ""
|
name = block.function or ""
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
print("{:016x} {}".format(int(ret), name))
|
print("{:016x}: {:016x} {}".format(int(frame), int(ret), name))
|
||||||
|
|
||||||
|
frame = gdb.parse_and_eval(f"*(uint64_t*)({frame})")
|
||||||
if frame == 0 or ret == 0:
|
if frame == 0 or ret == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user