﻿<?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++博客-markqian86-随笔分类-调试</title><link>http://www.cppblog.com/markqian86/category/21313.html</link><description>practice makes perfect，阅读、分析、练习、总结。</description><language>zh-cn</language><lastBuildDate>Fri, 22 Jan 2021 21:17:00 GMT</lastBuildDate><pubDate>Fri, 22 Jan 2021 21:17:00 GMT</pubDate><ttl>60</ttl><item><title>centos7安装distcc和ccache</title><link>http://www.cppblog.com/markqian86/archive/2021/01/19/217577.html</link><dc:creator>长戟十三千</dc:creator><author>长戟十三千</author><pubDate>Tue, 19 Jan 2021 02:20:00 GMT</pubDate><guid>http://www.cppblog.com/markqian86/archive/2021/01/19/217577.html</guid><wfw:comment>http://www.cppblog.com/markqian86/comments/217577.html</wfw:comment><comments>http://www.cppblog.com/markqian86/archive/2021/01/19/217577.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/markqian86/comments/commentRss/217577.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/markqian86/services/trackbacks/217577.html</trackback:ping><description><![CDATA[<p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">centos7安装distcc</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">依赖项：</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">安装g++<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y gcc<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y gcc-c++</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">python：<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />python3.1版本以上。<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y python36</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">python环境<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />安装python3-devel， &nbsp; &nbsp; &nbsp;distcc安装时候需要其中的依赖<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y python3-devel</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">安装libbinutils 库 &nbsp; &nbsp; &nbsp; distcc需要依赖<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y binutils-devel</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">下载distcc包<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />https://distcc.github.io/&nbsp;<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />下载最新的安装包就好，我用的是distcc3.3.3</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">1 tar -xvf distcc-3.3.3.tar.gz<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />2 cd distcc-3.3.3<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />3 ./configure &nbsp; 如果报错Cannot find libiberty。需要安装libbinutils 库 &nbsp;<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />4 make &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如果报错，应该是上面的安装依赖项没安装全&nbsp;<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />5 make install<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />6 ln -s ./distcc-3.3.3/distcc /usr/lib/distcc</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">配置：<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />vim ~/.bashrc<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />export DISTCC_HOSTS="localhost"<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />export DISTCC_POTENTIAL_HOSTS="localhost"<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />export DISTCC_LOG="./distcc.log" #编译日志</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">意外：如果以上都配置好了，还是连不上，关掉防火墙，重试<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />systemctl stop firewall</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">安装ccache<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />yum install -y ccache<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />vim ~/.bash_profile<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />PATH=/usr/lib/ccache/bin:$PATH:$HOME/bin<br style="box-sizing: border-box; outline: 0px; overflow-wrap: break-word;" />&nbsp;</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">开启指令</p><p style="box-sizing: border-box; outline: 0px; margin: 0px 0px 16px; padding: 0px; font-size: 16px; color: #4d4d4d; overflow: auto hidden; overflow-wrap: break-word; font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; background-color: #ffffff; line-height: 26px !important;">distccd --daemon --allow 192.168.0.0/8 --user nobody --enable-tcp-insecure</p><img src ="http://www.cppblog.com/markqian86/aggbug/217577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/markqian86/" target="_blank">长戟十三千</a> 2021-01-19 10:20 <a href="http://www.cppblog.com/markqian86/archive/2021/01/19/217577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>c++运用backtrace追踪函数调用的堆栈</title><link>http://www.cppblog.com/markqian86/archive/2018/06/29/215755.html</link><dc:creator>长戟十三千</dc:creator><author>长戟十三千</author><pubDate>Fri, 29 Jun 2018 09:03:00 GMT</pubDate><guid>http://www.cppblog.com/markqian86/archive/2018/06/29/215755.html</guid><wfw:comment>http://www.cppblog.com/markqian86/comments/215755.html</wfw:comment><comments>http://www.cppblog.com/markqian86/archive/2018/06/29/215755.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/markqian86/comments/commentRss/215755.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/markqian86/services/trackbacks/215755.html</trackback:ping><description><![CDATA[<p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><span style="font-size: medium;">一般察看函数运行时堆栈的方法是使用GDB之类的外部调试器,但是,有些时候为了分析程序的BUG,(主要针对长时间运行程序的分析),在程序出错时打印出函数的调用堆栈是非常有用的。</span><br /><br /><span style="font-size: medium;">在头文件"execinfo.h"中声明了三个函数用于获取当前线程的函数调用堆栈</span><br /><br /><span style="font-size: medium;">Function: int backtrace(void **buffer,int size)<br /><br /></span><span style="font-size: medium;">该函数用与获取当前线程的调用堆栈,获取的信息将会被存放在buffer中,它是一个指针列表。参数 size 用来指定buffer中可以保存多少个void* 元素。函数返回值是实际获取的指针个数,最大不超过size大小</span>，<span style="font-size: medium;">在buffer中的指针实际是从堆栈中获取的返回地址,每一个堆栈框架有一个返回地址，</span><span style="font-size: medium;">注意某些编译器的优化选项对获取正确的调用堆栈有干扰,另外内联函数没有堆栈框架;删除框架指针也会使无法正确解析堆栈内容。</span><br /><br /><span style="font-size: medium;">Function: char ** backtrace_symbols (void *const *buffer, int size)<br /><br />backtrace_symbols</span><span style="font-size: medium;">将从backtrace函数获取的信息转化为一个字符串数组. 参数buffer应该是从backtrace函数获取的数组指针,size是该数组中的元素个数(backtrace的返回值)。</span><span style="font-size: medium;">函数返回值是一个指向字符串数组的指针,它的大小同buffer相同.每个字符串包含了一个相对于buffer中对应元素的可打印信息.它包括函数名，函数的偏移地址,和实际的返回地址。</span><br /><span style="font-size: medium;">现在,只有使用ELF二进制格式的程序和苦衷才能获取函数名称和偏移地址.在其他系统,只有16进制的返回地址能被获取.另外,你可能需要传递相应的标志给链接器,以能支持函数名功能(比如,在使用GNU ld的系统中,你需要传递</span><span style="font-size: medium;">(-rdynamic))。<br />该函数的返回值是通过malloc函数申请的空间,因此调用这必须使用free函数来释放指针</span><span style="font-size: medium;">.<br />注意:如果不能为字符串获取足够的空间函数的返回值将会为</span><span style="font-size: medium;">NULL<br /><br />Function:void backtrace_symbols_fd (void *const *buffer, int size, int fd)<br /><br />backtrace_symbols_fd与backtrace_symbols 函数具有相同的功能,不同的是它不会给调用者返回字符串数组,而是将结果写入文件描述符为fd的文件中,每个函数对应一行.它不需要调用malloc函数,因此适用于有可能调用该函数会失败的情况。</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><span style="font-size: medium;">下面是一个使用backtrace捕获异常并打印函数调用堆栈的例子：</span></p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">&nbsp;</p><div style="margin: 5px 0px; max-width: 900px; font-size: 12px;"><div style="margin-top: 5px;"><span style="padding-right: 5px; line-height: 1.5 !important;"><a title="复制代码" style="color: #1d58d1; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 22px; word-wrap: break-word; white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">#include &lt;signal.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;stdio.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;stdlib.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;execinfo.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;sys/types.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;sys/stat.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;fcntl.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;<span style="color: #0000ff; line-height: 1.5 !important;">string</span>.h&gt;<span style="line-height: 1.5 !important;"> #include </span>&lt;unistd.h&gt;  <span style="color: #0000ff; line-height: 1.5 !important;">#define</span> PRINT_DEBUG  <span style="color: #0000ff; line-height: 1.5 !important;">static</span> <span style="color: #0000ff; line-height: 1.5 !important;">void</span> print_reason(<span style="color: #0000ff; line-height: 1.5 !important;">int</span><span style="line-height: 1.5 !important;"> sig) {     </span><span style="color: #0000ff; line-height: 1.5 !important;">void</span> *array[<span style="color: #800080; line-height: 1.5 !important;">10</span><span style="line-height: 1.5 !important;">];     size_t size;     size </span>= backtrace(array, <span style="color: #800080; line-height: 1.5 !important;">10</span><span style="line-height: 1.5 !important;">); #ifdef PRINT_DEBUG     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> **<span style="line-height: 1.5 !important;">strings;     </span><span style="color: #0000ff; line-height: 1.5 !important;">int</span><span style="line-height: 1.5 !important;"> i;     strings </span>=<span style="line-height: 1.5 !important;"> backtrace_symbols(array, size);     printf(</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">Obtained %d stack frames.\n</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">, size);     </span><span style="color: #0000ff; line-height: 1.5 !important;">for</span> (i = <span style="color: #800080; line-height: 1.5 !important;">0</span>; i &lt; size; i++<span style="line-height: 1.5 !important;">)         printf(</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">%s\n</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">, strings[i]);     free(strings);      </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> cmd[<span style="color: #800080; line-height: 1.5 !important;">64</span>] = <span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">addr2line -C -f -e </span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">;     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span>* prog = cmd +<span style="line-height: 1.5 !important;"> strlen(cmd);     readlink(</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">/proc/self/exe</span><span style="color: #800000; line-height: 1.5 !important;">"</span>, prog, <span style="color: #0000ff; line-height: 1.5 !important;">sizeof</span>(cmd) - strlen(cmd) - <span style="color: #800080; line-height: 1.5 !important;">1</span>);<span style="color: #008000; line-height: 1.5 !important;">//</span><span style="color: #008000; line-height: 1.5 !important;"> 获取进程的完整路径</span> <span style="line-height: 1.5 !important;">     FILE</span>* fp = popen(cmd, <span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">w</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">);     </span><span style="color: #0000ff; line-height: 1.5 !important;">if</span> (fp !=<span style="line-height: 1.5 !important;"> NULL)     {         </span><span style="color: #0000ff; line-height: 1.5 !important;">for</span> (i = <span style="color: #800080; line-height: 1.5 !important;">0</span>; i &lt; size; ++<span style="line-height: 1.5 !important;">i)         {             fprintf(fp, </span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">%p\n</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">, array[i]);         }         pclose(fp);     } </span><span style="color: #0000ff; line-height: 1.5 !important;">#else</span>     <span style="color: #0000ff; line-height: 1.5 !important;">int</span> fd = open(<span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">err.log</span><span style="color: #800000; line-height: 1.5 !important;">"</span>, O_CREAT |<span style="line-height: 1.5 !important;"> O_WRONLY);     backtrace_symbols_fd(array, size, fd);     close(fd); </span><span style="color: #0000ff; line-height: 1.5 !important;">#endif</span><span style="line-height: 1.5 !important;">     exit(</span><span style="color: #800080; line-height: 1.5 !important;">0</span><span style="line-height: 1.5 !important;">); } </span><span style="color: #0000ff; line-height: 1.5 !important;">void</span><span style="line-height: 1.5 !important;"> die() {     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> *<span style="line-height: 1.5 !important;">test1;     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> *<span style="line-height: 1.5 !important;">test2;     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> *<span style="line-height: 1.5 !important;">test3;     </span><span style="color: #0000ff; line-height: 1.5 !important;">char</span> *test4 =<span style="line-height: 1.5 !important;"> NULL;     strcpy(test4, </span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="color: #800000; line-height: 1.5 !important;">ab</span><span style="color: #800000; line-height: 1.5 !important;">"</span><span style="line-height: 1.5 !important;">); } </span><span style="color: #0000ff; line-height: 1.5 !important;">void</span><span style="line-height: 1.5 !important;"> test1() {     die(); } </span><span style="color: #0000ff; line-height: 1.5 !important;">int</span> main(<span style="color: #0000ff; line-height: 1.5 !important;">int</span> argc, <span style="color: #0000ff; line-height: 1.5 !important;">char</span> **<span style="line-height: 1.5 !important;">argv) {     </span><span style="color: #0000ff; line-height: 1.5 !important;">struct</span><span style="line-height: 1.5 !important;"> sigaction myAction;     myAction.sa_handler </span>=<span style="line-height: 1.5 !important;"> print_reason;     sigemptyset(</span>&amp;<span style="line-height: 1.5 !important;">myAction.sa_mask);     myAction.sa_flags </span>= SA_RESTART |<span style="line-height: 1.5 !important;"> SA_SIGINFO;     sigaction(SIGSEGV, </span>&amp;myAction, NULL); <span style="color: #008000; line-height: 1.5 !important;">//</span><span style="color: #008000; line-height: 1.5 !important;"> 无效内存引用</span>     sigaction(SIGABRT, &amp;myAction, NULL); <span style="color: #008000; line-height: 1.5 !important;">//</span><span style="color: #008000; line-height: 1.5 !important;"> 异常终止</span> <span style="line-height: 1.5 !important;">    test1(); }</span></pre><div style="margin-top: 5px;"><span style="padding-right: 5px; line-height: 1.5 !important;"><a title="复制代码" style="color: #1d58d1; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; border: none !important;" /></a></span></div></div><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">&nbsp;</p><p style="margin-top: 10px; margin-bottom: 10px; font-family: Verdana, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">我本机测试打印出的信息如下：</p><div style="margin: 5px 0px; max-width: 900px; font-size: 12px;"><div style="margin-top: 5px;"><span style="padding-right: 5px; line-height: 1.5 !important;"><a title="复制代码" style="color: #1d58d1; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="max-width: 900px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; margin-left: 22px; word-wrap: break-word; white-space: pre-wrap; font-family: &quot;Courier New&quot; !important;">Obtained <span style="color: #800080; line-height: 1.5 !important;">7</span><span style="line-height: 1.5 !important;"> stack frames. </span>/root/workspace/test/Debug/test(__gxx_personality_v0+<span style="color: #800080; line-height: 1.5 !important;">0x12d</span>) [<span style="color: #800080; line-height: 1.5 !important;">0x80486c1</span><span style="line-height: 1.5 !important;">] [</span><span style="color: #800080; line-height: 1.5 !important;">0x71b440</span><span style="line-height: 1.5 !important;">] </span>/root/workspace/test/Debug/test(__gxx_personality_v0+<span style="color: #800080; line-height: 1.5 !important;">0x2ac</span>) [<span style="color: #800080; line-height: 1.5 !important;">0x8048840</span><span style="line-height: 1.5 !important;">] </span>/root/workspace/test/Debug/test(__gxx_personality_v0+<span style="color: #800080; line-height: 1.5 !important;">0x2c0</span>) [<span style="color: #800080; line-height: 1.5 !important;">0x8048854</span><span style="line-height: 1.5 !important;">] </span>/root/workspace/test/Debug/test(__gxx_personality_v0+<span style="color: #800080; line-height: 1.5 !important;">0x339</span>) [<span style="color: #800080; line-height: 1.5 !important;">0x80488cd</span><span style="line-height: 1.5 !important;">] </span>/lib/libc.so.<span style="color: #800080; line-height: 1.5 !important;">6</span>(__libc_start_main+<span style="color: #800080; line-height: 1.5 !important;">0xdc</span>) [<span style="color: #800080; line-height: 1.5 !important;">0xbf3e9c</span><span style="line-height: 1.5 !important;">] </span>/root/workspace/test/Debug/test(__gxx_personality_v0+<span style="color: #800080; line-height: 1.5 !important;">0x5d</span>) [<span style="color: #800080; line-height: 1.5 !important;">0x80485f1</span><span style="line-height: 1.5 !important;">] print_reason </span>/root/workspace/test/Debug/../main.cpp:<span style="color: #800080; line-height: 1.5 !important;">15</span> ?? ??:<span style="color: #800080; line-height: 1.5 !important;">0</span><span style="line-height: 1.5 !important;"> die() </span>/root/workspace/test/Debug/../main.cpp:<span style="color: #800080; line-height: 1.5 !important;">51</span><span style="line-height: 1.5 !important;"> test1() </span>/root/workspace/test/Debug/../main.cpp:<span style="color: #800080; line-height: 1.5 !important;">56</span><span style="line-height: 1.5 !important;"> main </span>/root/workspace/test/Debug/../main.cpp:<span style="color: #800080; line-height: 1.5 !important;">65</span> ?? ??:<span style="color: #800080; line-height: 1.5 !important;">0</span><span style="line-height: 1.5 !important;"> _start </span>??:<span style="color: #800080; line-height: 1.5 !important;">0</span></pre></div><img src ="http://www.cppblog.com/markqian86/aggbug/215755.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/markqian86/" target="_blank">长戟十三千</a> 2018-06-29 17:03 <a href="http://www.cppblog.com/markqian86/archive/2018/06/29/215755.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下内存检测工具：asan</title><link>http://www.cppblog.com/markqian86/archive/2018/06/14/215728.html</link><dc:creator>长戟十三千</dc:creator><author>长戟十三千</author><pubDate>Thu, 14 Jun 2018 07:46:00 GMT</pubDate><guid>http://www.cppblog.com/markqian86/archive/2018/06/14/215728.html</guid><wfw:comment>http://www.cppblog.com/markqian86/comments/215728.html</wfw:comment><comments>http://www.cppblog.com/markqian86/archive/2018/06/14/215728.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/markqian86/comments/commentRss/215728.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/markqian86/services/trackbacks/215728.html</trackback:ping><description><![CDATA[<p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">（<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">Address-Sanitizier</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">）</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">早先是<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">LLVM</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">中的特性，后被加入</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">GCC 4.8</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">，在</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">GCC 4.9</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">后加入对</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ARM</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">平台的支持。因此</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">GCC 4.8</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">以上版本使用ASAN时不需要安装第三方库，通过在编译时指定编译</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">CFLAGS</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">即可打开开关。</span></span></p><h2><a name="t1" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">1</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">、编译选项</span></h2><h3><a name="t2" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">1.1 Gcc</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">编译选项</span></h3><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># -fsanitize=address</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：开启内存越界检测</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># -fsanitize-recover=address</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：一般后台程序为保证稳定性，不能遇到错误就简单退出，而是继续运行，采用该选项支持内存出错之后程序继续运行，需要叠加设置<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">ASAN_OPTIONS=halt_on_error=0</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">才会生效；若未设置此选项，则内存出错即报错退出</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN_CFLAGS +=<span style="outline: 0px; box-sizing: border-box; font-weight: 700; word-break: break-all;">&nbsp;-fsanitize=address -fsanitize-recover=address</span></span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">&nbsp;</span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># -fno-stack-protector</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：去使能栈溢出保护</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># -fno-omit-frame-pointer</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：去使能栈溢出保护</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># -fno-var-tracking</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：默认选项为<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">-fvar-tracking</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">，会导致运行非常慢</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># -g1</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：表示最小调试信息，通常<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">debug</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">版本用</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">-g</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">即</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">-g2</span></span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN_CFLAGS += -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -g1</span></span></p><h3><a name="t3" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">1.2 Ld</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">链接选项</span></h3><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN_LDFLAGS += -fsanitize=address -g1</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">如果使用<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">gcc</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">链接，此处可忽略。</span></span></p><h2><a name="t4" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">2</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">、<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">ASAN</span>运行选项</span></h2><h3><a name="t5" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">2.1 ASAN_OPTIONS</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">设置</span></h3><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN_OPTIONS</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">是<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">Address-Sanitizier</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">的运行选项环境变量。</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># halt_on_error=0</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：检测内存错误后继续运行</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># detect_leaks=1:</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">使能内存泄露检测</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># malloc_context_size=15</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：内存错误发生时，显示的调用栈层数为<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">15</span></span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># log_path=/home/xos/asan.log:</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">内存检查问题日志存放文件路径</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># suppressions=$SUPP_FILE:</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">屏蔽打印某些内存错误</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">export ASAN_OPTIONS=halt_on_error=0:use_sigaltstack=0:detect_leaks=1:malloc_context_size=15:log_path=/home/xos/asan.log:suppressions=$SUPP_FILE</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">&nbsp;</span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">除了上述常用选项，以下还有一些选项可根据实际需要添加：</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"># detect_stack_use_after_return=1</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;">：检查访问指向已被释放的栈空间</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># handle_segv=1</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：处理段错误；也可以添加<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">handle_sigill=1</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">处理</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">SIGILL</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">信号</span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># quarantine_size=4194304:</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">内存<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">cache</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">可缓存</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">free</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">内存大小</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">4M</span></span></span></p><p align="left" style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN_OPTIONS=${ASAN_OPTIONS}:verbosity=0:handle_segv=1:allow_user_segv_handler=1:detect_stack_use_after_return=1:fast_unwind_on_fatal=1:fast_unwind_on_check=1:fast_unwind_on_malloc=1:quarantine_size=4194304</span></span></p><h3><a name="t6" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">2.2 LSAN_OPTIONS</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 10.5pt; line-height: 24.22px;">设置</span></h3><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">LSAN_OPTIONS</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">是<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">LeakSanitizier</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">运行选项的环境变量，而</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">LeakSanitizier</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">是</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">ASAN</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">的内存泄漏检测模块，常用运行选项有：</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># exitcode=0</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：设置内存泄露退出码为<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">0</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">，默认情况内存泄露退出码</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">0x16</span></span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"># use_unaligned=4</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">：<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">4</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">字节对齐</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">export LSAN_OPTIONS=exitcode=0:use_unaligned=4</span></span></p><h2><a name="t7" style="outline: 0px; cursor: pointer; box-sizing: border-box; color: rgb(78, 161, 219); word-break: break-all;"></a><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">3</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体; font-size: 12pt; line-height: 27.68px;">、总结</span></h2><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">实际开发环境中，可能存在<span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;">gcc</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">版本低，使用</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">asan</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">做内存检查时，需要链接</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">libasan.so</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">库的情况。其次，平台软件通常都会内部实现一套内存操作接口，为使用</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">asan</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">工具，需要替换成</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">glibc</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">提供的接口。此时，可以通过</span><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">LD_PRELOAD</span></span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">环境变量解决这类问题。</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background: #f2f2f2;"><span xml:lang="en-us" style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">export LD_PRELOAD= libasan.so.2:libprelib.so&nbsp;&nbsp;&nbsp;</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;">#vos_malloc --&gt; malloc</span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"><br /><br />ps:<br /><span style="font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px;">1、安装LLVM 3.1以上版本</span></span></span></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; margin: 0px 0px 16px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;">2、编译参数附加</p><pre name="code" style="outline: 0px; position: relative; overflow: auto hidden; box-sizing: border-box; font-family: Consolas, Inconsolata, Courier, monospace; line-height: 22px; word-break: break-all; margin-top: 0px; margin-bottom: 24px; padding: 8px 16px 4px 56px; background-color: #f6f8fa; border: none;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all;">-</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all;">fsanitize</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all;">=</span><span style="outline: 0px; box-sizing: border-box; word-break: break-all;">address</span></pre><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; margin: 0px 0px 16px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; margin: 0px 0px 16px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;">3、设置环境变量参数<br style="outline: 0px; box-sizing: border-box; word-break: break-all;" /></p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; margin: 0px 0px 16px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;">export ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer</p><span style="color: #4f4f4f; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 16px; text-align: justify; background-color: #ffffff;">export&nbsp;</span>ASAN_OPTIONS=symbolize=1<p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; margin: 0px 0px 16px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;">4、运行程序，如果出错，addressSanitizer会给出详细的报告。</p><p style="outline: 0px; padding: 0px; box-sizing: border-box; font-size: 16px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; background-color: #ffffff;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-family: 宋体;"><span style="outline: 0px; box-sizing: border-box; word-break: break-all; font-size: 14px;"></span></span></p><img src ="http://www.cppblog.com/markqian86/aggbug/215728.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/markqian86/" target="_blank">长戟十三千</a> 2018-06-14 15:46 <a href="http://www.cppblog.com/markqian86/archive/2018/06/14/215728.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>c++调试录像和回放</title><link>http://www.cppblog.com/markqian86/archive/2017/08/29/215206.html</link><dc:creator>长戟十三千</dc:creator><author>长戟十三千</author><pubDate>Tue, 29 Aug 2017 10:21:00 GMT</pubDate><guid>http://www.cppblog.com/markqian86/archive/2017/08/29/215206.html</guid><wfw:comment>http://www.cppblog.com/markqian86/comments/215206.html</wfw:comment><comments>http://www.cppblog.com/markqian86/archive/2017/08/29/215206.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/markqian86/comments/commentRss/215206.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/markqian86/services/trackbacks/215206.html</trackback:ping><description><![CDATA[1、gdb7 提供了<span style="color: #222222; font-family: Arial, sans-serif; font-size: 14.9248px; background-color: #ffffff;">反向调试 (reverse debug)的功能<br /></span><table border="0" cellpadding="0" cellspacing="0" class="ibm-data-table" style="margin: 0px 0px 20px; padding: 0px; outline: 0px; font-size: 12.8px; vertical-align: baseline; border-collapse: collapse; border-bottom-style: solid; border-bottom-color: #cccccc; border-left: 0px none; border-right: 0px none; color: #000000; font-family: Arial, sans-serif; background-color: #ffffff; width: 780px !important;"><tbody xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top: 2px solid #999999; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-continue ('rc')</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top: 2px solid #999999; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Continue</code><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">program being debugged but run it in reverse</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none; background: #d7edf8;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-finish</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none; background: #d7edf8;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Execute backward until just before the selected stack frame is called</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-next ('rn')</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Step program backward, proceeding through subroutine calls.</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-nexti ('rni')</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Step backward one instruction, but proceed through called subroutines.</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-step ('rs')</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Step program backward until it reaches the beginning of a previous</code><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">line</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Reverse-stepi</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Step backward exactly one instruction</code></td></tr><tr style="margin: 0px; padding: 0px; outline: 0px; font-size: inherit; vertical-align: baseline;"><td style="margin: 0px; padding: 8px 10px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 0px none; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">set exec-direction</code></td><td style="margin: 0px; padding: 8px 5px 5px 3px; outline: 0px; font-size: inherit; vertical-align: top; border-left: 3px solid #ffffff; border-top-style: solid; border-top-color: #dddddd; color: #555555; border-right: 0px none;"><code style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.95em !important; vertical-align: baseline; font-family: &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, Monaco, Liberation, fixed, monospace; line-height: 1.5em; color: #666666 !important;">Set direction of execution.</code></td></tr></tbody></table><span style="color: #222222; font-family: Arial, sans-serif; font-size: 14.9248px; background-color: #ffffff;">2、第三方的方向调试工具 rr :&nbsp;</span><span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; background-color: #ffffff;">Record and Replay Framework<br /></span><div>https://github.com/mozilla/rr</div><img src ="http://www.cppblog.com/markqian86/aggbug/215206.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/markqian86/" target="_blank">长戟十三千</a> 2017-08-29 18:21 <a href="http://www.cppblog.com/markqian86/archive/2017/08/29/215206.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>