You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于GDB实现ARM汇编代码每秒自动单步执行的技术问询

Auto-Stepping ARM Assembly in GDB with 1-Second Intervals for Demos

Got it, let's sort this out for your booth demo—you need GDB to automatically step through ARM assembly code every second, no manual key presses required, until you hit Ctrl+C. Here are two reliable, easy-to-use approaches:

Method 1: GDB Built-In Script (Cleanest for Reuse)

You can leverage GDB's internal command loop to repeat single-step instructions with a 1-second delay. Here's how to set it up:

  1. Create a GDB script file (name it auto-step.gdb for example) with this content:
# Auto-step through ARM instructions every second until Ctrl+C
while 1
    # Step one individual assembly instruction (use "step" instead if you want to step over functions)
    stepi
    # Pause for 1 second using the system sleep command
    shell sleep 1
end
  1. Launch GDB and load your ARM executable as normal:
gdb your-arm-demo-program.elf
  1. Once inside GDB, start the auto-stepping by running:
source auto-step.gdb

GDB will immediately begin stepping through instructions every second. To stop the loop, just press Ctrl+C—this will break the cycle and return you to the GDB prompt.

Method 2: One-Liner Command (No Script File Needed)

If you don't want to create a separate script, you can run the loop directly in the GDB prompt:

while 1; stepi; shell sleep 1; end

This does exactly the same as the script—hit Ctrl+C whenever you need to stop the auto-stepping.

Quick Tips for Your Demo

  • To start auto-stepping immediately when GDB launches, pass the script as an argument:
    gdb -x auto-step.gdb your-arm-demo-program.elf
    
  • Make sure your ARM program is compiled with debug symbols (-g flag) so GDB can properly resolve and step through assembly instructions.
  • Adjust the delay by changing sleep 1 to another value (e.g., sleep 0.5 for half-second steps, or sleep 2 for slower pacing).

内容的提问来源于stack exchange,提问作者71GA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:27:00