Message ID | cover.1677582744.git.tankut.baris.aktemur@intel.com |
---|---|
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 EED1F3857C45 for <patchwork@sourceware.org>; Tue, 28 Feb 2023 11:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EED1F3857C45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583746; bh=KtZnyhSosg8Eln8dCR30G5b68iO5LChxZNMEe/OLiPI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J+ZR9iQocGm+OlSroqS7xTX8RMJct3kvYFLBTMLYyxC6rssexfd1jRsHjwYxH4sM8 bnGXyEDpR/24uuH18It/A82g/tjDbOzsFqsX5oloGchmExkbVk4QNXyqGZ4JmbOnNR XVXbd59VXH4opQ5bDxDeba4BkKACY/ylqb5zzC5E= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id A93843858D33 for <gdb-patches@sourceware.org>; Tue, 28 Feb 2023 11:28:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A93843858D33 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="335597971" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="335597971" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:28:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="706541625" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="706541625" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:28:36 -0800 To: gdb-patches@sourceware.org Subject: [PATCH 00/26] gdbserver: refactor regcache and allow gradually populating Date: Tue, 28 Feb 2023 12:27:58 +0100 Message-Id: <cover.1677582744.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=AC_FROM_MANY_DOTS, BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdbserver: refactor regcache and allow gradually populating
|
|
Message
Tankut Baris Aktemur
Feb. 28, 2023, 11:27 a.m. UTC
Hello, Gdbserver's regcache is defined and used in a way that it is either invalid or fetches all the registers from the target prior to being used. It also seems some regcache functions have two different contracts based on argument values (e.g. a buffer being nullptr). This is an attempt to refactor the regcache in gdbserver to - convert several free functions to methods. - use and update register statuses more consistently. - allow populating register values gradually, instead of having to fetch all register values from the target. The last item above is utilized in our (Intel) downstream debugger. No gdbserver low target is modified to utilize that feature in this series. Regression-tested on X86_64 Linux using the native-gdbserver and native-extended-gdbserver board files. Tankut Baris Aktemur (26): gdbserver: convert init_register_cache into regcache::initialize gdbserver: convert new_register_cache into a regcache constructor gdbserver: by-pass regcache to access tdesc only gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcache gdbserver: add a pointer to the owner thread in regcache gdbserver: turn part of get_thread_regcache into regcache::fetch gdbserver: convert regcache_cpy into regcache::copy_from gdbserver: convert free_register_cache into a destructor of regcache gdbserver: extract out regcache::invalidate and regcache::discard gdbserver: convert registers_to_string into regcache::registers_to_string gdbserver: convert registers_from_string into regcache::registers_from_string gdbserver: convert supply_regblock to regcache::supply_regblock gdbserver: convert register_data into regcache::register_data gdbserver: introduce and use regcache::set_register_status gdbserver: check for nullptr condition in regcache::get_register_status gdbserver: boolify regcache fields gdbserver: rename regcache's registers_valid to registers_fetched gdbsupport: fix a typo in a comment in common-regcache.h gdbserver: fix the declared type of register_status in regcache gdbserver: make some regcache fields private gdbserver: use REG_UNKNOWN for a regcache's register statuses gdbserver: zero-out register values in regcache-discard gdbserver: set register statuses in registers_from_string gdbserver: return tracked register status in regcache_raw_read_unsigned gdbserver: refuse null argument in regcache::supply_regblock gdbserver: allow gradually populating and selectively storing a regcache gdbserver/gdbthread.h | 2 +- gdbserver/linux-aarch32-low.cc | 2 +- gdbserver/linux-low.cc | 18 +- gdbserver/linux-ppc-low.cc | 12 +- gdbserver/linux-s390-low.cc | 14 +- gdbserver/linux-x86-low.cc | 9 +- gdbserver/mem-break.cc | 4 +- gdbserver/proc-service.cc | 2 +- gdbserver/regcache.cc | 305 ++++++++++++++++++++------------- gdbserver/regcache.h | 92 ++++++---- gdbserver/remote-utils.cc | 2 +- gdbserver/server.cc | 16 +- gdbserver/tracepoint.cc | 25 ++- gdbserver/win32-low.cc | 2 +- gdbsupport/common-regcache.h | 11 +- 15 files changed, 302 insertions(+), 214 deletions(-)
Comments
>>>>> Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes: > Gdbserver's regcache is defined and used in a way that it is either > invalid or fetches all the registers from the target prior to being > used. It also seems some regcache functions have two different contracts > based on argument values (e.g. a buffer being nullptr). > This is an attempt to refactor the regcache in gdbserver to > - convert several free functions to methods. > - use and update register statuses more consistently. > - allow populating register values gradually, instead of having to > fetch all register values from the target. I haven't read these patches, but I wanted to mention that, over time, we've been trying to bring gdb and gdbserver closer together where possible. And, I'm wondering how this series fits into this. At the end, are the two register caches more similar? More divergent? I'm not necessarily saying this is the most important thing, but for example what would be unfortunate is if the two ended up with similar functionality but very different expressions, which would make the sharing of other code even harder. Tom
On Tuesday, March 7, 2023 9:40 PM, Tom Tromey wrote: > >>>>> Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes: > > > Gdbserver's regcache is defined and used in a way that it is either > > invalid or fetches all the registers from the target prior to being > > used. It also seems some regcache functions have two different contracts > > based on argument values (e.g. a buffer being nullptr). > > > This is an attempt to refactor the regcache in gdbserver to > > > - convert several free functions to methods. > > - use and update register statuses more consistently. > > - allow populating register values gradually, instead of having to > > fetch all register values from the target. > > I haven't read these patches, but I wanted to mention that, over time, > we've been trying to bring gdb and gdbserver closer together where > possible. And, I'm wondering how this series fits into this. At the > end, are the two register caches more similar? More divergent? > > I'm not necessarily saying this is the most important thing, but for > example what would be unfortunate is if the two ended up with similar > functionality but very different expressions, which would make the > sharing of other code even harder. > > Tom Hello Tom, The regcache implementation in gdb is a lot more involved with its relation to gdbarch, pseudo registers, values, etc. that do not exist at the gdbserver side. As far as I can tell, gdbserver's regcache can/should be compared with gdb's reg_buffer. The series I posted does not strictly aim at sharing code. But from a general perspective, I think it would be fair to say that the refactorings I posted bring gdbserver's regcache's behavior closer to the definitions in gdb. E.g. the use of REG_VALID/UNKNOWN/UNAVAILABLE statuses and the moving of free functions to class methods. For true code sharing, however, there is much work to do, in my opinion. The series at the end introduces a REG_DIRTY status as a new state. This does not exist in the gdb side and could be considered a divergence. Regards -Baris Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928
Kindly pinging. Thanks, -Baris On Tuesday, February 28, 2023 12:28 PM, Aktemur, Tankut Baris wrote: > Hello, > > Gdbserver's regcache is defined and used in a way that it is either > invalid or fetches all the registers from the target prior to being > used. It also seems some regcache functions have two different contracts > based on argument values (e.g. a buffer being nullptr). > > This is an attempt to refactor the regcache in gdbserver to > > - convert several free functions to methods. > - use and update register statuses more consistently. > - allow populating register values gradually, instead of having to > fetch all register values from the target. > > The last item above is utilized in our (Intel) downstream debugger. > No gdbserver low target is modified to utilize that feature in this > series. > > Regression-tested on X86_64 Linux using the native-gdbserver and > native-extended-gdbserver board files. > > Tankut Baris Aktemur (26): > gdbserver: convert init_register_cache into regcache::initialize > gdbserver: convert new_register_cache into a regcache constructor > gdbserver: by-pass regcache to access tdesc only > gdbserver: boolify and defaultize the 'fetch' parameter of > get_thread_regcache > gdbserver: add a pointer to the owner thread in regcache > gdbserver: turn part of get_thread_regcache into regcache::fetch > gdbserver: convert regcache_cpy into regcache::copy_from > gdbserver: convert free_register_cache into a destructor of regcache > gdbserver: extract out regcache::invalidate and regcache::discard > gdbserver: convert registers_to_string into > regcache::registers_to_string > gdbserver: convert registers_from_string into > regcache::registers_from_string > gdbserver: convert supply_regblock to regcache::supply_regblock > gdbserver: convert register_data into regcache::register_data > gdbserver: introduce and use regcache::set_register_status > gdbserver: check for nullptr condition in > regcache::get_register_status > gdbserver: boolify regcache fields > gdbserver: rename regcache's registers_valid to registers_fetched > gdbsupport: fix a typo in a comment in common-regcache.h > gdbserver: fix the declared type of register_status in regcache > gdbserver: make some regcache fields private > gdbserver: use REG_UNKNOWN for a regcache's register statuses > gdbserver: zero-out register values in regcache-discard > gdbserver: set register statuses in registers_from_string > gdbserver: return tracked register status in > regcache_raw_read_unsigned > gdbserver: refuse null argument in regcache::supply_regblock > gdbserver: allow gradually populating and selectively storing a > regcache > > gdbserver/gdbthread.h | 2 +- > gdbserver/linux-aarch32-low.cc | 2 +- > gdbserver/linux-low.cc | 18 +- > gdbserver/linux-ppc-low.cc | 12 +- > gdbserver/linux-s390-low.cc | 14 +- > gdbserver/linux-x86-low.cc | 9 +- > gdbserver/mem-break.cc | 4 +- > gdbserver/proc-service.cc | 2 +- > gdbserver/regcache.cc | 305 ++++++++++++++++++++------------- > gdbserver/regcache.h | 92 ++++++---- > gdbserver/remote-utils.cc | 2 +- > gdbserver/server.cc | 16 +- > gdbserver/tracepoint.cc | 25 ++- > gdbserver/win32-low.cc | 2 +- > gdbsupport/common-regcache.h | 11 +- > 15 files changed, 302 insertions(+), 214 deletions(-) > > -- > 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928
Kindly pinging. Thanks, -Baris On Tuesday, February 28, 2023 12:28 PM, Aktemur, Tankut Baris wrote: > Hello, > > Gdbserver's regcache is defined and used in a way that it is either > invalid or fetches all the registers from the target prior to being > used. It also seems some regcache functions have two different contracts > based on argument values (e.g. a buffer being nullptr). > > This is an attempt to refactor the regcache in gdbserver to > > - convert several free functions to methods. > - use and update register statuses more consistently. > - allow populating register values gradually, instead of having to > fetch all register values from the target. > > The last item above is utilized in our (Intel) downstream debugger. > No gdbserver low target is modified to utilize that feature in this > series. > > Regression-tested on X86_64 Linux using the native-gdbserver and > native-extended-gdbserver board files. > > Tankut Baris Aktemur (26): > gdbserver: convert init_register_cache into regcache::initialize > gdbserver: convert new_register_cache into a regcache constructor > gdbserver: by-pass regcache to access tdesc only > gdbserver: boolify and defaultize the 'fetch' parameter of > get_thread_regcache > gdbserver: add a pointer to the owner thread in regcache > gdbserver: turn part of get_thread_regcache into regcache::fetch > gdbserver: convert regcache_cpy into regcache::copy_from > gdbserver: convert free_register_cache into a destructor of regcache > gdbserver: extract out regcache::invalidate and regcache::discard > gdbserver: convert registers_to_string into > regcache::registers_to_string > gdbserver: convert registers_from_string into > regcache::registers_from_string > gdbserver: convert supply_regblock to regcache::supply_regblock > gdbserver: convert register_data into regcache::register_data > gdbserver: introduce and use regcache::set_register_status > gdbserver: check for nullptr condition in > regcache::get_register_status > gdbserver: boolify regcache fields > gdbserver: rename regcache's registers_valid to registers_fetched > gdbsupport: fix a typo in a comment in common-regcache.h > gdbserver: fix the declared type of register_status in regcache > gdbserver: make some regcache fields private > gdbserver: use REG_UNKNOWN for a regcache's register statuses > gdbserver: zero-out register values in regcache-discard > gdbserver: set register statuses in registers_from_string > gdbserver: return tracked register status in > regcache_raw_read_unsigned > gdbserver: refuse null argument in regcache::supply_regblock > gdbserver: allow gradually populating and selectively storing a > regcache > > gdbserver/gdbthread.h | 2 +- > gdbserver/linux-aarch32-low.cc | 2 +- > gdbserver/linux-low.cc | 18 +- > gdbserver/linux-ppc-low.cc | 12 +- > gdbserver/linux-s390-low.cc | 14 +- > gdbserver/linux-x86-low.cc | 9 +- > gdbserver/mem-break.cc | 4 +- > gdbserver/proc-service.cc | 2 +- > gdbserver/regcache.cc | 305 ++++++++++++++++++++------------- > gdbserver/regcache.h | 92 ++++++---- > gdbserver/remote-utils.cc | 2 +- > gdbserver/server.cc | 16 +- > gdbserver/tracepoint.cc | 25 ++- > gdbserver/win32-low.cc | 2 +- > gdbsupport/common-regcache.h | 11 +- > 15 files changed, 302 insertions(+), 214 deletions(-) > > -- > 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928