used with tools like `grep'. Note that this is different from the syntax used by
shells, so for instance foo* matches all functions that include an fo followed
by zero or more os. There is an implicit .* leading and trailing the regular
expression you supply, so to match only functions that begin with foo, use ^foo.
When debugging C++ programs, rbreak is useful for setting breakpoints on
overloaded functions that are not members of any special classes.
break *address 在程序运行的内存地址设置断点
break filename:function
info break [n] 查看断点,n 表示断点号
值得一提的是,C++允许 overloading,所以直接指定函数名称有时候 gdb 无法辨认要把中断
点设在哪。 举例:
int takeout(int i,int j){...}
int takeout(float i,float j){...}
这时候我们可以设定 break takeout(int,int),这样就会在上面的函数的进入点设定中断
点。 当然假如我们只输入 break takeout,gdb 会显示一个互动示选单显示所有可能的函式
的原型,让我们挑选要将中断点设在哪个函式。break 的简写是 b,通常只输入简写方便多
了。
二、设置观察点(WatchPoint)
观察点一般来观察某个表达式(变量也是一种表达式)的值是否有变化了,如果有变化,马
上停住程序。我们有下面的几种方法来设置观察点:
watch expr
为表达式(变量)expr 设置一个观察点。一量表达式值有变化时,马上停住程序。
rwatch expr
当表达式(变量)expr 被读时,停住程序。
awatch expr
当表达式(变量)的值被读或被写时,停住程序。
info watchpoints
列出当前所设置了的所有观察点。