Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: debugging on Intel macs



On Apr 6, 2006, at 11:36 AM, Aurélien Hugelé wrote:

I'm really sorry to bother you with this, but i don't understand anything...
(gdb) po *(int *) ($esp + 4)
sometimes display "self" (objC speaking), which is equivalent to $r3 on PPC
sometimes causes a KERN_PROTECTION_FAILURE
sometimes display "something" which is not self nor an argument.


Can you please describe the rule (i hope it is simple, but i fear that it's a total mess) if there is one, I'm only interested in objC/Cocoa debugging...

i want the self argument
the _cmd argument (current selector)
and the possible folowing arguments

Thanks a lot, i'm totally lost and unproductive with my new iMac :(

The expression I described above will give you self if you do a 'b objc_msgSend'. That's because
a) objc_msgSend doesn't use a frame pointer, so %ebp isn't set to anything useful
and
b) %esp hasn't been changed yet at the point in objc_msgSend where 'b objc_msgSend' sets its breakpoint.


The standard rule is as I described originally -- the first argument is at %ebp + 8, the second is at %ebp + 12, etc. objc_msgSend is one of the exceptions, where on the first instruction arguments are at %esp + 4, %esp + 8, etc.

There's obviously more to know, but this isn't really the right place to describe the x86 calling convention. See <http://developer.apple.com/documentation/DeveloperTools/Conceptual/ LowLevelABI/Articles/IA32.html> for details on that. Note that the "saved frame pointer" described on that page is optional, which is what's happening in the objc_msgSend case.

-Eric

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >Re: debugging on Intel macs (From: Aurélien Hugelé <email@hidden>)
 >Re: debugging on Intel macs (From: Eric Albert <email@hidden>)
 >Re: debugging on Intel macs (From: Aurélien Hugelé <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.