开发者

Print characters from a void* in gdb

I have a void* and I think there's a string nearby, somewhere within the next few bytes, b开发者_开发技巧ut I'm not sure where. I don't know have any other knowledge of the what's nearby in memory, including whether there are 0s, so casting to char* isn't what I want. How can I print the next 20 bytes from this pointer as characters?


Use the “x“ command to display the memory contents at a given address using the specified format.

Syntax:

    x [Address expression]
    x /[Format] [Address expression]
    x /[Length][Format] [Address expression]

Dumps 20 bytes as characters:

    x/20c voidptr

Dumps 20 bytes as hex:

    x/20x voidptr

See GDB command reference for x command

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