public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Getting access to environement variables
@ 2021-02-05  9:58 vincent Dupaquis
  2021-02-05 14:06 ` Paul Koning
  0 siblings, 1 reply; 5+ messages in thread
From: vincent Dupaquis @ 2021-02-05  9:58 UTC (permalink / raw)
  To: gdb

    Hello,

    I would like to point-out a possibly missing feature, which is the
possibility of accessing ENV variables in GDB commands.

    Currently, if I want my command scripts to work on a remote target
or another, the only way I've found to parametrize the target/port is to
generate a command file in the calling script, and to include it into
the executed script.

    Something like :

#!/bin/bash
GDBPORT=(GDBPORT:=1234)
echo "target remote localhost:${GDBPORT}" > connect.cmd

    And then in the gdb script
include connect.cmd
...

    Is there a better way, or is it the way it is intended top be done ?

    Else, I wanted to thank/copngratulate everyone who contributed to
GDB for their fantastic work building probably the most powerfull
debugger ever (not the most user friendly, still :) ).

    Best regards,
        Vincent.

-- 

*Vincent Dupaquis*
Software security & Cryptography expert
06 24 58 17 05
/Europarc de Pichaury Bâtiment B8 1330 rue Guillibert Gautier de la
Lauzière 13290 Aix-en-Provence/

www.trusted-objects.com <http://www.trusted-objects.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting access to environement variables
  2021-02-05  9:58 Getting access to environement variables vincent Dupaquis
@ 2021-02-05 14:06 ` Paul Koning
  2021-02-05 14:28   ` vincent Dupaquis
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Koning @ 2021-02-05 14:06 UTC (permalink / raw)
  To: vincent Dupaquis; +Cc: gdb



> On Feb 5, 2021, at 4:58 AM, vincent Dupaquis <v.dupaquis@trusted-objects.com> wrote:
> 
>     Hello,
> 
>     I would like to point-out a possibly missing feature, which is the
> possibility of accessing ENV variables in GDB commands.

Assuming your GDB is built with Python scripting included, you can do it via Python; "import os" then access environment variables as elements of dictionary "os.environ".

	paul


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting access to environement variables
  2021-02-05 14:06 ` Paul Koning
@ 2021-02-05 14:28   ` vincent Dupaquis
  2021-02-05 14:34     ` Jan Vrany
  0 siblings, 1 reply; 5+ messages in thread
From: vincent Dupaquis @ 2021-02-05 14:28 UTC (permalink / raw)
  To: Paul Koning; +Cc: gdb

Good point !

That's something I already use when instrumenting gdb, but for some easy
and quick scripting, it would have been easier to be able to access the
environement variables directly from the gdb commands.

Vincent.

Le 05/02/2021 à 15:06, Paul Koning a écrit :
>
>> On Feb 5, 2021, at 4:58 AM, vincent Dupaquis <v.dupaquis@trusted-objects.com> wrote:
>>
>>     Hello,
>>
>>     I would like to point-out a possibly missing feature, which is the
>> possibility of accessing ENV variables in GDB commands.
> Assuming your GDB is built with Python scripting included, you can do it via Python; "import os" then access environment variables as elements of dictionary "os.environ".
>
> 	paul
>
-- 

*Vincent Dupaquis*
Software security & Cryptography expert
06 24 58 17 05
/Europarc de Pichaury Bâtiment B8 1330 rue Guillibert Gautier de la
Lauzière 13290 Aix-en-Provence/

www.trusted-objects.com <http://www.trusted-objects.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting access to environement variables
  2021-02-05 14:28   ` vincent Dupaquis
@ 2021-02-05 14:34     ` Jan Vrany
  2021-02-05 14:51       ` vincent Dupaquis
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Vrany @ 2021-02-05 14:34 UTC (permalink / raw)
  To: gdb

On Fri, 2021-02-05 at 15:28 +0100, vincent Dupaquis wrote:
> Good point !
> 
> That's something I already use when instrumenting gdb, but for some
> easy
> and quick scripting, it would have been easier to be able to access
> the
> environement variables directly from the gdb commands.

I have not tried, but I believe you can implement new convenience
function in Python that would allow you to write something like

   $ENV("MY_ENV_VARIABLE") 

See
https://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html#Functions-In-Python

HTH, Jan

> 
> Vincent.
> 
> Le 05/02/2021 à 15:06, Paul Koning a écrit :
> > 
> > > On Feb 5, 2021, at 4:58 AM, vincent Dupaquis <
> > > v.dupaquis@trusted-objects.com> wrote:
> > > 
> > >     Hello,
> > > 
> > >     I would like to point-out a possibly missing feature, which
> > > is the
> > > possibility of accessing ENV variables in GDB commands.
> > Assuming your GDB is built with Python scripting included, you can
> > do it via Python; "import os" then access environment variables as
> > elements of dictionary "os.environ".
> > 
> >         paul
> > 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Getting access to environement variables
  2021-02-05 14:34     ` Jan Vrany
@ 2021-02-05 14:51       ` vincent Dupaquis
  0 siblings, 0 replies; 5+ messages in thread
From: vincent Dupaquis @ 2021-02-05 14:51 UTC (permalink / raw)
  To: gdb

I did not knew this one :)

Even better, looks like we are reaching a point where no one will be
able to complain about a missing tiny function ;)

Vincent.


Le 05/02/2021 à 15:34, Jan Vrany a écrit :
> On Fri, 2021-02-05 at 15:28 +0100, vincent Dupaquis wrote:
>> Good point !
>>
>> That's something I already use when instrumenting gdb, but for some
>> easy
>> and quick scripting, it would have been easier to be able to access
>> the
>> environement variables directly from the gdb commands.
> I have not tried, but I believe you can implement new convenience
> function in Python that would allow you to write something like
>
>    $ENV("MY_ENV_VARIABLE") 
>
> See
> https://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html#Functions-In-Python
>
> HTH, Jan
>
>> Vincent.
>>
>> Le 05/02/2021 à 15:06, Paul Koning a écrit :
>>>> On Feb 5, 2021, at 4:58 AM, vincent Dupaquis <
>>>> v.dupaquis@trusted-objects.com> wrote:
>>>>
>>>>     Hello,
>>>>
>>>>     I would like to point-out a possibly missing feature, which
>>>> is the
>>>> possibility of accessing ENV variables in GDB commands.
>>> Assuming your GDB is built with Python scripting included, you can
>>> do it via Python; "import os" then access environment variables as
>>> elements of dictionary "os.environ".
>>>
>>>         paul
>>>
>
-- 

*Vincent Dupaquis*
Software security & Cryptography expert
06 24 58 17 05
/Europarc de Pichaury Bâtiment B8 1330 rue Guillibert Gautier de la
Lauzière 13290 Aix-en-Provence/

www.trusted-objects.com <http://www.trusted-objects.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-05 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  9:58 Getting access to environement variables vincent Dupaquis
2021-02-05 14:06 ` Paul Koning
2021-02-05 14:28   ` vincent Dupaquis
2021-02-05 14:34     ` Jan Vrany
2021-02-05 14:51       ` vincent Dupaquis

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).