如何正确使用rbreak的命令?

时间:2015-07-03 06:21:18

标签: c++ gdb

我想在Test :: Say()中设置一个休息点。中断的方式Test :: Say()可以做到。但是,rbreak TestSay()的方法无法做到并报告以下错误信息:

(gdb) rbreak Test::Say()
Can't find member of namespace, class, struct, or union named "main.cpp:'Test::Say()"
Hint: try 'main.cpp:'Test::Say()' or 'main.cpp:'Test::Say()'
(Note leading single quote.)
   class Test
    {
    public:
            Test()
            {
            }

            void Say()
            {
                    printf("Hello word!");
            }
    };


    int main ()
    {
            Test a;
            a.Say();
            getchar();
            return 0;
    }

1 个答案:

答案 0 :(得分:1)

我建议将gdb升级到最新版本。我用gdb版本7.2重现了你的错误:

{

然而,最近的gdb版本7.9 rbreak工作正常:

 /usr/bin/gdb ./a.out   
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/rbreak/a.out...done.
(gdb) rbreak Test::Say()
Can't find member of namespace, class, struct, or union named "main.cpp:'Test::Say()"
Hint: try 'main.cpp:'Test::Say()'<TAB> or 'main.cpp:'Test::Say()'<ESC-?>
(Note leading single quote.)
Breakpoint 1 (main.cpp:'Test::Say()') pending.
void Test::Say();
(gdb)