mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Add popc_stack command to gdb
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user