tools/gdb: fix type and comments

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu 2024-11-20 14:47:04 +08:00 committed by Xiang Xiao
parent cd78de7c63
commit 1518f8bdb8
5 changed files with 19 additions and 11 deletions

View file

@ -1,6 +1,8 @@
############################################################################
# tools/gdb/macros.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
@ -26,14 +28,14 @@
# then parse and evaluate it by ourselves.
#
# There might be two ways to achieve this, one is to leverage the C preprocessor
# to directly preprocess all the macros instereted into python constants
# to directly preprocess all the macros interpreted into python constants
# gcc -E -x c -P <file_with_macros> -I/path/to/nuttx/include
#
# While the other way is to leverage the dwarf info stored in the ELF file,
# with -g3 switch, we have a `.debug_macro` section containing all the information
# about the macros.
#
# Currently, we using the second method.
# Currently, we are using the second method.
import os
import re
@ -184,9 +186,9 @@ def do_expand(expr, macro_map):
# NOTE: Implement a fully functional parser which can
# preprocessing all the C marcos according to ISO 9899 standard
# preprocess all the C macros according to ISO 9899 standard
# may be an overkill, what we really care about are those
# macros that can be evaluted to an constant value.
# macros that can be evaluated to a constant value.
#
# #define A (B + C + D)
# #define B 1
@ -202,7 +204,7 @@ def do_expand(expr, macro_map):
# use case for it in our GDB plugin.
#
# However, you can switch to the correct stack frame that has this macro defined
# and let GDB expand and evaluate it for you if you really want to evalue some very
# and let GDB expand and evaluate it for you if you really want to evaluate some very
# complex macros.

View file

@ -1,6 +1,8 @@
############################################################################
# tools/gdb/memdump.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
@ -469,7 +471,7 @@ class Memdump(gdb.Command):
return
title_dict = {
PID_MM_ALLOC: "Dump all used memory node info, use '\x1b[33;1m*\x1b[m' mark pid is not exist:\n",
PID_MM_ALLOC: "Dump all used memory node info, use '\x1b[33;1m*\x1b[m' mark pid does not exist:\n",
PID_MM_FREE: "Dump all free memory node info:\n",
PID_MM_BIGGEST: f"Dump biggest allocated top {biggest_top}\n",
PID_MM_ORPHAN: "Dump allocated orphan nodes\n",
@ -789,10 +791,10 @@ class Memleak(gdb.Command):
gdb.write("\n")
if len(white_dict) == 0:
gdb.write("All node have references, no memory leak!\n")
gdb.write("All nodes have references, no memory leak!\n")
return
gdb.write("Leak catch!, use '\x1b[33;1m*\x1b[m' mark pid is not exist:\n")
gdb.write("Leak catch!, use '\x1b[33;1m*\x1b[m' mark pid does not exist:\n")
if CONFIG_MM_BACKTRACE > 0 and not arg["detail"]:
gdb.write("%6s" % ("CNT"))

View file

@ -143,7 +143,7 @@ def fetch_stacks():
)
except gdb.GdbError as e:
gdb.write(f"Failed to construction stack object for tcb: {e}")
gdb.write(f"Failed to construct stack object for tcb: {e}")
return stacks

View file

@ -1,6 +1,8 @@
############################################################################
# tools/gdb/thread.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

View file

@ -1,6 +1,8 @@
############################################################################
# tools/gdb/utils.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
@ -323,7 +325,7 @@ target_arch = None
def is_target_arch(arch, exact=False):
"""
For non exactly match, this function will
For non extact match, this function will
return True if the target architecture contains
keywords of an ARCH family. For example, x86 is
contained in i386:x86_64.
@ -410,7 +412,7 @@ def get_arch_pc_name():
def get_register_byname(regname, tcb=None):
frame = gdb.selected_frame()
# If no tcb is given then we can directly used the register from
# If no tcb is given then we can directly use the register from
# the cached frame by GDB
if not tcb:
return int(frame.read_register(regname))