﻿<?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++博客-Xin's Blog</title><link>http://www.cppblog.com/Xin0101/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 08 Apr 2026 21:05:04 GMT</lastBuildDate><pubDate>Wed, 08 Apr 2026 21:05:04 GMT</pubDate><ttl>60</ttl><item><title>VAX 快捷键</title><link>http://www.cppblog.com/Xin0101/archive/2011/08/13/153279.html</link><dc:creator>阿鑫</dc:creator><author>阿鑫</author><pubDate>Sat, 13 Aug 2011 08:19:00 GMT</pubDate><guid>http://www.cppblog.com/Xin0101/archive/2011/08/13/153279.html</guid><wfw:comment>http://www.cppblog.com/Xin0101/comments/153279.html</wfw:comment><comments>http://www.cppblog.com/Xin0101/archive/2011/08/13/153279.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Xin0101/comments/commentRss/153279.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Xin0101/services/trackbacks/153279.html</trackback:ping><description><![CDATA[<div><span style="color: #8b8b83; font-family: Arial; font-size: 12px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; line-height: normal; ">Alt + G： 在定义与声明之间互跳<br /><div>Alt + Shift + F：光标放到某个字符串上，按下此键，会找出所有引用了这个字符串的地方<br /><div>Alt + Shift + O：定位文件。项目文件太多时，这个会帮上大忙，当然，你的文件名命名最好有个比较好的规范<br /><div>Alt + Shift + S：方便你寻找某个对象或变量等等<br /><div>Alt + Shift + R：当想改掉一个类名或是其他东西的命名时，可能已经有很多地方引用这个名称了，这时按下此快捷键，可以很方便的辅助你重命名<br />&nbsp;</div></div></div></div></span></div><img src ="http://www.cppblog.com/Xin0101/aggbug/153279.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Xin0101/" target="_blank">阿鑫</a> 2011-08-13 16:19 <a href="http://www.cppblog.com/Xin0101/archive/2011/08/13/153279.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>通过软件出错的提示码找出代码出错处</title><link>http://www.cppblog.com/Xin0101/archive/2010/08/11/123117.html</link><dc:creator>阿鑫</dc:creator><author>阿鑫</author><pubDate>Wed, 11 Aug 2010 14:43:00 GMT</pubDate><guid>http://www.cppblog.com/Xin0101/archive/2010/08/11/123117.html</guid><wfw:comment>http://www.cppblog.com/Xin0101/comments/123117.html</wfw:comment><comments>http://www.cppblog.com/Xin0101/archive/2010/08/11/123117.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Xin0101/comments/commentRss/123117.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Xin0101/services/trackbacks/123117.html</trackback:ping><description><![CDATA[

<p class="MsoNormal"><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">首先配置<span lang="EN-US">vc2005</span>生成<span lang="EN-US">map</span>文件和<span lang="EN-US">cod</span>文件：<span lang="EN-US"><o:p></o:p></span></span></p>

<span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-ascii-theme-font:
minor-fareast;mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Arial;color:#383838;mso-ansi-language:EN-US;mso-fareast-language:
ZH-CN;mso-bidi-language:AR-SA"><br>
(1).map</span><span style="font-size:10.5pt;font-family:宋体;mso-ascii-theme-font:
minor-fareast;mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Arial;color:#383838;mso-ansi-language:EN-US;mso-fareast-language:
ZH-CN;mso-bidi-language:AR-SA">文件<span lang="EN-US">:property-&gt;Configuration
Properties-&gt;Linker-&gt;Debugging </span>中的<span lang="EN-US">Generate Map File</span>选择<span lang="EN-US">Yes(/MAP);<br>
<br>
(2).cod</span>文件<span lang="EN-US">:property-&gt;Configuration
Properties-&gt;C/C++-&gt;output Files</span>中<span lang="EN-US">Assembler OutPut</span>中选择<span lang="EN-US">Assembly,Maching Code and Source(/FAcs),</span>生成机器，源代码。<span lang="EN-US"><br style="mso-special-character:line-break">
<p class="MsoNormal"><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">上面所说的<span lang="EN-US"> property </span>是<span lang="EN-US">&#8220;</span>项目<span lang="EN-US">&#8221;</span>菜单下的<span lang="EN-US"> property</span>，而非<span lang="EN-US">&#8220;</span>工具<span lang="EN-US">&#8221;</span>菜单下的<span lang="EN-US"> property</span>。<span lang="EN-US"><o:p></o:p></span></span></p>

