Importing debug information into dbx
Thoughts on developer tools.

All | Dbx | Development Tools | Life in General | OpenSolaris | plus | Software Philosophy | Sun Studio

fav comics

« The story of lazy... | Main | Sun Studio 11, less... »
20051114 Monday November 14, 2005

Importing debug information into dbx I'm sure I wrote this up somewhere before, but now I can't find it. Just in case you guys (my two faithful readers) haven't seen this trick yet. If you are stuck with a core file that doesn't have debug information, you can "import" debugging information using the "loadobject -load" command. It's especially useful for C++ to help get rid of the mangled names that show up in stack traces.

% #########################
% more t.c

#include "t.h"

struct foo foofoo;

int
main()
{
foofoo.a = 1;
foofoo.b = 2;
* (int *) 0 = 0;
}

% #########################
% more t.h

struct foo {
int a;
int b;
};

% #########################
% cc -o t t.c # no debug info

% #########################
% ./t
Segmentation Fault (core dumped)

% #########################
% dbx t core
Reading t
core file header read successfully
Reading ld.so.1
Reading libc.so.1
Reading libdl.so.1
Reading libc_psr.so.1
program terminated by signal SEGV (no mapping at the fault address)
0x00010bb4: main+0x001c: clr [0]
(dbx) whatis foofoo
dbx: warning: unknown language, 'c' assumed
(int {assumed}) foofoo;
(dbx) print foofoo
foofoo = 0x1
(dbx) whatis -t foo
dbx: "foo" is not defined in the scope `t`main`
dbx: see `help scope' for details
(dbx) quit

% #
% # You really want to see the contents of the 'foofoo'
% # structure, but the binary doesn't have debug info!
% # So create a dummy .so file with debug info, and load
% # that into dbx manually.
% #

% #########################
% more dummy.c

#include "t.h"

% #########################
% cc -G -g -o dummy.so dummy.c

% #########################
% dbx t core
Reading t
core file header read successfully
Reading ld.so.1
Reading libc.so.1
Reading libdl.so.1
Reading libc_psr.so.1
program terminated by signal SEGV (no mapping at the fault address)
0x00010bb4: main+0x001c: clr [0]
(dbx) loadobject -load dummy.so
Reading dummy.so
Loaded loadobject: /set/dbx/somewhere/misc/coretest/dummy.so
(dbx) modules | grep dummy
Not Read dummy.o
(dbx) module dummy.o
Read dummy.o
(dbx) whatis -t foo
struct foo {
int a;
int b;
};
(dbx) print *(struct foo*)&foofoo
dbx: warning: unknown language, 'c' assumed
*((struct foo *) &foofoo) = {
a = 0x1
b = 0x2
}


Posted by Chris Quenelle ( Nov 14 2005, 07:28:22 PM PST ) - Permalink - Comments [5] -

Comments:

Hi Chris, May I ask a few dbx questions? I am using Sun Dbx Debugger 7.5. My program X is very large and involves lots of source files, the X is an executable with debugging information (build using g++ with -gdwarf-2 option) on Solaris 2.8. X's size is more than 1GB. I got thousands of warning messages "dbx: warning: Too many #included source files near LocalInitialize -- limit is 1023" after start dbx to debug the X by using following command %dbx X. Do you know what these warning messages really mean? Also I understand the executable is very large so I shall expect the dbx running very slow, but is there any way we can make it faster? Thanks much, Jim.

Posted by Jim on October 01, 2006 at 04:14 AM PDT #

Jim, you didn't leave your email address (from what I can see) so I can't reply directly to you. It would be better if you reposted this question on the developer forms for Sun Studio. The URL is here: http://forum.sun.com/jive/forum.jspa?forumID=309 Make sure you donwload the latest patches from sunsolve.sun.com. There is a slightly out-of-date list of the patches here: http://developers.sun.com/prodtech/cc/downloads/patches/ss11_patches.html the sunsolve site will tell you the latest rev numbers for those patches. (The -XX at the end of the patchid)

Posted by Chris Quenelle on October 02, 2006 at 03:10 PM PDT #

Chris, Thanks for providing these information. I had posted the question on the developer forms per your suggestion. Best regards, Jim

Posted by Jim on October 03, 2006 at 04:06 AM PDT #

You have more then 2 reads, I make at least #3! ;)

Posted by Jeffrey Olson on February 01, 2007 at 03:08 PM PST #

Thanks, Jeff!

Posted by Chris Quenelle on February 01, 2007 at 03:08 PM PST #

Post a Comment:

Comments are closed for this entry.

Older blog entries:

mug shot Chris Quenelle is a tools developer at Sun Microsystems. He's worked on performance and debugging tools at Sun for more than 10 years. He reads comic books and science fiction, and has more tivos than he can keep track of.

Calendar

RSS Feeds

Search

Links

Navigation

Referers