Hi,
I am working with TCF as a developer of Wind River Simics and have found an issue with the DWARF service in the TCF agent with an ELF file that contains a .debug_loc section.
In dwarfexpr.c:76 in dwarf_get_expression_list there is an issue when converting the end address (Addr1) to a run-time address:
if (!errno) RT_Addr1 = elf_map_to_run_time_address(Value->mContext, Unit->mFile, S1, Base + Addr1);
The end address (Addr1) for the location in debug_loc is an exclusive address, containing the first address past the end of the address range, and that address is being translated to a run-time address using elf_map_to_run_time_address
(in tcf_elf.c). For the case when the region in the ELF-file has its last byte at Base + Addr1 – 1 the translation will fail as elf_run_time_address_in_region() will fail (check is “addr >= p->address + p->mem_size”). This mapping (if necessary) should be
done for the last address included in the address range, not the first address outside of the range.
Something like:
if (!errno) RT_Addr1 = elf_map_to_run_time_address(Value->mContext, Unit->mFile, S1, Base + Addr1 - 1) + 1;
An alternative might be to determine Info->code_size from Addr1 – Addr0 instead of converting the upper address.
I ran into this issue with a ppc64 binary compiled with gcc4.1.0.
Regards,
Andreas Ragnerstam