From 27710edb4e588d0360620df424dd7ee7e8cfafee Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 30 Jul 2022 22:43:54 -0400 Subject: gdb: remove TYPE_TARGET_TYPE Remove the macro, replace all uses by calls to type::target_type. Change-Id: Ie51d3e1e22f94130176d6abd723255282bb6d1ed --- gdb/python/py-finishbreakpoint.c | 2 +- gdb/python/py-lazy-string.c | 4 ++-- gdb/python/py-type.c | 8 ++++---- gdb/python/py-value.c | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index c80096f..c4b043f 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -254,7 +254,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) if (function != nullptr) { struct type *ret_type = - check_typedef (TYPE_TARGET_TYPE (function->type ())); + check_typedef (function->type ()->target_type ()); /* Remember only non-void return types. */ if (ret_type->code () != TYPE_CODE_VOID) diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index c49987e..8cd8b91 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -130,7 +130,7 @@ stpy_convert_to_value (PyObject *self, PyObject *args) /* PR 20786: There's no way to specify an array of length zero. Record a length of [0,-1] which is how Ada does it. Anything we do is broken, but this is one possible solution. */ - type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype), + type = lookup_array_range_type (realtype->target_type (), 0, self_string->length - 1); val = value_at_lazy (type, self_string->address); } @@ -262,7 +262,7 @@ stpy_lazy_string_elt_type (lazy_string_object *lazy) { case TYPE_CODE_PTR: case TYPE_CODE_ARRAY: - return TYPE_TARGET_TYPE (realtype); + return realtype->target_type (); default: /* This is done to preserve existing behaviour. PR 20769. E.g., gdb.parse_and_eval("my_int_variable").lazy_string().type. */ diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index d14f9e4..3d7d2f6 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -503,7 +503,7 @@ typy_get_composite (struct type *type) if (!type->is_pointer_or_reference ()) break; - type = TYPE_TARGET_TYPE (type); + type = type->target_type (); } /* If this is not a struct, union, or enum type, raise TypeError @@ -686,14 +686,14 @@ typy_target (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - if (!TYPE_TARGET_TYPE (type)) + if (!type->target_type ()) { PyErr_SetString (PyExc_RuntimeError, _("Type does not have a target.")); return NULL; } - return type_to_type_object (TYPE_TARGET_TYPE (type)); + return type_to_type_object (type->target_type ()); } /* Return a const-qualified type variant. */ @@ -1007,7 +1007,7 @@ typy_template_argument (PyObject *self, PyObject *args) { type = check_typedef (type); if (TYPE_IS_REFERENCE (type)) - type = check_typedef (TYPE_TARGET_TYPE (type)); + type = check_typedef (type->target_type ()); } catch (const gdb_exception &except) { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 3b75cda..cb3346c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -422,7 +422,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) type = check_typedef (type); if (type->is_pointer_or_reference () - && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_STRUCT)) + && (type->target_type ()->code () == TYPE_CODE_STRUCT)) { struct value *target; int was_pointer = type->code () == TYPE_CODE_PTR; @@ -525,7 +525,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) length = array_length; else if (array_length == -1) { - type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype), + type = lookup_array_range_type (realtype->target_type (), 0, length - 1); } else if (length != array_length) @@ -534,7 +534,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) specified length. */ if (length > array_length) error (_("Length is larger than array size.")); - type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype), + type = lookup_array_range_type (realtype->target_type (), low_bound, low_bound + length - 1); } @@ -886,7 +886,7 @@ value_has_field (struct value *v, PyObject *field) val_type = value_type (v); val_type = check_typedef (val_type); if (val_type->is_pointer_or_reference ()) - val_type = check_typedef (TYPE_TARGET_TYPE (val_type)); + val_type = check_typedef (val_type->target_type ()); type_code = val_type->code (); if ((type_code == TYPE_CODE_STRUCT || type_code == TYPE_CODE_UNION) @@ -1274,7 +1274,7 @@ enum valpy_opcode /* If TYPE is a reference, return the target; otherwise return TYPE. */ #define STRIP_REFERENCE(TYPE) \ - (TYPE_IS_REFERENCE (TYPE) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE)) + (TYPE_IS_REFERENCE (TYPE) ? ((TYPE)->target_type ()) : (TYPE)) /* Helper for valpy_binop. Returns a value object which is the result of applying the operation specified by OPCODE to the given -- cgit v1.1