Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb 5.3nb1 crashing when accessing elements in static libs
@ 2005-04-04  9:54 Stuart Brooks
  2005-04-04 13:39 ` Daniel Jacobowitz
  2005-04-04 17:09 ` Nathan J. Williams
  0 siblings, 2 replies; 5+ messages in thread
From: Stuart Brooks @ 2005-04-04  9:54 UTC (permalink / raw)
  To: gdb

Hi,

I'm new to this list, so if this is not the right place to be posting
please let me know....

I am experiencing problems when interrogating a core file - as soon as I
try to access a global variable in a statically linked library or view
the internals of a class/struct declared in a static lib gdb either says
<unknown type>, gives garbage or segmentation faults. Details of my
system are:

OS: Netbsd 2.0
gdb: 5.3nb1
compiler: g++ 3.3

Using the same code, gdb works fine on [Netbsd 1.5.1,gdb 4.17,g++
2.91.66] and [Netbsd 1.6.2,gdb 5.0nb1,g++ 2.95.3] so it looks to me like
a conflict between g++ and gdb. The libs are being compiled with -g and
without optimizations. I'm really not too sure what to do from here. Any
ideas/help would be much appreciated ...

Thanks
 Stuart

---------------------------
More info:

(gdb) bt
#0 0x4822cfeb in kill () from /usr/lib/libc.so.12
#1 0x08064f85 in Sql_Query::executeQuery() (this=0x8073220)
at sql_query.cpp:410
#2 0x0804f51b in Sql_Gateway::updateGateway(Sql_Database*, int) (
this=0x80870d0, db=0x8088080, gateway_id=1) at sql_gateway.cpp:247
...
#7 0x08049e8c in main (argc=1, argv=0xbfbff88c) at main.cpp:50
#8 0x08049b12 in ___start ()

(gdb) up
#1 0x08064f85 in Sql_Query::executeQuery() (this=0x8073220) at
sql_query.cpp:410
410 CHECK(false);

(gdb) up
#2 0x0804f51b in Sql_Gateway::updateGateway(Sql_Database*, int) (
this=0x80870d0, db=0x8088080, gateway_id=1) at sql_gateway.cpp:247
247 if (!q->executeQuery())

(gdb) p db
$1 = (<unknown type> *) 0x8088080

(gdb) p *db
$2 = <error type>

---------------------------

Also when trying to print out the value of a global pointer I get this:

(gdb) p server
$5 = 134692864


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb 5.3nb1 crashing when accessing elements in static libs
  2005-04-04  9:54 gdb 5.3nb1 crashing when accessing elements in static libs Stuart Brooks
@ 2005-04-04 13:39 ` Daniel Jacobowitz
  2005-04-04 17:09 ` Nathan J. Williams
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-04-04 13:39 UTC (permalink / raw)
  To: Stuart Brooks; +Cc: gdb

On Mon, Apr 04, 2005 at 11:53:39AM +0200, Stuart Brooks wrote:
> Hi,
> 
> I'm new to this list, so if this is not the right place to be posting
> please let me know....
> 
> I am experiencing problems when interrogating a core file - as soon as I
> try to access a global variable in a statically linked library or view
> the internals of a class/struct declared in a static lib gdb either says
> <unknown type>, gives garbage or segmentation faults. Details of my
> system are:
> 
> OS: Netbsd 2.0
> gdb: 5.3nb1
> compiler: g++ 3.3
> 
> Using the same code, gdb works fine on [Netbsd 1.5.1,gdb 4.17,g++
> 2.91.66] and [Netbsd 1.6.2,gdb 5.0nb1,g++ 2.95.3] so it looks to me like
> a conflict between g++ and gdb. The libs are being compiled with -g and
> without optimizations. I'm really not too sure what to do from here. Any
> ideas/help would be much appreciated ...

You should try a more recent version of GDB.  The latest release is
6.3, and the CVS has an additional almost-year of development.

> Also when trying to print out the value of a global pointer I get this:
> 
> (gdb) p server
> $5 = 134692864

