LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-15-2009, 04:06 PM   #1
kubaPL
LQ Newbie
 
Registered: Apr 2009
Location: Poland
Distribution: Fedora
Posts: 6

Rep: Reputation: 0
debugging madness - user stack mem maps, core files and other wonders


Hi all,

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 .

Regards,
kuba

------------------------------------------------------
asking all the hard questions - because someone has to

Last edited by kubaPL; 12-15-2009 at 04:24 PM.
 
Old 12-20-2009, 07:54 AM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by kubaPL View Post
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?
I would assume that you could somehow enable this feature, especially if you're using a vanilla Linux kernel. But I don't know how ... Sorry. (If you're using a Linux kernel shipped with your distro, this might not necessarily be available in the vanilla kernel!)

Quote:
Originally Posted by kubaPL View Post
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.
Yes, you could examine a core file with GDB (GNU Debugger).

Quote:
Originally Posted by kubaPL View Post
3) Is it also possible to retrieve the contents of the registers from said core dump as well? particularly the stack pointer.
Yes, that's also possible with GDB. To display the contents of all registers, use

<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)

Quote:
Originally Posted by kubaPL View Post
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?
Basically, C does not use name mangling and you can't retrieve the function type from the function name like in C++.

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 -
 
1 members found this post helpful.
  


Reply

Tags
crash, debug, kernel, stack


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] POSTFIX - virtual domain and alias maps results in 'unknown user' brenton.williams Linux - Server 2 08-19-2009 12:32 AM
Difference b/t Kernel stack and User stack hazzyb Linux - Software 2 09-29-2008 07:40 PM
Debugging with gdb, core.xxxx files, howto? GlennsPref Linux - Software 3 01-12-2006 07:55 PM
Help debugging with gdb and core files moon.es Programming 1 05-28-2005 04:58 AM
dependency madness with .deb files zvonSully Debian 2 03-18-2005 06:27 AM


All times are GMT -5. The time now is 01:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration