|
32 | 32 |
|
33 | 33 | from gdbmongo import stdlib_printers, stdlib_xmethods
|
34 | 34 | from gdbmongo.abseil_printers import (AbslFlatHashMapPrinter, AbslNodeHashMapPrinter,
|
35 |
| - AbslFlatHashSetPrinter) |
| 35 | + AbslFlatHashSetPrinter, AbslNodeHashSetPrinter) |
36 | 36 | from gdbmongo.decorable_printer import DecorationIterator
|
37 | 37 | from gdbmongo.gdbutil import gdb_is_libthread_db_loaded, gdb_lookup_value
|
38 | 38 | from gdbmongo.printer_protocol import (PrettyPrinterProtocol, SupportsChildren, SupportsDisplayHint,
|
@@ -386,6 +386,22 @@ def __bool__(self) -> bool:
|
386 | 386 | return self.val["_front"] != 0
|
387 | 387 |
|
388 | 388 |
|
| 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 | + |
389 | 405 | # pylint: disable-next=too-few-public-methods
|
390 | 406 | class LockRequestPrinter(SupportsChildren):
|
391 | 407 | # pylint: disable=missing-function-docstring
|
@@ -509,7 +525,7 @@ def _populate_cached_operation_contexts(cls) -> None:
|
509 | 525 |
|
510 | 526 | cached_operation_contexts: typing.Dict[int, gdb.Value] = {}
|
511 | 527 |
|
512 |
| - for (_, client) in AbslFlatHashSetPrinter(service_context["_clients"]).children(): |
| 528 | + for client in ServiceContextClientsListIterator(service_context): |
513 | 529 | if (operation_context := client["_opCtx"]) != 0:
|
514 | 530 | locker = operation_context["_locker"]
|
515 | 531 |
|
|
0 commit comments