public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "lvernschrock at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug cli/15190] New: programs run inside gdb ignore LD_LIBRARY_PATH
Date: Sun, 24 Feb 2013 21:49:00 -0000	[thread overview]
Message-ID: <bug-15190-4717@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=15190

             Bug #: 15190
           Summary: programs run inside gdb ignore LD_LIBRARY_PATH
           Product: gdb
           Version: 7.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: cli
        AssignedTo: unassigned@sourceware.org
        ReportedBy: lvernschrock@gmail.com
    Classification: Unclassified


This looks very similar to bug # 9011. I think that the easiest way to discuss
this is to simply paste my shell output in the bug report:
[quote]
tc@box:~$ cat > awsome.h << EOF
> void printmessage();
> EOF
tc@box:~$ cat > awsome.c << EOF
> #include "awsome.h"
> #include <stdio.h>
>
> void printmessage(){
>     printf("your computer is awsome\n");
> }
> EOF
tc@box:~$ mkdir mylib
tc@box:~$ gcc -fPIC -c awsome.c -o awsome.o
tc@box:~$ gcc -shared awsome.o -o mylib/libawsome.so
tc@box:~$ cat > demo.c << EOF
> #include "awsome.h"
>
> int main(int argv){
>     printmessage();
>     return 0;
> }
> EOF
tc@box:~$ gcc -c demo.c -o demo.o
tc@box:~$ gcc demo.o -Lmylib -lawsome -o demo
tc@box:~$ ./demo
./demo: error while loading shared libraries: libawsome.so: cannot open shared
object file: No such file or directory
tc@box:~$ export LD_LIBRARY_PATH=~/mylib
tc@box:~$ ./demo
your computer is awsome
tc@box:~$ gdb demo
GNU gdb (GDB) 7.2
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 "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tc/demo...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/tc/demo
/home/tc/demo: error while loading shared libraries: libawsome.so: cannot open
shared object file: No such file or directory

Program exited with code 0177.
(gdb) show env LD_LIBRARY_PATH
LD_LIBRARY_PATH = /home/tc/mylib
(gdb) quit
[/quote]
What really bothers me is the output from "show env LD_LIBRARY_PATH".
It seems that gdb sees the environmental variable; why can't the program inside
see it? 
I'm running on a Linux-based O.S.; kernel version 3.0.21.

P.S. I don't actually want to debug this demo program. I'm trying to debug a
more complex program and I wrote this trivial example to illustrate the issue
I'm running into.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2013-02-24 21:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-24 21:49 lvernschrock at gmail dot com [this message]
2013-02-26 15:39 ` [Bug cli/15190] " jan.kratochvil at redhat dot com
2013-02-26 20:18 ` palves at redhat dot com
2013-02-27 15:01 ` lvernschrock at gmail dot com

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=bug-15190-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).