This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Tutorial on debugging with an alternate loader
- From: Daniel De La Zerda <ddelazerda007 at yahoo dot com>
- To: Ryan Arnold <ryan dot arnold at gmail dot com>
- Cc: Carlos O'Donell <carlos at systemhalted dot org>, libc-help at sourceware dot org, pasky at suse dot cz
- Date: Thu, 16 Apr 2009 11:11:59 -0700 (PDT)
- Subject: Re: Tutorial on debugging with an alternate loader
- References: <684720.61839.qm@web63201.mail.re1.yahoo.com> <335499.11939.qm@web63206.mail.re1.yahoo.com> <119aab440903181350s9a21410tff40cf9d37301819@mail.gmail.com> <588946.38944.qm@web63206.mail.re1.yahoo.com> <119aab440903181431p6b55bf9dnd3f1fb4caffbbf8b@mail.gmail.com> <680017.83123.qm@web63206.mail.re1.yahoo.com> <119aab440903191247h68392104qadfbb4ab0b0a8ea5@mail.gmail.com> <740092.5205.qm@web63206.mail.re1.yahoo.com> <ff4da150903191905r6b284d79s65c3eb0bb7f96e69@mail.gmail.com> <396494.10605.qm@web63201.mail.re1.yahoo.com> <ff4da150904161035w7836ebag3aaffbc181e72512@mail.gmail.com>
- Reply-to: Daniel De La Zerda <danieldelazerda at gmail dot com>
After playing with it a little bit I made a minor change to the debug script:
#!/bin/bash
GLIBC="/home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build"
PWD=`pwd`
# We need to make sure that gdb is linked against the standalone glibc so that
# it picks up the correct nptl_db/libthread_db.so. So that means invoking gdb
# using the standalone glibc's linker.
${GLIBC}/elf/ld-linux-x86-64.so.2 --library-path \
${GLIBC}:\
${GLIBC}/math:\
${GLIBC}/elf:\
${GLIBC}/dlfcn:\
${GLIBC}/nss:\
${GLIBC}/nis:\
${GLIBC}/rt:\
${GLIBC}/resolv:\
${GLIBC}/crypt:\
${GLIBC}/nptl:\
${GLIBC}/nptl_db \
gdb -x /home/devel/src/rmp/BUILD/test/test.gdb -d /home/devel/src/rpm/BUILD/glibc-2.4-copy ${GLIBC}/elf/ld-linux-x86-64.so.2
In the line before the lastline instead of "${GLIBC}/nptl_db:\" I now have "${GLIBC}/nptl_db \" and I get a different error:
"gdb: error while loading shared libraries: gdb: cannot open shared object file: No such file or directory"
and since it still doesn't say what exactly it can't find I did an "strace" of running the command and found out which files it is looking for and not finding. Here is the file in question from the strace output: "open("/home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/etc/ld.so.cache", O_RDONLY) = -1 ENOENT (No such file or directory)".
Just thinking out loud - There is not "etc" directory under my-glibc-build, I think because that gets generated after "ldconfig" is run, but I don't have an "ld.so.conf" file for that.
What would you suggest I do?
Thanks again for your time in helping,
Daniel
----- Original Message ----
From: Ryan Arnold <ryan.arnold@gmail.com>
To: Daniel De La Zerda <danieldelazerda@gmail.com>
Cc: Carlos O'Donell <carlos@systemhalted.org>; libc-help@sourceware.org; pasky@suse.cz
Sent: Thursday, April 16, 2009 1:35:29 PM
Subject: Re: Tutorial on debugging with an alternate loader
On Thu, Apr 16, 2009 at 11:32 AM, Daniel De La Zerda
<ddelazerda007@yahoo.com> wrote:
> set environment C -E -x c-header
> break _dl_main_dispatch
> run --library-path
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/nptl:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/math:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/elf:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/dlfcn:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/nss:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/nis:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/rt:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/resolv:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/crypt:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/nptl:\
> /home/devel/src/rpm/BUILD/glibc-2.4-copy/my-glibc-build/nptl_db \
> /home/devel/src/rpm/BUILD/test/minicond_clock_test
>
> minicond_clock_test is the executable that I want to debug.
>
> When I run the bash script above I get the following error:
>
> "-x: error while loading shared libraries: -x: cannot open shared object file: No such file or directory"
>
> This is strange because I did an "ls" on every path of the bash script and their are all valid paths. I don't know what else could it be. If you need more information, I will be glad to provide.
>
> Thank you for your time,
>
> Daniel
One problem I see right away is with '_dl_main_dispatch'. That symbol
isn't available on x86[-64] so you'll have to find somewhere else to
break.
With regard to -x, is this error actually referring to the gdb
environment -x or the gdb invocation? Perhaps older versions of gdb
don't support -x?
Ryan