From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14757 invoked by alias); 2 Sep 2008 21:27:00 -0000 Received: (qmail 14744 invoked by uid 22791); 2 Sep 2008 21:27:00 -0000 X-Spam-Check-By: sourceware.org Received: from wmproxy1-g27.free.fr (HELO wmproxy1-g27.free.fr) (212.27.42.91) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 02 Sep 2008 21:26:20 +0000 Received: from UNKNOWN (unknown [172.20.243.132]) by wmproxy1-g27.free.fr (Postfix) with ESMTP id D0D362B40F for ; Tue, 2 Sep 2008 23:50:18 +0200 (CEST) Received: by UNKNOWN (Postfix, from userid 0) id 7850B791F8D; Tue, 2 Sep 2008 23:26:17 +0200 (CEST) Received: from ([82.227.65.140]) by imp.free.fr (IMP) with HTTP for ; Tue, 02 Sep 2008 23:26:17 +0200 Message-ID: <1220390777.48bdaf79617dd@imp.free.fr> Date: Tue, 02 Sep 2008 21:27:00 -0000 From: J R To: gdb@sourceware.org Subject: how to examine data with compiler optimization option set? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.8 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: 2008-09/txt/msg00008.txt.bz2 Extract of GDB user manual: "Another possible effect of compiler optimizations is to optimize unused variables out of existence, or assign variables to registers (as opposed to memory addresses). Depending on the support for such cases offered by the debug info format used by the compiler, GDB might not be able to display values for such local variables. To solve such problems, either recompile without optimizations, or use a different debug info format, if the compiler supports several such formats. For example, GCC, the GNU C/C++ compiler usually supports the `-gstabs' option. `-gstabs' produces debug info in a format that is superior to formats such as COFF. You may be able to use DWARF2 (`-gdwarf-2'), which is also an effective form for debug info. See section `Options for Debugging Your Program or GNU CC' in Using GNU CC, for more information." I wanted to keep the optimization option, so I tried to recompile with GCC, using the -gstabs and -gdwarf-2 options, and even -g3, with this very simple program: int main(void){ int a = 1; int b = 2; int c = a+b; printf("Value c = %d \n", c); } But still couldn't display the variables a, b and c! Is there a particular compiling option configuration to set? Many thanks in advance. Regards.