debug-jlink
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJ-Link GDB 调试
J-Link GDB Debugging
适用场景
Applicable Scenarios
- 用户希望通过 SEGGER J-Link 探针调试 Cortex-M 类目标。
- 工作区中已有 和 J-Link 探针。
ELF - 烧录或串口监视流程表明,需要进一步查看断点、停核控制、寄存器或回溯信息。
- 需要使用 SWO 输出捕获功能。
- 需要在调试前确认 JLinkGDBServer 和 GDB 环境是否就绪。
- Users want to debug Cortex-M targets via SEGGER J-Link probes.
- The workspace already has an file and a J-Link probe.
ELF - Flashing or serial monitoring processes indicate that further inspection of breakpoints, core halt control, registers, or backtrace information is required.
- Need to use the SWO output capture feature.
- Need to confirm whether the JLinkGDBServer and GDB environment are ready before debugging.
必要输入
Required Inputs
- 一份带符号的 ,或包含
ELF的artifact_path。Project Profile - 参数指定目标芯片型号(J-Link GDB Server 要求必须指定)。
--device - 可选调试模式:、
download-and-halt、attach-only。crash-context - 可选的 GDB 可执行文件路径。
- A symbol-containing file, or a
ELFthat includesProject Profile.artifact_path - The parameter specifying the target chip model (required by J-Link GDB Server).
--device - Optional debugging modes: ,
download-and-halt,attach-only.crash-context - Optional path to the GDB executable file.
自动探测
Auto-Detection
- 默认模式为 ;只有用户显式要求附着调试或崩溃现场检查时才切换。
download-and-halt - GDB 由脚本自动探测,优先级为:显式用户输入、、
Project Profile、arm-none-eabi-gdb。gdb-multiarch - JLinkGDBServer 按配置文件、PATH、常见安装路径顺序查找。
- 做符号级调试必须有 。若只有
ELF或HEX,应阻塞并要求提供匹配BIN。ELF
- The default mode is ; it only switches when the user explicitly requests attach debugging or crash site inspection.
download-and-halt - GDB is automatically detected by the script, with priority: explicit user input, ,
Project Profile,arm-none-eabi-gdb.gdb-multiarch - JLinkGDBServer is searched in the order of configuration files, PATH, and common installation paths.
- An file is mandatory for symbol-level debugging. If only
ELForHEXfiles are available, the process should block and request a matchingBINfile.ELF
执行步骤
Execution Steps
- 先阅读 references/usage.md,确认本次是环境探测,还是执行调试会话。
- 若不确定环境是否就绪,先运行自带脚本 scripts/jlink_debugger.py 的 模式确认。
--detect - 根据用户意图选择调试模式:(默认)、
download-and-halt或attach-only。crash-context - 使用 +
--elf启动调试,可选--device和--interface。--port - 需要 SWO 输出时,使用 参数。
--swo - 读取脚本输出的调试结果,重点关注寄存器状态、回溯帧和 Fault 寄存器。
- First read references/usage.md to confirm whether this is an environment detection or a debugging session execution.
- If unsure whether the environment is ready, first run the mode of the built-in script scripts/jlink_debugger.py to confirm.
--detect - Select the debugging mode based on the user's intent: (default),
download-and-halt, orattach-only.crash-context - Start debugging using +
--elf, with optional--deviceand--interfaceparameters.--port - Use the parameter when SWO output is needed.
--swo - Read the debugging results output by the script, focusing on register status, backtrace frames, and Fault registers.
失败分流
Failure Diversion
- 当缺少 或兼容 GDB 时,返回
JLinkGDBServerCLExe。environment-missing - 当没有可用的 时,返回
ELF。artifact-missing - 当 JLinkGDBServer 无法连接目标板时,返回 。
connection-failure - 当设备名不被 J-Link 识别或配置不一致时,返回 。
project-config-error - 当会话可以建立,但无法停核、加载或得到可信回溯时,返回 。
target-response-abnormal - 当 缺失且无法从工作区推断时,返回
--device。ambiguous-context
- Returns when
environment-missingor a compatible GDB is missing.JLinkGDBServerCLExe - Returns when no available
artifact-missingfile exists.ELF - Returns when JLinkGDBServer cannot connect to the target board.
connection-failure - Returns when the device name is not recognized by J-Link or the configuration is inconsistent.
project-config-error - Returns when the session can be established but cannot halt the core, load files, or obtain a reliable backtrace.
target-response-abnormal - Returns when
ambiguous-contextis missing and cannot be inferred from the workspace.--device
平台说明
Platform Notes
- JLinkGDBServer 在 Linux/macOS 下为 ,Windows 下为
JLinkGDBServerCLExe。JLinkGDBServerCL.exe - 默认 GDB 端口为 2331(J-Link 默认),可通过 修改。
--port - 自带脚本使用 Python 标准库和 subprocess,跨平台兼容。
- SWO 功能为 J-Link 独有,可捕获 ITM printf 输出。
- JLinkGDBServer is on Linux/macOS, and
JLinkGDBServerCLExeon Windows.JLinkGDBServerCL.exe - The default GDB port is 2331 (J-Link default), which can be modified via .
--port - The built-in script uses Python standard libraries and subprocess, and is cross-platform compatible.
- The SWO feature is exclusive to J-Link and can capture ITM printf output.
输出约定
Output Conventions
- 输出调试模式、JLinkGDBServer 命令、GDB 可执行文件、路径和关键观察结论。
ELF - 在 中保留
Project Profile、artifact_path、artifact_kind、gdb_executable。jlink_device - 当复位后或继续运行后下一步是观察运行行为时,推荐 。
serial-monitor
- Output the debugging mode, JLinkGDBServer command, GDB executable file, path, and key observation conclusions.
ELF - Retain ,
artifact_path,artifact_kind, andgdb_executablein thejlink_device.Project Profile - When the next step after reset or resume is to observe runtime behavior, is recommended.
serial-monitor
交接关系
Handover Relationships
- 当目标恢复运行后,需要继续观察运行期日志时,将成功会话交给 。
serial-monitor - 当用户需要 RTOS 线程感知调试时,将会话交给 。
rtos-debug
- When the target resumes operation and runtime logs need to be observed continuously, hand over the successful session to .
serial-monitor - When the user requires RTOS thread-aware debugging, hand over the session to .
rtos-debug