diff --git a/tools/gdb/nuttxgdb/__init__.py b/tools/gdb/nuttxgdb/__init__.py index 68e62541270..48fba48c0d2 100644 --- a/tools/gdb/nuttxgdb/__init__.py +++ b/tools/gdb/nuttxgdb/__init__.py @@ -47,18 +47,21 @@ def register_commands(event): gdb.execute('handle SIGUSR1 "nostop" "pass" "noprint"') gdb.write('"handle SIGUSR1 "nostop" "pass" "noprint"\n') - # Register all modules - for m in modules: - if m == "__init__": - continue - + def init_gdb_commands(m: str): module = importlib.import_module(f"{__package__}.{m}") - - # Get all classes inherited from gdb.Command for c in module.__dict__.values(): if isinstance(c, type) and issubclass(c, gdb.Command): c() + # Register prefix commands firstly + init_gdb_commands("prefix") + modules.remove("prefix") + modules.remove("__init__") + + # Register all other modules + for m in modules: + init_gdb_commands(m) + utils = importlib.import_module(f"{__package__}.utils") utils.check_version() diff --git a/tools/gdb/nuttxgdb/fs.py b/tools/gdb/nuttxgdb/fs.py index 19ba4bf849f..a82ab25cb72 100644 --- a/tools/gdb/nuttxgdb/fs.py +++ b/tools/gdb/nuttxgdb/fs.py @@ -241,7 +241,7 @@ class ForeachInode(gdb.Command): """Dump each inode info""" def __init__(self): - super().__init__("foreach_inode", gdb.COMMAND_USER) + super().__init__("foreach inode", gdb.COMMAND_USER) self.level = 4096 def get_root_inode(self, addr_or_expr): @@ -253,7 +253,7 @@ class ForeachInode(gdb.Command): return utils.gdb_eval_or_none(addr_or_expr) def parse_arguments(self, argv): - parser = argparse.ArgumentParser(description="foreach_inode command") + parser = argparse.ArgumentParser(description="foreach inode command") parser.add_argument( "-L", "--level", diff --git a/tools/gdb/nuttxgdb/lists.py b/tools/gdb/nuttxgdb/lists.py index 5cde4685904..b96cdb6ea97 100644 --- a/tools/gdb/nuttxgdb/lists.py +++ b/tools/gdb/nuttxgdb/lists.py @@ -293,9 +293,7 @@ class ForeachListEntry(gdb.Command): """Dump list members for a given list""" def __init__(self): - super().__init__( - "foreach_list_entry", gdb.COMMAND_DATA, gdb.COMPLETE_EXPRESSION - ) + super().__init__("foreach list", gdb.COMMAND_DATA, gdb.COMPLETE_EXPRESSION) def invoke(self, arg, from_tty): argv = gdb.string_to_argv(arg) diff --git a/tools/gdb/nuttxgdb/prefix.py b/tools/gdb/nuttxgdb/prefix.py new file mode 100644 index 00000000000..2f135acbf0c --- /dev/null +++ b/tools/gdb/nuttxgdb/prefix.py @@ -0,0 +1,30 @@ +############################################################################ +# tools/gdb/nuttx_gdb/prefix.py +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +import gdb + + +class ForeachPrefix(gdb.Command): + """foreach commands prefix.""" + + def __init__(self): + super(ForeachPrefix, self).__init__("foreach", gdb.COMMAND_USER, prefix=True)