forked from Imagelibrary/binutils-gdb
Implement 'Object_Size
This patch started as an attempt to allow the 'Size attribute to be applied to types, and not just objects. However, that turns out to be difficult due to the Ada semantcs of 'Size. In particular, Ada requires 'Size to denote the size of the representation of the value, so for example Boolean'Size must be 1. Implementing this properly requires information not readily available to gdb... and while we could synthesize this information in many cases, it also seemed to me that this wasn't strictly very useful when debugging. So instead, this patch adds support for the 'Object_Size attribute, which is somewhat closer to 'sizeof'. Note also that while 'Object_Size is defined for some dynamic types, I chose not to implement this here, as again this information is not readily available -- and I think it's preferable to error than to print something that might be incorrect. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
This commit is contained in:
@@ -30,10 +30,6 @@ extern struct value *ada_atr_tag (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside, enum exp_opcode op,
|
||||
struct value *arg1);
|
||||
extern struct value *ada_atr_size (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside, enum exp_opcode op,
|
||||
struct value *arg1);
|
||||
extern struct value *ada_abs (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside, enum exp_opcode op,
|
||||
@@ -200,10 +196,24 @@ public:
|
||||
|
||||
using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
|
||||
using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
|
||||
using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
|
||||
using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
|
||||
using ada_pos_operation = unop_operation<OP_ATR_POS, ada_pos_atr>;
|
||||
|
||||
/* Implementation of the 'Size and 'Object_Size attribute. The
|
||||
boolean parameter is true for 'Size and false for 'Object_Size. */
|
||||
class ada_atr_size_operation
|
||||
: public maybe_constant_operation<operation_up, bool>
|
||||
{
|
||||
using maybe_constant_operation::maybe_constant_operation;
|
||||
|
||||
value *evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside) override;
|
||||
|
||||
enum exp_opcode opcode () const override
|
||||
{ return OP_ATR_SIZE; }
|
||||
};
|
||||
|
||||
/* The in-range operation, given a type. */
|
||||
class ada_unop_range_operation
|
||||
: public tuple_holding_operation<operation_up, struct type *>
|
||||
|
||||
Reference in New Issue
Block a user