[PATCH] Fix off-by-one bug in dwarf 5 file indexes.

Ali Tamur via gdb-patches gdb-patches@sourceware.org
Sun Feb 16 06:21:00 GMT 2020


Hi,

Sorry I have tried more than a day and I can neither find a test whose
success depends solely on this change, nor was I able to construct
one. It seems to me gdb is too resilient for small errors in debug
sections. Current code ignores the first file name entry in the line
header for dwarf 5, when constructing
dwarf2_per_cu_data.v.quick.file_names:
- Suppose the line header has two file name entries in m_file_names[0]
and m_file_names[1]. A possible current code flow for the first
iteration is:
file_full_name(i + 1) => fule_file_name(1) => lh->file_name_at (1) =>
(because version >= 5) return &m_file_names[1];
So, m_file_names[0] is never used.. Can we apply the 'obvious rule' to
submit this?

Thanks,
Ali



On Thu, Feb 13, 2020 at 6:24 AM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Ali" == Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Ali> Fix dw2_get_file_names_reader behavior where it treated file names in
> Ali> line header as one indexed.
>
> Ali> gdb/ChangeLog:
>
> Ali>    * dwarf2/read.c (dw2_get_file_names_reader): Bug fix.
>
> Normally you should mention how the patch was tested.  If it triggers
> for some existing test, then you can just note that.  Otherwise, it's
> normal to add a new test, unless there's some reason that this is too
> difficult.
>
> thanks,
> Tom



More information about the Gdb-patches mailing list