From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id EFF033858C66 for ; Fri, 3 Nov 2023 16:09:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFF033858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EFF033858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699027789; cv=none; b=sU4OnZD524wi4CAtW7RtDuUUbe5fzAOueio0TVxSPvx66J200BaMWKe8xn08TEDkLXfdPpuYR+YC/xgP6/3X4hvyEZNYw11x5gp/oQC16G+G9Bk9PIuBzHwJdz01vdwxXPKGakfMUIEauobLD0oOe8AYdJycKJOY0x1PqPLZtsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699027789; c=relaxed/simple; bh=/a4l6wJIn7q9ckNDA4tCXWMP47Y6NZ1oRRW29dFANNk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=AGpNVMDMZ+gFcFyuHQMHVW/4MlIRQMV0N2oPC0YtjcRrwRRbH7db81ia8/RJeSKgpdqAMBJZ9tji66mHUDhbHRfZLtWNoK/nGFhvOigehaSwmXhoOAkS4MxjKXQB9HqxIuH06/itDq6P0mNqzvfWi6fu6UXi9oxWxCdAkAXdlVc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7a69a71cc1dso80869039f.0 for ; Fri, 03 Nov 2023 09:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699027772; x=1699632572; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Xq78oYAzpdT1CRrDqTNFJB5lRwDsub9hRe34kbw8P7k=; b=Sw+D/VZovaifzkE4tDRSHe2RrlkTIUMEm0/erRXvBf4mUpqZZxYxfpo9H1duLUAY3x AydLh0ILNzBag7oBwiE71fg5MoTaGL+0Ir6csPmuraRIGEadz8dp47tptxver2RmDecz igPXJzy1OpQn49Z/TQ7LrUoVa2zq3b6O2XhzUy6ogaObaNiIZ4XYrX7aRfVnioy5AlYo y92RSsAXH7Ko3rJk2PXJhoRR6tQdCWjRkSYNxSYrJrjwAj4e8wYi4SAP8z8OwtKcmyeO 1eO/3lSCg16ZK0ymH5wGtSRYAbk2HYyR7DYfaVk/kFLCgVgY/+rzjRBQ+DSg4qhBulId bo0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699027772; x=1699632572; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xq78oYAzpdT1CRrDqTNFJB5lRwDsub9hRe34kbw8P7k=; b=Gd5A37yildcl19pfGv0abfQ4niEfK33HyHrmF1KB0bKUOahErm+NEPyG/X4Yz8tenE jxAG3fhEo+U5UN3QcCXdLsGozGO7ygoljXb+BMAvyokdgxPGB7dqZ25V7kkvAgdhP4Mq 4yaAyfblaMhO/06Xo6eRPC+ChPdchetwJp0ROs2sLzssEl1SD1qGHjLbDwmDQUoTfF5U CZUvokllnSQn+xLTezCHhfJNpheah8MaRuVoVhv6ejyX9lJI/Aaf+wkzjCa06ks17T7K 9RyJgljOqd67wzplQGRokxswdHoQAr4pWs+tr8xBWaUNKuNn27V/mjt2O+u9Bt6sxH0d QtuA== X-Gm-Message-State: AOJu0YynEYbDdkU8AfysNgr2jW2So/7P2bpUN0t6JON+fhCh7qvHeXD4 PKBKUWCac43M6q8nx5zRrD6Ftg== X-Google-Smtp-Source: AGHT+IGz8e/8hthRh380jeuGdVcmMOeySEtBxcUd9iQWZai3ffT6vMDUr8LSPQEY10kqgl1xvtja9A== X-Received: by 2002:a05:6602:29cf:b0:78b:d0a9:34fb with SMTP id z15-20020a05660229cf00b0078bd0a934fbmr24350381ioq.20.1699027772142; Fri, 03 Nov 2023 09:09:32 -0700 (PDT) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id gu16-20020a0566382e1000b0042b3dcb1106sm581839jab.47.2023.11.03.09.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 09:09:31 -0700 (PDT) From: Tom Tromey Date: Fri, 03 Nov 2023 10:09:28 -0600 Subject: [PATCH v3 6/9] Remove some type field accessor macros MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231103-field-bits-v3-6-273c40bcaf3d@adacore.com> References: <20231103-field-bits-v3-0-273c40bcaf3d@adacore.com> In-Reply-To: <20231103-field-bits-v3-0-273c40bcaf3d@adacore.com> To: gdb-patches@sourceware.org Cc: Simon Marchi , Keith Seitz X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This removes TYPE_FIELD_PRIVATE, TYPE_FIELD_PROTECTED, TYPE_FIELD_IGNORE, and TYPE_FIELD_VIRTUAL. In c-varobj.c, match_accessibility can be removed entirely now. Note that the comment before this function was incorrect. Acked-By: Simon Marchi Reviewed-by: Keith Seitz --- gdb/ada-valprint.c | 2 +- gdb/c-typeprint.c | 10 +++++----- gdb/c-varobj.c | 31 ++++++++----------------------- gdb/compile/compile-cplus-types.c | 7 ++++--- gdb/cp-valprint.c | 4 ++-- gdb/gdbtypes.c | 27 ++++++++++++++------------- gdb/gdbtypes.h | 9 --------- gdb/p-typeprint.c | 6 ++++-- gdb/p-valprint.c | 4 ++-- 9 files changed, 40 insertions(+), 60 deletions(-) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index b32f1e506d1..b981be89b18 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -627,7 +627,7 @@ print_field_values (struct value *value, struct value *outer_value, { /* Bitfields require special handling, especially due to byte order problems. */ - if (HAVE_CPLUS_STRUCT (type) && TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled (_(""), metadata_style.style (), stream); diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 241fbca49b7..4a0c6950b0c 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -238,7 +238,7 @@ cp_type_print_derivation_info (struct ui_file *stream, gdb_puts (i == 0 ? ": " : ", ", stream); gdb_printf (stream, "%s%s ", BASETYPE_VIA_PUBLIC (type, i) - ? "public" : (TYPE_FIELD_PROTECTED (type, i) + ? "public" : (type->field (i).is_protected () ? "protected" : "private"), BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : ""); name = TYPE_BASECLASS (type, i)->name (); @@ -912,7 +912,7 @@ need_access_label_p (struct type *type) if (type->is_declared_class ()) { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) - if (!TYPE_FIELD_PRIVATE (type, i)) + if (!type->field (i).is_private ()) return true; for (int j = 0; j < TYPE_NFN_FIELDS (type); j++) for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++) @@ -926,7 +926,7 @@ need_access_label_p (struct type *type) else { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) - if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i)) + if (!type->field (i).is_public ()) return true; for (int j = 0; j < TYPE_NFN_FIELDS (type); j++) { @@ -1102,8 +1102,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, { section_type = output_access_specifier (stream, section_type, level, - TYPE_FIELD_PROTECTED (type, i), - TYPE_FIELD_PRIVATE (type, i), flags); + type->field (i).is_protected (), + type->field (i).is_private (), flags); } bool is_static = type->field (i).is_static (); diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 543cd585eb2..05b5bd7fa23 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -647,16 +647,18 @@ cplus_class_num_children (struct type *type, int children[3]) vptr_fieldno = get_vptr_fieldno (type, &basetype); for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) { + field &fld = type->field (i); + /* If we have a virtual table pointer, omit it. Even if virtual table pointers are not specifically marked in the debug info, they should be artificial. */ if ((type == basetype && i == vptr_fieldno) - || type->field (i).is_artificial ()) + || fld.is_artificial ()) continue; - if (TYPE_FIELD_PROTECTED (type, i)) + if (fld.is_protected ()) children[v_protected]++; - else if (TYPE_FIELD_PRIVATE (type, i)) + else if (fld.is_private ()) children[v_private]++; else children[v_public]++; @@ -669,23 +671,6 @@ cplus_name_of_variable (const struct varobj *parent) return c_name_of_variable (parent); } -/* Check if field INDEX of TYPE has the specified accessibility. - Return 0 if so and 1 otherwise. */ - -static int -match_accessibility (struct type *type, int index, enum accessibility acc) -{ - if (acc == accessibility::PRIVATE && TYPE_FIELD_PRIVATE (type, index)) - return 1; - else if (acc == accessibility::PROTECTED && TYPE_FIELD_PROTECTED (type, index)) - return 1; - else if (acc == accessibility::PUBLIC && !TYPE_FIELD_PRIVATE (type, index) - && !TYPE_FIELD_PROTECTED (type, index)) - return 1; - else - return 0; -} - static void cplus_describe_child (const struct varobj *parent, int index, std::string *cname, struct value **cvalue, struct type **ctype, @@ -751,9 +736,9 @@ cplus_describe_child (const struct varobj *parent, int index, if ((type == basetype && type_index == vptr_fieldno) || type->field (type_index).is_artificial ()) ; /* ignore vptr */ - else if (match_accessibility (type, type_index, acc)) - --index; - ++type_index; + else if (type->field (type_index).accessibility () == acc) + --index; + ++type_index; } --type_index; diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index ac27e83618b..a59d77b76a9 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -73,9 +73,10 @@ compile_cplus_instance::decl_name (const char *natural) static enum gcc_cp_symbol_kind get_field_access_flag (const struct type *type, int num) { - if (TYPE_FIELD_PROTECTED (type, num)) + field &fld = type->field (num); + if (fld.is_protected ()) return GCC_CP_ACCESS_PROTECTED; - else if (TYPE_FIELD_PRIVATE (type, num)) + else if (fld.is_private ()) return GCC_CP_ACCESS_PRIVATE; /* GDB assumes everything else is public. */ @@ -583,7 +584,7 @@ compile_cplus_convert_struct_or_union_members { const char *field_name = type->field (i).name (); - if (TYPE_FIELD_IGNORE (type, i) + if (type->field (i).is_ignored () || type->field (i).is_artificial ()) continue; diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 820a761054a..a803c786d2b 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -265,7 +265,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, /* Bitfields require special handling, especially due to byte order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); @@ -290,7 +290,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, } else { - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index e3a12a45afd..d40de91001f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5229,33 +5229,34 @@ recursive_dump_type (struct type *type, int spaces) gdb_printf ("%s\n", host_address_to_string (type->fields ())); for (idx = 0; idx < type->num_fields (); idx++) { + field &fld = type->field (idx); if (type->code () == TYPE_CODE_ENUM) gdb_printf ("%*s[%d] enumval %s type ", spaces + 2, "", - idx, plongest (type->field (idx).loc_enumval ())); + idx, plongest (fld.loc_enumval ())); else gdb_printf ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "", - idx, plongest (type->field (idx).loc_bitpos ()), - type->field (idx).bitsize ()); + idx, plongest (fld.loc_bitpos ()), + fld.bitsize ()); gdb_printf ("%s name '%s' (%s)", - host_address_to_string (type->field (idx).type ()), - type->field (idx).name () != NULL - ? type->field (idx).name () + host_address_to_string (fld.type ()), + fld.name () != NULL + ? fld.name () : "", - host_address_to_string (type->field (idx).name ())); - if (TYPE_FIELD_VIRTUAL (type, idx)) + host_address_to_string (fld.name ())); + if (fld.is_virtual ()) gdb_printf (" virtual"); - if (TYPE_FIELD_PRIVATE (type, idx)) + if (fld.is_private ()) gdb_printf (" private"); - else if (TYPE_FIELD_PROTECTED (type, idx)) + else if (fld.is_protected ()) gdb_printf (" protected"); - else if (TYPE_FIELD_IGNORE (type, idx)) + else if (fld.is_ignored ()) gdb_printf (" ignored"); gdb_printf ("\n"); - if (type->field (idx).type () != NULL) + if (fld.type () != NULL) { - recursive_dump_type (type->field (idx).type (), spaces + 4); + recursive_dump_type (fld.type (), spaces + 4); } } if (type->code () == TYPE_CODE_RANGE) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index b6a693f1316..6c011a56dd8 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1974,15 +1974,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define BASETYPE_VIA_VIRTUAL(thistype, index) \ ((thistype)->field (index).is_virtual ()) -#define TYPE_FIELD_PRIVATE(thistype, n) \ - ((thistype)->field (n).is_private ()) -#define TYPE_FIELD_PROTECTED(thistype, n) \ - ((thistype)->field (n).is_protected ()) -#define TYPE_FIELD_IGNORE(thistype, n) \ - ((thistype)->field (n).is_ignored ()) -#define TYPE_FIELD_VIRTUAL(thistype, n) \ - ((thistype)->field (n).is_virtual ()) - #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n] #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 41058a8b59e..b5d66269d6e 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -486,7 +486,9 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int if (HAVE_CPLUS_STRUCT (type)) { - if (TYPE_FIELD_PROTECTED (type, i)) + field &fld = type->field (i); + + if (fld.is_protected ()) { if (section_type != s_protected) { @@ -495,7 +497,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int level + 2, ""); } } - else if (TYPE_FIELD_PRIVATE (type, i)) + else if (fld.is_private ()) { if (section_type != s_private) { diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index fb9386293a6..05601622560 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -604,7 +604,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, /* Bitfields require special handling, especially due to byte order problems. */ - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); @@ -629,7 +629,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, } else { - if (TYPE_FIELD_IGNORE (type, i)) + if (type->field (i).is_ignored ()) { fputs_styled ("", metadata_style.style (), stream); -- 2.40.1