From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22341 invoked by alias); 11 Jul 2007 17:41:41 -0000 Received: (qmail 22333 invoked by uid 22791); 11 Jul 2007 17:41:41 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jul 2007 17:41:39 +0000 Received: (qmail 4119 invoked from network); 11 Jul 2007 17:41:37 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Jul 2007 17:41:37 -0000 To: Hadron Cc: Nick Roberts , Hadron , gdb@sourceware.org Subject: Re: argc - cant access memory References: <87ejjhg137.fsf@gmail.com> <18066.47080.812496.129394@kahikatea.snap.net.nz> <87hcoc5uef.fsf@gmail.com> From: Jim Blandy Date: Wed, 11 Jul 2007 17:41:00 -0000 In-Reply-To: <87hcoc5uef.fsf@gmail.com> (Hadron's message of "Tue, 10 Jul 2007 14:13:12 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2007-07/txt/msg00093.txt.bz2 Hadron writes: > I get the message after stepping over the first line in main and then > when I get to line 3 (in main) then I get > > #0 main (argc=191860, argv=0xb7f49850) at hello.c:94 > > (94 is the line "glutInitWindowSize (250, 250);" in main) > > If you say this is normal behaviour then fine, but I haven't experienced > it before. I would be interested to hear if you get the same. This really looks like what happens when you debug optimized code. The compiler emits debugging information that doesn't accurately relate the machine code it generated to the original source. If this is the case, there isn't much a debugger can do about it. You might try re-compiling without optimization. But the make fragment you posted didn't look like it was compiled with optimization. Without optimization, the compiler is supposed to generate code which behaves as expected under the debugger; from the GCC manual: Without any optimization option, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.