0

I have an application that can be installed in various (multiple) locations on a linux server. When a core occurs, the corefile contains the library path relative to that instance. To debug that corefile however, I'm required to do it on another system as I don't have access often to the one that it occurred on. My question then is how do I set gdb to point to my local versions of the shared libraries rather than trying to locate them in the path that they were under when the core occurred?

I realize that's probably a bit confusing, so here's an example...(keep in mind I'm just making up these files/libs names).

On server 1, there is an application called myapp, in location /var/service/myfolder. In that folder there is a library called libXXX.so that is used by myapp.

On server 2, the same application is in /temp as is the same version of the libXXX.so file.

Server 1:

[root@server1]# ll /var/service/myfolder total 20 -rw-r--r-- 1 root admin 0 Nov 2 09:55 libXXX.so -rwxr-xr-x 1 root root 288 Nov 2 09:55 myapp

[root@server2]# ll /temp total 20 -rw-r--r-- 1 root admin 0 Nov 2 09:55 libXXX.so -rwxr-xr-x 1 root root 288 Nov 2 09:55 myapp

When I get a corefile from server 1 and try to debug it on server 2, I get the following error:

warning: .dynamic section for "/var/service/myfolder/libXXX.so" is not at the expected address (wrong library or version mismatch?)

If I look at the sharedlibrary, I see:

(gdb) info sharedlibrary From To Syms Read Shared Object Library 0x00b6ab30 0x00b86144 Yes /var/service/myfolder/libXXX.so

How do I tell gdb to ignore the /var/service/myfolder version and use the /temp version instead?

I've tried various combinations of setting the solib path, symbol-files, etc but I can't come up with the right combination.

Note: Yes, I realize that I can simply copy or link the /temp version to /var/service/myfolder on server2, however this isn't always possible.

When using the answer from Employed Russian, it still doesn't remove the link to the original library locations. Note that there are versions of those libraries in that folder, I just don't want to use them. What the answer provides will most likely work if libraries aren't found in the default location(s), and will use the new supplied paths, but how do you prevent it from looking the in original paths as well?

ex...

[root@server1 temp]# gdb /temp/app1/app1    
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6) 
Copyright (C) 2010 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 "x86_64-redhat-linux-gnu".
bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /temp/app1/app1...done.
(gdb) set sysroot /
(gdb) set solib-search-path /temp/app1
(gdb) core testapp1.core
[New Thread 4409]
[New Thread 4407]
[New Thread 4405]
warning: .dynamic section for "/var/service/app1/libXXX.so" is not at the expected address (wrong library or version mismatch?)

Thanks

  • GDB *doesn't* care about static (aka archive) libraries. Your question is about *shared* (aka dynamic) libraries. Please edit it accordingly. – Employed Russian Jan 18 '17 at 18:54
  • Thanks, yes sorry I meant shared, not static. The answer you linked to however either doesn't work for me or the instructions aren't as clear as they seem....I'll add the output. – user7437316 Jan 20 '17 at 20:43

0 Answers0