에서 실패했습니다. 클래스 커서는 '커서 : boost :: noncopyable'로 정의 된 다음 클래스에서 파생됩니다. 나는 XXXCursor가 사용 된 클라이언트로부터 주어진 오퍼레이션을 알고 싶다. 그래서 나는 Cursor :: Cursor에 중단 점을 설정하려고한다. 그러나 실패했다. 기본 클래스의 gdb 중단 점,하지만 mongodb의
(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;
}
을 썼다.
mongo :: Cursor :: Cursor에 중단 점을 설정할 수없는 이유는 무엇입니까?
몽고 :: 커서 여기 definied했다 : 당신의 예로서 https://github.com/mongodb/mongo/blob/master/src/mongo/db/cursor.h
FWIW - "nm"출력을 보는 것만으로는 충분하지 않습니다. gdb는 debuginfo를 사용하여 인라인 된 함수에 중단 점을 설정할 수도 있습니다. 이를 위해 "readelf-wi"출력을 파헤쳐 야합니다. 나는이 상황에서 문제를 알지 못한다. 가능한 많은 것들이 있습니다 - 컴파일러 버그, gdb 버그, 모호한 의도적 인 행동 등이 있습니다. –
Tom,이 예제에서는 Base :: Base()가 사용자에 의해 정의되지 않았습니다. 내 요점은 Base :: Base() 컴파일러에 의해 수준 O0에 암시 적으로 정의되어 있고 그것은 비어 있습니다. 레벨 O2에서 컴파일러는 완전히 제거하므로 인라인되지 않습니다. –
두 분 모두 고마워요! 나는 'scons -Q -d all'로 몽고를 건설한다. 출력에 -O0이 포함되어 있습니다. g ++ -o build/linux2/d/mongo/db/jsobj.o -c -Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno -unknown-pragma -Winvalid-pch -Werror- 파이프 -O0 -fstack-protector -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp -DBOOST_ALL_NO_LIB -D_SCONS -DMONGO_EXPOSE_MACROS -DSUPPORT_UTF8 -D_FILE_OFFSET_BITS = 64 -DMONGO_HAVE_HEADER_UNISTD_H -DMONGO_HAVE_EXECINFO_BACKTRACE ... src/mongo/db/jsobj.cpp 그래서 다른 이유가있을 수 있습니다. – zhihuifan