From: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Nathan Miller <nathanm2@us.ibm.com>, Jon Tollefson <tollefso@us.ibm.com>
Subject: [RFC] Prevent GDB from loading native libraries when debugging a cross-target corefile
Date: Fri, 28 Sep 2012 06:32:00 -0000 [thread overview]
Message-ID: <1348813904-21180-1-git-send-email-emachado@linux.vnet.ibm.com> (raw)
Hi,
The GDB documentation recommends the following in the 'set solib-search-path'
description:
"If you want to use `solib-search-path' instead of `sysroot', be sure to set
`sysroot' to a nonexistent directory to prevent gdb from finding your host's
libraries." (http://sourceware.org/gdb/onlinedocs/gdb/Files.html)
However, when trying to debug cross-target corefiles using recent versions of
gdb, we noticed it's trying to load host libraries instead of libraries from a
cross-architecture jail (pointed by solib-search-path). Here's the example
showing the problem:
Using a faulty application foo that uses a shared library libfoo.so, generate a
corefile in the target system (a powerpc machine in my example here):
$ ls /usr/local/lib/libfoo.so
/usr/local/lib/libfoo.so
$ ./foo
Segmentation fault (core dumped)
Then copy the binary and the corefile for a cross-target debugging in the host
(an x86 machine here) that has his own libfoo.so at the same /usr/local/lib
and a cross environment at /opt/at6.0/ppc. Note that 'info sharedlibrary'
shows that GDB was trying to load the native library libfoo.so:
$ powerpc64-linux-gdb ./foo -q
Reading symbols from /home/emachado/bugs/ppc32-bin/foo...done.
(gdb) set sysroot /dev/null
(gdb) set solib-search-path /opt/at6.0/ppc/lib:/opt/at6.0/ppc/usr/lib
(gdb) core core.19304
[New LWP 19304]
warning: `/usr/local/lib/libfoo.so': Shared library architecture unknown is not compatible with target architecture powerpc:common.
warning: .dynamic section for "/opt/at6.0/ppc/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
warning: .dynamic section for "/opt/at6.0/ppc/lib/ld.so.1" is not at the expected address (wrong library or version mismatch?)
warning: Could not load shared library symbols for linux-vdso32.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./foo'.
Program terminated with signal 11, Segmentation fault.
#0 0x10000704 in main () at foo.c:7
7 printf("null dereference: %c\n", *p);
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
No linux-vdso32.so.1
0x0ffdec50 0x0ffded58 Yes (*) /usr/local/lib/libfoo.so
0x0fe49a5c 0x0ff6aacc Yes /opt/at6.0/ppc/lib/libc.so.6
0xf7eb2fb0 0xf7ece9d0 Yes /opt/at6.0/ppc/lib/ld.so.1
(*): Shared library is missing debugging information.
It might be worth mentioning that this behavior was modified by this patch from
April 2010:
http://sourceware.org/ml/gdb-patches/2010-04/msg00758.html
Please consider the following patch as a fix for this issue.
Thanks,
--
Edjunior
gdb/
2012-09-28 Nathan Miller <nathanm2@us.ibm.com>
Edjunior Machado <emachado@linux.vnet.ibm.com>
* solib.c (solib_find): Prevent GDB from loading native libraries when
debugging a cross-target corefile.
---
gdb/solib.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/gdb/solib.c b/gdb/solib.c
index 01573f8..d795678 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -300,11 +300,6 @@ solib_find (char *in_pathname, int *fd)
if (found_file < 0)
temp_pathname = NULL;
- /* If not found, search the solib_search_path (if any). */
- if (found_file < 0 && solib_search_path != NULL)
- found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST,
- in_pathname, O_RDONLY | O_BINARY, &temp_pathname);
-
/* If the search in gdb_sysroot failed, and the path name is
absolute at this point, make it relative. (openp will try and open the
file according to its absolute path otherwise, which is not what we want.)
--
1.7.9.5
next reply other threads:[~2012-09-28 6:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 6:32 Edjunior Barbosa Machado [this message]
2012-09-28 19:03 ` Pedro Alves
2012-09-28 20:31 ` Edjunior Barbosa Machado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348813904-21180-1-git-send-email-emachado@linux.vnet.ibm.com \
--to=emachado@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=nathanm2@us.ibm.com \
--cc=tollefso@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox