[PATCH] gdb: Fix false match issue in skip_prologue_using_linetable

WANG Rui r@hev.cc
Mon Apr 17 16:24:28 GMT 2023


We should exclude matches to the ending PC to prevent false matches with the
next function, as prologue_end is located at the end PC.

  <fun1>:
    0x00: ... <-- start_pc
    0x04: ...
    0x08: ... <-- breakpoint
    0x0c: ret
  <fun2>:
    0x10: ret <-- end_pc | prologue_end of fun2
---
 gdb/symtab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index f2b1a14e006..a662d7d1869 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3735,7 +3735,7 @@ skip_prologue_using_linetable (CORE_ADDR func_addr)
 	 });
 
       for (;
-	   it < linetable->item + linetable->nitems && it->pc <= end_pc;
+	   it < linetable->item + linetable->nitems && it->pc < end_pc;
 	   it++)
 	if (it->prologue_end)
 	  return {it->pc};
-- 
2.40.0



More information about the Gdb-patches mailing list