﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-佳为好友-随笔分类-Debug-GDB</title><link>http://cppblog.com/walkklookk/category/17759.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 29 Dec 2012 22:54:31 GMT</lastBuildDate><pubDate>Sat, 29 Dec 2012 22:54:31 GMT</pubDate><ttl>60</ttl><item><title>原：查看retain和release的历史记录</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196792.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:10:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196792.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196792.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196792.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196792.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196792.html</trackback:ping><description><![CDATA[<span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">创建：2011.10.06</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">修改：2011.11.03：增加循环引用的检测。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">malloc_<wbr>history只能查看alloc和dealloc的历史，<wbr>看不到retain和release的历史，<wbr>但是Instruments却可以，我们可以利用之。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">思路是：对想查看的对象进行过度的release，<wbr>这样就可以利用Instruments来查看了。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">简单的方法如下：</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><div style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #eeeeee; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 1150px; word-break: break-all;"><p style="margin: 10px 0px;">static id sNeedReleaseObj = nil;</p><p style="margin: 10px 0px;"><br /></p><p style="margin: 10px 0px;">@interface TTT : NSObject</p><p style="margin: 10px 0px;"><br /></p><p style="margin: 10px 0px;">- (void)releaseUntilCrash;</p><p style="margin: 10px 0px;"><br /></p><p style="margin: 10px 0px;">@end</p><p style="margin: 10px 0px;"><br /></p><p style="margin: 10px 0px;">@implementation TTT</p><p style="margin: 10px 0px;">- (void)delayReleaseUntilCrash</p><p style="margin: 10px 0px;">{</p><p style="margin: 10px 0px;">&nbsp; &nbsp; if (sNeedReleaseObj == nil) {</p><p style="margin: 10px 0px;">&nbsp; &nbsp; &nbsp; &nbsp; return;</p><p style="margin: 10px 0px;">&nbsp; &nbsp; }</p><p style="margin: 10px 0px;">&nbsp; &nbsp; for (int pos=0; pos&lt;10000; pos++) {</p><p style="margin: 10px 0px;">&nbsp; &nbsp; &nbsp; &nbsp; [sNeedReleaseObj release];</p><p style="margin: 10px 0px;">&nbsp; &nbsp; } &nbsp; &nbsp;</p><p style="margin: 10px 0px;">}</p><p style="margin: 10px 0px;"><br /></p><p style="margin: 10px 0px;">- (void)releaseUntilCrash</p><p style="margin: 10px 0px;">{</p><p style="margin: 10px 0px;">&nbsp; &nbsp; [self performSelector:@selector(<wbr>delayReleaseUntilCrash) withObject:nil afterDelay:10.0f];</p><p style="margin: 10px 0px;">}</p><p style="margin: 10px 0px;">@end</p></div><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">调用的时候，可以用：</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><div style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #eeeeee; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 1150px; word-break: break-all;"><p style="margin: 10px 0px;">&nbsp;</p><div><div>&nbsp; &nbsp; &nbsp; &nbsp; TTT *ttt = [[TTT alloc] init];</div><div>&nbsp; &nbsp; &nbsp; &nbsp; sNeedReleaseObj = csvDict;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; [ttt performSelectorOnMainThread:@<wbr>selector(releaseUntilCrash) withObject:nil waitUntilDone:NO];</div></div><p style="margin: 10px 0px;">&nbsp;</p></div><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">csvDict一定会Crash的，<wbr>然后就可以查看csvDict的retain和release历<wbr>史记录了。</div><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">＝＝＝＝＝</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">对于循环引用，也就是A强引用B，B有强引用A，<wbr>导致AB都无法释放的问题。例如：</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><div style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: #eeeeee; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 1150px; word-break: break-all;">-&nbsp;(IBAction)onBtnPressed:(id)<wbr>sender&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;*a&nbsp;=&nbsp;[[A&nbsp;alloc]&nbsp;init];<br />&nbsp;&nbsp;&nbsp;&nbsp;B&nbsp;*b&nbsp;=&nbsp;[[B&nbsp;alloc]&nbsp;init];<br />&nbsp;&nbsp;&nbsp;&nbsp;a.b&nbsp;=&nbsp;b;<br />&nbsp;&nbsp;&nbsp;&nbsp;b.a&nbsp;=&nbsp;a;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;[a&nbsp;release];<br />&nbsp;&nbsp;&nbsp;&nbsp;[b&nbsp;release];<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;TTT&nbsp;*ttt&nbsp;=&nbsp;[[TTT&nbsp;alloc]&nbsp;<wbr>init];<br />&nbsp;&nbsp;&nbsp;&nbsp;sNeedReleaseObj&nbsp;=&nbsp;a;<br />&nbsp;&nbsp;&nbsp;&nbsp;[ttt&nbsp;<wbr>performSelectorOnMainThread:@<wbr>selector(releaseUntilCrash)&nbsp;<wbr>withObject:nil&nbsp;waitUntilDone:<wbr>NO];<br /><br />}</div><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">如果不加入TTT，则上面的代码中，A和B都无法释放。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">加入TTT之后，查看Instruments的结果如下：</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><img src="http://www.cppblog.com/images/cppblog_com/walkklookk/LoopRef.png" width="940" height="143" alt="循环引用释放时的状态图" style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">注意：在倒数2次TTT的调用中间，会有一次-[B dealloc]，这在正常释放的情况下是不存在的，<wbr>只有发生了双重引用才会出现这个问题。<wbr>这说明在A和B循环引用了。因为，TTT释放的是A，<wbr>而上述图例中出现了B，因此说明A和B循环引用了，<wbr>这样就可以直接确定循环引用的2个对象了。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">循环引用是很难发现的，因为它即不是内存泄露，<wbr>也不会出现内存崩溃，只是始终霸占着内存不释放。<wbr>只有通过Instruments的Allocations，<wbr>才能大约判断是哪个对象没有正确释放，<wbr>然后在使用TTT来查找出来。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:10 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196792.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Enabling Remote Debugging via Private APIs in Mobile Safari</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:51:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196767.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196767.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196767.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.08.06</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/" target="_blank" style="color: #1155cc;">http://atnan.com/blog/2011/<wbr>11/17/enabling-remote-<wbr>debugging-via-private-apis-in-<wbr>mobile-safari/</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><h1>Enabling Remote Debugging via Private APIs in Mobile Safari</h1><p style="margin: 0px; padding: 0px; border: 0px; font-size: 0.9em; font: inherit; vertical-align: baseline; color: #aaaaaa; font-family: 'PT Sans', 'Helvetica Neue', Arial, sans-serif; text-transform: uppercase;">NOV 17<span style="margin: 0px; padding: 0px; border: 0px; font-size: 17px; font: inherit; vertical-align: baseline;">TH</span>, 2011</p><div style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; font-family: 'PT Serif', Georgia, Times, 'Times New Roman', serif; line-height: 27.58333396911621px; background-color: #f8f8f8;"><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">The WebKit Web Inspector in Safari &amp; Chrome is part of every decent web developer&#8217;s toolkit, but unfortunately it&#8217;s unavailable in Mobile Safari.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Or is it?</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">While I was researching my previous article on&nbsp;<a href="http://atnan.com/blog/2011/11/03/enabling-and-using-webgl-on-ios/" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">enabling WebGL on iOS via private WebKit APIs</a>, another API caught my eye while I was&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">class-dump</code>ing the private&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">WebKit.framework</code>.</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Private WebView API</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 758px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">@interface</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #d33682 !important;">WebView</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">(WebPrivate)</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">+</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">void</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">_enableRemoteInspector</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">;</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">@end</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">I did a little bit of research and found an article by Pavel Feldman (<a href="https://twitter.com/repenaxa" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">@repenaxa</a>) on the Surfin&#8217; Safari blog about&nbsp;<a href="http://www.webkit.org/blog/1620/webkit-remote-debugging/" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">WebKit&#8217;s remote debugging feature</a>. This private&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">+[WebView _enableRemoteInspector]</code>API enables those same features in mobile WebKit.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><strong style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">Note:&nbsp;</strong>This API is available as of iOS 5.0. To use it, you&#8217;ll need a copy of Xcode with the iOS 5.0 SDK. You&#8217;ll also need to make sure that if you&#8217;ve got the iOS 4.0 SDK installed alongside the iOS 5.0 SDK, that you&#8217;ve selected iOS 5.0 in the iPhone Simulator via the&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">Hardware &#8594; Version</code>&nbsp;menu. Hat tip to Phil Oye (<a href="https://twitter.com/philoye" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">@philoye</a>) for pointing that out.</p><h2>Enabling remote debugging in a&nbsp;<code style="margin: 0px; padding: 0px; border: 0px; font-size: 28px; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace;">UIWebView</code></h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">To see if I could get it working, I checked out a copy of my&nbsp;<a href="https://github.com/atnan/UIWebViewWebGL" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">UIWebViewWebGL</a>&nbsp;project, and called the private API in&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">application:<wbr>didFinishLaunchingWithOptions</code>:</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Enabling the remote inspector on launch</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">4</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">5</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 900px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">-</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">BOOL</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">application:</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">UIApplicati<wbr>on</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">*</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">application</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">didFinishLaunchingWithOptions:</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><wbr>(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">NSDictionary</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">*</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">launchOptions</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">{</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #586e75 !important;">// ...Snipped...</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">[</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">NSClassFromString</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">@"WebView"</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">_enableRemoteInspector</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">];</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #586e75 !important;">// ...Snipped...</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">}</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">The Surfin&#8217; Safari article said the remote debugger runs on port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">9222</code>, but connecting to&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9222/" target="_blank" style="color: #1155cc;">http://localhost:9222</a></code>&nbsp;while the app was running in the simulator didn&#8217;t seem to work.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Using&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">lsof</code>&nbsp;showed that&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebViewWebGL.app</code>&nbsp;was actually listening on port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">9999</code>:</p><pre style="white-space: pre-wrap;"><code style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace;">$ sudo lsof -i TCP -a -p $(pidof UIWebViewWebGL) -P COMMAND    PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME UIWebView 3748 nathan    9u  IPv6 0xffffff800fa25d80      0t0  TCP localhost:9999 (LISTEN) UIWebView 3748 nathan   13u  IPv6 0xffffff80111ba340      0t0  TCP localhost:9999-&gt;localhost:<wbr>52483 (ESTABLISHED) </code></pre><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Now when I pointed my browser at&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9999/" target="_blank" style="color: #1155cc;">http://localhost:9999</a></code>, it worked!</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><img src="http://atnan.com/downloads/WebKit_Remote_Debugger.png" style="margin: 0px auto 1.5em; padding: 0px; border: 0.5em solid white; font-size: 18px; font: inherit; vertical-align: baseline; max-width: 100%; min-height: auto; border-top-left-radius: 0.3em; border-top-right-radius: 0.3em; border-bottom-right-radius: 0.3em; border-bottom-left-radius: 0.3em; display: block;"  alt="" /></p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Logging&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">document.location.href</code><wbr>&nbsp;in the web inspector console shows I&#8217;m successfully inspecting the web content from&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebViewWebGL.app</code>&nbsp;<wbr>running in the iPhone Simulator.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Huzzah!</p><h2>Enabling remote debugging in Mobile Safari</h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Enabling the web inspector in an embedded&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebView</code>&nbsp;is handy, but what about content running in Mobile Safari?</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">To do that, we need to call the&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">+[WebView _enableRemoteInspector]</code>&nbsp;API from within the Mobile Safari app. The easiest way to do that is by launching Mobile Safari in the iPhone Simulator, and then use&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">gdb</code>&nbsp;to attach to it and call the private API.</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Script to enable the remote inspector in Mobile Safari</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">4</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">5</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">6</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">7</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">8</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">9</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">10</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">11</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">12</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">13</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 750px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">MobileSafari_PID</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">=</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">$(</span>ps x | grep <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"MobileSafari"</span> | grep -v grep | awk <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">'{ print $1 }'</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">)</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">if</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">[</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"$MobileSafari_PID"</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">==</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">""</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">]</span>; <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">then</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">echo</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"Mobile Safari.app must be running in the Simulator to enable the remote inspector."</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">else</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> cat <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">&lt;&lt;EOM | gdb -quiet &gt; /dev/null</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  attach $MobileSafari_PID</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  p (void *)[WebView _enableRemoteInspector]</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  detach</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">EOM</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">fi</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Browsing to&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9999/" target="_blank" style="color: #1155cc;">http://localhost:9999</a></code>&nbsp;will show an index page listing the URL of each tab open in Mobile Safari. This allows you to have a remote inspector open for each tab in Mobile Safari.</p><h2>Summing Up</h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">I haven&#8217;t used the remote inspector in anger yet, but so far it&#8217;s been incredibly useful.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Note that you can&#8217;t use&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">gdb</code>&nbsp;to inject code on a device, so enabling remote debugging in Mobile Safari is limited to the Simulator. Hopefully Apple will provide the option to enable it, much like the debug console in&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">Settings &#8594; Safari &#8594; Advanced &#8594; Debug Console</code>.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><strike style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">In the meantime, you can load your web content in an embedded UIWebView.</strike>&nbsp;Enabling the remote inspector on a&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebView</code>&nbsp;in an app running on the device doesn&#8217;t seem to work. Using&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">nmap</code>shows that my iPhone only has port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">62078</code>&nbsp;open for OTA syncing, so it&#8217;s likely there&#8217;s a firewall preventing connections to the remote inspector port.</p></div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196767.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:51 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原:gdb与时间戳</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/27/196709.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Thu, 27 Dec 2012 05:28:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/27/196709.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196709.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/27/196709.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196709.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196709.html</trackback:ping><description><![CDATA[创建:2012年12月27日<br /><br /><div>gdb</div><div></div><div>使用while循环打印ctime失败。</div><div>不得已，在代码中定义了一个临时函数</div><div>- (NSDate *)getTTT:(NSTimeInterval)tt</div><div>{</div><div>&nbsp; &nbsp; return [NSDate dateWithTimeIntervalSince1970:tt];</div><div>}</div><div></div><div></div><div>(gdb) p $p=0</div><div>$828 = 0</div><div>(gdb) while ($p&lt;$c)</div><div>&nbsp;&gt;p $ttt = (double)[(NSNumber *)[$ts objectAtIndex:$p] doubleValue]</div><div>&nbsp;&gt;po [self getTTT:$ttt]</div><div>&nbsp;&gt;p $p++</div><div>&nbsp;&gt;end</div><div>$829 = 1351569600</div><div>2012-10-30 04:00:00 +0000</div><div>$830 = 0</div><div>$831 = 1351570500</div><div>2012-10-30 04:15:00 +0000</div><div>$832 = 1</div><div>$833 = 1351571400</div><div>2012-10-30 04:30:00 +0000</div><div>$834 = 2</div><div>$835 = 1351572300</div><div>2012-10-30 04:45:00 +0000</div><div>$836 = 3</div><div>$837 = 1351573200</div><div>2012-10-30 05:00:00 +0000</div><div>$838 = 4</div><div>$839 = 1351574100</div><div>2012-10-30 05:15:00 +0000</div><div>$840 = 5</div><div>$841 = 1351575000</div><div>2012-10-30 05:30:00 +0000</div><div>$842 = 6</div><div>$843 = 1351575900</div><div>2012-10-30 05:45:00 +0000</div><div>$844 = 7</div><div>$845 = 1351576800</div><div>2012-10-30 06:00:00 +0000</div><div>$846 = 8</div><div>$847 = 1351577700</div><div>2012-10-30 06:15:00 +0000</div><div>$848 = 9</div><div>$849 = 1351578600</div><div>2012-10-30 06:30:00 +0000</div><div>$850 = 10</div><div>$851 = 1351579500</div><div>2012-10-30 06:45:00 +0000</div><div>$852 = 11</div><div>$853 = 1351580400</div><div>2012-10-30 07:00:00 +0000</div><div>$854 = 12</div><div>$855 = 1351581300</div><div>2012-10-30 07:15:00 +0000</div><div>$856 = 13</div><div>$857 = 1351582200</div><div>2012-10-30 07:30:00 +0000</div><div>$858 = 14</div><div>$859 = 1351583100</div><div>2012-10-30 07:45:00 +0000</div><div>$860 = 15</div><div>$861 = 1351584000</div><div>2012-10-30 08:00:00 +0000</div><div>$862 = 16</div><div>$863 = 1351584900</div><div>2012-10-30 08:15:00 +0000</div><div>$864 = 17</div><div>$865 = 1351585800</div><div>2012-10-30 08:30:00 +0000</div><div>$866 = 18</div><div>$867 = 1351586700</div><div>2012-10-30 08:45:00 +0000</div><div>$868 = 19</div><div>$869 = 1351587600</div><div>2012-10-30 09:00:00 +0000</div><div>$870 = 20</div><div>$871 = 1351589400</div><div>2012-10-30 09:30:00 +0000</div><div>$872 = 21</div><div>$873 = 1351590300</div><div>2012-10-30 09:45:00 +0000</div><div>$874 = 22</div><div>$875 = 1351597500</div><div>2012-10-30 11:45:00 +0000</div><div>$876 = 23</div><div>$877 = 1351638000</div><div>2012-10-30 23:00:00 +0000</div><div>$878 = 24</div><div>$879 = 1351645200</div><div>2012-10-31 01:00:00 +0000</div><div>$880 = 25</div><div>$881 = 1351646100</div><div>2012-10-31 01:15:00 +0000</div><div>$882 = 26</div><div>$883 = 1351647000</div><div>2012-10-31 01:30:00 +0000</div><div>$884 = 27</div><div>$885 = 1351647900</div><div>2012-10-31 01:45:00 +0000</div><div>$886 = 28</div><div>$887 = 1351648800</div><div>2012-10-31 02:00:00 +0000</div><div>$888 = 29</div><div>$889 = 1351649700</div><div>2012-10-31 02:15:00 +0000</div><div>$890 = 30</div><div>$891 = 1351650600</div><div>2012-10-31 02:30:00 +0000</div><div>$892 = 31</div><div>$893 = 1351651500</div><div>2012-10-31 02:45:00 +0000</div><div>$894 = 32</div><div>$895 = 1351652400</div><div>2012-10-31 03:00:00 +0000</div><div>$896 = 33</div><div>$897 = 1351653300</div><div>2012-10-31 03:15:00 +0000</div><div>$898 = 34</div><div>$899 = 1351654200</div><div>2012-10-31 03:30:00 +0000</div><div>$900 = 35</div><div>$901 = 1351656000</div><div>2012-10-31 04:00:00 +0000</div><div>$902 = 36</div><div>$903 = 1351656900</div><div>2012-10-31 04:15:00 +0000</div><div>$904 = 37</div><div>$905 = 1351657800</div><div>2012-10-31 04:30:00 +0000</div><div>$906 = 38</div><div>$907 = 1351658700</div><div>2012-10-31 04:45:00 +0000</div><div>$908 = 39</div><div>$909 = 1351659600</div><div>2012-10-31 05:00:00 +0000</div><div>$910 = 40</div><div>$911 = 1351660500</div><div>2012-10-31 05:15:00 +0000</div><div>$912 = 41</div><div>$913 = 1351661400</div><div>2012-10-31 05:30:00 +0000</div><div>$914 = 42</div><div>$915 = 1351662300</div><div>2012-10-31 05:45:00 +0000</div><div>$916 = 43</div><div>$917 = 1351663200</div><div>2012-10-31 06:00:00 +0000</div><div>$918 = 44</div><div>$919 = 1351664100</div><div>2012-10-31 06:15:00 +0000</div><div>$920 = 45</div><div>$921 = 1351665000</div><div>2012-10-31 06:30:00 +0000</div><div>$922 = 46</div><div>$923 = 1351665900</div><div>2012-10-31 06:45:00 +0000</div><div>$924 = 47</div><div>$925 = 1351666800</div><div>2012-10-31 07:00:00 +0000</div><div>$926 = 48</div><div>$927 = 1351667700</div><div>2012-10-31 07:15:00 +0000</div><div>$928 = 49</div><div>$929 = 1351668600</div><div>2012-10-31 07:30:00 +0000</div><div>$930 = 50</div><div>$931 = 1351669500</div><div>2012-10-31 07:45:00 +0000</div><div>$932 = 51</div><div>$933 = 1351670400</div><div>2012-10-31 08:00:00 +0000</div><div>$934 = 52</div><div>$935 = 1351671300</div><div>2012-10-31 08:15:00 +0000</div><div>$936 = 53</div><div>$937 = 1351672200</div><div>2012-10-31 08:30:00 +0000</div><div>$938 = 54</div><div>$939 = 1351673100</div><div>2012-10-31 08:45:00 +0000</div><div>$940 = 55</div><div>$941 = 1351674000</div><div>2012-10-31 09:00:00 +0000</div><div>$942 = 56</div><div>$943 = 1351702800</div><div>2012-10-31 17:00:00 +0000</div><div>$944 = 57</div><div>$945 = 1351724400</div><div>2012-10-31 23:00:00 +0000</div><div>$946 = 58</div><div>$947 = 1351731600</div><div>2012-11-01 01:00:00 +0000</div><div>$948 = 59</div><div>$949 = 1351732500</div><div>2012-11-01 01:15:00 +0000</div><div>$950 = 60</div><div>$951 = 1351733400</div><div>2012-11-01 01:30:00 +0000</div><div>$952 = 61</div><div>$953 = 1351734300</div><div>2012-11-01 01:45:00 +0000</div><div>$954 = 62</div><div>$955 = 1351735200</div><div>2012-11-01 02:00:00 +0000</div><div>$956 = 63</div><div>$957 = 1351736100</div><div>2012-11-01 02:15:00 +0000</div><div>$958 = 64</div><div>$959 = 1351737000</div><div>2012-11-01 02:30:00 +0000</div><div>$960 = 65</div><div>$961 = 1351737900</div><div>2012-11-01 02:45:00 +0000</div><div>$962 = 66</div><div>$963 = 1351738800</div><div>2012-11-01 03:00:00 +0000</div><div>$964 = 67</div><div>$965 = 1351739700</div><div>2012-11-01 03:15:00 +0000</div><div>$966 = 68</div><div>$967 = 1351740600</div><div>2012-11-01 03:30:00 +0000</div><div>$968 = 69</div><div>$969 = 1351742400</div><div>2012-11-01 04:00:00 +0000</div><div>$970 = 70</div><div>$971 = 1351743300</div><div>2012-11-01 04:15:00 +0000</div><div>$972 = 71</div><div>$973 = 1351744200</div><div>2012-11-01 04:30:00 +0000</div><div>$974 = 72</div><div>$975 = 1351745100</div><div>2012-11-01 04:45:00 +0000</div><div>$976 = 73</div><div>$977 = 1351746000</div><div>2012-11-01 05:00:00 +0000</div><div>$978 = 74</div><div>$979 = 1351746900</div><div>2012-11-01 05:15:00 +0000</div><div>$980 = 75</div><div>$981 = 1351747800</div><div>2012-11-01 05:30:00 +0000</div><div>$982 = 76</div><div>$983 = 1351748700</div><div>2012-11-01 05:45:00 +0000</div><div>$984 = 77</div><div>$985 = 1351749600</div><div>2012-11-01 06:00:00 +0000</div><div>$986 = 78</div><div>$987 = 1351750500</div><div>2012-11-01 06:15:00 +0000</div><div>$988 = 79</div><div>$989 = 1351751400</div><div>2012-11-01 06:30:00 +0000</div><div>$990 = 80</div><div>$991 = 1351752300</div><div>2012-11-01 06:45:00 +0000</div><div>$992 = 81</div><div>$993 = 1351753200</div><div>2012-11-01 07:00:00 +0000</div><div>$994 = 82</div><div>$995 = 1351754100</div><div>2012-11-01 07:15:00 +0000</div><div>$996 = 83</div><div>$997 = 1351755000</div><div>2012-11-01 07:30:00 +0000</div><div>$998 = 84</div><div>$999 = 1351755900</div><div>2012-11-01 07:45:00 +0000</div><div>$1000 = 85</div><div>$1001 = 1351756800</div><div>2012-11-01 08:00:00 +0000</div><div>$1002 = 86</div><div>$1003 = 1351757700</div><div>2012-11-01 08:15:00 +0000</div><div>$1004 = 87</div><div>$1005 = 1351758600</div><div>2012-11-01 08:30:00 +0000</div><div>$1006 = 88</div><div>$1007 = 1351759500</div><div>2012-11-01 08:45:00 +0000</div><div>$1008 = 89</div><div>$1009 = 1351760400</div><div>2012-11-01 09:00:00 +0000</div><div>$1010 = 90</div><div>$1011 = 1351810800</div><div>2012-11-01 23:00:00 +0000</div><div>$1012 = 91</div><div>$1013 = 1351816200</div><div>2012-11-02 00:30:00 +0000</div><div>$1014 = 92</div><div>$1015 = 1351818000</div><div>2012-11-02 01:00:00 +0000</div><div>$1016 = 93</div><div>$1017 = 1351818900</div><div>2012-11-02 01:15:00 +0000</div><div>$1018 = 94</div><div>$1019 = 1351819800</div><div>2012-11-02 01:30:00 +0000</div><div>$1020 = 95</div><div>$1021 = 1351820700</div><div>2012-11-02 01:45:00 +0000</div><div>$1022 = 96</div><div>$1023 = 1351821600</div><div>2012-11-02 02:00:00 +0000</div><div>$1024 = 97</div><div>$1025 = 1351822500</div><div>2012-11-02 02:15:00 +0000</div><div>$1026 = 98</div><div>$1027 = 1351823400</div><div>2012-11-02 02:30:00 +0000</div><div>$1028 = 99</div><div>$1029 = 1351824300</div><div>2012-11-02 02:45:00 +0000</div><div>$1030 = 100</div><div>$1031 = 1351825200</div><div>2012-11-02 03:00:00 +0000</div><div>$1032 = 101</div><div>$1033 = 1351826100</div><div>2012-11-02 03:15:00 +0000</div><div>$1034 = 102</div><div>$1035 = 1351827000</div><div>2012-11-02 03:30:00 +0000</div><div>$1036 = 103</div><div>$1037 = 1351828800</div><div>2012-11-02 04:00:00 +0000</div><div>$1038 = 104</div><div>$1039 = 1351829700</div><div>2012-11-02 04:15:00 +0000</div><div>$1040 = 105</div><div>$1041 = 1351830600</div><div>2012-11-02 04:30:00 +0000</div><div>$1042 = 106</div><div>$1043 = 1351831500</div><div>2012-11-02 04:45:00 +0000</div><div>$1044 = 107</div><div>$1045 = 1351832400</div><div>2012-11-02 05:00:00 +0000</div><div>$1046 = 108</div><div>$1047 = 1351833300</div><div>2012-11-02 05:15:00 +0000</div><div>$1048 = 109</div><div>$1049 = 1351834200</div><div>2012-11-02 05:30:00 +0000</div><div>$1050 = 110</div><div>$1051 = 1351835100</div><div>2012-11-02 05:45:00 +0000</div><div>$1052 = 111</div><div>$1053 = 1351836000</div><div>2012-11-02 06:00:00 +0000</div><div>$1054 = 112</div><div>$1055 = 1351836900</div><div>2012-11-02 06:15:00 +0000</div><div>$1056 = 113</div><div>$1057 = 1351837800</div><div>2012-11-02 06:30:00 +0000</div><div>$1058 = 114</div><div>$1059 = 1351838700</div><div>2012-11-02 06:45:00 +0000</div><div>$1060 = 115</div><div>$1061 = 1351839600</div><div>2012-11-02 07:00:00 +0000</div><div>$1062 = 116</div><div>$1063 = 1351840500</div><div>2012-11-02 07:15:00 +0000</div><div>$1064 = 117</div><div>$1065 = 1351841400</div><div>2012-11-02 07:30:00 +0000</div><div>$1066 = 118</div><div>$1067 = 1351842300</div><div>2012-11-02 07:45:00 +0000</div><div>$1068 = 119</div><div>$1069 = 1351843200</div><div>2012-11-02 08:00:00 +0000</div><div>$1070 = 120</div><div>$1071 = 1351844100</div><div>2012-11-02 08:15:00 +0000</div><div>$1072 = 121</div><div>$1073 = 1351845000</div><div>2012-11-02 08:30:00 +0000</div><div>$1074 = 122</div><div>$1075 = 1351845900</div><div>2012-11-02 08:45:00 +0000</div><div>$1076 = 123</div><div>$1077 = 1351846800</div><div>2012-11-02 09:00:00 +0000</div><div>$1078 = 124</div><div>$1079 = 1351881000</div><div>2012-11-02 18:30:00 +0000</div><div>$1080 = 125</div><div>$1081 = 1351882800</div><div>2012-11-02 19:00:00 +0000</div><div>$1082 = 126</div><div>$1083 = 1351884600</div><div>2012-11-02 19:30:00 +0000</div><div>$1084 = 127</div><div>$1085 = 1351886400</div><div>2012-11-02 20:00:00 +0000</div><div>$1086 = 128</div><div>$1087 = 1352077200</div><div>2012-11-05 01:00:00 +0000</div><div>$1088 = 129</div><div>$1089 = 1352078100</div><div>2012-11-05 01:15:00 +0000</div><div>$1090 = 130</div><div>$1091 = 1352079000</div><div>2012-11-05 01:30:00 +0000</div><div>$1092 = 131</div><div>$1093 = 1352079900</div><div>2012-11-05 01:45:00 +0000</div><div>$1094 = 132</div><div>$1095 = 1352080800</div><div>2012-11-05 02:00:00 +0000</div><div>$1096 = 133</div><div>$1097 = 1352081700</div><div>2012-11-05 02:15:00 +0000</div><div>$1098 = 134</div><div>$1099 = 1352082600</div><div>2012-11-05 02:30:00 +0000</div><div>$1100 = 135</div><div>$1101 = 1352083500</div><div>2012-11-05 02:45:00 +0000</div><div>$1102 = 136</div><div>$1103 = 1352084400</div><div>2012-11-05 03:00:00 +0000</div><div>$1104 = 137</div><div>$1105 = 1352085300</div><div>2012-11-05 03:15:00 +0000</div><div>$1106 = 138</div><div>$1107 = 1352086200</div><div>2012-11-05 03:30:00 +0000</div><div>$1108 = 139</div><div>$1109 = 1352087100</div><div>2012-11-05 03:45:00 +0000</div><div>$1110 = 140</div><div>$1111 = 1352088000</div><div>2012-11-05 04:00:00 +0000</div><div>$1112 = 141</div><div>$1113 = 1352088900</div><div>2012-11-05 04:15:00 +0000</div><div>$1114 = 142</div><div>$1115 = 1352089800</div><div>2012-11-05 04:30:00 +0000</div><div>$1116 = 143</div><div>$1117 = 1352091600</div><div>2012-11-05 05:00:00 +0000</div><div>$1118 = 144</div><div>$1119 = 1352092500</div><div>2012-11-05 05:15:00 +0000</div><div>$1120 = 145</div><div>$1121 = 1352093400</div><div>2012-11-05 05:30:00 +0000</div><div>$1122 = 146</div><div>$1123 = 1352094300</div><div>2012-11-05 05:45:00 +0000</div><div>$1124 = 147</div><div>$1125 = 1352095200</div><div>2012-11-05 06:00:00 +0000</div><div>$1126 = 148</div><div>$1127 = 1352096100</div><div>2012-11-05 06:15:00 +0000</div><div>$1128 = 149</div><div>$1129 = 1352097000</div><div>2012-11-05 06:30:00 +0000</div><div>$1130 = 150</div><div>$1131 = 1352097900</div><div>2012-11-05 06:45:00 +0000</div><div>$1132 = 151</div><div>$1133 = 1352098800</div><div>2012-11-05 07:00:00 +0000</div><div>$1134 = 152</div><div>$1135 = 1352099700</div><div>2012-11-05 07:15:00 +0000</div><div>$1136 = 153</div><div>$1137 = 1352100600</div><div>2012-11-05 07:30:00 +0000</div><div>$1138 = 154</div><div>$1139 = 1352101500</div><div>2012-11-05 07:45:00 +0000</div><div>$1140 = 155</div><div>$1141 = 1352102400</div><div>2012-11-05 08:00:00 +0000</div><div>$1142 = 156</div><div>$1143 = 1352103300</div><div>2012-11-05 08:15:00 +0000</div><div>$1144 = 157</div><div>$1145 = 1352104200</div><div>2012-11-05 08:30:00 +0000</div><div>$1146 = 158</div><div>$1147 = 1352105100</div><div>2012-11-05 08:45:00 +0000</div><div>$1148 = 159</div><div>$1149 = 1352106000</div><div>2012-11-05 09:00:00 +0000</div><div>$1150 = 160</div><div>$1151 = 1352110500</div><div>2012-11-05 10:15:00 +0000</div><div>$1152 = 161</div><div>$1153 = 1352111400</div><div>2012-11-05 10:30:00 +0000</div><div>$1154 = 162</div><div>$1155 = 1352131200</div><div>2012-11-05 16:00:00 +0000</div><div>$1156 = 163</div><div>$1157 = 1352132100</div><div>2012-11-05 16:15:00 +0000</div><div>$1158 = 164</div><div>$1159 = 1352156400</div><div>2012-11-05 23:00:00 +0000</div><div>$1160 = 165</div><div>$1161 = 1352163600</div><div>2012-11-06 01:00:00 +0000</div><div>$1162 = 166</div><div>$1163 = 1352164500</div><div>2012-11-06 01:15:00 +0000</div><div>$1164 = 167</div><div>$1165 = 1352165400</div><div>2012-11-06 01:30:00 +0000</div><div>$1166 = 168</div><div>$1167 = 1352166300</div><div>2012-11-06 01:45:00 +0000</div><div>$1168 = 169</div><div>$1169 = 1352167200</div><div>2012-11-06 02:00:00 +0000</div><div>$1170 = 170</div><div>$1171 = 1352168100</div><div>2012-11-06 02:15:00 +0000</div><div>$1172 = 171</div><div>$1173 = 1352169000</div><div>2012-11-06 02:30:00 +0000</div><div>$1174 = 172</div><div>$1175 = 1352169900</div><div>2012-11-06 02:45:00 +0000</div><div>$1176 = 173</div><div>$1177 = 1352170800</div><div>2012-11-06 03:00:00 +0000</div><div>$1178 = 174</div><div>$1179 = 1352171700</div><div>2012-11-06 03:15:00 +0000</div><div>$1180 = 175</div><div>$1181 = 1352172600</div><div>2012-11-06 03:30:00 +0000</div><div>$1182 = 176</div><div>$1183 = 1352173500</div><div>2012-11-06 03:45:00 +0000</div><div>$1184 = 177</div><div>$1185 = 1352174400</div><div>2012-11-06 04:00:00 +0000</div><div>$1186 = 178</div><div>$1187 = 1352175300</div><div>2012-11-06 04:15:00 +0000</div><div>$1188 = 179</div><div>$1189 = 1352178000</div><div>2012-11-06 05:00:00 +0000</div><div>$1190 = 180</div><div>$1191 = 1352178900</div><div>2012-11-06 05:15:00 +0000</div><div>$1192 = 181</div><div>$1193 = 1352179800</div><div>2012-11-06 05:30:00 +0000</div><div>$1194 = 182</div><div>$1195 = 1352180700</div><div>2012-11-06 05:45:00 +0000</div><div>$1196 = 183</div><div>$1197 = 1352181600</div><div>2012-11-06 06:00:00 +0000</div><div>$1198 = 184</div><div>$1199 = 1352182500</div><div>2012-11-06 06:15:00 +0000</div><div>$1200 = 185</div><div>$1201 = 1352183400</div><div>2012-11-06 06:30:00 +0000</div><div>$1202 = 186</div><div>$1203 = 1352184300</div><div>2012-11-06 06:45:00 +0000</div><div>$1204 = 187</div><div>$1205 = 1352185200</div><div>2012-11-06 07:00:00 +0000</div><div>$1206 = 188</div><div>$1207 = 1352186100</div><div>2012-11-06 07:15:00 +0000</div><div>$1208 = 189</div><div>$1209 = 1352187000</div><div>2012-11-06 07:30:00 +0000</div><div>$1210 = 190</div><div>$1211 = 1352187900</div><div>2012-11-06 07:45:00 +0000</div><div>$1212 = 191</div><div>$1213 = 1352188800</div><div>2012-11-06 08:00:00 +0000</div><div>$1214 = 192</div><div>$1215 = 1352189700</div><div>2012-11-06 08:15:00 +0000</div><div>$1216 = 193</div><div>$1217 = 1352190600</div><div>2012-11-06 08:30:00 +0000</div><div>$1218 = 194</div><div>$1219 = 1352191500</div><div>2012-11-06 08:45:00 +0000</div><div>$1220 = 195</div><div>$1221 = 1352192400</div><div>2012-11-06 09:00:00 +0000</div><div>$1222 = 196</div><div>(gdb)&nbsp;</div><div></div>+++++<img src ="http://www.cppblog.com/walkklookk/aggbug/196709.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-27 13:28 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/27/196709.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原:gdb</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/27/196707.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Thu, 27 Dec 2012 05:23:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/27/196707.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196707.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/27/196707.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196707.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196707.html</trackback:ping><description><![CDATA[创建:2012年12月27日<br /><br /><div>u 跳出循环。相当与next命令，但是在循环的时候不进入循环体。</div><div>u 123 直到第123行才停下。相当于在第123行打下一个临时的断点。</div><div></div><div></div><div>WhatGDBDoesDuringStartup</div><div>1. Executes all commands from system init file</div><div>2. Executes all the commands from ~/.gdbinit</div><div>3. Process command line options and operands</div><div>4. Executes all the commands from ./.gdbinit</div><div>5. reads command files specified by the `-x' option&nbsp;</div><div>6. ...</div><div></div><div></div><div>￼Automating tasks - history, recording</div><div>&#8226; continue What GDB Does During Startup</div><div>... 6. Reads the command history recorded in the history file.</div><div>&#8226; (gdb) set history filename fname (gdb) set history save on/off</div><div>&#8226; (gdb) show history</div><div>&#8226; (gdb) show commands</div><div></div><div></div><div>+++</div><div>Sending messages to objects while debugging Objective-C in gdb, without symbols</div><div>If you must override gdb and send a message to an object when it will not let you, you can use performSelector:</div><div></div><div>(gdb) print (int)[receivedData count]</div><div>Target does not respond to this message selector.</div><div></div><div>(gdb) print (int)[receivedData performSelector:@selector(count) ]</div><div>2008-09-15 00:46:35.854 Executable[1008:20b] *** -[NSConcreteMutableData count]:</div><div>unrecognized selector sent to instance 0x105f2e0</div><div>If you need to pass an argument use withObject:</div><div></div><div>(gdb) print (int)[receivedData performSelector:@selector(count) withObject:myObject ]</div><div></div><div>po (id)objc_msgSend(JSONObject, @selector(class))</div><div></div><div>+++</div><div>gdb输出长字符串</div><div>最好的方法：</div><div>call (void)puts(your_string)</div><div>puts能把字符串输出到终端。</div><div>次好的方法：</div><div>set print elements 0</div><div>set print elements number-of-elements命令能设定print的输出长度。如果number-of-elements为0，则输出没有限制。默认限制是200.</div><div></div><div>+++</div><div>检查你的OS是否支持watchpoint，</div><div>gdb$ show can-use-hw-watchpoints</div><div>Debugger's willingness to use watchpoint hardware is 1.</div><div></div><div>++++</div><div>tbreak: Break once, and then remove the breakpoint</div><div>rbreak: break on function matching regular expression</div><div></div><div>+++</div><div>打印STL的内容</div><div>http://sourceware.org/gdb/wiki/STLSupport?action=AttachFile&amp;do=view&amp;target=stl-views-1.0.3.gdb</div><div></div><div></div><div>=====</div><div></div><div>lsof 显示当前所有进程打开的文件</div><div>nm &nbsp; 显示一个文件的symbol table。</div><div></div>+++++<img src ="http://www.cppblog.com/walkklookk/aggbug/196707.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-27 13:23 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/27/196707.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：使用Crash文件的步骤和原理 -3</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196646.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:59:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196646.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196646.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196646.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196646.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196646.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 创建：2011.06.22 修改：2012.04.18 修改：2012.04.24  ＊ 使用Crash文件的步骤：  ＃源代码上传并tag一个版本。  ＃生成AdHoc包。Release或者Debug都可以。 ＃生成xcarchive文件。保存该文件到某个你习惯的路径。 ＃得到ipa包。 ＃发布到手机。 ＃产生异常。 ＃连接手机和mac。 ＃在CrashLog中得到Crash的log。 ＃查看l...&nbsp;&nbsp;<a href='http://www.cppblog.com/walkklookk/archive/2012/12/26/196646.html'>阅读全文</a><img src ="http://www.cppblog.com/walkklookk/aggbug/196646.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:59 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196646.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：gdb高级技巧 -2</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196645.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:56:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196645.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196645.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196645.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196645.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196645.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012年10月25日</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>增加：2012年11月29日</div><div></div><div></div><div>*函数的返回值保存在$eax中。</div><div>因此，如果你在一个函数中调用finish，结束该函数后，<wbr>调用po $eax可以查看返回值。</div><div></div><div>*如果你调用<strong>(gdb)&nbsp;</strong><strong>x/10i $pc</strong>得到一些地址，并且想在某个地址上加上断点，<wbr>那么你需要使用*。例如：</div><div><p><strong>(gdb)&nbsp;</strong><strong>disassemble main</strong></p><p>Dump of assembler code for function main:</p><p>0x0046c050 &lt;main+0&gt;:	push &nbsp; ebp</p><p>0x0046c051 &lt;main+1&gt;:	mov&nbsp; &nbsp; ebp,esp</p><p>0x0046c053 &lt;main+3&gt;:	push &nbsp; ebx</p><p>0x0046c054 &lt;main+4&gt;:	push &nbsp; edi</p><p>0x0046c055 &lt;main+5&gt;:	push &nbsp; esi</p><p>0x0046c056 &lt;main+6&gt;:	sub&nbsp; &nbsp; esp,0x2c</p><p>0x0046c059 &lt;main+9&gt;:	call &nbsp; 0x46c05e &lt;main+14&gt;</p><p>0x0046c05e &lt;main+14&gt;:	pop&nbsp; &nbsp; eax</p><p>0x0046c05f &lt;main+15&gt;:	mov&nbsp; &nbsp; ecx,DWORD PTR [ebp+0xc]</p><p>&nbsp;</p><p><strong>(gdb)&nbsp;</strong><strong>b *0x0046c05f &nbsp; &nbsp; // 就是这里，需要加入一个*</strong></p><p>Breakpoint 8 at 0x46c05f: file main.m, line 14.</p><p>No symbol "null" in current context.</p><p><strong>(gdb)&nbsp;</strong></p><p>&nbsp;</p><p><br /></p></div><div></div><div>*有时候编译器会自动优化程序，导致一些变量消失了。<wbr>如果希望编译器不要优化掉它们，<wbr>可以将它们声明为volatile类型。例如：</div><div>volatile int k = 23;</div><div>k++;</div><div></div><div>这样k就不会被优化掉了。</div><div></div><div>*在objc_exception_<wbr>throw设定一个断点就可以捕获所有的抛出的异常。<wbr>在XCode中可以直接通过UI设定。</div><div></div><div></div><div>+++++</div></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196645.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:56 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196645.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：gdb user command file</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196644.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:55:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196644.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196644.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196644.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196644.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196644.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012年11月02日</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>参考：</div><div><a href="http://www.adacore.com/adaanswers/gems/gem-119-gdb-scripting-part-1" target="_blank" style="color: #1155cc;">http://www.adacore.com/<wbr>adaanswers/gems/gem-119-gdb-<wbr>scripting-part-1</a></div><div><a href="http://www.adacore.com/adaanswers/gems/gem-120-gdb-scripting-part-2" target="_blank" style="color: #1155cc;">http://www.adacore.com/<wbr>adaanswers/gems/gem-120-gdb-<wbr>scripting-part-2</a></div><div><a href="http://www.praetorian.com/blog/building-a-basic-fuzzer-with-gdb-the-five-minute-gdb-scripting-tutorial" target="_blank" style="color: #1155cc;">http://www.praetorian.com/<wbr>blog/building-a-basic-fuzzer-<wbr>with-gdb-the-five-minute-gdb-<wbr>scripting-tutorial</a></div><div></div><div></div><div>user command文件可以放在~/.gdbinit , 也可以使用source命令</div><div>(gdb) source /xxx/xx.gdb</div><div></div><div></div><div></div><div></div><div>This language follows the following format:</div><div>&nbsp;</div><div>define _command_</div><div>&nbsp; _code_</div><div>end</div><div>document _command_</div><div>_help text_</div><div>end</div><div></div><div></div><div></div><div></div><div>$arg0</div><div>$arg1</div><div>$arg2</div><div>...</div><div>最多10个参数，即$arg9</div><div>$argc是参数的个数。if $argc == 0 xxx</div><div></div><div>设置变量</div><div>set $VAR = 0</div><div>set $byte = *(unsigned char *)$arg0</div><div></div><div>if语句</div><div>&nbsp;</div><div>if _expression_</div><div>&nbsp; _statements_</div><div>else</div><div>&nbsp; _statements_</div><div>end</div><div></div><div></div><div>while 语句</div><div>&nbsp;</div><div>while _expression_</div><div>&nbsp; _statements_</div><div>end</div><div></div><div>输出</div><div>echo _text_</div><div>echo可以识别非c-style string。例如，\n.</div><div>echo也不会输出newline，除非你指定\n。</div><div></div><div>output _expression_</div><div>output只输出_expression_的值，<wbr>不会输出newline，也不会输出`$nn = '</div><div></div><div>printf _string_, _expressions_...</div><div>printf有格式化的能力。printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo</div><div></div><div></div><div></div><div>gdb有一个默认的user command，叫做hook-stop，<wbr>它在每次gdb停下来的时候执行。你可以改写它。</div><div>define hook-stop</div><div>&nbsp; eflags</div><div>end</div><div>document hook-stop</div><div>/!\ For internal use only - do not call manually /!\</div><div>end</div><div></div><div></div><div>一个随机数的例子</div><div>define build_fuzz_buf</div><div><span style="white-space: pre-wrap;">	</span>set $size = $arg0</div><div><span style="white-space: pre-wrap;">	</span>call (char *)malloc($size)</div><div><span style="white-space: pre-wrap;">	</span>set $buf = $</div><div><span style="white-space: pre-wrap;">	</span>set $i = 0</div><div><span style="white-space: pre-wrap;">	</span>call (int)time(0)</div><div><span style="white-space: pre-wrap;">	</span>set $time = $</div><div><span style="white-space: pre-wrap;">	</span>call (int) srand($time)</div><div><span style="white-space: pre-wrap;">	</span>while $i &lt; $size</div><div><span style="white-space: pre-wrap;">		</span>call (char) rand()</div><div><span style="white-space: pre-wrap;">		</span>set *(char *)($buf + $i) = $</div><div><span style="white-space: pre-wrap;">		</span>set $i = $i+1</div><div><span style="white-space: pre-wrap;">	</span>end</div><div><span style="white-space: pre-wrap;">	</span>printf &#8220;buf: 0xx len: %d\n&#8221;, $buf, $size</div><div><span style="white-space: pre-wrap;">	</span>p $buf</div><div>end</div><div></div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196644.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:55 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196644.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：gdb与dateWithTimeIntervalSince1970的bug</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196643.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:55:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196643.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196643.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196643.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196643.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196643.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012年10月31日</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">当使用gdb调试dateWithTimeIntervalSi<wbr>nce1970时出现bug，</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">po [NSDate&nbsp;<wbr>dateWithTimeIntervalSince1970:<wbr>123]</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">得到的始终是1970年</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">可以使用ctime，如下：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p><strong>(gdb)&nbsp;</strong><strong>p (char *)ctime(&amp;{123})</strong></p><p>$6 = 0x4b99cf6 "Thu Jan&nbsp; 1 08:02:03 1970\n"</p><p><strong>(gdb)&nbsp;</strong></p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:55 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Inspecting Obj-C parameters in gdb -好</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196641.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:54:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196641.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196641.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196641.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196641.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196641.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012年10月24日</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://www.clarkcox.com/blog/2009/02/04/inspecting-obj-c-parameters-in-gdb/" target="_blank" style="color: #1155cc;">http://www.clarkcox.com/<wbr>blog/2009/02/04/inspecting-<wbr>obj-c-parameters-in-gdb/</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">Since the addition of i386 and x86_64 to the Mac OS&#8217;s repertoire several years back, remembering which registers are used for what has become difficult, and this can complicate the debugging of code for which you have no symbols. So here is my cheat-sheet (posted here, mostly so that I can find it again without google-ing for old mailing list posts; but, I figure someone else may find it useful as well):</p><h4>arm (before prolog)</h4><ul style="line-height: 21px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;"><li style="margin-left: 15px;"><code>$r0</code>&nbsp;➡ arg0 (self)</li><li style="margin-left: 15px;"><code>$r1</code>&nbsp;➡ arg1 (_cmd)</li><li style="margin-left: 15px;"><code>$r2</code>&nbsp;➡ arg2</li><li style="margin-left: 15px;"><code>$r3</code>&nbsp;➡ arg3</li><li style="margin-left: 15px;"><code>*($sp)</code>&nbsp;➡ arg4</li><li style="margin-left: 15px;"><code>*($sp+4)</code>&nbsp;➡ arg5</li><li style="margin-left: 15px;"><code>*($sp+8)</code>&nbsp;➡ arg6</li></ul><h4>ppc/ppc64</h4><ul style="line-height: 21px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;"><li style="margin-left: 15px;"><code>$r3</code>&nbsp;➡ arg0 (self)</li><li style="margin-left: 15px;"><code>$r4</code>&nbsp;➡ arg1 (_cmd)</li><li style="margin-left: 15px;"><code>$r5</code>&nbsp;➡ arg2</li><li style="margin-left: 15px;"><code>$r6</code>&nbsp;➡ arg3</li><li style="margin-left: 15px;"><code>$r7</code>&nbsp;➡ arg4</li><li style="margin-left: 15px;"><code>$r8</code>&nbsp;➡ arg5</li></ul><h4>i386 (before prolog)</h4><ul style="line-height: 21px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;"><li style="margin-left: 15px;"><code>*($esp+4n)</code>&nbsp;➡ arg(n)</li><li style="margin-left: 15px;"><code>*($esp)</code>&nbsp;➡ arg0 (self)</li><li style="margin-left: 15px;"><code>*($esp+4)</code>&nbsp;➡ arg1 (_cmd)</li><li style="margin-left: 15px;"><code>*($esp+8)</code>&nbsp;➡ arg2</li><li style="margin-left: 15px;"><code>*($esp+12)</code>&nbsp;➡ arg3</li><li style="margin-left: 15px;"><code>*($esp+16)</code>&nbsp;➡ arg4</li><li style="margin-left: 15px;"><code>*($esp+20)</code>&nbsp;➡ arg5</li></ul><h4>i386 (after prolog)</h4><ul style="line-height: 21px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;"><li style="margin-left: 15px;"><code>*($ebp+8+4n)</code>&nbsp;➡ arg(n)</li><li style="margin-left: 15px;"><code>*($ebp+4)</code>&nbsp;➡ Return addr</li><li style="margin-left: 15px;"><code>*($ebp+8)</code>&nbsp;➡ arg0 (self)</li><li style="margin-left: 15px;"><code>*($ebp+12)</code>&nbsp;➡ arg1 (_cmd)</li><li style="margin-left: 15px;"><code>*($ebp+16)</code>&nbsp;➡ arg2</li><li style="margin-left: 15px;"><code>*($ebp+20)</code>&nbsp;➡ arg3</li><li style="margin-left: 15px;"><code>*($ebp+24)</code>&nbsp;➡ arg4</li><li style="margin-left: 15px;"><code>*($ebp+28)</code>&nbsp;➡ arg5</li><li style="margin-left: 15px;"><code>*($ebp)</code>&nbsp;➡ Previous $ebp</li></ul><h4>x86_64</h4><ul style="line-height: 21px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;"><li style="margin-left: 15px;"><code>$rdi</code>&nbsp;➡ arg0 (self)</li><li style="margin-left: 15px;"><code>$rsi</code>&nbsp;➡ arg1 (_cmd)</li><li style="margin-left: 15px;"><code>$rdx</code>&nbsp;➡ arg2</li><li style="margin-left: 15px;"><code>$rcx</code>&nbsp;➡ arg3</li><li style="margin-left: 15px;"><code>$r8</code>&nbsp;➡ arg4</li><li style="margin-left: 15px;"><code>$r9</code>&nbsp;➡ arg5</li></ul><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">So, if you have a method defined as:<br /><code>-(id)method:(id)foo bar:(id)bar baz:(id)baz</code><br />you can print each of the parameters with:</p><table border="1" style="line-height: 21px; text-align: justify; color: #666666; font-size: 14px; white-space: nowrap; font-family: 'Trebuchet MS', sans-serif; table-layout: fixed;"><tbody><tr><th></th><th>arm</th><th>ppc/ppc64</th><th>x86_64</th><th>i386 (before prolog)</th><th>i386 (after prolog)</th></tr><tr><th>self</th><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r0</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r3</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$rdi</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($esp)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($ebp+8)</code></td></tr><tr><th>_cmd</th><td style="font-family: arial, sans-serif; margin: 0px;"><code>p (SEL)$r1</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>p (SEL)$r4</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>p (SEL)$rsi</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>p *(SEL*)($esp+4)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>p *(SEL*)($ebp+12)</code></td></tr><tr><th>foo</th><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r2</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r5</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$rdx</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($esp+8)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($ebp+16)</code></td></tr><tr><th>bar</th><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r3</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r6</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$rcx</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($esp+12)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($ebp+20)</code></td></tr><tr><th>baz</th><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($sp)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r7</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;$r8</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($esp+16)</code></td><td style="font-family: arial, sans-serif; margin: 0px;"><code>po&nbsp;*(id*)($ebp+24)</code></td></tr></tbody></table><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">As Blake mentioned in his comment, on i386, if you&#8217;re at the beginning of a function or method, before the prolog has executed (i.e. the bit of code responsible for saving registers, adjusting the stack pointer, etc.), then ebp won&#8217;t have been set up for you yet.<br />So, I&#8217;ve amended the above table.</p><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">That complexity is another reason I long for the simplicity of PowerPC asm, not to mention M68k asm; at least x86_64 has made the step towards using registers for parameters where possible.</p><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">Edited to add: In case it isn&#8217;t obvious, these particular stack offsets and registers assignments only make sense when dealing with pointer and integer parameters and return values. When structures and floating point values come into the mix, things can get more complicated.</p><p style="line-height: 21px; margin: 0px 0px 20px; text-align: justify; color: #666666; font-family: 'Trebuchet MS', sans-serif;">Edited to add: I&#8217;ve added registers/stack offsets for arm. But note that these are for before the prolog has executed. Arm code seems much looser about what happens in its function prologs, so there really isn&#8217;t a standard layout post-prolog</p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196641.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:54 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196641.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：检查内存泄露的思路 --2</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196640.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:54:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196640.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196640.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196640.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196640.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196640.html</trackback:ping><description><![CDATA[<h2><span style="font-weight: normal;">创建：2011.10.10</span></h2><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2012.10.22</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><br />首先，使用XCode的静态解析工具，尽量去掉内存泄露的地方。<br />然后，使用Leaks工具找到内存泄露的对象。<wbr>记得选择Leaks，并去掉每10s的自动解析功能，<wbr>要手动解析，因为这样运行起来会比较快。<br />按照先易后难的方法解决每个Leak，有时候你会发现，<wbr>那些比较难的Leak，会随着简单的Leak的解决而消失。<br />结合Zombies来解决Leaks。<br /><br />比较复杂的Leaks：<br />Leak发生在系统函数中。<br />随机的Leak。<br />只有真机才出现的Leak。无法使用Zombies。<br />程序太大了，导致无法使用Leaks程序解析。<br /><br />2012年10月22日：<br />使用Instrument解决MemoryLeaks步骤</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">*不要被Memory Leaks的数量吓到，<wbr>有些Leak其实可能只是因为一个对象的泄露导致的。因此，<wbr>总体思路是从易到难，从熟悉到陌生的类。<br />*首先浏览全部的Memory Leaks，找到那些是我们自定义的类的泄露，<wbr>从这些类开始解决。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">因为系统的类不容易解决内存泄露，因为要么它们发生在系统内部，<wbr>要么使用的太过频繁，<wbr>而且很多都是由于我们自己的类的泄露导致的。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">而我们自己的类，则使用范围比较窄，容易找到原因。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">*浏览对象泄露的历史，查看&#8220;Responsible Library&#8221;，看这些Library中，哪些是我们的软件，<wbr>哪些是系统的（如，Foundation, UIKit)，先查看我们自己软件的。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">一一对照我们自己软件的历史，看看它们是否是配对的。如果不是，<wbr>则泄露在我们内部了。如果是，则可能是调用系统函数出错，<wbr>导致了泄露。此时，在依次查看每个系统的Library调用，<wbr>看看它们是否是一一匹配的。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">总之，要根据Library的来查看配对，<wbr>而不应该根据内存引用计数的历史过程来查找泄露。</div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"></div><div style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><br /><br />＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196640.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:54 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196640.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：常用GDB命令</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196639.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:53:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196639.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196639.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196639.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196639.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196639.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.10.19</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>+++</div><div>Help</div><div>(gdb) h &nbsp; &nbsp; &nbsp; &nbsp; -- h is for help -- list of help topics&nbsp;</div><div>(gdb) h topic &nbsp; -- help on named topic&nbsp;</div><div>(gdb) h bt &nbsp; &nbsp; &nbsp; -- help on bt command</div><div></div><div>+++</div><div>Stopping And Continuing</div><div>5.1 Breakpoints, Watchpoints, and Catchpoints</div><div>(gdb) b</div><div>(gdb) b 36 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- break at line number 36 of current source file &nbsp;</div><div>(gdb) b fn.c:22 &nbsp; &nbsp; &nbsp; &nbsp; - break at line number 22 of source file fn.c which</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is compiled into this executable &nbsp;</div><div>(gdb) b [NSNotificationCenter postNotificationName:object:]</div><div>(gdb) i b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - info breakpoints. Lists all breakpoints now set up.</div><div>(gdb) break frik.c:13 thread 28 &nbsp;-只在thread28上设置断点</div><div></div><div></div><div>(gdb) watch var<span style="white-space: pre-wrap;">			</span>- w</div><div>(gdb) rwatch var<span style="white-space: pre-wrap;">		</span>- r</div><div>(gdb) awatch var<span style="white-space: pre-wrap;">		</span>- r/w</div><div>(gdb) i watchpoints&nbsp;<span style="white-space: pre-wrap;">	</span>-&nbsp;</div><div></div><div></div><div>(gdb) d &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - delete all breakpoints</div><div>(gdb) d 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - delete #4 breakpoint</div><div></div><div>(gdb) dis &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - disable all breakpoints</div><div>(gdb) dis 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - disable #4 breakpoint</div><div></div><div>(gdb) enable &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- enable all breakpoints</div><div>(gdb) enable 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- enable #4 breakpoint</div><div></div><div>(gdb) b 36 if i==3 &nbsp; &nbsp; &nbsp;- b and condition</div><div>(gdb) condition 4 i==3<span style="white-space: pre-wrap;">	</span>- condition #4 breakpoint</div><div>(gdb) condition 4<span style="white-space: pre-wrap;">		</span>- remove condition #4 breakpoint</div><div></div><div>(gdb) ignore 4 10<span style="white-space: pre-wrap;">		</span>- ignore #4 breakpoint for 10 times.</div><div>(gdb) ignore 4 0<span style="white-space: pre-wrap;">		</span>- remove ignore for #4 breakpoint</div><div>(gdb) c 10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- continue, and ignore next 10 times.</div><div></div><div>(gdb) commands 4<span style="white-space: pre-wrap;">		</span>- add commands</div><div>silent</div><div>printf "x is %d\n",x</div><div>c</div><div>end</div><div>(gdb) commands 4<span style="white-space: pre-wrap;">		</span>- remove commands</div><div>end</div><div></div><div></div><div>5.2 Continuing and Stepping</div><div>(gdb) c</div><div>(gdb) n<span style="white-space: pre-wrap;">					</span>- next</div><div>(gdb) n 2<span style="white-space: pre-wrap;">				</span>- next 2 line.</div><div>(gdb) ni</div><div>(gdb) s<span style="white-space: pre-wrap;">					</span>- step.</div><div>(gdb) si</div><div>(gdb) finish<span style="white-space: pre-wrap;">			</span>- return this function.</div><div>(gdb) u<span style="white-space: pre-wrap;">					</span>- until. skip loop.</div><div>(gdb) q<span style="white-space: pre-wrap;">					</span>- quit</div><div></div><div>+++</div><div>8 Examining the Stack</div><div>(gdb) bt</div><div>(gdb) bt f<span style="white-space: pre-wrap;">				</span>- `bt full`.</div><div>(gdb) thread apply all backtrace</div><div>(gdb) f 9</div><div>(gdb) i args</div><div>(gdb) i lo<span style="white-space: pre-wrap;">				</span>- local variables</div><div></div><div>+++</div><div>10 Examining Data</div><div>(gdb) p 3*i</div><div>(gdb) p/x 3*i</div><div>(gdb) p/s str</div><div>(gdb) p array[3]@12 &nbsp; &nbsp; - will print out values starting at array position 3 for 12 positions</div><div>(gdb) p/x (short[2])0x12345678 // 强制把一个整数当作一个数组来看.</div><div>$1 = {0x1234, 0x5678}</div><div>(gdb) p/x (short[])0x12345678 // 自动计算数组size.</div><div>$2 = {0x1234, 0x5678}</div><div></div><div>(gdb) x/s 0x20034&nbsp;<span style="white-space: pre-wrap;">		</span>- examine memory, addr 0x20034, as a string</div><div></div><div></div><div></div><div>(gdb) po someObj</div><div>po命令与print命令也极为相似,<wbr>只不过它只能对objc对象求值,<wbr>并返回description函数的内容.如果po命令失败,<wbr>你可以通过显式调用description函数来查看内容.</div><div></div><div>Note:No printf command. printf only is used in `commands`</div><div></div><div>Symbol可以用单引号括起来,以免GDB无法正确识别.<wbr>例如:对于foo.c会识别成3个变量,所以要这样做:</div><div>*p 'foo.c'::x</div><div></div><div>whatis 命令可以显示某个变量的类型</div><div>ptype:比whatis的功能更强，<wbr>他可以提供一个结构的定义&nbsp;</div><div>(gdb) whatis v</div><div>type = struct complex</div><div>(gdb) ptype v</div><div>type = struct complex {</div><div>&nbsp; &nbsp; double real;</div><div>&nbsp; &nbsp; double imag;</div><div>}</div><div></div><div></div><div>info types regexp<span style="white-space: pre-wrap;">				</span>- 注意，regexp是正则。</div><div>info functions regexp<span style="white-space: pre-wrap;">			</span>-&nbsp;</div><div>info var regexp<span style="white-space: pre-wrap;">					</span>-&nbsp;</div><div>info classes regexp<span style="white-space: pre-wrap;">				</span>-&nbsp;</div><div>info selectors regexp<span style="white-space: pre-wrap;">			</span>-&nbsp;</div><div></div><div>info address symbol&nbsp;<span style="white-space: pre-wrap;">			</span>- 仅仅显示地址,作用不大.</div><div>info symbol addr&nbsp;<span style="white-space: pre-wrap;">				</span>- &nbsp;好像仅对全局变量,类定义,函数起作用.总之,作用似乎不大.</div><div></div><div></div><div>+++</div><div>17 Altering Execution</div><div>(gdb) p x=4<span style="white-space: pre-wrap;">			</span></div><div>(gdb) p my_function () &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - calls a function</div><div>(gdb) call my_function () &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- same as p.call命令与print命令基本相同.唯一的差别是:<wbr>如果返回值是void,则call不会显示任何内容,<wbr>仅仅执行该函数,而print会打印该void,<wbr>并将值保存到value history.对于有返回值的函数,<wbr>则call于print的操作结果完全相同,包括执行函数,<wbr>并在屏幕显示执行结果,同时将值保存到value history.</div><div></div><div>+++</div><div>设置GDB变量</div><div>(gdb) set $i = 0<span style="white-space: pre-wrap;">	</span>-</div><div>(gdb) set $i++<span style="white-space: pre-wrap;">			</span>- 注意++必须用set。</div><div>(gdb) p bar[$i++]-&gt;contents<span style="white-space: pre-wrap;">	</span>-但是在表达式里面的++就不用set了。</div><div></div><div>(gdb) show convenience&nbsp;<span style="white-space: pre-wrap;">	</span>- 显示所有gdb变量。</div><div></div><div></div><div>+++</div><div>Line</div><div>(gdb) l 23 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- list to terminal screen 10 lines of current source</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; centered at line 23&nbsp;</div><div>(gdb) l fn.c:22 &nbsp; &nbsp; &nbsp; &nbsp; -&nbsp;</div><div>(gdb) l func &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&nbsp;</div><div>(gdb) l &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - print 10 or more lines after lines last printed</div><div></div><div></div><div>+++汇编</div><div>(gdb) set disassembly-flavor intel</div><div>(gdb) disas mainFun</div><div>(gdb) show architecture &nbsp; &nbsp;- Show architecture of target.</div><div>(gdb) x/5i $pc&nbsp;<span style="white-space: pre-wrap;">			</span>- examine memory address.</div><div>(gdb) i r<span style="white-space: pre-wrap;">				</span>- registers</div><div>(gdb) p $eip。</div><div></div><div>+++其他</div><div>(gdb) show paths<span style="white-space: pre-wrap;">			</span>-程序路径。Show命令用于显示gdb的一些信息。</div><div>(gdb) shell &lt;command string&gt; - 在gdb中运行shell命令。</div><div></div><div>回车，是重复上一个命令</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:53 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：gdb打印NSArray里面的每个元素的内容</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196638.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:53:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196638.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196638.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196638.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196638.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196638.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.10.19</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">一个NSArray里面有Item，Item有元素s1和s2</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果普通的po命令，则只能打印出Item的地址。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果想的到Item的s1和s2的值，则需要：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p><strong>(gdb)&nbsp;</strong><strong>set $i = 0</strong></p><p><strong>(gdb)&nbsp;</strong><strong>set $c = (int)[arr count]</strong></p><p><strong>(gdb)&nbsp;</strong><strong>while ($i &lt; $c)</strong></p><p><strong>&nbsp;&gt;</strong><strong>po [[arr objectAtIndex:$i] s1]</strong></p><p><strong>&nbsp;&gt;</strong><strong>po [[arr objectAtIndex:$i++] s2]</strong></p><p><strong>&nbsp;&gt;</strong><strong>end</strong></p><p>a1</p><p>a2</p><p>b1</p><p>b2</p><p>c1</p><p>c2</p><p><strong>(gdb)&nbsp;</strong></p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果不嫌手动麻烦，也可以</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p><strong>(gdb)&nbsp;</strong><strong>set $i = 0</strong></p><p><strong>(gdb)&nbsp;</strong><strong>po [[arr objectAtIndex:$i++] s1]</strong></p><p>a1</p><p><strong>(gdb)&nbsp;</strong><strong>po [[arr objectAtIndex:$i++] s1]</strong></p><p>b1</p><p><strong>(gdb)&nbsp;</strong><strong>po [[arr objectAtIndex:$i++] s1]</strong></p><p>c1</p><p><strong>(gdb)&nbsp;</strong></p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196638.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:53 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196638.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：GDB的conditions的摘要</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196637.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:52:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196637.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196637.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196637.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196637.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建:2012.10.12</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://sourceware.org/gdb/current/onlinedocs/gdb/Conditions.html#Conditions" target="_blank" style="color: #1155cc;">http://sourceware.org/gdb/<wbr>current/onlinedocs/gdb/<wbr>Conditions.html#Conditions</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>conditions也可以在设定断点的时候就直接指定，<wbr>在break后面加if，例如：</div><div>conditions也可以使用conditions命令来更改<wbr>。</div><div></div><div>指定condition的方法</div><div>1）condition 断点序号 expression &nbsp; &nbsp; ： 为一个断点设定condition</div><div>2）condition 断点序号 &nbsp; &nbsp;： &nbsp;删除一个断点的condition</div><div>3）ignore 断点序号 count &nbsp; ：忽略前count次。</div><div>4）ignore 断点序号 0 &nbsp; &nbsp; &nbsp;： 重置了ignore。</div><div></div><div>如果一个断点既有condition又有ignore，<wbr>那么condition将会被忽略，<wbr>直到ignore的值都被消耗完才继续判断condition。</div><div>你可以自己实现一个既响应condition又响应ignore<wbr>的方法，<wbr>就是结合condition和gdb的convenience variable，例如，设定一个condition为&#8220;$<wbr>foo-- &lt;= 0&#8221;</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:52 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196637.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：GDB Command Lists摘要 -2</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196636.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:51:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196636.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196636.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196636.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196636.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196636.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.10.12</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2012.10.12<br /><div><div></div><div></div><div><div>转：<a href="http://sourceware.org/gdb/current/onlinedocs/gdb/Break-Commands.html#Break-Commands" target="_blank" style="font-size: 14.399999618530273px; color: #1155cc;">http://sourceware.org/gdb/<wbr>current/onlinedocs/gdb/Break-<wbr>Commands.html#Break-Commands</a></div><div></div><div></div><div>GDB Command Lists</div><div></div><div>用法：</div><div>commands 1</div><div>silent</div><div>printf "x is %d\n",x</div><div>cont</div><div>end</div><div></div><div>如果要删除一个断点的command，<wbr>只需要在commands后面直接跟end，例如</div><div>commands 1</div><div>end</div><div></div><div>如果commands后面没有跟任何数字，<wbr>则默认是在为最后一个设定的断点设定commands，注意，<wbr>不是你当前中断的断点。例如：</div><div><div>1）</div><div>break foo if x&gt;0</div><div>commands</div><div>printf "x is %d\n",x</div><div>c</div><div>end</div></div><div>2）</div><div><div>(gdb) break</div><div>Breakpoint 3 at 0x9470d674</div><div>(gdb) commands</div><div>&gt;x/s $ecx</div><div>&gt;c</div><div>&gt;end</div><div>(gdb) c</div><div></div></div><div></div><div></div><div></div><div>comands里面可以放继续执行gdb的命令，<wbr>如continue，step等。不过，<wbr>这些命令之后的任何命令都会被忽略掉（<wbr>因为gdb已经开始继续运行了）。</div><div></div><div>如果commands的第一个命令是silent，<wbr>则该断点中断时，出现的一般提示将不会在出现。注意，<wbr>silent必须是第一个命令。</div><div></div><div>也可以在command中改变变量的值，例如</div><div>commands 403</div><div>set x = y + 4</div><div>c</div><div>end</div><div></div><div>commands中，一般的打印的命令都将失效，<wbr>只能使用echo，output和printf。<wbr>一般只使用printf就足够了。</div><div>printf的例子：</div><div>printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo</div><div></div></div><div></div><div>一些复杂的例子：</div><div>(gdb) b *0x9470d674</div><div><div>Breakpoint 1 at 0x9470d674</div><div>(gdb) commands</div><div>Type commands for when breakpoint 1 is hit, one per line.</div><div>End with a line saying just "end".</div><div>&gt;<span style="background-color: #ff6666;">call (char *)class_getName($eax)</span></div><div>&gt;x/s $ecx</div><div>&gt;c</div><div>&gt;end</div><div>(gdb) run</div></div><div></div><div></div><div></div><div><div>commands&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="background-color: #ff6666;">set $id &nbsp;= *(long *)($esp+4)</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; set $sel = *(long *)($esp+8)</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if(*(long *)($id+8) != 0)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf "[%s %s]\n", *(long *)($id+8),$sel</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="background-color: #ff6666;">end</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; set $isx = *(long *)($id)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; printf "[%s %s]\n", *(long *)($isx+8),$sel</div><div>&nbsp; &nbsp; &nbsp; &nbsp; continue</div><div>end</div></div><div></div><div>+++++</div></div></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196636.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:51 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196636.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：汇编MOV和LEA</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196635.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:51:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196635.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196635.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196635.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196635.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196635.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.10.12</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>int v = 123;</div><div>int *p = &amp;v;</div><div>int **pp = &amp;p; // &amp;&amp;v</div><div></div><div></div><div></div><div>lea p v</div><div>int *p = &amp;v;</div><div></div><div>move v p</div><div>int v = *p;</div><div></div><div>move v [pp] // pp是一个变量的地址，该变量存储了另外一个地址</div><div>int v = **pp</div><div></div><div>lea p [pp]</div><div>int *p = *pp; &nbsp;// p</div><div></div><div>move [p] v</div><div>int *p = v</div><div></div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196635.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:51 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196635.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：GDB的数据断点和ObjC的@property</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196634.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:50:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196634.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196634.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196634.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196634.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196634.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.10.05</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">OC的@property可以让编译器自动提供对应的成员变量，<wbr>而不必再指定@synthesize&nbsp;quoteData=<wbr>quoteData;</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">但是，当使用gdb的watch命令的时候，它却无法成功，<wbr>例如：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) watch self.dataSource.quoteData</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因为有@<wbr>property生成的quoteData只是一个get函数，<wbr>它返回的值是一个临时的指针，因此无法跟踪。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">解决方法是再dataSource中创建一个quoteData<wbr>的成员变量，例如：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">@interface F7iPhoneQuoteViewControllerDat<wbr>aSource : NSObject&lt;<wbr>QuotesManagerDelegate&gt;<br />{<br />&nbsp; &nbsp; Quote *quoteData;<br />}</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">然后，在调试时使用：<br />(gdb) watch self.dataSource<span style="background-color: #ff0000;">-&gt;</span>quoteData</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">这样就可以了。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196634.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:50 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196634.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：使用GDB调试某次NSNotification</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196633.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:50:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196633.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196633.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196633.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196633.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196633.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.06.01</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">已知某个时间会发出一个NSNotification，<wbr>但是不知道是哪个NSNotification。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">直接设置[NSNotificationCenter postNotificationName:object:]<wbr>和[NSNotificationCenter postNotificationName:object:<wbr>userInfo:]会导致很多的中断，因此，<wbr>使用一个断点命令，<wbr>同时打印出NSNotification的参数内容，<wbr>然后一次查找可能的Notification。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">过程如下：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">1,运行程序；</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">2,中断程序；</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">3,设置断点：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>(gdb) b [NSNotificationCenter postNotificationName:object:]</div><div>Breakpoint 1 at 0x2068ad8</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>(gdb) b [NSNotificationCenter postNotificationName:object:<wbr>userInfo:]</div><div>Breakpoint 2 at 0x205c147</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">4,设置断点的命令：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>(gdb) commands 1</div><div>&gt;po *(id *)($fp + 16)</div><div>&gt;po *(id *)($fp + 20)</div><div>&gt;c</div><div>&gt;end</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>(gdb) commands 2</div><div>&gt;po *(id *)($fp + 16)</div><div>&gt;po *(id *)($fp + 20)</div><div>&gt;c</div><div>&gt;end</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">5,继续运行</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) c</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">6,等待事件发生。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">7,查看Log。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>Continuing.</div><div>_<wbr>UIApplicationDidBeginIgnoringI<wbr>nteractionEventsNotification</div><div>&lt;XXXApplication: 0x8e5f870&gt;</div><div>Continuing.</div><div>UIViewAnimationDidCommitNotifi<wbr>cation</div><div>UIViewAnimationState</div><div>Continuing.</div><div>UIViewAnimationDidCommitNotifi<wbr>cation</div><div>UIViewAnimationState</div><div>Continuing.</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">其中：po *(id *)($fp + 16)为函数第一个参数。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196633.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:50 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196633.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：检查内存泄露的思路</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196632.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:50:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196632.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196632.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196632.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196632.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196632.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">创建：2011.10.10</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">首先，使用XCode的静态解析工具，尽量去掉内存泄露的地方。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">然后，使用Leaks工具找到内存泄露的对象。</span><wbr style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;"><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">记得选择Leaks，并去掉每10s的自动解析功能，</span><wbr style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;"><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">要手动解析，因为这样运行起来会比较快。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">按照先易后难的方法解决每个Leak，有时候你会发现，</span><wbr style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;"><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">那些比较难的Leak，会随着简单的Leak的解决而消失。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">结合Zombies来解决Leaks。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">比较复杂的Leaks：</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">Leak发生在系统函数中。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">随机的Leak。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">只有真机才出现的Leak。无法使用Zombies。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">程序太大了，导致无法使用Leaks程序解析。</span><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><br style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12.800000190734863px; line-height: 19px; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196632.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:50 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196632.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：利用Leaks和Zombies检查内存泄露</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196631.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:49:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196631.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196631.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196631.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196631.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196631.html</trackback:ping><description><![CDATA[<span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">创建：2011.10.10</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">修改：2011.10.28</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: yellow;">本文无效。</span><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: yellow;">Leaks可以直接查看</span><span style="color: #222222; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: yellow;">retain和release<wbr>的历史。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">Leaks只能知道哪个类进行了泄露，<wbr>以及它是在什么地方分配的。但是，<wbr>却无法知道是在什么地方泄露的，<wbr>也就是说无法知道全部的retain和release的历史。<wbr>但是，Zombies却知道，因此可以结合两者。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">方法如下：</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">用Leaks找到内存泄露的类。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">找到该对象的分配地址。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">利用TTT类延迟10s释放该对象，释放多次，<wbr>确保一定Crash。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">然后使用Zombies运行程序。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">当程序因为TTT崩溃时，查看retain／<wbr>release的历史。检查在什么地方两者不匹配了。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">使用此方法普通的泄露问题都可以解决。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">此外，TTT类是另一篇文章里面的类。<wbr>用于结合Zombies类查看对象的retain和releas<wbr>e的历史的。</span><br style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" /><span style="color: #222222; background-color: #ffffff; line-height: 19px; font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196631.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:49 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196631.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：iPhone Crash Logs -3</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/26/196630.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Wed, 26 Dec 2012 01:49:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/26/196630.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196630.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/26/196630.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196630.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196630.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><a href="/Files/walkklookk/symbolicatecrash.txt">/Files/walkklookk/symbolicatecrash.txt</a><br /><br />日期：2010.12.23</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2011.05.14</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2011.06.22</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://www.anoshkin.net/blog/2008/09/09/iphone-crash-logs/" target="_blank" style="color: #1155cc;">http://www.anoshkin.net/<wbr>blog/2008/09/09/iphone-crash-<wbr>logs/</a><br /><div><br />[2011.06.22自：<wbr>我已经写了一个更加详细和介绍更多内幕的教程了。参见：原：使 用Crash文件的步骤和原理]<br /><br /><span style="color: #3333ff;">【自：非常强大的工具和用法。可以直接通过crash 文件和对应的dSYM文件，得到crash所在的代码的行数。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">在使用之前，有几个注意事项：</span><br style="color: #3333ff;" /><span style="color: #3333ff;">1，发布代码之前，从svn上重新下载一份代码，并单 独保存到一个文件中。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">这样，就可以生成独立的dSYM和源代码。不必和现有 的代码冲突。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">2，如果没有这样做。则在重新恢复现场的时候，要 update一份当时的代码。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">3，保留dSYM。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">另外，我没有在作者提到的路径下面找到 symbolicatecrash工具，于是，<wbr>从网上找到了一份，并放到附件中了。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">另外，我也没能copy到/usr/local /bin/下，所以我复制到/usr/bin/也一样可以。</span><br style="color: #3333ff;" /><span style="color: #3333ff;">】</span><br /><br /><h2><a href="http://www.anoshkin.net/blog/2008/09/09/iphone-crash-logs/" rel="bookmark" title="Permanent Link: iPhone Crash Logs" target="_blank" style="color: #1155cc;">iPhone Crash Logs</a></h2><p>Sometimes programs crash. This annoys users and developers alike. Users are frustrated because they cannot use crashing software, developers are&nbsp;frustrated because they have to hunt bugs instead of doing something creative and&nbsp;rewarding.&nbsp;How do we communicate if an iPhone application crashes?</p><p>I&#8217;ll start with a disclaimer. I&#8217;m not sure whether the information provided in this post is covered by iPhone Developer Program NDA or not. If it is, the post will be removed. Secondly, this post is a result of googling, so I haven&#8217;t invented anything new here.</p><p>Working with crash logs typically involves certain interaction between developers and users, unless they are automagically sent to the developer. First of all, the user should get the crash log and send it to&nbsp;the developer, who should examine it, find the bug and fix it.</p><p>iPhone OS and Mac OS X are remarkably similar architectures. Both store crash logs to help identify crashing bugs. The difference between the two is how users&nbsp;retrieve&nbsp;them. On Mac OS X every user has unrestricted access to crash logs related to the applications she runs. The iPhone does not even have a file browser. What to do? iTunes comes to the rescue.</p><p>Whenever you synchronize your iPhone or iPod Touch, all the crash logs are transferred to your computer. Here are their locations:</p><ul><li style="margin-left: 15px; background-color: #ff6666;"><strong>Mac OS X&nbsp;</strong>:&nbsp;<code>~/Library/Logs/CrashReporter/<wbr>MobileDevice/&lt;DEVICE_NAME&gt;</code></li><li style="margin-left: 15px;"><strong>Windows XP</strong>:&nbsp;<code>C:\Documents and Settings\&lt;USERNAME&gt;\<wbr>Application Data\Apple computer\Logs\CrashReporter/&lt;<wbr>DEVICE_NAME&gt;</code></li><li style="margin-left: 15px;"><strong>Windows Vista</strong>:&nbsp;<code>C:\Users\&lt;USERNAME&gt;\AppData\<wbr>Roaming\Apple computer\Logs\CrashReporter/<wbr>MobileDevice/&lt;DEVICE_NAME&gt;</code></li></ul><p>The log file names start with application name and have the extension &#8220;crash&#8221;. They are just plain text files and can be sent by e-mail in original or zipped form, or even copy-pasted into your e-mail program.</p><p>The second part is trickier. Both Apple and common sense suggest that all AppStore binaries are shipped with stripped&nbsp;symbols. If you ever saw a crash log like this, read on:</p><pre style="white-space: pre-wrap;">Thread 0 Crashed: 0   libobjc.A.dylib           0x300c87ec 0x300bb000 + 55276 1   MobileLines               0x00006434 0x1000 + 21556 2   MobileLines               0x000064c2 0x1000 + 21698 3   UIKit                     0x30a740ac 0x30a54000 + 131244    4   UIKit                     0x30a66110 0x30a54000 + 74000 5   UIKit                     0x30a6565c 0x30a54000 + 71260 6   GraphicsServices          0x3169b0b4 0x31696000 + 20660 7   GraphicsServices          0x3169d818 0x31696000 + 30744    8   IOMobileFramebuffer       0x31f3e8f8 0x31f3d000 + 6392 9   com.apple.framework.IOKit 0x30f342b8 0x30f30000 + 17080 10  CoreFoundation            0x3025ced4 0x30229000 + 212692 11  CoreFoundation            0x3025bed6 0x30229000 + 208598    12  CoreFoundation            0x3025b584 0x30229000 + 206212 13  GraphicsServices          0x316998e4 0x31696000 + 14564 14  UIKit                     0x30a5e308 0x30a54000 + 41736 15  UIKit                     0x30a671dc 0x30a54000 + 78300    16  MobileLines               0x00002090 0x1000 + 4240 17  MobileLines               0x0000202c 0x1000 + 4140</pre><p>In a nutshell, it contains function addresses and offsets instead of function names and line numbers. The structure is obvious, but, to be honest, I don&#8217;t know what<em>&#8220;MobileLines 0&#215;00006434 0&#215;1000 + 21556&#8243;</em>&nbsp;is, even though I have all the source code. Thanks to Apple Developer Tools and to&nbsp;Craig Hockenberry who&nbsp;<a title="furbo.org" href="http://furbo.org/2008/08/08/symbolicatifination/" target="_blank" style="color: #1155cc;">wrote about it</a>, we have a perfect solution called&nbsp;<em>symbolicatecrash</em>.</p><p>I copied it to&nbsp;<code>/usr/local/bin/</code>&nbsp;so that I can run it whenever I want without trying to remember its original location (you may prefer a symbolic link):<br /><code style="background-color: #ff6666;">$ sudo cp /Developer/Platforms/iPhoneOS.<wbr>platform/Developer/Library/<wbr>Xcode/Plug-ins/<wbr>iPhoneRemoteDevice.<wbr>xcodeplugin/Contents/<wbr>Resources/symbolicatecrash /usr/local/bin/</code></p><p>Running this script with the&nbsp;<code>-h</code>&nbsp;option provides the minimal help:</p><p><code>$ symbolicatecrash -h<br />usage:</code></p><p><code>&nbsp;&nbsp; &nbsp;symbolicatecrash [-Ah] LOGFILE [SYMBOL_PATH ...]</code></p><p>&nbsp;&nbsp; &nbsp;Symbolicates a crashdump LOGFILE which may be "-" to refer<br />&nbsp; to stdin. By default, all heuristics will be employed<br />&nbsp; in an attempt to symbolicate all addresses.&nbsp;Additional<br />&nbsp; symbol files can be found under specified directories.</p><p><code>Options:<br />&nbsp;&nbsp; &nbsp;-A &nbsp;Only symbolicate the application, not libraries<br />&nbsp;&nbsp; &nbsp;-h &nbsp;Display this message<br />&nbsp;&nbsp; &nbsp;-v &nbsp;Verbose</code></p><p>To add symbols to the crash log you need the&nbsp;dSYM file generated by the linker when you compiled your application for AppStore. In other words, when you build for AppStore you should keep the dSYM package in a safe place backed up by Time Machine. This is very important.&nbsp;<strong>You should keep a copy of the dSYM for each version of your application ever shipped</strong>. If you have the package, translating code offsets to function names with line numbers has never been easier:</p><p style="background-color: #cccccc;"><code>$ symbolicatecrash&nbsp;<span style="background-color: #ff6666;">report.crash</span>&nbsp;MobileLines.app.dSYM &gt; report-with-symbols.crash</code></p><p>Here is the result:</p><pre style="white-space: pre-wrap;">Thread 0 Crashed: 0   libobjc.A.dylib           0x300c87ec objc_msgSend + 20 1   MobileLines               0x00006434 -[BoardView setSelectedPiece:] (BoardView.m:321) 2   MobileLines               0x000064c2 -[BoardView touchesBegan:withEvent:] (BoardView.m:349)    3   UIKit                     0x30a740ac -[UIWindow sendEvent:] + 264 4   UIKit                     0x30a66110 -[UIApplication sendEvent:] + 248 5   UIKit                     0x30a6565c _UIApplicationHandleEvent + 4088    6   GraphicsServices          0x3169b0b4 PurpleEventCallback + 428 7   GraphicsServices          0x3169d818 HeartbeatVBLCallback + 152 8   IOMobileFramebuffer       0x31f3e8f8 IOMobileFramebufferNotifyFunc + 124    9   com.apple.framework.IOKit 0x30f342b8 IODispatchCalloutFromCFMessage + 304 10  CoreFoundation            0x3025ced4 __CFMachPortPerform + 72 11  CoreFoundation            0x3025bed6 CFRunLoopRunSpecific + 2364    12  CoreFoundation            0x3025b584 CFRunLoopRunInMode + 44 13  GraphicsServices          0x316998e4 GSEventRunModal + 268 14  UIKit                     0x30a5e308 -[UIApplication _run] + 404 15  UIKit                     0x30a671dc UIApplicationMain + 1064    16  MobileLines               0x00002090 main (main.m:16) 17  MobileLines               0x0000202c start + 44</pre><p>Now, this is&nbsp;<em>much</em>&nbsp;better. Happy debugging!</p><br /><br />＋＋＋＋＋</div></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-26 09:49 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/26/196630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：How to debug those random crashes in your Cocoa app －非常强悍的调试技巧</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196599.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 02:04:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196599.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196599.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196599.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196599.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196599.html</trackback:ping><description><![CDATA[日期：2011.06.07<br /><br />[自：非常强悍的调试技巧。<br />iphone也可以用，但是有些地方不同了。选项和名字。]<br /><br />转：<a href="http://www.corbinstreehouse.com/blog/2007/10/instruments-on" target="_blank" style="color: #1155cc;">http://www.corbinstreehouse.<wbr>com/blog/2007/10/instruments-<wbr>on</a>- leopard-how-to-debug-those-<wbr>random-crashes-in-your-cocoa-<wbr>app/<br /><br /><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><strong>Update: Sept 9, 2009:</strong>&nbsp;Mac OS 10.6 Snow Leopard now has this feature built into Instruments! In Xcode, choose &#8220;Run -&gt; Run with Performance Tool -&gt; Zombies&#8221;, and repeat your steps that cause the crash. Easy as pie. Read on if you don&#8217;t have Snow Leopard&#8230;</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><a href="http://www.apple.com/macosx/" target="_blank" style="color: #1155cc;">Mac OS 10.5 Leopard</a>&nbsp;has a great new developer app called&nbsp;<a style="color: #1155cc;">Instruments</a>.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">It can easily be used to debug those &#8220;random crashers&#8221; in your application caused by too many -release or -autorelease calls. Let&#8217;s see how.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you want to follow along, download this project:&nbsp;<a href="http://www.corbinstreehouse.com/blog/wp-content/uploads/CrashTestDummy.zip" title="CrashTestDummy.zip" target="_blank" style="color: #1155cc;">CrashTestDummy.zip</a></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Open it up in Xcode.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">The nib has two outlets in it: a basic NSObject called&nbsp;<span style="color: #3f6e74; font-family: Monaco; font-size: 10px;">testObject</span>&nbsp;and button setup to invoke the following code:</p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco;">- (<span style="color: #aa0d91;">IBAction</span>)<wbr>buttonCrashTestAction:(<span style="color: #aa0d91;">id</span>)<wbr>sender {</p><p style="line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; color: #007400;">// We are going to autorelease the testObject too many times..</p><p style="line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; color: #2e0d6e;"><span style="color: #000000;">[</span><span style="color: #3f6e74;">testObject</span>&nbsp;autorelease<span style="color: #000000;">];</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco;">}</p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">So, we will hit the button a few times and we should get a crash. Compile the app with the Debug target. Start Instruments, and select the&nbsp;<strong>Object Allocations</strong>&nbsp;template:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.1&amp;disp=emb&amp;zw&amp;atsh=1" height="524" width="654"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Hit the purple &#8220;i&#8221; next to the instruments to bring up the inspector for it, and be sure to check &#8220;Record reference counts&#8221;, as seen below:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.2&amp;disp=emb&amp;zw&amp;atsh=1" height="255" width="501"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Cool. Click &#8220;Launch Executable&#8221; and select &#8220;Choose Executable&#8221;, and find CrashTestDummy.app from the built directory.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.3&amp;disp=emb&amp;zw&amp;atsh=1" height="308" width="469"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">While you have the Open Panel up, add the environment variable NSZombieEnabled and set it to YES (sort of an optional step):</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.4&amp;disp=emb&amp;zw&amp;atsh=1" height="532" width="598"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Hit Open, if you haven&#8217;t already done so.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Hit &#8220;Record&#8221; in instruments, which will start the app, and click the &#8220;Crash Test&#8221; button a few times until the app crashes.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Alright! Fire up Console.app and look for a line like this:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.5&amp;disp=emb&amp;zw&amp;atsh=1" height="38" width="1099"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">The important part is the address, 0x150d40, in this case.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">In Instruments, move the mouse to the right of &#8220;All Allocations&#8221; and a little triangle appears:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.6&amp;disp=emb&amp;zw&amp;atsh=1" height="55" width="181"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Click on it to see all the allocations.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">In the lower right hand corner of instruments click on the magnifying glass in the NSSearchField and select &#8220;Address&#8221;:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.7&amp;disp=emb&amp;zw&amp;atsh=1" height="175" width="245"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Type in your address, and you should see all allocations at that address:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.8&amp;disp=emb&amp;zw&amp;atsh=1" height="210" width="781"  alt="" /><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Now, why so many? Well, addresses are reused. Chances are, the&nbsp;<strong>last</strong>&nbsp;allocation is your object, and sure enough, it is, since we know we are over releasing an&nbsp;<strong>NSObject</strong>&nbsp;instance. Click on that item, and you&#8217;ll see the history for it. Scroll to the bottom to see just the history for that NSObject:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.9&amp;disp=emb&amp;zw&amp;atsh=1" height="56" width="778"  alt="" /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Now! You should be able to figure out which release probably shouldn&#8217;t be there. We know it is #19 from our demo, but sometimes it isn&#8217;t that easy to figure out. Select #19&#8242;s row and then click the little gray arrow to next to its address (or whatever yours is), and then click on this button at the bottom of instruments to show the stack trace / extended detail:</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.10&amp;disp=emb&amp;zw&amp;atsh=1" height="28" width="34"  alt="" /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">You can then see when that &#8220;bad release&#8221; happened. Click on the thumb below for a full size screen shot of it.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /><a href="http://www.corbinstreehouse.com/blog/wp-content/uploads/TheBadReleaseInInstruments.jpg" target="_blank" style="color: #1155cc;"><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=13068aa5b5ece55b&amp;attid=0.1.11&amp;disp=emb&amp;zw&amp;atsh=1" height="206" width="300"  alt="" /></a><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Ahh! Way cool. Of course, this was a simple and easy test case.</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">Happy debugging :)</span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;"><br /></span></p><p style="color: #222222; line-height: normal; background-color: #ffffff; margin: 0px; font-size: 10px; font-family: Monaco; min-height: 14px;"><span style="font-family: Helvetica;">corbin</span></p><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br />＋＋＋＋＋<img src ="http://www.cppblog.com/walkklookk/aggbug/196599.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 10:04 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196599.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：So you crashed in objc_msgSend()</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196598.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 02:01:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196598.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196598.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196598.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196598.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196598.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.05.16</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">[自：对于objc_msgSend() 的情况介绍的很详细，可以用于调试。不过，用处不大。]</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://www.sealiesoftware.com/blog/archive/2008/09/22/objc_explain_So_you_crashed_in_objc_msgSend.html" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://www.sealiesoftware.<wbr>com/blog/archive/2008/09/22/<wbr>objc_explain_So_you_crashed_<wbr>in_objc_msgSend.html</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><table cellpadding="0" cellspacing="3" style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; text-align: start; background-color: #ffffff;"><tbody><tr><td style="margin: 0px;"><a href="http://www.sealiesoftware.com/blog/archive/2008/09/22/objc_explain_So_you_crashed_in_objc_msgSend.html" target="_blank" style="color: #1155cc;"><img src="http://www.sealiesoftware.com/link.gif" alt="(link)" border="0" width="14" height="16" /></a></td><td style="margin: 0px;"><strong>[objc explain]: So you crashed in objc_msgSend()</strong>&nbsp;&nbsp;&nbsp;(<a href="http://www.sealiesoftware.com/blog/archive/2008/09/22/objc_explain_So_you_crashed_in_objc_msgSend.html" target="_blank" style="color: #1155cc;">2008-09-22 02:02 PM</a>)</td></tr><tr><td style="margin: 0px;">&nbsp;</td><td style="margin: 0px;"><p>So you crashed in&nbsp;<code>objc_msgSend()</code>. Now what?</p><p>Most likely, you sent a message to an already-freed object. Or maybe your pointer is perfectly correct, but someone else mangled the object's contents - perhaps a buffer overrun in a nearby allocation, or use of a dangling pointer that once pointed to the memory now occupied by your object. Occasionally&nbsp;<code>objc_msgSend()</code>crashes because a memory error smashed the runtime's own data structures, but usually the trouble is in the receiver object itself.</p><p>Whether you're in the debugger or looking at a crash log, you can recover more information about the crash than just the backtrace.</p><h4>Receiver and selector registers</h4><p><code>objc_msgSend()</code>&nbsp;stores the receiver object and the selector in CPU registers while it works. These values can help diagnose the problem.</p><p>The register names differ based on architecture and the&nbsp;<code>objc_msgSend()</code>&nbsp;variant used. This list is correct for Mac OS X Leopard and will probably remain correct for Snow Leopard.</p><table border="1" cellpadding="4" cellspacing="0"><tbody><tr><th><br /></th><td colspan="2" align="center" style="margin: 0px;"><code>objc_msgSend</code><br /><code>objc_msgSend_fpret</code></td><td colspan="2" align="center" style="margin: 0px;"><code>objc_msgSend_stret</code></td></tr><tr><td align="center" style="margin: 0px;">&nbsp;</td><td align="center" style="margin: 0px;"><code>receiver</code></td><td align="center" style="margin: 0px;"><code>SEL</code></td><td align="center" style="margin: 0px;"><code>receiver</code></td><td align="center" style="margin: 0px;"><code>SEL</code></td></tr><tr><td style="margin: 0px;">i386</td><td align="center" style="margin: 0px;">eax*</td><td align="center" style="margin: 0px;">ecx</td><td align="center" style="margin: 0px;">eax*</td><td align="center" style="margin: 0px;">ecx</td></tr><tr><td style="margin: 0px;">x86_64</td><td align="center" style="margin: 0px;">rdi</td><td align="center" style="margin: 0px;">rsi</td><td align="center" style="margin: 0px;">rsi</td><td align="center" style="margin: 0px;">rdx</td></tr><tr><td style="margin: 0px;">ppc</td><td align="center" style="margin: 0px;">r3</td><td align="center" style="margin: 0px;">r4</td><td align="center" style="margin: 0px;">r4</td><td align="center" style="margin: 0px;">r5</td></tr><tr><td style="margin: 0px;">ppc64</td><td align="center" style="margin: 0px;">r3</td><td align="center" style="margin: 0px;">r4</td><td align="center" style="margin: 0px;">r4</td><td align="center" style="margin: 0px;">r5</td></tr><tr><td style="margin: 0px;">arm</td><td align="center" style="margin: 0px;">r0</td><td align="center" style="margin: 0px;">r1</td><td align="center" style="margin: 0px;">r1</td><td align="center" style="margin: 0px;">r2</td></tr></tbody></table>* i386 note: The receiver is in eax for most crashes, but not all. If you manage to get far into&nbsp;<code>objc_msgSend()</code>&nbsp;before falling over, then eax will have some other value.<h4>Interpreting the receiver and invalid address</h4><p>You can use the receiver's address and the invalid address that caused the crash to get some hints about the underlying problem. In a crash log, the receiver's address is in the Thread State using the register name in the table above, and the invalid address is listed at the top (usually something like&nbsp;<code>KERN_PROTECTION_FAILURE at &lt;invalid address&gt;</code>). In the debugger console, the invalid address is printed when the program stops, and you can print the receiver's address using the register name in the table above.</p><pre style="white-space: pre-wrap;">    Program received signal EXC_BAD_ACCESS, Could not access memory.<br />    Reason: KERN_PROTECTION_FAILURE at address: 0x00000001<br />    0x00090ec4 in objc_msgSend ()<br />    (gdb) <span style="background-color: #ff6666;">p/x $eax</span><br />     $1 = 0x1</pre>My test program crashed at&nbsp;<code>[(id)1 release]</code>. In real crashes, these values are typically more interesting.<p>Usually, one of two things happens. The receiver address itself is bogus, and the invalid address is the same value (or 16 or 32 bytes away). Or the receiver address is reasonable, and the invalid address is the receiver's&nbsp;<code>isa</code>&nbsp;pointer. The latter is what usually happens if you try to use an already-deallocated object or someone else clobbered your valid object.</p><p>Look for special values like these in your crashes. Also look for nearby values; on some architectures, an invalid&nbsp;<code>isa</code>&nbsp;will cause a crash at&nbsp;<code>isa+16</code>&nbsp;or&nbsp;<code>isa+32</code>&nbsp;instead.</p><dl><dt>Not divisble by 16 - misaligned</dt><dd><code>malloc()</code>&nbsp;returns 16-byte aligned blocks. If your receiver isn't 16-byte aligned, it probably never was a valid object pointer.</dd><dt>Top two and bottom two bits all set - malloc free list</dt><dd>After a block is freed, the memory allocator may write free list pointers into it. If you use a freed object after this, you'll see an&nbsp;<code>isa</code>&nbsp;pointer with the top two and bottom two bits all set.</dd><dt>All bits inverted - GC free list</dt><dd>Like the malloc free list case above, but caused by the garbage collector instead. In this case&nbsp;<code>address</code>&nbsp;looks bad, but&nbsp;<code>~address</code>&nbsp;is more reasonable.</dd><dt>0xa1b1c1d3 - CF container</dt><dd>CoreFoundation containers use this value for deleted or empty items. Perhaps a freed object has been re-allocated as a container, or someone used a freed container that has been re-allocated as your object, or you read your pointer from a container that was simultaneously changed by some other thread and you don't have the right locks in place.</dd><dt>ASCII text</dt><dd>Perhaps a freed object has been re-allocated as a string, or someone used a freed string that has been re-allocated as your object, or some string operation has a buffer overrun. Use&nbsp;<a href="http://www.sealiesoftware.com/asciify.c" target="_blank" style="color: #1155cc;">asciify</a>&nbsp;to print these quickly in both endians. This one looks URL-related, for example:<pre style="white-space: pre-wrap;">% asciify 0x2e777777<br />###.www###<br />###www.###</pre></dd></dl><h4>Interrogating the selector</h4><p>Compiler optimization means the call site pointed to by the second frame in the backtrace might not be the call that actually crashed. It's possible that call succeeded, and then that method made a&nbsp;<em>tail call</em>&nbsp;which was the one that crashed. Because of tail call optimization, the intermediate frame would be missing from the backtrace. We can use the selector register to determine what the real crashing call was.</p><p>A selector is a pointer to a unique C string. This may change in future OS versions, but for now it's handy for debugging. If you have crashed in a debugger, open the debugger console and run this, substituting the correct&nbsp;<code>SEL</code>&nbsp;register from the table above:</p><pre style="white-space: pre-wrap;">    (gdb) <span style="background-color: #ff6666;">x/s $ecx</span><br />    0xa1029: "release"</pre><p>Snow Leopard's crash reporter adds selector names to crash logs for you:</p><pre style="white-space: pre-wrap;">    Application Specific Information:<br />    objc_msgSend() selector name: release</pre>Otherwise, retrieving the selector name from just a crash log is difficult and doesn't always work. Until you have Snow Leopard, cross your fingers and try this.<ol><li style="margin-left: 15px;">From the crash log's Thread State, find the&nbsp;<code>SEL</code>'s value using the register name in the table above.<pre style="white-space: pre-wrap;">    ecx: 0x000a1029</pre></li><li style="margin-left: 15px;">From the crash log's Binary Images, find the image whose address range includes the&nbsp;<code>SEL</code>'s value. This will often be either the application itself or<code>libobjc.A.dylib</code>. If no image spans that address, give up.&nbsp;<br /><code>&nbsp; &nbsp; 0x8b000 - &nbsp; 0x106ff7 &nbsp;libobjc.A.dylib ??? (???) &lt;<wbr>9b5973b7fa88f9aab7885530c7b278<wbr>dd&gt; /usr/lib/libobjc.A.dylib</code></li><li style="margin-left: 15px;">Find a copy of the image that matches the one in the crash log. Use the UUID to verify the match.<pre style="white-space: pre-wrap;">    % dwarfdump -u /usr/lib/libobjc.A.dylib<br />    UUID: 26650299-C6EA-B1C8-52D6-<wbr>072AC874D400 (ppc) /usr/lib/libobjc.A.dylib<br />    UUID: 9B5973B7-FA88-F9AA-B788-<wbr>5530C7B278DD (i386) /usr/lib/libobjc.A.dylib<br />     UUID: D2A4E8E1-3C1C-E0D9-2249-<wbr>125B6DD621F8 (x86_64) /usr/lib/libobjc.A.dylib</pre>This crash matches my installed&nbsp;<code>libobjc.A.dylib</code>&nbsp;for i386. If it's a system library, you may need the image from the OS version listed in the crash log. If it's your application, you did keep a copy of every version you shipped, right?</li><li style="margin-left: 15px;">Calculate the&nbsp;<code>SEL</code>'s offset into the image.<pre style="white-space: pre-wrap;">    0xa1029 - 0x8b000 = 0x16029</pre></li><li style="margin-left: 15px;">Print the C string in the image at that offset. Remember to specify the correct architecture.<pre style="white-space: pre-wrap;">    % otool -v -arch i386 -s __TEXT __cstring /usr/lib/libobjc.A.dylib | grep 16029<br />    00016029  release<br />	    </pre></li></ol></td></tr></tbody></table><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196598.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 10:01 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196598.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Manually symbolicating crash logs with gdb</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196597.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 02:01:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196597.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196597.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196597.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196597.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-12-30<br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://www.picsoftware.ca/blog/?p=8" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://www.picsoftware.ca/<wbr>blog/?p=8</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">[自：简单步骤：</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">1，首先对比App的UUID，<wbr>来确定Crash的版本和App版本是否符合；</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">2，进入到App和dSYM文件的目录；</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">3，运行/Developer/Platforms/<wbr>iPhoneOS.platform/Developer/<wbr>usr/libexec/gdb/gdb-arm-apple-<wbr>darwin MyApp.app/MyApp；</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">4，</span><code style="line-height: normal; background-color: #ffffff; color: #3333ff;">set print asm-demangle on<br />5，</code><code style="line-height: normal; background-color: #ffffff; color: #3333ff;">set print symbol-filename on<br />6，</code><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">p/a 0&#215;00015c64</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">0&#215;00015c64就是想要查询的位置。</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">]</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><h2 style="color: #222222; font-family: arial, sans-serif; line-height: normal; background-color: #ffffff;">Manually symbolicating crash logs with gdb</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you&#8217;ve ever downloaded a crash report from iTunes Connect for one of your apps there is a good chance that you had a hard time getting any useful information from it. The stack traces in these crash reports don&#8217;t contain the meaningful method and file names that would help you track down the bug, they only contain the hexadecimal addresses of the methods. According to&nbsp;<a href="http://developer.apple.com/iphone/library/technotes/tn2008/tn2151.html" target="_blank" style="color: #1155cc;">this page</a>&nbsp;as long as you have the proper .app and .dSYM files somewhere that Finder can find them Xcode&#8217;s Organizer should be able to translate these addresses to the source code method name and line number to which they refer. This is a process called symbolication.&nbsp;<span style="background-color: #cccccc;">In my experience sometimes this works and sometimes it doesn&#8217;t.<span style="color: #3333ff;">【自：有时候好用，有时候不好用。】</span>&nbsp;</span>I have tried opening crash reports in the organizer and seen none or in some cases only a few of the symbols coming from my code being properly resolved . This post will describe a method to manually symbolicate these addresses when the Organizer doesn&#8217;t work.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">As you can see from this screenshot this is a crash log that Xcode only symbolicated a few of the addresses that originated from my code in lines 6 and 7 of the stack trace. Lines 0-5 have not been symbolicated.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><img title="Crash log" src="http://www.picsoftware.ca/blog_uploads/crash_log_1.png" alt="Crash log" width="620" height="544" /></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">So let&#8217;s symbolicate these addresses manually.&nbsp;<span style="background-color: #cccccc;">First we need to make sure we have the right .app and .dSYM files</span>.&nbsp;<span style="background-color: #ff6666;">The UUID in the crash log has to match the ones in our .app and .dSYM files</span>. We can check this with a command line utility called dwarfdump.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Running dwarfdump with the &#8211;uuid option on our executable gives us this result:</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>pics&#8208;imac:Downloads pic$ <span style="background-color: #cccccc;">dwarfdump &#8208;&#8208;uuid MyApp.app<span style="background-color: #ff6666;">/MyApp   <span style="background-color: #ffffff; color: #3333ff;">  [自：注意，这里不是.app文件夹，而是在.<wbr>app下的可执行文件]</span></span></span><br />
UUID: E2D9D241&#8208;37D3&#8208;CE06&#8208;7272&#8208;<wbr>653B813963E2 (armv6) MyApp.app/MyApp</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Now we run the same command on our .dSYM file and get this result:</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>pics&#8208;imac:Downloads pic$ <span style="background-color: #cccccc;">dwarfdump &#8208;&#8208;uuid MyApp.app.dSYM</span><br />UUID: E2D9D241&#8208;37D3&#8208;CE06&#8208;7272&#8208;<wbr>653B813963E2 (armv6)<br />MyApp.app.dSYM/Contents/<wbr>Resources/DWARF/MyApp</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Good, they match, so we can now check if they are the same as the UUID in the crash log. This can be found in the Binary Images section of the crash log as you can see in this screenshot.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><img title="Crash log" src="http://www.picsoftware.ca/blog_uploads/crash_log_2.png" alt="Crash log" width="622" height="177" /></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">You&#8217;ll notice they aren&#8217;t in the same format (the one in the crash log doesn&#8217;t have the dashes) but that doesn&#8217;t matter, as long as the numbers are the same everything is ok.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Now we know we have the .app and .dSYM files that match our crash log so we can launch gdb and start symbolicating. Make sure to use the arm version of gdb which is typically found at:<br /><code>/Developer/Platforms/iPhoneOS.<wbr>platform/Developer/usr/<wbr>libexec/gdb/gdb-arm-apple-<wbr>darwin</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #cccccc;"><code>pics-imac:Downloads pic$/Developer/Platforms/<wbr>iPhoneOS.platform/Developer/<wbr>usr/libexec/gdb/gdb-arm-apple-<wbr>darwin MyApp.app/MyApp</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">You may see some warnings about not being able to read symbols for a bunch of frameworks but this is ok. We use the &#8216;p/a&#8217; command in gdb to symbolicate the addresses from our crash log. Let&#8217;s start with the first unsymbolicated address on line 5 of the stack trace.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><code>5 MyApp 0x0002b0ee 0x0002b0ee</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Type this ate the gdb prompt:</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #cccccc;"><code>(gdb) p/a 0x0002b0ee</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">The result is:</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>$1 = 0x2b0ee &lt;_ZN7MyAppBase5touchEP8_touch_<wbr>ts+14&gt;</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">We can probably figure out what method this address is referring to from that but it is still a little ugly. There must be a way to tell gdb to make it nicer for us. After a quick search I found this site that explains some gdb print settings:</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><a href="http://www.delorie.com/gnu/docs/gdb/gdb_58.html" target="_blank" style="color: #1155cc;">http://www.delorie.com/gnu/<wbr>docs/gdb/gdb_58.html</a></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">One that looks promising is:</p><blockquote style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>set print asm-demangle on<br />Print C++ names in their source form rather than their mangled form, even in assembler code printouts such as instruction disassemblies. The default is off.</p></blockquote><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Let&#8217;s turn it on and see what happens.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #cccccc;"><code>(gdb) set print asm-demangle on<br />(gdb) p/a 0x0002b0ee</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">And now the result is:</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>$2 = 0x2b0ee &lt;MyApp::touch(_touch_t*, short)+14&gt;</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">This is much better, we can now see the class name, method name, parameters, and an offset. The only other thing I would like to see is the source code file name and line number just like a properly symbolicated crash log in the Organizer would show. After checking the website with the gdb print settings I found one that looks like it might do what I want:</p><blockquote style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>set print symbol-filename on<br />Tell GDB to print the source file name and line number of a symbol in the symbolic form of an address.</p></blockquote><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Let&#8217;s try it.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ff6666;"><code>(gdb) set print symbol-filename on<br />(gdb) p/a 0x0002b0ee</code></p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">This is the result we get:</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>$3 = 0x2b0ee &lt;MyApp::touch(_touch_t*, short)+14 at<br />/Users/pic/Dev/MyApp/Source/<wbr>MyApp.cpp:307&gt;</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Perfect! So now we can check the rest of the addresses in the crash log to get the full stack trace and find out exactly where the crash occurred.</p><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>(gdb) p/a 0x0006840a<br />$4 = 0x6840a &lt;Container::touch(_touch_t*, short)+188 at<br />/Users/pic/Dev/MyApp/Source/<wbr>widgets/Container.cpp:227&gt;<br />(gdb) p/a 0x000400ac<br />$5 = 0x400ac &lt;PuzzleView::touch(_touch_t*, short)+4 at<br />
/Users/pic/Dev/MyApp/Source/<wbr>PuzzleView.cpp:135&gt;<br />(gdb) p/a 0x0006840a<br />$6 = 0x6840a &lt;Container::touch(_touch_t*, short)+188 at<br />/Users/pic/Dev/MyApp/Source/<wbr>widgets/Container.cpp:227&gt;<br />(gdb) p/a 0x0002e216<br />
$7 = 0x2e216 &lt;Keyboard::touch(_touch_t*, short)+554 at<br />/Users/pic/Dev/MyApp/Source/<wbr>widgets/Keyboard.cpp:333&gt;<br />(gdb) p/a 0x0003aa9a<br />$8 = 0x3aa9a &lt;Grid::keypress(Keyboard*, wchar_t, touch_t)+1114 at<br />/Users/pic/Dev/MyApp/Source/<wbr>Grid.cpp:730&gt;<br />
(gdb) q<br />pics-imac:Downloads pic$</code></pre><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Now we know the crash was at line 730 in Grid.cpp and we can go find the bug.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">It would be nice if Xcode&#8217;s&nbsp;Organizer would just work all the time, but it has been my experience that sometimes for whatever reason it just doesn&#8217;t, even if you have the right .app and .dSYM files. In those cases I find this method to be very useful.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Happy debugging!</p><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 10:01 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：非常好的检测内存问题的文章</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196596.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 02:00:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196596.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196596.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196596.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196596.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196596.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-11-18<br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://gabriel.github.com/gh-unit/_env_variables.html" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://gabriel.github.com/<wbr>gh-unit/_env_variables.html</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><h1>Environment Variables</h1></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><h2>GHUnit Environment Variables</h2><p>Go into the "Get Info" contextual menu of your (Tests) executable (inside the "Executables" group in the left panel of XCode). Then go in the "Arguments" tab. You can add the following environment variables:</p><div><pre style="white-space: pre-wrap;"> GHUNIT_CLI - Default NO; Runs tests on the command line (see Debugger Console, Cmd-Shift-R)<br /> GHUNIT_RERAISE - Default NO; If an exception is encountered it re-raises it allowing you to crash into the debugger<br />
 GHUNIT_AUTORUN - Default NO; If YES, tests will start automatically<br /> GHUNIT_AUTOEXIT - Default NO; If YES, will exit upon test completion (no matter what); For command line MacOSX testing<br /> </pre></div><h2>Test Environment Variables (Recommended)</h2><p>Go into the "Get Info" contextual menu of your (Tests) executable (inside the "Executables" group in the left panel of XCode). Then go in the "Arguments" tab. You can add the following environment variables:</p><div><pre style="white-space: pre-wrap;"> Environment Variable:                 Default:  Set to:<br /> NSDebugEnabled                           NO       YES<br /> NSZombieEnabled                          NO       YES<br />
 NSDeallocateZombies                      NO       NO (or YES)<br /> NSHangOnUncaughtException                NO       YES<br /> NSAutoreleaseFreedObjectCheckE<wbr>nabled     NO       YES<br /> </pre></div><p>If Using NSDeallocateZombies=NO, then all objects will leak so be sure to turn it off when debugging memory leaks.</p><p>For more info on these varaiables see NSDebug.h (<a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html" target="_blank" style="color: #1155cc;">http://theshadow.uw.hu/<wbr>iPhoneSDKdoc/Foundation.<wbr>framework/NSDebug.h.html</a>)</p><p>For malloc debugging:</p><div><pre style="white-space: pre-wrap;"> MallocStackLogging<br /> MallocStackLoggingNoCompact<br /> MallocScribble<br /> MallocPreScribble<br /> MallocGuardEdges<br /> MallocDoNotProtectPrelude<br /> MallocDoNotProtectPostlude<br />
 MallocCheckHeapStart<br /> MallocCheckHeapEach<br /> </pre></div><p>If you see a message like:</p><div><pre style="white-space: pre-wrap;"> 2009-10-15 13:02:24.746 Tests[38615:40b] *** -[Foo class]: message sent to deallocated instance 0x1c8e680<br /> </pre></div><p>Re-run (in gdb) with&nbsp;<code>MallocStackLogging=YES</code>&nbsp;(or&nbsp;<code>MallocStackLoggingNoCompact=<wbr>YES</code>), then if you run under gdb:</p><div><pre style="white-space: pre-wrap;"> (gdb) shell malloc_history 38615 0x1c8e680<br /> <br /> ALLOC 0x1a9ad10-0x1a9ad6f [size=96]: thread_a024a500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __NSThreadPerformPerform | -[GHTestGroup _run:] | -[GHTest run] | +[GHTesting runTest:selector:withObject:<wbr>exception:interval:] | -[Foo foo] | +[NSObject alloc] | +[NSObject allocWithZone:] | _internal_class_createInstance | _internal_class_<wbr>createInstanceFromZone | calloc | malloc_zone_calloc <br />
 <br /> </pre></div><p>Somewhere between runTest and NSObject alloc there may be an object that wasn't retained.</p><p>Also using&nbsp;<code>MallocScribble=YES</code>&nbsp;causes the malloc library to overwrite freed memory with a well-known value (0x55), and occasionally checks freed malloc blocks to make sure the memory has not been over-written overwritten written since it was cleared.</p><p>For more info on these variables see MallocDebug (<a href="http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html" target="_blank" style="color: #1155cc;">http://developer.apple.com/<wbr>mac/library/documentation/<wbr>Performance/Conceptual/<wbr>ManagingMemory/Articles/<wbr>MallocDebug.html</a>)</p><p>For more info on malloc_history see malloc_history (<a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/malloc_history.1.html" target="_blank" style="color: #1155cc;">http://developer.apple.com/<wbr>mac/library/documentation/<wbr>Darwin/Reference/ManPages/<wbr>man1/malloc_history.1.html</a>)</p></div><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196596.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 10:00 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196596.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：NSDebug.h －Cocoa的用于调试的环境变量</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196595.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:59:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196595.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196595.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196595.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196595.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-11-18<br /><br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://theshadow.uw.hu/<wbr>iPhoneSDKdoc/Foundation.<wbr>framework/NSDebug.h.html</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><table style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; text-align: start; background-color: #ffffff;"><tbody><tr><td bgcolor="#eeeeff" width="100%" style="margin: 0px;"><h3>Foundation/NSDebug.h</h3></td><td nowrap="" style="margin: 0px;">iPhone.SDK<br />by hackstock</td></tr></tbody></table><hr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><code style="color: #222222; line-height: normal; background-color: #ffffff;"><font color="green">/*	NSDebug.h<br />Copyright (c) 1994-2005, Apple, Inc. All rights reserved.<br />*/<br /></font><br /><font color="green">/*****************************<wbr>******************************<wbr>***************<br />WARNING: Unsupported API.<br /><br />This module contains material that is only partially supported -- if<br />at all. Do not depend on the existance of any of these symbols in your<br />code in future releases of this software. Certainly, do not depend on<br />the symbols in this header in production code. The format of any data<br />produced by the functions in this header may also change at any time.<br /><br />However, it should be noted that the features (but not necessarily the<br />exact implementation) in this file have been found to be generally useful,<br />and in some cases invaluable, and are not likely to go away anytime soon.<br />******************************<wbr>******************************<wbr>**************/<br /></font><br />#import &lt;<a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSObject.h.html" target="_blank" style="color: #1155cc;">Foundation/NSObject.h</a>&gt;<br />#import &lt;<a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSAutoreleasePool.h.html" target="_blank" style="color: #1155cc;">Foundation/NSAutoreleasePool.<wbr>h</a>&gt;<br />#import &lt;<a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDate.h.html" target="_blank" style="color: #1155cc;">Foundation/NSDate.h</a>&gt;<br />#import &lt;<a href="http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSPort.h.html" target="_blank" style="color: #1155cc;">Foundation/NSPort.h</a>&gt;<br /><br /><font color="green">/* The environment component of this API<br /><br />The boolean- and integer-valued variables declared in this header,<br />plus some values set by methods, read starting values from the<br />process's environment at process startup. This is mostly a benefit<br />if you need to initialize these variables to some non-default value<br />before your program's main() routine gets control, but it also<br />allows you to change the value without modifying your program's<br />source. (Variables can be set and methods called around specific<br />areas within a program, too, of course.)<br /><br />The initialization from the environment happens very early, but may<br />not have happened yet at the time of a +load method statically linked<br />into an application (as opposed to one in a dynamically loaded module).&nbsp;<br />But as noted in the "Foundation Release Notes", +load methods that are<br />statically linked into an application are tricky to use and are not<br />recommended.<br /><br />Here is a table of the variables/values initialized from the environment<br />at startup. Some of these just set variables, others call methods to<br />set the values.<br /><br />NAME OF ENV. VARIABLE	 DEFAULT	SET TO...<br />NSDebugEnabled	 NO	"YES"<br />NSZombieEnabled	 NO	"YES"<br />NSDeallocateZombies	 NO	"YES"<br />NSHangOnUncaughtException	 NO	"YES"<br /><br />NSEnableAutoreleasePool	 YES	"NO"<br />NSAutoreleaseFreedObjectCheckE<wbr>nabled	 NO	"YES"<br />NSAutoreleaseHighWaterMark	 0	non-negative integer<br />NSAutoreleaseHighWaterResoluti<wbr>on	 0	non-negative integer<br /><br />*/<br /></font><br /><font color="green">/****************	General	 ****************/<br /></font><br />FOUNDATION_EXPORT BOOL NSDebugEnabled;<br /><font color="green">// General-purpose global boolean. Applications and frameworks</font><br /><font color="green">// may choose to do some extra checking, or use different</font><br /><font color="green">// algorithms, or log informational messages, or whatever, if</font><br /><font color="green">// this variable is true (ex: if (NSDebugEnabled) { ... }).</font><br /><br />FOUNDATION_EXPORT BOOL NSZombieEnabled;<br /><font color="green">// Enable object zombies. When an object is deallocated, its isa</font><br /><font color="green">// pointer is modified to be that of a "zombie" class (whether or</font><br /><font color="green">// not the storage is then freed can be controlled by the</font><br /><font color="green">// NSDeallocateZombies variable). Messages sent to the zombie</font><br /><font color="green">// object cause logged messages and can be broken on in a debugger.</font><br /><font color="green">// The default is NO.</font><br /><br />FOUNDATION_EXPORT BOOL NSDeallocateZombies;<br /><font color="green">// Determines whether the storage of objects that have been</font><br /><font color="green">// "zombified" is then freed or not. The default value (NO)</font><br /><font color="green">// is most suitable for debugging messages sent to zombie</font><br /><font color="green">// objects. And since the memory is never freed, storage</font><br /><font color="green">// allocated to an object will never be reused, either (which</font><br /><font color="green">// is sometimes useful otherwise).</font><br /><br />FOUNDATION_EXPORT BOOL NSHangOnUncaughtException;<br /><font color="green">// If set to YES, causes the process to hang after logging the</font><br /><font color="green">// "*** Uncaught exception:" message. A backtrace can be gotten</font><br /><font color="green">// from the process with the 'sample' utility, or the process can</font><br /><font color="green">// be attached to with a debugger. The default is NO.</font><br /><br />FOUNDATION_EXPORT BOOL NSIsFreedObject(id anObject);<br /><font color="green">// Returns YES if the value passed as the parameter is a pointer</font><br /><font color="green">// to a freed object. Note that memory allocation packages will</font><br /><font color="green">// eventually reuse freed memory blocks to satisfy a request.</font><br /><font color="green">// NSZombieEnabled and NSDeallocateZombies can be used to prevent</font><br /><font color="green">// reuse of allocated objects.</font><br /><br /><font color="green">/****************	Stack processing	****************/<br /></font><br />FOUNDATION_EXPORT void *NSFrameAddress(unsigned frame);<br />FOUNDATION_EXPORT void *NSReturnAddress(unsigned frame);<br /><font color="green">// Returns the value of the frame pointer or return address,</font><br /><font color="green">// respectively, of the specified frame. Frames are numbered</font><br /><font color="green">// sequentially, with the "current" frame being zero, the</font><br /><font color="green">// previous frame being 1, etc. The current frame is the</font><br /><font color="green">// frame in which either of these functions is called. For</font><br /><font color="green">// example, NSReturnAddress(0) returns an address near where</font><br /><font color="green">// this function was called, NSReturnAddress(1) returns the</font><br /><font color="green">// address to which control will return when current frame</font><br /><font color="green">// exits, etc. If the requested frame does not exist, then</font><br /><font color="green">// NULL is returned. The behavior of these functions is</font><br /><font color="green">// undefined in the presence of code which has been compiled</font><br /><font color="green">// without frame pointers.</font><br /><br />FOUNDATION_EXPORT unsigned NSCountFrames(void);<br /><font color="green">// Returns the number of call frames on the stack. The behavior</font><br /><font color="green">// of this functions is undefined in the presence of code which</font><br /><font color="green">// has been compiled without frame pointers.</font><br /><br /><font color="green">/****************	Autorelease pool debugging	****************/<br /></font><br /><font color="green">// Functions used as interesting breakpoints in a debugger</font><br />FOUNDATION_EXPORT void _NSAutoreleaseNoPool(void *object);<br /><font color="green">// Called to log the "Object X of class Y autoreleased with no</font><br /><font color="green">// pool in place - just leaking" message.</font><br /><br />FOUNDATION_EXPORT void _NSAutoreleaseFreedObject(void *freedObject);<br /><font color="green">// Called when a previously freed object would be released</font><br /><font color="green">// by an autorelease pool. See +enableFreedObjectCheck: below.</font><br /><br />FOUNDATION_EXPORT void _NSAutoreleaseHighWaterLog(<wbr>unsigned int count);<br /><font color="green">// Called whenever a high water mark is reached by a pool.</font><br /><font color="green">// See +setPoolCountHighWaterMark: below.</font><br /><br />@interface&nbsp;<a name="12c5c8c2554f98c8_NSAutoreleasePool" style="color: #1155cc;">NSAutoreleasePool</a>&nbsp;(NSAutoreleasePoolDebugging)<br /><br />+ (void)enableRelease:(BOOL)<wbr>enable;<br /><font color="green">// Enables or disables autorelease pools; that is, whether or</font><br /><font color="green">// not the autorelease pools send the -release message to their</font><br /><font color="green">// objects when each pool is released. This message affects only</font><br /><font color="green">// the pools of the autorelease pool stack of the current thread</font><br /><font color="green">// (and any future pools in that thread). The "default default"</font><br /><font color="green">// value can be set in the initial environment when a program</font><br /><font color="green">// is launched with the NSEnableAutoreleasePool environment</font><br /><font color="green">// variable (see notes at the top of this file) -- as thread</font><br /><font color="green">// pool-stacks are created, they take their initial enabled</font><br /><font color="green">// state from that environment variable.</font><br /><br />+ (void)showPools;<br /><font color="green">// Displays to stderr the state of the current thread's</font><br /><font color="green">// autorelease pool stack.</font><br /><br />+ (void)<wbr>resetTotalAutoreleasedObjects;<br />+ (unsigned)<wbr>totalAutoreleasedObjects;<br /><font color="green">// Returns the number of objects autoreleased (in ALL threads,</font><br /><font color="green">// currently) since the counter was last reset to zero with</font><br /><font color="green">// +<wbr>resetTotalAutoreleasedObjects.</font><br /><br />+ (void)enableFreedObjectCheck:(<wbr>BOOL)enable;<br /><font color="green">// Enables or disables freed-object checking for the pool stack</font><br /><font color="green">// of the current thread (and any future pools in that thread).</font><br /><font color="green">// When enabled, an autorelease pool will call the function</font><br /><font color="green">// _NSAutoreleaseFreedObject() when it is about to attempt to</font><br /><font color="green">// release an object that the runtime has marked as freed (and</font><br /><font color="green">// then it doesn't attempt to send -release to the freed storage).</font><br /><font color="green">// The pointer to the freed storage is passed to that function.</font><br /><font color="green">// The "default default" value can be set in the initial</font><br /><font color="green">// environment when a program is launched with the</font><br /><font color="green">// NSAutoreleaseFreedObjectCheckE<wbr>nabled environment variable</font><br /><font color="green">// (see notes at the top of this file) -- as thread pool-stacks</font><br /><font color="green">// are created, they take their initial freed-object-check state</font><br /><font color="green">// from that environment variable.</font><br /><br />+ (unsigned int)autoreleasedObjectCount;<br /><font color="green">// Returns the total number of autoreleased objects in all pools</font><br /><font color="green">// in the current thread's pool stack.</font><br /><br />+ (unsigned int)topAutoreleasePoolCount;<br /><font color="green">// Returns the number of autoreleased objects in top pool of</font><br /><font color="green">// the current thread's pool stack.</font><br /><br />+ (unsigned int)poolCountHighWaterMark;<br />+ (void)<wbr>setPoolCountHighWaterMark:(<wbr>unsigned int)count;<br /><font color="green">// Sets the pool count high water mark for the pool stack of</font><br /><font color="green">// the current thread (and any future pools in that thread). When</font><br /><font color="green">// 'count' objects have accumulated in the top autorelease pool,</font><br /><font color="green">// the pool will call _NSAutoreleaseHighWaterLog(), which</font><br /><font color="green">// generates a message to stderr. The number of objects in the</font><br /><font color="green">// top pool is passed as the parameter to that function. The</font><br /><font color="green">// default high water mark is 0, which disables pool count</font><br /><font color="green">// monitoring. The "default default" value can be set in the</font><br /><font color="green">// initial environment when a program is launched with the</font><br /><font color="green">// NSAutoreleaseHighWaterMark environment variable (see notes at</font><br /><font color="green">// the top of this file) -- as thread pool-stacks are created,</font><br /><font color="green">// they take their initial high water mark value from that</font><br /><font color="green">// environment variable. See also +<wbr>setPoolCountHighWaterResolutio<wbr>n:.</font><br /><br />+ (unsigned int)<wbr>poolCountHighWaterResolution;<br />+ (void)<wbr>setPoolCountHighWaterResolutio<wbr>n:(unsigned int)res;<br /><font color="green">// Sets the pool count high water resolution for the pool stack of</font><br /><font color="green">// the current thread (and any future pools in that thread). A</font><br /><font color="green">// call to _NSAutoreleaseHighWaterLog() is generated every multiple</font><br /><font color="green">// of 'res' objects above the high water mark. If 'res' is zero</font><br /><font color="green">// (the default), only one call to _NSAutoreleaseHighWaterLog() is</font><br /><font color="green">// made, when the high water mark is reached. The "default default"</font><br /><font color="green">// value can be set in the initial environment when a program is</font><br /><font color="green">// launched with the NSAutoreleaseHighWaterResoluti<wbr>on environment</font><br /><font color="green">// variable (see notes at the top of this file) -- as thread</font><br /><font color="green">// pool-stacks are created, they take their initial high water</font><br /><font color="green">// resolution value from that environment variable. See also</font><br /><font color="green">// +setPoolCountHighWaterMark:.</font><br /><br />@end<br /><br /><font color="green">/****************	Allocation statistics	****************/<br /></font><br /><font color="green">// The statistics-keeping facilities generate output on various types of</font><br /><font color="green">// events. Currently, output logs can be generated for use of the zone</font><br /><font color="green">// allocation functions (NSZoneMalloc(), etc.), and allocation and</font><br /><font color="green">// deallocation of objects (and other types of lifetime-related events).</font><br /><br /><font color="green">// This boolean is obsolete and unused</font><br />FOUNDATION_EXPORT BOOL NSKeepAllocationStatistics;<br /><br /><font color="green">// Object allocation event types</font><br />#define NSObjectAutoreleasedEvent	 3<br />#define NSObjectExtraRefIncrementedEve<wbr>nt	4<br />#define NSObjectExtraRefDecrementedEve<wbr>nt	5<br />#define NSObjectInternalRefIncremented<wbr>Event	6<br />#define NSObjectInternalRefDecremented<wbr>Event	7<br /><br /><br />FOUNDATION_EXPORT void NSRecordAllocationEvent(int eventType, ...);<br /><font color="green">// Notes an object or zone allocation event and various other</font><br /><font color="green">// statistics, such as the time and current thread. The additional</font><br /><font color="green">// arguments to be passed to this function vary by the type of</font><br /><font color="green">// event. The behavior is undefined (and likely catastrophic) if</font><br /><font color="green">// the correct arguments for 'eventType' are not provided.</font><br /><font color="green">//</font><br /><font color="green">// The parameter prototypes for each event type are shown below.</font><br /><font color="green">// NSRecordAllocationEvent(<wbr>NSObjectAutoreleasedEvent, curObj)</font><br /><font color="green">// NSRecordAllocationEvent(<wbr>NSObjectExtraRefIncrementedEve<wbr>nt, curObj)</font><br /><font color="green">// NSRecordAllocationEvent(<wbr>NSObjectExtraRefDecrementedEve<wbr>nt, curObj)</font><br /><font color="green">// NSRecordAllocationEvent(<wbr>NSObjectInternalRefIncremented<wbr>Event, curObj)</font><br /><font color="green">// NSRecordAllocationEvent(<wbr>NSObjectInternalRefDecremented<wbr>Event, curObj)</font><br /><font color="green">//</font><br /><font color="green">// Only the Foundation should have reason to use many of these.</font><br /><font color="green">// Do not call NSRecordAllocationEvent(<wbr>NSZoneMallocEvent, ...)</font><br /><font color="green">// after NSZoneMalloc(), for example, in your own code because</font><br /><font color="green">// NSZoneMalloc() has already done this for you. The only common</font><br /><font color="green">// use of this function should be with these two events:</font><br /><font color="green">//	NSObjectInternalRefIncremented<wbr>Event</font><br /><font color="green">//	NSObjectInternalRefDecremented<wbr>Event</font><br /><font color="green">// when a class overrides -retain and -release to do its own</font><br /><font color="green">// reference counting.</font><br /><font color="green">//</font><br /><br /></code><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:59 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：GDB和ObjC结合的高级技巧</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196594.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:59:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196594.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196594.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196594.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196594.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196594.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-11-12<br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://support.apple.com/kb/TA45906?viewlocale=en_US" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://support.apple.com/kb/<wbr>TA45906?viewlocale=en_US</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Advanced Debugging Techniques</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Backtraces</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Gdb provides a set of commands that allow you to examine the state of your application. Use the backtrace command (bt) to find out where control has come from, based on a list of stack frames. Use the frame command (f) to choose which of those stack frames is selected. The info frame, info locals, and info args commands provide you with more information about the chosen frame. Remember that gdb's command line interpreter can evaluate any C or Objective-C expression, so when your application is stopped in gdb, you can examine and set variables of your program, make function calls, send messages to objects, and so on.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Backtrace output looks like this:</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) bt</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#0 -[MovieMgr fetchMovies] (self=0x439750, _cmd=0x402127) at MovieMgr.m:28</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#1 0x401030 in -[MovieMgr init] (self=0x439750, _cmd=0x310255d3)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">at MovieMgr.m:12</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#2 0x320434c0 in +[NSObject new] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#3 0x31017842 in objc_msgSendv ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#4 0x320410d5 in -[NSInvocation invoke] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#5 0x540b4134 in NMSPerformSelector ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#6 0x540bf01e in -[WOObjCExpression evaluateInScope:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#7 0x540bb575 in -[WOBinaryExpression evaluateInScope:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#8 0x540bc8d5 in -[WOExpressionStatement executeInScope:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#9 0x540c27b0 in -[WOStatements executeInScope:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#10 0x540bc6a7 in -[WOCompoundStatement executeInScope:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#11 0x540bd45f in -[WOMethod executeInParentScope:debugger:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">forSelf:arguments:]</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#12 0x540be5a5 in -[WOModule evaluateMethodNamed:forSelf:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">count:arguments:inScope</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#13 0x540b7289 in _NMSGenericMethod ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#14 0x540b72dd in -[_NMSScriptedClassShadow _genericVararg:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#15 0x4201d5ad in -[WOComponent(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WOComponentPrivate) _initWithName:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#16 0x4201e7bb in -[WOComponentDefinition(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WOComponentGeneration) componentInstan</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">ce] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#17 0x42018a5f in -[WOApplication(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WOPageManagement) pageWithName:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#18 0x4201932f in -[WOApplication(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WORequestHandlingInternals) _handleRequestInPr</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">eparedSession] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#19 0x42019277 in -[WOApplication(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WORequestHandlingInternals) _handleRequestInPr</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">eparedApplication] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#20 0x42019915 in -[WOApplication(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">WORequestHandling) handleRequest:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#21 0x4202a0c5 in -[WODefaultAdaptor handleConnection:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#22 0x3203946f in _postNotification ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#23 0x32039d6a in -[NSNotificationCenter postNotificationName:object:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">userInfo:]</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#24 0x320604ad in -[NSConcreteFileHandle handleMachMessage:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#25 0x3206f0c6 in -[NSRunLoop acceptInputForMode:beforeDate:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#26 0x3206f268 in -[NSRunLoop runMode:beforeDate:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#27 0x42018d75 in -[WOApplication(WORunning) run] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#28 0x4012d6 in main (argc=4, argv=0x436430) at main.m:183</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#29 0x40144c in mainCRTStartup ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">You can then inspect the frames.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) f 12</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#12 0x540be5a5 in -[WOModule evaluateMethodNamed:forSelf:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">count:arguments:inScope</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you have the symbols, you can use info args to print the function's arguments and info locals to print the local variables:</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) info args</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">self = (MovieMgr *) 0x439750</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">_cmd = (struct objc_selector *) 0x402127</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) info locals</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">self = (MovieMgr *) 0x439750</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">fetchSpec = (EOFetchSpecification *) 0x448a80</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you do not have the symbols, you can still get to some of the argument information by using the frame pointer and offsets. (These offsets vary based on system architecture.)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">p *(id *)($fp + 8) - prints the receiver of the message (often the same as self)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">p *(SEL *)($fp + 12) - prints the selector (the method that was called)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">p *(id *)($fp + 16) - prints argument 1</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">p *(id *)($fp + 20) - prints argument 2</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">p *(id *)($fp + 24) - prints argument 3</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) f 12</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">#12 0x540be5a5 in -[WOModule evaluateMethodNamed:forSelf:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">count:arguments:inScope</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">:debugger:] ()</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) p *(id *)($fp + 8)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">$4 = (WOModule *) 0x43ab70</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) p *(id *)($fp + 16)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">$5 = (NSInlineCString *) 0x428ff0</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) po $5</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">init</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb) p *(id *)($fp + 20)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">$6 = (WOScriptedClass(/WebObjects/</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Projects/batch.woa/Main.wo/</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Main) *) 0x432ea0</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">(gdb)</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">For convenience, you may want to create user-defined commands for these offsets in your .gdbinit file.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196594.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:59 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196594.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：很强大的介绍ObjC的内部知识，用于调试</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196593.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:58:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196593.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196593.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196593.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196593.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196593.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-11-12<br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://www.phrack.org/issues.html?issue=66&amp;id=4#article" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://www.phrack.org/<wbr>issues.html?issue=66&amp;id=4#<wbr>article</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;">The Objective-C Runtime:  Understanding and Abusing</pre><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196593.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:58 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196593.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：调试教程 – 使用UIRecorder Instrument将测试自动化</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196592.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:57:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196592.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196592.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196592.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196592.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196592.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-11-3<br /><br /></span><div style="color: #222222; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; font-family: sans-serif; overflow: auto; width: 544.5999755859375px; margin: 0px 10px;"><h2 style="margin: 0.25em 0px 0px;"><a href="http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e8%b0%83%e8%af%95%e6%95%99%e7%a8%8b-%e2%80%93-%e4%bd%bf%e7%94%a8uirecorder-instrument%e5%b0%86%e6%b5%8b%e8%af%95%e8%87%aa%e5%8a%a8%e5%8c%96" target="_blank" style="color: #1155cc;">调试教程 &#8211; 使用UIRecorder Instrument将测试自动化</a></h2><div style="margin-bottom: 0.5em;">于 10-7-18 通过&nbsp;<a href="http://www.iphone-geek.cn/" target="_blank" style="color: #1155cc;">iPhoneGeek 爱疯极客</a>&nbsp;作者：bagusflyer</div><br /><p>（注：这是我以前收集的一篇文章，找不到出处了，<wbr>稍作修改在此发布）</p><p><br /></p><p>如果你发现程序的bug，<wbr>但每次进行测试都需要许多步骤才能重现问题，那么本教程适合你。<wbr>通常，测试和调试是非常繁琐的事情，<wbr>iPhone程序的开发尤其如此。</p><p><br /></p><p>比如说，你有个程序需要经过5个步骤才能到达另一个view。<wbr>如果你有一个bug发生在这个需要5步之多的view上，<wbr>通常情况下调试的步骤如下：</p><ul><li style="margin-left: 15px;">运行程序</li><li style="margin-left: 15px;">触击 view 1</li><li style="margin-left: 15px;">触击view 2</li><li style="margin-left: 15px;">触击 view 3</li><li style="margin-left: 15px;">触击 view 4</li><li style="margin-left: 15px;">触击 view 5</li><li style="margin-left: 15px;">(程序崩溃)</li><li style="margin-left: 15px;">修改代码</li><li style="margin-left: 15px;">重复以上步骤</li></ul><p><br /></p><p>如你所见，这是多么痛苦的事情啊。&nbsp;<a href="http://twitter.com/kendalldevdiary" target="_blank" style="color: #1155cc;">Kendall Gelner</a>&nbsp;在&nbsp;<a href="http://www.360idev.com/" target="_blank" style="color: #1155cc;">360iDev</a>&nbsp;上有关使用Instruments 和 XCode进行调试的若干提示的演讲中，<wbr>对我而言最为有用的就是将测试自动化。我演示一下应该怎么做:</p><p style="padding-left: 30px;">1. 打开希望测试/调试的程序</p><p style="padding-left: 30px;">2. 在模拟器中运行</p><p style="padding-left: 30px;">3. 打开<strong>Instrument</strong>&nbsp;&#8211; 位于 /Developer/<a href="http://www.iphone-geek.cn/wp-admin/#" target="_blank" style="color: #1155cc;"><span style="color: #346200 !important;"><span style="font-family: Helvetica, Arial, sans-serif;">Applications</span></span></a>/<wbr>Instruments</p><ol></ol><ol></ol><p><br /></p><p style="text-align: center;"><strong><a href="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_01.png" target="_blank" style="color: #1155cc;"><img title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_01-300x229.png" alt="screenshot_01" width="300" height="229" style="zoom: 1; display: inline;" /></a></strong></p><p style="text-align: center;"><strong><br /></strong></p><p style="padding-left: 30px;">4. 选择&nbsp;<strong>UIRecorder</strong>&nbsp;并按<strong>Choose&nbsp;</strong>- 你将看到下面窗口</p><p style="text-align: center;"><strong><a href="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_02.png" target="_blank" style="color: #1155cc;"><img title="screenshot_02" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_02-300x211.png" alt="screenshot_02" width="300" height="211" style="zoom: 1; display: inline;" /></a></strong></p><p style="text-align: center;"><strong><br /></strong></p><p style="padding-left: 30px;">5.&nbsp; 然后需要将此工具与iPhone模拟器进程链接。<wbr>按下下拉菜单选择&nbsp;<strong>Default Target</strong>&nbsp;-&gt;&nbsp;<strong>Attach to Process&nbsp;</strong>-&gt;&nbsp;<strong>iPhone Simulator</strong>.</p><p style="text-align: center;"><a href="http://icodeblog.com/wp-content/uploads/2009/10/ss_03.png" target="_blank" style="color: #1155cc;"><img title="ss_03" src="http://icodeblog.com/wp-content/uploads/2009/10/ss_03-300x136.png" alt="ss_03" width="300" height="136" style="zoom: 1; display: inline;" /></a></p><p><br /></p><p style="padding-left: 30px;">6. 再按下&nbsp;<strong>Drive &amp; Record</strong>&nbsp;并在模拟器中完成测试所需的所有步骤。至此，UI Recorder记录下了你的一举一动。完成时，按下<strong>Stop</strong>按<wbr>钮。&nbsp;<span style="color: #ff0000;"><strong>注意：</strong></span>&nbsp;在完成记录后请不要移动模拟器，<wbr>因为这有可能会使弄乱整个处理过程。</p><p style="padding-left: 30px;">7. 修改你的代码&#8230;</p><p style="padding-left: 30px;">8. 按下&nbsp;<strong>Drive &amp; Record&nbsp;</strong>按钮亲眼目睹一下有什么神奇的事情发生吧。测试自动进行了！<wbr>你应该看到它自动模拟了你刚才进行的所有动作。<br /><br /><br /><br /></p><p><br /></p></div><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">+++++</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196592.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:57 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196592.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原:内存泄露问题经验</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196591.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:55:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196591.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196591.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196591.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196591.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196591.html</trackback:ping><description><![CDATA[创建：<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">10-9-28</span><br /><br /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">内存泄露问题:</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*所有成员变量需要在程序中,多次赋值的,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">也就是说不仅仅是在初始化函数分配一次的,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">则一定要使用访问变量,否则容易引起内存的释放等问题.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*数组释放时异常,发现前几个元素都是0x0.注意,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">这个时候并不是因为数组因为有0x0的元素而导致的异常,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">而是因为在释放到0x0之后的元素时,发生了异常,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">很可能是外部将数组的元素释放了.至于有0x0的原因,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">是因为数组在依次释放,每次释放了一个元素之后,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">都会置为0x0.所以,显示0x0的元素,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">其实是正确释放了的元素.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改方法是:查找数组的对象,是否正确释放了,有些时候,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">可能需要使用访问函数来进行成员变量的存储和释放,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">而不是直接操作成员变量.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*[alert show]会提示内存泄露.因为,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">alert不会在当前页面显示.它会被加入到系统的资源中,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">等待下次event到达之后,才会显示出来,因此,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">系统会在你show之后,自动retain它,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">然后在它显示之后,在release它.总而言之,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">你可以忽略它的泄露.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">参见:</span><a href="http://stackoverflow.com/questions/2862335/uialertview-show-causing-a-memory-leak" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://stackoverflow.com/<wbr>questions/2862335/uialertview-<wbr>show-causing-a-memory-leak</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*访问函数的内存泄露.如果某个变量有访问函数,则 在程序中someVar = xxx会导致内存泄露,而[someVar release],则会导致异常退出.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">方法是:</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">1,先使用@pro&nbsp; ,搜索所有的访问变量.然后全选,粘贴到某个文本文件中.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">2,然后针对每个访问变量,搜索&nbsp; [^.]sessionid[ ]*=&nbsp; 正则表达式来搜索所有someVar = xxx</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">3,然后针对每个访问变量,搜索 name[ ]*release 查看是否有除了在dealloc之外的删除,</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">需要修正为self.xxx = nil;</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196591.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:55 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196591.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转:深入理解ObjectiveC Part3</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/25/196590.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Tue, 25 Dec 2012 01:54:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/25/196590.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196590.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/25/196590.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196590.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196590.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 创建：10-9-25转:http://www.phrack.org/issues.html?issue=66&amp;id=4#article--[ 5 - Exploiting Objective-C ApplicationsHopefully at this stage you're fairly familiar with the Objective-Cruntime. In this se...&nbsp;&nbsp;<a href='http://www.cppblog.com/walkklookk/archive/2012/12/25/196590.html'>阅读全文</a><img src ="http://www.cppblog.com/walkklookk/aggbug/196590.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-25 09:54 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/25/196590.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>