Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set breakpoint for class member function not successful

Tags:

c++

gdb

I have a class looks like this:

namespace madoka
{
class polarizable_sites
{
public:
void resize(const size_t dim_);
void clear(void);
};
}

in gdb, I could set breakpoint on clear by

b 'madoka::polarizable_sites::clear()'

however, for member function resize, a

b 'madoka::polarizable_sites::resize(const size_t)'

does not work. GDB reported error:

the class madoka::polarizable_sites does not have any method named resize(const size_t) Hint: try 'madoka::polarizable_sites::resize(const size_t)' or 'madoka::polarizable_sites::resize(const size_t)' (Note leading single quote.)

I am wondering why since the function style is auto-completed by TAB.

BTW: I'm using GDB

GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2 Copyright (C) 2010 Free Software Foundation, Inc.

with compiler'

g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 Copyright (C) 2010 Free Software Foundation, Inc.

like image 923
xis Avatar asked Jul 31 '11 21:07

xis


People also ask

How do you add a breakpoint in GDB C++?

You can also set breakpoints on function names. To do this, just type "break [functionname]". gdb will stop your program just before that function is called. Breakpoints stay set when your program ends, so you do not have to reset them unless you quit gdb and restart it.

Can I set breakpoints to all methods in a class at once in Visual Studio?

In short, you can bring up the "New Breakpoint" dialog by pressing Ctrl+K, B and type in ClassName::* to the function field. In Visual Studio 2017 you need to include the namespace in the field, as in NamespaceName::ClassName::* . You can then disable some of them in the breakpoints window.

How do you add a class breakpoint?

To set a method breakpoint in Eclipse, double-click in the margin to the left of the line defining the method name. Class Load Breakpoint: This type of breakpoint is used to halt execution when a specified class is loaded. This is especially useful when classes are loaded dynamically at runtime.

How do I remove a breakpoint in GDB?

With the clear command you can delete breakpoints according to where they are in your program. With the delete command you can delete individual breakpoints, watchpoints, or catchpoints by specifying their breakpoint numbers. It is not necessary to delete a breakpoint to proceed past it.


1 Answers

Probably the function is inlined. Try adding __asm int 3 if it's x86 code in GDB syntax and walk the code. This trick has saved me a lot of time when debugging MSVC x86 code.

like image 149
Coder Avatar answered Oct 13 '22 00:10

Coder