debugging madness - user stack mem maps, core files and other wonders
I have an application that is crashing on an custom platform running linux. When it crashes, the kernel nicely prints out *both* the mem map and the stack information for that process.
1) Does anyone know if this can be turned on in other kernels or is this a custom feature in our kernel?
2) Is it possible to retrieve this information from a core file. I see that it's in an ELF format but the standard binutils tools don't give me the info I need (although i might be using them incorrectly). I'm not particularly keen on creating my own tools seeing as i've found no information on the core file format itself.
3) Is it also possible to retrieve the contents of the registers from said core dump as well? particularly the stack pointer.
On a side note:
4) Is it possible to get the prototype from a symbol for a c method. I know you can use c++filt to demangle a c++ method but does c have an equivalent? All I'm interested in is what parameters a particular method symbol has (i.e. method foo has parameters int, int and char). I would guess that nm does not support that but does the binary itself contain this information? Maybe some tool that analyses the machine code to see how many values are pushed on the stack before the program jumps to the method?
Thanks to those that can help answer any of these question (and even those that bothered to read this convoluted post ;).
asking all the hard questions - because someone has to
<gdb> info registers
or to display the contents of the stack pointer
<gdb> p $esp
<gdb> p $rsp
(The first command is for 32-bit stack pointers, while the second one is for 64-bit stack pointers)
Yes, you can! :) As a prerequsite, you would require to compile your program with debug information (-g), but then you could issue this gdb command to see the function parameters:
<gdb> ptype <func_name>
type = int (int, int, char)
I hope that answers most of your questions ...
- Andi -
|All times are GMT -5. The time now is 10:08 PM.|