c - 如何跳过 GDB 中循环的多次迭代?

标签 c debugging loops for-loop gdb

假设我有一个将迭代 100 次的循环,我想跳过 50 次迭代,但我想从那里继续按 next 以查看每一行。

我不想在循环后设置断点,因为这样我会跳过所有迭代,而不仅仅是我想要的次数。

有没有办法在 GDB 中做到这一点?怎么办?

附言我不想从头到尾一直按 next。这很耗时...

最佳答案

在循环中设置断点,然后调用c 50继续50次

Debugging with GDB

5.2 Continuing and stepping

continue [ignore-count]
c [ignore-count]
fg [ignore-count]
Resume program execution, at the address where your program last stopped; any breakpoints set at that address are bypassed. The optional argument ignore-count allows you to specify a further number of times to ignore a breakpoint at this location; its effect is like that of ignore (see section Break conditions). The argument ignore-count is meaningful only when your program stopped due to a breakpoint. At other times, the argument to continue is ignored.

关于c - 如何跳过 GDB 中循环的多次迭代?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27388729/

相关文章:

c# - 调试时如何进入重载的运算符?

java - 有没有更好的方法来编写这个循环?

c# - for 循环中的预递减值在第一个循环中未正确递减值

actionscript-3 - AS3 : Loop in enterframe/s

c - timer_create 在 i386 系统上导致段错误,但在 x86_64 系统(linux)上没有

c - 使用 printf 时 Mergesort 输出发生变化

使用 Logcat 和模拟器进行 Android 调试。可能吗?

c - C 中的动态内存分配 : Problems in Realloc

c - 线程间setjmp/longjmp处理超时

Android包不可调试