From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wWOlDvV7GmkBuQoAWB0awg (envelope-from ) for ; Sun, 16 Nov 2025 20:35:49 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=LvM/u9qS; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 375A31E0AB; Sun, 16 Nov 2025 20:35:49 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 61EA61E08D for ; Sun, 16 Nov 2025 20:35:48 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB7243858C54 for ; Mon, 17 Nov 2025 01:35:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB7243858C54 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=LvM/u9qS Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 858A93858D26 for ; Mon, 17 Nov 2025 01:28:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 858A93858D26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 858A93858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763342912; cv=none; b=ss6n1CHzCaXKvdLdOA1GG04nODUmDLUJvHnxetBX0WzONittvEyXHwPIOEXfKyIDUY8lXBWgIF5hT3Gpx2/RPbCeUfXOwMi2QIlh2X7TUs0p8lWsBDb62LtUOiyqK/XTQm/CH24gONVyH1aL9Punebd2zftRHXHFURlVnX+4kyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763342912; c=relaxed/simple; bh=AHIgRao3+WfYOKTUaw6nXbgCVuQ6WDZCrJ5LIPqBnnc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TnG17WFj3DcS0t5mRTbDYtNXLQeFtR+EnW/jFBTuXMFIqIlMtL0+xYCGqW1U7CSC2AZBtNcOIOpHghDDWSYPdNacjLHbbUrBueOpRhrmah/csvUe1EkwQP772B5R1ae6OsLemM/FbQOQEHO8RAI3rZujVbcKpZPX9lbwN/csmi0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 858A93858D26 Received: from eig-obgw-5004b.ext.cloudfilter.net ([10.0.29.208]) by cmsmtp with ESMTPS id KllLvhPuvVCBNKo2ivwTjj; Mon, 17 Nov 2025 01:28:32 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Ko2hv54vqoYytKo2hvTMK6; Mon, 17 Nov 2025 01:28:32 +0000 X-Authority-Analysis: v=2.4 cv=Xqn6OUF9 c=1 sm=1 tr=0 ts=691a7a40 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=6UeiqGixMTsA:10 a=ItBw4LHWJt0A:10 a=xQIqzTmkJmjjbQqpmTkA:9 a=VS4QxaUSPT0UtbFnIvSC:22 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:Cc:To:From:Sender:Reply-To: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=Lj94k0SsBxbFipoTxVi1l1MNe0INix2sbFUwLixxp7M=; b=LvM/u9qSNp2CQbsCFOFmz9a3Up lgvAPdP0soE6Hp3IHW9I0sZ9cru/Wai2cReQyYiBYzwuylBtC02ICOw27KRgvjfK9DRKTevzErMvo kKW8tdwwsoEpBpmEj2Lw/3cDf; Received: from 97-122-120-205.hlrn.qwest.net ([97.122.120.205]:41170 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vKo2d-00000000Q3v-2OAi; Sun, 16 Nov 2025 18:28:27 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/7] Remove a couple Objective-C expression helpers Date: Sun, 16 Nov 2025 18:27:04 -0700 Message-ID: <20251117012752.2657208-6-tom@tromey.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251117012752.2657208-1-tom@tromey.com> References: <20251117012752.2657208-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.120.205 X-Source-L: No X-Exim-ID: 1vKo2d-00000000Q3v-2OAi X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-120-205.hlrn.qwest.net (localhost.localdomain) [97.122.120.205]:41170 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfMQPD0JEAeALvWqS0HvPRt1BP50q5ucOzjx9VMG+NwHblnAnp6S04jYqBiCcTs4MNT5f+ESYaJtWGewogCqPmXJ/4bECsyk2h6j3e7CB7Eourhd+B6ER /lEx742X5W4eAk6928jq9ZMgYy4zasEHCaCOyROgjHU6tp42J3/wbbk8P49yvKr0nZZcsX6XFUCiPKMGancsYSaqxTosdUFScZo= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The Objective-C expression code has a couple of helper functions with just a single caller. This patch unifies them with the appropriate evaluate method. --- gdb/c-exp.h | 16 ++-------------- gdb/eval.c | 13 ++++++------- gdb/objc-lang.c | 16 +++++++++++++--- gdb/objc-lang.h | 3 --- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/gdb/c-exp.h b/gdb/c-exp.h index f15185f4da0..8dbbce0f406 100644 --- a/gdb/c-exp.h +++ b/gdb/c-exp.h @@ -23,10 +23,6 @@ #include "expop.h" #include "objc-lang.h" -extern struct value *eval_op_objc_selector (struct type *expect_type, - struct expression *exp, - enum noside noside, - const char *sel); extern struct value *opencl_value_cast (struct type *type, struct value *arg); extern struct value *eval_opencl_assign (struct type *expect_type, struct expression *exp, @@ -72,11 +68,7 @@ class objc_nsstring_operation value *evaluate (struct type *expect_type, struct expression *exp, - enum noside noside) override - { - const std::string &str = std::get<0> (m_storage); - return value_nsstring (exp->gdbarch, str.c_str (), str.size () + 1); - } + enum noside noside) override; enum exp_opcode opcode () const override { return OP_OBJC_NSSTRING; } @@ -91,11 +83,7 @@ class objc_selector_operation value *evaluate (struct type *expect_type, struct expression *exp, - enum noside noside) override - { - return eval_op_objc_selector (expect_type, exp, noside, - std::get<0> (m_storage).c_str ()); - } + enum noside noside) override; enum exp_opcode opcode () const override { return OP_OBJC_SELECTOR; } diff --git a/gdb/eval.c b/gdb/eval.c index 9aa9665e959..530d5871a9c 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1185,20 +1185,19 @@ ternop_slice_operation::evaluate (struct type *expect_type, return value_slice (array, lowbound, upperbound - lowbound + 1); } -} /* namespace expr */ - -/* Helper function that implements the body of OP_OBJC_SELECTOR. */ - struct value * -eval_op_objc_selector (struct type *expect_type, struct expression *exp, - enum noside noside, - const char *sel) +objc_selector_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) { + const char *sel = std::get<0> (m_storage).c_str (); struct type *selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr; return value_from_longest (selector_type, lookup_child_selector (exp->gdbarch, sel)); } +} /* namespace expr */ + /* A helper function for STRUCTOP_STRUCT. */ struct value * diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index b307a0022b5..a6abcd60089 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -151,9 +151,17 @@ lookup_child_selector (struct gdbarch *gdbarch, const char *selname) return value_as_long (call_function_by_hand (function, NULL, selstring)); } +namespace expr +{ + struct value * -value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len) +objc_nsstring_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) { + const std::string &str = std::get<0> (m_storage); + struct gdbarch *gdbarch = exp->gdbarch; + struct type *char_type = builtin_type (gdbarch)->builtin_char; struct value *stringValue[3]; struct value *function, *nsstringValue; @@ -163,8 +171,8 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len) if (!target_has_execution ()) return 0; /* Can't call into inferior to create NSString. */ - stringValue[2] = value_string(ptr, len, char_type); - stringValue[2] = value_coerce_array(stringValue[2]); + stringValue[2] = value_string (str.c_str (), str.size () + 1, char_type); + stringValue[2] = value_coerce_array (stringValue[2]); /* _NSNewStringFromCString replaces "istr" after Lantern2A. */ if (lookup_minimal_symbol (current_program_space, "_NSNewStringFromCString").minsym != nullptr) @@ -207,6 +215,8 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len) return nsstringValue; } +} /* namespace expr */ + /* Class representing the Objective-C language. */ class objc_language : public language_defn diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h index d6a7509f21a..a472556d019 100644 --- a/gdb/objc-lang.h +++ b/gdb/objc-lang.h @@ -36,9 +36,6 @@ extern int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc); extern const char *find_imps (const char *method, std::vector *symbol_names); -extern struct value *value_nsstring (struct gdbarch *gdbarch, - const char *ptr, int len); - /* for parsing Objective C */ extern void start_msglist (void); extern void add_msglist (struct stoken *str, int addcolon); -- 2.49.0