8

Inside gdb to print the content at a particular memory address, I can ran the below command. It prints the content in hex

x <memoryaddress>

(gdb) x 299395816
0x11d86ae8: 0x0ec14153

I am using the gdb python module inside the gdb, what's the equivalent command to read the memory location with the gdb module inside my python script.

1 Answer 1

11

I guess inferior is what you want:

(gdb) python i = gdb.inferiors()[0]
(gdb) python m = i.read_memory(0x7fffffffe39c, 4) # an int32
(gdb) python print(m.tobytes())
b'\x01\x00\x00\x00'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.