Re: Advanced GDB question: menu item enabling / disabling debugging
Re: Advanced GDB question: menu item enabling / disabling debugging
- Subject: Re: Advanced GDB question: menu item enabling / disabling debugging
- From: Ken Thomases <email@hidden>
- Date: Fri, 25 Sep 2009 18:17:48 -0500
On Sep 25, 2009, at 9:34 AM, Eric Gorr wrote:
What I would like to do is the following:
1. Set a break point on DisableMenuItem & DisableItem - easy to do,
just enter 'b DisableMenuItem' from the GDB command line
2. Set a condition on this break point to only fire when the menu
item text of the menu item being disabled is 'Undo' - hard...???
Yes, hard. Or at least complex. I think it might be something like
this (composed in email, untested, appropriate for i386):
set $menuTitle=(void**)malloc(sizeof(void*))
condition <n> (((int)CopyMenuItemTextAsCFString(*(void**)($ebp+8),
*(unsigned short*)($ebp+12), $menuTitle)==0 && (int)CFEqual(*
$menuTitle, @"Undo"))
If you're on another architecture, you'll need to figure out how to
access the arguments in the registers or stack frame.
Note that the above leaks CFStrings like a sieve. It might be
acceptable for a brief debugging session, though.
3. When the conditional break point fires, get a backtrace - easy,
from the GDB command line:
commands n
backtrace
end
where n is the break point # determined in #1
I would also like to print out the name of the menu item being
disabled - hard...?
call (void)CFShow(*$menuTitle)
or
po *$menuTitle
Good luck,
Ken
_______________________________________________
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