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

nuttxgdb utils module update #14912

Merged
merged 19 commits into from
Nov 23, 2024
Merged

Commits on Nov 23, 2024

  1. gdb/macro: fix cached macro info is outdated

    Use the file hash instead to avoid file name conflicts
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    b40b07b View commit details
    Browse the repository at this point in the history
  2. tools/gdb: fix elf file with special character

    Make sure file name is surrounded by \"
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    ee82d46 View commit details
    Browse the repository at this point in the history
  3. gdb/macro: cache macro info to json and load directly

    Use json module to save macro info to json file and load directly. It can save 2seconds for x4b projects to load plugin
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    390d48e View commit details
    Browse the repository at this point in the history
  4. nuttxgdb: fix container_of pointer offset calc problem

    Signed-off-by: buxiasen <[email protected]>
    jasonbu authored and XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    21defc8 View commit details
    Browse the repository at this point in the history
  5. tools/gdb: Allow utils.container_of with str input

    After we introduced NxDQueue and NxSQueue, we're using them like `NxDQueue(g_active_connections, "struct socket_conn_s", "node")` and leads to `utils.container_of(ptr, str, str)`, so maybe we need to allow str input for `utils.container_of`
    
    Signed-off-by: Zhe Weng <[email protected]>
    wengzhe authored and XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    6f355f9 View commit details
    Browse the repository at this point in the history
  6. tools/gdb: Use ptr's value instead of ptr's adderess in container_of

    We're using `ptr.cast(get_long_type())` a week ago to get the pointer's value, it's alright, but `ptr.address` is not, the `ptr.address` will return **the address of the pointer**.
    
    These values are the address of first element in the queue:
        - `int(g_sigfreeaction["head"])`
        - `g_sigfreeaction["head"].cast(get_long_type())`
        - `g_sigfreeaction["head"].dereference().address`
    But:
        `int(g_sigfreeaction["head"].address)` is the address of the "head" member, which equals to the address of `g_sigfreeaction`
    
    It's happening in NxSQueue:
        g_sigfreeaction = gdb.parse_and_eval("g_sigfreeaction")
        print(["%x" % (node) for node in NxSQueue(g_sigfreeaction)])
        print(["%x" % (node) for node in NxSQueue(g_sigfreeaction, "sigactq_t", "flink")])
    Without this patch:
        ['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
        ['55db90a0', 'f3c0aa10', 'f3c0aa2c']
    With this patch:
        ['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
        ['f3c0aa10', 'f3c0aa2c', 'f3c0aa48']
    
    Signed-off-by: Zhe Weng <[email protected]>
    wengzhe authored and XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    b89d64e View commit details
    Browse the repository at this point in the history
  7. tools/gdb: add array iterator

    Use array iterator where possible.
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    b4784d1 View commit details
    Browse the repository at this point in the history
  8. tools/gdb: add utils.get_tid(tcb)

    Signed-off-by: huangyin5 <[email protected]>
    huangyin5 authored and XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    63f8683 View commit details
    Browse the repository at this point in the history
  9. tools/gdb: decode backtrace of crashlog

    Now crash log can be directly pass to addr2line tool to get all backtraces.
    
    E.g.
    (gdb) addr2line -f crash.log -p 485
    Address              Symbol                           Source
    
    Backtrace of 485
    0x402cc0ac           <up_switch_context+84>           /home/work/ssd1/workspace/MiRTOS-X4b-Stable-Build/nuttx/include/arch/syscall.h:179
    0x40291276           <nxsig_timedwait+386>            signal/sig_timedwait.c:365
    0x4028fc7e           <nxsig_nanosleep+106>            signal/sig_nanosleep.c:141
    0x4028fdba           <clock_nanosleep+26>             signal/sig_nanosleep.c:333
    0x402c3736           <usleep+62>                      unistd/lib_usleep.c:108
    0x415018c0           <cs2p2p_mSecSleep+24>            Src/PPPP_Common.c:1139
    0x414fabde           <cs2p2p_Run_send_DRW+258>        Src/PPPP_API.c:5577
    0x414fac62           <cs2p2p_PPPP_thread_send_DRW+18> Src/PPPP_API.c:5616
    0x40446f62           <pthread_startup+10>             pthread/pthread_create.c:59
    0x41094f4a           <pthread_start+106>              pthread/pthread_create.c:139
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    df822c7 View commit details
    Browse the repository at this point in the history
  10. tools/gdb: support string type in offset_of

    1. Support any type of value as pointer address in container_of
    2. Support string as type in offset_of
    3. Make sure type is a pointer in container_of, and not a pointer in
       offset_of
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    cb8a737 View commit details
    Browse the repository at this point in the history
  11. nuttxgdb/utils.py:add ArrayIterator reverse iterate.

    Signed-off-by: yangao1 <[email protected]>
    yangao1 authored and XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    d13931f View commit details
    Browse the repository at this point in the history
  12. tools/gdb: fix hexdump expression parse

    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    bfd8e67 View commit details
    Browse the repository at this point in the history
  13. tools/gdb: add function to convert C enum to python Enum class

    Usage:
    (gdb) py NX_INITSTATE = utils.enum("enum nx_initstate_e")
    (gdb) py print(list(NX_INITSTATE))
    [<NX_INITSTATE_E.POWERUP: 0>, <NX_INITSTATE_E.BOOT: 1>, <NX_INITSTATE_E.TASKLISTS: 2>, <NX_INITSTATE_E.MEMORY: 3>, <NX_INITSTATE_E.HARDWARE: 4>, <NX_INITSTATE_E.OSREADY: 5>, <NX_INITSTATE_E.IDLELOOP: 6>, <NX_INITSTATE_E.PANIC: 7>]
    (gdb) py print(NX_INITSTATE.POWERUP)
    NX_INITSTATE_E.POWERUP
    (gdb) py print(NX_INITSTATE.POWERUP.value)
    0
    (gdb) py print(NX_INITSTATE(1))
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    0947bc6 View commit details
    Browse the repository at this point in the history
  14. gdb: add sizeof helper

    Signed-off-by: Xu Xingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    b6b9ae5 View commit details
    Browse the repository at this point in the history
  15. gdb: move profiling commands to profile.py

    Add simple time command to test time cost of a command.
    Usage:
    (gdb) time memleak
    ...
    (gdb) Time elapsed: 1.23456s
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    f2bab72 View commit details
    Browse the repository at this point in the history
  16. gdb/register: register name sp, pc are always available

    GDB provides four “standard” register names sp, pc, fp and ps. Those can be used in most of the cases.
    
    See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Registers.html
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    a3ba96e View commit details
    Browse the repository at this point in the history
  17. gdb/backtrace: optimize backtrace formatting

    Use a class Bactrace to support convert address to backtrace, format to string, accessing element and iterate though them.
    Adjust usage in fs and addr2line to make full use of it.
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    15a9d53 View commit details
    Browse the repository at this point in the history
  18. gdb/utils: cache backtrace result for better performance

    GDB is slow to look up symbols, cache the result to speed up commands like memdump etc.
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    86d7419 View commit details
    Browse the repository at this point in the history
  19. tools/gdb: improve nxgcore speed

    Let GDB to read from ELF for readonly data.
    Disable this feature by nxgcore --no-trust-readonly.
    
    Signed-off-by: xuxingliang <[email protected]>
    XuNeo committed Nov 23, 2024
    Configuration menu
    Copy the full SHA
    41c88d9 View commit details
    Browse the repository at this point in the history