
On 23.07.12 23:26, Russell Coker wrote:
I have a multi-threaded program that has just SEGV'd. I want to extract a chunk of data from the program to run in a test program to try and reproduce the problem.
Is there a way of telling gdb to dump a chunk of data to a file?
The data in question is a regular C string. I tried using p fopen() but it seems that you can't do that sort of thing in a multi-threaded program. p open() fails and I can't work out why.
It normally should be possible to print the contents of C variables by name, without manually working out where they are, but the multiple characters of a string might need "x <addr>/17b, if there are 17 characters. I don't remember the neatest way to dump strings, sorry. Here is an excerpt of my notes from using gdb with embedded targets over the years: (gdb) print EXPR # EXPR = Any source language constant, variable or operator. # Includes conditional expressions, function calls, # casts, and string constants. Special EXPR syntax: # FILE::VARIABLE # FUNCTION::VARIABLE (gdb) help print # Gives a bit of info, but nothing on strings. Or Examine memory: (gdb) x 0x8000cc # Examine avr I/O register 0xcc 0x8000cc: 0x22 # xb does same. x/8xw = display 8 hex words. (gdb) set *0x8000cc=0x11 # Setting memory. (gdb) xb 0x8000cc 0x8000cc: 0x11 (gdb) show register # Show cpu register contents. (gdb) disassemble 0x00010003 # Disassemble code. If it doesn't work for you, I'll try it out on a bit of native C, to check what still works for me now, but it's midnight, and I've neglected the fire in the wood heater at this stage. I never did come across any comprehensive gdb documentation, so have just made do with fragments stitched together. Erik -- manual, n.: A unit of documentation. There are always three or more on a given item. One is on the shelf; someone has the others. The information you need is in the others. - Ray Simard