c - GDB print all values in char array -



c - GDB print all values in char array -

i storing various filenames in array partitioned null bytes. when debugging, able see first filename. so, instance if array this: hello.txt00000hello2.txt, able see hello.txt. how can print entire array? have problem finding such command elsewhere.

you can utilize x/999bc, 999 size of array, instance:

paul@thoth:~/src/sandbox$ gdb ./str gnu gdb (gdb) 7.4.1-debian copyright (c) 2012 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free alter , redistribute it. there no warranty, extent permitted law. type "show copying" , "show warranty" details. gdb configured "x86_64-linux-gnu". bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... reading symbols /home/paul/src/sandbox/str...done. (gdb) list 1 int main(void) { 2 char * p = "hello\0world\0hahaha"; 3 homecoming 0; 4 } 5 (gdb) b 3 breakpoint 1 @ 0x4004b8: file str.c, line 3. (gdb) run starting program: /home/paul/src/sandbox/str breakpoint 1, main () @ str.c:3 3 homecoming 0; (gdb) print p $1 = 0x40056c "hello" (gdb) x/19bc p 0x40056c: 104 'h' 101 'e' 108 'l' 108 'l' 111 'o' 0 '\000' 119 'w' 111 'o' 0x400574: 114 'r' 108 'l' 100 'd' 0 '\000' 104 'h' 97 'a' 104 'h' 97 'a' 0x40057c: 104 'h' 97 'a' 0 '\000' (gdb)

c gdb

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -