From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10859 invoked by alias); 23 May 2006 13:05:52 -0000 Received: (qmail 10849 invoked by uid 22791); 23 May 2006 13:05:51 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Tue, 23 May 2006 13:05:49 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FiWa1-0005XE-JW; Tue, 23 May 2006 09:05:45 -0400 Date: Tue, 23 May 2006 22:07:00 -0000 From: Daniel Jacobowitz To: Bob Rossi Cc: Arijit Das , gdb@sourceware.org Subject: Re: How to portably print out Env of a Process Message-ID: <20060523130544.GA21177@nevyn.them.org> Mail-Followup-To: Bob Rossi , Arijit Das , gdb@sourceware.org References: <5f3d30900605222046t810dd4cue180cba7b0541fa7@mail.gmail.com> <20060523125622.GA15393@brasko.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060523125622.GA15393@brasko.net> User-Agent: Mutt/1.5.11+cvs20060403 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/msg00336.txt.bz2 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 = 0xdffff781 "/remote/vtghome7/arijit" > > (gdb) > > > > It worked fine. > > > > But when I tried executing this command in x86_64, I got strange results: > > > > (gdb) p (char *) getenv("HOME") > > [Switching to Thread 182901576896 (LWP 26427)] > > $1 = 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