From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joel Brobecker To: Kevin Buettner Cc: Michael Snyder , gdb-patches@sources.redhat.com Subject: Re: Pb when calling a nested function in the inferior Date: Tue, 31 Jul 2001 00:24:00 -0000 Message-id: <20010731092456.B31388@act-europe.fr> References: <20010730144818.A4726@act-europe.fr> <3B659961.26242FE@cygnus.com> <1010730183050.ZM5116@ocotillo.lan> <20010730232457.A8362@act-europe.fr> <1010730224909.ZM5581@ocotillo.lan> X-SW-Source: 2001-07/msg00746.html > Have you verified that the mechanisms used by gcc and by Ada95 for > passing the static chain are the same? Yes. Actually, the code was exactly the same. > 1) In the version of gcc that I'm using the symbol that's associated > with get_value() is get_value.0. You could look for such symbols > and refuse to allow them to be called as inferior functions. this suggestion has my preference, being more general than the suggestion below. Let me check it out. > 2) You could scan the prologue and look for a sequence of instructions > which looks like a save of the static chain. E.g, in your example, > I see: > > 0x804842c : push %ebp > 0x804842d : mov %esp,%ebp > 0x804842f : sub $0x4,%esp > 0x8048432 : mov %ecx,0xfffffffc(%ebp) > 0x8048435 : mov 0xfffffffc(%ebp),%ecx > 0x8048438 : mov %ecx,%ecx > 0x804843a : mov 0xfffffffc(%ecx),%eax > 0x804843d : mov %eax,%eax > 0x804843f : leave > 0x8048440 : ret > > It appears to me that ``mov %ecx,0xfffffffc(%ebp)'' is > responsible for saving the static chain pointer. If you could > detect this, you could print your error or warning. (You'd > want to make sure that no other instruction with a destination > of %ecx appears before this instruction in the prologue though; > if it does, it means it's doing something else.) > > BTW, GDB isn't particularly graceful in its handling of the ``get_value.0'' > symbol. E.g, observe what happens when I do ``x/i get_value.0'': > > (gdb) x/i get_value.0 > No symbol "get_value" in current context. That's curious. With my version of gdb, I don't get the same result (using GNU gdb 2001-07-30-cvs (MI_OUT)): (gdb) x/10i get_value.0 A parse error in expression, near `'. (gdb) x/4i get_value 0x8048468 : push %ebp 0x8048469 : mov %esp,%ebp 0x804846b : sub $0x4,%esp 0x804846e : mov %ecx,0xfffffffc(%ebp) -- Joel