Hi,

Gentle ping.  I sent this patch a couple of weeks ago and wanted to
check whether someone has had a chance to look at it.

The patch addresses PR gdb/21221 and introduces a heuristic that ends
a source-level step after one iteration of a tight empty loop.  I
would appreciate any feedback.

Thanks,
Bai


原始邮件

发件人: <597498687@qq.com>
发件时间:2026年8月17日 18:07
收件人:gdb-patches <gdb-patches@sourceware.org>
主题:[PATCH] infrun: Introduce empty-loop step heuristic

Hi,

This patch addresses PR gdb/21221.  When a user single-steps a source
line containing a tight empty loop, GDB currently steps every
iteration and only stops once the loop finishes.  The patch introduces a
heuristic that ends the step after one iteration by detecting when the
inferior returns to the first stop PC observed on the same source line.

The heuristic is only active in forward execution and includes a
safety threshold to avoid runaway steps.  A ui_out message is emitted
so front-ends can parse the stop reason.

Tested by gdb.base/empty-loop-step.exp.

Thanks,
Bai