Re: [PATCH 07/43] Move get_object_address to dwarf_expr_context

Zoran Zaric via Gdb-patches
2021-04-28T11:35:02Z

On 4/27/21 4:12 AM, Simon Marchi wrote:
> [CAUTION: External Email]
>
>> @@ -204,7 +207,12 @@ struct dwarf_expr_context
>> int deref_size) = 0;
>>
>> /* Return the `object address' for DW_OP_push_object_address. */
>> - virtual CORE_ADDR get_object_address () = 0;
>> + virtual CORE_ADDR get_object_address ()
>> + {
>> + if (obj_address == 0)
>> + error (_("Location address is not set."));
>> + return obj_address;
>
> Instead of having obj_address == 0 as a special case, I'd suggest making
> it a gdb::optional maybe. To make sure that nobody accesses it
> directly, other than through the getter, you could even apply the same
> pattern of wrapping it that I suggested for the frame and per_cu.
>
> Should the error thrown here be of the same type as the error thrown for
> if the frame or per_cu is not there (NOT_AVAILABLE_ERROR currently, but
> perhaps subject to change)?
>
> Simon
>

This method was just copied from the previous implementation and inlined
in the later patches.

Zoran