mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
30 lines
692 B
Python
30 lines
692 B
Python
import gdb
|
|
|
|
class PrintStackCommand(gdb.Command):
|
|
def __init__(self):
|
|
super().__init__("popc_stack", gdb.COMMAND_DATA)
|
|
|
|
def invoke(self, arg, from_tty):
|
|
args = gdb.string_to_argv(arg)
|
|
|
|
base = "$rsp"
|
|
if len(args) > 0:
|
|
base = args[0]
|
|
|
|
depth = 22
|
|
if len(args) > 1:
|
|
depth = int(args[1])
|
|
|
|
for i in range(depth-1, -1, -1):
|
|
offset = i * 8
|
|
value = gdb.parse_and_eval(f"*(uint64_t*)({base} + {offset})")
|
|
print("{:04x}: {:016x}".format(offset, int(value)))
|
|
|
|
|
|
PrintStackCommand()
|
|
|
|
import time
|
|
time.sleep(3.5)
|
|
gdb.execute("target remote :1234")
|
|
gdb.execute("set waiting = false")
|