LinuxQuestions.org
Visit Jeremy's Blog.
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 07-20-2005, 05:34 PM   #1
GreyBeard
LQ Newbie
 
Registered: Oct 2003
Location: Taxachusetts, USA
Distribution: Slackware
Posts: 25

Rep: Reputation: 0
Question Backtrace / stack dump for all Linux platforms


Hi,

I have an application I run on multiple platforms. I do not have any
choice over which version or distribution of Linux it is or what other
supporting software is loaded on the machine. Sometimes this
program fails and I need to see what it was doing when it failed.
GDB is nice and the program links to it on machines which have it
but, as I said, I have no control over what any one machine has.

I am therefore looking for backtrace (stack dump) code which I
can build into the program so I can always get a backtrace file from
each failure. Such code *MUST* exist somewhere. For example,
are there SMALLish parts of GDB which I can encorporate into my
program to implement this feature?

Thanks In Advance,
GB
 
Old 07-21-2005, 10:19 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Does your program generates a core file when it fails ?
If true, you can get the backtrace from it.
 
Old 07-21-2005, 10:40 AM   #3
GreyBeard
LQ Newbie
 
Registered: Oct 2003
Location: Taxachusetts, USA
Distribution: Slackware
Posts: 25

Original Poster
Rep: Reputation: 0
No it does not generate a core file, and I don't recall ever
seeing a system call that will make a program do that, tho
there probably is one. Name? If it's Unix/Linux the name
is no doubt weird, like "ls" to view directories or "fgrep" to
search files. Does that call operate on all versions of Linux?

Then, once I have the core file, I presume then I can drag
it back to my machine and attach it to gdb or such, yes?
(Assuming of course it's the same kind of machine.)

TIA,
GreyBeard
 
Old 07-21-2005, 10:50 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
No it does not generate a core file, and I don't recall ever
seeing a system call that will make a program do that, tho
there probably is one. Name? If it's Unix/Linux the name
is no doubt weird, like "ls" to view directories or "fgrep" to
search files. Does that call operate on all versions of Linux?
Well, it's so easy to have a program generating a core, this have happened to zillions of programmers, usually unwanting it ... and not even a system call is required.
Just a divide by zero, a surfing pointer, whatever ...

Quote:
Then, once I have the core file, I presume then I can drag
it back to my machine and attach it to gdb or such, yes?
(Assuming of course it's the same kind of machine.)
This is true.

The problem is you tell the program "fails", but do not details how it does and how you detect it.
Also, is it multi-threaded ?
 
Old 07-21-2005, 11:09 AM   #5
GreyBeard
LQ Newbie
 
Registered: Oct 2003
Location: Taxachusetts, USA
Distribution: Slackware
Posts: 25

Original Poster
Rep: Reputation: 0
The program is very multi-threaded and I need to shut it down gracefully, so I catch exceptions and start the halt process. Usually it's an ACCVIO that signals a problem.
 
Old 07-21-2005, 11:28 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Okay, Unix has had a gcore utility for ages, but only recently was made available a similar feature on Linux, the google coredumper:

http://goog-coredumper.sourceforge.net/
 
Old 07-21-2005, 11:47 AM   #7
GreyBeard
LQ Newbie
 
Registered: Oct 2003
Location: Taxachusetts, USA
Distribution: Slackware
Posts: 25

Original Poster
Rep: Reputation: 0
(a) Thanks for the pointer. That may be just what I need.

(b) Then I wasn't missing something because, until recently, there was nothing there to miss! Does that make sense? :-)

GreyBeard
 
Old 07-21-2005, 12:04 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
You bet !
 
  


Reply


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
Difference b/t Kernel stack and User stack hazzyb Linux - Software 2 09-29-2008 07:40 PM
Firefox/Thunderbird Printing Issues on Linux Platforms Sonomatek Linux - Software 17 05-30-2005 07:25 PM
Dbx stack dump for a C/Proc Code. Help! nathan75 Programming 0 10-13-2004 08:48 AM
dual boot of two linux platforms is it possible? keeknspin Linux - Newbie 1 12-31-2003 06:47 AM
Linux on multiple hardware platforms BobRobertson LinuxQuestions.org Member Success Stories 2 03-18-2003 12:19 AM


All times are GMT -5. The time now is 03:37 PM.

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