From patchwork Fri Dec 1 16:27:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 81147 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 6DCD8386180D for ; Fri, 1 Dec 2023 16:31:54 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E4A27385C6DE for ; Fri, 1 Dec 2023 16:29:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4A27385C6DE Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4A27385C6DE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701448200; cv=none; b=nASmeXpPfvFm5A5GMGCgbjqVLGnW/uw3/zoNttnO5xnqpWaYTeRgm6OdBXk/Ti6wzzsYL7p6Km2nfw7n1PX+tGiczYQoJcYVpqshiAu//cFhuFOphOFH2eYUYM3x3B3kuxg2eBygTuGVhd1hYGIpzgGEX0FWwhZVmQfgGJz5ckQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701448200; c=relaxed/simple; bh=v3Hy35HSXC9RZUfatLFJmMpuvB8l7zneABMgAFOlGbI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Rj9c2167kAX8sBOVas9lYHJO6R915L6vKWXhtFUBKGSDH5ew3WiKm70s1ZbKBoKnMMbawYXSAMzgxKbdkqBy6/90lZFIUny7GWUgOw6X1QoLiFtjOMtgn/v2SCivIQ58ROI7Zmep7Fo7zlhXUV1EDC4n54yJdkOHroBy7d2BPoA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (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 ESMTPSA id 1EF681E11E; Fri, 1 Dec 2023 11:29:57 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Luis Machado , John Baldwin , "Aktemur, Tankut Baris" , Simon Marchi , John Baldwin Subject: [PATCH 12/24] gdb: make get_frame_register_bytes take the next frame Date: Fri, 1 Dec 2023 11:27:25 -0500 Message-ID: <20231201162751.741751-13-simon.marchi@efficios.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231201162751.741751-1-simon.marchi@efficios.com> References: <20231201162751.741751-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3496.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Similar to the previous patches, change get_frame_register_bytes to take the "next frame" instead of "this frame". Change-Id: Ie8f35042bfa6e93565fcefaee71b6b3903f0fe9f Reviewed-By: John Baldwin --- gdb/dwarf2/expr.c | 22 +++++++++++----------- gdb/frame.c | 16 ++++++---------- gdb/frame.h | 10 +++++----- gdb/i386-tdep.c | 8 ++++---- gdb/i387-tdep.c | 10 +++++----- gdb/ia64-tdep.c | 9 ++++----- gdb/m68k-tdep.c | 10 +++++----- gdb/mips-tdep.c | 7 ++++--- gdb/rs6000-tdep.c | 10 +++++----- gdb/valops.c | 3 +-- 10 files changed, 50 insertions(+), 55 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 7fc7b3abf5ca..c71bbb594131 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -204,8 +204,9 @@ rw_pieced_value (value *v, value *from, bool check_optimized) { case DWARF_VALUE_REGISTER: { - frame_info_ptr frame = frame_find_by_id (c->frame_id); - gdbarch *arch = get_frame_arch (frame); + frame_info_ptr next_frame + = get_next_frame_sentinel_okay (frame_find_by_id (c->frame_id)); + gdbarch *arch = frame_unwind_arch (next_frame); int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno); ULONGEST reg_bits = 8 * register_size (arch, gdb_regnum); int optim, unavail; @@ -225,9 +226,9 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (from == nullptr) { /* Read mode. */ - if (!get_frame_register_bytes (frame, gdb_regnum, - bits_to_skip / 8, - buffer, &optim, &unavail)) + if (!get_frame_register_bytes (next_frame, gdb_regnum, + bits_to_skip / 8, buffer, + &optim, &unavail)) { if (optim) { @@ -254,9 +255,9 @@ rw_pieced_value (value *v, value *from, bool check_optimized) { /* Data is copied non-byte-aligned into the register. Need some bits from original register value. */ - get_frame_register_bytes (frame, gdb_regnum, - bits_to_skip / 8, - buffer, &optim, &unavail); + get_frame_register_bytes (next_frame, gdb_regnum, + bits_to_skip / 8, buffer, &optim, + &unavail); if (optim) throw_error (OPTIMIZED_OUT_ERROR, _("Can't do read-modify-write to " @@ -272,9 +273,8 @@ rw_pieced_value (value *v, value *from, bool check_optimized) copy_bitwise (buffer.data (), bits_to_skip % 8, from_contents, offset, this_size_bits, bits_big_endian); - put_frame_register_bytes - (get_next_frame_sentinel_okay (frame), gdb_regnum, - bits_to_skip / 8, buffer); + put_frame_register_bytes (next_frame, gdb_regnum, + bits_to_skip / 8, buffer); } } break; diff --git a/gdb/frame.c b/gdb/frame.c index 982aaa6d6753..d260e8c28f3f 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1456,12 +1456,11 @@ deprecated_frame_register_read (frame_info_ptr frame, int regnum, } bool -get_frame_register_bytes (frame_info_ptr frame, int regnum, - CORE_ADDR offset, - gdb::array_view buffer, +get_frame_register_bytes (frame_info_ptr next_frame, int regnum, + CORE_ADDR offset, gdb::array_view buffer, int *optimizedp, int *unavailablep) { - struct gdbarch *gdbarch = get_frame_arch (frame); + gdbarch *gdbarch = frame_unwind_arch (next_frame); /* Skip registers wholly inside of OFFSET. */ while (offset >= register_size (gdbarch, regnum)) @@ -1499,17 +1498,14 @@ get_frame_register_bytes (frame_info_ptr frame, int regnum, CORE_ADDR addr; int realnum; - frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum, - optimizedp, unavailablep, &lval, &addr, - &realnum, buffer.data ()); + frame_register_unwind (next_frame, regnum, optimizedp, unavailablep, + &lval, &addr, &realnum, buffer.data ()); if (*optimizedp || *unavailablep) return false; } else { - struct value *value - = frame_unwind_register_value (frame_info_ptr (frame->next), - regnum); + value *value = frame_unwind_register_value (next_frame, regnum); gdb_assert (value != NULL); *optimizedp = value->optimized_out (); *unavailablep = !value->entirely_available (); diff --git a/gdb/frame.h b/gdb/frame.h index 5ce3a1b285aa..62f53ece9eaa 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -733,11 +733,11 @@ extern bool read_frame_register_unsigned (frame_info_ptr frame, extern void put_frame_register (frame_info_ptr next_frame, int regnum, gdb::array_view buf); -/* Read LEN bytes from one or multiple registers starting with REGNUM - in frame FRAME, starting at OFFSET, into BUF. If the register - contents are optimized out or unavailable, set *OPTIMIZEDP, - *UNAVAILABLEP accordingly. */ -extern bool get_frame_register_bytes (frame_info_ptr frame, int regnum, +/* Read LEN bytes from one or multiple registers starting with REGNUM in + NEXT_FRAME's previous frame, starting at OFFSET, into BUF. If the register + contents are optimized out or unavailable, set *OPTIMIZEDP, *UNAVAILABLEP + accordingly. */ +extern bool get_frame_register_bytes (frame_info_ptr next_frame, int regnum, CORE_ADDR offset, gdb::array_view buffer, int *optimizedp, int *unavailablep); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f188f83de6f3..59d77d1d574d 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3877,10 +3877,10 @@ i386_register_to_value (frame_info_ptr frame, int regnum, gdb_assert (regnum != -1); gdb_assert (register_size (gdbarch, regnum) == 4); - if (!get_frame_register_bytes (frame, regnum, 0, - gdb::make_array_view (to, - register_size (gdbarch, - regnum)), + auto to_view + = gdb::make_array_view (to, register_size (gdbarch, regnum)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); + if (!get_frame_register_bytes (next_frame, regnum, 0, to_view, optimizedp, unavailablep)) return 0; diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 77dc5a008d5f..ffd8303746e5 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -364,11 +364,11 @@ i387_register_to_value (frame_info_ptr frame, int regnum, } /* Convert to TYPE. */ - if (!get_frame_register_bytes (frame, regnum, 0, - gdb::make_array_view (from, - register_size (gdbarch, - regnum)), - optimizedp, unavailablep)) + auto from_view + = gdb::make_array_view (from, register_size (gdbarch, regnum)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); + if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp, + unavailablep)) return 0; target_float_convert (from, i387_ext_type (gdbarch), to, type); diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 3bede2644c03..b009b46ef6df 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -1227,11 +1227,10 @@ ia64_register_to_value (frame_info_ptr frame, int regnum, gdb_byte in[IA64_FP_REGISTER_SIZE]; /* Convert to TYPE. */ - if (!get_frame_register_bytes (frame, regnum, 0, - gdb::make_array_view (in, - register_size (gdbarch, - regnum)), - optimizedp, unavailablep)) + auto in_view = gdb::make_array_view (in, register_size (gdbarch, regnum)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); + if (!get_frame_register_bytes (next_frame, regnum, 0, in_view, optimizedp, + unavailablep)) return 0; target_float_convert (in, ia64_ext_type (gdbarch), out, valtype); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 8bbfa4bd0b10..f9c734cf3808 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -216,11 +216,11 @@ m68k_register_to_value (frame_info_ptr frame, int regnum, gdb_assert (type->code () == TYPE_CODE_FLT); /* Convert to TYPE. */ - if (!get_frame_register_bytes (frame, regnum, 0, - gdb::make_array_view (from, - register_size (gdbarch, - regnum)), - optimizedp, unavailablep)) + auto from_view + = gdb::make_array_view (from, register_size (gdbarch, regnum)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); + if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp, + unavailablep)) return 0; target_float_convert (from, fpreg_type, to, type); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 9c0cfede492a..fc3193ea27a5 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -947,17 +947,18 @@ mips_register_to_value (frame_info_ptr frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); if (mips_convert_register_float_case_p (gdbarch, regnum, type)) { get_frame_register (frame, regnum + 0, to + 4); get_frame_register (frame, regnum + 1, to + 0); - if (!get_frame_register_bytes (frame, regnum + 0, 0, {to + 4, 4}, + if (!get_frame_register_bytes (next_frame, regnum + 0, 0, { to + 4, 4 }, optimizedp, unavailablep)) return 0; - if (!get_frame_register_bytes (frame, regnum + 1, 0, {to + 0, 4}, + if (!get_frame_register_bytes (next_frame, regnum + 1, 0, { to + 0, 4 }, optimizedp, unavailablep)) return 0; *optimizedp = *unavailablep = 0; @@ -969,7 +970,7 @@ mips_register_to_value (frame_info_ptr frame, int regnum, CORE_ADDR offset; offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 - len : 0; - if (!get_frame_register_bytes (frame, regnum, offset, {to, len}, + if (!get_frame_register_bytes (next_frame, regnum, offset, { to, len }, optimizedp, unavailablep)) return 0; diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index c43039302bc3..643997e5bd7d 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2713,11 +2713,11 @@ rs6000_register_to_value (frame_info_ptr frame, fpr to vsr. */ regnum = ieee_128_float_regnum_adjust (gdbarch, type, regnum); - if (!get_frame_register_bytes (frame, regnum, 0, - gdb::make_array_view (from, - register_size (gdbarch, - regnum)), - optimizedp, unavailablep)) + auto from_view + = gdb::make_array_view (from, register_size (gdbarch, regnum)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame); + if (!get_frame_register_bytes (frame, regnum, 0, from_view, optimizedp, + unavailablep)) return 0; target_float_convert (from, builtin_type (gdbarch)->builtin_double, diff --git a/gdb/valops.c b/gdb/valops.c index 8e1849837cf1..dbf7a7552b10 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1225,8 +1225,7 @@ value_assign (struct value *toval, struct value *fromval) "don't fit in a %d bit word."), (int) sizeof (LONGEST) * HOST_CHAR_BIT); - if (!get_frame_register_bytes (get_prev_frame_always (next_frame), - value_reg, offset, + if (!get_frame_register_bytes (next_frame, value_reg, offset, { buffer, changed_len }, &optim, &unavail)) {