doc: Add ESP-IDF GDB OpenOCD debugging plugin support

This commit is contained in:
Kondal Kolipaka 2023-05-09 19:31:56 +08:00
parent 38e84bdd4f
commit 62ef1a5b86
2 changed files with 93 additions and 63 deletions

View File

@ -2,13 +2,13 @@ Using Debugger
--------------
:link_to_translation:`zh_CN:[中文]`
This section covers configuration and running debugger using several methods:
This section covers the steps to configure and run a debugger using various methods, including:
* from :ref:`jtag-debugging-using-debugger-eclipse`
* from :ref:`jtag-debugging-using-debugger-command-line`
* using :ref:`jtag-debugging-with-idf-py`
* :ref:`jtag-debugging-using-debugger-eclipse`
* :ref:`jtag-debugging-using-debugger-command-line`
* :ref:`jtag-debugging-with-idf-py`
See also a separate document `Configuration for Visual Studio Code Debug <https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/DEBUGGING.md>`__ describing how to run a debugger from VS Code.
For how to run a debugger from VS Code, see `Configuration for Visual Studio Code Debug <https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/DEBUGGING.md>`__.
.. _jtag-debugging-using-debugger-eclipse:
@ -20,21 +20,35 @@ Eclipse
It is recommended to first check if debugger works using :ref:`jtag-debugging-with-idf-py` or from :ref:`jtag-debugging-using-debugger-command-line` and then move to using Eclipse.
Debugging functionality is provided out of box in standard Eclipse installation. Another option is to use pluggins like "GDB Hardware Debugging" plugin. We have found this plugin quite convenient and decided to use throughout this guide.
Eclipse is an integrated development environment (IDE) that provides a powerful set of tools for developing and debugging software applications. For ESP-IDF applications, `IDF Eclipse plugin <https://github.com/espressif/idf-eclipse-plugin>`_ provides two ways of debugging:
To begin with, install "GDB Hardware Debugging" plugin by opening Eclipse and going to `Help` > `Install` New Software.
1. `ESP-IDF GDB OpenOCD Debugging <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`_
2. GDB Hardware Debugging
Once installation is complete, configure debugging session following steps below. Please note that some of configuration parameters are generic and some are project specific. This will be shown below by configuring debugging for "blink" example project. If not done already, add this project to Eclipse workspace following guidance in `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md>`_. The source of :example:`get-started/blink` application is available in :idf:`examples` directory of ESP-IDF repository.
By default, Eclipse supports OpenOCD Debugging via the GDB Hardware Debugging plugin, which requires starting the OpenOCD server from the command line and configuring the GDB client from Eclipse to start with the debugging. This approach can be time-consuming and error-prone.
1. In Eclipse go to `Run` > `Debug Configuration`. A new window will open. In the window's left pane double click "GDB Hardware Debugging" (or select "GDB Hardware Debugging" and press the "New" button) to create a new configuration.
To make the debugging process easier, the IDF Eclipse plugin has a customized ESP-IDF GDB OpenOCD Debugging functionality. This functionality supports configuring the OpenOCD server and GDB client from within Eclipse. All the required configuration parameters will be pre-filled by the plugin, and you can start debugging with just a click of a button.
2. In a form that will show up on the right, enter the "Name:" of this configuration, e.g. "Blink checking".
Therefore, it is recommended to use the `ESP-IDF GDB OpenOCD Debugging <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`_ via the IDF Eclipse plugin.
3. On the "Main" tab below, under "Project:", press "Browse" button and select the "blink" project.
**GDB Hardware Debugging**
4. In next line "C/C++ Application:" press "Browse" button and select "blink.elf" file. If "blink.elf" is not there, then likely this project has not been build yet. See `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md>`_ how to do it.
.. note::
This approach is recommended only if you are unable to debug using `ESP-IDF GDB OpenOCD Debugging <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`_ for some reason.
5. Finally, under "Build (if required) before launching" click "Disable auto build".
To install the ``GDB Hardware Debugging`` plugin, open Eclipse and select ``Help`` > ``Install`` New Software.
After installation is complete, follow these steps to configure the debugging session. Please note that some configuration parameters are generic, while others are project-specific. This will be shown below by configuring debugging for "blink" example project. If not done already, add this project to Eclipse workspace following `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md>`_. The source of :example:`get-started/blink` application is available in :idf:`examples` directory of ESP-IDF repository.
1. In Eclipse, go to ``Run`` > ``Debug Configuration``. A new window will open. In the left pane of the window, double-click ``GDB Hardware Debugging`` (or select ``GDB Hardware Debugging`` and press the ``New`` button) to create a new configuration.
2. In a form that will show up on the right, enter the ``Name:`` of this configuration, e.g. "Blink checking".
3. On the ``Main`` tab below, under ``Project:``, press the ``Browse`` button and select the ``blink`` project.
4. In the next line under ``C/C++ Application:``, press the ``Browse`` button and select the ``blink.elf`` file. If ``blink.elf`` is not there, it is likely that this project has not been built yet. Refer to the `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md>`_ for instructions.
5. Finally, under ``Build (if required) before launching`` click ``Disable auto build``.
A sample window with settings entered in points 1 - 5 is shown below.
@ -45,9 +59,9 @@ Once installation is complete, configure debugging session following steps below
Configuration of GDB Hardware Debugging - Main tab
6. Click "Debugger" tab. In field "GDB Command" enter ``{IDF_TARGET_TOOLCHAIN_PREFIX}-gdb`` to invoke debugger.
6. Click the ``Debugger`` tab. In field ``GDB Command``, enter ``{IDF_TARGET_TOOLCHAIN_PREFIX}-gdb`` to invoke the debugger.
7. Change default configuration of "Remote host" by entering ``3333`` under the "Port number".
7. Change the default configuration of the ``Remote host`` by entering ``3333`` under the ``Port number``.
Configuration entered in points 6 and 7 is shown on the following picture.
@ -58,7 +72,7 @@ Once installation is complete, configure debugging session following steps below
Configuration of GDB Hardware Debugging - Debugger tab
8. The last tab to that requires changing of default configuration is "Startup". Under "Initialization Commands" uncheck "Reset and Delay (seconds)" and "Halt"". Then, in entry field below, enter the following lines:
8. The last tab that requires changing the default configuration is ``Startup``. Under ``Initialization Commands`` uncheck ``Reset and Delay (seconds)`` and ``Halt``. Then, in the entry field below, enter the following lines:
::
@ -67,18 +81,18 @@ Once installation is complete, configure debugging session following steps below
set remote hardware-watchpoint-limit 2
.. note::
If you want to update image in the flash automatically before starting new debug session add the following lines of commands at the beginning of "Initialization Commands" textbox::
To automatically update the image in the flash before starting a new debug session, add the following command lines to the beginning of the ``Initialization Commands`` textbox::
mon reset halt
mon program_esp ${workspace_loc:blink/build/blink.bin} 0x10000 verify
For description of ``program_esp`` command see :ref:`jtag-upload-app-debug`.
For description of ``program_esp`` command, see :ref:`jtag-upload-app-debug`.
9. Under "Load Image and Symbols" uncheck "Load image" option.
9. Uncheck the ``Load image`` option under ``Load Image and Symbols``.
10. Further down on the same tab, establish an initial breakpoint to halt CPUs after they are reset by debugger. The plugin will set this breakpoint at the beginning of the function entered under "Set break point at:". Checkout this option and enter ``app_main`` in provided field.
10. Further down on the same tab, establish an initial breakpoint to halt CPUs after they are reset by debugger. The plugin will set this breakpoint at the beginning of the function entered under ``Set break point at:``. Checkout this option and enter ``app_main`` in provided field.
11. Checkout "Resume" option. This will make the program to resume after ``mon reset halt`` is invoked per point 8. The program will then stop at breakpoint inserted at ``app_main``.
11. Checkout ``Resume`` option. This will make the program to resume after ``mon reset halt`` is invoked per point 8. The program will then stop at breakpoint inserted at ``app_main``.
Configuration described in points 8 - 11 is shown below.
@ -89,11 +103,11 @@ Once installation is complete, configure debugging session following steps below
Configuration of GDB Hardware Debugging - Startup tab
If the "Startup" sequence looks convoluted and respective "Initialization Commands" are not clear to you, check :ref:`jtag-debugging-tip-debugger-startup-commands` for additional explanation.
If the ``Startup`` sequence looks convoluted and respective ``Initialization Commands`` are unclear, check :ref:`jtag-debugging-tip-debugger-startup-commands` for additional explanation.
12. If you previously completed :ref:`jtag-debugging-configuring-target` steps described above, so the target is running and ready to talk to debugger, go right to debugging by pressing "Debug" button. Otherwise press "Apply" to save changes, go back to :ref:`jtag-debugging-configuring-target` and return here to start debugging.
12. If you have completed the :ref:`jtag-debugging-configuring-target` steps described above, so the target is running and ready to talk to debugger, go right to debugging by pressing ``Debug`` button. Otherwise press ``Apply`` to save changes, go back to :ref:`jtag-debugging-configuring-target` and return here to start debugging.
Once all 1 - 12 configuration steps are satisfied, the new Eclipse perspective called "Debug" will open as shown on example picture below.
Once all configuration steps 1-12 are satisfied, the new Eclipse perspective called "Debug" will open, as shown in the example picture below.
.. figure:: ../../../_static/debug-perspective.jpg
:align: center
@ -110,11 +124,11 @@ If you are not quite sure how to use GDB, check :ref:`jtag-debugging-examples-ec
Command Line
^^^^^^^^^^^^
1. Begin with completing steps described under :ref:`jtag-debugging-configuring-target`. This is prerequisite to start a debugging session.
1. Begin by completing the steps described under :ref:`jtag-debugging-configuring-target`. This is prerequisite to start a debugging session.
.. highlight:: bash
2. Open a new terminal session and go to directory that contains project for debugging, e.g.
2. Open a new terminal session and go to the directory that contains the project for debugging, e.g.
::
@ -122,7 +136,7 @@ Command Line
.. highlight:: none
3. When launching a debugger, you will need to provide couple of configuration parameters and commands. Instead of entering them one by one in command line, create a configuration file and name it ``gdbinit``:
3. When launching a debugger, you will need to provide a couple of configuration parameters and commands. Instead of entering them one by one in the command line, create a configuration file and name it ``gdbinit``:
::
@ -133,9 +147,9 @@ Command Line
thb app_main
c
Save this file in current directory.
Save this file in the current directory.
For more details what's inside ``gdbinit`` file, see :ref:`jtag-debugging-tip-debugger-startup-commands`
For more details on what's inside ``gdbinit`` file, see :ref:`jtag-debugging-tip-debugger-startup-commands`
.. highlight:: bash
@ -147,7 +161,7 @@ Command Line
.. highlight:: none
5. If previous steps have been done correctly, you will see a similar log concluded with ``(gdb)`` prompt:
5. If the previous steps have been done correctly, you will see a similar log concluded with the ``(gdb)`` prompt:
::
@ -194,9 +208,10 @@ Command Line
43 xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
(gdb)
Note the third line from bottom that shows debugger halting at breakpoint established in ``gdbinit`` file at function ``app_main()``. Since the processor is halted, the LED should not be blinking. If this is what you see as well, you are ready to start debugging.
If you are not quite sure how to use GDB, check :ref:`jtag-debugging-examples-command-line` example debugging session in section :ref:`jtag-debugging-examples`.
Note the third-to-last line, which shows debugger halting at breakpoint established in ``gdbinit`` file at function ``app_main()``. Since the processor is halted, the LED should not be blinking. If this is what you see as well, you are ready to start debugging.
If you are not sure how to use GDB, check :ref:`jtag-debugging-examples-command-line` example debugging session in section :ref:`jtag-debugging-examples`.
.. _jtag-debugging-with-idf-py:
@ -215,25 +230,25 @@ It is also possible to execute the described debugging tools conveniently from `
:start-after: idf-py-openocd-default-cfg
:end-before: ---
As for the JTAG configuration of the current board, please use the environmental variable ``OPENOCD_COMMANDS`` or ``--openocd-commands`` command line argument. If none of the above is defined, OpenOCD is started with |idf-py-def-cfg| board definition.
To configure the JTAG configuration for the current board, please use the environmental variable ``OPENOCD_COMMANDS`` or ``--openocd-commands`` command line argument. If none of the above is defined, OpenOCD is started with |idf-py-def-cfg| board definition.
2. ``idf.py gdb``
Starts the gdb the same way as the :ref:`jtag-debugging-using-debugger-command-line`, but generates the initial gdb scripts referring to the current project elf file.
Starts the GDB the same way as the :ref:`jtag-debugging-using-debugger-command-line`, but generates the initial GDB scripts referring to the current project elf file.
3. ``idf.py gdbtui``
The same as `2`, but starts the gdb with ``tui`` argument allowing very simple source code view.
The same as `2`, but starts the gdb with ``tui`` argument, allowing for a simple source code view.
4. ``idf.py gdbgui``
Starts `gdbgui <https://www.gdbgui.com>`_ debugger frontend enabling out-of-the-box debugging in a browser window. Please run the install script with the "--enable-gdbgui" argument in order to make this option supported, e.g. ``install.sh --enable-gdbgui``.
Starts `gdbgui <https://www.gdbgui.com>`_ debugger frontend enabling out-of-the-box debugging in a browser window. To enable this option, run the install script with the "--enable-gdbgui" argument, e.g. ``install.sh --enable-gdbgui``.
It is possible to combine these debugging actions on a single command line allowing convenient setup of blocking and non-blocking actions in one step. ``idf.py`` implements a simple logic to move the background actions (such as openocd) to the beginning and the interactive ones (such as gdb, monitor) to the end of the action list.
You can combine these debugging actions on a single command line, allowing for convenient setup of blocking and non-blocking actions in one step. ``idf.py`` implements a simple logic to move the background actions (such as openocd) to the beginning and the interactive ones (such as gdb, monitor) to the end of the action list.
An example of a very useful combination is::

