From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SAKkB3I0YWfkLB4AWB0awg (envelope-from ) for ; Tue, 17 Dec 2024 03:21:06 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EYlzfUjK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 199B41E097; Tue, 17 Dec 2024 03:21:06 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 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 BB3031E05C for ; Tue, 17 Dec 2024 03:21:04 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 551C93858CDA for ; Tue, 17 Dec 2024 08:21:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 551C93858CDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EYlzfUjK Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by sourceware.org (Postfix) with ESMTPS id 3C7913858CD9 for ; Tue, 17 Dec 2024 08:18:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C7913858CD9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3C7913858CD9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734423539; cv=none; b=DE/NRQnYBxXDOytG6F5KGyCwyj+pCI9wC7sblUI1b8gkg+5Ve1oWbM5Bhj0sLBY+4p8pjjA+wC7362n/N6mUW1Dh4cYTtVQUKgNeN882XrVpY/jL4gNeoDpLYYnskVaTTf0svfz1V27qHqgUhpRxjzk8RHT6PITFOV0Gvzv1lWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734423539; c=relaxed/simple; bh=VwllcBce1lDWx1szhxwN+djI4LspNK+O6ZRo6nfB8uo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=D08cwITBczJPkFcnKodIQFpN5fiCKkIAAFNdQXUvSFFqCxNChCrRSzzX/+pwHiQLq4Pt8CbbWsjxwOmjWA3teTvnb4V9gMZTrsr5553Gu2PZsn9E/ei9RlRRBzOFPrKh3Hf0Kg08lo0wEEPBhd738r1giHu+CNVpHmXwvD61YfE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C7913858CD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734423540; x=1765959540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VwllcBce1lDWx1szhxwN+djI4LspNK+O6ZRo6nfB8uo=; b=EYlzfUjK3NQobRabC13zo4fMUy+ipWFUoKl1GHLi23Bi8l1SjgoGPzXs GVkkV4KOBzelTKBq0USwRDWytZ75BFkDkvEgHrgIbuozk8NBMzM6IpwZm Do77xslkx47LwCQtjzZzN4RRbY7PnNtMNh95qG87BRn5rOrV4wjkzrpu7 82fRUpvb4bQK7/5ykQrT5Ry3lEFJcR2H4pBDG1eigYPWRkwvCpyPyoMAW vLx9bIpngwakXo8crp9N2N0YzNT/KWGxysHQvNyT/WoeUjASHedDDSoMP viXxUUSMMz1FSP2OUHm4dUvIKy5gl592owbpN1xfg5LWXgTvwvd+xOCs9 A==; X-CSE-ConnectionGUID: KZyN2Yw6Rf21QFiGfzaH7A== X-CSE-MsgGUID: Ur+AuR+nQyOWZXU2Y5xLYg== X-IronPort-AV: E=McAfee;i="6700,10204,11288"; a="22427822" X-IronPort-AV: E=Sophos;i="6.12,241,1728975600"; d="scan'208";a="22427822" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2024 00:18:59 -0800 X-CSE-ConnectionGUID: de9D5tIUQDmutE9ccYwz6A== X-CSE-MsgGUID: zaOgn5k+RVm/B1QMO/J/iA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,241,1728975600"; d="scan'208";a="97346341" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2024 00:18:57 -0800 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Cc: simon.marchi@efficios.com Subject: [PUSHED 2/8] gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcache Date: Tue, 17 Dec 2024 09:18:24 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Boolify the 'fetch' parameter of the get_thread_regcache function. All of the current uses pass true for this parameter. Therefore, define its default value as true and remove the argument from the uses. We still keep the parameter, though, to give downstream targets the option to obtain a regcache without having to fetch the whole contents. Our (Intel) downstream target is an example. Approved-By: Simon Marchi --- gdbserver/linux-aarch32-low.cc | 2 +- gdbserver/linux-low.cc | 18 +++++++++--------- gdbserver/linux-ppc-low.cc | 2 +- gdbserver/linux-x86-low.cc | 2 +- gdbserver/mem-break.cc | 4 ++-- gdbserver/proc-service.cc | 2 +- gdbserver/regcache.cc | 4 ++-- gdbserver/regcache.h | 2 +- gdbserver/remote-utils.cc | 2 +- gdbserver/server.cc | 4 ++-- gdbserver/tracepoint.cc | 4 ++-- gdbserver/win32-low.cc | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc index ca66e7f8fbc..a70cc4ac403 100644 --- a/gdbserver/linux-aarch32-low.cc +++ b/gdbserver/linux-aarch32-low.cc @@ -170,7 +170,7 @@ struct regs_info regs_info_aarch32 = int arm_is_thumb_mode (void) { - struct regcache *regcache = get_thread_regcache (current_thread, 1); + regcache *regcache = get_thread_regcache (current_thread); unsigned long cpsr; collect_register_by_name (regcache, "cpsr", &cpsr); diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index dfe4c6a39a0..50ce2b44927 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -788,7 +788,7 @@ linux_process_target::get_pc (lwp_info *lwp) scoped_restore_current_thread restore_thread; switch_to_thread (lwp->thread); - struct regcache *regcache = get_thread_regcache (current_thread, 1); + regcache *regcache = get_thread_regcache (current_thread); CORE_ADDR pc = low_get_pc (regcache); threads_debug_printf ("pc is 0x%lx", (long) pc); @@ -804,7 +804,7 @@ linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno) scoped_restore_current_thread restore_thread; switch_to_thread (lwp->thread); - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); low_get_syscall_trapinfo (regcache, sysno); threads_debug_printf ("get_syscall_trapinfo sysno %d", *sysno); @@ -894,7 +894,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) if (pc != sw_breakpoint_pc) { struct regcache *regcache - = get_thread_regcache (current_thread, 1); + = get_thread_regcache (current_thread); low_set_pc (regcache, sw_breakpoint_pc); } @@ -2074,7 +2074,7 @@ linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat) (PTRACE_TYPE_ARG3) 0, &info); } - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); low_set_pc (regcache, status.tpoint_addr); lwp->stop_pc = status.tpoint_addr; @@ -3088,7 +3088,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, if (increment_pc != 0) { struct regcache *regcache - = get_thread_regcache (current_thread, 1); + = get_thread_regcache (current_thread); event_child->stop_pc += increment_pc; low_set_pc (regcache, event_child->stop_pc); @@ -3376,7 +3376,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, if (low_supports_breakpoints ()) { struct regcache *regcache - = get_thread_regcache (current_thread, 1); + = get_thread_regcache (current_thread); low_set_pc (regcache, event_child->stop_pc); } @@ -3611,7 +3611,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, if (decr_pc != 0) { struct regcache *regcache - = get_thread_regcache (current_thread, 1); + = get_thread_regcache (current_thread); low_set_pc (regcache, event_child->stop_pc + decr_pc); } } @@ -3957,7 +3957,7 @@ void linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp) { thread_info *thread = lwp->thread; - struct regcache *regcache = get_thread_regcache (thread, 1); + regcache *regcache = get_thread_regcache (thread); scoped_restore_current_thread restore_thread; @@ -4131,7 +4131,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, if (thread->process ()->tdesc != nullptr && low_supports_breakpoints ()) { - struct regcache *regcache = get_thread_regcache (current_thread, 1); + regcache *regcache = get_thread_regcache (current_thread); lwp->stop_pc = low_get_pc (regcache); diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index d3c86671148..3ce978f4c7c 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -1053,7 +1053,7 @@ ppc_target::low_get_thread_area (int lwpid, CORE_ADDR *addr) { struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid)); thread_info *thr = lwp->thread; - struct regcache *regcache = get_thread_regcache (thr, 1); + regcache *regcache = get_thread_regcache (thr); ULONGEST tp = 0; #ifdef __powerpc64__ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index ad7ed1ce0ad..6c2688d3678 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -361,7 +361,7 @@ x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr) { thread_info *thr = lwp->thread; - struct regcache *regcache = get_thread_regcache (thr, 1); + regcache *regcache = get_thread_regcache (thr); unsigned int desc[4]; ULONGEST gs = 0; const int reg_thread_area = 3; /* bits to scale down register value. */ diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc index 971734d3532..134e2431370 100644 --- a/gdbserver/mem-break.cc +++ b/gdbserver/mem-break.cc @@ -1238,7 +1238,7 @@ gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr) if (bp->cond_list == NULL) return 1; - ctx.regcache = get_thread_regcache (current_thread, 1); + ctx.regcache = get_thread_regcache (current_thread); ctx.tframe = NULL; ctx.tpoint = NULL; @@ -1360,7 +1360,7 @@ run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr) if (bp == NULL) return 1; - ctx.regcache = get_thread_regcache (current_thread, 1); + ctx.regcache = get_thread_regcache (current_thread); ctx.tframe = NULL; ctx.tpoint = NULL; diff --git a/gdbserver/proc-service.cc b/gdbserver/proc-service.cc index 9896f7168f0..198a6f24eab 100644 --- a/gdbserver/proc-service.cc +++ b/gdbserver/proc-service.cc @@ -112,7 +112,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) scoped_restore_current_thread restore_thread; switch_to_thread (lwp->thread); - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); gregset_info ()->fill_function (regcache, gregset); return PS_OK; diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index f1d63eac0ba..5ae922ec0be 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -25,7 +25,7 @@ #ifndef IN_PROCESS_AGENT struct regcache * -get_thread_regcache (thread_info *thread, int fetch) +get_thread_regcache (thread_info *thread, bool fetch) { regcache *regcache = thread->regcache (); @@ -66,7 +66,7 @@ get_thread_regcache (thread_info *thread, int fetch) reg_buffer_common * get_thread_regcache_for_ptid (ptid_t ptid) { - return get_thread_regcache (find_thread_ptid (ptid), 1); + return get_thread_regcache (find_thread_ptid (ptid)); } void diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 16ee4d0a2e7..068f9e8df3d 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -72,7 +72,7 @@ void regcache_cpy (struct regcache *dst, struct regcache *src); struct regcache *new_register_cache (const struct target_desc *tdesc); -struct regcache *get_thread_regcache (thread_info *thread, int fetch); +regcache *get_thread_regcache (thread_info *thread, bool fetch = true); /* Release all memory associated with the register cache for INFERIOR. */ diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index 42252bad78f..3584697b2ab 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -1175,7 +1175,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) switch_to_thread (the_target, ptid); - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); if (the_target->stopped_by_watchpoint ()) { diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 264fac44b74..e5bdb379234 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -4721,7 +4721,7 @@ process_serial_event (void) write_enn (cs.own_buf); else { - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); registers_to_string (regcache, cs.own_buf); } } @@ -4738,7 +4738,7 @@ process_serial_event (void) write_enn (cs.own_buf); else { - regcache = get_thread_regcache (current_thread, 1); + regcache = get_thread_regcache (current_thread); registers_from_string (regcache, &cs.own_buf[1]); write_ok (cs.own_buf); } diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index ab68984330a..6b5541b5fbf 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -4376,7 +4376,7 @@ tracepoint_finished_step (thread_info *tinfo, CORE_ADDR stop_pc) wstep->tp_number, paddress (wstep->tp_address)); ctx.base.type = trap_tracepoint; - ctx.regcache = get_thread_regcache (tinfo, 1); + ctx.regcache = get_thread_regcache (tinfo); while (wstep != NULL) { @@ -4537,7 +4537,7 @@ tracepoint_was_hit (thread_info *tinfo, CORE_ADDR stop_pc) return 0; ctx.base.type = trap_tracepoint; - ctx.regcache = get_thread_regcache (tinfo, 1); + ctx.regcache = get_thread_regcache (tinfo); for (tpoint = tracepoints; tpoint; tpoint = tpoint->next) { diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 49f0ed3b1f4..da858b65e6f 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -943,7 +943,7 @@ gdbserver_windows_process::handle_access_violation static void maybe_adjust_pc () { - struct regcache *regcache = get_thread_regcache (current_thread, 1); + regcache *regcache = get_thread_regcache (current_thread); child_fetch_inferior_registers (regcache, -1); windows_thread_info *th -- 2.34.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928