daisy
daisy

Reputation: 23501

How should i view stack data of a specific address in GDB?

Simple c source code to execute a program:

int main ( int argc , char **argv )                                                                                                                          
{                                                                                                                                                            
        system ("XXXX");                                                                                                                           
        return 0;                                                                                                                                            
} 

Now compile it and debug with gdb , and i tried to view what address of "XXX" actually represents by using p command , but got an void , am i doing it wrong ?

enter image description here

Upvotes: 0

Views: 1493

Answers (2)

Employed Russian
Employed Russian

Reputation: 213526

If you want to examine a string located at address 0x40063c, use the GDB examine command:

(gdb) x/s 0x40063c

Note that this data is not on the stack. You can find out where that data is with info symbol command:

(gdb) info sym 0x40063c

(this should print something like symbol LC1 in .rodata of a.out)

Upvotes: 1

ugoren
ugoren

Reputation: 16441

You shouldn't use the $ character - it's part of assembly syntax, but not of gdb syntax.
And the "x" command is easier to use if you simply want to see the memory:

(gdb) p/s 0x40063c

You can also use p/x to show in hex format, and there are lots of other variations.

Upvotes: 1

Related Questions