Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
C ドライバー
/ /

デバッグの支援

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
}

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を使用して を構成します。

戻る

インデックスの管理

項目一覧