From patchwork Wed Mar 1 15:18:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 65843 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B57263858D3C for ; Wed, 1 Mar 2023 15:19:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B57263858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677683976; bh=x9jbd9PJfv45cpocMjVmqy9jHVz4dxXgZrnaDfhWQBw=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BvANP60FNWgxpGkjGYID+uwmm75peaGl1xYI8SG+nf47pvXM/sl/tXmMPAskUAgm5 T68uJGp+FiSo4DluMnDdP66hS7F54qotqHqieOcDPAYaU3uwvZSX42AS5FhjM6HIsc ka1/0ENlJ1SyyLvqCg9t0IwYsEqfwpoy8naZ7mIQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 04B5D3858D3C for ; Wed, 1 Mar 2023 15:18:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04B5D3858D3C Received: by mail-il1-x136.google.com with SMTP id g9so925439ila.8 for ; Wed, 01 Mar 2023 07:18:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677683924; h=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=x9jbd9PJfv45cpocMjVmqy9jHVz4dxXgZrnaDfhWQBw=; b=i2wqbQP5FkZOPZnOtyYbk6drSkPKmytEST1gf/V2LC+MHW/HExUKkqYvHMAsGGJRaH gaAoU2Nxkns+hiyUHDTBe9J1XGvMGIZ1YAx1GwXSVbgi77FW1WcYadDpqvb4eTkHH/o5 lzYcGTZp9J0bPKK4jY29Fo+zLOY5Y/39pNt6QrbCl3Sdtv/NkGYDaNkXKgS89dz6ps4B tgHl4xgDB5wRwktvQLPJlDUv5dl8fD4eSzahUQr+wi/LFb4cX/3E6F6RRbqbnBr1NWT2 GtxScxiHlPD3p3elemO/5/hn8bfx/hWcaDXH6vR3nEbFrndTir6mgpVhriJm2ygjhLGm smzg== X-Gm-Message-State: AO0yUKUZkV/XheW2CpjkqoTdwCTNvwmEUDJ0Pe5ENYJMkLIjQZ+lI4XW M237Mn2kO23/Q5aTsPC216cWxd6MHVYpKUao X-Google-Smtp-Source: AK7set/Hn4rN3ZVQk/F9nZrqe+Xu+mYnvS7Fh3bv7HGrANZlC1KESZuXGzASznyBrATbF+EXtiqc3Q== X-Received: by 2002:a05:6e02:1b89:b0:315:7911:748a with SMTP id h9-20020a056e021b8900b003157911748amr15480298ili.1.1677683924238; Wed, 01 Mar 2023 07:18:44 -0800 (PST) Received: from localhost.localdomain (75-166-130-93.hlrn.qwest.net. [75.166.130.93]) by smtp.gmail.com with ESMTPSA id p10-20020a02b38a000000b003c4f96913c1sm3974241jan.105.2023.03.01.07.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 07:18:43 -0800 (PST) Date: Wed, 01 Mar 2023 08:18:42 -0700 Subject: [PATCH 1/2] Make gdb property batons type-safe MIME-Version: 1.0 Message-Id: <20230301-submit-baton-stuff-v1-1-567d536a8245@adacore.com> References: <20230301-submit-baton-stuff-v1-0-567d536a8245@adacore.com> In-Reply-To: <20230301-submit-baton-stuff-v1-0-567d536a8245@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-11.6 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" gdbtypes treats dynamic property batons as 'void *', but in actuality the only users all use dwarf2_property_baton. This patch changes this code to be type-safe. If a new type is needed here, it seems like that too could be done in a type-safe way. --- gdb/dwarf2/loc.c | 12 ++++-------- gdb/gdbtypes.h | 11 ++++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 4727651027b..bf582bcfeff 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1649,8 +1649,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, { case PROP_LOCEXPR: { - const struct dwarf2_property_baton *baton - = (const struct dwarf2_property_baton *) prop->baton (); + const struct dwarf2_property_baton *baton = prop->baton (); gdb_assert (baton->property_type != NULL); bool is_reference = baton->locexpr.is_reference; @@ -1692,8 +1691,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, case PROP_LOCLIST: { - struct dwarf2_property_baton *baton - = (struct dwarf2_property_baton *) prop->baton (); + struct dwarf2_property_baton *baton = prop->baton (); CORE_ADDR pc; const gdb_byte *data; struct value *val; @@ -1724,8 +1722,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, case PROP_ADDR_OFFSET: { - struct dwarf2_property_baton *baton - = (struct dwarf2_property_baton *) prop->baton (); + struct dwarf2_property_baton *baton = prop->baton (); const struct property_addr_info *pinfo; struct value *val; @@ -1775,8 +1772,7 @@ dwarf2_compile_property_to_c (string_file *stream, CORE_ADDR pc, struct symbol *sym) { - struct dwarf2_property_baton *baton - = (struct dwarf2_property_baton *) prop->baton (); + struct dwarf2_property_baton *baton = prop->baton (); const gdb_byte *data; size_t size; dwarf2_per_cu_data *per_cu; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index c2253310666..701a64d457a 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -64,6 +64,7 @@ struct value_print_options; struct language_defn; struct dwarf2_per_cu_data; struct dwarf2_per_objfile; +struct dwarf2_property_baton; /* Some macros for char-based bitfields. */ @@ -289,7 +290,7 @@ union dynamic_prop_data /* Storage for dynamic property. */ - void *baton; + dwarf2_property_baton *baton; /* Storage of variant parts for a type. A type with variant parts has all its fields "linearized" -- stored in a single field @@ -339,7 +340,7 @@ struct dynamic_prop m_data.const_val = const_val; } - void *baton () const + dwarf2_property_baton *baton () const { gdb_assert (m_kind == PROP_LOCEXPR || m_kind == PROP_LOCLIST @@ -348,19 +349,19 @@ struct dynamic_prop return m_data.baton; } - void set_locexpr (void *baton) + void set_locexpr (dwarf2_property_baton *baton) { m_kind = PROP_LOCEXPR; m_data.baton = baton; } - void set_loclist (void *baton) + void set_loclist (dwarf2_property_baton *baton) { m_kind = PROP_LOCLIST; m_data.baton = baton; } - void set_addr_offset (void *baton) + void set_addr_offset (dwarf2_property_baton *baton) { m_kind = PROP_ADDR_OFFSET; m_data.baton = baton;