Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Where does gdb find libraries: (9 Items)
   
Where does gdb find libraries  
When running gdb on our target systems, it's never able to find any of the .so files to load symbols.

Under QNX 6.3.2, we set LD_LIBRARY_PATH and/or the LIBPATH sysconf and this seemed to make gdb happy.

But this no longer works on 6.5.0.  So I was wondering, how does gdb decide where the .so files reside?  Note that the 
libraries in question are all in /lib, /lib/dll, /usr/lib, i.e., the standard places.

Thanks,
lew
Re: Where does gdb find libraries  
Try setting env. var

QNX_TARGET=/

before running gdb.


On Fri, 2011-02-25 at 09:11 -0500, Lewis Donzis wrote:
> When running gdb on our target systems, it's never able to find any of
> the .so files to load symbols.
> 
> Under QNX 6.3.2, we set LD_LIBRARY_PATH and/or the LIBPATH sysconf and
> this seemed to make gdb happy.
> 
> But this no longer works on 6.5.0.  So I was wondering, how does gdb
> decide where the .so files reside?  Note that the libraries in
> question are all in /lib, /lib/dll, /usr/lib, i.e., the standard
> places.
> 
> Thanks,
> lew
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post83500
> 
> 
> 

Re: Where does gdb find libraries  
> Try setting env. var
> 
> QNX_TARGET=/
> 
> before running gdb.

Thanks for the suggestion, but it doesn't seem to help.  Here's an example:

# export QNX_TARGET=/
# gdb pefilter /var/dumps/pefilter.core 
GNU gdb 6.8 qnx-nto (rev. 347)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-nto-qnx6.4.0"...
(no debugging symbols found)
Error while mapping shared library sections:
libsocket.so.2: No such file or directory.
Error while mapping shared library sections:
libc.so.2: No such file or directory.
Error while mapping shared library sections:
libc.so.3: No such file or directory.
Symbol file not found for libsocket.so.2
Symbol file not found for libc.so.2
Symbol file not found for libc.so.3
Program terminated with signal 11, Segmentation fault.
[New process 1671426163 thread 1]
#0  0x08047d50 in ?? ()
(gdb) bt
#0  0x08047d50 in ?? ()
#1  0xb032c4f8 in ?? ()
#2  0x08062260 in ?? ()
#3  0x08062188 in ?? ()
#4  0x08047cc8 in ?? ()
#5  0xb03568eb in ?? ()
#6  0x00000000 in ?? ()
Re: Where does gdb find libraries  
If you are opening a core, try doing "shared" after you open core.

Alternatively, start gdb with exe only, then do explicit
(gdb) core <corefile>

It should "just work" even without QNX_TARGET.

Do you have SKD installed on self-hosted? if so, it should have
QNX_TARGET set correctly to something like /usr/qnx.../target/qnx6

If not, then for the QNX_TARGET trick, the missing bit is creating a
softlink:

# ln -s / /x86


Our gdb is tuned to work with SDK which always sets QNX_TARGET, even for
self-hosted where it is assumed that self-hosted is used as development
platform.

In your case you are using self-hosted gdb without SDK available, the
easiest way is I believe with QNX_TARGET=/ + soft link /x86 -> /

p.s. you can update your gdb, it should work better. You can download
the latest from:

http://community.qnx.com/sf/frs/do/listReleases/projects.toolchain/frs.gdb


On Fri, 2011-02-25 at 20:21 -0500, Lewis Donzis wrote:
> > Try setting env. var
> >
> > QNX_TARGET=/
> >
> > before running gdb.
> 
> Thanks for the suggestion, but it doesn't seem to help.  Here's an
> example:
> 
> # export QNX_TARGET=/
> # gdb pefilter /var/dumps/pefilter.core
> GNU gdb 6.8 qnx-nto (rev. 347)
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>;
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show
> copying"
> and "show warranty" for details.
> This GDB was configured as "i386-pc-nto-qnx6.4.0"...
> (no debugging symbols found)
> Error while mapping shared library sections:
> libsocket.so.2: No such file or directory.
> Error while mapping shared library sections:
> libc.so.2: No such file or directory.
> Error while mapping shared library sections:
> libc.so.3: No such file or directory.
> Symbol file not found for libsocket.so.2
> Symbol file not found for libc.so.2
> Symbol file not found for libc.so.3
> Program terminated with signal 11, Segmentation fault.
> [New process 1671426163 thread 1]
> #0  0x08047d50 in ?? ()
> (gdb) bt
> #0  0x08047d50 in ?? ()
> #1  0xb032c4f8 in ?? ()
> #2  0x08062260 in ?? ()
> #3  0x08062188 in ?? ()
> #4  0x08047cc8 in ?? ()
> #5  0xb03568eb in ?? ()
> #6  0x00000000 in ?? ()
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post83544
> 
> 
> 

Re: Where does gdb find libraries  
> If you are opening a core, try doing "shared" after you open core.

That just says that the .so files are already loaded.

> Alternatively, start gdb with exe only, then do explicit
> (gdb) core <corefile>

That produces the same output as when it's run with the core file on the command line.

