Re: Inspecting Obj-C method parameters from gdb
Re: Inspecting Obj-C method parameters from gdb
- Subject: Re: Inspecting Obj-C method parameters from gdb
- From: "Clark Cox" <email@hidden>
- Date: Tue, 6 May 2008 10:20:50 -0700
Here's the cheat sheet that I keep in a Stickies window:
x86:
$ebp+8+4n -> arg(n)
… -> …
$ebp+4 -> Return addr
$ebp+8 -> arg0 (self)
$ebp+12 -> arg1 (_cmd)
$ebp+16 -> arg2
$ebp -> Previous $ebp
x86-64:
$rdi -> arg0 (self)
$rsi -> arg1 (_cmd)
$rdx -> arg2
$rcx -> arg3
$r8 -> arg4
$r9 -> arg5
ppc:
$r3 -> arg0 (self)
$r4 -> arg1 (_cmd)
$r5 -> arg2
$r6 -> arg3
$r7 -> arg4
$r8 -> arg5
-(id)method:(id)foo bar:(id)bar baz:(id)baz
ppc: x86-64: x86:
self: $r3 $rdi *(id*)($ebp + 8)
_cmd: $r4 $rsi *(SEL*)($ebp + 12)
foo: $r5 $rdx *(id*)($ebp + 16)
bar: $r6 $rcx *(id*)($ebp + 20)
So, to print out self on i386, one does:
po *(id*)($ebp + 8)
To print out the first parameter to the method (assuming that it is an
object), one does:
*(id*)($ebp + 16)
ppc and ppc64 are essentially identical.
On Tue, May 6, 2008 at 8:12 AM, Sean McBride <email@hidden> wrote:
> Hi all,
>
> I've read conflicting info in TN2124 (Debugging Magic) and the list
> archives, so I'm hoping someone can straighten this out. :)
>
> If I'm debugging Obj-C code for which I don't have source, how can I
> inspect method parameters? My understanding is on ppc 'self' is in $r3
> and '_cmd' (the method selector) is in $r4.
>
> On i386, I've seen some references to 'esp + 4' and others to 'ebp +
> 8'. But I'm not sure which is correct.
>
> And as for ppc64 and x86_64, I can't find much info at all.
>
> Thanks,
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng email@hidden
> Rogue Research www.rogue-research.com
> Mac Software Developer Montréal, Québec, Canada
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
Clark S. Cox III
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden