使用 「信息功能< <。*字符串」 搜索功能在其名稱中< <和串。 信息功能需要一個正則表達式作爲參數。
然後從列出的功能中選擇一個你想要的。刪除;在聲明如果任何的端部並粘貼聲明作爲參數傳遞給破命令:
$ gdb -q ./ostream-operator-breakpoint
<...>
(gdb) start
Temporary breakpoint 1 at 0x4006b0: file ostream-operator-breakpoint.cc, line 4.
Starting program: /home/scottt/Dropbox/stackoverflow/ostream-operator-breakpoint
<...>
(gdb) info functions <<.*string
All functions matching regular expression "<<.*string":
File /usr/src/debug/gcc-4.7.2-20121109/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:
std::basic_ostream<char, std::char_traits<char> > &std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&);
std::basic_ostream<wchar_t, std::char_traits<wchar_t> > &std::operator<< <wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&);
(gdb) break std::basic_ostream<char, std::char_traits<char> > &std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
Breakpoint 2 at 0x3cbfa94640: file /usr/src/debug/gcc-4.7.2-20121109/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h, line 2750.
的開始(或運行)命令所需的動態鏈接的程序。除非您首先啓動劣質進程,否則信息函數將不會列出共享庫(例如libstdC++)中的函數。從同事
答案: http://tdistler.com/2008/11/13/debugging-c-templates-brekpoints-and-gdb 簡單的回答:使用objdump的,C++ FILT,和grep找到GDB需要的完整定義。 $ objdump -t libMyLib.so | C++ filt | grep'BarAbstract。* Baz' 0000d2d6 w F .text 0000000a MY_PLUGIN_A :: Foo :: Baz() 現在,只需在設置斷點時將完整的方法定義複製粘貼到GDB: (gdb)b MY_PLUGIN_A :: Foo :: Baz() Breakpoint 6 at 0×8048890:file Source/Bar.cpp,line 355 –
2013-05-13 13:27:30
運算符上的斷點:http://stackoverflow.com/questions/15301924/how-do-i-set-a-breakpoint-on-operator-with-gdb在正則表達式中斷開:'rbreak regexp'。 – 2015-07-27 16:41:14