2

Today, when I wanted to print 8 bytes from a memory address, I entered and received the following


(gdb) x/8x 0x55683298 0x55683298 <_reserved+1036952>: 0xa8 0x32 0x68 0x55 0xec 0x73 0xfc 0xf7 

Last month, if I were to have done the same print command, I would have received a different print format.

0x55683298 <_reserved+1036952>: 0x556832a8 0xf7fc73ec 

How can I get that old printing format back? Also, any ideas as to why it changed?

1 Answer 1

3

How can I get that old printing format back?

(gdb) x/wx 0x55683298 (gdb) help x Examine memory: x/FMT ADDRESS. ADDRESS is an expression for the memory address to examine. FMT is a repeat count followed by a format letter and a size letter. Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal), t(binary), f(float), a(address), i(instruction), c(char), s(string) and z(hex, zero padded on the left). Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes). The specified number of objects of the specified size are printed according to the format. Defaults for format and size letters are those previously used. Default count is 1. Default address is following last thing printed with this command or "print". 

Note in particular the "previously used" part:

(gdb) x/x &main 0x4004ed <main>: 0xe5894855 (gdb) x/c &main 0x4004ed <main>: 85 'U' (gdb) x/x &main 0x4004ed <main>: 0x55 <<=== new default is 'c'! 
Sign up to request clarification or add additional context in comments.

3 Comments

What's the purpose of the change? What was the project trying to fix? (I can't understand why a function pointer would not be best represented by %p).
@jww There was no change. GDB has worked that way for many years. You examined memory in a different way, and that different way is "sticky" in a way you didn't expect.
@jww I just ran it again and it "fixed" itself. Yeah so I must have at some point done "x/8bx", so it stuck.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.