[PATCH v3 1/1] gdb: Fix assertion in 'value_primitive_field'

Tom Tromey tom@tromey.com
Tue Apr 16 17:52:59 GMT 2024


>>>>> Stephan Rohr <stephan.rohr@intel.com> writes:

> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> GDB asserts that the data location of a value's field with a dynamic
> data location is resolved when fetching the field's value in
> 'value_primitive_field'.  This assertion was hit because of bogus DWARF
> generated by the Intel Fortran compiler.  While that compiler should fix
> the DWARF, we prefer GDB to error out here instead, e.g. to allow the
> user to continue debugging other parts of the program.

I have been trying to understand this patch for a while but I really
don't.  Could you explain it in more detail, preferably in the commit
message?

> +	    DW_TAG_variable {
> +		{DW_AT_name var_a_invalid_location}
> +		{DW_AT_type :$struct_label}
> +		{DW_AT_location {
> +		    DW_OP_addr [gdb_target_symbol var_a]
> +		    DW_OP_deref
> +		    DW_OP_stack_value
> +		} SPECIAL_expr}
> +	    }

For example, I don't understand what is invalid about this.
It's weird for sure, but why is gdb's failure to evaluate it anything
other than a bug somewhere else in gdb?

In the "valid" case I see the field type being resolved.  Why doesn't
this happen in the invalid case?

> +	error (_("cannot read %s, expected an already resolved data "
> +		 "location."), arg_type->field (fieldno).name ());

This error shouldn't have a trailing ".", it makes the output look
weird:

$1 = {data = <error reading variable: cannot read data, expected an already resolved data location.>

Tom


More information about the Gdb-patches mailing list