<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Mon, 17 Aug 2026 11:00:27 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Hugo Rumens - 2012-08-23 13:46:10</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>This article is a great resource.
&lt;br /&gt;
&lt;br /&gt;One thing I would add is I've found that putting in a cast for the return type when doing a print-object is not always necessary, e.g. with a method returning a string, both of these work:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;(gdb) po [someObject someMethodReturningNSString]
&lt;br /&gt;or
&lt;br /&gt;(gdb) po (NSString *) [someObject someMethodReturningNSString]
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;However, if trying to call a method that takes an argument:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;- (NSString *)someMethod:(NSDictionary *)dict;
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;calling
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;(gdb) po (NSString *) [someObject someMethod:[NSDictionary dictionary]]
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;gives you the infamous (even though there is a return type cast)
&lt;br /&gt;
&lt;br /&gt;Unable to call function "objc_msgSend" at 0x7fff84f100f4: no return type information available.
&lt;br /&gt;
&lt;br /&gt;You have to cast the argument as well:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;(gdb) po (NSString *) [someObject someMethod:(NSDictionary *) [NSDictionary dictionary]]
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;I've also found you can't pass nil - this won't work:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;(gdb) po (NSString *) [someObject someMethod:(NSDictionary *) nil]
&lt;br /&gt;&lt;/code&gt;</description><guid isPermaLink="true">1b02944177472e39d58afcdae4f3ddb2</guid><pubDate>Thu, 23 Aug 2012 13:46:10 GMT</pubDate></item><item><title>mikeash - 2011-07-15 01:13:12</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Very cool, thanks!</description><guid isPermaLink="true">ebfd884fad7d71e0df88892ed91fc364</guid><pubDate>Fri, 15 Jul 2011 01:13:12 GMT</pubDate></item><item><title>Sagyuwara  - 2011-07-14 02:27:56</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>I'm sorry for not responding sooner. 
&lt;br /&gt;The link is &lt;a href="http://www.cocoachina.com/bbs/read.php?tid-66525.html"&gt;http://www.cocoachina.com/bbs/read.php?tid-66525.html&lt;/a&gt;.
&lt;br /&gt;Thanks again.</description><guid isPermaLink="true">94576c68c7acc99cf44c1da3f4f53cd4</guid><pubDate>Thu, 14 Jul 2011 02:27:56 GMT</pubDate></item><item><title>mikeash - 2011-07-08 14:20:49</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Please feel free to post translations, just provide attribution and a link to the original. If you do this, I'd love to see a link to the translation even if I can't understand it!</description><guid isPermaLink="true">623e1e244dfe3427ec413182eb181feb</guid><pubDate>Fri, 08 Jul 2011 14:20:49 GMT</pubDate></item><item><title>Sagyuwara  - 2011-07-08 08:01:56</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Very simple and clear article. Thanks a lot.
&lt;br /&gt;
&lt;br /&gt;Is it allowed to translate and post it on other forums?</description><guid isPermaLink="true">6327c722f9d4a11fb06dbf737bcf5b99</guid><pubDate>Fri, 08 Jul 2011 08:01:56 GMT</pubDate></item><item><title>Ben - 2011-07-06 19:44:24</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Awesome article, interesting to see the things it can do with Objective-C.
&lt;br /&gt;
&lt;br /&gt;Don't forget about the &lt;code&gt;step&lt;/code&gt; and &lt;code&gt;finish&lt;/code&gt; commands (abbreviated &lt;code&gt;s&lt;/code&gt; and &lt;code&gt;f&lt;/code&gt;).  They let you step into and out of the current function and are very useful for navigating shallow stacks when debugging in a localized area.</description><guid isPermaLink="true">3f58be4cc63923f6471c262282532112</guid><pubDate>Wed, 06 Jul 2011 19:44:24 GMT</pubDate></item><item><title>Mohamed - 2011-06-29 20:56:31</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Very nice tutorial.  Very nice.</description><guid isPermaLink="true">bff2540fec63612c9e390107af80dbd5</guid><pubDate>Wed, 29 Jun 2011 20:56:31 GMT</pubDate></item><item><title>SefTarbell - 2011-06-24 14:40:07</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Excellent article, I have found myself struggling with anything in gdb outside the basic p &amp;amp; po. This gave me a bunch of new things to try!</description><guid isPermaLink="true">babac638e4ee045d4b77ede841d967ff</guid><pubDate>Fri, 24 Jun 2011 14:40:07 GMT</pubDate></item><item><title>ssp - 2011-06-21 06:09:13</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Thanks for the examples, Mike.</description><guid isPermaLink="true">dc9cfb7ca764482674ffaf8aefed10f5</guid><pubDate>Tue, 21 Jun 2011 06:09:13 GMT</pubDate></item><item><title>mikeash - 2011-06-21 01:28:12</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Xcode does allow you to access nearly everything gdb can do, but there are a couple of gotchas.
&lt;br /&gt;
&lt;br /&gt;One is that if you ever need to run gdb as root, say, to debug a process that runs as root, Xcode gets really inconvenient.
&lt;br /&gt;
&lt;br /&gt;The other is that Xcode's GUI wrapper is buggy. I've had bugs in my code which completely destroyed Xcode's debugger due to weird data propagating up to the UI layer, but which command-line gdb handled fine.</description><guid isPermaLink="true">9280a8846867e65f067053376832871e</guid><pubDate>Tue, 21 Jun 2011 01:28:12 GMT</pubDate></item><item><title>SSteve - 2011-06-20 22:00:15</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Oh, sorry. I didn't notice the &lt;code&gt;@&lt;/code&gt; got removed. I thought that line of code was just a placeholder. I obviously need to try harder to read bugs. :-)</description><guid isPermaLink="true">d5421809cedf8de4299acd5270ecd82e</guid><pubDate>Mon, 20 Jun 2011 22:00:15 GMT</pubDate></item><item><title>ssp - 2011-06-20 21:38:10</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Very nice writeup, thanks a lot!
&lt;br /&gt;
&lt;br /&gt;For curiosity's sake: care to give an example of something that doesn't work when using gdb from Xcode? I had the impression that – among the GUI-stuff – Xcode just offers a gdb console as well.</description><guid isPermaLink="true">a249e54545aec6a8a71d9a9f590aada0</guid><pubDate>Mon, 20 Jun 2011 21:38:10 GMT</pubDate></item><item><title>mikeash - 2011-06-20 21:31:22</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>If you mean the very first one under Getting Started, that's intended to be a working program. The bugs come later. It was tough to come up with realistic bugs, though....</description><guid isPermaLink="true">cf8f288c10d761b043ed3b8036cc0ba2</guid><pubDate>Mon, 20 Jun 2011 21:31:22 GMT</pubDate></item><item><title>SSteve - 2011-06-20 21:03:09</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>The first code example shouldn't have the &lt;code&gt;@&lt;/code&gt; before &lt;code&gt;"Hello World!"&lt;/code&gt;. You obviously need to try harder to write bugs. :-)</description><guid isPermaLink="true">db03f6903a76626b837c44e9991e4398</guid><pubDate>Mon, 20 Jun 2011 21:03:09 GMT</pubDate></item><item><title>Pádraig Brady - 2011-06-20 11:56:01</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>My most common use of gdb is with: gdb -tui -args ....
&lt;br /&gt;That starts a curses interface which you can see in action here:
&lt;br /&gt;&lt;a href="http://www.pixelbeat.org/programming/debugger/"&gt;http://www.pixelbeat.org/programming/debugger/&lt;/a&gt;</description><guid isPermaLink="true">1e3dd1c6956756cac0ff991cadd2b81e</guid><pubDate>Mon, 20 Jun 2011 11:56:01 GMT</pubDate></item><item><title>mikeash - 2011-06-20 01:43:08</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Running gdb separately is really only for when you can't, or at least don't want to, get Xcode involved at all. For example, debugging processes belonging to a different user, where you need to run the debugger as root, or getting gdb attached to some process for which there's no corresponding Xcode project, or unfortunate situations where you trigger bugs in Xcode which cause it to crash or otherwise fail at debugging. It's a nice skill to have because of that, but it doesn't really help except for specific situations.</description><guid isPermaLink="true">0e54b081e11c36864a6133403315d47a</guid><pubDate>Mon, 20 Jun 2011 01:43:08 GMT</pubDate></item><item><title>Dad - 2011-06-19 20:06:47</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>GOLD!  Great stuff!  Thanks Mike.</description><guid isPermaLink="true">f4cd8f961e8bba97af9d20a94102a13d</guid><pubDate>Sun, 19 Jun 2011 20:06:47 GMT</pubDate></item><item><title>Evgeniy Dzhurov - 2011-06-18 10:44:34</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Thanks for the article, it's quite useful. And I have one question to add. As I'm used to running gdb from Xcode and occasionally throw in commands as I learn, are there any significant capabilities that I'm missing out by not running the debugger separately as per your advice. Perhaps something must-know for day to day Xcode development?</description><guid isPermaLink="true">f49528d70c6850eef3aadc09ad298876</guid><pubDate>Sat, 18 Jun 2011 10:44:34 GMT</pubDate></item><item><title>Vasi - 2011-06-17 21:33:16</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>If you want to provide arguments to the target at the command-line, you can use:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;gdb --args /path/to/executable arg1 arg2 etc&lt;/code&gt;</description><guid isPermaLink="true">b08285b81b437a38017d0721d2293d35</guid><pubDate>Fri, 17 Jun 2011 21:33:16 GMT</pubDate></item><item><title>Randy Becker - 2011-06-17 21:07:39</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2011-06-17-gdb-tips-and-tricks.html#comments</link><description>Great article, as always.  I do wish you had mentioned &lt;code&gt;x/s&lt;/code&gt;.  I often use it to inspect selectors that will be passed to &lt;code&gt;objc_msgSend()&lt;/code&gt;.</description><guid isPermaLink="true">3c5ee7c88169cba568117b662b29d233</guid><pubDate>Fri, 17 Jun 2011 21:07:39 GMT</pubDate></item></channel></rss>
