public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Integer arguments passed to inferior's functions
@ 2011-10-30 10:07 Eli Zaretskii
  2011-10-30 13:51 ` Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2011-10-30 10:07 UTC (permalink / raw)
  To: gdb

If I type

  (gdb) call foo(1)

what will be the type of the argument GDB will pass to `foo'?  Will
GDB look up the function signature or will it use some default?.  If
the former, what happens when the signature is unknown or unavailable?
If the latter, how is that default computed? does it depend on the
inferior's architecture, for instance?

Apologies if this is in the manual and I missed it; at least the node
"Calling" keeps silent about this issue.

TIA

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Integer arguments passed to inferior's functions
  2011-10-30 10:07 Integer arguments passed to inferior's functions Eli Zaretskii
@ 2011-10-30 13:51 ` Jan Kratochvil
  2011-10-30 18:22   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2011-10-30 13:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb

On Sun, 30 Oct 2011 07:38:44 +0100, Eli Zaretskii wrote:
> If I type
> 
>   (gdb) call foo(1)
> 
> what will be the type of the argument GDB will pass to `foo'?  Will
> GDB look up the function signature or will it use some default?.

Yes, it looks up the function signature, see the value_arg_coerce call in
call_function_by_hand.  It uses the passed parameter (typeof (1) -> int here)
if the parameter is after the known count of parameter types.


> If the former, what happens when the signature is unknown or unavailable?

The known parameters count is 0 in such case.


> If the latter, how is that default computed?

value_type of that value (1 here, therefore int).


> does it depend on the inferior's architecture, for instance?

After all these types are determined you are right the types are further
promoted depending on the arch, by gdbarch_push_dummy_call.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Integer arguments passed to inferior's functions
  2011-10-30 13:51 ` Jan Kratochvil
@ 2011-10-30 18:22   ` Eli Zaretskii
  2011-10-30 19:06     ` Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2011-10-30 18:22 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb

> Date: Sun, 30 Oct 2011 14:30:01 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb@sourceware.org
> 
> On Sun, 30 Oct 2011 07:38:44 +0100, Eli Zaretskii wrote:
> > If I type
> > 
> >   (gdb) call foo(1)
> > 
> > what will be the type of the argument GDB will pass to `foo'?  Will
> > GDB look up the function signature or will it use some default?.
> 
> Yes, it looks up the function signature, see the value_arg_coerce call in
> call_function_by_hand.  It uses the passed parameter (typeof (1) -> int here)
> if the parameter is after the known count of parameter types.

And 1 is an int because it has no l/ll qualifier?

> > does it depend on the inferior's architecture, for instance?
> 
> After all these types are determined you are right the types are further
> promoted depending on the arch, by gdbarch_push_dummy_call.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Integer arguments passed to inferior's functions
  2011-10-30 18:22   ` Eli Zaretskii
@ 2011-10-30 19:06     ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2011-10-30 19:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb

On Sun, 30 Oct 2011 19:17:07 +0100, Eli Zaretskii wrote:
> And 1 is an int because it has no l/ll qualifier?

I think so:

(gdb) ptype 1
type = int
(gdb) ptype 1L
type = long
(gdb) ptype 1LL
type = long long


Regards,
Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-30 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-30 10:07 Integer arguments passed to inferior's functions Eli Zaretskii
2011-10-30 13:51 ` Jan Kratochvil
2011-10-30 18:22   ` Eli Zaretskii
2011-10-30 19:06     ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).