Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

XuNeo
Copy link
Contributor

@XuNeo XuNeo commented Nov 19, 2024

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:

  1. mount: similar to device side, mount lists all the mount point.
  2. foreach_inode print all the inode and its information
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......
  1. fdinfo print all the file opened in each task
(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
  1. info shm show the share memory usage
(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)

Also 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).

@github-actions github-actions bot added Area: Tooling Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Nov 19, 2024
Copy link

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.

@acassis
Copy link
Contributor

acassis commented Nov 19, 2024

@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.

tools/gdb/macros.py Outdated Show resolved Hide resolved
tools/gdb/macros.py Outdated Show resolved Hide resolved
tools/gdb/macros.py Outdated Show resolved Hide resolved
tools/gdb/macros.py Outdated Show resolved Hide resolved
tools/gdb/macros.py Outdated Show resolved Hide resolved


def get_symbol_value(name, locspec="nx_start", cacheable=True):
"""Return the value of a symbol value etc: Variable, Marco"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Return the value of a symbol value etc: Variable, Marco"""
"""Return the value of a symbol value etc: Variable, Macro"""

tools/gdb/utils.py Outdated Show resolved Hide resolved
zhengyu9 and others added 5 commits November 22, 2024 09:13
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
(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 <[email protected]>
@github-actions github-actions bot added Size: M The size of the change in this PR is medium and removed Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Nov 22, 2024
@XuNeo XuNeo marked this pull request as ready for review November 22, 2024 01:16
@XuNeo
Copy link
Contributor Author

XuNeo commented Nov 22, 2024

@acassis Hi Alan,

I'm going to update the docs after uploading all my features. Is that OK? There are some command usage will be slightly changed later.

For command usage, use help <command name> or <command> --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Tooling Size: M The size of the change in this PR is medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants