Visualising CGRects and NSRects from lldb with drawrect
Halfway through debugging the new enumeration engine for Shortcat, I realised I needed a way to visualise
NSRects while debugging. Trying to figure out how one
CGRect relates to another by looking at four numbers is a PITA.
I decided to write a tool to solve this problem. I also took the chance to actually develop an app with RubyMotion.
drawrect is a command line tool for OS X that simply draws translucent rectangles on the screen.
You can use it from within
lldb (provided you installed the scripts) or from the command line.
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
I couldn’t find a way to hook into process termination or resuming in
lldb, so you would have to clear the rects manually with
lldb. If someone knows how to do this, please let me know in the comments!
I’d like to add a feature where you could hover over a
NSRect in the Variable view and it would highlight, but I’m not sure how to do this without resorting to Accessibility.
drawrect is useful to others! Let me know if this has been useful to you.