1MONGOC_DEBUGGING(3)                libmongoc               MONGOC_DEBUGGING(3)
2
3
4

NAME

6       mongoc_debugging - Aids for Debugging
7

GDB

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

LLDB

71       This  repository also includes a script that customizes LLDB's standard
72       print command to print a bson_t or bson_t * as JSON:
73
74          (lldb) print b
75          (bson_t) $0 = {"x": 1, "y": 2}
76
77       The custom bson command provides more options:
78
79          (lldb) bson --verbose b
80          len=19
81          flags=INLINE|STATIC
82          {
83            "x": 1,
84            "y": 2
85          }
86          (lldb) bson --raw b
87          '\x13\x00\x00\x00\x10x\x00\x01\x00\x00\x00\x10y\x00\x02\x00\x00\x00\x00'
88
89       Type help bson for a list of options.
90
91       The script requires a build of libbson with debug symbols, and  an  in‐
92       stallation of PyMongo. Install PyMongo with:
93
94          python -m pip install pymongo
95
96       If  you  see  "No module named pip" then you must install pip, then run
97       the previous command again.
98
99       Create a file ~/.lldbinit containing:
100
101          command script import /path/to/mongo-c-driver/lldb_bson.py
102
103       If you see "bson command installed by lldb_bson" at  the  beginning  of
104       your LLDB session, you've installed the script correctly.
105

AUTHOR

107       MongoDB, Inc
108
110       2017-present, MongoDB, Inc
111
112
113
114
1151.17.6                           Jun 03, 2021              MONGOC_DEBUGGING(3)
Impressum