From 69bec87a91ce4e29c87da6d0b33f554d1dfd0aa8 Mon Sep 17 00:00:00 2001 From: Mike Gerdts Date: Fri, 16 Dec 2022 14:02:50 -0600 Subject: [PATCH] scripts: gdb macros should allow missing symbols When gdb_macros.py is used with unit tests some of the globals it expects are not present. This commit handles the relevant exceptions so a missing symbol does not prevent the use of macros that are initialized later. Signed-off-by: Mike Gerdts Change-Id: Ic81f0dfa705839c9a03fb76e934684716b710390 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15999 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- scripts/gdb_macros.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/gdb_macros.py b/scripts/gdb_macros.py index 8c9f0c9ae..ee2d13a22 100644 --- a/scripts/gdb_macros.py +++ b/scripts/gdb_macros.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (C) 2019 Intel Corporation. +# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # import gdb @@ -126,7 +127,11 @@ class IoDevices(SpdkRbTree): class spdk_print_io_devices(SpdkPrintCommand): def __init__(self): - io_devices = IoDevices() + try: + io_devices = IoDevices() + except RuntimeError as e: + print("Cannot load IO devices: " + str(e)) + return name = 'spdk_print_io_devices' super(spdk_print_io_devices, self).__init__(name, io_devices) @@ -147,7 +152,11 @@ class spdk_print_bdevs(SpdkPrintCommand): name = 'spdk_print_bdevs' def __init__(self): - bdevs = BdevMgrBdevs() + try: + bdevs = BdevMgrBdevs() + except RuntimeError as e: + print("Cannot load bdevs: " + str(e)) + return super(spdk_print_bdevs, self).__init__(self.name, bdevs) @@ -210,7 +219,11 @@ class SpdkNvmfTgtSubsystems(SpdkArr): return int(self.spdk_nvmf_tgt['opts']['max_subsystems']) def __init__(self): - self.spdk_nvmf_tgt = gdb.parse_and_eval("g_spdk_nvmf_tgt") + try: + self.spdk_nvmf_tgt = gdb.parse_and_eval("g_spdk_nvmf_tgt") + except RuntimeError as e: + print("Cannot load nvmf target subsystems: " + str(e)) + return subsystems = gdb.parse_and_eval("g_spdk_nvmf_tgt->subsystems") super(SpdkNvmfTgtSubsystems, self).__init__(subsystems, self.get_num_subsystems(),