2015-07-03 3 views
2

Я хочу установить перерыв в Test :: Say(). Способ разгона Test :: Say() может это сделать. Но путь RBREAK TestSay() не может это сделать и информация сообщить об ошибке следующее:Как правильно использовать команду rbreak?

 
(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; 
    } 
+0

Начальный "г" в 'rbreak' для [* Регулярного выражения * ] (https://en.wikipedia.org/wiki/Regular_expression), и это означает, что определенные символы имеют особое значение, например, круглые скобки. Почему бы не использовать обычную команду 'break'? Тогда вы должны быть в состоянии сделать просто «break Test :: Say» (с другой стороны, вы также сможете выполнять «rbreak Test :: Say»). –

+0

Мое намерение - найти способ, который использует регулярное выражение для установки точки останова. Да, вы правы, но если даже я использую способ в соответствии с форматом выражения regualr, он не может этого сделать. – Summer

ответ

0

Я рекомендую модернизации GDB до самой последней версии. Я воспроизвел свою ошибку с помощью GDB версии 7.2:

/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) 

Однако с недавним GdB версией 7.9 RBREAK работает как exected:

$ \gdb ./a.out 
GNU gdb (GDB) 7.9.1 
Copyright (C) 2015 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-unknown-linux-gnu". 
Type "show configuration" for configuration details. 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
Find the GDB manual and other documentation resources online at: 
<http://www.gnu.org/software/gdb/documentation/>. 
For help, type "help". 
Type "apropos word" to search for commands related to "word"... 
Reading symbols from ./a.out...done. 
(gdb) rbreak Test::Say() 
Breakpoint 1 at 0x400626: file main.cpp, line 12. 
void Test::Say(); 
(gdb) r 
Starting program: /home/rbreak/a.out 

Breakpoint 1, Test::Say (this=0x7fffffffdd7f) at main.cpp:12 
12   printf("Hello word!"); 
(gdb) 
Смежные вопросы