mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-06 07:33:08 +00:00
gdb: make find_sal_for_pc_sect attempt to fill sal section
The find_sal_for_pc_section function inconsistently fills the section field from its output symtab_and_line, depending on whether a symtab is present or not. In the case that we cannot find a symtab for the pc and section, the function would construct a sal with a pc but no section, even though it could be either forwarded from the arguments, or computed from the pc. With the proposed changes, the function attempts to set the section in all code paths and performs a section lookup when it is not provided as an argument. This change is part of a patch series to fix inconsistencies in symtab_and_line constructions, making it the responsibility of the sal creator to fill out the section field (when possible). This section may be passed from a minsym in an unmapped overlay section. Leaving the section field empty would mean in most cases losing some important context (e.g. which overlay section this pc corresponds to). Approved-By: Tom Tromey <tom@tromey.com> Change-Id: I818a08c4f61803b6d2cadd32ec106fe416af4c66
This commit is contained in:
@@ -2905,6 +2905,13 @@ find_sal_for_pc_sect (CORE_ADDR pc, struct obj_section *section, int notcurrent)
|
|||||||
CORE_ADDR best_end = 0;
|
CORE_ADDR best_end = 0;
|
||||||
struct symtab *best_symtab = 0;
|
struct symtab *best_symtab = 0;
|
||||||
|
|
||||||
|
if (section == nullptr)
|
||||||
|
{
|
||||||
|
section = find_pc_overlay (pc);
|
||||||
|
if (section == nullptr)
|
||||||
|
section = find_pc_section (pc);
|
||||||
|
}
|
||||||
|
|
||||||
/* Store here the first line number
|
/* Store here the first line number
|
||||||
of a file which contains the line at the smallest pc after PC.
|
of a file which contains the line at the smallest pc after PC.
|
||||||
If we don't find a line whose range contains PC,
|
If we don't find a line whose range contains PC,
|
||||||
@@ -3030,6 +3037,7 @@ find_sal_for_pc_sect (CORE_ADDR pc, struct obj_section *section, int notcurrent)
|
|||||||
if (notcurrent)
|
if (notcurrent)
|
||||||
pc++;
|
pc++;
|
||||||
val.pc = pc;
|
val.pc = pc;
|
||||||
|
val.section = section;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user