GDB
This repository contains a .gdbinit
file that contains helper functions to aid debugging of data structures. GDB will load this file automatically if you have added the directory which contains the .gdbinit
file to GDB's auto-load safe-path, and you start GDB from the directory which holds the .gdbinit
file.
GDB 프롬프트에서 show auto-load safe-path
이 포함된 안전 경로를 볼 수 있습니다. 다음을 사용하여 ~/.gdbinit
에서 설정하여 구성할 수 있습니다.
add-auto-load-safe-path /path/to/mongo-c-driver
자동 로드 안전 경로에 경로를 추가하지 않았거나 다른 디렉토리에서 GDB를 시작하는 경우, 다음을 사용하여 파일을 로드합니다.
source path/to/mongo-c-driver/.gdbinit
.gdbinit
파일 은 bson_t *
변수의 내용을 표시하는 printbson
함수를 정의합니다. 로컬 bson_t
이 있는 경우 변수 앞에 &
를 붙여야 합니다.
예시 GDB 세션은 다음과 같습니다.
(gdb) printbson bson ALLOC [0x555556cd7310 + 0] (len=475) { 'bool' : true, 'int32' : NumberInt("42"), 'int64' : NumberLong("3000000042"), 'string' : "Stŕìñg", 'objectId' : ObjectID("5A1442F3122D331C3C6757E1"), 'utcDateTime' : UTCDateTime(1511277299031), 'arrayOfInts' : [ '0' : NumberInt("1"), '1' : NumberInt("2") ], 'embeddedDocument' : { 'arrayOfStrings' : [ '0' : "one", '1' : "two" ], 'double' : 2.718280, 'notherDoc' : { 'true' : NumberInt("1"), 'false' : false } }, 'binary' : Binary("02", "3031343532333637"), 'regex' : Regex("@[a-z]+@", "im"), 'null' : null, 'js' : JavaScript("print foo"), 'jsws' : JavaScript("print foo") with scope: { 'f' : NumberInt("42"), 'a' : [ '0' : 3.141593, '1' : 2.718282 ] }, 'timestamp' : Timestamp(4294967295, 4294967295), 'double' : 3.141593 }
LLDB
mongo-c-driver 리포지토리 에는 LLDB 세션으로 가져올 수 있는 lldb_bson.py
스크립트 가 포함되어 있으며 이를 통해 BSON 값을 다양하게 검사할 수 있습니다.
참고
lldb_bson.py
모듈에는 Python 3.8 이상이 설치된 LLDB가 필요합니다.
스크립트 를 활성화하려면 LLDB 명령줄 에서 가져옵니다.
(lldb) command script import /path/to/mongo-c-driver/lldb_bson.py
성공 하면 lldb_bson is ready
메시지가 LLDB 콘솔에 인쇄됩니다.
이 스크립트 가져오기는 .lldbinit
파일 에 명령을 추가하여 자동으로 수행할 수 있습니다. 예시: 다음을 포함하는 ~/.lldbinit
파일 을 만듭니다.
command script import /path/to/mongo-c-driver/lldb_bson.py
lldb_bson.py
파일 상단의 독스트링에는 모듈의 기능에 대한 자세한 정보가 포함되어 있습니다.
디버그 어설션
런타임 디버그 어설션을 활성화하려면 -DENABLE_DEBUG_ASSERTIONS=ON
으로 구성합니다.