weixin_39548438
weixin_39548438
2020-12-30 00:26

tools: Add .nuttx-gdbinit for nuttx thread debugging

Summary

  • This commit enables nuttx thread debugging without openocd-nuttx
  • To use this script, gdb must support python
  • To show all thread, use 'info_nxthreads'
  • To switch thread, use 'nxthread pid'
  • To continue, use 'nxcontinue'

Impact

  • No impact

Testing

  • Tested with spresense (Cortex-M4F), sim (x86_64), lm3s6965-ek (Cortex-M3) with qemu
  • Tested with GNU Tools for Arm Embedded Processors 9-2019-q4-major
  • Tested with GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

该提问来源于开源项目:apache/incubator-nuttx

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

11条回答

  • weixin_39519769 weixin_39519769 3月前

    LGTM

    点赞 评论 复制链接分享
  • weixin_39716088 weixin_39716088 3月前

    Great, thanks! I will try it next time I need to debug NuttX. By the way, wouldn't it be better to not use '.' in the name? Otherwise no one will know of its existence unless they go looking for hidden files.

    点赞 评论 复制链接分享
  • weixin_39731586 weixin_39731586 3月前

    Thanks for this. I will test on SAMA5 today.

    点赞 评论 复制链接分享
  • weixin_39657094 weixin_39657094 3月前

    Great, thanks! I will try it next time I need to debug NuttX. By the way, wouldn't it be better to not use '.' in the name? Otherwise no one will know of its existence unless they go looking for hidden files.

    +1 it is better to keep it as "nuttx-gdbinit" and include comments instructions at the header to copy it to ~/.gdbinit to get it loaded automatically to debug the NuttX.

    点赞 评论 复制链接分享
  • weixin_39548438 weixin_39548438 3月前

    Great, thanks! I will try it next time I need to debug NuttX. By the way, wouldn't it be better to not use '.' in the name? Otherwise no one will know of its existence unless they go looking for hidden files.

    +1 it is better to keep it as "nuttx-gdbinit" and include comments instructions at the header to copy it to ~/.gdbinit to get it loaded automatically to debug the NuttX.

    Hi, ,

    Thanks for your feedback.

    The reason why I choose the name '.nuttx-gdbinit' instead of 'nuttex-gdbinit' is that the Emacs understand gdb scripts by the following rules.

    
    ;;; gud.el --- Grand Unified Debugger mode for running GDB and other debuggers
    ...
    ...
    ;; Besides .gdbinit, gdb documents other names to be usable for init
    ;; files, cross-debuggers can use something like
    ;; .PROCESSORNAME-gdbinit so that the host and target gdbinit files
    ;; don't interfere with each other.
    ;;;###autoload
    (add-to-list 'auto-mode-alist '("/\\.[a-z0-9-]*gdbinit" . gdb-script-mode))
    

    Of course, we can add a new rule to our .emacs to let the Emacs know that 'nuttx-gdbinit' is a gdb script. But I thought we should conform to the default rules.

    Another reason why I do not want to copy '.nuttx-gdbinit' to .gdbinit is that I do not modify existing .gdbinit. Actually, they can coexist. So, please try the script with your own .gdbinit.

    点赞 评论 复制链接分享
  • weixin_39716088 weixin_39716088 3月前

    I'd prefer to create a local symbolic link from .nuttx-gdbinit to tools/nuttx-gdbinit if needed, so that is easier to discover.

    点赞 评论 复制链接分享
  • weixin_39548438 weixin_39548438 3月前

    Hi ,

    Should I rename .nuttx-gdbinit to nuttx-gdbinit so that it can be merged?

    点赞 评论 复制链接分享
  • weixin_39716088 weixin_39716088 3月前

    Yes, I think it is preferable.

    点赞 评论 复制链接分享
  • weixin_39548438 weixin_39548438 3月前

    Yes, I think it is preferable.

    OK. I will rename the file name and push it later.

    点赞 评论 复制链接分享
  • weixin_39548438 weixin_39548438 3月前

    I pushed the file with -f.

    点赞 评论 复制链接分享
  • weixin_39657094 weixin_39657094 3月前

    Hi ,

    Should I rename .nuttx-gdbinit to nuttx-gdbinit so that it can be merged?

    Thank you

    点赞 评论 复制链接分享