在mongodb中,类游标被定义为'Cursor : boost::noncopyable',然后有很多类是从它派生的。我想知道客户端的给定操作使用了哪个 XXXCursor。所以我想在 Cursor::Cursor 上设置一个断点。但失败了。
(gdb) b mongo::Cursor::Cursor
the class mongo::Cursor does not have any method named Cursor
Hint: try 'mongo::Cursor::Cursor<TAB> or 'mongo::Cursor::Cursor<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) ptype mongo::Cursor
type = class mongo::Cursor : private boost::noncopyable_::noncopyable {
public:
~Cursor(int);
virtual bool ok(void);
bool eof(void);
virtual mongo::Record * _current(void);
virtual mongo::BSONObj current(void);
virtual mongo::DiskLoc currLoc(void);
virtual bool advance(void);
virtual mongo::BSONObj currKey(void) const;
....
}
(gdb) list mongo::Cursor::Cursor
**the class mongo::Cursor does not have any method named Cursor
Hint: try 'mongo::Cursor::Cursor<TAB> or 'mongo::Cursor::Cursor<ESC-?>**
(Note leading single quote.)
但是我写了一个类似的程序
#include <iostream>
#include <boost/utility.hpp>
class Base : boost::noncopyable {
public:
void printx() {std::cout<< getx() <<"\n" ;}
virtual int getx()=0;
};
class P : public Base {
public:
int x;
virtual int getx() { return x*3;}
P(int c){ x= c;}
};
int main(){
P p(2);
p.printx();
return 0;
}
我可以成功地在 Base::Base 上设置断点。
你知道为什么我不能在 mongo::Cursor::Cursor 上设置断点吗?
mongo::Cursor 在这里定义: https ://github.com/mongodb/mongo/blob/master/src/mongo/db/cursor.h