Skip to content

Commit

Permalink
[VelaBT Gdb] Added script to show all BT commands help usage info.
Browse files Browse the repository at this point in the history
bug: V/46055

Example:
(gdb) bthelp

========================================
Help for command: btsocket
========================================
usage: [-h] [-s] [-c] [-d] [-t {scan}]

Command to traverse socket lists and print IPC server/client msg_queue lengths.

options:
  -h, --help            show this help message and exit
  -s, --server          Traverse g_instances_list for server.
  -c, --client          Traverse g_bt_ins for client.
  -d, --detail          Show detailed packet information.
  -t {scan}, --type {scan}
                        Specify the packet type to process (e.g., 'scan', 'gatt', 'state').

========================================
Help for command: btdev
========================================
usage: [-h] -t {le,br}

Command to traverse device lists and print detailed device information.

options: -h, --help            show this help message and exit
  -t {le,br}, --type {le,br}
                        Specify the device type to traverse (e.g., 'le' for BLE, 'br' for BR/EDR).
Signed-off-by: zhongzhijie1 <[email protected]>
  • Loading branch information
jxqnzzj committed Dec 23, 2024
1 parent 9d6b39c commit ace375c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tools/gdb/btdiag_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,32 @@
gdb.write(f"Failed to source module {module_path}: {e}\n")
else:
gdb.write(f"Module not found: {module_path}\n")


# Register the bthelp command in GDB
class BtHelpCommand(gdb.Command):
"""Custom command to show help information for Bluetooth-related GDB commands."""

def __init__(self):
super(BtHelpCommand, self).__init__("bthelp", gdb.COMMAND_SUPPORT)

def invoke(self, arg, from_tty):
# Iterate through the modules and execute the help command for each
for module_name in modules_to_register:
command_name = module_name.split(".")[
-1
] # Extract the command name from module name
try:
# Print a divider for each command
gdb.write(f"\n{'=' * 40}\n")
gdb.write(f"Help for command: {command_name}\n")
gdb.write(f"{'=' * 40}\n")

# Execute the help command for each registered module
gdb.execute(f"{command_name} -h")
except gdb.error as e:
gdb.write(f"Failed to execute help for {command_name}: {e}\n")


# Instantiate the bthelp command
BtHelpCommand()

0 comments on commit ace375c

Please sign in to comment.