Re: RFC: bfd_section should not be NULL in call to prim_record_minimal_*

Tom Tromey
2012-04-17T11:51:39Z

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> But I think it is wrong, because I think a lot of places in the GDB code
Joel> make the assumption that a minimal symbol's obj_section is not NULL, and
Joel> the only way to set it, I think, is to have the BFD section.

Joel> So, I think the function documentation should be changed to remove
Joel> the permission to pass NULL, and a gdb_assert should also be added
Joel> to verify that SYMBOL_OBJ_SECTION (msymbol) != NULL after the
Joel> BFD section to obj_section search.

Joel> In the meantime, patch #2 fixes the problem by making sure that we
Joel> always pass a BFD section. I haven't tested it against the official
Joel> testsuite, I will do so now, but I also wanted to start this discussion
Joel> before I forget.

This change is fine with me -- even more than fine, I think removing
special cases is generally better when possible.

However, if this is just a regression caused by linespec changes, maybe
it can also be fixed in another way. That is, you can find a minsym's
objfile using msymbol_objfile; I think this would fix the possibly
problematic uses I see in linespec.c (the one in minsym_found is maybe
ok).

I wanted to mention this in case the change causes other regressions in
your testing.

Did you audit the other symbol readers?

Tom