* Running GDB with args and variables [not found] <1367979679.9898.1630088891149.ref@mail.yahoo.com> @ 2021-08-27 18:28 ` Mahmood Naderan 2021-08-30 15:56 ` Christian Biesinger 0 siblings, 1 reply; 4+ messages in thread From: Mahmood Naderan @ 2021-08-27 18:28 UTC (permalink / raw) To: gdb Hi I use the following command to run a program $ LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt Now I want to use 'gdb --args' but the following command doesn't work. $ gdb --args LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt ... For help, type "help". Type "apropos word" to search for commands related to "word"... LD_PRELOAD=/home/mahmood/foo.so: No such file or directory. (gdb) The "No such file" error is weird because the file exists when I run 'ls' command. Any idea about that? Regards, Mahmood ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running GDB with args and variables 2021-08-27 18:28 ` Running GDB with args and variables Mahmood Naderan @ 2021-08-30 15:56 ` Christian Biesinger 2021-08-30 16:13 ` Luke Drummond 0 siblings, 1 reply; 4+ messages in thread From: Christian Biesinger @ 2021-08-30 15:56 UTC (permalink / raw) To: Mahmood Naderan; +Cc: gdb On Fri, Aug 27, 2021 at 2:29 PM Mahmood Naderan via Gdb <gdb@sourceware.org> wrote: > I use the following command to run a program > > $ LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt > > Now I want to use 'gdb --args' but the following command doesn't work. > > > $ gdb --args LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt > ... > > For help, type "help". > Type "apropos word" to search for commands related to "word"... > LD_PRELOAD=/home/mahmood/foo.so: No such file or directory. > (gdb) > > > > > The "No such file" error is weird because the file exists when I run 'ls' command. > > Any idea about that? I would think the error comes from the fact that gdb is looking for a file called "LD_PRELOAD=..." and there is no such file. Maybe try: gdb --args env LD_PRELOAD=... foo Christian ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running GDB with args and variables 2021-08-30 15:56 ` Christian Biesinger @ 2021-08-30 16:13 ` Luke Drummond 2021-08-30 17:18 ` Mahmood Naderan 0 siblings, 1 reply; 4+ messages in thread From: Luke Drummond @ 2021-08-30 16:13 UTC (permalink / raw) To: Christian Biesinger, Mahmood Naderan; +Cc: gdb Hi all On Mon Aug 30, 2021 at 4:56 PM BST, Christian Biesinger via Gdb wrote: > On Fri, Aug 27, 2021 at 2:29 PM Mahmood Naderan via Gdb > <gdb@sourceware.org> wrote: > > I use the following command to run a program > > $ LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt > > I would think the error comes from the fact that gdb is looking for a > file called "LD_PRELOAD=..." and there is no such file. > > Maybe try: gdb --args env LD_PRELOAD=... foo To avoid the confusion with the `env` fork/exec without worrying about `set follow-fork-mode child` the following might be better: gdb \ --init-eval-command="set environment LD_PRELOAD=/home/mahmood/foo.so" \ --args /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt This commands gdb to set the environment in the child before the child is loaded All the Best Luke -- Codeplay Software Ltd. Company registered in England and Wales, number: 04567874 Registered office: Regent House, 316 Beulah Hill, London, SE19 3HF ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running GDB with args and variables 2021-08-30 16:13 ` Luke Drummond @ 2021-08-30 17:18 ` Mahmood Naderan 0 siblings, 0 replies; 4+ messages in thread From: Mahmood Naderan @ 2021-08-30 17:18 UTC (permalink / raw) To: Christian Biesinger, Luke Drummond; +Cc: gdb Right. Both solutions work. Thanks. Regards, Mahmood On Monday, August 30, 2021, 6:13:11 PM GMT+2, Luke Drummond <luke.drummond@codeplay.com> wrote: Hi all On Mon Aug 30, 2021 at 4:56 PM BST, Christian Biesinger via Gdb wrote: > On Fri, Aug 27, 2021 at 2:29 PM Mahmood Naderan via Gdb > <gdb@sourceware.org> wrote: > > I use the following command to run a program > > $ LD_PRELOAD=/home/mahmood/foo.so /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt > > I would think the error comes from the fact that gdb is looking for a > file called "LD_PRELOAD=..." and there is no such file. > > Maybe try: gdb --args env LD_PRELOAD=... foo To avoid the confusion with the `env` fork/exec without worrying about `set follow-fork-mode child` the following might be better: gdb \ --init-eval-command="set environment LD_PRELOAD=/home/mahmood/foo.so" \ --args /home/mahmood/program/run /home/mahmood/p2/bin/p2 -config t.txt This commands gdb to set the environment in the child before the child is loaded All the Best Luke -- Codeplay Software Ltd. Company registered in England and Wales, number: 04567874 Registered office: Regent House, 316 Beulah Hill, London, SE19 3HF ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-30 17:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1367979679.9898.1630088891149.ref@mail.yahoo.com> 2021-08-27 18:28 ` Running GDB with args and variables Mahmood Naderan 2021-08-30 15:56 ` Christian Biesinger 2021-08-30 16:13 ` Luke Drummond 2021-08-30 17:18 ` Mahmood Naderan
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).