﻿<?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++博客-紫月城游戏软件-随笔分类-通用编程</title><link>http://www.cppblog.com/kevinlynx/category/6540.html</link><description>低调做技术</description><language>zh-cn</language><lastBuildDate>Sat, 26 Apr 2008 12:09:09 GMT</lastBuildDate><pubDate>Sat, 26 Apr 2008 12:09:09 GMT</pubDate><ttl>60</ttl><item><title>调试经验总结-VC下的错误对话框</title><link>http://www.cppblog.com/kevinlynx/archive/2008/04/24/47998.html</link><dc:creator>Kevin Lynx</dc:creator><author>Kevin Lynx</author><pubDate>Thu, 24 Apr 2008 05:43:00 GMT</pubDate><guid>http://www.cppblog.com/kevinlynx/archive/2008/04/24/47998.html</guid><wfw:comment>http://www.cppblog.com/kevinlynx/comments/47998.html</wfw:comment><comments>http://www.cppblog.com/kevinlynx/archive/2008/04/24/47998.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/kevinlynx/comments/commentRss/47998.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kevinlynx/services/trackbacks/47998.html</trackback:ping><description><![CDATA[<p><font size=2>很早前就想写点总结将编程中遇到的各种错误刨根挖底地罗列出来。但是因为这些错误（VC中开调试器遇到的各种错误对话框）都是随机性的，真正想总结的时候又不想不起来有哪些错误。恰好最近运气比较背，各种错误都被我遇遍了，于是恰好有机会做个总结。 </font>
<p><font size=2>这里所说的VC下的错误对话框时指在VC中开调试器运行程序时，IDE弹出的对话框。</font>
<p><strong>1.不是错误的错误：断言</strong> .</p>
<p>将断言视为错误其实有点可笑，但是因为有些同学甚至不知道这个，所以我稍微提一下。断言对话框大致上类似于：</p>
<p><a href="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/assert_1.jpg"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=257 alt=assert src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/assert_thumb_1.jpg" width=444 border=0></a> </p>
<p>断言对话框是由assert引起的，在对话框上通常会给出表达式，例如assert( 0 ); 弹出对话框时就会将0这个表达式显示出来（Expression:0)。关于assert的具体信息建议自己google。这里稍微提一下一个技巧：有时候为了让assert提供更多的信息，我们可以这样写一个assert:</p>
<p>assert( expression &amp;&amp; "Function : invalid argument!" ); </p>
<p>因为字符串被用在布尔表达式中时，始终为true，不会妨碍对expression的判断，当断言发生时(expression为false) 时，断言对话框上就会显示这个字符串，从而方便我们调试。</p>
<p>要解决这个问题，首先要确定断言发生的位置，如果是你自己设置的断言被引发，就很好解决，如果是系统内部的函数产生的，那么一般是因为你传入的函数参数无效引起。</p>
<p>&nbsp;</p>
<p><strong>2.内存相关：最简单的非法访问：</strong></p>
<p>C、C++程序中经常误用无效的指针，从而大致各种各样的非法内存访问（写/读）。最简单的情况类似于：</p>
<p><a href="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/wrongaccess.jpg"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=186 alt=wrongaccess src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/wrongaccess_thumb.jpg" width=444 border=0></a> </p>
<p>这样的情况由类似以下代码引起：</p>
<p>char *p = 0;
<p>*p = 'a';
<p>当你看到类似于&#8220;写入位置XXXX时发生访问冲突&#8220;时，那么你大致可以断定，你的程序在某个地方访问到非法内存。开调试器对调用堆栈进行跟踪即可找出错误。</p>
<p>&nbsp;</p>
<p><strong>3.内存相关：不小心的栈上数组越界：</strong></p>
<p>当你写下类似以下的代码时：</p>
<p>char str[3];
<p>strcpy( str, "abc" );
<p>就将看到如下的对话框：
<p><a href="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/stackerror.jpg"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=235 alt=stackerror src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/stackerror_thumb.jpg" width=516 border=0></a>&nbsp;
<p>对话框大致的意思就是说str周围的栈被破坏了，因为str本身就被放在栈上，所以strcpy(str,"abc")多写入的'\0'就写到非法的栈区域。看到这样的对话框可以根据调用堆栈定位到错误发生的函数，然后检查此函数内部定义的数组访问，即可解决问题。
<p>&nbsp;
<p><strong>4.内存相关：不小心的堆上数组越界：<br></strong>并不是每次数组越界都会得到上面所描述的错误，当数组是在堆上分配时，情况就变得隐秘得多：
<p>char *str = new char [2];
<p>strcpy( str, "ab" ); //执行到这里时并不见得会崩溃
<p>delete [] str;//但是到这里时就肯定会崩溃
<p>以上代码导致的错误对话框还要诡异些：
<p><a href="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/heaperror.jpg"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=206 alt=heaperror src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/heaperror_thumb.jpg" width=516 border=0></a>
<p>似乎不同的DAMAGE对应的错误号（这里是47）都不一样，因为这里的错误发生在delete，而delete跟new很可能在不同的地方，所以这个错误调试起来不是那么容易，很多时候只能靠经验。
<p>当看到类似的对话框时，根据调用堆栈跟到delete时，你就可以大致怀疑堆上数组越界。
<p>&nbsp;
<p><strong>5.调用相关：函数调用约定带来的错误：</strong>
<p>这是所有我这里描述的错误中最诡异的一种，先看下对话框大致的样子：
<p><a href="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/run_functioncall2.jpg"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=195 alt=run_functioncall2 src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/run_functioncall2_thumb.jpg" width=446 border=0></a>
<p>对话框大致的意思就是说（没开调试器时对话框样式可能不一样），通过函数指针调用某个函数时，函数指针的类型（函数原型）可能与函数指针指向的函数的类型不一样。这里的类型不一致主要是调用约定(call conversation）不一样。如果函数类型（参数个数，返回值）不一样，一般不会出错。
<p>调用约定是指调用一个函数时，函数参数的压入顺序、谁来清理栈的内容等。例如默认的C、C++调用约定__cdecl，对于函数的参数是从右往左压入。而__stdcall（WIN API的调用约定）则是从左向右压。我这里所说的函数类型不一样，就是指一个函数是使用__cdecl，还是__stdcall。例如以下代码：
<p>&#160;</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;__stdcall&nbsp;show(&nbsp;</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">str&nbsp;)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img id=Codehighlighter1_63_67_Open_Image onclick="this.style.display='none'; Codehighlighter1_63_67_Open_Text.style.display='none'; Codehighlighter1_63_67_Closed_Image.style.display='inline'; Codehighlighter1_63_67_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_63_67_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_63_67_Closed_Text.style.display='none'; Codehighlighter1_63_67_Open_Image.style.display='inline'; Codehighlighter1_63_67_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_63_67_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_63_67_Open_Text><span style="COLOR: #000000">{&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;__stdcall&nbsp;show2()&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img id=Codehighlighter1_96_100_Open_Image onclick="this.style.display='none'; Codehighlighter1_96_100_Open_Text.style.display='none'; Codehighlighter1_96_100_Closed_Image.style.display='inline'; Codehighlighter1_96_100_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_96_100_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_96_100_Closed_Text.style.display='none'; Codehighlighter1_96_100_Open_Image.style.display='inline'; Codehighlighter1_96_100_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_96_100_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_96_100_Open_Text><span style="COLOR: #000000">{&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img id=Codehighlighter1_117_239_Open_Image onclick="this.style.display='none'; Codehighlighter1_117_239_Open_Text.style.display='none'; Codehighlighter1_117_239_Closed_Image.style.display='inline'; Codehighlighter1_117_239_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_117_239_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_117_239_Closed_Text.style.display='none'; Codehighlighter1_117_239_Open_Image.style.display='inline'; Codehighlighter1_117_239_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_117_239_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_117_239_Open_Text><span style="COLOR: #000000">{&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>typedef&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">Func)(&nbsp;</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;show;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>Func&nbsp;my_func&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;(Func)&nbsp;p;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>my_func(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">kevin</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<p>&nbsp;</p>
<p>因为Func默认地被处理为__cdecl，而show是__stdcall的，所以当通过函数指针my_func时，就导致了以上对话框的出现。但是当p指向show2时，又不会出错，这是因为show2没有参数，不同的调用约定不影响这个规则。<br><br></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><strong style="mso-bidi-font-weight: normal"><span lang=EN-US>6.</span></strong><strong style="mso-bidi-font-weight: normal"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常相关：默认终止程序</span><span lang=EN-US><o:p></o:p></span></strong></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当我们使用</span><span lang=EN-US>C++</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">库时，因为库本身可能会抛出</span><span lang=EN-US>C++</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常，如果你不捕获这个异常，那么</span><span lang=EN-US>C++</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">默认就会调用</span><span lang=EN-US>abort</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（或者</span><span lang=EN-US>exit</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）函数终止程序。例如：</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p>&nbsp;</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;test()<br><img id=Codehighlighter1_12_61_Open_Image onclick="this.style.display='none'; Codehighlighter1_12_61_Open_Text.style.display='none'; Codehighlighter1_12_61_Closed_Image.style.display='inline'; Codehighlighter1_12_61_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_12_61_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_12_61_Closed_Text.style.display='none'; Codehighlighter1_12_61_Open_Image.style.display='inline'; Codehighlighter1_12_61_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_12_61_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_12_61_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">throw</span><span style="COLOR: #000000">&nbsp;std::exception(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">some&nbsp;exceptions</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"></o:p></span>&nbsp;</p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当你调用</span><span lang=EN-US>test</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数时，如果不</span><span lang=EN-US>catch</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这个异常，开调试器就会得到类似的错误对话框：</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p><img height=199 alt="" src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/exception.jpg" width=443 border=0>&nbsp;</o:p></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而如果不开调试器，则会得到：</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p>&nbsp;<img height=232 alt="" src="http://www.cppblog.com/images/cppblog_com/kevinlynx/WindowsLiveWriter/VC_BA3E/abort.jpg" width=439 border=0></o:p></span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当你看到类似于&#8220;</span><span lang=EN-US>This application has requested the Runtime to terminate it&#8230;&#8221;</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之类的字眼时，那就表明程序调用了</span><span lang=EN-US>abort</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（或</span><span lang=EN-US>exit</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）函数，导致程序异常终止。其实这个错误只要开调试器，一般可以准确定位错误的发生点。</span></p>
<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><span lang=EN-US><o:p>&nbsp;</o:p></span></p>
<p>&#160;</p>
<img src ="http://www.cppblog.com/kevinlynx/aggbug/47998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kevinlynx/" target="_blank">Kevin Lynx</a> 2008-04-24 13:43 <a href="http://www.cppblog.com/kevinlynx/archive/2008/04/24/47998.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TCP/IP Concepts 1</title><link>http://www.cppblog.com/kevinlynx/archive/2008/04/18/47471.html</link><dc:creator>Kevin Lynx</dc:creator><author>Kevin Lynx</author><pubDate>Fri, 18 Apr 2008 02:02:00 GMT</pubDate><guid>http://www.cppblog.com/kevinlynx/archive/2008/04/18/47471.html</guid><wfw:comment>http://www.cppblog.com/kevinlynx/comments/47471.html</wfw:comment><comments>http://www.cppblog.com/kevinlynx/archive/2008/04/18/47471.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/kevinlynx/comments/commentRss/47471.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kevinlynx/services/trackbacks/47471.html</trackback:ping><description><![CDATA[<p><br><font style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #ffffff">最近在草草地看&lt;TCP/IP详解&gt;TCP那一部分，之所以草草地看是因为觉得早晚一天会回过头去细看。手头上<br>有工作要做，所以先草草地把之前随便摘抄的TCP/IP相关概念贴出来：<br><br>继续草草地贴:<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------<br>TCP segment:<br>Thus, we have simply &#8220;passed the buck&#8221; to TCP, which must take the stream from the application <br>and divide it into discrete messages for IP. These messages are called TCP segments.</font></p>
<p><font style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #ffffff">On regular intervals, it forms segments to be transmitted using IP. The size of the segment is <br>controlled by two primary factors. The first issue is that there is an overall limit to the size <br>of a segment, chosen to prevent unnecessary fragmentation at the IP layer. This is governed by a <br>parameter called the maximum segment size (MSS), which is determined during connection establishment. <br>The second is that TCP is designed so that once a connection is set up, each of the devices tells the <br>other how much data it is ready to accept at any given time. If this is lower than the MSS value, a <br>smaller segment must be sent. This is part of the sliding window system described in the next topic.</font></p>
<p><font style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #ffffff">Since TCP works with individual bytes of data rather than discrete messages, it must use an <br>identification scheme that works at the byte level to implement its data transmission and tracking <br>system. This is accomplished by assigning each byte TCP processes a sequence number.</font></p>
<p><font style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #ffffff"><br>Since applications send data to TCP as a stream of bytes and not prepackaged messages, each <br>application must use its own scheme to determine where one application data element ends and the <br>next begins.<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------<br></p>
<p>TCP MSS:<br><a href="http://www.tcpipguide.com/free/t_TCPMaximumSegmentSizeMSSandRelationshiptoIPDatagra.htm">http://www.tcpipguide.com/free/t_TCPMaximumSegmentSizeMSSandRelationshiptoIPDatagra.htm</a></p>
<p>In addition to the dictates of the current window size, each TCP device also has associated <br>with it a ceiling on TCP size—a segment size that will never be exceeded regardless of how<br>&nbsp;large the current window is. This is called the maximum segment size (MSS). When deciding <br>how much data to put into a segment, each device in the TCP connection will choose the amount<br>&nbsp;based on the current window size, in conjunction with the various algorithms described in <br>the reliability section, but it will never be so large that the amount of data exceeds the<br>&nbsp;MSS of the device to which it is sending. </p>
<p><br>Note: I need to point out that the name &#8220;maximum segment size&#8221; is in fact misleading. The<br>&nbsp;value actually refers to the maximum amount of data that a segment can hold—it does not <br>include the TCP headers. So if the MSS is 100, the actual maximum segment size could be 120 <br>(for a regular TCP header) or larger (if the segment includes TCP options). </p>
<p>This was computed by starting with the minimum MTU for IP networks of 576. </p>
<p>Devices can indicate that they wish to use a different MSS value from the default by including <br>a Maximum Segment Size option in the SYN message they use to establish a connection. Each <br>device in the connection may use a different MSS value.<br><br>--------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>delayed ACK algorithm<br><br><a href="http://tangentsoft.net/wskfaq/intermediate.html#delayed-ack">http://tangentsoft.net/wskfaq/intermediate.html#delayed-ack</a></p>
<p>In a simpleminded implementation of TCP, every data packet that comes in is immediately acknowledged<br>&nbsp;with an ACK packet. (ACKs help to provide the reliability TCP promises.)</p>
<p>In modern stacks, ACKs are delayed for a short time (up to 200ms, typically) for three reasons: a) <br>to avoid the silly window syndrome; b) to allow ACKs to piggyback on a reply frame if one is ready <br>to go when the stack decides to do the ACK; and c) to allow the stack to send one ACK for several <br>frames, if those frames arrive within the delay period.</p>
<p>The stack is only allowed to delay ACKs for up to 2 frames of data.</p>
<p><br>&nbsp;</p>
<p>--------------------------------------------------------------------------------------------------------------------------------------------------------<br>Nagle algorithm:</p>
<p>Nagle's algorithm, named after John Nagle, is a means of improving the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network.</p>
<p>Nagle's document, Congestion Control in IP/TCP Internetworks (RFC896) describes what he called the 'small packet problem', where an application repeatedly emits data in small chunks, frequently only 1 byte in size. Since TCP packets have a 40 byte header (20 bytes for TCP, 20 bytes for IPv4), this results in a 41 byte packet for 1 byte of useful information, a huge overhead. This situation often occurs in Telnet sessions, where most keypresses generate a single byte of data which is transmitted immediately. Worse, over slow links, many such packets can be in transit at the same time, potentially leading to congestion collapse.</p>
<p>Nagle's algorithm works by coalescing a number of small outgoing messages, and sending them all at once. Specifically, as long as there is a sent packet for which the sender has received no acknowledgment, the sender should keep buffering its output until it has a full packet's worth of output, so that output can be sent all at once.</p>
<p><br>[edit] Algorithm<br>if there is new data to send<br>&nbsp; if the window size &gt;= MSS and available data is &gt;= MSS<br>&nbsp;&nbsp;&nbsp; send complete MSS segment now<br>&nbsp; else<br>&nbsp;&nbsp;&nbsp; if there is unconfirmed data still in the pipe<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enqueue data in the buffer until an acknowledge is received<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; send data immediately<br>&nbsp;&nbsp;&nbsp; end if<br>&nbsp; end if<br>end if<br>where MSS = Maximum segment size</p>
<p>This algorithm interacts badly with TCP delayed acknowledgments, a feature introduced into TCP at roughly the same time in the early 1980s, but by a different group. With both algorithms enabled, applications which do two successive writes to a TCP connection, followed by a read, experience a constant delay of up to 500 milliseconds, the "ACK delay". For this reason, TCP implementations usually provide applications with an interface to disable the Nagle algorithm. This is typically called the TCP_NODELAY option. The first major application to run into this problem was the X Window System.</p>
<p>The tinygram problem and silly window syndrome are sometimes confused. The tinygram problem occurs when the window is almost empty. Silly window syndrome occurs when the window is almost full</p>
<p>===================================================================================================================================<br>3.17 - What is the Nagle algorithm?<br>The Nagle algorithm is an optimization to TCP that makes the stack wait until all data is acknowledged on the connection before it sends more data. The exception is that Nagle will not cause the stack to wait for an ACK if it has enough enqueued data that it can fill a network frame. (Without this exception, the Nagle algorithm would effectively disable TCP's sliding window algorithm.) For a full description of the Nagle algorithm, see RFC 896.</p>
<p>So, you ask, what's the purpose of the Nagle algorithm?</p>
<p>The ideal case in networking is that each program always sends a full frame of data with each call to send(). That maximizes the percentage of useful program data in a packet.</p>
<p>The basic TCP and IPv4 headers are 20 bytes each. The worst case protocol overhead percentage, therefore, is 40/41, or 98%. Since the maximum amount of data in an Ethernet frame is 1500 bytes, the best case protocol overhead percentage is 40/1500, less than 3%.</p>
<p>While the Nagle algorithm is causing the stack to wait for data to be ACKed by the remote peer, the local program can make more calls to send(). Because TCP is a stream protocol, it can coalesce the data in those send() calls into a single TCP packet, increasing the percentage of useful data.</p>
<p>Imagine a simple Telnet program: the bulk of a Telnet conversation consists of sending one character, and receiving an echo of that character back from the remote host. Without the Nagle algorithm, this results in TCP's worst case: one byte of user data wrapped in dozens of bytes of protocol overhead. With the Nagle algorithm enabled, the TCP stack won't send that one Telnet character out until the previous characters have all been acknowledged. By then, the user may well have typed another character or two, reducing the relative protocol overhead.</p>
<p>This simple optimization interacts with other features of the TCP protocol suite, too:</p>
<p>Most stacks implement the delayed ACK algorithm: this causes the remote stack to delay ACKs under certain circumstances, which allows the local stack a bit of time to "Nagle" some more bytes into a single packet. </p>
<p>The Nagle algorithm tends to improve the percentage of useful data in packets more on slow networks than on fast networks, because ACKs take longer to come back. </p>
<p>TCP allows an ACK packet to also contain data. If the local stack decides it needs to send out an ACK packet and the Nagle algorithm has caused data to build up in the output buffer, the enqueued data will go out along with the ACK packet. <br>The Nagle algorithm is on by default in Winsock, but it can be turned off on a per-socket basis with the TCP_NODELAY option of setsockopt(). This option should not be turned off except in a very few situations.</p>
<p>Beware of depending on the Nagle algorithm too heavily. send() is a kernel function, so every call to send() takes much more time than for a regular function call. Your application should coalesce its own data as much as is practical to minimize the number of calls to send().</p>
<p><br>--------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>Sliding Window Acknowledgment System :<br><a href="http://www.tcpipguide.com/free/t_TCPSlidingWindowAcknowledgmentSystemForDataTranspo.htm">http://www.tcpipguide.com/free/t_TCPSlidingWindowAcknowledgmentSystemForDataTranspo.htm</a><br>--------------------------------------------------------------------------------------------<br>A basic technique for ensuring reliability in communications uses a rule that requires a <br>device to send back an acknowledgment each time it successfully receives a transmission. <br>If a transmission is not acknowledged after a period of time, it is retransmitted by its <br>sender. This system is called positive acknowledgment with retransmission (PAR). One<br>&nbsp;drawback with this basic scheme is that the transmitter cannot send a second message <br>until the first has been acknowledged.<br>--------------------------------------------------------------------------------------------</p>
<p><a href="http://www.ssfnet.org/Exchange/tcp/tcpTutorialNotes.html">http://www.ssfnet.org/Exchange/tcp/tcpTutorialNotes.html</a></p>
<p>The sliding window serves several purposes:<br>(1) it guarantees the reliable delivery of data<br>(2) it ensures that the data is delivered in order,<br>(3) it enforces flow control between the sender and the receiver.</p>
<p><br><br><br>------------------to be continued<br></p>
</font>
<img src ="http://www.cppblog.com/kevinlynx/aggbug/47471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kevinlynx/" target="_blank">Kevin Lynx</a> 2008-04-18 10:02 <a href="http://www.cppblog.com/kevinlynx/archive/2008/04/18/47471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>探究CRC32算法实现原理-why table-driven implemention</title><link>http://www.cppblog.com/kevinlynx/archive/2008/04/01/45952.html</link><dc:creator>Kevin Lynx</dc:creator><author>Kevin Lynx</author><pubDate>Tue, 01 Apr 2008 13:22:00 GMT</pubDate><guid>http://www.cppblog.com/kevinlynx/archive/2008/04/01/45952.html</guid><wfw:comment>http://www.cppblog.com/kevinlynx/comments/45952.html</wfw:comment><comments>http://www.cppblog.com/kevinlynx/archive/2008/04/01/45952.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/kevinlynx/comments/commentRss/45952.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kevinlynx/services/trackbacks/45952.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 探究CRC32算法实现原理-why table-driven implementionAuthor : Kevin Lynxemail&nbsp; : zmhn320@163.comPreface基于不重造轮子的原则，本文尽量不涉及网络上遍地都是的资料。What's CRC ?简而言之，CRC是一个数值。该数值被用于校验数据的正确性。CRC数值简单地说就是通过让你需要做处理的数...&nbsp;&nbsp;<a href='http://www.cppblog.com/kevinlynx/archive/2008/04/01/45952.html'>阅读全文</a><img src ="http://www.cppblog.com/kevinlynx/aggbug/45952.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kevinlynx/" target="_blank">Kevin Lynx</a> 2008-04-01 21:22 <a href="http://www.cppblog.com/kevinlynx/archive/2008/04/01/45952.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用dbghelp获取调用堆栈--release下的调试方法学</title><link>http://www.cppblog.com/kevinlynx/archive/2008/03/28/45628.html</link><dc:creator>Kevin Lynx</dc:creator><author>Kevin Lynx</author><pubDate>Fri, 28 Mar 2008 08:37:00 GMT</pubDate><guid>http://www.cppblog.com/kevinlynx/archive/2008/03/28/45628.html</guid><wfw:comment>http://www.cppblog.com/kevinlynx/comments/45628.html</wfw:comment><comments>http://www.cppblog.com/kevinlynx/archive/2008/03/28/45628.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.cppblog.com/kevinlynx/comments/commentRss/45628.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kevinlynx/services/trackbacks/45628.html</trackback:ping><description><![CDATA[<p style="FONT-SIZE: 10pt">Author : Kevin Lynx</p>
<p style="FONT-SIZE: 10pt">当软件作为release模式被发布给用户时，当程序崩溃时我们很难去查找原因。常见的手法是输出LOG文件，根据LOG文件分析<br>程序崩溃时的运行情况。我们可以通过SEH来捕获程序错误，然后输出一些有用的信息作为我们分析错误的资料。一般我们需要<br>输出的信息包括：系统信息、CPU寄存器信息、堆栈信息、调用堆栈等。而调用堆栈则是最有用的部分，它可以直接帮我们定位<br>到程序崩溃时所处的位置(在何处崩溃)。(codeproject上关于这个专题的常见开场白 = =#)</p>
<p style="FONT-SIZE: 10pt">要获取call stack(所谓的调用堆栈)，就需要查看(unwind)stack的内容。We could conceivably attempt to unwind the <br>stack ourselves using inline assembly. But stack frames can be organized in different ways, depending on compiler <br>optimizations and calling conventions, so it could become complicated to do it that way.(摘自vld文档)要获取栈的<br>内容，我们可以自己使用内联汇编获取，但是考虑到兼容性，内联汇编并不是一个好的解决方案。我们可以使用微软的dbghelp<br>中的StackWalk64来获取栈的内容。</p>
<p style="FONT-SIZE: 10pt">StackWalk64声明如下：<br>BOOL StackWalk64(<br>&nbsp; DWORD MachineType,<br>&nbsp; HANDLE hProcess,<br>&nbsp; HANDLE hThread,<br>&nbsp; LPSTACKFRAME64 StackFrame,<br>&nbsp; PVOID ContextRecord,<br>&nbsp; PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,<br>&nbsp; PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,<br>&nbsp; PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,<br>&nbsp; PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress<br>);</p>
<p style="FONT-SIZE: 10pt">具体每个参数的含义可以参见MSDN。这里说下ContextRecord参数，该参数指定了CPU各个寄存器的内容。StackFrame指定了stack <br>frame的内容。stack frame是什么，我也不知道。(= =) StackWalk64函数需要用户指定当前frame的地址，以及当前程序的指令<br>地址。这两个信息都被填充进ContextRecord，然后传进StackWalk64函数。</p>
<p style="FONT-SIZE: 10pt">那么如何获取当前的stack frame地址和当前程序指令地址呢？如前所说，你可以使用内联汇编。(对于程序指令地址，因为要获取<br>EIP寄存器的内容，而该寄存器不能被软件访问)也可以使用GetThreadContext一次性获取当前线程当前运行情况下的CPU各个寄存器<br>内容。补充下，当前frame地址被放在EBP寄存器里，当前程序指令地址放在EIP寄存器里。但是，如同MSDN对GetThreadContext函数<br>的说明一样，该函数可能获取到错误的寄存器内容(You cannot get a valid context for a running thread)。</p>
<p style="FONT-SIZE: 10pt">另一种获取Context(包含EBP and EIP)的方法就是使用SEH(结构化异常处理)，在__except中使用GetExceptionInformation获取。</p>
<p style="FONT-SIZE: 10pt">GetExceptionInformation 传回一个LPEXCEPTION_POINTERS指针，该指针指向一个EXCEPTION_POINTERS结构，该结构里包含一个<br>Context的指针，即达到目标，可以使用StackWalk函数。</p>
<p style="FONT-SIZE: 10pt">补充一下，你可以直接使用StackWalk函数，StackWalk被define为StackWalk64(windows平台相关)。</p>
<p style="FONT-SIZE: 10pt">unwind栈后，可以进一步获取一个stack frame的内容，例如函数名。这里涉及到SymFromAddr函数，该函数可以根据一个地址返回<br>符号名(函数名)。还有一个有意思的函数：SymGetLineFromAddr，可以获取函数对应的源代码的文件名和行号。</p>
<p style="FONT-SIZE: 10pt">当然，这一切都依赖于VC产生的程序数据库文件(pdb)，以及提供以上API函数的dbghelp.dll。</p>
<p style="FONT-SIZE: 10pt">参考一段简单的代码：<br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img id=Codehighlighter1_0_11_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_11_Open_Text.style.display='none'; Codehighlighter1_0_11_Closed_Image.style.display='inline'; Codehighlighter1_0_11_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_0_11_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_11_Closed_Text.style.display='none'; Codehighlighter1_0_11_Open_Image.style.display='inline'; Codehighlighter1_0_11_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><span id=Codehighlighter1_0_11_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id=Codehighlighter1_0_11_Open_Text><span style="COLOR: #808080">///</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #808080">///</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></span><span style="COLOR: #808080">///</span></span><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">windows.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">dbghelp.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#pragma&nbsp;comment(&nbsp;lib,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">dbghelp.lib</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;dump_callstack(&nbsp;CONTEXT&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">context&nbsp;)<br><img id=Codehighlighter1_153_1506_Open_Image onclick="this.style.display='none'; Codehighlighter1_153_1506_Open_Text.style.display='none'; Codehighlighter1_153_1506_Closed_Image.style.display='inline'; Codehighlighter1_153_1506_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_153_1506_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_153_1506_Closed_Text.style.display='none'; Codehighlighter1_153_1506_Open_Image.style.display='inline'; Codehighlighter1_153_1506_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_153_1506_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_153_1506_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;STACKFRAME&nbsp;sf;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;memset(&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">sf,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(&nbsp;STACKFRAME&nbsp;)&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrPC.Offset&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;context</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Eip;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrPC.Mode&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;AddrModeFlat;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrStack.Offset&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;context</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Esp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrStack.Mode&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;AddrModeFlat;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrFrame.Offset&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;context</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Ebp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;sf.AddrFrame.Mode&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;AddrModeFlat;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;DWORD&nbsp;machineType&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;IMAGE_FILE_MACHINE_I386;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;HANDLE&nbsp;hProcess&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;GetCurrentProcess();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;HANDLE&nbsp;hThread&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;GetCurrentThread();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(&nbsp;;&nbsp;;&nbsp;)<br><img id=Codehighlighter1_563_1504_Open_Image onclick="this.style.display='none'; Codehighlighter1_563_1504_Open_Text.style.display='none'; Codehighlighter1_563_1504_Closed_Image.style.display='inline'; Codehighlighter1_563_1504_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_563_1504_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_563_1504_Closed_Text.style.display='none'; Codehighlighter1_563_1504_Open_Image.style.display='inline'; Codehighlighter1_563_1504_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_563_1504_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_563_1504_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">StackWalk(machineType,&nbsp;hProcess,&nbsp;hThread,&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">sf,&nbsp;context,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,&nbsp;SymFunctionTableAccess,&nbsp;SymGetModuleBase,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&nbsp;)&nbsp;)<br><img id=Codehighlighter1_681_695_Open_Image onclick="this.style.display='none'; Codehighlighter1_681_695_Open_Text.style.display='none'; Codehighlighter1_681_695_Closed_Image.style.display='inline'; Codehighlighter1_681_695_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_681_695_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_681_695_Closed_Text.style.display='none'; Codehighlighter1_681_695_Open_Image.style.display='inline'; Codehighlighter1_681_695_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_681_695_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_681_695_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;sf.AddrFrame.Offset&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">&nbsp;)<br><img id=Codehighlighter1_733_747_Open_Image onclick="this.style.display='none'; Codehighlighter1_733_747_Open_Text.style.display='none'; Codehighlighter1_733_747_Closed_Image.style.display='inline'; Codehighlighter1_733_747_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_733_747_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_733_747_Closed_Text.style.display='none'; Codehighlighter1_733_747_Open_Image.style.display='inline'; Codehighlighter1_733_747_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_733_747_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_733_747_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;BYTE&nbsp;symbolBuffer[&nbsp;</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(&nbsp;SYMBOL_INFO&nbsp;)&nbsp;</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">&nbsp;];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;PSYMBOL_INFO&nbsp;pSymbol&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;(&nbsp;PSYMBOL_INFO&nbsp;)&nbsp;symbolBuffer;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;pSymbol</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">SizeOfStruct&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(&nbsp;symbolBuffer&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;pSymbol</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">MaxNameLen&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;DWORD64&nbsp;symDisplacement&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;SymFromAddr(&nbsp;hProcess,&nbsp;sf.AddrPC.Offset,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,&nbsp;pSymbol&nbsp;)&nbsp;)<br><img id=Codehighlighter1_1036_1088_Open_Image onclick="this.style.display='none'; Codehighlighter1_1036_1088_Open_Text.style.display='none'; Codehighlighter1_1036_1088_Closed_Image.style.display='inline'; Codehighlighter1_1036_1088_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1036_1088_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1036_1088_Closed_Text.style.display='none'; Codehighlighter1_1036_1088_Open_Image.style.display='inline'; Codehighlighter1_1036_1088_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_1036_1088_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1036_1088_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Function&nbsp;:&nbsp;%s\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;pSymbol</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Name&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_1099_1141_Open_Image onclick="this.style.display='none'; Codehighlighter1_1099_1141_Open_Text.style.display='none'; Codehighlighter1_1099_1141_Closed_Image.style.display='inline'; Codehighlighter1_1099_1141_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1099_1141_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1099_1141_Closed_Text.style.display='none'; Codehighlighter1_1099_1141_Open_Image.style.display='inline'; Codehighlighter1_1099_1141_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_1099_1141_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1099_1141_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">SymFromAdd&nbsp;failed!\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img id=Codehighlighter1_1171_1195_Open_Image onclick="this.style.display='none'; Codehighlighter1_1171_1195_Open_Text.style.display='none'; Codehighlighter1_1171_1195_Closed_Image.style.display='inline'; Codehighlighter1_1171_1195_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1171_1195_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1171_1195_Closed_Text.style.display='none'; Codehighlighter1_1171_1195_Open_Image.style.display='inline'; Codehighlighter1_1171_1195_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;IMAGEHLP_LINE&nbsp;lineInfo&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span id=Codehighlighter1_1171_1195_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1171_1195_Open_Text><span style="COLOR: #000000">{&nbsp;</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(IMAGEHLP_LINE)&nbsp;}</span></span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;DWORD&nbsp;dwLineDisplacement;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;SymGetLineFromAddr(&nbsp;hProcess,&nbsp;sf.AddrPC.Offset,&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">dwLineDisplacement,&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">lineInfo&nbsp;)&nbsp;)<br><img id=Codehighlighter1_1318_1440_Open_Image onclick="this.style.display='none'; Codehighlighter1_1318_1440_Open_Text.style.display='none'; Codehighlighter1_1318_1440_Closed_Image.style.display='inline'; Codehighlighter1_1318_1440_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1318_1440_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1318_1440_Closed_Text.style.display='none'; Codehighlighter1_1318_1440_Open_Image.style.display='inline'; Codehighlighter1_1318_1440_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_1318_1440_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1318_1440_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">[Source&nbsp;File&nbsp;:&nbsp;%s]\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;lineInfo.FileName&nbsp;);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">[Source&nbsp;Line&nbsp;:&nbsp;%u]\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;lineInfo.LineNumber&nbsp;);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_1451_1501_Open_Image onclick="this.style.display='none'; Codehighlighter1_1451_1501_Open_Text.style.display='none'; Codehighlighter1_1451_1501_Closed_Image.style.display='inline'; Codehighlighter1_1451_1501_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1451_1501_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1451_1501_Closed_Text.style.display='none'; Codehighlighter1_1451_1501_Open_Image.style.display='inline'; Codehighlighter1_1451_1501_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_1451_1501_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1451_1501_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">SymGetLineFromAddr&nbsp;failed!\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>DWORD&nbsp;excep_filter(&nbsp;LPEXCEPTION_POINTERS&nbsp;lpEP&nbsp;)<br><img id=Codehighlighter1_1557_1841_Open_Image onclick="this.style.display='none'; Codehighlighter1_1557_1841_Open_Text.style.display='none'; Codehighlighter1_1557_1841_Closed_Image.style.display='inline'; Codehighlighter1_1557_1841_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1557_1841_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1557_1841_Closed_Text.style.display='none'; Codehighlighter1_1557_1841_Open_Image.style.display='inline'; Codehighlighter1_1557_1841_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1557_1841_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1557_1841_Open_Text><span style="COLOR: #000000">{<br><img id=Codehighlighter1_1560_1580_Open_Image onclick="this.style.display='none'; Codehighlighter1_1560_1580_Open_Text.style.display='none'; Codehighlighter1_1560_1580_Closed_Image.style.display='inline'; Codehighlighter1_1560_1580_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1560_1580_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1560_1580_Closed_Text.style.display='none'; Codehighlighter1_1560_1580_Open_Image.style.display='inline'; Codehighlighter1_1560_1580_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_1560_1580_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id=Codehighlighter1_1560_1580_Open_Text><span style="COLOR: #808080">///</span><span style="COLOR: #008000">&nbsp;init&nbsp;dbghelp.dll</span><span style="COLOR: #808080"></span></span><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;SymInitialize(&nbsp;GetCurrentProcess(),&nbsp;NULL,&nbsp;TRUE&nbsp;)&nbsp;)<br><img id=Codehighlighter1_1638_1676_Open_Image onclick="this.style.display='none'; Codehighlighter1_1638_1676_Open_Text.style.display='none'; Codehighlighter1_1638_1676_Closed_Image.style.display='inline'; Codehighlighter1_1638_1676_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1638_1676_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1638_1676_Closed_Text.style.display='none'; Codehighlighter1_1638_1676_Open_Image.style.display='inline'; Codehighlighter1_1638_1676_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_1638_1676_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1638_1676_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Init&nbsp;dbghelp&nbsp;ok.\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;dump_callstack(&nbsp;lpEP</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">ContextRecord&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(&nbsp;SymCleanup(&nbsp;GetCurrentProcess()&nbsp;)&nbsp;)<br><img id=Codehighlighter1_1762_1803_Open_Image onclick="this.style.display='none'; Codehighlighter1_1762_1803_Open_Text.style.display='none'; Codehighlighter1_1762_1803_Closed_Image.style.display='inline'; Codehighlighter1_1762_1803_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1762_1803_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1762_1803_Closed_Text.style.display='none'; Codehighlighter1_1762_1803_Open_Image.style.display='inline'; Codehighlighter1_1762_1803_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_1762_1803_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1762_1803_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Cleanup&nbsp;dbghelp&nbsp;ok.\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;EXCEPTION_EXECUTE_HANDLER;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;func1(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;)<br><img id=Codehighlighter1_1864_1888_Open_Image onclick="this.style.display='none'; Codehighlighter1_1864_1888_Open_Text.style.display='none'; Codehighlighter1_1864_1888_Closed_Image.style.display='inline'; Codehighlighter1_1864_1888_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1864_1888_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1864_1888_Closed_Text.style.display='none'; Codehighlighter1_1864_1888_Open_Image.style.display='inline'; Codehighlighter1_1864_1888_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1864_1888_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1864_1888_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;i;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;func2(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;)<br><img id=Codehighlighter1_1911_1930_Open_Image onclick="this.style.display='none'; Codehighlighter1_1911_1930_Open_Text.style.display='none'; Codehighlighter1_1911_1930_Closed_Image.style.display='inline'; Codehighlighter1_1911_1930_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1911_1930_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1911_1930_Closed_Text.style.display='none'; Codehighlighter1_1911_1930_Open_Image.style.display='inline'; Codehighlighter1_1911_1930_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1911_1930_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1911_1930_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;func1(&nbsp;i&nbsp;</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;func3(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;)<br><img id=Codehighlighter1_1953_1972_Open_Image onclick="this.style.display='none'; Codehighlighter1_1953_1972_Open_Text.style.display='none'; Codehighlighter1_1953_1972_Closed_Image.style.display='inline'; Codehighlighter1_1953_1972_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1953_1972_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1953_1972_Closed_Text.style.display='none'; Codehighlighter1_1953_1972_Open_Image.style.display='inline'; Codehighlighter1_1953_1972_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1953_1972_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1953_1972_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;func2(&nbsp;i&nbsp;</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;test(&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i&nbsp;)<br><img id=Codehighlighter1_1994_2013_Open_Image onclick="this.style.display='none'; Codehighlighter1_1994_2013_Open_Text.style.display='none'; Codehighlighter1_1994_2013_Closed_Image.style.display='inline'; Codehighlighter1_1994_2013_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1994_2013_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1994_2013_Closed_Text.style.display='none'; Codehighlighter1_1994_2013_Open_Image.style.display='inline'; Codehighlighter1_1994_2013_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1994_2013_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1994_2013_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;func3(&nbsp;i&nbsp;</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()<br><img id=Codehighlighter1_2027_2171_Open_Image onclick="this.style.display='none'; Codehighlighter1_2027_2171_Open_Text.style.display='none'; Codehighlighter1_2027_2171_Closed_Image.style.display='inline'; Codehighlighter1_2027_2171_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_2027_2171_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2027_2171_Closed_Text.style.display='none'; Codehighlighter1_2027_2171_Open_Image.style.display='inline'; Codehighlighter1_2027_2171_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_2027_2171_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_2027_2171_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;__try<br><img id=Codehighlighter1_2037_2054_Open_Image onclick="this.style.display='none'; Codehighlighter1_2037_2054_Open_Text.style.display='none'; Codehighlighter1_2037_2054_Closed_Image.style.display='inline'; Codehighlighter1_2037_2054_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_2037_2054_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2037_2054_Closed_Text.style.display='none'; Codehighlighter1_2037_2054_Open_Image.style.display='inline'; Codehighlighter1_2037_2054_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_2037_2054_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_2037_2054_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;test(&nbsp;</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;__except(&nbsp;excep_filter(&nbsp;GetExceptionInformation()&nbsp;)&nbsp;)<br><img id=Codehighlighter1_2112_2157_Open_Image onclick="this.style.display='none'; Codehighlighter1_2112_2157_Open_Text.style.display='none'; Codehighlighter1_2112_2157_Closed_Image.style.display='inline'; Codehighlighter1_2112_2157_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_2112_2157_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2112_2157_Closed_Text.style.display='none'; Codehighlighter1_2112_2157_Open_Image.style.display='inline'; Codehighlighter1_2112_2157_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_2112_2157_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_2112_2157_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;printf(&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Some&nbsp;exception&nbsp;occures.\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<p style="FONT-SIZE: 10pt"><br>以上代码在release模式下需要关掉优化，否则调用堆栈显示不正确(某些函数被去掉了?)，同时需要pdb文件。<br></p>
<font style="BACKGROUND-COLOR: #ffffff" size=2>参考资料：<br><a href="http://www.codeproject.com/KB/threads/StackWalker.aspx">http://www.codeproject.com/KB/threads/StackWalker.aspx</a><br><a href="http://www.cnblogs.com/protalfox/articles/84723.html">http://www.cnblogs.com/protalfox/articles/84723.html</a><br><a href="http://www.codeproject.com/KB/debug/XCrashReportPt1.aspx">http://www.codeproject.com/KB/debug/XCrashReportPt1.aspx</a><br><a href="http://www.codeproject.com/KB/applications/visualleakdetector.aspx">http://www.codeproject.com/KB/applications/visualleakdetector.aspx</a><br><br>ps,本文技术浅尝辄止，部分内容是否完全准确(正确)我个人都持保留态度，仅供参考。:D<br></font>
<img src ="http://www.cppblog.com/kevinlynx/aggbug/45628.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kevinlynx/" target="_blank">Kevin Lynx</a> 2008-03-28 16:37 <a href="http://www.cppblog.com/kevinlynx/archive/2008/03/28/45628.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>