Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro_alves@portugalmail.pt>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Teach i386 prologue reader about _alloca and __main
Date: Sun, 14 Oct 2007 02:24:00 -0000	[thread overview]
Message-ID: <4711528C.60300@portugalmail.pt> (raw)
In-Reply-To: <200710132107.l9DL7Rd4014026@brahms.sibelius.xs4all.nl>

Mark Kettenis wrote:
> 
> Do I understand correctly that this is not really Cygwin specific, but
> done for all targets with executable formats that don't have a concept
> of constructors (like ELF with .init)?
> 

Correct.


>> Gcc >= 4.1 can put code in the prologue to realign the stack pointer.
>> In that case, the frame base will not be the same as the incoming args
>> address, so gdb prints garbage for the arguments:
>>
>> main (argc=2280856, argv=0x61006198) at main.c:8
> 
> This is why you added i386_frame_args_address() isn't it?  I thought
> GCC would actually copy the arguments in that case, but apperently
> that doesn't happen (anymore).  Perhaps I'm just mistaken though.
> 

Yes, that's why I added it.  Humm, I'll have to try it out on
another target to see if its a Cygwin specific gcc problem.

> It's probably best to seperate this bit form the __main/_alloca mess.
> 

Will do.

>> Comments?
> 
> I'm not too happy about this.  It adds a lot of complexity for
> something I think the compiler should emit proper debug information
> for.  Did you raise the issue with the GCC people?  What was their
> answer?
> 

I can't say I am happy either.
I'll see if I can simplify it a bit, by only caring about -O0.

I did raise it with GCC almost a year ago, in the form of a patch:
http://gcc.gnu.org/ml/gcc-patches/2006-12/msg00633.html

Got no replies, but then again, I never pinged it.

We have to live with current compilers, though.

> I think the alloca analysis should only happen on targets that need
> it.  I wonder why GCC needs to make a library call, where it seems
> simply touching every page would be enough.
> 

Dunno.  The MSFT version of __chkstk supposedly compares the amount
of stack space a function requires with the amount the stack space
available, specified in the EXE header, and I guess specified on thread
creation.

http://support.microsoft.com/?scid=kb%3Ben-us%3B100775&x=10&y=10

gcc's version doesn't, so, it looks like work waiting for a volunteer.

> Also, in i386_frame_cache(), I'd make the comment about where to
> finding %ecx a bit more general.  I can think of other reasons why
> that register might have been pushed onto the stack.  Might as well
> seperate out that bit from the diff too.
> 

Will do.  Thanks.

Cheers,
Pedro Alves



  reply	other threads:[~2007-10-13 23:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-13 20:26 Pedro Alves
2007-10-13 21:09 ` Daniel Jacobowitz
2007-10-13 23:20   ` Pedro Alves
2007-10-14 15:55     ` Daniel Jacobowitz
2007-10-13 21:14 ` Mark Kettenis
2007-10-14  2:24   ` Pedro Alves [this message]
2007-12-05 10:11 ` [RFC] testsuite: Skip over function prologue in runto and runto_main Pierre Muller
2007-12-05 22:56   ` Pedro Alves
2007-12-06 16:34     ` Pierre Muller
2007-12-06 17:07       ` Daniel Jacobowitz

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=4711528C.60300@portugalmail.pt \
    --to=pedro_alves@portugalmail.pt \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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