1MONGOC_DEBUGGING(3) libmongoc MONGOC_DEBUGGING(3)
2
3
4
6 This repository contains a .gdbinit file that contains helper functions
7 to aid debugging of data structures. GDB will load this file
8 automatically if you have added the directory which contains the
9 .gdbinit file to GDB's auto-load safe-path, and you start GDB from the
10 directory which holds the .gdbinit file.
11
12 You can see the safe-path with show auto-load safe-path on a GDB
13 prompt. You can configure it by setting it in ~/.gdbinit with:
14
15 add-auto-load-safe-path /path/to/mongo-c-driver
16
17 If you haven't added the path to your auto-load safe-path, or start GDB
18 in another directory, load the file with:
19
20 source path/to/mongo-c-driver/.gdbinit
21
22 The .gdbinit file defines the printbson function, which shows the con‐
23 tents of a bson_t * variable. If you have a local bson_t, then you
24 must prefix the variable with a &.
25
26 An example GDB session looks like:
27
28 (gdb) printbson bson
29 ALLOC [0x555556cd7310 + 0] (len=475)
30 {
31 'bool' : true,
32 'int32' : NumberInt("42"),
33 'int64' : NumberLong("3000000042"),
34 'string' : "Stŕìñg",
35 'objectId' : ObjectID("5A1442F3122D331C3C6757E1"),
36 'utcDateTime' : UTCDateTime(1511277299031),
37 'arrayOfInts' : [
38 '0' : NumberInt("1"),
39 '1' : NumberInt("2")
40 ],
41 'embeddedDocument' : {
42 'arrayOfStrings' : [
43 '0' : "one",
44 '1' : "two"
45 ],
46 'double' : 2.718280,
47 'notherDoc' : {
48 'true' : NumberInt("1"),
49 'false' : false
50 }
51 },
52 'binary' : Binary("02", "3031343532333637"),
53 'regex' : Regex("@[a-z]+@", "im"),
54 'null' : null,
55 'js' : JavaScript("print foo"),
56 'jsws' : JavaScript("print foo") with scope: {
57 'f' : NumberInt("42"),
58 'a' : [
59 '0' : 3.141593,
60 '1' : 2.718282
61 ]
62 },
63 'timestamp' : Timestamp(4294967295, 4294967295),
64 'double' : 3.141593
65 }
66
68 The mongo-c-driver repository contains a script lldb_bson.py that can
69 be imported into an LLDB sessions and allows rich inspection of BSON
70 values.
71
72 NOTE:
73 The lldb_bson.py module requires an LLDB with Python 3.8 or newer.
74
75 To activate the script, import it from the LLDB command line:
76
77 (lldb) command script import /path/to/mongo-c-driver/lldb_bson.py
78
79 Upon success, the message lldb_bson is ready will be printed to the
80 LLDB console.
81
82 The import of this script can be made automatic by adding the command
83 to an .lldbinit file. For example: Create a file ~/.lldbinit contain‐
84 ing:
85
86 command script import /path/to/mongo-c-driver/lldb_bson.py
87
88 The docstring at the top of the lldb_bson.py file contains more infor‐
89 mation on the capabilities of the module.
90
92 To enable runtime debug assertions, configure with -DENABLE_DEBUG_AS‐
93 SERTIONS=ON.
94
96 MongoDB, Inc
97
99 2017-present, MongoDB, Inc
100
101
102
103
1041.25.1 Nov 08, 2023 MONGOC_DEBUGGING(3)