-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDB Plugin Upgrade part3: fs related tools #14854
base: master
Are you sure you want to change the base?
Conversation
support mount command in gdb, print mount information test result: /bin type binfs /data type hostfs /etc type romfs /proc type procfs /resource type hostfs /tmp type tmpfs Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
go through each inode and print its structure info in the form like below: ├── i_name: bin, i_ino: 51 │ i_parent: , i_peer: data, i_child: , i_crefs: 1, i_flags: 3 │ ......(other info) │ ├── i_name: audio, i_ino: 5 │ │ i_parent: dev, i_peer: binder, i_child: mixer...... Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
Execute fdinfo or fdinfo -p pid. (gdb) fdinfo PID: 0 FD OFLAGS POS PATH BACKTRACE 0 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105 0x402888f8 <file_allocate_from_tcb+236> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:615 0x402979d0 <nx_vopen+104> /home/neo/projects/vela2/nuttx/fs/vfs/fs_open.c:326 0x40297ad4 <nx_open+116> /home/neo/projects/vela2/nuttx/fs/vfs/fs_open.c:449 0x40291eb4 <group_setupidlefiles+28> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:75 0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651 0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205 1 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105 0x40289574 <file_dup3+248> /home/neo/projects/vela2/nuttx/fs/vfs/fs_dup2.c:177 0x40288b88 <nx_dup3_from_tcb+176> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:314 0x40288c64 <nx_dup2_from_tcb+16> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:901 0x40288c88 <nx_dup2+28> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:924 0x40291ec4 <group_setupidlefiles+44> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:84 0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651 0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205 2 3 0 /dev/console 0x4028ff0c <sched_backtrace+48> /home/neo/projects/vela2/nuttx/sched/sched/sched_backtrace.c:105 0x40289574 <file_dup3+248> /home/neo/projects/vela2/nuttx/fs/vfs/fs_dup2.c:177 0x40288b88 <nx_dup3_from_tcb+176> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:314 0x40288c64 <nx_dup2_from_tcb+16> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:901 0x40288c88 <nx_dup2+28> /home/neo/projects/vela2/nuttx/fs/inode/fs_files.c:924 0x40291ed0 <group_setupidlefiles+56> /home/neo/projects/vela2/nuttx/sched/group/group_setupidlefiles.c:117 0x4028df94 <nx_start+628> /home/neo/projects/vela2/nuttx/sched/init/nx_start.c:651 0x4028119c <arm64_boot_primary_c_routine+16> /home/neo/projects/vela2/nuttx/arch/arm64/src/common/arm64_boot.c:205 Signed-off-by: yangao1 <yangao1@xiaomi.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
(gdb) info shm /var/shm/xms:bq-325-1044165565 memsize: 1536000, paddr: 0x41de3970 /var/shm/xms:bq-325-2123092606 memsize: 1536000, paddr: 0x41f5a9a8 /var/shm/xms:fakemq-325-1835096569 memsize: 12, paddr: 0x420d19e0 (gdb) Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
@XuNeo please update https://nuttx.apache.org/docs/latest/guides/gdbwithpython.html with all the steps you put here. The current "guide" is not useful and point to an external doc that will know fit to NuttX details. |
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# to directly preprocess all the macros instereted into python constants | |
# to directly preprocess all the macros inserted into python constants |
# with -g3 switch, we have a `.debug_macro` section containing all the information | ||
# about the macros. | ||
# | ||
# Currently, we using the second method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Currently, we using the second method. | |
# Currently, we are using the second method. |
|
||
|
||
# NOTE: Implement a fully functional parser which can | ||
# preprocessing all the C marcos according to ISO 9899 standard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# preprocessing all the C marcos according to ISO 9899 standard | |
# preprocess all the C macros according to ISO 9899 standard |
# NOTE: Implement a fully functional parser which can | ||
# preprocessing all the C marcos 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# macros that can be evaluted to an constant value. | |
# macros that can be evaluated to a constant value. |
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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 |
|
||
|
||
def get_symbol_value(name, locspec="nx_start", cacheable=True): | ||
"""Return the value of a symbol value etc: Variable, Marco""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Return the value of a symbol value etc: Variable, Marco""" | |
"""Return the value of a symbol value etc: Variable, Macro""" |
"""Return True if the target architecture is ARCH""" | ||
def is_target_arch(arch, exact=False): | ||
""" | ||
For non exactly match, this function will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non exactly match, this function will | |
For non exact match, this function will |
Note: Please adhere to Contributing Guidelines.
Summary
In this PR, we introduces several fs related tools.
This PR is based on part1/2 to minimize conflicts. I'll rebase once they are merged. For now please review commits by commits.
New tools added:
foreach_inode
print all the inode and its informationfdinfo
print all the file opened in each taskinfo shm
show the share memory usageAlso included an performance optimization that use generate instead of list where possible.
Impact
New feature added.
Testing
Tested on qemu arm64(info shm is not available because it's disabled).