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-ドライバーのリポジトリには、LDDB セッションにインポートして、BSON 値の豊富な検査を可能にするスクリプトlldb_bson.py
が含まれています。
注意
lldb_bson.py
モジュールには、Python 3.8以降を搭載した LDDB が必要です。
スクリプトをアクティブにするには、LDDB コマンドラインからインポートします。
(lldb) command script import /path/to/mongo-c-driver/lldb_bson.py
成功すると、メッセージlldb_bson is ready
が LDDB コンソールに出力されます。
このスクリプトのインポートは、コマンドを.lldbinit
ファイルに追加することで自動で行うことができます。 たとえば、次の内容を含むファイル~/.lldbinit
を作成します。
command script import /path/to/mongo-c-driver/lldb_bson.py
lldb_bson.py
ファイル上部の docstring には、モジュールの機能に関する詳細情報が含まれています。
デバッグ アサーション
ランタイム デバッグ アサーションを有効にするには、 -DENABLE_DEBUG_ASSERTIONS=ON
を使用して を構成します。