Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57326

Add GDB pretty printer support for bson given a process memory address

    • Fully Compatible

      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"
      }
      

            Assignee:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: