From patchwork Sat Nov 2 02:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 840271 Delivered-To: patch@linaro.org Received: by 2002:adf:a38c:0:b0:37d:45d0:187 with SMTP id l12csp1158102wrb; Fri, 1 Nov 2024 19:56:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBbJC/mfR6MebdfZf+9dlRYk4AHPAOu6cgrR5lafa6DMig502vd4i9LwiqPdGsAFXzlEfb4Q==@linaro.org X-Google-Smtp-Source: AGHT+IGanwyQxu7qGmV5zupO6EWNch7KCVy2kLQ1bIltQrzWlMF7L0smoUn2boDJYkmTgQQ7d3Cm X-Received: by 2002:a05:620a:4547:b0:7b1:4cd4:469c with SMTP id af79cd13be357-7b2fb9cc305mr633630785a.51.1730516205710; Fri, 01 Nov 2024 19:56:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730516205; cv=pass; d=google.com; s=arc-20240605; b=HuJgMxMcT+yAW111CNp+J20+2C9C0P6booopYRMZyu4J4tWacmSNTqBu2yLTI9GI2d +nCXGkU4y6Ds8CUUwoCK6EZSeG+1u9SEYH8dRic/Ic35HQUu61HYXVp21YZxc6ki8hIu qSd1c8drjO4Hl4NJZlO5n19Dfq3Ci6D/UmEzQIy6zI2floIYfBDH+6qyKshU9wYBYr91 xM4JKcXb4nO/nXjKgn3MtYPLwdSIAbfbsK/kUFekh8pEAwjmyWlQU7TY94O6Xuq2FU04 wpZ9R3A5Ce5fUtvuNtEz2fIeKtZ1dmWyVc9W865bcRLJ/818IXP6ZpupB+tnyn791/Uk p6cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=dXJBz8NYG+h4ReMI1aFOzCbLTHtQiA6H5m+Q6nRH7oU=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=bLcWosvPsEER47wtvCujcvTsl3H7I4H9FT5RzbidOauXMGJXbPc24Q2H7eelTQ/shT 12czfulYBNWLg5EvJMyAx0vbqILC8ZxIH4T19NI9ZPm9vffddvAnCS98MnQdSvrnrvxv ClA87QOnXD0NHPEOev55fcrCCJYUGFppaSq+AXt8rCJ3/CpToAEVmQ3A04JPtG66r3Jr UEYVHml0ayNaMpAXwVCod4Oud070EDWfEEiMU1YJejcMjFgD/VXFjcWIooS3tjhV0FNG qjJE7m9gV0CIAetJ/XFXcRevmmPo8zp16L96XDnOUphjax4dPfCJzNdJMDYdiZhsBUiu Io6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zXycDAIm; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id af79cd13be357-7b2f3ab4cefsi566680485a.605.2024.11.01.19.56.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 19:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zXycDAIm; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4EE853858290 for ; Sat, 2 Nov 2024 02:56:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 046CE3858D37 for ; Sat, 2 Nov 2024 02:56:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 046CE3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 046CE3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730516202; cv=none; b=DQOZbRTk7ztl3F4Vo80FkRaSHGVj0Ecig/4SDbRjbl/Ze4T5YejwMci7zz8djkFvm04fxNNcjaHBt+IHnAI7OUGyOo1G5OOrapGpzw9mGdK3mHr0HzohwMzt5W5mnAy2VjbqIqPzpdo5C9Cx+IhdGXtJQmrSf2xhdNaiCznZR1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730516202; c=relaxed/simple; bh=yv0IcWUL8BFfj7GBWkf7Kk0MTGYniuU/jvgdTcEo+/A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uY0XOQhgP2VmrzIV+aM+DJs84yyZT+f4q5Hsd3KuUDtmS3/LkViI6gme7DJtSLdNqgUVtZY5frXvX09vVGi9WFFaMJw4Hj0IzuTYONhlJe5K01RQG0hQ8i3vQAHCeBzZaZPVNDS4C/GRXxMNQZ3IE7fnSHlH9yI0EF/mmxeNc1k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-20c767a9c50so25800785ad.1 for ; Fri, 01 Nov 2024 19:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730516199; x=1731120999; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=dXJBz8NYG+h4ReMI1aFOzCbLTHtQiA6H5m+Q6nRH7oU=; b=zXycDAImLvhZ3Zr4RHX3tIDbsyLo5bNY970qGwV65Pz2K1zjKgmbD+lze7RqnL9wvN oCjhUwwXOCTwex88yD9BHVAewCt+y2f3fNVpNL1Pbit+ExN9RNqL/3Ai/jdYqkaxuuuJ lQpieO9ZiBqjlOV94l7F9EcDAUAg7xyz5mYy2roaleSVL6l3LJDTZqA/eNcH1hl+dg/G XbVSusUeUTnhDRJF+G4BTyvTFHRb6rGNhlo9yNam7XdnsmQrBgeo++X01DBQA0p0UitJ xB/wlFe1wk+q1kzOjk4K9IqpeqMSPwjKt1CFGr6Q6LfhxsZ8zYxGxvNh3I9yF/LZCUCU P+tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730516199; x=1731120999; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dXJBz8NYG+h4ReMI1aFOzCbLTHtQiA6H5m+Q6nRH7oU=; b=h92h1bBYmpDLakXqhZHhHoKD6NMRnZsF8D7JOcvJgww8TIJEdeHs76QQjLyI4lEnMx 86EIhGa89XUIaICxEDg6Ns/SpY7dox3CQP+jXpbhGeUfzyvV4eI23p5j1tP+VmhfVDsI CcceTzMg5saLh9qT6Yv23YmHcrXcFvSVR6AoCKyDNk7cqZzHJQ0oqs4skpUMHk71bz1o w5Ieaix1F6fFUMy1eIhTDsgwe4TzlKXfjF466QvcNOA3smxvUMBfdv2lAr6A61QOhtjr hqjYv6r1hilhQBmLs3HnmsM1aYvC/ZJKI+RA8bgNv9hKR3WviAhn3RtpTbxGV1XxTwOV j3Kw== X-Gm-Message-State: AOJu0YwbXTuRC+owpzzzCQz2PYnIpyE9Q0FyGhL9a5GXUeC92BCWFTBu OlZUScJ/2NK0OWzUlaBmygQgJzHEzj6Y6loIOfygK0tx3VnnDtrh3L8TuQ63b1PngH5qh6wphQJ S X-Received: by 2002:a17:903:32cc:b0:20c:b485:eda3 with SMTP id d9443c01a7336-2111af3d1demr81139205ad.20.1730516198589; Fri, 01 Nov 2024 19:56:38 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:f214:b4dc:314a:c1ee]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057a6815sm27847525ad.135.2024.11.01.19.56.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 19:56:38 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [RFC PATCH v4 00/15] gdbserver improvements for AArch64 SVE support Date: Fri, 1 Nov 2024 23:56:20 -0300 Message-ID: <20241102025635.586759-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 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~patch=linaro.org@sourceware.org Hello, This is the fourth try at implementing variable-length register support in gdbserver and the remote protocol. It corresponds to the talk I gave at GNU Tools Cauldron 2024: https://www.youtube.com/watch?v=sghWiqTKBN0&list=PL_GiHdX17Wtye5q4zPVnJc6ec7PdnUNil&index=7 The v3 submission is here: https://inbox.sourceware.org/gdb-patches/20230130044518.3322695-1-thiago.bauermann@linaro.org/ Thank you all for attending the talk and for the great discussion and suggestions that followed it. I really appreciate it. This code doesn't reflect that discussion nor the suggestions though, because I wanted to post a version of the patches that corresponded to what I presented. I will address the presentation comments in the next version. Namely: - Pedro's suggestion of changing the VG register (which gives the size of the vector registers) to appear before the variable-length vector registers in the internal GDB register numbering, without affecting the remote protocol register numbering. - Simon's suggestion of keeping the fixed-size registers and the variable-size registers in the same regcache buffer, making sure that the latter are always placed at the end. - Baris' suggestion of implementing an 'e' packet to request the expedited registers from the remote target. - Luis' suggestion of extending the 'p' packet to fetch a specific list or registers. There are some FIXMEs in this code, which is why one of the reasons this version is marked as RFC. The other reason is the lack of implementing the suggestions above. v4 is a different approach from the previous versions, because the main point of this series is to allow expressing a vector register's size using a math expression. Previous versions relied on a different target description for each register size. The first 5 patches are cleanups and can be pushed independently, if approved. Some of them are about using gdb::array_view in more functions related to unwinding and manipulating registers, so that GDB can make sure that the buffers being passed around have the correct size. This helped me gain confidence that variable-sized registers were being correctly read and stored, but I also think it's a useful cleanup in general. Thiago Jung Bauermann (15): GDB, gdbserver: Convert regcache_register_size function to method GDB: Use gdb::array_view for buffers used in register reading and unwinding GDB: remote: Print total bytes received in debug message GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg gdbserver: nat/aarch64: Only check Z registers for extra contents if they can have it gdbserver: Implement p and P packets GDB, gdbserver: Create concept of load-early registers GDB: Allow DWARF expression evaluation to use regcache GDB tdesc: Add vector type with number of elements given by math expression. GDB: Add concept of variable-size registers to the regcache gdbserver: Add concept of variable-size registers to the regcache GDB: aarch64-linux: Load and store VG separately from other SVE registers GDB, gdbserver: aarch64: Convert SVE feature to use variable-size registers GDB, gdbserver: aarch64: Use VG instead of VQ gdb/testsuite: Add test to exercise multi-threaded AArch64 SVE inferiors gdb/aarch64-linux-nat.c | 53 ++- gdb/aarch64-linux-tdep.c | 55 ++- gdb/aarch64-tdep.c | 124 +++--- gdb/aarch64-tdep.h | 21 +- gdb/arch/aarch64.c | 36 +- gdb/arch/aarch64.h | 25 +- gdb/dwarf2/expr.c | 63 ++- gdb/dwarf2/expr.h | 17 +- gdb/dwarf2/frame.c | 2 +- gdb/dwarf2/loc.c | 41 +- gdb/dwarf2/loc.h | 2 + gdb/eval.c | 13 +- gdb/features/Makefile | 1 + gdb/features/aarch64-sve.c | 199 +++++---- gdb/features/aarch64-sve.xml | 217 +++++++++ gdb/features/gdb-target.dtd | 17 +- gdb/findvar.c | 22 +- gdb/frame-unwind.c | 18 +- gdb/frame-unwind.h | 2 +- gdb/frame.c | 72 +-- gdb/frame.h | 8 +- gdb/gdbarch-gen.c | 32 ++ gdb/gdbarch-gen.h | 9 + gdb/gdbarch_components.py | 11 + gdb/gdbtypes.c | 138 ++++-- gdb/gdbtypes.h | 7 +- gdb/gnu-v3-abi.c | 2 +- gdb/i387-tdep.c | 4 +- gdb/jit.c | 2 +- gdb/mips-tdep.c | 19 +- gdb/nat/aarch64-hw-point.c | 2 +- gdb/nat/aarch64-scalable-linux-ptrace.c | 52 +-- gdb/nat/aarch64-scalable-linux-ptrace.h | 12 +- gdb/process-stratum-target.h | 3 + gdb/python/py-unwind.c | 7 +- gdb/record-full.c | 21 +- gdb/regcache-dump.c | 2 +- gdb/regcache.c | 376 +++++++++++++--- gdb/regcache.h | 61 ++- gdb/regformats/regdef.h | 35 +- gdb/remote.c | 163 +++++-- gdb/stack.c | 2 +- gdb/target-descriptions.c | 114 ++++- gdb/target-descriptions.h | 11 + gdb/testsuite/gdb.arch/aarch64-sve-threads.c | 125 ++++++ .../gdb.arch/aarch64-sve-threads.exp | 80 ++++ gdb/trad-frame.h | 10 +- gdb/value.c | 16 +- gdb/value.h | 3 + gdb/xml-tdesc.c | 416 +++++++++++++++++- gdbserver/Makefile.in | 2 + gdbserver/ax.cc | 2 +- gdbserver/config.in | 3 + gdbserver/configure | 6 + gdbserver/configure.ac | 5 + gdbserver/configure.srv | 1 + gdbserver/linux-aarch64-low.cc | 6 +- gdbserver/linux-aarch64-tdesc.cc | 17 +- gdbserver/locexpr.cc | 107 +++++ gdbserver/locexpr.h | 31 ++ gdbserver/regcache.cc | 217 +++++++-- gdbserver/regcache.h | 32 +- gdbserver/remote-utils.cc | 2 +- gdbserver/server.cc | 75 ++++ gdbserver/tdesc.cc | 110 ++++- gdbserver/tdesc.h | 4 +- gdbserver/tracepoint.cc | 4 +- gdbsupport/common-regcache.h | 19 +- gdbsupport/tdesc.cc | 143 +++++- gdbsupport/tdesc.h | 60 ++- 70 files changed, 3022 insertions(+), 567 deletions(-) create mode 100644 gdb/features/aarch64-sve.xml create mode 100644 gdb/testsuite/gdb.arch/aarch64-sve-threads.c create mode 100644 gdb/testsuite/gdb.arch/aarch64-sve-threads.exp create mode 100644 gdbserver/locexpr.cc create mode 100644 gdbserver/locexpr.h