{"id":5697,"date":"2012-08-14T14:11:50","date_gmt":"2012-08-14T19:11:50","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=5697"},"modified":"2012-08-16T20:52:34","modified_gmt":"2012-08-17T01:52:34","slug":"lldb-from-python","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2012\/08\/14\/lldb-from-python\/","title":{"rendered":"LLDB From Python"},"content":{"rendered":"<p><a href=\"http:\/\/www.libertypages.com\/clarktech\/?p=4289\">Clark Goble<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.libertypages.com\/clarktech\/?p=4289\"><p>The main debugger, lldb, comes with Python built in! [&#8230;] it appears you can actually have a Python script run when a breakpoint gets hit. The current stack frame and breakpoint location are passed to your function.<\/p><\/blockquote>\n<p>I tend to instrument my code because I really dislike clicking around in the debugger. This seems to have a lot of potential for making debugging faster.<\/p>\n<p>Update (2012-08-15): <a href=\"http:\/\/www.libertypages.com\/clarktech\/?p=4303\">Clark Goble<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.libertypages.com\/clarktech\/?p=4303\"><p>What you could do to make the above function a tad more useful is keep a global counter that is incremented in every call to the Python function and then increment the column in Numbers by the same amount. That&rsquo;ll give you a nice spreadsheet listing variables and their value according to time. More than a slight bit more readable than trying to traverse the output of numerous NSLog calls. You could even write a script that reads the values in say the first column down, treating them as variable names, and then print their values.<\/p><\/blockquote>\n<p>Update (2012-08-16): <a href=\"http:\/\/www.libertypages.com\/clarktech\/?p=4341\">Clark Goble<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.libertypages.com\/clarktech\/?p=4341\"><p>When you print things from your Python scripts the first time off a break not everything will print. At first I thought Python-lldb weren&rsquo;t seeing all the variables. However everything gets copied to the spreadsheet properly. So it&rsquo;s really a bug in Xcode where all the text output isn&rsquo;t getting displayed correctly. This is useful to know if you start relying on lldb and scripting. Interestingly the second time you run your script on a single breakpoint the problem disappears. Until you advance your position in code whereupon it all begins again. Undoubtedly a small bug that will be fixed in a future Xcode version.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Clark Goble: The main debugger, lldb, comes with Python built in! [&#8230;] it appears you can actually have a Python script run when a breakpoint gets hit. The current stack frame and breakpoint location are passed to your function. I tend to instrument my code because I really dislike clicking around in the debugger. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-5697","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/5697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=5697"}],"version-history":[{"count":6,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/5697\/revisions"}],"predecessor-version":[{"id":5711,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/5697\/revisions\/5711"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=5697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=5697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=5697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}