> Do you have SKD installed on self-hosted? if so, it should have
> QNX_TARGET set correctly to something like /usr/qnx.../target/qnx6

No, this is a target system.  Sometimes we like to run gdb on our target because it's more convenient than taking the 
core file off and running it on a real SDK system.  Note that if we move the core file to a development system, it all 
works fine.

On QNX 6.3.2, it worked fine on the target after setting LD_LIBRARY_PATH, but not on 6.5.0.

> If not, then for the QNX_TARGET trick, the missing bit is creating a
> softlink:
> 
> # ln -s / /x86
> 
> 
> Our gdb is tuned to work with SDK which always sets QNX_TARGET, even for
> self-hosted where it is assumed that self-hosted is used as development
> platform.
> 
> In your case you are using self-hosted gdb without SDK available, the
> easiest way is I believe with QNX_TARGET=/ + soft link /x86 -> /

With the soft link, it can find the files, but says "no debugging symbols found" and also, the backtrace is completely 
wrong.

> p.s. you can update your gdb, it should work better. You can download
> the latest from:
> 
> http://community.qnx.com/sf/frs/do/listReleases/projects.toolchain/frs.gdb

It's unclear whether this is newer than what we have already.  The date on the file is about a year older than the 
released one, and also it says it's for nto 6.3:

Existing gdb:

GNU gdb 6.8 qnx-nto (rev. 506)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-pc-nto-qnx6.5.0".

"New" one from the above link:

GNU gdb 6.8 qnx-nto update 5 (rev. 398)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-nto-qnx6.3.0".
Re: Where does gdb find libraries  
Try the gdb "set solib-search-path"?

----- Original Message -----
From: Lewis Donzis [mailto:community-noreply@qnx.com]
Sent: Saturday, February 26, 2011 08:14 AM
To: general-toolchain <post83549@community.qnx.com>
Subject: Re: Where does gdb find libraries

> If you are opening a core, try doing "shared" after you open core.

That just says that the .so files are already loaded.

> Alternatively, start gdb with exe only, then do explicit
> (gdb) core <corefile>

That produces the same output as when it's run with the core file on the command line.

> Do you have SKD installed on self-hosted? if so, it should have
> QNX_TARGET set correctly to something like /usr/qnx.../target/qnx6

No, this is a target system.  Sometimes we like to run gdb on our target because it's more convenient than taking the 
core file off and running it on a real SDK system.  Note that if we move the core file to a development system, it all 
works fine.

On QNX 6.3.2, it worked fine on the target after setting LD_LIBRARY_PATH, but not on 6.5.0.

> If not, then for the QNX_TARGET trick, the missing bit is creating a
> softlink:
> 
> # ln -s / /x86
> 
> 
> Our gdb is tuned to work with SDK which always sets QNX_TARGET, even for
> self-hosted where it is assumed that self-hosted is used as development
> platform.
> 
> In your case you are using self-hosted gdb without SDK available, the
> easiest way is I believe with QNX_TARGET=/ + soft link /x86 -> /

With the soft link, it can find the files, but says "no debugging symbols found" and also, the backtrace is completely 
wrong.

> p.s. you can update your gdb, it should work better. You can download
> the latest from:
> 
> http://community.qnx.com/sf/frs/do/listReleases/projects.toolchain/frs.gdb

It's unclear whether this is newer than what we have already.  The date on the file is about a year older than the 
released one, and also it says it's for nto 6.3:

Existing gdb:

GNU gdb 6.8 qnx-nto (rev. 506)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-pc-nto-qnx6.5.0".

"New" one from the above link:

GNU gdb 6.8 qnx-nto update 5 (rev. 398)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-nto-qnx6.3.0".



_______________________________________________

General
http://community.qnx.com/sf/go/post83549
Re: Where does gdb find libraries  
> Try the gdb "set solib-search-path"?

I have to apologize... yes, the above works, as does creating the soft link as suggested by Aleksandar.

I had checked that core file earlier and it was ok, but apparently, something happened along the way, the the core file 
was junk.

I produced a new "good" core file and the soft link and the above "set" command both work perfectly.

Thanks very much for your help and sorry for dragging it out a little extra :)

lew
Re: Where does gdb find libraries  
As for the gdb version: your first post indicated rev. 347 which was
shipped with 6.4.1 sdk; that's why I suggested update site, but then
later you posted log with rev.506 which shipped with 6.5.0 sdk which is
newer than what is posted on our update site.

The larger the rev. number the newer gdb is so you already have the
latest. We did not update the "udpate" web site, we should have - to
avoid confusion.


---
Aleksandar

Re: Where does gdb find libraries  
> As for the gdb version: your first post indicated rev. 347 which was
> shipped with 6.4.1 sdk; that's why I suggested update site, but then
> later you posted log with rev.506 which shipped with 6.5.0 sdk which is
> newer than what is posted on our update site.
> 
> The larger the rev. number the newer gdb is so you already have the
> latest. We did not update the "udpate" web site, we should have - to
> avoid confusion.

Thanks for pointing that out, it looks like we must have something out of date in our target build.  I'll make sure we 
use the rev 506 throughout.

Thanks,
lew