From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 171793860C37 for ; Wed, 14 Jul 2021 14:07:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 171793860C37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from gimli.baldwin.cx (d-24-233-223-154.va.cpe.atlanticbb.net [24.233.223.154]) by mail.baldwin.cx (Postfix) with ESMTPSA id E29771A84BA9 for ; Wed, 14 Jul 2021 10:07:45 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 0/8] Switch FreeBSD x86 to using register maps for GP registers Date: Wed, 14 Jul 2021 07:07:33 -0700 Message-Id: <20210714140741.6460-1-jhb@FreeBSD.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Wed, 14 Jul 2021 10:07:46 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Wed, 14 Jul 2021 14:07:49 -0000 The x86 architectures in GDB provide existing helpers for parsing general-purpose register sets. However, these helpers have some limitations, such as assuming that registers are always full size. On FreeBSD/amd64 in particular, segment registers are stored as 16-bit quantities that in some cases are packed together. GDB for historical reasons treats these 16-bit registers as 32 bits in size. Using the more generic regcache_map_entry to describe the GP register sets permits supporting these registers as 16-bit values. In addition, the FreeBSD x86 signal frames have included the base address of the FS and GS segments (equivalent to the fs_base and gs_base registers), but the existing signal context helpers were written before those registers were added to GDB. Longer term my goal is to use regcache_map_entry-based register sets in FreeBSD gdbserver support to simplify the implementation. Note that patch 4 fixes an issue in regcache_collect_regset where it didn't quite do what I thought it did. I believe the change is ok, but it definitely warrants review. I have tested this on both FreeBSD/amd64 (32-bit and 64-bit processes) and FreeBSD/i386. John Baldwin (8): Remove vestigal FreeBSD/i386 3.x support. Remove support for pre-5.0 FreeBSD/i386 signal trampolines. FreeBSD x86: Remove fallback for detecting signal trampolines by address. regcache: Zero-extend small registers described by a register map. Use register maps for gp regsets on FreeBSD/x86 core dumps. FreeBSD x86: Use tramp-frame for signal frames. fbsd-nat: Return a bool from fetch_register_set and store_register_set. FreeBSD x86 nat: Use register maps for GP register sets. gdb/amd64-bsd-nat.c | 96 --------- gdb/amd64-fbsd-nat.c | 346 ++++++++++++++++++------------- gdb/amd64-fbsd-tdep.c | 279 ++++++++++++++----------- gdb/amd64-fbsd-tdep.h | 27 +++ gdb/amd64-tdep.h | 5 - gdb/configure.nat | 4 +- gdb/fbsd-nat.c | 8 +- gdb/fbsd-nat.h | 21 +- gdb/i386-bsd-nat.c | 98 +-------- gdb/i386-fbsd-nat.c | 255 +++++++++++++++++++---- gdb/i386-fbsd-tdep.c | 461 ++++++++++++++++++------------------------ gdb/i386-fbsd-tdep.h | 4 + gdb/i386-tdep.h | 4 - gdb/regcache.c | 7 +- gdb/x86-bsd-nat.c | 4 - gdb/x86-bsd-nat.h | 3 - 16 files changed, 844 insertions(+), 778 deletions(-) create mode 100644 gdb/amd64-fbsd-tdep.h -- 2.31.1