From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12825 invoked by alias); 8 May 2011 08:05:21 -0000 Received: (qmail 12816 invoked by uid 22791); 8 May 2011 08:05:20 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 08 May 2011 08:05:06 +0000 Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [172.25.149.14]) by smtp-out.google.com with ESMTP id p485gVcr022071 for ; Sat, 7 May 2011 22:42:31 -0700 Received: from ywk9 (ywk9.prod.google.com [10.192.11.9]) by hpaq14.eem.corp.google.com with ESMTP id p485gTTX020322 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sat, 7 May 2011 22:42:30 -0700 Received: by ywk9 with SMTP id 9so2081276ywk.7 for ; Sat, 07 May 2011 22:42:29 -0700 (PDT) Received: by 10.151.10.19 with SMTP id n19mr4629814ybi.430.1304833349265; Sat, 07 May 2011 22:42:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.11.17 with HTTP; Sat, 7 May 2011 22:41:59 -0700 (PDT) In-Reply-To: <102a959df9a18135271bc2ddd5ae9eb1@localhost> References: <1fd75d649d5b52f429ef7a945ed1d8c5@localhost> <102a959df9a18135271bc2ddd5ae9eb1@localhost> From: Paul Pluzhnikov Date: Sun, 08 May 2011 08:05:00 -0000 Message-ID: Subject: Re: Inspecting environment variables from a core dump? To: Ludovic Brenta Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00030.txt.bz2 On Wed, Apr 20, 2011 at 5:24 AM, Ludovic Brenta wrote: > > Andreas Schwab wrote: >> Ludovic Brenta writes: >> >>> Does a core dump contain the environment of the program that dumped > core? >> >> A core dump contains the whole used address space of the program, and >> the environment is of course part of it. >> >>> If so, how can I inspect the environment variables? >> >> The environment is always stored in the variable environ. There are possibly two environments: "the environment passed from the kernel at execve(2) time", and "the environment as it was possibly modified by putenv/setenv etc. at crash point". The latter is pointed at by the 'environ' variable. > Thanks but: > > (gdb) p environ > $13 = 0 > (gdb) whatis environ > type = > > Am I simply out of luck or doing something wrong? You aren't doing anything wrong, but you lack debug info needed to make it work. GDB has no special knowledge about the 'environ', but you *do*. Use it! (gdb) print (char ***) &environ $1 = (char ***) 0x7ffff7ffe9a0 (gdb) print $1[0][0]@100 # should print the first 100 env variables. HTH, -- Paul Pluzhnikov