<p class="MsoNormal" align="left" style="text-align:left;line-height:15.05pt;
mso-pagination:widow-orphan"><span lang="EN-US" style="font-size:9.0pt;
mso-bidi-font-size:11.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#383838;
mso-font-kerning:0pt"><o:p>&nbsp;</o:p></span>例子<span lang="EN-US">:</span></p><p class="MsoNormal" align="left" style="text-align:left;line-height:15.05pt;
mso-pagination:widow-orphan"></p><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080; ">&nbsp;1</span>&nbsp;<span style="color: #000000; ">#include&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">stdafx.h</span><span style="color: #000000; ">"</span><span style="color: #000000; "><br></span><span style="color: #008080; ">&nbsp;2</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">&nbsp;errorFun(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;p)<br></span><span style="color: #008080; ">&nbsp;3</span>&nbsp;<span style="color: #000000; ">{<br></span><span style="color: #008080; ">&nbsp;4</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">p</span><span style="color: #000000; ">=</span><span style="color: #000000; ">1</span><span style="color: #000000; ">;<br></span><span style="color: #008080; ">&nbsp;5</span>&nbsp;<span style="color: #000000; ">}<br></span><span style="color: #008080; ">&nbsp;6</span>&nbsp;<span style="color: #000000; "></span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;_tmain(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;argc,&nbsp;_TCHAR</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;argv[])<br></span><span style="color: #008080; ">&nbsp;7</span>&nbsp;<span style="color: #000000; ">{<br></span><span style="color: #008080; ">&nbsp;8</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">*</span><span style="color: #000000; ">&nbsp;p</span><span style="color: #000000; ">=</span><span style="color: #000000; ">NULL;<br></span><span style="color: #008080; ">&nbsp;9</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorFun(p);<br></span><span style="color: #008080; ">10</span>&nbsp;<span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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></span><span style="color: #008080; ">11</span>&nbsp;<span style="color: #000000; ">}</span></div><br><p>&nbsp;</p>