Probably server has no debug information in your object.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb 5.3nb1 crashing when accessing elements in static libs
  2005-04-04  9:54 gdb 5.3nb1 crashing when accessing elements in static libs Stuart Brooks
  2005-04-04 13:39 ` Daniel Jacobowitz
@ 2005-04-04 17:09 ` Nathan J. Williams
  2005-04-05  5:40   ` Stuart Brooks
  1 sibling, 1 reply; 5+ messages in thread
From: Nathan J. Williams @ 2005-04-04 17:09 UTC (permalink / raw)
  To: Stuart Brooks; +Cc: gdb

"Stuart Brooks" <stuartb@cat.co.za> writes:

> I am experiencing problems when interrogating a core file - as soon as I
> try to access a global variable in a statically linked library or view
> the internals of a class/struct declared in a static lib gdb either says
> <unknown type>, gives garbage or segmentation faults. Details of my
> system are:
> 
> OS: Netbsd 2.0
> gdb: 5.3nb1
> compiler: g++ 3.3

I'm assuming this is i386? You're going to be in some pain with C++ on
this combination; netbsd/i386 2.0 sets gcc to use the stabs debugging
format by default instead of dwarf-2, because of a bug in 3.3's dwarf
generation (netbsd PR #25094; equivalent to GCC bug #16788) [I'm not
at all sure that this is the right tradeoff for that bug].

        - Nathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb 5.3nb1 crashing when accessing elements in static libs
  2005-04-04 17:09 ` Nathan J. Williams
@ 2005-04-05  5:40   ` Stuart Brooks
  2005-04-05  7:51     ` Stuart Brooks
  0 siblings, 1 reply; 5+ messages in thread
From: Stuart Brooks @ 2005-04-05  5:40 UTC (permalink / raw)
  To: Nathan J. Williams; +Cc: gdb


> > I am experiencing problems when interrogating a core file - as soon
as I
> > try to access a global variable in a statically linked library or
view
> > the internals of a class/struct declared in a static lib gdb either
says
> > <unknown type>, gives garbage or segmentation faults. Details of my
> > system are:
> >
> > OS: Netbsd 2.0
> > gdb: 5.3nb1
> > compiler: g++ 3.3
>
> I'm assuming this is i386? You're going to be in some pain with C++ on
> this combination; netbsd/i386 2.0 sets gcc to use the stabs debugging
> format by default instead of dwarf-2, because of a bug in 3.3's dwarf
> generation (netbsd PR #25094; equivalent to GCC bug #16788) [I'm not
> at all sure that this is the right tradeoff for that bug].

Yes, this is i386 :( What would you recommend I do? I suppose I could
install a later version of gcc (seems 3.4.0 has this fixed) but I would
imagine that that will need a full system rebuild depending on the
compatibility between 3.3.3 and 3.4.0. Or is there some easier solution,
maybe setting g++ to use dwarf-2 and accepting that the offset for long
long structs will be incorrect (is this a train smash?)?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gdb 5.3nb1 crashing when accessing elements in static libs
  2005-04-05  5:40   ` Stuart Brooks
@ 2005-04-05  7:51     ` Stuart Brooks
  0 siblings, 0 replies; 5+ messages in thread
From: Stuart Brooks @ 2005-04-05  7:51 UTC (permalink / raw)
  To: Stuart Brooks, Nathan J. Williams; +Cc: gdb

> > I'm assuming this is i386? You're going to be in some pain with C++
on
> > this combination; netbsd/i386 2.0 sets gcc to use the stabs
debugging
> > format by default instead of dwarf-2, because of a bug in 3.3's
dwarf
> > generation (netbsd PR #25094; equivalent to GCC bug #16788) [I'm not
> > at all sure that this is the right tradeoff for that bug].
>
> Yes, this is i386 :( What would you recommend I do? I suppose I could
> install a later version of gcc (seems 3.4.0 has this fixed) but I
would
> imagine that that will need a full system rebuild depending on the
> compatibility between 3.3.3 and 3.4.0. Or is there some easier
solution,
> maybe setting g++ to use dwarf-2 and accepting that the offset for
long
> long structs will be incorrect (is this a train smash?)?

Compiling everything with -gdwarf-2 gives me the ability to access
symbols in classes compiled in static libraries which is great (I
couldn't do this before). An interesting thing though is that all global
variables seem to be viewed/treated as ints.

eg.

// global variables
MyClass* g_myclass_p; // initialized later
MyClass g_myclass;
int* g_int_p=(int*)2000;
int g_int=1234;

will give (in gdb printouts):

g_myclass_p = 13423223
g_myclass = 0
g_int_p = 2000
g_int = 1234

Again, this is a new one for me. Does anyone know if this is somehow
related? Thanks for the help so far, I really appreciate it!

- Stuart



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-05  7:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-04  9:54 gdb 5.3nb1 crashing when accessing elements in static libs Stuart Brooks
2005-04-04 13:39 ` Daniel Jacobowitz
2005-04-04 17:09 ` Nathan J. Williams
2005-04-05  5:40   ` Stuart Brooks
2005-04-05  7:51     ` Stuart Brooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox