From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by sourceware.org (Postfix) with ESMTPS id 61A60385840B for ; Thu, 8 Sep 2022 06:42:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61A60385840B Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-127d10b4f19so16160082fac.9 for ; Wed, 07 Sep 2022 23:42:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=d8Eg336cCEDswfLbmgnkiRCiqEvvHDodUMTYSjSBCH0=; b=TUZvZ5FqO9rxHvskfc5qcOBCykqfIp3ZORDW7ywaa+cMah3kxpDcN6mgiAgVvxQh9k 4vOuFhO2+xSO65a2fihdEKBpV2L9kbun1d3vMDfPBsMFyW+zhouecKq16VFpGWqfACg+ OdyhLcLe60I2RrFJwn55RG4xvRHMPtl5n8u2aiksk3q/fCOTCR9f0Hc+G4OUYA2sI5iz JQgT6TlZ2QJrMI3ua3soZp9jqSXPFnYXYM1bXvE2r1Q5+Q51NAjKgziGHPVSXn1Egf6A 7OrEIIvoo8mgzPccIBloa1dPFmp2seQEnj1NHr/Ri5O/CYFHllz5zQVWKFvJoJ38+mao cT9A== X-Gm-Message-State: ACgBeo366k+kImBIpGrdUO+/FYFpIT9I0W8wSbAT6NDd/C/krqIPHrQS P7/VljPx639rCOu0JZDDkfloq0TcJyrzzQ== X-Google-Smtp-Source: AA6agR54eNgQiBSZ4Grr7Oczzn2vQzOiplPVHbkJE/06kogcSa+D+VguNWZ8/4HLWvq3dQHuwJ5CbQ== X-Received: by 2002:a05:6870:b40d:b0:116:861f:15b6 with SMTP id x13-20020a056870b40d00b00116861f15b6mr1126348oap.180.1662619364483; Wed, 07 Sep 2022 23:42:44 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:8eab:4efc:ca3b:b046]) by smtp.gmail.com with ESMTPSA id eq15-20020a056870a90f00b001278611f0f6sm4758790oab.32.2022.09.07.23.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 23:42:43 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann Subject: [PATCH 0/8] gdbserver improvements for AArch64 SVE support Date: Thu, 8 Sep 2022 06:41:43 +0000 Message-Id: <20220908064151.3959930-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Sep 2022 06:42:48 -0000 Hello, The aarch64 architecture supports the Scalable Vector Extension, which provides vector registers and operations that can be used by software in a way that is agnostic to the size of the vector length actually provided by the hardware. It also allows programs to change the vector length at runtime. Also, it's worth noting that each thread in the program can have a different vector length. GDB supports debugging programs using SVE, and also supports debugging programs which change their vector length at runtime. gdbserver, on the other hand, supports the former but not the latter. This patch series adds support to gdbserver to allow debugging programs that change their vector length at runtime. This series makes the test gdb.arch/aarch64-sve.exp pass on the native-gdbserver and native-extended-gdbserver boards. GDB supports different vector lengths by using one target description for each vector length, and switches target descriptions when it notices that the vector length of the inferior thread changed. This is done by aarch64_linux_nat_target::thread_architecture, which returns a gdbarch reflecting the current vector length. This patch series' idea is to provide a remote_target::thread_architecture method so that the same mechanism can be used in the case of remote debugging. It returns a gdbarch based on the expedited registers seen in the most recent stop reply. To arrive at that solution some preparation is necessary. Most patches are small cleanups or code reorganisation to make review easier. The biggest change is arguably in patch 5, which changes gdbserver to use per-thread target descriptions rather than per-process. In practice only the aarch64-linux target will actually have different per-thread tdescs. All other targets use the same tdesc in all threads so little is changed. Since patch 5 touches so many targets, I'm trying to test this series on some different systems but the only real or virtualized machines I can test on are {aarch64,x86_64}-{linux,freebsd,netbsd}. I'll also try it out on QEMU-emulated machines on some other architectures, assuming that's helpful. I'm still going through testing (and struggling a bit to get the testsuite running properly on the BSDs) but these are my results so far: These targets were regression tested and no regressions were found: - aarch64-linux on the native-extended-gdbserver board - x86_64-linux on unix¹ and native-extended-gdbserver boards These targets build but were not regression tested: - aarch64-freebsd13.1 - aarch64-netbsd9.3 - arm-linux-gnueabihf - powerpc-linux - powerpc64le-linux - riscv64-linux The targets corresponding to these files were edited with no testing so far. I'll test some under QEMU emulation but most will be left untested: - linux-arc-low.cc - linux-ia64-low.cc - linux-loongarch-low.cc - linux-m68k-low.cc - linux-mips-low.cc - linux-nios2-low.cc - linux-or1k-low.cc - linux-s390-low.cc - linux-sh-low.cc - linux-sparc-low.cc - linux-tic6x-low.cc - linux-xtensa-low.cc - netbsd-amd64-low.cc - netbsd-i386-low.cc ¹ There's one additional unexpected core file reported on x86_linux native, even though the test results are unchanged. I'm looking into it and will report back. Thiago Jung Bauermann (8): gdbserver: Add asserts in register_size and register_data functions gdbserver: Add thread parameter to linux_get_auxv and linux_get_hwcap gdb,gdbserver/aarch64-linux: Allow aarch64_sve_get_vq to return error gdbserver/linux-aarch64: Factor out function to get aarch64_features gdbserver: Move target description from being per-process to being per-thread gdbserver/linux-aarch64: When inferior stops, update its target description gdb/aarch64: Factor out most of the thread_architecture method gdb/aarch64: When remote debugging detect changes in the target description gdb/aarch64-linux-nat.c | 37 ++++------ gdb/aarch64-tdep.c | 60 ++++++++++++++++ gdb/aarch64-tdep.h | 2 + gdb/arch-utils.c | 9 +++ gdb/arch-utils.h | 5 ++ gdb/gdbarch-components.py | 16 +++++ gdb/gdbarch-gen.h | 11 +++ gdb/gdbarch.c | 23 ++++++ gdb/nat/aarch64-sve-linux-ptrace.c | 18 +++-- gdb/nat/aarch64-sve-linux-ptrace.h | 2 +- gdb/remote.c | 42 +++++++++++ gdbserver/gdbthread.h | 2 + gdbserver/inferiors.h | 2 - gdbserver/linux-aarch64-low.cc | 110 +++++++++++++++++++++++++---- gdbserver/linux-arc-low.cc | 6 +- gdbserver/linux-arm-low.cc | 6 +- gdbserver/linux-ia64-low.cc | 2 +- gdbserver/linux-loongarch-low.cc | 2 +- gdbserver/linux-low.cc | 62 +++++++++++----- gdbserver/linux-low.h | 15 ++-- gdbserver/linux-m68k-low.cc | 2 +- gdbserver/linux-mips-low.cc | 8 +-- gdbserver/linux-nios2-low.cc | 2 +- gdbserver/linux-or1k-low.cc | 2 +- gdbserver/linux-ppc-low.cc | 16 ++--- gdbserver/linux-riscv-low.cc | 2 +- gdbserver/linux-s390-low.cc | 6 +- gdbserver/linux-sh-low.cc | 2 +- gdbserver/linux-sparc-low.cc | 2 +- gdbserver/linux-tic6x-low.cc | 2 +- gdbserver/linux-x86-low.cc | 2 +- gdbserver/linux-xtensa-low.cc | 2 +- gdbserver/netbsd-aarch64-low.cc | 2 +- gdbserver/netbsd-amd64-low.cc | 2 +- gdbserver/netbsd-i386-low.cc | 2 +- gdbserver/netbsd-low.cc | 4 +- gdbserver/netbsd-low.h | 4 +- gdbserver/regcache.cc | 10 +-- gdbserver/server.cc | 2 +- gdbserver/target.cc | 4 +- gdbserver/target.h | 4 +- gdbserver/tdesc.cc | 2 +- 42 files changed, 395 insertions(+), 121 deletions(-) base-commit: 5edf42b635a375f7bf79e2079529eeb869129cbe