<p class="MsoNormal"><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">在<span lang="EN-US">errorFun</span>中函数中，<span lang="EN-US">*p=1</span>这一行出错，由于<span lang="EN-US">p</span>没有申请空间，运行时出错<span lang="EN-US">,</span>弹出<span lang="EN-US"><br>
Unhandled exception at 0x004113b1 in testError.exe: 0xC0000005: Access
violation writing location 0x00000000.<br>
</span>在<span lang="EN-US">0x004113b1</span>程序发生崩溃。<span lang="EN-US"><o:p></o:p></span></span></p><p class="MsoNormal"><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt"></span></p><p class="MsoNormal"><strong><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">具体步骤：</span></strong><span lang="EN-US" style="mso-bidi-font-size:
10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;
color:#383838;mso-font-kerning:0pt"><br>
(1)debug</span><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">文件下打开<span lang="EN-US">map</span>文件，定位崩溃函数<span lang="EN-US">.<br>
<br>
map</span>文件开头是一些链接信息，然后我们要找函数和实始地址信息。地址是函始的开始地址<span lang="EN-US"><br>
<br>
Address</span>　　　　　　　<span lang="EN-US">Publics by Value</span>　　　　　　　<span lang="EN-US">Rva+Base</span>　　　　<span lang="EN-US">Lib:Object<br>
<br>
0000:00000000</span>　　　　<span lang="EN-US">___safe_se_handler_count</span>　　　<span lang="EN-US">00000000</span>　　　　<span lang="EN-US">&lt;absolute&gt;<br>
0000:00000000</span>　　　　<span lang="EN-US">___safe_se_handler_table</span>　　　<span lang="EN-US">00000000</span>　　　　<span lang="EN-US">&lt;absolute&gt;<br>
0000:00000000</span>　　　　<span lang="EN-US">___ImageBase</span>　　　　　　　　　<span lang="EN-US">00400000</span>　　　　<span lang="EN-US">&lt;linker-defined&gt;<br>
0001:00000000</span>　　　　<span lang="EN-US">__enc$textbss$begin</span>　　　　　<span lang="EN-US"> 00401000</span>　　 　　<span lang="EN-US">&lt;linker-defined&gt;<br>
0001:00010000</span>　　　　<span lang="EN-US">__enc$textbss$end</span>　　　　　 　<span lang="EN-US">00411000</span>　　 　　<span lang="EN-US">&lt;linker-defined&gt;<br>
0002:00000390</span>　　　　</span><span lang="EN-US" style="mso-bidi-font-size:10.5pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:red;
mso-font-kerning:0pt">?errorFun@@YAXPAH@Z</span><span style="mso-bidi-font-size:
10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;
color:red;mso-font-kerning:0pt">　　　<span lang="EN-US"> 00411390 f</span>　 　　<span lang="EN-US">testError.obj</span></span><span lang="EN-US" style="mso-bidi-font-size:
10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;
color:#383838;mso-font-kerning:0pt"><br>
0002:000003d0</span><span style="mso-bidi-font-size:10.5pt;font-family:宋体;
mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:#383838;
mso-font-kerning:0pt">　　　　<span lang="EN-US">_wmain</span>　　　　　　　　　　　　</span><span lang="EN-US" style="mso-bidi-font-size:10.5pt;font-family:宋体;mso-ascii-theme-font:
minor-fareast;mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Arial;color:red;mso-font-kerning:0pt">004113d0 f</span><span style="mso-bidi-font-size:10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Arial;color:#383838;mso-font-kerning:0pt">　　　　<span lang="EN-US">testError.obj<br>
0002:00000430</span>　　　　<span lang="EN-US">__RTC_InitBase</span>　　　　　　　　<span lang="EN-US">00411430 f</span>　　　<span lang="EN-US">MSVCRTD:init.obj<br>
0002:00000470</span>　　　　<span lang="EN-US">__RTC_Shutdown</span>　　　　　　　　<span lang="EN-US">00411470 f</span>　　　<span lang="EN-US">MSVCRTD:init.obj<br>
0002:00000490</span>　　　　<span lang="EN-US">__RTC_CheckEsp</span>　　　　　　　　<span lang="EN-US">00411490 f</span>　　　<span lang="EN-US">MSVCRTD:stack.obj<br>
0002:000004c0</span>　　　　<span lang="EN-US">@_RTC_CheckStackVars@8</span>　　　　<span lang="EN-US">004114c0 f</span>　　　<span lang="EN-US">MSVCRTD:stack.obj<br>
0002:00000540</span>　　　　<span lang="EN-US">@_RTC_AllocaHelper@12</span>　　 　　<span lang="EN-US">00411540 f</span>　 　　<span lang="EN-US">MSVCRTD:stack.obj<br>
<br>
....<br>
<br>
</span>程序崩溃地址<span lang="EN-US">0x004113b1,</span>我们找到第一个比这个地址大的<span lang="EN-US">004113d0,</span>前一个是<span lang="EN-US">00411390,</span>地址是函数的开始地址，所以发生的崩溃的的函数是<span lang="EN-US">errorFun,</span>这个函数的初始地址<span lang="EN-US">00411390.<br>
<br>
(2)</span>找出具体崩溃行号<span lang="EN-US">.<br>
<br>
</span>由<span lang="EN-US">(2)</span>可知，发生错误函数是<span lang="EN-US">errorFun,</span>在<span lang="EN-US">testError.obj</span>，打开<span lang="EN-US">testError.cod</span>文件，找到<span lang="EN-US">errorFun</span>函数生成的机器码<span lang="EN-US">.<br>
<br>
?errorFun@@YAXPAH@Z PROC&nbsp;&nbsp;&nbsp; ; errorFun, COMDAT<br>
<br>
; 7&nbsp;&nbsp;&nbsp; : {<br>
<br>
&nbsp; 00000 55&nbsp;&nbsp; push&nbsp; ebp<br>
&nbsp; 00001 8b ec&nbsp;&nbsp; mov&nbsp; ebp, esp<br>
&nbsp; 00003 81 ec c0 00 00<br>
00&nbsp;&nbsp; sub&nbsp; esp, 192&nbsp; ; 000000c0H<br>
&nbsp; 00009 53&nbsp;&nbsp; push&nbsp; ebx<br>
&nbsp; 0000a 56&nbsp;&nbsp; push&nbsp; esi<br>
&nbsp; 0000b 57&nbsp;&nbsp; push&nbsp; edi<br>
&nbsp; 0000c 8d bd 40 ff ff<br>
ff&nbsp;&nbsp; lea&nbsp; edi, DWORD PTR [ebp-192]<br>
&nbsp; 00012 b9 30 00 00 00&nbsp; mov&nbsp; ecx, 48&nbsp;&nbsp; ; 00000030H<br>
&nbsp; 00017 b8 cc cc cc cc&nbsp; mov&nbsp; eax, -858993460&nbsp; ; ccccccccH<br>
&nbsp; 0001c f3 ab&nbsp;&nbsp; rep stosd<br>
<br>
; 8&nbsp;&nbsp;&nbsp; :&nbsp; *p=1;<br>
<br>
&nbsp; 0001e 8b 45 08&nbsp; mov&nbsp; eax, DWORD PTR _p$[ebp]<br>
&nbsp;&nbsp;</span></span><span lang="EN-US" style="mso-bidi-font-size:10.5pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;color:red;
mso-font-kerning:0pt">00021</span><span lang="EN-US" style="mso-bidi-font-size:
10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;
color:#383838;mso-font-kerning:0pt">&nbsp;c7 00 01 00 00<br>
00&nbsp;&nbsp; mov&nbsp; DWORD PTR [eax], 1<br>
<br>
; 9&nbsp;&nbsp;&nbsp; : }<br>
<br>
&nbsp; 00027 5f&nbsp;&nbsp; pop&nbsp; edi<br>
&nbsp; 00028 5e&nbsp;&nbsp; pop&nbsp; esi<br>
&nbsp; 00029 5b&nbsp;&nbsp; pop&nbsp; ebx<br>
&nbsp; 0002a 8b e5&nbsp;&nbsp; mov&nbsp; esp, ebp<br>
&nbsp; 0002c 5d&nbsp;&nbsp; pop&nbsp; ebp<br>
&nbsp; 0002d c3&nbsp;&nbsp; ret&nbsp; 0<br>
</span><span style="mso-bidi-font-size:10.5pt;font-family:宋体;mso-ascii-theme-font:
minor-fareast;mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Arial;color:#383838;mso-font-kerning:0pt">（说明<span lang="EN-US">: 7,8,9</span>是表示在源代码的行号。<span lang="EN-US"><br>
00000 55&nbsp;&nbsp; push&nbsp; ebp</span>，<span lang="EN-US">000000</span>是相对偏移地地，<span lang="EN-US">55</span>是机器码号，<span lang="EN-US">push ebp,000000</span>是汇编码。）<span lang="EN-US"><br>
<br>
</span>通过（<span lang="EN-US">2</span>）我们计算相对偏移地址，即崩溃地址<span lang="EN-US">-</span>函数起始地址<span lang="EN-US">,0x004113b1-0x00411390=0x21(16</span>进制的计数<span lang="EN-US">)</span>。找到<span lang="EN-US">0x21</span>这一行对应的机器码是<span lang="EN-US"> 00021 c7 00 01 00 00,</span>向上看它是由第<span lang="EN-US">8</span>行<span lang="EN-US">*p=1</span>；生成的汇编码，由此可见是这一行程序发生崩溃。<span lang="EN-US"><br style="mso-special-character:line-break">
<br style="mso-special-character:line-break">
<o:p></o:p></span></span></p>

<p class="MsoNormal" style="text-indent:21.0pt"><span style="mso-bidi-font-size:
10.5pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Arial;
color:#383838;mso-font-kerning:0pt">结束语：当然这只是一个简单的例子，实际上一运行便知道是这一行出错，但是对于一个比较大的工程，特别是在多线程并发情况下，要找出那一行出错比较困难，便可以使用<span lang="EN-US">map</span>和<span lang="EN-US">cod</span>文件找到程序崩溃原因。<span lang="EN-US"><o:p></o:p></span></span></p></span><p>&nbsp;</p></span><img src ="http://www.cppblog.com/Xin0101/aggbug/123117.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Xin0101/" target="_blank">阿鑫</a> 2010-08-11 22:43 <a href="http://www.cppblog.com/Xin0101/archive/2010/08/11/123117.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>