7
votes

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.

2
you can always use file:linenumber. - Karoly Horvath
@yi_H well, it would be much better to use function name since the linenumber might change if I change the source code and it will be somewhat difficult to trace. - xis
I'm aware of this, it's just a workaround - Karoly Horvath
If you have optimizations enabled, it's possible that the compiler automatically inlined the function. Try recompiling with -O0 -ggdb - Chris Eberle

2 Answers

3
votes

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.

0
votes

I'm guessing the compiler has stripped the const specifier,

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