Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Dave Korn" <dave.korn@artimi.com>
To: "'Hadron'" <rileyrg@googlemail.com>,
		"'Nick Roberts'" <nickrob@snap.net.nz>
Cc: "'Jim Blandy'" <jimb@codesourcery.com>,
		"'Hadron'" <hadronquark@googlemail.com>, 	<gdb@sourceware.org>
Subject: RE: argc - cant access memory
Date: Tue, 10 Jul 2007 19:41:00 -0000	[thread overview]
Message-ID: <00a401c7c32a$567046f0$2e08a8c0@CAM.ARTIMI.COM> (raw)
In-Reply-To: <87hcoc5uef.fsf@gmail.com>

On 10 July 2007 13:13, Hadron wrote:


> As for optimizing the arguments away, wouldn't this be the case for all
> the lines referencing argc in the main()? But is this the typical
> "error" for such a case?

  Ah, I've just recognised what's going on here, this is not optimisation,
that's a red herring.
 
> 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 is normal behaviour.  It's nothing to do with optimisation: it's just
that gdb breakpoints at the very start of the function epilogue, but none of
the arguments parameters are accessible in the expected places indicated by
the debug info until after the epilogue has created the stack frame, etc.

  Try this with any function you like: set a breakpoint on the very first line
- the one with the opening '{' of the function, run until you hit the
breakpoint.  You'll see nonsense in the locals and arguments.  Now use the
'next' function to step over the opening brace - which amounts to stepping
over the function epilogue - and suddenly all those variables will spring into
being with their correct values.

  It's a cosmetic glitch that gdb fails to say something like "not in scope"
before the prologue has completed.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


  reply	other threads:[~2007-07-10 19:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09 13:26 Hadron
2007-07-09 21:04 ` Jim Blandy
2007-07-09 22:34   ` Nick Roberts
2007-07-10 12:13     ` Hadron
2007-07-10 19:41       ` Dave Korn [this message]
2007-07-10 19:46         ` Daniel Jacobowitz
2007-07-10 19:50           ` Dave Korn
2007-07-11 21:13         ` Jim Blandy
2007-07-11 17:41       ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00a401c7c32a$567046f0$2e08a8c0@CAM.ARTIMI.COM' \
    --to=dave.korn@artimi.com \
    --cc=gdb@sourceware.org \
    --cc=hadronquark@googlemail.com \
    --cc=jimb@codesourcery.com \
    --cc=nickrob@snap.net.nz \
    --cc=rileyrg@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox