From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 0583F3858D32 for ; Mon, 19 Dec 2022 18:17:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0583F3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x136.google.com with SMTP id y3so5168838ilq.0 for ; Mon, 19 Dec 2022 10:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9iOhf6U/nyqN2WtDs7kaLqNKdCrL77m+ERDp08KAOII=; b=fcjB9QuPHCFD8LVZW0lyEzUADdQTFRsTXIflpthJjopFaKWmQIBXdfe7X5l3KD8Hvr dJmmo+iJFpL1hERrPqT0r4yjdSFEffJ2dKliXchubIHpJKtZgsLM7aHIG0bql11BmQCx PZlXv0AEKqpXDMPHFQXbcDVZpYX25Ds+KLqUkWZLuuys6qmBE5Z4jLo6PwcAt3MIvKc6 2gu+eltb4Z6SfILkifHaTfGwIWDCANMgscKlwuYOEQJ/HqghUThvHe7ffWwvYqFbVwHc zrg1U/OnSlKlfC7rfT5814jrOt8AIgl6nV31bV5QFElYY7HXtvvbJc7M3TT+hH9iL0Qg X6FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9iOhf6U/nyqN2WtDs7kaLqNKdCrL77m+ERDp08KAOII=; b=Co+Bix7jQxKJAFftLcByytEu2rRrpKHuu6YmtJY7E35QWPLtj9knBmPr2u+69MHdFR kld57N+jiSKBC5NlW4eQoFGbDnC5xhS/m5Srav+BK2zV/JiwgSH0FGiKbvWfqPt1FuOl AxgOLgrANxi/qaZZp8P13Rnx8lq07DkCRu0mIJ8Kk3l1CkIaFvbGVsF8g0cCZ6WrqTDt h0CnkpvDZ1RI+6adsDvCKsMp13DkpKF7SvoX1ikUmo+QmI5tNvUeWTp0+zu0H975ee98 /Pe2KbP6yDs8lWaCgaMqXS99hAI1/BNBsu5ArgelebBppDlv09EIUgCNH6UqWTDSGbXR eWSQ== X-Gm-Message-State: ANoB5plnyMAcJZhcYfO3Wj8YkcLiTDEQv3w7rxeArbnMYVi5VzhlrpbD zA1swR0yKnaIgtIt6zz7o5Hq0j0/sIx1Kbqp X-Google-Smtp-Source: AA0mqf41cxgt7qprPb33tf4NS4iQMEC93aN2hnVpKwFimQyv02Q211qGfNCfeDceCmc51VtR7MtEgA== X-Received: by 2002:a05:6e02:be7:b0:303:7171:7f with SMTP id d7-20020a056e020be700b003037171007fmr23404939ilu.17.1671473862220; Mon, 19 Dec 2022 10:17:42 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id w10-20020a92c88a000000b0030287ff00fesm3459204ilo.60.2022.12.19.10.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 10:17:41 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Convert exp_uses_objfile to a method of expression Date: Mon, 19 Dec 2022 11:17:31 -0700 Message-Id: <20221219181732.469376-2-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219181732.469376-1-tromey@adacore.com> References: <20221219181732.469376-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 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 List-Id: This changes the exp_uses_objfile function to be a method of 'expression'. --- gdb/eval.c | 9 +++++++++ gdb/expression.h | 5 +++++ gdb/parse.c | 12 ------------ gdb/parser-defs.h | 2 -- gdb/printcmd.c | 2 +- gdb/varobj.c | 3 +-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index d0a4a16ceb5..a43eda54411 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -89,6 +89,15 @@ parse_to_comma_and_eval (const char **expp) /* See expression.h. */ +bool +expression::uses_objfile (struct objfile *objfile) const +{ + gdb_assert (objfile->separate_debug_objfile_backlink == nullptr); + return op->uses_objfile (objfile); +} + +/* See expression.h. */ + struct value * expression::evaluate (struct type *expect_type, enum noside noside) { diff --git a/gdb/expression.h b/gdb/expression.h index a56b1856cda..47626b3cb8e 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -214,6 +214,11 @@ struct expression op->dump (stream, 0); } + /* Return true if this expression uses OBJFILE (and will become + dangling when OBJFILE is unloaded), otherwise return false. + OBJFILE must not be a separate debug info file. */ + bool uses_objfile (struct objfile *objfile) const; + /* Evaluate the expression. EXPECT_TYPE is the context type of the expression; normally this should be nullptr. NOSIDE controls how evaluation is performed. */ diff --git a/gdb/parse.c b/gdb/parse.c index bfd9de09a10..cccdb8f98d9 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -667,18 +667,6 @@ parser_fprintf (FILE *x, const char *y, ...) va_end (args); } -/* Return rue if EXP uses OBJFILE (and will become dangling when - OBJFILE is unloaded), otherwise return false. OBJFILE must not be - a separate debug info file. */ - -bool -exp_uses_objfile (struct expression *exp, struct objfile *objfile) -{ - gdb_assert (objfile->separate_debug_objfile_backlink == NULL); - - return exp->op->uses_objfile (objfile); -} - void _initialize_parse (); void _initialize_parse () diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index ade3039ebb0..5fda49ce72c 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -421,7 +421,5 @@ extern bool fits_in_type (int n_sign, ULONGEST n, int type_bits, extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3); -extern bool exp_uses_objfile (struct expression *exp, struct objfile *objfile); - #endif /* PARSER_DEFS_H */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 60921415abd..bbe8d6eb4b2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2360,7 +2360,7 @@ clear_dangling_display_expressions (struct objfile *objfile) } if (bl_objf == objfile - || (d->exp != NULL && exp_uses_objfile (d->exp.get (), objfile))) + || (d->exp != nullptr && d->exp->uses_objfile (objfile))) { d->exp.reset (); d->block = NULL; diff --git a/gdb/varobj.c b/gdb/varobj.c index 6ed5b7049bc..599dd3013a7 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2412,8 +2412,7 @@ varobj_invalidate_if_uses_objfile (struct objfile *objfile) } } - if (var->root->exp != nullptr - && exp_uses_objfile (var->root->exp.get (), objfile)) + if (var->root->exp != nullptr && var->root->exp->uses_objfile (objfile)) { /* The varobj's current expression references the objfile. For globals and floating, it is possible that when we try to -- 2.38.1