Created attachment 12719 [details] Patch (version 1) While debugging a program that dumped core (which I unfortunately can't share), GDB gets into an infinite loop inside dwarf2_attr() because the ``die'' returned by follow_die_ref() is the same one that was passed in. Attached is a patch that addresses this issue, but I'm not familiar with GDB or DWARF enough to reason about it, so feedback would be appreciated.
Created attachment 12720 [details] Patch (version 1, but with the correct email address)
Created attachment 12721 [details] Extended patch including test case This started out with me "just" writing a test case for this issue. Unfortunately this exposed a bunch more places that needed fixing up, so this is now the original patch + a test case + some additional fixes. This is still work-in-progress, but the code needs a clean up, and I suspect that there might be additional test cases that need to be written.
FWIW it's good, when possible, to print info about which DIE is offending. Here's an example: complaint (_("Computed physname <%s> does not match demangled <%s> " "(from linkage <%s>) - DIE at %s [in module %s]"), physname, canon, mangled, sect_offset_str (die->sect_off), objfile_name (objfile)); That way it is sometimes simpler to track down the bug.
Switching components.