<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[实践OK] gdb断点保存，gdb单文件多文件断点设置及断点管理,GDB通过自定义命令实现一次执行多个命令。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Thu, 19 Mar 2015 03:21:16 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：调试大的程序时，经常会设置很多断点。但一旦退出gdb，这些断点会全部丢失，再调试时又得重新设置断点，费时费力。gdb断点保存势在必行。<br/>实践如下：<br/>vi bp.list<br/>set follow-fork-mode child<br/>b&nbsp;&nbsp;187<br/>b 194<br/>b 290&nbsp;&nbsp;&nbsp;&nbsp; <br/><br/>后用-x命令载入这个断电的列表：<br/><textarea name="code" class="php" rows="15" cols="100">
gdb multipepollserver -x bp.list 
</textarea><br/>GNU gdb Fedora (6.8-37.el5)<br/>Copyright (C) 2008 Free Software Foundation, Inc.<br/>License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;<br/>This is free software: you are free to change and redistribute it.<br/>There is NO WARRANTY, to the extent permitted by law.&nbsp;&nbsp;Type &quot;show copying&quot;<br/>and &quot;show warranty&quot; for details.<br/>This GDB was configured as &quot;x86_64-redhat-linux-gnu&quot;...<br/>Breakpoint 1 at 0x4025de: file multipepollserver.cpp, line 187.<br/>Breakpoint 2 at 0x4026cf: file multipepollserver.cpp, line 194.<br/>Breakpoint 3 at 0x402c2a: file multipepollserver.cpp, line 290.<br/><br/>有时进程退出有问题，于是得杀死，其shell一行解决：<br/>ps aux&#124;grep httpmut&#124;grep -v grep&#124;awk &#039;&#123;print &quot;kill -9 &quot;$2 &#125;&#039;<br/>kill：<br/><textarea name="code" class="php" rows="15" cols="100">
ps aux&#124;grep httpmut&#124;grep -v grep&#124;awk &#039;&#123;print &quot;kill -9 &quot;$2 &#125;&#039;&#124;sh
</textarea><br/>——————————————————————————————————————————————————————————<br/>一、Share: gdb断点保存<br/>调试大的程序时，经常会设置很多断点。但一旦退出gdb，这些断点会全部丢失，再调试时又得重新设置断点，费时费力。<br/>我们可能利用gdb的-x参数来载入所有预设的断点，步骤如下：<br/><br/>１.将断点保存到一个文件中，如bp.list；<br/><br/>2.用gdb调试时，加-x参数载入上述文件。这相当于是gdb的一个批处理功能，因此你还可以在上述文件中加上其他你经常要用到的命令。<br/><br/>Ｆor example:<br/><br/>bash-3.00$ cat bp.list <br/>b main<br/>b 8<br/><br/>bash-3.00$ g++ -g test.cpp<br/>bash-3.00$ gdb ./a.out -x bp.list -tui<br/><br/>GNU gdb 6.6<br/>Copyright (C) 2006 Free Software Foundation, Inc.<br/>GDB is free software, covered by the GNU General Public License, and you are<br/>welcome to change it and/or distribute copies of it under certain conditions.<br/>Type &quot;show copying&quot; to see the conditions.<br/>There is absolutely no warranty for GDB.&nbsp;&nbsp;Type &quot;show warranty&quot; for details.<br/>This GDB was configured as &quot;sparc-sun-solaris2.10&quot;...<br/>Breakpoint 1 at 0x11000: file test.cpp, line 26.<br/>Breakpoint 2 at 0x10e28: file test.cpp, line 8.<br/>(gdb)<br/><br/>Enjoy it~<br/><br/><br/>例如，你每次启动gdb，想在main 函数处设断点 <br/><br/>编辑一个文件比如叫&nbsp;&nbsp; a <br/>a中输入&nbsp;&nbsp; <br/>br&nbsp;&nbsp; main <br/>保存 <br/><br/>gdb&nbsp;&nbsp; 你的可执行文件&nbsp;&nbsp; -x&nbsp;&nbsp; a就自动执行设断点了。 <br/><br/>这相当于是gdb的一个批处理功能，你还可以在文件中加上其他你经常要用到的命令 <br/><br/>只要用-x&nbsp;&nbsp; 参数加批处理文件运行就可以了<br/><br/> <br/>来自：http://blog.csdn.net/rxl2008/article/details/6273664<br/><br/>http://topic.csdn.net/t/20041117/17/3562393.html<br/>可以把一些需要用到的命令写到一个文件中，运行gdb的时候读取之就ok了。<br/><br/>6 楼datuhao（峡谷）回复于 2004-11-18 19:22:14 得分 90<br/>例如&nbsp;&nbsp; <br/>&nbsp;&nbsp;你每次启动gdb&nbsp;&nbsp; ，想在main&nbsp;&nbsp; 函数处设断点&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;编辑一个文件比如叫&nbsp;&nbsp; a&nbsp;&nbsp; <br/>&nbsp;&nbsp;a中输入&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;br&nbsp;&nbsp; main&nbsp;&nbsp; <br/>&nbsp;&nbsp;保存&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;gdb&nbsp;&nbsp; 你的可执行文件&nbsp;&nbsp; -x&nbsp;&nbsp; a就自动执行设断点了。&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;这相当于是gdb的一个批处理功能，你还可以在文件中加上其他你经常要用到的命令&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;只要用-x&nbsp;&nbsp; 参数加批处理文件运行就可以了<br/><br/><br/><br/>二、gdb单文件多文件断点设置及断点管理:<br/>摘自：http://blog.163.com/xychenbaihu@yeah/blog/static/13222965520112179264986/<br/><br/><br/><br/><br/>三、GDB通过自定义命令实现一次执行多个命令<br/>今天，想在gdb一次执行next和p num_caches两条命令，尝试<br/><br/>next; p num_cache<br/><br/>等基于分割符的命令无效后，查了下，需要通过自定义命令实现，具体如下：<br/><br/>(gdb) next;p num_caches<br/><br/>Invalid character &#039;;&#039; in expression.<br/><br/>(gdb) define myfun<br/><br/>Type commands for definition of &quot;myfun&quot;.<br/><br/>End with a line saying just &quot;end&quot;.<br/><br/>&gt;next<br/><br/>&gt;p num_caches<br/><br/>&gt;end<br/><br/>(gdb) myfun<br/><br/>731&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpus[j].dcache-&gt;owner = (struct godson2_cpu *)&amp;cpus[j];<br/><br/>$4 = 3<br/><br/>另外，有些常用的命令组合可以在~/.gdbinit中定义<br/><br/>原文：http://mblog.sigma.me/2011/09/22/gdb-run-multi-cmd.html
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK] gdb断点保存，gdb单文件多文件断点设置及断点管理,GDB通过自定义命令实现一次执行多个命令。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>