[3/3] dwarf-reader: fix lookup for repeated translation unit paths
Commit Message
When using relative compilation unit paths in DWARF, the lookup for an
existing one was done with an incorrect path. In particular, a '/' was
prefixed to the path regardless of whether the compilation_dir is set.
That led to the instantiation of an additional translation unit that and
failed when adding it to the corpus due to violating translation unit
uniqueness. Fix that by correcting the lookup.
* src/abg-dwarf-reader.cc(build_translation_unit_and_add_to_ir):
Fix lookup for potentially already existing translation units.
Reported-by: Dan Albert <danalbert@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
---
src/abg-dwarf-reader.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
Hello Matthias,
Matthias Maennich <maennich@google.com> a écrit:
> When using relative compilation unit paths in DWARF, the lookup for an
> existing one was done with an incorrect path. In particular, a '/' was
> prefixed to the path regardless of whether the compilation_dir is set.
> That led to the instantiation of an additional translation unit that and
> failed when adding it to the corpus due to violating translation unit
> uniqueness. Fix that by correcting the lookup.
>
> * src/abg-dwarf-reader.cc(build_translation_unit_and_add_to_ir):
> Fix lookup for potentially already existing translation units.
>
> Reported-by: Dan Albert <danalbert@google.com>
> Signed-off-by: Matthias Maennich <maennich@google.com>
Applied to master, thanks!
Cheers,
@@ -12826,7 +12826,8 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
// unit. That is, it's going to be the union of all the translation
// units of the same path.
{
- string abs_path = compilation_dir + "/" + path;
+ const string& abs_path =
+ compilation_dir.empty() ? path : compilation_dir + "/" + path;
result = ctxt.current_corpus()->find_translation_unit(abs_path);
}