diff --git a/gdb/symtab.c b/gdb/symtab.c index c0c2454d967..31f91a8b7f0 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3196,6 +3196,12 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) if (item != first) prev = item - 1; /* Found a matching item. */ + /* For lines with multiple statements, ensure that `item` points to the next *line*, + as opposed to the next statement on the same line. That way, the PC range we return + will cover the whole line, as opposed to a single statement on the line. */ + while (item->line == prev->line && item != last) + ++item; + /* At this point, prev points at the line whose start addr is <= pc, and item points at the next line. If we ran off the end of the linetable (pc >= start of the last line), then prev == item. If pc < start of