mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[tools] Improve j6stack GDB command
Improve the j6stack command in two ways: first, swap the order of the arguments, as depth is much more likely to be changed. Second, on any exception accessing memory in the stack, print the exception and continue instead of failing the whole command.
This commit is contained in:
@@ -16,10 +16,14 @@ class PrintStackCommand(gdb.Command):
|
|||||||
depth = int(args[1])
|
depth = int(args[1])
|
||||||
|
|
||||||
for i in range(depth-1, -1, -1):
|
for i in range(depth-1, -1, -1):
|
||||||
offset = i * 8
|
try:
|
||||||
base_addr = gdb.parse_and_eval(base)
|
offset = i * 8
|
||||||
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + {offset})")
|
base_addr = gdb.parse_and_eval(base)
|
||||||
print("{:016x} (+{:04x}): {:016x}".format(int(base_addr) + offset, offset, int(value)))
|
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + {offset})")
|
||||||
|
print("{:016x} (+{:04x}): {:016x}".format(int(base_addr) + offset, offset, int(value)))
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
class PrintBacktraceCommand(gdb.Command):
|
class PrintBacktraceCommand(gdb.Command):
|
||||||
@@ -29,13 +33,13 @@ class PrintBacktraceCommand(gdb.Command):
|
|||||||
def invoke(self, arg, from_tty):
|
def invoke(self, arg, from_tty):
|
||||||
args = gdb.string_to_argv(arg)
|
args = gdb.string_to_argv(arg)
|
||||||
|
|
||||||
frame = "$rbp"
|
|
||||||
if len(args) > 0:
|
|
||||||
frame = args[0]
|
|
||||||
|
|
||||||
depth = 30
|
depth = 30
|
||||||
|
if len(args) > 0:
|
||||||
|
depth = int(args[0])
|
||||||
|
|
||||||
|
frame = "$rbp"
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
depth = int(args[1])
|
frame = args[1]
|
||||||
|
|
||||||
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} + 8)")
|
||||||
|
|||||||
Reference in New Issue
Block a user