From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id 7310F393BC0F for ; Fri, 1 Jan 2021 21:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7310F393BC0F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 1421C391E for ; Fri, 1 Jan 2021 15:49:07 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSIFkZFJ4oE4DvSIFkuHhU; Fri, 01 Jan 2021 15:49:07 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kkogKpetj1Op32pqEe6wgrrdx3l7isaNPxvPgXOh1+s=; b=Ih38lDuAjNE081sljYlBI8A4Yt Ax38JyMlpEV/koFkzWgnJzrwdXWhEHzeZaYDVTOKa6GxbxWq/kImbJNUfNGNmLhS3ISufX76r3HFb +4F1a+emAeJEGgXW8hBZROdp6; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60430 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kvSIE-002A5T-SK for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:49:06 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 202/203] Use bound_minimal_symbol in var_msym_value_operation Date: Fri, 1 Jan 2021 14:47:22 -0700 Message-Id: <20210101214723.1784144-203-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210101214723.1784144-1-tom@tromey.com> References: <20210101214723.1784144-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kvSIE-002A5T-SK X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60430 X-Source-Auth: tom+tromey.com X-Email-Count: 203 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3029.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=no 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: Fri, 01 Jan 2021 21:49:10 -0000 This changes var_msym_value_operation to use a bound_minimal_symbol rather than separate minsym and objfile parameters. The main benefit of this is removing the possibly-confusing check_objfile overload for a plain minimal symbol. gdb/ChangeLog 2021-01-01 Tom Tromey * parse.c (parser_state::push_symbol, parser_state::push_dollar): Update. * p-exp.y (variable): Update. * go-exp.y (variable): Update. * expprint.c (dump_for_expression): Use bound_minimal_symbol. Remove overload for objfile. * expop.h (eval_op_var_msym_value): Use bound_minimal_symbol parameter. (check_objfile): Likewise. (dump_for_expression): Likewise. Remove overload for objfile. (class var_msym_value_operation): Use bound_minimal_symbol. * eval.c (eval_op_var_msym_value): Use bound_minimal_symbol parameter. (var_msym_value_operation::evaluate_for_address) (var_msym_value_operation::evaluate_for_sizeof) (var_msym_value_operation::evaluate_for_cast): Update. * d-exp.y (PrimaryExpression): Update. * c-exp.y (variable): Update. * ax-gdb.c (var_msym_value_operation::do_generate_ax): Update. * ada-lang.c (ada_var_msym_value_operation::evaluate_for_cast): Update. * ada-exp.y (write_var_or_type): Update. --- gdb/ChangeLog | 25 +++++++++++++++++++++++++ gdb/ada-exp.y | 3 +-- gdb/ada-lang.c | 5 ++--- gdb/ax-gdb.c | 6 +++--- gdb/c-exp.y | 4 ++-- gdb/d-exp.y | 3 +-- gdb/eval.c | 25 +++++++++++-------------- gdb/expop.h | 26 +++++++------------------- gdb/expprint.c | 14 ++++---------- gdb/go-exp.y | 2 +- gdb/p-exp.y | 2 +- gdb/parse.c | 5 ++--- 12 files changed, 60 insertions(+), 60 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 033bde38d3c..ca37ec602e1 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1518,8 +1518,7 @@ write_var_or_type (struct parser_state *par_state, = ada_lookup_simple_minsym (encoded_name); if (msym.minsym != NULL) { - par_state->push_new - (msym.minsym, msym.objfile); + par_state->push_new (msym); /* Maybe cause error here rather than later? FIXME? */ write_selectors (par_state, encoded_name + tail_index); return NULL; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4ab9172cc81..e848e141465 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10407,9 +10407,8 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (expect_type, not_lval); - value *val = evaluate_var_msym_value (noside, - std::get<1> (m_storage), - std::get<0> (m_storage)); + const bound_minimal_symbol &b = std::get<0> (m_storage); + value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); val = ada_value_cast (expect_type, val); diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 788be528d1b..33fc5383764 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1631,13 +1631,13 @@ var_msym_value_operation::do_generate_ax (struct expression *exp, struct axs_value *value, struct type *cast_type) { - gen_msym_var_ref (ax, value, std::get<0> (m_storage), - std::get<1> (m_storage)); + const bound_minimal_symbol &b = std::get<0> (m_storage); + gen_msym_var_ref (ax, value, b.minsym, b.objfile); if (value->type->code () == TYPE_CODE_ERROR) { if (cast_type == nullptr) - error_unknown_type (std::get<0> (m_storage)->linkage_name ()); + error_unknown_type (b.minsym->linkage_name ()); value->type = cast_type; } } diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 3ce08838080..dbdd68fb183 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1195,7 +1195,7 @@ variable: name_not_typename = find_gnu_ifunc (sym.symbol); if (resolver.minsym != NULL) pstate->push_new - (resolver.minsym, resolver.objfile); + (resolver); else pstate->push_new (sym.symbol, sym.block); @@ -1243,7 +1243,7 @@ variable: name_not_typename (alias_target, SYMBOL_BLOCK_VALUE (alias_target)); else pstate->push_new - (msymbol.minsym, msymbol.objfile); + (msymbol); } } ; diff --git a/gdb/d-exp.y b/gdb/d-exp.y index d79eaf14a8f..34b97d03489 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -470,8 +470,7 @@ PrimaryExpression: /* Lookup foreign name in global static symbols. */ msymbol = lookup_bound_minimal_symbol (copy.c_str ()); if (msymbol.minsym != NULL) - pstate->push_new - (msymbol.minsym, msymbol.objfile); + pstate->push_new (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command")); else diff --git a/gdb/eval.c b/gdb/eval.c index 49e53f930b9..bf865296baa 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1004,14 +1004,15 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp, struct value * eval_op_var_msym_value (struct type *expect_type, struct expression *exp, enum noside noside, - minimal_symbol *msymbol, struct objfile *objfile) + bound_minimal_symbol msymbol) { - value *val = evaluate_var_msym_value (noside, objfile, msymbol); + value *val = evaluate_var_msym_value (noside, msymbol.objfile, + msymbol.minsym); struct type *type = value_type (val); if (type->code () == TYPE_CODE_ERROR && (noside != EVAL_AVOID_SIDE_EFFECTS)) - error_unknown_type (msymbol->print_name ()); + error_unknown_type (msymbol.minsym->print_name ()); return val; } @@ -2508,9 +2509,8 @@ value * var_msym_value_operation::evaluate_for_address (struct expression *exp, enum noside noside) { - value *val = evaluate_var_msym_value (noside, - std::get<1> (m_storage), - std::get<0> (m_storage)); + const bound_minimal_symbol &b = std::get<0> (m_storage); + value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *type = lookup_pointer_type (value_type (val)); @@ -2616,14 +2616,12 @@ var_msym_value_operation::evaluate_for_sizeof (struct expression *exp, enum noside noside) { - minimal_symbol *msymbol = std::get<0> (m_storage); - value *mval = evaluate_var_msym_value (noside, - std::get<1> (m_storage), - msymbol); + const bound_minimal_symbol &b = std::get<0> (m_storage); + value *mval = evaluate_var_msym_value (noside, b.objfile, b.minsym); struct type *type = value_type (mval); if (type->code () == TYPE_CODE_ERROR) - error_unknown_type (msymbol->print_name ()); + error_unknown_type (b.minsym->print_name ()); /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; @@ -2727,9 +2725,8 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (to_type, not_lval); - value *val = evaluate_var_msym_value (noside, - std::get<1> (m_storage), - std::get<0> (m_storage)); + const bound_minimal_symbol &b = std::get<0> (m_storage); + value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); val = value_cast (to_type, val); diff --git a/gdb/expop.h b/gdb/expop.h index 0abe6dac90b..98d5d34c7f5 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -52,8 +52,7 @@ extern struct value *eval_op_scope (struct type *expect_type, extern struct value *eval_op_var_msym_value (struct type *expect_type, struct expression *exp, enum noside noside, - minimal_symbol *msymbol, - struct objfile *objfile); + bound_minimal_symbol msymbol); extern struct value *eval_op_var_entry_value (struct type *expect_type, struct expression *exp, enum noside noside, symbol *sym); @@ -243,11 +242,9 @@ check_objfile (const struct block *block, struct objfile *objfile) } static inline bool -check_objfile (minimal_symbol *minsym, struct objfile *objfile) +check_objfile (bound_minimal_symbol minsym, struct objfile *objfile) { - /* This may seem strange but minsyms are only used with an objfile - as well. */ - return false; + return check_objfile (minsym.objfile, objfile); } static inline bool @@ -330,7 +327,7 @@ extern void dump_for_expression (struct ui_file *stream, int depth, extern void dump_for_expression (struct ui_file *stream, int depth, symbol *sym); extern void dump_for_expression (struct ui_file *stream, int depth, - minimal_symbol *msym); + bound_minimal_symbol msym); extern void dump_for_expression (struct ui_file *stream, int depth, const block *bl); extern void dump_for_expression (struct ui_file *stream, int depth, @@ -339,8 +336,6 @@ extern void dump_for_expression (struct ui_file *stream, int depth, enum c_string_type_values flags); extern void dump_for_expression (struct ui_file *stream, int depth, enum range_flag flags); -extern void dump_for_expression (struct ui_file *stream, int depth, - objfile *objf); extern void dump_for_expression (struct ui_file *stream, int depth, const std::unique_ptr &comp); @@ -445,7 +440,7 @@ check_constant (const operation_up &item) } static inline bool -check_constant (struct minimal_symbol *msym) +check_constant (bound_minimal_symbol msym) { return false; } @@ -468,12 +463,6 @@ check_constant (const std::string &str) return true; } -static inline bool -check_constant (struct objfile *objfile) -{ - return true; -} - static inline bool check_constant (ULONGEST cst) { @@ -705,7 +694,7 @@ class long_const_operation }; class var_msym_value_operation - : public maybe_constant_operation + : public maybe_constant_operation { public: @@ -716,8 +705,7 @@ class var_msym_value_operation enum noside noside) override { return eval_op_var_msym_value (expect_type, exp, noside, - std::get<0> (m_storage), - std::get<1> (m_storage)); + std::get<0> (m_storage)); } value *evaluate_for_sizeof (struct expression *exp, enum noside noside) diff --git a/gdb/expprint.c b/gdb/expprint.c index 5e55e77b5a2..c0969e37295 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -110,10 +110,11 @@ dump_for_expression (struct ui_file *stream, int depth, symbol *sym) } void -dump_for_expression (struct ui_file *stream, int depth, minimal_symbol *msym) +dump_for_expression (struct ui_file *stream, int depth, + bound_minimal_symbol msym) { - fprintf_filtered (stream, _("%*sMinsym: %s\n"), depth, "", - msym->print_name ()); + fprintf_filtered (stream, _("%*sMinsym %s in objfile %s\n"), depth, "", + msym.minsym->print_name (), objfile_name (msym.objfile)); } void @@ -162,13 +163,6 @@ dump_for_expression (struct ui_file *stream, int depth, fputs_unfiltered ("\n", stream); } -void -dump_for_expression (struct ui_file *stream, int depth, objfile *objf) -{ - fprintf_filtered (stream, _("%*sObjfile: %s\n"), depth, "", - objfile_name (objf)); -} - void dump_for_expression (struct ui_file *stream, int depth, enum range_flag flags) diff --git a/gdb/go-exp.y b/gdb/go-exp.y index d096cc8b7c9..05822d142db 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -581,7 +581,7 @@ variable: name_not_typename lookup_bound_minimal_symbol (arg.c_str ()); if (msymbol.minsym != NULL) pstate->push_new - (msymbol.minsym, msymbol.objfile); + (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. " diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 4ac2f1f268d..c10402e4e5c 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -730,7 +730,7 @@ variable: name_not_typename lookup_bound_minimal_symbol (arg.c_str ()); if (msymbol.minsym != NULL) pstate->push_new - (msymbol.minsym, msymbol.objfile); + (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. " diff --git a/gdb/parse.c b/gdb/parse.c index 3b7680e3127..d5215d89d14 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -226,8 +226,7 @@ parser_state::push_symbol (const char *name, struct symbol *sym) { struct bound_minimal_symbol msymbol = lookup_bound_minimal_symbol (name); if (msymbol.minsym != NULL) - push_new (msymbol.minsym, - msymbol.objfile); + push_new (msymbol); else if (!have_full_symbols () && !have_partial_symbols ()) error (_("No symbol table is loaded. Use the \"file\" command.")); else @@ -305,7 +304,7 @@ parser_state::push_dollar (struct stoken str) msym = lookup_bound_minimal_symbol (copy.c_str ()); if (msym.minsym) { - push_new (msym.minsym, msym.objfile); + push_new (msym); return; } -- 2.26.2