How can I make gdb print unprintable characters of a string in hex instead of octal while preserving the ascii characters in ascii form?

前端 未结 3 1369
忘了有多久
忘了有多久 2021-02-12 10:11

Suppose I have a buffer buf whose c string representation is

 char* buf = \"Hello World \\x1c\"

When I print this buf in gdb using

3条回答
  •  误落风尘
    2021-02-12 11:06

    You might use the x command to dump the memory your char-pointer points to:

    (gdb) x/32xb buf
    

    shows the first 32 bytes.

    See

    (gdb) help x
    

    for details.

提交回复
热议问题