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 <mgerdts@nvidia.com>
Change-Id: Ic81f0dfa705839c9a03fb76e934684716b710390
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15999
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Mike Gerdts 2022-12-16 14:02:50 -06:00 committed by Tomasz Zawadzki
parent 555ca7adc0
commit 69bec87a91

View File

@ -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(),