Newbie question: how to get the stack trace from a dump file
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Newbie question: how to get the stack trace from a dump file




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Newbie question: how to get the stack trace from a dump file  
usgog@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-17-05 10:57 PM

I am a newbie to Linux and just got a core dump file for my program.
The error is segmentation fault. So how to get the stack trace out of
the dump file? I used gdb -> 'core-file mycorefile' -> 'where' and it
returns 'Can't access memory at address 0x...'. Do I need any other
files for gdb to output the stack trace? Please advise.






[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
Loic Domaigne


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-17-05 10:57 PM

Hello,

> I am a newbie to Linux and just got a core dump file for my program.
> The error is segmentation fault. So how to get the stack trace out of
> the dump file? I used gdb -> 'core-file mycorefile' -> 'where' and it
> returns 'Can't access memory at address 0x...'. Do I need any other
> files for gdb to output the stack trace? Please advise.

Compile your program with the flag -g (debugging symbols)

Run then gdb as follows:
bash$ gdb name_of_your_binary name_of_your_core

and then type 'where', followed eventually by the command 'bt' if the
command 'where' wasn't explicit enough.

Cheers,
Loic.






[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-17-05 10:57 PM

usgog@yahoo.com writes:

> Do I need any other
> files for gdb to output the stack trace?

No.

Some versions of gdb have difficulties with core files on some
platforms, especially if the executable is multithreaded.

Try running your program under gdb from the start, or try a different
version of gdb.

If neither of the above helps, tell us what platform you are on,
what version of gdb you are using. Some details about the app may
come in handy as well.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.





[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-17-05 10:57 PM

Loic Domaigne <loic-dev@gmx.net> writes:

> Run then gdb as follows:
> bash$ gdb name_of_your_binary name_of_your_core

This is exactly equivalent to:

gdb name_of_your_binary
(gdb) core name_of_your_core

which is what OP has apparently already done.

> and then type 'where', followed eventually by the command 'bt' if the
> command 'where' wasn't explicit enough.

The 'where' and 'bt' are exact synonyms.
Are you saying they sometimes produce different output?
Could you perhaps demonstrate that?

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.





[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
Måns Rullgård


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-17-05 10:57 PM

Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> writes:

> usgog@yahoo.com writes:
> 
>
> No.
>
> Some versions of gdb have difficulties with core files on some
> platforms, especially if the executable is multithreaded.
>
> Try running your program under gdb from the start, or try a different
> version of gdb.

In my experience, gdb more often has problems running a multithreaded
program than examining a core dump from one.

--
Måns Rullgård
mru@inprovide.com





[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-18-05 01:48 AM


"Måns Rullgård" <mru@inprovide.com> wrote in message
news:yw1xy8admooa.fsf@ford.inprovide.com...

> Paul Pluzhnikov <ppluzhnikov-nsp@charter.net> writes:
 
[vbcol=seagreen]
> In my experience, gdb more often has problems running a multithreaded
> program than examining a core dump from one.

And you can always catch SIGBUS, SIGSEFV, SIGILL, SIGFPE and in the
handler, call 'fork' and then 'abort' in the child. On some operating
systems, you may need to invoke the 'fork' system call directly as it may
otherwise be unsafe to call 'fork' in a signal handler.

This breaks some rules, but it may work for you. And, obviously, once
you've encountered a fatal signal, you can't keep going anyway.

DS







[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
David Resnick


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-18-05 12:53 PM


Paul Pluzhnikov wrote:
> Loic Domaigne <loic-dev@gmx.net> writes:
> 
>
> This is exactly equivalent to:
>
>   gdb name_of_your_binary
>   (gdb) core name_of_your_core
>
> which is what OP has apparently already done.
>

Nope.  Looking at OP's message, he said
[vbcol=seagreen] 

Looks like he invoked gdb without indicating
the binary name and that was his issue.

-David






[ Post a follow-up to this message ]



    Re: Newbie question: how to get the stack trace from a dump file  
loic-dev@gmx.net


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-19-05 12:48 PM

Salut Paul,
 
the[vbcol=seagreen] 
>
> The 'where' and 'bt' are exact synonyms.
> Are you saying they sometimes produce different output?
> Could you perhaps demonstrate that?

In my mind, 'where' wouldn't show the stack trace. But I've been
mistaken.

Loic.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:26 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register