[gdb/testsuite] Don't use default form in Dwarf::_guess_form
The only possible form for a DW_AT_low_pc attribute is DW_FORM_addr.
When specifying in dwarf assembly a low_pc attribute without explicit form:
...
{low_pc {main_label - 4}}
...
the resulting attribute uses DW_FORM_string, which is misinterpreted by gdb
when reading it as:
...
cu->base_address = attr->as_address ();
...
Stop using DW_FORM_string as default form. Instead, use a default form based
on the attribute name, if possible and unambiguous. Otherwise, error out.
F.i.:
- for DW_AT_low_pc we use DW_FORM_addr.
- For DW_AT_high_pc, we don't specify a default form because it could be
either address or constant class.
- For DW_AT_name, we use DW_FORM_string. While we could encode with
DW_FORM_strp instead, DW_FORM_string is always ok.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-23 Tom de Vries <tdevries@suse.de>
* lib/dwarf.exp (Dwarf::_guess_form): Return "" by default instead of
DW_FORM_string.
(Dwarf::_default_form): New proc.
(Dwarf::_handle_DW_TAG): Use _default_form. Error out if no form was
guessed.