Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Setting environment variables on remote target via GDB/Momentics: (4 Items)
   
Setting environment variables on remote target via GDB/Momentics  
First off I'm running:

----
$ ntox86-gdb -v
GNU gdb 6.8 qnx-nto (rev. 506)
Copyright (C) 2008 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 "--host=i686-pc-linux-gnu --target=i486-pc-nto-qnx6.5.0".

----
QNX® Momentics® Integrated Development Environment
Version: 4.7.0
Build id: 201006232051

----

I'm trying to preload a library into an application I'm debugging remotely, but seem to be unable to influence the 
environment on the target. Something as simple as LD_PRELOAD=foo.so on the target would be useful.

Right now I'm using the gdb command-line, but if there is a way to do this from Momentics that's fine too. 

After connecting to the target via:
(gdb) target qnx x.x.x.x:####

All of the following commands operate in the context of the host machine:
(gdb) set environment LD_PRELOAD=foo.so
(gdb) set sysroot /location/of/foo.so/
(gdb) set solib-search-path /location/of/foo.so/

Also doing the following doesn't work:
(gdb) r LD_PRELOAD=foo.so bar

I was wondering if anyone had any idea on how I can set the environment remotely through gdb? IN the mean time I know 
that I can use gdb locally on the target machine. And I can also create a wrapper application that sets LD_PRELOAD via 
execve() and start by debugging that. I was just hoping there would be some feature of gdb, or Momentics, that someone 
knew about.

Thanks
Re: Setting environment variables on remote target via GDB/Momentics  
On 10-11-24 11:05 AM, Aaron Adams wrote:
> I was wondering if anyone had any idea on how I can set the environment
> remotely through gdb? IN the mean time I know that I can use gdb locally
> on the target machine. And I can also create a wrapper application that
> sets LD_PRELOAD via execve() and start by debugging that. I was just
> hoping there would be some feature of gdb, or Momentics, that someone
> knew about.

(gdb) help set nto-inherit-env
Set if the inferior should inherit environment from pdebug or gdb.
If nto-inherit-env is off, the process spawned on the remote will have 
its environment set by gdb.  Otherwise, it will inherit its environment 
from pdebug.

Regards,

Ryan Mansfield
RE: Setting environment variables on remote target via GDB/Momentics  
Have you tried to set the LD_PRELOAD environment variable in the "Environment" tab of the IDE debug launch configuration
 dialog? The Environment tab lets you set the environment variables and values to use when the program launches.

The other way to set it is to use the GDB command file ".gdbinit". It's defined in the Debugger tab. Put all your "set" 
commands in the GDB command file they will be executed before the debug binary is loaded. 


-----Original Message-----
From: Aaron Adams [mailto:community-noreply@qnx.com] 
Sent: Wednesday, November 24, 2010 11:06 AM
To: general-ide
Subject: Setting environment variables on remote target via GDB/Momentics


I'm trying to preload a library into an application I'm debugging remotely, but seem to be unable to influence the 
environment on the target. Something as simple as LD_PRELOAD=foo.so on the target would be useful.

Right now I'm using the gdb command-line, but if there is a way to do this from Momentics that's fine too. 

After connecting to the target via:
(gdb) target qnx x.x.x.x:####

All of the following commands operate in the context of the host machine:
(gdb) set environment LD_PRELOAD=foo.so
(gdb) set sysroot /location/of/foo.so/
(gdb) set solib-search-path /location/of/foo.so/

Also doing the following doesn't work:
(gdb) r LD_PRELOAD=foo.so bar

I was wondering if anyone had any idea on how I can set the environment remotely through gdb? IN the mean time I know 
that I can use gdb locally on the target machine. And I can also create a wrapper application that sets LD_PRELOAD via 
execve() and start by debugging that. I was just hoping there would be some feature of gdb, or Momentics, that someone 
knew about.

Re: Setting environment variables on remote target via GDB/Momentics  
set nto-inherit-env is working fine, which is preferable as I can use it
from the command-line. I think you're right though, that the environment
tab from the IDE would work. I hadn't tested that, as I was only using
gdb directly so far. I'll give it a shot though.

Ya, having a custom .gdbinit file for handling this situation will be ideal.

Thanks,
Aaron

On 10-11-24 12:47 PM, Andy Jin wrote:
> Have you tried to set the LD_PRELOAD environment variable in the "Environment"
> tab of the IDE debug launch configuration dialog? The Environment tab lets you
> set the environment variables and values to use when the program launches.
>
> The other way to set it is to use the GDB command file ".gdbinit". It's defined
> in the Debugger tab. Put all your "set" commands in the GDB command file they
> will be executed before the debug binary is loaded.
>
>
> -----Original Message-----
> From: Aaron Adams [mailto:community-noreply@qnx.com]
> Sent: Wednesday, November 24, 2010 11:06 AM
> To: general-ide
> Subject: Setting environment variables on remote target via GDB/Momentics
>
>
> I'm trying to preload a library into an application I'm debugging remotely, but
> seem to be unable to influence the environment on the target. Something as
> simple as LD_PRELOAD=foo.so on the target would be useful.
>
> Right now I'm using the gdb command-line, but if there is a way to do this from
> Momentics that's fine too.
>
> After connecting to the target via:
> (gdb) target qnx x.x.x.x:####
>
> All of the following commands operate in the context of the host machine:
> (gdb) set environment LD_PRELOAD=foo.so
> (gdb) set sysroot /location/of/foo.so/
> (gdb) set solib-search-path /location/of/foo.so/
>
> Also doing the following doesn't work:
> (gdb) r LD_PRELOAD=foo.so bar
>
> I was wondering if anyone had any idea on how I can set the environment remotely
> through gdb? IN the mean time I know that I can use gdb locally on the target
> machine. And I can also create a wrapper application that sets LD_PRELOAD via
> execve() and start by debugging that. I was just hoping there would be some
> feature of gdb, or Momentics, that someone knew about.
>
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post75825
>


---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including 
material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any 
use of this information by anyone other than the intended recipient is prohibited. If you have received this 
transmission in error, please immediately reply to the sender and delete this information from your system. Use, 
dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be 
unlawful.