[PATCH][gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder(), again

Tom Tromey tom@tromey.com
Mon Jun 14 20:22:44 GMT 2021


>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> ISTM that the ancestor implementation is confusing and fragile, and should
Tom> go.  Furthermore, it seems that keeping track of the m_builder in scope can be
Tom> handled simply with a global variable.

I'd rather not have any global variables.

Maybe a new member of dwarf2_per_objfile would be equivalent.

Tom> +  gdb_assert (dwarf2_cu::sym_cu == nullptr);
Tom> +  scoped_restore restore_sym_cu = make_scoped_restore (&dwarf2_cu::sym_cu);
Tom> +  dwarf2_cu::sym_cu = cu;

You can pass 'cu' as a second argument to make_scoped_restore.

thanks,
Tom


More information about the Gdb-patches mailing list