public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Luke Drummond" <luke.drummond@codeplay.com>
To: "Christian Biesinger" <cbiesinger@google.com>,
	"Mahmood Naderan" <nt_mahmood@yahoo.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Running GDB with args and variables
Date: Mon, 30 Aug 2021 17:13:09 +0100	[thread overview]
Message-ID: <CDWZAJD2UZFP.2KFWN9AB5TD9A@lukedrummondpc> (raw)
In-Reply-To: <CAPTJ0XH2Q1Fc-DQuSdpa-PBWZvkzy6BgZvzmxbXtpt9X4EdBgA@mail.gmail.com>

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


  reply	other threads:[~2021-08-30 16:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1367979679.9898.1630088891149.ref@mail.yahoo.com>
2021-08-27 18:28 ` Mahmood Naderan
2021-08-30 15:56   ` Christian Biesinger
2021-08-30 16:13     ` Luke Drummond [this message]
2021-08-30 17:18       ` Mahmood Naderan

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=CDWZAJD2UZFP.2KFWN9AB5TD9A@lukedrummondpc \
    --to=luke.drummond@codeplay.com \
    --cc=cbiesinger@google.com \
    --cc=gdb@sourceware.org \
    --cc=nt_mahmood@yahoo.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).