.\" Man page generated from reStructuredText. . .TH "MONGOC_DEBUGGING" "3" "Jun 04, 2021" "1.17.6" "libmongoc" .SH NAME mongoc_debugging \- Aids for Debugging . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH GDB .sp This repository contains a \fB\&.gdbinit\fP file that contains helper functions to aid debugging of data structures. GDB will load this file \fI\%automatically\fP if you have added the directory which contains the \fI\&.gdbinit\fP file to GDB\(aqs \fI\%auto\-load safe\-path\fP, \fIand\fP you start GDB from the directory which holds the \fI\&.gdbinit\fP file. .sp You can see the safe\-path with \fBshow auto\-load safe\-path\fP on a GDB prompt. You can configure it by setting it in \fB~/.gdbinit\fP with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C add\-auto\-load\-safe\-path /path/to/mongo\-c\-driver .ft P .fi .UNINDENT .UNINDENT .sp If you haven\(aqt added the path to your auto\-load safe\-path, or start GDB in another directory, load the file with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C source path/to/mongo\-c\-driver/.gdbinit .ft P .fi .UNINDENT .UNINDENT .sp The \fB\&.gdbinit\fP file defines the \fBprintbson\fP function, which shows the contents of a \fBbson_t *\fP variable. If you have a local \fBbson_t\fP, then you must prefix the variable with a \fI&\fP\&. .sp An example GDB session looks like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C (gdb) printbson bson ALLOC [0x555556cd7310 + 0] (len=475) { \(aqbool\(aq : true, \(aqint32\(aq : NumberInt("42"), \(aqint64\(aq : NumberLong("3000000042"), \(aqstring\(aq : "Stŕìñg", \(aqobjectId\(aq : ObjectID("5A1442F3122D331C3C6757E1"), \(aqutcDateTime\(aq : UTCDateTime(1511277299031), \(aqarrayOfInts\(aq : [ \(aq0\(aq : NumberInt("1"), \(aq1\(aq : NumberInt("2") ], \(aqembeddedDocument\(aq : { \(aqarrayOfStrings\(aq : [ \(aq0\(aq : "one", \(aq1\(aq : "two" ], \(aqdouble\(aq : 2.718280, \(aqnotherDoc\(aq : { \(aqtrue\(aq : NumberInt("1"), \(aqfalse\(aq : false } }, \(aqbinary\(aq : Binary("02", "3031343532333637"), \(aqregex\(aq : Regex("@[a\-z]+@", "im"), \(aqnull\(aq : null, \(aqjs\(aq : JavaScript("print foo"), \(aqjsws\(aq : JavaScript("print foo") with scope: { \(aqf\(aq : NumberInt("42"), \(aqa\(aq : [ \(aq0\(aq : 3.141593, \(aq1\(aq : 2.718282 ] }, \(aqtimestamp\(aq : Timestamp(4294967295, 4294967295), \(aqdouble\(aq : 3.141593 } .ft P .fi .UNINDENT .UNINDENT .SH LLDB .sp This repository also includes a script that customizes LLDB\(aqs standard \fBprint\fP command to print a \fBbson_t\fP or \fBbson_t *\fP as JSON: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C (lldb) print b (bson_t) $0 = {"x": 1, "y": 2} .ft P .fi .UNINDENT .UNINDENT .sp The custom \fBbson\fP command provides more options: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C (lldb) bson \-\-verbose b len=19 flags=INLINE|STATIC { "x": 1, "y": 2 } (lldb) bson \-\-raw b \(aq\ex13\ex00\ex00\ex00\ex10x\ex00\ex01\ex00\ex00\ex00\ex10y\ex00\ex02\ex00\ex00\ex00\ex00\(aq .ft P .fi .UNINDENT .UNINDENT .sp Type \fBhelp bson\fP for a list of options. .sp The script requires a build of libbson with debug symbols, and an installation of \fI\%PyMongo\fP\&. Install PyMongo with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C python \-m pip install pymongo .ft P .fi .UNINDENT .UNINDENT .sp If you see "No module named pip" then you must \fI\%install pip\fP, then run the previous command again. .sp Create a file \fB~/.lldbinit\fP containing: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C command script import /path/to/mongo\-c\-driver/lldb_bson.py .ft P .fi .UNINDENT .UNINDENT .sp If you see "bson command installed by lldb_bson" at the beginning of your LLDB session, you\(aqve installed the script correctly. .SH AUTHOR MongoDB, Inc .SH COPYRIGHT 2017-present, MongoDB, Inc .\" Generated by docutils manpage writer. .