From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20855 invoked by alias); 24 May 2006 04:43:58 -0000 Received: (qmail 20842 invoked by uid 22791); 24 May 2006 04:43:56 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0102.google.com (HELO nz-out-0102.google.com) (64.233.162.202) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 May 2006 04:43:17 +0000 Received: by nz-out-0102.google.com with SMTP id 14so1194757nzn for ; Tue, 23 May 2006 21:43:16 -0700 (PDT) Received: by 10.64.131.17 with SMTP id e17mr2632031qbd; Tue, 23 May 2006 21:43:16 -0700 (PDT) Received: by 10.65.224.3 with HTTP; Tue, 23 May 2006 21:43:16 -0700 (PDT) Message-ID: <5f3d30900605232143w18744017s439a8762616b53e8@mail.gmail.com> Date: Wed, 24 May 2006 09:16:00 -0000 From: "Arijit Das" To: "Bob Rossi" , "Arijit Das" , gdb@sourceware.org Subject: Re: How to portably print out Env of a Process In-Reply-To: <20060523130544.GA21177@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <5f3d30900605222046t810dd4cue180cba7b0541fa7@mail.gmail.com> <20060523125622.GA15393@brasko.net> <20060523130544.GA21177@nevyn.them.org> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00347.txt.bz2 Thanks... (gdb) p ((char * (*)()) getenv) ("HOME") seems to be working fine so far. But couldn't make sense of the cast logically. As you said, ideally, it should have been something like (gdb) p ((char * (*)(const char *)) getenv) ("HOME") which doesn't work! -Arijit On 5/23/06, Daniel Jacobowitz wrote: > On Tue, May 23, 2006 at 08:56:22AM -0400, Bob Rossi wrote: > > On Tue, May 23, 2006 at 09:16:42AM +0530, Arijit Das wrote: > > > Hi, > > > > > > Is it possible to print out the env of a process portably with the > > > same cmdline/script in different os/arch combinations? > > > > > > Here is how I tried to do it for i686 - RH3.0: > > > > > > (gdb) p (char *) getenv("HOME") > > > [Switching to Thread 1024 (LWP 17639)] > > > $1 =3D 0xdffff781 "/remote/vtghome7/arijit" > > > (gdb) > > > > > > It worked fine. > > > > > > But when I tried executing this command in x86_64, I got strange resu= lts: > > > > > > (gdb) p (char *) getenv("HOME") > > > [Switching to Thread 182901576896 (LWP 26427)] > > > $1 =3D 0xffffffffbfffc790
> > > (gdb) > > > > > > I guess some kind of 32/64 bits conversion might be messing things up > > > here....but am not sure exactly what? Any help here? > > Exactly. Try this: > > (gdb) p ((char * (*)()) getenv) ("HOME") > > I first tried (char * (*) (char *)), but GDB reported that as an > invalid cast. I'm not sure why. > > > > > How about, 'shell echo $HOME'? > > If you wanted that, "show env", but you don't - the child's might be > different. > > -- > Daniel Jacobowitz > CodeSourcery >