Skip to content

Commit 34df8e8

Browse files
committed
Fix display of OperationContext associated with mongo::Locker.
Also fixes an issue where AbslFlatHashSetPrinter was being used where AbslNodeHashSetPrinter had been intended. This wasn't causing a functional issue because GDB would still dereference the pointer when accessing data members of the mongo::Client class.
1 parent 289635b commit 34df8e8

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

CHANGELOG.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
0.15.0 (2024-04-29)
5+
-------------------
6+
7+
* Support dumping LockManager from core dump of MongoDB 8.0.
8+
49
0.14.0 (2023-09-30)
510
-------------------
611

gdbmongo/lock_manager_printer.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from gdbmongo import stdlib_printers, stdlib_xmethods
3434
from gdbmongo.abseil_printers import (AbslFlatHashMapPrinter, AbslNodeHashMapPrinter,
35-
AbslFlatHashSetPrinter)
35+
AbslFlatHashSetPrinter, AbslNodeHashSetPrinter)
3636
from gdbmongo.decorable_printer import DecorationIterator
3737
from gdbmongo.gdbutil import gdb_is_libthread_db_loaded, gdb_lookup_value
3838
from gdbmongo.printer_protocol import (PrettyPrinterProtocol, SupportsChildren, SupportsDisplayHint,
@@ -386,6 +386,22 @@ def __bool__(self) -> bool:
386386
return self.val["_front"] != 0
387387

388388

389+
# pylint: disable-next=invalid-name
390+
def ServiceContextClientsListIterator(service_context: gdb.Value, /) -> typing.Iterator[gdb.Value]:
391+
"""Return a generator of every mongo::Client* in the given mongo::ServiceContext."""
392+
try:
393+
gdb.lookup_type("mongo::ServiceContext::ClientMap")
394+
except gdb.error as err:
395+
if not err.args[0].startswith("No type named "):
396+
raise
397+
398+
for (_, client) in AbslNodeHashSetPrinter(service_context["_clients"]).children():
399+
yield client
400+
else:
401+
for (client, _) in AbslNodeHashMapPrinter(service_context["_clients"]).items():
402+
yield client
403+
404+
389405
# pylint: disable-next=too-few-public-methods
390406
class LockRequestPrinter(SupportsChildren):
391407
# pylint: disable=missing-function-docstring
@@ -509,7 +525,7 @@ def _populate_cached_operation_contexts(cls) -> None:
509525

510526
cached_operation_contexts: typing.Dict[int, gdb.Value] = {}
511527

512-
for (_, client) in AbslFlatHashSetPrinter(service_context["_clients"]).children():
528+
for client in ServiceContextClientsListIterator(service_context):
513529
if (operation_context := client["_opCtx"]) != 0:
514530
locker = operation_context["_locker"]
515531

0 commit comments

Comments
 (0)