Documentation:add gdb python script documentation

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-07-24 18:23:21 +08:00 committed by Alan Carvalho de Assis
parent 0092b3e30f
commit 4745ab64c3

View File

@ -242,27 +242,29 @@ With gdb
You can also do NuttX aware debugging using ``gdb`` scripting support. You can also do NuttX aware debugging using ``gdb`` scripting support.
The benefit is that it works also for the sim build where ``openocd`` is The benefit is that it works also for the sim build where ``openocd`` is
not applicable. For this to work, you will need to enable PROC filesystem support not applicable. For this to work, you will need to enable PROC filesystem support
which will expose required task information (``CONFIG_FS_PROCFS=y``). which will expose required task information (``CONFIG_FS_PROCFS=y CONFIG_DEBUG_TCBINFO=y``).
To use this approach, you can load the ``nuttx/tools/nuttx-gdbinit`` file. An To use this approach, you can load the ``nuttx/tools/gdb/__init__.py`` file. An
easy way to do this is to create a symbolic link: easy way to do this is to add an extra command:
.. code-block:: console .. code-block:: console
$ cd $HOME $ gdb nuttx -ex "nuttx/tools/gdb/__init__.py"
$ ln -s nuttx/tools/nuttx-gdbinit .gdbinit
This way whenever gdb is started it will run the appropriate commands. To inspect gdb can need to set the current elf support architecture, for example,
the threads you can now use the following ``gdb`` command: the prefix is arm-ebai-none-.
.. code-block:: .. code-block::
(gdb) info_nxthreads (gdb) info threads
target examined Id Thread Info Frame
_target_arch.name=armv7e-m *0 Thread 0x20000398 (Name: Idle Task, State: Running, Priority: 0, Stack: 1000) 0x80001ac __start() at chip/stm32_start.c:111
$_target_has_fpu : 0 1 Thread 0x10000188 (Name: nsh_main, State: Waiting,Semaphore, Priority: 100, Stack: 2000) 0x800aa06 sys_call2() at /home/ajh/work/vela_all/nuttx/include/arch/syscall.h:187
$_target_has_smp : 0
saved current_tcb (pid=0)
* 0 Thread 0x20000308 (Name: Idle Task, State: Running, Priority: 0) 0xdc in __start()
1 Thread 0x20001480 (Name: init, State: Waiting,Semaphore, Priority: 100) 0x7e08 in arm_switchcontext()
The python script has extended many commands like ``thread <id>`` ,
``thread apply <all|id list> cmd``, ``nxsetargs`` etc.
You can use ``help <command>`` to get help.
Note that if you need to continue debugging after using the thread command,
please use ``c`` instead of ``continue``, because thread will force the register to be set,
and the `c` command will restore the register before conitune.