From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by sourceware.org (Postfix) with ESMTPS id 2C170385783A for ; Wed, 26 Aug 2020 10:06:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2C170385783A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x442.google.com with SMTP id a5so1195438wrm.6 for ; Wed, 26 Aug 2020 03:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VqN+l/H1tlcLMGZ4VKaC9Nxxf5rfe7PGMkUo5RHkI6A=; b=GYNb6NLsOpsPLV6vJ3Ecd89nOTB/lWgneidPxUiFQGBU5L4jErVDoZ3jDEavJsuEqZ 77AtiybeSWfH/7vV7ZRxVgNAW+NhVMNBXG1SoDd94694EFk73cp4ub7FGoRP+7eDpt9F zFoz+JVB6RsQAXjcrR4oIdXbvgpGm4AGVSuwilC8hr54eLoN4RnzQKwmVS7hD1tyjJTU KbjrGkUs1jp74nIAPsG78Sgrhy22TLNcCOIeBRr04mchmIGFBK/JIV+1zIPdUTpUoy5h eftR+BcwOA7fcYBrNb3ChBDxUImWWzF5rchCIFRVFM6Qm8OsDmbAtOyZNX8itKmyt8Ko F/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VqN+l/H1tlcLMGZ4VKaC9Nxxf5rfe7PGMkUo5RHkI6A=; b=PbOBsJknL8oAzv1CGgWb3yIxWMzuFAOUQu8jDfg/HseppI4TuQuzz46zwwJg/w/w/T pH5Yeiyx69umUAgK5JdH3BI9DOkurFqbEzcTO5HaoCdWWSfGGov0PpB26dswaSSDiXo0 y3QDvm1HcbIo/VlxRPhpCXfCcylJEI9NQzRX45eBtO16DIXlUHwUUt0j+49BYpC6idfT fzxRJ0c14+F/eW4+SktGtT9OaTdX2TS76J+Iq4Z4C42sD3hQL1HnHnPe3V6EeqPlQqUM dBJt+yDMtfGzdQZqpeohYQuIRb8jsN6BXTHu1MKueuGQOIAk98VR/KGYy8PAet+O0pL3 IGNw== X-Gm-Message-State: AOAM532b1M2Ucravs43GfqaaO9vdRzL5bxwJnfZ6xle0aPNIQcgZicD0 6wQ7fGtIkyhtHUoX5mnNV6M/LtiXichFlw== X-Google-Smtp-Source: ABdhPJz501EWZdbQp6WCVs3NiSrjv3ElFkDtuKjBPNATpLo+rcfuVvjhBHEJ34299bDyLJjxcKKrtg== X-Received: by 2002:a5d:674d:: with SMTP id l13mr14814456wrw.151.1598436411962; Wed, 26 Aug 2020 03:06:51 -0700 (PDT) Received: from localhost (host109-148-134-218.range109-148.btcentralplus.com. [109.148.134.218]) by smtp.gmail.com with ESMTPSA id n4sm4540661wrv.8.2020.08.26.03.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 03:06:51 -0700 (PDT) Date: Wed, 26 Aug 2020 11:06:50 +0100 From: Andrew Burgess To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/3] Use type_instance_flags more throughout Message-ID: <20200826100650.GU853475@embecosm.com> References: <20200821144523.19451-1-pedro@palves.net> <20200821144523.19451-3-pedro@palves.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200821144523.19451-3-pedro@palves.net> X-Operating-System: Linux/5.6.15-200.fc31.x86_64 (x86_64) X-Uptime: 11:04:32 up 38 days, 19:19, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 10:06:55 -0000 * Pedro Alves [2020-08-21 15:45:22 +0100]: > The next patch in this series will rewrites enum_flags fixing some API > holes. That would cause build failures around code using > type_instance_flags. Or rather, that should be using it, but wasn't. > > This patch fixes it by using type_instance_flags throughout instead of > plain integers. > > Note that we can't make the seemingly obvious change to struct > type::instance_flags: > > - unsigned instance_flags : 9; > + ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9; > > Because G++ complains then that 9 bits isn't sufficient for holding > all values of type_instance_flag_value. > > So the patch adds a cast to TYPE_INSTANCE_FLAGS, and adds a separate > SET_TYPE_INSTANCE_FLAGS macro. > > gdb/ChangeLog: > > * dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags. > * eval.c (fake_method::fake_method): Use SET_TYPE_INSTANCE_FLAGS. > * gdbarch.h, gdbarch.c: Regenerate. > * gdbarch.sh (address_class_type_flags): Use type_instance_flags. > (address_class_name_to_type_flags): Use type_instance_flags and > bool. > * gdbtypes.c (address_space_name_to_int) > (address_space_int_to_name, make_qualified_type): Use > type_instance_flags. > (make_qualified_type): Use type_instance_flags and > SET_TYPE_INSTANCE_FLAGS. > (make_type_with_address_space, make_cv_type, make_vector_type) > (check_typedef): Use type_instance_flags. > (recursive_dump_type): Cast type_instance_flags to unsigned for > printing. > (copy_type_recursive): Use SET_TYPE_INSTANCE_FLAGS. > * gdbtypes.h (TYPE_INSTANCE_FLAGS): Return a type_instance_flags. > (SET_TYPE_INSTANCE_FLAGS): New. > (address_space_name_to_int, address_space_int_to_name) > (make_type_with_address_space): Pass flags using > type_instance_flags instead of int. > * stabsread.c (cleanup_undefined_types_noname): Use > SET_TYPE_INSTANCE_FLAGS. > * type-stack.c (type_stack::follow_types): Use type_instance_flags. Pedro, While testing this I found a few issues building with --enable-targets=all. The patch below fixes all of the issues I ran into. Feel free to merge this with your work of keep it as a separate patch, whatever works for you. Thanks, Andrew --- commit b6c8d1ca8077fa7ea2d6f6336b2115b3dcf9dfbb Author: Andrew Burgess Date: Wed Aug 26 11:02:22 2020 +0100 gdb: additional changes to make use of type_instance_flags more Further updates to make use of type_instance_flags. gdb/ChangeLog: * avr-tdep.c (avr_address_class_type_flags): Update return type. (avr_address_class_type_flags_to_name): Update argument types. (avr_address_class_name_to_type_flags): Update return type and argument types. * ft32-tdep.c (ft32_address_class_type_flags): Update return type. (ft32_address_class_type_flags_to_name): Update argument types. (ft32_address_class_name_to_type_flags): Update return type and argument types. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (address_class_type_flags_to_name): Update argument types. * s390-tdep.c (s390_address_class_type_flags): Update return type. (s390_address_class_type_flags_to_name): Update argument types. (s390_address_class_name_to_type_flags): Update return type and argument types. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 74ab531711e..0148f4e4db2 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1372,7 +1372,7 @@ avr_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) This method maps DW_AT_address_class attributes to a type_instance_flag_value. */ -static int +static type_instance_flags avr_address_class_type_flags (int byte_size, int dwarf2_addr_class) { /* The value 1 of the DW_AT_address_class attribute corresponds to the @@ -1389,7 +1389,8 @@ avr_address_class_type_flags (int byte_size, int dwarf2_addr_class) Convert a type_instance_flag_value to an address space qualifier. */ static const char* -avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) +avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, + type_instance_flags type_flags) { if (type_flags & AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH) return "flash"; @@ -1401,18 +1402,18 @@ avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) Convert an address space qualifier to a type_instance_flag_value. */ -static int +static bool avr_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char* name, - int *type_flags_ptr) + type_instance_flags *type_flags_ptr) { if (strcmp (name, "flash") == 0) { *type_flags_ptr = AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH; - return 1; + return true; } else - return 0; + return false; } /* Initialize the gdbarch structure for the AVR's. */ diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 99ef69de770..8ce16c06505 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -341,7 +341,7 @@ ft32_pointer_to_address (struct gdbarch *gdbarch, This method maps DW_AT_address_class attributes to a type_instance_flag_value. */ -static int +static type_instance_flags ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class) { /* The value 1 of the DW_AT_address_class attribute corresponds to the @@ -357,7 +357,8 @@ ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class) Convert a type_instance_flag_value to an address space qualifier. */ static const char* -ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) +ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, + type_instance_flags type_flags) { if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) return "flash"; @@ -369,18 +370,18 @@ ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) Convert an address space qualifier to a type_instance_flag_value. */ -static int +static bool ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char* name, - int *type_flags_ptr) + type_instance_flags *type_flags_ptr) { if (strcmp (name, "flash") == 0) { *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; - return 1; + return true; } else - return 0; + return false; } /* Given a return value in `regbuf' with a type `valtype', diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 2be959ecfc9..a3a67020078 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3526,7 +3526,7 @@ gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch) } const char * -gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) +gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->address_class_type_flags_to_name != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 8a4a384fda9..5ac4f5495c4 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -854,8 +854,8 @@ extern void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbar extern int gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch); -typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, int type_flags); -extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags); +typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, type_instance_flags type_flags); +extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags); extern void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name); /* Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction. diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 7e9204119bd..a64afb5a3d2 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -690,7 +690,7 @@ v;int;cannot_step_breakpoint;;;0;0;;0 # non-steppable watchpoints. v;int;have_nonsteppable_watchpoint;;;0;0;;0 F;type_instance_flags;address_class_type_flags;int byte_size, int dwarf2_addr_class;byte_size, dwarf2_addr_class -M;const char *;address_class_type_flags_to_name;int type_flags;type_flags +M;const char *;address_class_type_flags_to_name;type_instance_flags type_flags;type_flags # Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction. # FS are passed from the generic execute_cfa_program function. m;bool;execute_dwarf_cfa_vendor_op;gdb_byte op, struct dwarf2_frame_state *fs;op, fs;;default_execute_dwarf_cfa_vendor_op;;0 diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 65cb23705d2..49a507f7c2d 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1583,7 +1583,7 @@ s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr) /* Implement addr_class_type_flags gdbarch method. Only used for ABI_LINUX_ZSERIES. */ -static int +static type_instance_flags s390_address_class_type_flags (int byte_size, int dwarf2_addr_class) { if (byte_size == 4) @@ -1596,7 +1596,8 @@ s390_address_class_type_flags (int byte_size, int dwarf2_addr_class) Only used for ABI_LINUX_ZSERIES. */ static const char * -s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) +s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, + type_instance_flags type_flags) { if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) return "mode32"; @@ -1607,18 +1608,18 @@ s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags) /* Implement addr_class_name_to_type_flags gdbarch method. Only used for ABI_LINUX_ZSERIES. */ -static int +static bool s390_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char *name, - int *type_flags_ptr) + type_instance_flags *type_flags_ptr) { if (strcmp (name, "mode32") == 0) { *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; - return 1; + return true; } else - return 0; + return false; } /* Inferior function calls. */