View File

@ -18,23 +18,37 @@
.. note::
建议首先通过 :ref:`idf.py <jtag-debugging-with-idf-py>`:ref:`命令行 <jtag-debugging-using-debugger-command-line>` 检查调试器是否正常工作,然后再转到使用 :ref:`Eclipse <jtag-debugging-using-debugger-eclipse>` 平台。
建议首先通过 :ref:`idf.py <jtag-debugging-with-idf-py>`:ref:`命令行 <jtag-debugging-using-debugger-command-line>` 检查调试器是否正常工作,然后再转到使用 :ref:`Eclipse <jtag-debugging-using-debugger-eclipse>` 平台。
标准的 Eclipse 安装流程默认安装调试功能,另外您还可以使用插件来调试,比如 “GDB Hardware Debugging”。这个插件用起来非常方便本指南会详细介绍该插件的使用方法。
作为一款集成开发环境 (IDE)Eclipse 提供了一套强大的工具,用于开发和调试软件应用程序。对于 ESP-IDF 应用程序,`IDF Eclipse 插件 <https://github.com/espressif/idf-eclipse-plugin>`_ 提供了两种调试方式:
首先,打开 Eclipse 并转到 “Help” > “Install New Software” 来安装 “GDB Hardware Debugging” 插件。
1. `ESP-IDF GDB OpenOCD 调试 <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`_
2. GDB 硬件调试
默认情况下Eclipse 通过 GDB 硬件调试插件支持 OpenOCD 调试。该调试方式需要从命令行启动 OpenOCD 服务器,并在 Eclipse 中配置 GDB 客户端,整个过程耗时且容易出错。
为了使调试过程更加容易,`IDF Eclipse 插件 <https://github.com/espressif/idf-eclipse-plugin>`_ 提供了定制的 ESP-IDF GDB OpenOCD 调试功能,支持在 Eclipse 内部配置好 OpenOCD 服务器和 GDB 客户端。该插件已经设置好所有必需的配置参数,点击一个按钮即可开始调试。
因此,建议通过 `IDF Eclipse 插件 <https://github.com/espressif/idf-eclipse-plugin>`_ 进行 `ESP-IDF GDB OpenOCD 调试 <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`__
**GDB 硬件调试**
.. note::
只有在无法使用 `ESP-IDF GDB OpenOCD 调试 <https://github.com/espressif/idf-eclipse-plugin/blob/master/docs/OpenOCD%20Debugging.md#esp-idf-gdb-openocd-debugging>`_ 的情况下,才建议使用 GDB 硬件调试。
首先,打开 Eclipse选择 ``Help`` > ``Install New Software`` 来安装 ``GDB Hardware Debugging`` 插件。
安装完成后,按照以下步骤配置调试会话。请注意,一些配置参数是通用的,有些则针对特定项目。我们会通过配置 "blink" 示例项目的调试环境来进行展示,请先按照 `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README_CN.md>`_ 介绍的方法将该示例项目添加到 Eclipse 的工作空间。示例项目 :example:`get-started/blink` 的源代码可以在 ESP-IDF 仓库的 :idf:`examples` 目录下找到。
1. 在 Eclipse 中,进入 `Run` > `Debug Configuration`,会出现一个新的窗口。在窗口的左侧窗格中,双击 “GDB Hardware Debugging”(或者选择 “GDB Hardware Debugging” 然后按下 “New” 按钮)来新建一个配置。
1. 在 Eclipse 中,进入 ``Run`` > ``Debug Configuration``,会出现一个新的窗口。在窗口的左侧窗格中,双击 ``GDB Hardware Debugging``(或者选择 ``GDB Hardware Debugging`` 然后按下 ``New`` 按钮)来新建一个配置。
2. 在右边显示的表单中“Name:” 一栏中输入配置的名称,例如: “Blink checking”。
2. 在右边显示的表单中,``Name:`` 一栏中输入配置的名称,例如: “Blink checking”。
3. 在下面的 “Main” 选项卡中, 点击 “Project:” 边上的 “Browse” 按钮,然后选择当前的 “blink” 项目。
3. 在下面的 ``Main`` 选项卡中, 点击 ``Project:`` 边上的 ``Browse`` 按钮,然后选择当前的 ``blink`` 项目。
4. 在下一行的 “C/C++ Application:” 中,点击 “Browse” 按钮,选择 “blink.elf” 文件。如果 “blink.elf” 文件不存在,那么很有可能该项目还没有编译,请参考 `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README_CN.md>`_ 指南中的介绍。
4. 在下一行的 ``C/C++ Application:`` 中,点击 ``Browse`` 按钮,选择 ``blink.elf`` 文件。如果 ``blink.elf`` 文件不存在,那么很有可能该项目还没有编译,请参考 `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin/blob/master/README_CN.md>`_ 指南中的介绍。
5. 最后,在 “Build (if required) before launching” 下面点击 “Disable auto build”。
5. 最后,在 ``Build (if required) before launching`` 下面点击 ``Disable auto build``
上述步骤 1 - 5 的示例输入如下图所示。
@ -45,9 +59,9 @@
GDB 硬件调试的配置 - Main 选项卡
6. 点击 “Debugger” 选项卡,在 “GDB Command” 栏中输入 ``{IDF_TARGET_TOOLCHAIN_PREFIX}-gdb`` 来调用调试器。
6. 点击 ``Debugger`` 选项卡,在 ``GDB Command`` 栏中输入 ``{IDF_TARGET_TOOLCHAIN_PREFIX}-gdb`` 来调用调试器。
7. 更改 “Remote host” 的默认配置,在 “Port number” 下面输入 ``3333``
7. 更改 ``Remote host`` 的默认配置,在 ``Port number`` 下面输入 ``3333``
上述步骤 6 - 7 的示例输入如下图所示。
@ -58,7 +72,7 @@
GDB 硬件调试的配置 - Debugger 选项卡
8. 最后一个需要更改默认配置的选项卡是 “Startup” 选项卡。在 “Initialization Commands” 下,取消选中 “Reset and Delay (seconds)” 和 “Halt”然后在下面一栏中输入以下命令
8. 最后一个需要更改默认配置的选项卡是 ``Startup`` 选项卡。在 ``Initialization Commands`` 下,取消选中 ``Reset and Delay (seconds)````Halt``,然后在下面一栏中输入以下命令:
::
@ -67,18 +81,18 @@
set remote hardware-watchpoint-limit 2
.. note::
如果想在启动新的调试会话之前自动更新闪存中的镜像,请在 “Initialization Commands” 文本框的开头添加以下命令行::
如果想在启动新的调试会话之前自动更新闪存中的镜像,请在 ``Initialization Commands`` 文本框的开头添加以下命令行::
mon reset halt
mon program_esp ${workspace_loc:blink/build/blink.bin} 0x10000 verify
有关 ``program_esp`` 命令的说明请参考 :ref:`jtag-upload-app-debug` 章节。
9. 在 “Load Image and Symbols” 下,取消选中 “Load image” 选项。
9. 在 ``Load Image and Symbols`` 下,取消选中 ``Load image`` 选项。
10. 在同一个选项卡中继续往下浏览,建立一个初始断点用来在调试器复位后暂停 CPU。插件会根据 “Set break point at:” 一栏中输入的函数名,在该函数的开头设置断点。选中这一选项,并在相应的字段中输入 ``app_main``
10. 在同一个选项卡中继续往下浏览,建立一个初始断点用来在调试器复位后暂停 CPU。插件会根据 ``Set break point at:`` 一栏中输入的函数名,在该函数的开头设置断点。选中这一选项,并在相应的字段中输入 ``app_main``
11. 选中 “Resume” 选项,这会使得程序在每次调用步骤 8 中的 ``mon reset halt`` 后恢复,然后在 ``app_main`` 的断点处停止。
11. 选中 ``Resume`` 选项,这会使得程序在每次调用步骤 8 中的 ``mon reset halt`` 后恢复,然后在 ``app_main`` 的断点处停止。
上述步骤 8 - 11 的示例输入如下图所示。
@ -89,11 +103,11 @@
GDB 硬件调试的配置 - Startup 选项卡
上面的启动序列看起来有些复杂,如果对其中的初始化命令不太熟悉,请查阅 :ref:`jtag-debugging-tip-debugger-startup-commands` 章节获取更多说明。
上面的启动序列看起来有些复杂,如果对其中的初始化命令不太熟悉,请查阅 :ref:`jtag-debugging-tip-debugger-startup-commands` 章节获取更多说明。
12. 如果前面已经完成 :ref:`jtag-debugging-configuring-target` 中介绍的步骤,那么目标正在运行并准备与调试器进行对话。按下 “Debug” 按钮就可以直接调试。否则请按下 “Apply” 按钮保存配置,返回 :ref:`jtag-debugging-configuring-target` 章节进行配置,最后再回到这里开始调试。
12. 如果前面已经完成 :ref:`jtag-debugging-configuring-target` 中介绍的步骤,目标正在运行并准备好与调试器进行对话,那么点击 ``Debug`` 按钮直接进行调试。如果尚未完成前面步骤,请点击 ``Apply`` 按钮保存配置,返回 :ref:`jtag-debugging-configuring-target` 章节进行配置,最后再回到这里开始调试。
一旦所有 1 - 12 的配置步骤都已经完成Eclipse 就会打开 “Debug” 视图,如下图所示。
一旦所有 1-12 的配置步骤都已经完成Eclipse 就会打开 ``Debug`` 视图,如下图所示。
.. figure:: ../../../_static/debug-perspective.jpg
:align: center
@ -102,7 +116,7 @@
Eclipse 中的调试视图
如果不太了解 GDB 的常用方法,请查阅 :ref:`jtag-debugging-examples-eclipse` 文章中的调试示例章节 :ref:`jtag-debugging-examples`
如果不太了解 GDB 的常用方法,请查阅 :ref:`jtag-debugging-examples-eclipse` 文章中的调试示例章节 :ref:`jtag-debugging-examples`
.. _jtag-debugging-using-debugger-command-line:
@ -122,7 +136,7 @@
.. highlight:: none
3. 当启动调试器时,通常需要提供几个配置参数和命令,为了避免每次都在命令行中逐行输入这些命令,可以新建一个配置文件,并将其命名为 ``gdbinit``:
3. 当启动调试器时,通常需要提供几个配置参数和命令,为了避免每次都在命令行中逐行输入这些命令,可以新建一个配置文件,并将其命名为 ``gdbinit``:
::
@ -147,7 +161,7 @@
.. highlight:: none
5. 如果前面的步骤已经正确完成,会看到如下所示的输出日志,在日志的最后会出现 ``(gdb)`` 提示符:
5. 如果前面的步骤已经正确完成,会看到如下所示的输出日志,在日志的最后会出现 ``(gdb)`` 提示符:
::
@ -194,9 +208,10 @@
43 xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
(gdb)
注意上面日志的倒数第三行显示了调试器已经在 ``app_main()`` 函数的断点处停止,该断点在 ``gdbinit`` 文件中设定。由于处理器已经暂停运行LED 也不会闪烁。如果这也是您看到的现象,您可以开始调试了。
如果您不太了解 GDB 的常用方法,请查阅 :ref:`jtag-debugging-examples-command-line` 文章中的调试示例章节 :ref:`jtag-debugging-examples`
注意上面日志的倒数第三行显示了调试器已经在 ``app_main()`` 函数的断点处停止,该断点在 ``gdbinit`` 文件中设定。由于处理器已经暂停运行LED 不会再闪烁。如果你的 LED 也停止了闪烁,则可以开始调试。
如果不太了解 GDB 的常用方法,请查阅 :ref:`jtag-debugging-examples-command-line` 文章中的调试示例章节 :ref:`jtag-debugging-examples`
.. _jtag-debugging-with-idf-py:
@ -204,12 +219,12 @@
使用 idf.py 进行调试
^^^^^^^^^^^^^^^^^^^^
还可以使用 ``idf.py`` 更方便地执行上述提到的调试命令,可以使用以下命令:
还可以使用 ``idf.py`` 更方便地执行上述提到的调试命令,可以使用以下命令:
1. ``idf.py openocd``
在终端中运行 OpenOCD其配置信息来源于环境变量或者命令行。默认会使用 ``OPENOCD_SCRIPTS`` 环境变量中指定的脚本路径,它是由 ESP-IDF 项目仓库中的导出脚本(``export.sh`` or ``export.bat``)添加到系统环境变量中的。
当然,可以在命令行中通过 ``--openocd-scripts`` 参数来覆盖这个变量的值。
当然,可以在命令行中通过 ``--openocd-scripts`` 参数来覆盖这个变量的值。
.. include:: {IDF_TARGET_PATH_NAME}.inc
:start-after: idf-py-openocd-default-cfg
@ -230,7 +245,7 @@
4. ``idf.py gdbgui``
启动 `gdbgui <https://www.gdbgui.com>`_,在浏览器中打开调试器的前端界面。请在运行安装脚本时添加 "--enable-gdbgui" 参数,即运行 ``install.sh --enable-gdbgui``,从而确保支持 “gdbgui” 选项。
启动 `gdbgui <https://www.gdbgui.com>`_,在浏览器中打开调试器的前端界面。请在运行安装脚本时添加 "--enable-gdbgui" 参数,即运行 ``install.sh --enable-gdbgui``,从而确保支持 ``gdbgui`` 选项。
上述这些命令也可以合并到一起使用,``idf.py`` 会自动将后台进程(比如 openocd最先运行交互式进程比如 GDBmonitor最后运行。