[SERVER-57326] Add GDB pretty printer support for bson given a process memory address Created: 01/Jun/21  Updated: 29/Oct/23  Resolved: 02/Jun/21

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Daniel Gottlieb (Inactive) Assignee: Daniel Gottlieb (Inactive)
Resolution: Fixed Votes: 0
Labels: gdb
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

Example usages:

(gdb) mongodb-help
Command - Description
mongodb-service-context - Dump the Global Service Context.
<snip>
mongodb-pprint-bson - 
    Interprets a pointer into raw memory as the start of a bson object. Pretty print the results.
<snip>
(gdb) mongodb-pprint-bson 
Usage: mongodb-pprint-bson <ptr> <optional length>
(gdb) mongodb-pprint-bson 0x7fbfffa6394f
Pretty printing bson object at 140462604564815 (20480 bytes)
{'ident': 'collection-361-5113077617502034514',
 'idxIdent': {'_id_': 'index-362-5113077617502034514',
              'a.b.0_1': 'index-365-5113077617502034514',
              'a.b.c_1': 'index-363-5113077617502034514',
              'a.b_1': 'index-364-5113077617502034514'},
 'md': {'indexes': [{'backgroundSecondary': False,
                     'head': 0,
                     'multikey': False,
                     'multikeyPaths': {'_id': b'\x00'},
                     'ready': True,
                     'spec': {'key': {'_id': 1}, 'name': '_id_', 'v': 2}},
                    {'backgroundSecondary': False,
                     'head': 0,
                     'multikey': True,
                     'multikeyPaths': {'a.b.c': b'\x01\x01\x01'},
                     'ready': True,
                     'spec': {'key': {'a.b.c': 1.0},
                              'name': 'a.b.c_1',
                              'v': 2}},
                    {'backgroundSecondary': False,
                     'head': 0,
                     'multikey': True,
                     'multikeyPaths': {'a.b': b'\x00\x01'},
                     'ready': True,
                     'spec': {'key': {'a.b': 1.0}, 'name': 'a.b_1', 'v': 2}},
                    {'backgroundSecondary': False,
                     'head': 0,
                     'multikey': False,
                     'multikeyPaths': {'a.b.0': b'\x00\x00\x00'},
                     'ready': True,
                     'spec': {'key': {'a.b.0': 1.0},
                              'name': 'a.b.0_1',
                              'v': 2}}],
        'ns': 'tenantMigrationTenantId_test.distinct_multikey',
        'options': {'uuid': UUID('5a441857-cd83-4b5f-9f96-c6d24f7a6d88')}},
 'ns': 'tenantMigrationTenantId_test.distinct_multikey'}

Additionally I added a pretty printer to interpret WT_UPDATE values (their data field) as bson payloads:

(gdb) print *(WT_UPDATE*)0x7fbfffa63920
$1 = WT_UPDATE: 
  ('txnid', '2486')
  ('durable_ts', '6964747752064417812')
  ('start_ts', '6964747752064417812')
  ('prev_durable_ts', '0')
  ('next', '0x7fbfffa6c4a0')
  ('size', '1023')
  ('type', "3 '\\003'")
  ('prepare_state', "0 '\\000'")
  ('flags', "0 '\\000'")
  ('data', '0x7fbfffa6394f "\\377\\003"') = {
  [md] = {"ns": "tenantMigrationTenantId_test.distinct_multikey", "options": {"uuid": {"$uuid": "5a441857cd834b5f9f96c6d24f7a6d88"}}, "indexes": [{"spec": {"v": 2, "key": {"_id": 1}, "name": "_id_"}, "ready": true, "multikey": false, "multikeyPaths": {"_id": {"$binary": "AA==", "$type": "00"}}, "head": 0, "backgroundSecondary": false}, {"spec": {"v": 2, "key": {"a.b.c": 1.0}, "name": "a.b.c_1"}, "ready": true, "multikey": true, "multikeyPaths": {"a.b.c": {"$binary": "AQEB", "$type": "00"}}, "head": 0, "backgroundSecondary": false}, {"spec": {"v": 2, "key": {"a.b": 1.0}, "name": "a.b_1"}, "ready": true, "multikey": true, "multikeyPaths": {"a.b": {"$binary": "AAE=", "$type": "00"}}, "head": 0, "backgroundSecondary": false}, {"spec": {"v": 2, "key": {"a.b.0": 1.0}, "name": "a.b.0_1"}, "ready": true, "multikey": false, "multikeyPaths": {"a.b.0": {"$binary": "AAAA", "$type": "00"}}, "head": 0, "backgroundSecondary": false}]},
  [idxIdent] = {"_id_": "index-362-5113077617502034514", "a.b.c_1": "index-363-5113077617502034514", "a.b_1": "index-364-5113077617502034514", "a.b.0_1": "index-365-5113077617502034514"},
  [ns] = "tenantMigrationTenantId_test.distinct_multikey",
  [ident] = "collection-361-5113077617502034514"
}



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 01/Jun/21 ]

Author:

{'name': 'Daniel Gottlieb', 'email': 'daniel.gottlieb@mongodb.com', 'username': 'dgottlieb'}

Message: SERVER-57326: Add bson data gdb pretty printer function.
Branch: master
https://github.com/mongodb/mongo/commit/87e10cc39920a7aff6283820686de312d4527df8

Generated at Thu Feb 08 05:41:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.