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