From patchwork Tue Mar 17 17:50:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184640 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4433070ile; Tue, 17 Mar 2020 10:53:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvr9Rueu3Jr4Qgau6N8FkfAuSet/iI4S0dy1HhHJc73FLxJdxrEdlZYlLRGLuEDr0eLsinf X-Received: by 2002:ac8:7257:: with SMTP id l23mr309074qtp.197.1584467596616; Tue, 17 Mar 2020 10:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467596; cv=none; d=google.com; s=arc-20160816; b=0jOPgj2OcvndApzHmlGNbh/DipUw0zRbrVShRaAW9mXltk5ox170V85n0YQaXsdSo9 oBgKzrVv7ekNseF4oiXz5fxwePsvZS4MXNtn6bokG/6O2ZimwkU4yMNRH23n2tIoETfz UWUGG8h7POW21p8qJ044yoyaaU9z1z4yFJI3oG0CMv6ELyS7O5N5fzZmZQa1jClFsKMV ZhD83nQhLCgEWD12F3wZsSpz40lUoWl7buvvQ6KQ9kUMqWT2xnXdDo747bjy80tCUNum fW9tdWpZidALUlClzBma7FWitRJYWsSbXLER6astI1LRbseAyPhK4nUkPt8RAnv7bL4v ZuSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Wo5mRBpfwNfsZY5/P5VVd4CS2W0ErWEgaoPNHTJ7c5w=; b=T1M211w7QwAMFLvqmhHd351aMd7Ce2lirvBOzHhA0Feo+lFXDNjvcDpxiqZUrS//Fo dEiBVw5ct5yygptWPOgaFiautr22fAimxCMx7wPswfKJU0QUpHim7r3VbyyHSz4n9vWT Pcs8iINMtMy6Qu3gtI1mGjAky67OCBdVFKfXLqjlxwTZf1IRECLnksNg6RBXck1Gb3F/ TiqTe5vBuOmHB2B60Jf4W4Nm1MwrC0vaOVSDmZ9WCmJ4HxPTOS8Tl7I66nQpIp9Ss+W1 Kn8Keds3C7tzYVTtvp3erosw/qcwisfXhvoLqozciQSf1zoVxLsWz6hXLFmaI8L1ounr /gdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xYM9l+MO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si2231179qvp.1.2020.03.17.10.53.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xYM9l+MO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGOy-00044K-39 for patch@linaro.org; Tue, 17 Mar 2020 13:53:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56916) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMs-0000In-1i for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMm-0001us-5s for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:04 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:44334) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMl-0001iS-UW for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:00 -0400 Received: by mail-wr1-x436.google.com with SMTP id y2so11392748wrn.11 for ; Tue, 17 Mar 2020 10:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wo5mRBpfwNfsZY5/P5VVd4CS2W0ErWEgaoPNHTJ7c5w=; b=xYM9l+MOVgtLwt7nitW5+c1idOSWGV6iidJuwcT2936jTC20FAuhDYgSameg6EtcIl 0RF6K+cbCnwhE30ck+tTTYqxD0JP9+Fddlfb/z68LrWvbRVRHXlxKXdYZAGjITJDUVqa btIB3srCipRDN4AhXtrvlbzhCRByISI1nf6xLe6FaEAvq3cxOP/WYslooPxT75qjyiV/ ypGNu1b2O2bulzi/uAFPdLaJj54LwZz36ZokHJwTw2hMMEok3JPNc83I/kWW+9gl+EDo G3b61tlGzY9CS3EldCsL/d64UyfpSFoz/fC3DFV0bKaO2Pi3io1GAHaSKxPHpPiMHjV9 FP0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wo5mRBpfwNfsZY5/P5VVd4CS2W0ErWEgaoPNHTJ7c5w=; b=Q8dXsoQWu5/8HQQcqToUWKXL1brwjpjdBVqJHC2/YbZFD6VjEMAOCCj/BssIO0noBn 6+zo74XqwLRUMIpikHMAiFik+3PGtT1Z3tTZ62rBSDUk5acgdPNn6ydQeMrz9rI/iGiK 3WnbTOtyadw9JnvwXffvcnUb7/1Pr87ShMBTLNdp+nMEMT0BGuwDXIK5/UWTyhvwUYmt i0mnUbCD+Gxaeirhz+EmiCYO6SR31vMILvmZwe5WGGF/g5ibnyQNYSw0QhNfPXI69mPt 8GVsj/gafjbZ9hvzitRKUmd0u4tKZSezqTNH5EdxkesS4HQdoLKU8yC29u0qFoWzagRF NXbA== X-Gm-Message-State: ANhLgQ17Ttq07iyglZAXlmc2FDGKXc/0Y+0QtiCSqOl418OIgQiJZIsl FTYUoAvtQ5JpUEaVSc2DTxhkNQ== X-Received: by 2002:a5d:4c47:: with SMTP id n7mr190248wrt.254.1584467457822; Tue, 17 Mar 2020 10:50:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 19sm238300wma.3.2020.03.17.10.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:50:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 588221FF87; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 01/28] tests/docker: Install tools to cross-debug and build Linux kernels Date: Tue, 17 Mar 2020 17:50:26 +0000 Message-Id: <20200317175053.5278-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé We often run Linux kernels to test QEMU. We sometimes need to build them manually to use non-default features. We only miss the tiny 'bc' tool. The ncurses library is helpful to run 'make menuconfig'. Finally, gdb-multiarch allow us to debug a TCG guest when its architecture is different than the host. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20200212202738.12986-1-philmd@redhat.com> Message-Id: <20200316172155.971-2-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/docker/dockerfiles/debian10.docker b/tests/docker/dockerfiles/debian10.docker index 5de79ae5527..2fcdc406e83 100644 --- a/tests/docker/dockerfiles/debian10.docker +++ b/tests/docker/dockerfiles/debian10.docker @@ -17,14 +17,17 @@ RUN apt update && \ DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \ DEBIAN_FRONTEND=noninteractive eatmydata \ apt install -y --no-install-recommends \ + bc \ bison \ build-essential \ ca-certificates \ clang \ dbus \ flex \ + gdb-multiarch \ gettext \ git \ + libncurses5-dev \ pkg-config \ psmisc \ python3 \ diff --git a/tests/docker/dockerfiles/debian9.docker b/tests/docker/dockerfiles/debian9.docker index 8cbd742bb5f..92edbbf0f48 100644 --- a/tests/docker/dockerfiles/debian9.docker +++ b/tests/docker/dockerfiles/debian9.docker @@ -17,13 +17,16 @@ RUN apt update && \ DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \ DEBIAN_FRONTEND=noninteractive eatmydata \ apt install -y --no-install-recommends \ + bc \ bison \ build-essential \ ca-certificates \ clang \ flex \ + gdb-multiarch \ gettext \ git \ + libncurses5-dev \ pkg-config \ psmisc \ python3 \ From patchwork Tue Mar 17 17:50:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184637 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4431324ile; Tue, 17 Mar 2020 10:51:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt8iiLQI4AKI6SYI3bFBvT8jw8KaJAjKGeLbxCfS54MQfqdjKGj1Mc3McVc8jJmDuZhxLDJ X-Received: by 2002:aed:3ae9:: with SMTP id o96mr332706qte.348.1584467485932; Tue, 17 Mar 2020 10:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467485; cv=none; d=google.com; s=arc-20160816; b=HqcwRA1Jo9eG0P+qO+qxaP3kCr/ENxYHcko7xYj76scsJTLWrc8gCcmcg0LRbt8LDv XaFF0bCoRERgLFVPUGFGAFBsa+VyDibkoqOk/S03d2FSZaOZXtpx+N8S/LopTNPiGlmk 1Mtypt/M5vypzfTumREPDmDkrBogA2nDaLVpfedMx5Lk3h/vEPzLcxYQLh45guR/HK7O baNV48qcCaHWdvcdZ4m76VG5amJc/c3p3T/bPzHnfYyPcmMJd1UROcvQ2t4qlMXAcCIM WzNDYPKgB216F36n1KPVuS8Y/DC6PN6eL26ODJv/zWx/EPTazNzzgygyGpmfQ9hiMYvS cVPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6P6zv/6ofxs/2NCuAiUr9RMgFMe7GhXKsA0Z+BVz5bQ=; b=jw5gqpJVgOBK41MhKo8RtFLLptR6MduONpkVjQLj87B/EAICLYSsSST4N+lCWz3gZ1 cImkYqAwucfKABfyohi/9+wv3GnLIUXLIuJrSyg22veasob1wfbYwPwNL82wR/fkh+xn kf/Jz1wXFk3tuGgqlyW2QJqQ2eyjw7C4pI8wQGxWZczOcJj4P+91eyKWjpfL5CkWg9ln ZRvy4fTK3R/Ep60cAd3wZ/hFJxnYAImgo74tueF3znFZH3yk4F3MDIwc+sUaqZ0d/fxs Ek8l6NeVBDtp8dLy+Sat0M4bhWMwNXM6SFogLubl/yk5L9km13NtYkynLxBJIbYG87YM InJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YgihsrZ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c7si1467417qka.367.2020.03.17.10.51.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:51:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YgihsrZ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGNB-0000Kc-CJ for patch@linaro.org; Tue, 17 Mar 2020 13:51:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56873) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMm-0000H1-JL for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMk-0001f3-1t for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:00 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:44332) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMj-0001TX-Px for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:50:57 -0400 Received: by mail-wr1-x434.google.com with SMTP id y2so11392628wrn.11 for ; Tue, 17 Mar 2020 10:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6P6zv/6ofxs/2NCuAiUr9RMgFMe7GhXKsA0Z+BVz5bQ=; b=YgihsrZ54bnA1c40o3Vr8+QqmMt3O5w3JPapOZCabBRP0GV6qFJfS0IoH5QZIFRV9H oDkU8AGnrkZ+y4TmpYCn0PGZaMveg3igNs8HLCFyCORr6DpXKmWLlJYxVzbiukCzvIgJ 8GvuVc2jSBImvFCWw1zS9HCvw5bV/HgbsiyEExoSsLolFEn+acAlSZVtbeiONtNr17XW pqEhW5+wufJr94qxkk6XGpHzQ2oiJX4qyr9J5rfhOlPHSd/WJlusNocnnm58Do8AATMj 91k2A0c619Al6rm8irl7ys65QTgLVP/OtbvXAOYXc1oZHGlJtkRtxLUmBWrHeLMEBvdp MogQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6P6zv/6ofxs/2NCuAiUr9RMgFMe7GhXKsA0Z+BVz5bQ=; b=OznHl8OwhUfW5khcG0died25MiL8fwyZBQT+R4tDDUPorLa4iFaD9DJePCJ+pZ+gqC rhDzP5IhQuE/9ZvYHzuNrrS94buwie6iYuuOZvngFJmUTc3Xzpd5zqp7PULl0fOyIIcF lW0VAmcOClYCV4gFrJk29OZ49bK/fLhFmJehweYQSKK+EGfsNfmAjPXd7T2OeCnTj6V0 HKLHXCacdirSCg149ldSLr+ZZVr7ZysxWNH0SF472GVAFz4/sLSJTrQ1VGxL9WyvpI43 xwT6eioA5MxPxYnZvCianMC0Kn2Cv7EOAWh/aOqWWWu/w7omx/l4kztixyYFgzh+PMyT poUA== X-Gm-Message-State: ANhLgQ3wFTimcQIok1lvLlzZHFGzeNcZvYHr0aAgWfqwVPgZWGLRhP0V R4tz7JM/qhbc4EcK3MfycSjNjA== X-Received: by 2002:adf:ed42:: with SMTP id u2mr197284wro.226.1584467456614; Tue, 17 Mar 2020 10:50:56 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l5sm223591wml.3.2020.03.17.10.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:50:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6F85F1FF8C; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 02/28] tests/docker: Update VirGL git repository URL Date: Tue, 17 Mar 2020 17:50:27 +0000 Message-Id: <20200317175053.5278-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé freedesktop.org is moving to a GitLab instance, use the new url. - https://www.fooishbar.org/blog/gitlab-fdo-introduction/ - https://gitlab.freedesktop.org/freedesktop/freedesktop/-/wikis/home Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20200212202709.12665-2-philmd@redhat.com> Message-Id: <20200316172155.971-3-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/dockerfiles/debian-amd64.docker index 3b860af1068..b67fad54cb7 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -27,7 +27,7 @@ RUN apt update && \ libegl1-mesa-dev \ libepoxy-dev \ libgbm-dev -RUN git clone https://anongit.freedesktop.org/git/virglrenderer.git /usr/src/virglrenderer && \ +RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/src/virglrenderer && \ cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --with-glx --disable-tests && make install From patchwork Tue Mar 17 17:50:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184642 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4434459ile; Tue, 17 Mar 2020 10:54:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuSIfBTFSQ0EjWHzNFoRgn6NYyxJ4XKNBMlA+I0ecD+U1WJ3McwKNrXu6FV51zd6ETtP5Dv X-Received: by 2002:ac8:1aed:: with SMTP id h42mr346907qtk.43.1584467694040; Tue, 17 Mar 2020 10:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467694; cv=none; d=google.com; s=arc-20160816; b=tgyd2dWivGpiVI1QfVnX5xxco7wyWrnYt6HJP3jrMQYJzGNk6YNCsiPgGHUG/UhyFC UR4izBTbahYjw2U1KpCDwtSavOQlm5Ac2mpxbJ6us5TmXhdMp53ITNEYU/3LRWw9CQEd GRxYtxA1lT5snLMTkL50NLqkdQAGtD/1kIN3WXD5gy2TKd6UXTqTCEWd0CYOID1n4sVa dY7sJp7OpXwxH4VH8O7ypopX+K2iowSC7HDWbHwBaUyyAX9nRnIgsp+kbktkjDkPgGYI vuABi+aQjM57ELICSUbVpeQqDrBZh8jCClR2uscQkEXD15T4/FR/x4yOiPvo4uthclxl 3LeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ct6UnNO0v3t7GlF0HPoxhyjiCS97DL0SR0Dn0QoY3ek=; b=0Ywa5HrCmvzUC64xkviNIN/Rq4aDn4fogh8HHZMWEzO+cqybKtRQrE5lh+jnOAjEfH vlTDDerpJv4/UScjb4EXlizDIzVWMM0nCGjPhKVqkFVhI/m0BPvinRWm7N4Izq4kd610 EPSRSTZPsscZCk2IKGMU2RpNQd+6g763Vm33jbLT4SlmTDg7I4xRaUb3IvSnZkpr3/GA 70/1xu8CamnRYhk17ldHvEJTktnQArfkjV+hp4Br9JqAd8l/EYCi3w5YSrCoQXhlOKLS Z/d3oiiHtB/QI3QBbb7kKjYlzfOF536XAsnlWB8p1Za9Qi1IfaFucCDnAOU/PwXZXzrJ 9VBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="D+H2vv2/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i14si2483179qki.363.2020.03.17.10.54.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="D+H2vv2/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGQX-0007Ds-HH for patch@linaro.org; Tue, 17 Mar 2020 13:54:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56915) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMs-0000Im-1x for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMn-000281-Q7 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:04 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:37968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMn-00023R-JX for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:01 -0400 Received: by mail-wm1-x32d.google.com with SMTP id t13so244527wmi.3 for ; Tue, 17 Mar 2020 10:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ct6UnNO0v3t7GlF0HPoxhyjiCS97DL0SR0Dn0QoY3ek=; b=D+H2vv2/ZJHaFBk4sfreBJmvQVNbPMwYBsV1/MBbHbDWTR4QlU4DzOZtpjtJCmZRt9 GGbbg/ia7Em/WgtmW9IIreh3RoWin5cesql74IOyQ2zmMWk6rn+RDS17EKbZG6Lft8CJ IN9wJpz3TrOxs7t2MRI8lpAm90o3f6K7PQfq7CdPBvab87BAp09nRmc+nvGdPXo/TGBI qwsduMUbtlcv4I+J7C25NfyuLMjpslo48nlRwJWVu5k/zCgzdPXrwsj/6VwkR6dU+Qes MgYd611UoG10XSlml6Qef7Gj1bwcVFy2VCXZ9shxyyYlX3g6VnMBumcmnpOf++iERfgd rTnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ct6UnNO0v3t7GlF0HPoxhyjiCS97DL0SR0Dn0QoY3ek=; b=XeySG/31U/Z88fM6OQ7GJjTmKu8x0XTptbbnmD6iARbx2MQSJt98RxnyRcF6D3u7bO Z/3On4H50ju2KdWOdWKidfYtmV5SBpsg4/x2/aX2CZEjbOw3B3VL6JCluiSitanaMig4 KPWTYJFg2tP6TKrfcsFJDWgXmbZ9KFGqS1DpUDtRoxnTJ9xCmCEjxZSP5aHj7GwfcL3l g4z02KuI5fFj/2eXQ74LwmSqsd1aTBhGAl5wWP9suS3Q2QKjj0uDqe48gG+LrrUxQP7C fhLYawaMiHkaSAsP3fIiI8W30aDEkNNcOMA5+CTT2a6edK87LPOji+QwshIekp9yh7Z2 XhqQ== X-Gm-Message-State: ANhLgQ1jZU/lfb044iJHNW/aoFVKSCuxNEj8LEREANynlLxyaeV1MDle 1RX7Pv+nDjpKOyjOZyKoRO4nXQ== X-Received: by 2002:a7b:c770:: with SMTP id x16mr144638wmk.159.1584467460485; Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n9sm207661wmi.23.2020.03.17.10.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:50:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 840841FF8F; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 03/28] tests/docker: Remove obsolete VirGL --with-glx configure option Date: Tue, 17 Mar 2020 17:50:28 +0000 Message-Id: <20200317175053.5278-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The GLX configure option has been removed in 71c75f201d [*]. We missed that when updating to v0.7.0 in commit fab3220f97. This silents: configure: creating ./config.status config.status: creating virglrenderer.pc ... configure: WARNING: unrecognized options: --with-glx [*] https://gitlab.freedesktop.org/virgl/virglrenderer/commit/71c75f201d Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20200212202709.12665-3-philmd@redhat.com> Message-Id: <20200316172155.971-4-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/dockerfiles/debian-amd64.docker index b67fad54cb7..a1d40a56fa1 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -29,7 +29,7 @@ RUN apt update && \ libgbm-dev RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/src/virglrenderer && \ cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 -RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --with-glx --disable-tests && make install +RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --disable-tests && make install # netmap RUN apt update && \ From patchwork Tue Mar 17 17:50:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184638 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4431333ile; Tue, 17 Mar 2020 10:51:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtBb8RQgYGhxYTDCvB4bmc0x2i6rUKbiYxqoA1jhASTnIYiqJNV2DUiaaZ4pjYoNfTVzmoJ X-Received: by 2002:a37:5685:: with SMTP id k127mr5914439qkb.481.1584467487084; Tue, 17 Mar 2020 10:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467487; cv=none; d=google.com; s=arc-20160816; b=cXANPGkr9Vt+8aQJ7Mx3wCqt5uMTb8ywXSx0ILgH99P2KiOuU7Km+FeUireui9oqjY TbC+19fmElnLAwp7jKVSn7TotkTkSOQRcgp7NAfV4k6TmmNEiQYuYI8JkhONNk9QSi4t nrNCyXvHAp4GqNQo6alEepyN7oSwIO9uEvL7oECmByeH1NxrOmDfa2HcTtQzP7ShQruR gaO+ccc+EeNBf82XRwu8l2wZiEfVmIGY4col8BF8HAEsj7JTdcTMCdYb2xJkmOjpmvOA GPjGFW1eW85qZPE3ljRhtLHUQAJQn9XdcvMF2rMAbuM8FvsdwaYzGd/0N1lJRkAOWP7/ Bd5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=y/xH7KKbev8lpysybsWMzMTaGtbZlSBv+uAIC7/GWhE=; b=vSEj+nkIkQkmD3fRzDk+Oh8fJWMeV599GHCQQaXPUbibZHJJB3N1pisbyrJmJpOLva GQ1bPMN1R88RcmPcnYSITPRnrSx7hzpzccp3s/dDqNNDLu59NT1ZvtJElehYuVveZJB0 M4nxwTcCcZtp75fCKVTuLgWTLZiIGbsHysG55xpu8vMArslayj2ZXmsj+cHLxL4b9aA/ kNL+HMq9lXNTVcg4Qz8pxP2l8B3Got8JO2axHdINPUsnTI4JCIhlBFsFl0XFCdg8ZJS3 Mpioz2BHBpVAN3QH7GIyjn/jfnwicdFOPh//XlOX6uN0VqOK2R1eki7nwry1ObgUxlzm KLnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WPb0FEwG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q37si2233943qtk.312.2020.03.17.10.51.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WPb0FEwG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGNC-0000Op-Fk for patch@linaro.org; Tue, 17 Mar 2020 13:51:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMs-0000JQ-77 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMm-00020t-OA for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:05 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:35112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMm-0001rv-CJ for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:00 -0400 Received: by mail-wr1-x431.google.com with SMTP id h4so6269763wru.2 for ; Tue, 17 Mar 2020 10:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y/xH7KKbev8lpysybsWMzMTaGtbZlSBv+uAIC7/GWhE=; b=WPb0FEwGGjDjC+kAwgIdvsyZ6f10D556yNER69hAeS5roDzoQqzMA7P6y+0rvp4mt2 H52efzx5PwLUJLyB3FcIehksDmLunUGDk+hK0y2M71s6kTtNtVPj+fqaT8Txuutvhe6H r78i3UP9FcB/wBHjEt161B+wQLoIAejWy/C39C6rclKWmELPjMU8BLW19eaeuP3dxH2o sjjiw07l2txW3oIAhX3cX1mY0nYN+lUzSvp9kvNpsN72Qu1vjOO5ZICoyuR7parVUVY9 gMy3E/ToybI679jNpYRY0wxgPiW9DJTy+IQx57ivSn1wTaeDjgIanHHBVJVyvBgJWJRg P8uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y/xH7KKbev8lpysybsWMzMTaGtbZlSBv+uAIC7/GWhE=; b=QIH5LHp8rx5NCDfVMzB9682+q8DuxIn08W/gyBcGlRUiPA3Z7BoBZhVASj54cmUKsJ 9hs66lgXtKUZgwvArOX5oe8fUyZOu3XsPDWH56Iw9D1ONzsC9zazCaqKuxBI3FNPvA8D 6hnrAT9/cnuYpa+D/UnmVWKWg1CnNqXQBXhQL2kvQgkIIf9siZM+lzFraGiC1fMHapco FG9YJc4VIa3hKY9wps2AZHRKx2Mm057y86oqEsl522T+FZ59+VSxmXRGccqsWb2bmmvc mjvnb+oh7u4IPMVI1oyK6UMfLSC8s0IsNUMAHPDtaPK5VNQixHGFp/F7lmxOg8VcmBjy JqMQ== X-Gm-Message-State: ANhLgQ0SybRAO6GuAeEzpaoNQB5FdZOl51MfFZse3akN+gVHVQ1edLL/ t4rye80WNisGGXoLjRwTS7HAhg== X-Received: by 2002:a5d:5504:: with SMTP id b4mr134936wrv.181.1584467459325; Tue, 17 Mar 2020 10:50:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n10sm5768352wro.14.2020.03.17.10.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:50:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 99B0B1FF90; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 04/28] tests/docker: Update VirGL to v0.8.0 Date: Tue, 17 Mar 2020 17:50:29 +0000 Message-Id: <20200317175053.5278-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Building the qemu:debian-amd64 fails when building VirGL: make[2]: Entering directory '/usr/src/virglrenderer/src/gallium/auxiliary' CC cso_cache/cso_cache.lo CC cso_cache/cso_hash.lo CC os/os_misc.lo CC util/u_debug.lo CC util/u_debug_describe.lo CC util/u_format.lo GEN util/u_format_table.c Traceback (most recent call last): File "./util/u_format_table.py", line 168, in main() File "./util/u_format_table.py", line 164, in main write_format_table(formats) File "./util/u_format_table.py", line 132, in write_format_table print(" %s,\t/* is_array */" % (bool_map(format.is_array()),)) File "/usr/src/virglrenderer/src/gallium/auxiliary/util/u_format_parse.py", line 164, in is_array return self.array_element() != None File "/usr/src/virglrenderer/src/gallium/auxiliary/util/u_format_parse.py", line 73, in __eq__ return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size AttributeError: 'NoneType' object has no attribute 'type' make[2]: Leaving directory '/usr/src/virglrenderer/src/gallium/auxiliary' make[2]: *** [Makefile:906: util/u_format_table.c] Error 1 make[1]: *** [Makefile:631: install-recursive] Error 1 VirGL commits a8962eda1..a613dcc82 fix this problem. Update to VirGL 0.8.0 which contains them. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20200212202709.12665-4-philmd@redhat.com> Message-Id: <20200316172155.971-5-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/dockerfiles/debian-amd64.docker index a1d40a56fa1..c70c916343e 100644 --- a/tests/docker/dockerfiles/debian-amd64.docker +++ b/tests/docker/dockerfiles/debian-amd64.docker @@ -28,7 +28,7 @@ RUN apt update && \ libepoxy-dev \ libgbm-dev RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git /usr/src/virglrenderer && \ - cd /usr/src/virglrenderer && git checkout virglrenderer-0.7.0 + cd /usr/src/virglrenderer && git checkout virglrenderer-0.8.0 RUN cd /usr/src/virglrenderer && ./autogen.sh && ./configure --disable-tests && make install # netmap From patchwork Tue Mar 17 17:50:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184639 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4432782ile; Tue, 17 Mar 2020 10:52:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu7hEuYaCDfYCLHB/5kmU3tYC2HKLWDd1IROOkk3L5as2bV96Gk+2GGG0YDhIeIM3HHdOz4 X-Received: by 2002:a05:6214:56c:: with SMTP id cj12mr328835qvb.29.1584467579086; Tue, 17 Mar 2020 10:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467579; cv=none; d=google.com; s=arc-20160816; b=oCjLW2at6eTW1jRuvezyxur+sVL4vsbovdb71tiqSWyBdlt4Go+KB1HRkw78skIPRV VueXG8fix/tQrLVaWeUyHFJ80wTQzaeaYRahRaYUKWWnnQ2YJHZop/XMfxk9blVEg4Ip pVTJ5oh36YndYl9ETzPs/6Rcx/Y2scG0beuoe91GMRf/HiS/jQ66dzLoxhNJMHSeq7b1 K4oFb+6FoLMkGRm5X+s7OPi56hJvOfgaucvCdAe/JIVMrT7Ot8tkyXrQ9ouYW2GR7ola 920qVeoqEkkY3C1MatmC44vskVnTqNbNvqYIjNps2gwKpT7HaUAoBLp8lk66XB+9G9kh Py7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=IMRyldADtWFAPXkEQJ3RH0vIzu/xA/WRDnShCl/zgaI=; b=GwpH0nUQYXJCu419E4mEZd514XRIMlaBZkm10RlIMNiCJlQdwHrh05dldbEQEFgPXi x6atnbzq6li8+uxnmOaOgbGvSGoDLqMf77ca47ccb1gkavcjETnGVyyshYw73KjMQQ/P HXBMi0QmkgfzU4U32X8k5U9Yek8nlRM3LjPiRH8/C3Paqs+TKKKRK6UUkHkDQp9qPhxV kysNHLqM5ZW3vYOftrZHTZr1PzLjN0/BiortiL5wgyz7kHQlU4hDS3nCgqS/mLkCbhLV x/W/iCr0BfuzMpnvYIZV4xIsCpQrA1UqGVIkrQmdKxySspDxDQaRXrgvT69FRv9JYhWH DIkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GUEM3lOu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i14si2563216qkg.74.2020.03.17.10.52.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GUEM3lOu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38071 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGOg-0003qW-Ij for patch@linaro.org; Tue, 17 Mar 2020 13:52:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56943) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMu-0000Ke-Fy for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMt-0002Ou-Ip for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:08 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:37626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMs-0002Bt-AB for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:07 -0400 Received: by mail-wr1-x431.google.com with SMTP id 6so26871668wre.4 for ; Tue, 17 Mar 2020 10:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IMRyldADtWFAPXkEQJ3RH0vIzu/xA/WRDnShCl/zgaI=; b=GUEM3lOu7uriy+U23tyWVTMCaZCMs3e0wSz/pfjCY30Df3cb96nxMKTlYw2WXSS25d zlm3ELwIzxlTs9pbAi/B9YQa/SeqzSUL0TTM37phHYXRBeYXs7dY2d3BGqz6eEGk6stY 7wf++SH8AvNBhVznbjid3s+xCD2/hV1PyQJuPfdRoVYONApdVMA9NhgtRIp1zeWyj48G yLImwpBAVfQY4q8wlci1rEmC0bEXS6AOEcixaRK3SZjmjcfyWHkmoizEnfnlNmw6yBSa kyqJw2sXQbZsbDTeJE+4AZtyhd7bHoM/ydESoJc2Ew0upEDUpNZzrOCGiDVnu7URfKoT CP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IMRyldADtWFAPXkEQJ3RH0vIzu/xA/WRDnShCl/zgaI=; b=OcMhTfodlMo6acramiaVHoY1LUqz7XU+LDwlhl/OzGHmOrrTPlXJ5b42HZnSeFO6yX JY+aQDyGl/f/nw4L6IKqgTL/Fasu4m6zxp2Mw4KguT/9KoWTmvWYuMhAE15wkCuMUyT/ gRxFyynwutkaQC2DMaK83dSLAojh+TS5jjvQ4kK9Dqjej6bl+IeJZx870ytUIPpmzKjk +4tbul4RBXJ0Y31O6XKvgW0ihvMD1jfXio86+KLGPeehbKMilieqngR30CvV/r6LRN6n P4cmEtWwQQDw26Nc1W58JkjReZ6wGgVbJaAjA/LcFQMonLwRoiRS9qEYvRCG/J+q2kab p4SQ== X-Gm-Message-State: ANhLgQ35lq3Dhta6aJ/5dubOSyWc7EtC0JlkYv/K1GbJ7ZstQCoIjnTk mkyhtP4YWFtu0WAnpppvEyxKDA== X-Received: by 2002:a5d:68c1:: with SMTP id p1mr197570wrw.198.1584467462480; Tue, 17 Mar 2020 10:51:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c5sm654524wma.3.2020.03.17.10.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE8401FF91; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 05/28] travis.yml: Set G_MESSAGES_DEBUG do report GLib errors Date: Tue, 17 Mar 2020 17:50:30 +0000 Message-Id: <20200317175053.5278-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Since commit f5852efa293 we can display GLib errors with the QEMU error reporting API. Set it to the 'error' level, as this helps understanding failures from QEMU calls to GLib on Travis-CI. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20200316101544.22361-1-philmd@redhat.com> Message-Id: <20200316172155.971-6-alex.bennee@linaro.org> -- 2.20.1 diff --git a/.travis.yml b/.travis.yml index b92798ac3b9..ccf68aa9abc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,6 +79,7 @@ env: - MAIN_SOFTMMU_TARGETS="aarch64-softmmu,mips64-softmmu,ppc64-softmmu,riscv64-softmmu,s390x-softmmu,x86_64-softmmu" - CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime" - CCACHE_MAXSIZE=1G + - G_MESSAGES_DEBUG=error git: From patchwork Tue Mar 17 17:50:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184641 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4433216ile; Tue, 17 Mar 2020 10:53:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt5C8A7LD4cjC40S8nN6zoQKyOtPEhagd92HX4n4o2OOJRIa0jmMEYNmurT4iPsCrveiZLh X-Received: by 2002:a37:4fd4:: with SMTP id d203mr8476qkb.249.1584467593277; Tue, 17 Mar 2020 10:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467593; cv=none; d=google.com; s=arc-20160816; b=wnh6yGyryG47UbMItaOThZ6F6FTrDQfc4i3eTe0ApVAUsHViHZ2228/WxXIPQu0p8z UDvc4eMQyxSRUD9FB48h4ofGRqkw9Wo7RTkzDDCcaVHDbx6IqdIfEAk/+H7JCUWztuRE j06kr7CKrbvl7IkCsw7bNnMIW0AH+LkTCGW+gVDrfs9ZyDlU/VfqWiBWOdPD/C3gbLaP ULsMhfhM2pUC56HPqLDrU38zr07Zui2W79r+hAfZ9mo6jUSj3ZcesG9HzkCNl3BJNX3j KUOcDa0u/M55q3/ZtxUycTknNnF1xQ6APcK0chb4TvCkdtJ54n9UrOCvHfptsyVYT73z k5jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=heJ4t9xE2YBO8U1r7sTN/0xyO/uGZXEKojg/o9HstSY=; b=kyFn9Tj6LNzMJ3bGiqwFyhn1PF/cKyvYIoyMUL5zNkpME4edORIsamL3nvP0WZqW+Y z6Bn2F0XUMv6InGHR3RfVeR/L3hDJdrsEuvki7r+47AEk9TnBG4mQ+ftOXyGyClicsJd ArJ9/qBNqK4DNKi/slcA447/vz7bomvHzJCZwSIocuGjTQXipcT4S/7mzVu415eaXG7T aL7i9VXXU+KhYUnXVjeoR7XkgRdaVYzygL+yQNDkuYaI4LxpiUfa8X6+lf8i8wpaYTPx e/h97oKu/8SJp+0Zaidm2ZMimE3Kq19p1MmT6kI9w9mt/M2rLdzTYQAWP4SldAL8qGKT JCWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lMLgqJKT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s28si2515390qkj.156.2020.03.17.10.53.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lMLgqJKT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGOu-0003wc-OF for patch@linaro.org; Tue, 17 Mar 2020 13:53:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57071) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMy-0000TP-Rl for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMt-0002Oz-Iv for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:12 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMs-0002CQ-9f for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:07 -0400 Received: by mail-wr1-x42d.google.com with SMTP id h4so6270151wru.2 for ; Tue, 17 Mar 2020 10:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=heJ4t9xE2YBO8U1r7sTN/0xyO/uGZXEKojg/o9HstSY=; b=lMLgqJKTtBZd6lqksygRd8WRWrb1/YIxIBHCVF1y9tq1o6jwYRZNMOxmKRsCCCDm35 yzsCXmLzV8MbNFJbBCJDaFh77xP+lBDIZyCHu+EyKKH+bEWf0Ot4XZFBZWl5kWnpgv/O VMACksNI4njN721Z8Z5zHiX+01Iz/+yn2C+34mFG9+ZnL86AqREKgvsTuFGlanfiyGVl KLWFloa/SeAOyMheGFwGgz3cOIOOI7CtxCyHSFhUX8ARrq2esdjsu898qTW6S2n3d7Xm ppaw2X1tgO1KEKv+/leNEdn06CyV2EJLZz9ORMHdyh/F8SNwgf0upI5qmYnJ+eK98aRa SoaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=heJ4t9xE2YBO8U1r7sTN/0xyO/uGZXEKojg/o9HstSY=; b=pA1ojZw5iqCTJJdSWsW6YvjMFcN5FK/RirXB+aS1Wa//GdAU6JWmYtq61rnpNhheCL Huktw3I214WglgltkP+PIszkfjRZIgO3/AH18lCTmR2+GFpChmeHWLAM6V1geF+4UtSv Hs53CQwDUtRa650MS3uzzUr0etKNPaDjpwrn20jTOFTW8ugB06t6aLZ+a2od5SGTRzed LydF8ws9lFv6/f3f7n1oJ4Ul3e8y+PPDnGH2dx3cBYjPJLlbVTj352s9at+HjGW9APY3 nPsPczQUsHZyckdJ5YnVYP4ogb/RaOS4uf2WfOul4HXEFyyabMxL+AQGbdknFh9L+q1t Cwow== X-Gm-Message-State: ANhLgQ0gQXRmOFdWo4aws7NVFyHrO+cd+EfFBZ3PMQRerIh6GSpR2M6A 7MrmnpUk3nMgJq24LdtvQ1ABEw== X-Received: by 2002:adf:dfc6:: with SMTP id q6mr115159wrn.375.1584467463743; Tue, 17 Mar 2020 10:51:03 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f9sm5534451wro.47.2020.03.17.10.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C36401FF92; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 06/28] gdbstub: make GDBState static and have common init function Date: Tue, 17 Mar 2020 17:50:31 +0000 Message-Id: <20200317175053.5278-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Instead of allocating make this entirely static. We shall reduce the size of the structure in later commits and dynamically allocate parts of it. We introduce an init and reset helper function to keep all the manipulation in one place. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Message-Id: <20200316172155.971-7-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 22a2d630cdc..57d6e50ddfc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -342,6 +342,7 @@ enum RSState { RS_CHKSUM2, }; typedef struct GDBState { + bool init; /* have we been initialised? */ CPUState *c_cpu; /* current CPU for step/continue ops */ CPUState *g_cpu; /* current CPU for other ops */ CPUState *query_cpu; /* for q{f|s}ThreadInfo */ @@ -372,7 +373,23 @@ typedef struct GDBState { */ static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER; -static GDBState *gdbserver_state; +static GDBState gdbserver_state; + +static void init_gdbserver_state(void) +{ + g_assert(!gdbserver_state.init); + memset(&gdbserver_state, 0, sizeof(GDBState)); + gdbserver_state.init = true; +} + +#ifndef CONFIG_USER_ONLY +static void reset_gdbserver_state(void) +{ + g_free(gdbserver_state.processes); + gdbserver_state.processes = NULL; + gdbserver_state.process_num = 0; +} +#endif bool gdb_has_xml; @@ -425,8 +442,8 @@ int use_gdb_syscalls(void) /* -semihosting-config target=auto */ /* On the first call check if gdb is connected and remember. */ if (gdb_syscall_mode == GDB_SYS_UNKNOWN) { - gdb_syscall_mode = (gdbserver_state ? GDB_SYS_ENABLED - : GDB_SYS_DISABLED); + gdb_syscall_mode = gdbserver_state.init ? + GDB_SYS_ENABLED : GDB_SYS_DISABLED; } return gdb_syscall_mode == GDB_SYS_ENABLED; } @@ -984,7 +1001,7 @@ static int gdb_breakpoint_insert(int type, target_ulong addr, target_ulong len) int err = 0; if (kvm_enabled()) { - return kvm_insert_breakpoint(gdbserver_state->c_cpu, addr, len, type); + return kvm_insert_breakpoint(gdbserver_state.c_cpu, addr, len, type); } switch (type) { @@ -1021,7 +1038,7 @@ static int gdb_breakpoint_remove(int type, target_ulong addr, target_ulong len) int err = 0; if (kvm_enabled()) { - return kvm_remove_breakpoint(gdbserver_state->c_cpu, addr, len, type); + return kvm_remove_breakpoint(gdbserver_state.c_cpu, addr, len, type); } switch (type) { @@ -1074,7 +1091,7 @@ static void gdb_breakpoint_remove_all(void) CPUState *cpu; if (kvm_enabled()) { - kvm_remove_all_breakpoints(gdbserver_state->c_cpu); + kvm_remove_all_breakpoints(gdbserver_state.c_cpu); return; } @@ -2601,7 +2618,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) void gdb_set_stop_cpu(CPUState *cpu) { - GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + GDBProcess *p = gdb_get_cpu_process(&gdbserver_state, cpu); if (!p->attached) { /* @@ -2611,14 +2628,14 @@ void gdb_set_stop_cpu(CPUState *cpu) return; } - gdbserver_state->c_cpu = cpu; - gdbserver_state->g_cpu = cpu; + gdbserver_state.c_cpu = cpu; + gdbserver_state.g_cpu = cpu; } #ifndef CONFIG_USER_ONLY static void gdb_vm_state_change(void *opaque, int running, RunState state) { - GDBState *s = gdbserver_state; + GDBState *s = &gdbserver_state; CPUState *cpu = s->c_cpu; char buf[256]; char thread_id[16]; @@ -2722,17 +2739,16 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) char *p_end; target_ulong addr; uint64_t i64; - GDBState *s; - s = gdbserver_state; - if (!s) + if (!gdbserver_state.init) return; - s->current_syscall_cb = cb; + + gdbserver_state.current_syscall_cb = cb; #ifndef CONFIG_USER_ONLY vm_stop(RUN_STATE_DEBUG); #endif - p = s->syscall_buf; - p_end = &s->syscall_buf[sizeof(s->syscall_buf)]; + p = &gdbserver_state.syscall_buf[0]; + p_end = &gdbserver_state.syscall_buf[sizeof(gdbserver_state.syscall_buf)]; *(p++) = 'F'; while (*fmt) { if (*fmt == '%') { @@ -2765,14 +2781,14 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } *p = 0; #ifdef CONFIG_USER_ONLY - put_packet(s, s->syscall_buf); + put_packet(&gdbserver_state, gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check * gdb_handlesig's return value (which is the signal to deliver if * execution was resumed via a continue packet). */ - gdb_handlesig(s->c_cpu, 0); + gdb_handlesig(gdbserver_state.c_cpu, 0); #else /* In this case wait to send the syscall packet until notification that the CPU has stopped. This must be done because if the packet is sent @@ -2780,7 +2796,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) is still in the running state, which can cause packets to be dropped and state transition 'T' packets to be sent while the syscall is still being processed. */ - qemu_cpu_kick(s->c_cpu); + qemu_cpu_kick(gdbserver_state.c_cpu); #endif } @@ -2941,15 +2957,13 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) /* Tell the remote gdb that the process has exited. */ void gdb_exit(CPUArchState *env, int code) { - GDBState *s; char buf[4]; - s = gdbserver_state; - if (!s) { + if (!gdbserver_state.init) { return; } #ifdef CONFIG_USER_ONLY - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } #endif @@ -2957,10 +2971,10 @@ void gdb_exit(CPUArchState *env, int code) trace_gdbstub_op_exiting((uint8_t)code); snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&s->chr, true); + qemu_chr_fe_deinit(&gdbserver_state.chr, true); #endif } @@ -2993,12 +3007,10 @@ static void create_default_process(GDBState *s) int gdb_handlesig(CPUState *cpu, int sig) { - GDBState *s; char buf[256]; int n; - s = gdbserver_state; - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return sig; } @@ -3008,58 +3020,55 @@ gdb_handlesig(CPUState *cpu, int sig) if (sig != 0) { snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); } /* put_packet() might have detected that the peer terminated the connection. */ - if (s->fd < 0) { + if (gdbserver_state.fd < 0) { return sig; } sig = 0; - s->state = RS_IDLE; - s->running_state = 0; - while (s->running_state == 0) { - n = read(s->fd, buf, 256); + gdbserver_state.state = RS_IDLE; + gdbserver_state.running_state = 0; + while (gdbserver_state.running_state == 0) { + n = read(gdbserver_state.fd, buf, 256); if (n > 0) { int i; for (i = 0; i < n; i++) { - gdb_read_byte(s, buf[i]); + gdb_read_byte(&gdbserver_state, buf[i]); } } else { /* XXX: Connection closed. Should probably wait for another connection before continuing. */ if (n == 0) { - close(s->fd); + close(gdbserver_state.fd); } - s->fd = -1; + gdbserver_state.fd = -1; return sig; } } - sig = s->signal; - s->signal = 0; + sig = gdbserver_state.signal; + gdbserver_state.signal = 0; return sig; } /* Tell the remote gdb that the process has exited due to SIG. */ void gdb_signalled(CPUArchState *env, int sig) { - GDBState *s; char buf[4]; - s = gdbserver_state; - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(s, buf); + put_packet(&gdbserver_state, buf); } static bool gdb_accept(void) { - GDBState *s; struct sockaddr_in sockaddr; socklen_t len; int fd; @@ -3083,15 +3092,13 @@ static bool gdb_accept(void) return false; } - s = g_malloc0(sizeof(GDBState)); - create_default_process(s); - s->processes[0].attached = true; - s->c_cpu = gdb_first_attached_cpu(s); - s->g_cpu = s->c_cpu; - s->fd = fd; + init_gdbserver_state(); + create_default_process(&gdbserver_state); + gdbserver_state.processes[0].attached = true; + gdbserver_state.c_cpu = gdb_first_attached_cpu(&gdbserver_state); + gdbserver_state.g_cpu = gdbserver_state.c_cpu; + gdbserver_state.fd = fd; gdb_has_xml = false; - - gdbserver_state = s; return true; } @@ -3144,13 +3151,11 @@ int gdbserver_start(int port) /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { - GDBState *s = gdbserver_state; - - if (gdbserver_fd < 0 || s->fd < 0) { + if (gdbserver_fd < 0 || gdbserver_state.fd < 0) { return; } - close(s->fd); - s->fd = -1; + close(gdbserver_state.fd); + gdbserver_state.fd = -1; cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } @@ -3167,7 +3172,7 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) int i; for (i = 0; i < size; i++) { - gdb_read_byte(gdbserver_state, buf[i]); + gdb_read_byte(&gdbserver_state, buf[i]); } } @@ -3210,13 +3215,13 @@ static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) const char *p = (const char *)buf; int max_sz; - max_sz = (sizeof(gdbserver_state->last_packet) - 2) / 2; + max_sz = (sizeof(gdbserver_state.last_packet) - 2) / 2; for (;;) { if (len <= max_sz) { - gdb_monitor_output(gdbserver_state, p, len); + gdb_monitor_output(&gdbserver_state, p, len); break; } - gdb_monitor_output(gdbserver_state, p, max_sz); + gdb_monitor_output(&gdbserver_state, p, max_sz); p += max_sz; len -= max_sz; } @@ -3308,18 +3313,10 @@ static void create_processes(GDBState *s) create_default_process(s); } -static void cleanup_processes(GDBState *s) -{ - g_free(s->processes); - s->process_num = 0; - s->processes = NULL; -} - int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); - GDBState *s; char gdbstub_device_name[128]; Chardev *chr = NULL; Chardev *mon_chr; @@ -3357,10 +3354,8 @@ int gdbserver_start(const char *device) return -1; } - s = gdbserver_state; - if (!s) { - s = g_malloc0(sizeof(GDBState)); - gdbserver_state = s; + if (!gdbserver_state.init) { + init_gdbserver_state(); qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); @@ -3369,31 +3364,30 @@ int gdbserver_start(const char *device) NULL, NULL, &error_abort); monitor_init_hmp(mon_chr, false, &error_abort); } else { - qemu_chr_fe_deinit(&s->chr, true); - mon_chr = s->mon_chr; - cleanup_processes(s); - memset(s, 0, sizeof(GDBState)); - s->mon_chr = mon_chr; + qemu_chr_fe_deinit(&gdbserver_state.chr, true); + mon_chr = gdbserver_state.mon_chr; + reset_gdbserver_state(); } - create_processes(s); + create_processes(&gdbserver_state); if (chr) { - qemu_chr_fe_init(&s->chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, - gdb_chr_event, NULL, s, NULL, true); + qemu_chr_fe_init(&gdbserver_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_state.chr, gdb_chr_can_receive, + gdb_chr_receive, gdb_chr_event, + NULL, &gdbserver_state, NULL, true); } - s->state = chr ? RS_IDLE : RS_INACTIVE; - s->mon_chr = mon_chr; - s->current_syscall_cb = NULL; + gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE; + gdbserver_state.mon_chr = mon_chr; + gdbserver_state.current_syscall_cb = NULL; return 0; } void gdbserver_cleanup(void) { - if (gdbserver_state) { - put_packet(gdbserver_state, "W00"); + if (gdbserver_state.init) { + put_packet(&gdbserver_state, "W00"); } } From patchwork Tue Mar 17 17:50:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184644 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4435149ile; Tue, 17 Mar 2020 10:55:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvFZeHd5s6BP4f3EZ/DrpNhER4bTiGedclLH5A5cP8q0DeSHSQveQWp06eIKKhubG0TGRmA X-Received: by 2002:ac8:6756:: with SMTP id n22mr327516qtp.312.1584467740907; Tue, 17 Mar 2020 10:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467740; cv=none; d=google.com; s=arc-20160816; b=GBYrfkmE+A3h/ITJ7bCwANagocZ7wuZ2JVjhDqNLEG8iPUO8Xb/uAd2R2XwwpjXNls EyPyjvt7FwvORfqGnZjHMIE91mP1f4Zo4MW+tygIrS5tcWunx0PxdYiQnh7oujAiexEp SYD/cMiWZygD5dsZysLMiEWQhJ0NDrcAR+pYbv/w3gMqxA2ID4Ww7/6AcbzGEE/Z5LE8 yzch0IdcH1yHhO9gyo7Ev7JrpTCZSs2I/lVnF160yOOkIrFkIUteWH+r5oRLcU4INwS8 dK8YBWXRSI5rjU6IwlAumWItkOqf8L9rYMUmI9pb9W9LfCeILnF1nzno5p88Aojsw41a s95w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=H9lCyHDq3VyvgPj2J2Jk19pcWolleFK9zFq0hATr+mk=; b=PFLwpfdAmIw+x1fnxNkLAH3ebszbxrvtXyMaOVdkpIW0JPptYReutdR5q2QdWSzHaG n3p4lXrNGxAluWOuHi7n1ULKnL3bm99RSNXTApodLjrDcXgnFmccB/VvrIoLI8NuJKPX Fux7ReF24BLZjOb1XqAPFK2DInEWoXSeEHEejmS8KhCm7vBC2XjgKIDtmuois88sdd5L NejmRpY390arUUhu9Kbjbx2pxEXWvDHb5TnRNUys+7mc9MgYBNod/MVG+mGzT0GORjH9 E3aRGB8OXDNX2B2pnLikZPD3t2/SOSOuODygLloa9YlxKl3aYikc2QHeSm+88GkXWgGj H03w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CLQj6z1c; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q14si2351875qtn.331.2020.03.17.10.55.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CLQj6z1c; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGRH-00087I-PF for patch@linaro.org; Tue, 17 Mar 2020 13:55:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57257) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN5-0000kj-KH for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMv-0002ak-SH for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:19 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:36488) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMv-0002Ry-Df for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:09 -0400 Received: by mail-wm1-x329.google.com with SMTP id g62so257343wme.1 for ; Tue, 17 Mar 2020 10:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H9lCyHDq3VyvgPj2J2Jk19pcWolleFK9zFq0hATr+mk=; b=CLQj6z1czEi+RuEs84H2PfZSu/LkxMKmvitXe/MvIu9zswM6Yx1xRyfjva0yw/E4nl kTv1Xl3hZk03A4H7IUWUN35vrqkmKxJtCKEo6ETWVdqdz9lEFn8lpxYhLRC2HL8SdZtY jMr351qWC8/WLEZL/76cP0Du27eJ/r7lCWG7j7wKSdEllQ80d6no5lJmbDLY7QJ6OePK buUN8muHguVmftM7kqZOJ+NWV00p38WTeB2aokMVaa7qq7RL54JZHkpC1/dY3X+GFjA9 u+6EGvX+oEBgMC9ihd0IrwuhuKp91+uEP7u9btK3MLC7D84w3XJepX6fFGRDvSJXVEYY +fDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H9lCyHDq3VyvgPj2J2Jk19pcWolleFK9zFq0hATr+mk=; b=CwCLuIEpfjHA3KSCKcx69QOQf8GlbL56OHg4qTTasTh8hE4kahg/1iMwR5ecZRBsog G+95BxHX0GaaOMgwXv/8t09KeLrp/Tm6uMY9fyARqcM6X5WhhuuA7M5U9WdYtqwSV5Ef UkT0hN2PhrS0/3x5Ukspv8R7CWO+g6tdakPz72URNEAQyJ35GJK/qJgbLqgWdGi4hwfV qBe0zQyALq/wWcAIkd7x7iFqWytjyyTwxd5mga2BIHkzsBVT6aWcb5hw831pPQr1tkTV a9Pn10AfNAl8HvCuMOqWsWXu64cJn0VOTJCqoBOlGgi+FKmDSGqlQ9PfO9jHWqkoRaML 7GmA== X-Gm-Message-State: ANhLgQ1U5gFxUZf/AejEQPVM320Xgg8kl0eJyq9pc7p73SnkSAR9to/j 4kndCnV6xgK5WwZOqEElrlD5+3P1Ie4= X-Received: by 2002:a1c:de41:: with SMTP id v62mr209220wmg.60.1584467467343; Tue, 17 Mar 2020 10:51:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y15sm5405874wrp.92.2020.03.17.10.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E087F1FF93; Tue, 17 Mar 2020 17:50:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 07/28] gdbstub: stop passing GDBState * around and use global Date: Tue, 17 Mar 2020 17:50:32 +0000 Message-Id: <20200317175053.5278-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We only have one GDBState which should be allocated at the time we process any commands. This will make further clean-up a bit easier. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-8-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 57d6e50ddfc..7243a2f7af9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -397,21 +397,21 @@ bool gdb_has_xml; /* XXX: This is not thread safe. Do we care? */ static int gdbserver_fd = -1; -static int get_char(GDBState *s) +static int get_char(void) { uint8_t ch; int ret; for(;;) { - ret = qemu_recv(s->fd, &ch, 1, 0); + ret = qemu_recv(gdbserver_state.fd, &ch, 1, 0); if (ret < 0) { if (errno == ECONNRESET) - s->fd = -1; + gdbserver_state.fd = -1; if (errno != EINTR) return -1; } else if (ret == 0) { - close(s->fd); - s->fd = -1; + close(gdbserver_state.fd); + gdbserver_state.fd = -1; return -1; } else { break; @@ -449,11 +449,11 @@ int use_gdb_syscalls(void) } /* Resume execution. */ -static inline void gdb_continue(GDBState *s) +static inline void gdb_continue(void) { #ifdef CONFIG_USER_ONLY - s->running_state = 1; + gdbserver_state.running_state = 1; trace_gdbstub_op_continue(); #else if (!runstate_needs_reset()) { @@ -467,7 +467,7 @@ static inline void gdb_continue(GDBState *s) * Resume execution, per CPU actions. For user-mode emulation it's * equivalent to gdb_continue. */ -static int gdb_continue_partial(GDBState *s, char *newstates) +static int gdb_continue_partial(char *newstates) { CPUState *cpu; int res = 0; @@ -482,7 +482,7 @@ static int gdb_continue_partial(GDBState *s, char *newstates) cpu_single_step(cpu, sstep_flags); } } - s->running_state = 1; + gdbserver_state.running_state = 1; #else int flag = 0; @@ -520,13 +520,13 @@ static int gdb_continue_partial(GDBState *s, char *newstates) return res; } -static void put_buffer(GDBState *s, const uint8_t *buf, int len) +static void put_buffer(const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY int ret; while (len > 0) { - ret = send(s->fd, buf, len, 0); + ret = send(gdbserver_state.fd, buf, len, 0); if (ret < 0) { if (errno != EINTR) return; @@ -538,7 +538,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) #else /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, buf, len); + qemu_chr_fe_write_all(&gdbserver_state.chr, buf, len); #endif } @@ -620,17 +620,18 @@ static void hexdump(const char *buf, int len, } /* return -1 if error, 0 if OK */ -static int put_packet_binary(GDBState *s, const char *buf, int len, bool dump) +static int put_packet_binary(const char *buf, int len, bool dump) { int csum, i; uint8_t *p; + uint8_t *ps = &gdbserver_state.last_packet[0]; if (dump && trace_event_get_state_backends(TRACE_GDBSTUB_IO_BINARYREPLY)) { hexdump(buf, len, trace_gdbstub_io_binaryreply); } for(;;) { - p = s->last_packet; + p = ps; *(p++) = '$'; memcpy(p, buf, len); p += len; @@ -642,11 +643,11 @@ static int put_packet_binary(GDBState *s, const char *buf, int len, bool dump) *(p++) = tohex((csum >> 4) & 0xf); *(p++) = tohex((csum) & 0xf); - s->last_packet_len = p - s->last_packet; - put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); + gdbserver_state.last_packet_len = p - ps; + put_buffer(ps, gdbserver_state.last_packet_len); #ifdef CONFIG_USER_ONLY - i = get_char(s); + i = get_char(); if (i < 0) return -1; if (i == '+') @@ -659,11 +660,11 @@ static int put_packet_binary(GDBState *s, const char *buf, int len, bool dump) } /* return -1 if error, 0 if OK */ -static int put_packet(GDBState *s, const char *buf) +static int put_packet(const char *buf) { trace_gdbstub_io_reply(buf); - return put_packet_binary(s, buf, strlen(buf), false); + return put_packet_binary(buf, strlen(buf), false); } /* Encode data using the encoding for 'x' packets. */ @@ -687,37 +688,38 @@ static int memtox(char *buf, const char *mem, int len) return p - buf; } -static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +static uint32_t gdb_get_cpu_pid(CPUState *cpu) { /* TODO: In user mode, we should use the task state PID */ if (cpu->cluster_index == UNASSIGNED_CLUSTER_INDEX) { /* Return the default process' PID */ - return s->processes[s->process_num - 1].pid; + int index = gdbserver_state.process_num - 1; + return gdbserver_state.processes[index].pid; } return cpu->cluster_index + 1; } -static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid) +static GDBProcess *gdb_get_process(uint32_t pid) { int i; if (!pid) { /* 0 means any process, we take the first one */ - return &s->processes[0]; + return &gdbserver_state.processes[0]; } - for (i = 0; i < s->process_num; i++) { - if (s->processes[i].pid == pid) { - return &s->processes[i]; + for (i = 0; i < gdbserver_state.process_num; i++) { + if (gdbserver_state.processes[i].pid == pid) { + return &gdbserver_state.processes[i]; } } return NULL; } -static GDBProcess *gdb_get_cpu_process(const GDBState *s, CPUState *cpu) +static GDBProcess *gdb_get_cpu_process(CPUState *cpu) { - return gdb_get_process(s, gdb_get_cpu_pid(s, cpu)); + return gdb_get_process(gdb_get_cpu_pid(cpu)); } static CPUState *find_cpu(uint32_t thread_id) @@ -733,13 +735,12 @@ static CPUState *find_cpu(uint32_t thread_id) return NULL; } -static CPUState *get_first_cpu_in_process(const GDBState *s, - GDBProcess *process) +static CPUState *get_first_cpu_in_process(GDBProcess *process) { CPUState *cpu; CPU_FOREACH(cpu) { - if (gdb_get_cpu_pid(s, cpu) == process->pid) { + if (gdb_get_cpu_pid(cpu) == process->pid) { return cpu; } } @@ -747,13 +748,13 @@ static CPUState *get_first_cpu_in_process(const GDBState *s, return NULL; } -static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +static CPUState *gdb_next_cpu_in_process(CPUState *cpu) { - uint32_t pid = gdb_get_cpu_pid(s, cpu); + uint32_t pid = gdb_get_cpu_pid(cpu); cpu = CPU_NEXT(cpu); while (cpu) { - if (gdb_get_cpu_pid(s, cpu) == pid) { + if (gdb_get_cpu_pid(cpu) == pid) { break; } @@ -764,12 +765,12 @@ static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) } /* Return the cpu following @cpu, while ignoring unattached processes. */ -static CPUState *gdb_next_attached_cpu(const GDBState *s, CPUState *cpu) +static CPUState *gdb_next_attached_cpu(CPUState *cpu) { cpu = CPU_NEXT(cpu); while (cpu) { - if (gdb_get_cpu_process(s, cpu)->attached) { + if (gdb_get_cpu_process(cpu)->attached) { break; } @@ -780,29 +781,29 @@ static CPUState *gdb_next_attached_cpu(const GDBState *s, CPUState *cpu) } /* Return the first attached cpu */ -static CPUState *gdb_first_attached_cpu(const GDBState *s) +static CPUState *gdb_first_attached_cpu(void) { CPUState *cpu = first_cpu; - GDBProcess *process = gdb_get_cpu_process(s, cpu); + GDBProcess *process = gdb_get_cpu_process(cpu); if (!process->attached) { - return gdb_next_attached_cpu(s, cpu); + return gdb_next_attached_cpu(cpu); } return cpu; } -static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu; if (!pid && !tid) { /* 0 means any process/thread, we take the first attached one */ - return gdb_first_attached_cpu(s); + return gdb_first_attached_cpu(); } else if (pid && !tid) { /* any thread in a specific process */ - process = gdb_get_process(s, pid); + process = gdb_get_process(pid); if (process == NULL) { return NULL; @@ -812,7 +813,7 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) return NULL; } - return get_first_cpu_in_process(s, process); + return get_first_cpu_in_process(process); } else { /* a specific thread */ cpu = find_cpu(tid); @@ -821,7 +822,7 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) return NULL; } - process = gdb_get_cpu_process(s, cpu); + process = gdb_get_cpu_process(cpu); if (pid && process->pid != pid) { return NULL; @@ -835,13 +836,13 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) } } -static const char *get_feature_xml(const GDBState *s, const char *p, - const char **newp, GDBProcess *process) +static const char *get_feature_xml(const char *p, const char **newp, + GDBProcess *process) { size_t len; int i; const char *name; - CPUState *cpu = get_first_cpu_in_process(s, process); + CPUState *cpu = get_first_cpu_in_process(process); CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; @@ -1076,13 +1077,13 @@ static inline void gdb_cpu_breakpoint_remove_all(CPUState *cpu) #endif } -static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProcess *p) +static void gdb_process_breakpoint_remove_all(GDBProcess *p) { - CPUState *cpu = get_first_cpu_in_process(s, p); + CPUState *cpu = get_first_cpu_in_process(p); while (cpu) { gdb_cpu_breakpoint_remove_all(cpu); - cpu = gdb_next_cpu_in_process(s, cpu); + cpu = gdb_next_cpu_in_process(cpu); } } @@ -1100,20 +1101,19 @@ static void gdb_breakpoint_remove_all(void) } } -static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) +static void gdb_set_cpu_pc(target_ulong pc) { - CPUState *cpu = s->c_cpu; + CPUState *cpu = gdbserver_state.c_cpu; cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } -static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, - char *buf, size_t buf_size) +static char *gdb_fmt_thread_id(CPUState *cpu, char *buf, size_t buf_size) { - if (s->multiprocess) { + if (gdbserver_state.multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", - gdb_get_cpu_pid(s, cpu), cpu_gdb_index(cpu)); + gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); } else { snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); } @@ -1180,7 +1180,7 @@ static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is * a format error, 0 on success. */ -static int gdb_handle_vcont(GDBState *s, const char *p) +static int gdb_handle_vcont(const char *p) { int res, signal = 0; char cur_action; @@ -1255,36 +1255,36 @@ static int gdb_handle_vcont(GDBState *s, const char *p) goto out; case GDB_ALL_PROCESSES: - cpu = gdb_first_attached_cpu(s); + cpu = gdb_first_attached_cpu(); while (cpu) { if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } - cpu = gdb_next_attached_cpu(s, cpu); + cpu = gdb_next_attached_cpu(cpu); } break; case GDB_ALL_THREADS: - process = gdb_get_process(s, pid); + process = gdb_get_process(pid); if (!process->attached) { res = -EINVAL; goto out; } - cpu = get_first_cpu_in_process(s, process); + cpu = get_first_cpu_in_process(process); while (cpu) { if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } - cpu = gdb_next_cpu_in_process(s, cpu); + cpu = gdb_next_cpu_in_process(cpu); } break; case GDB_ONE_THREAD: - cpu = gdb_get_cpu(s, pid, tid); + cpu = gdb_get_cpu(pid, tid); /* invalid CPU/thread specified */ if (!cpu) { @@ -1299,8 +1299,8 @@ static int gdb_handle_vcont(GDBState *s, const char *p) break; } } - s->signal = signal; - gdb_continue_partial(s, newstates); + gdbserver_state.signal = signal; + gdb_continue_partial(newstates); out: g_free(newstates); @@ -1409,7 +1409,6 @@ static int cmd_parse_params(const char *data, const char *schema, } typedef struct GdbCmdContext { - GDBState *s; GdbCmdVariant *params; int num_params; uint8_t mem_buf[MAX_PACKET_LENGTH]; @@ -1453,7 +1452,7 @@ static inline int startswith(const char *string, const char *pattern) return !strncmp(string, pattern, strlen(pattern)); } -static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, +static int process_string_cmd(void *user_ctx, const char *data, const GdbCmdParseEntry *cmds, int num_cmds) { int i, schema_len, max_num_params = 0; @@ -1490,7 +1489,6 @@ static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, return -1; } - gdb_ctx.s = s; cmd->handler(&gdb_ctx, user_ctx); return 0; } @@ -1498,8 +1496,7 @@ static int process_string_cmd(GDBState *s, void *user_ctx, const char *data, return -1; } -static void run_cmd_parser(GDBState *s, const char *data, - const GdbCmdParseEntry *cmd) +static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) { if (!data) { return; @@ -1507,44 +1504,43 @@ static void run_cmd_parser(GDBState *s, const char *data, /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ - if (process_string_cmd(s, NULL, data, cmd, 1)) { - put_packet(s, ""); + if (process_string_cmd(NULL, data, cmd, 1)) { + put_packet(""); } } static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) { GDBProcess *process; - GDBState *s = gdb_ctx->s; uint32_t pid = 1; - if (s->multiprocess) { + if (gdbserver_state.multiprocess) { if (!gdb_ctx->num_params) { - put_packet(s, "E22"); + put_packet("E22"); return; } pid = gdb_ctx->params[0].val_ul; } - process = gdb_get_process(s, pid); - gdb_process_breakpoint_remove_all(s, process); + process = gdb_get_process(pid); + gdb_process_breakpoint_remove_all(process); process->attached = false; - if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { - s->c_cpu = gdb_first_attached_cpu(s); + if (pid == gdb_get_cpu_pid(gdbserver_state.c_cpu)) { + gdbserver_state.c_cpu = gdb_first_attached_cpu(); } - if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { - s->g_cpu = gdb_first_attached_cpu(s); + if (pid == gdb_get_cpu_pid(gdbserver_state.g_cpu)) { + gdbserver_state.g_cpu = gdb_first_attached_cpu(); } - if (!s->c_cpu) { + if (!gdbserver_state.c_cpu) { /* No more process attached */ gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + gdb_continue(); } - put_packet(s, "OK"); + put_packet("OK"); } static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1552,33 +1548,33 @@ static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) CPUState *cpu; if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } if (gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } - cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + cpu = gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, gdb_ctx->params[0].thread_id.tid); if (!cpu) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->s, gdb_ctx->params[0].val_ull); + gdb_set_cpu_pc(gdb_ctx->params[0].val_ull); } - gdb_ctx->s->signal = 0; - gdb_continue(gdb_ctx->s); + gdbserver_state.signal = 0; + gdb_continue(); } static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1593,11 +1589,11 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) signal = gdb_ctx->params[0].val_ul; } - gdb_ctx->s->signal = gdb_signal_to_target(signal); - if (gdb_ctx->s->signal == -1) { - gdb_ctx->s->signal = 0; + gdbserver_state.signal = gdb_signal_to_target(signal); + if (gdbserver_state.signal == -1) { + gdbserver_state.signal = 0; } - gdb_continue(gdb_ctx->s); + gdb_continue(); } static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1605,24 +1601,24 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) CPUState *cpu; if (gdb_ctx->num_params != 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } if (gdb_ctx->params[1].thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } if (gdb_ctx->params[1].thread_id.kind != GDB_ONE_THREAD) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } - cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[1].thread_id.pid, + cpu = gdb_get_cpu(gdb_ctx->params[1].thread_id.pid, gdb_ctx->params[1].thread_id.tid); if (!cpu) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } @@ -1632,15 +1628,15 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) */ switch (gdb_ctx->params[0].opcode) { case 'c': - gdb_ctx->s->c_cpu = cpu; - put_packet(gdb_ctx->s, "OK"); + gdbserver_state.c_cpu = cpu; + put_packet("OK"); break; case 'g': - gdb_ctx->s->g_cpu = cpu; - put_packet(gdb_ctx->s, "OK"); + gdbserver_state.g_cpu = cpu; + put_packet("OK"); break; default: - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); break; } } @@ -1650,7 +1646,7 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) int res; if (gdb_ctx->num_params != 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } @@ -1658,14 +1654,14 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_ctx->params[1].val_ull, gdb_ctx->params[2].val_ull); if (res >= 0) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } else if (res == -ENOSYS) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1673,7 +1669,7 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) int res; if (gdb_ctx->num_params != 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } @@ -1681,14 +1677,14 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_ctx->params[1].val_ull, gdb_ctx->params[2].val_ull); if (res >= 0) { - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); return; } else if (res == -ENOSYS) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } /* @@ -1707,20 +1703,20 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) int reg_size; if (!gdb_has_xml) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } if (gdb_ctx->num_params != 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } reg_size = strlen(gdb_ctx->params[1].data) / 2; hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); - gdb_write_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + gdb_write_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, gdb_ctx->params[0].val_ull); - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1728,73 +1724,73 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) int reg_size; if (!gdb_has_xml) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } - reg_size = gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf, + reg_size = gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, gdb_ctx->params[0].val_ull); if (!reg_size) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params != 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } /* hextomem() reads 2*len bytes */ if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, gdb_ctx->params[1].val_ull); - if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_ull, + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].val_ull, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull, true)) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params != 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } /* memtohex() doubles the required space */ if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } - if (target_memory_rw_debug(gdb_ctx->s->g_cpu, gdb_ctx->params[0].val_ull, + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].val_ull, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull, false)) { - put_packet(gdb_ctx->s, "E14"); + put_packet("E14"); return; } memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1807,37 +1803,37 @@ static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - cpu_synchronize_state(gdb_ctx->s->g_cpu); + cpu_synchronize_state(gdbserver_state.g_cpu); registers = gdb_ctx->mem_buf; len = strlen(gdb_ctx->params[0].data) / 2; hextomem(registers, gdb_ctx->params[0].data, len); - for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs && len > 0; + for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; addr++) { - reg_size = gdb_write_register(gdb_ctx->s->g_cpu, registers, addr); + reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, addr); len -= reg_size; registers += reg_size; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) { target_ulong addr, len; - cpu_synchronize_state(gdb_ctx->s->g_cpu); + cpu_synchronize_state(gdbserver_state.g_cpu); len = 0; - for (addr = 0; addr < gdb_ctx->s->g_cpu->gdb_num_g_regs; addr++) { - len += gdb_read_register(gdb_ctx->s->g_cpu, gdb_ctx->mem_buf + len, + for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++) { + len += gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf + len, addr); } memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) { - if (gdb_ctx->num_params >= 1 && gdb_ctx->s->current_syscall_cb) { + if (gdb_ctx->num_params >= 1 && gdbserver_state.current_syscall_cb) { target_ulong ret, err; ret = (target_ulong)gdb_ctx->params[0].val_ull; @@ -1846,31 +1842,31 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) } else { err = 0; } - gdb_ctx->s->current_syscall_cb(gdb_ctx->s->c_cpu, ret, err); - gdb_ctx->s->current_syscall_cb = NULL; + gdbserver_state.current_syscall_cb(gdbserver_state.c_cpu, ret, err); + gdbserver_state.current_syscall_cb = NULL; } if (gdb_ctx->num_params >= 3 && gdb_ctx->params[2].opcode == (uint8_t)'C') { - put_packet(gdb_ctx->s, "T02"); + put_packet("T02"); return; } - gdb_continue(gdb_ctx->s); + gdb_continue(); } static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) { if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->s, (target_ulong)gdb_ctx->params[0].val_ull); + gdb_set_cpu_pc((target_ulong)gdb_ctx->params[0].val_ull); } - cpu_single_step(gdb_ctx->s->c_cpu, sstep_flags); - gdb_continue(gdb_ctx->s); + cpu_single_step(gdbserver_state.c_cpu, sstep_flags); + gdb_continue(); } static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "vCont;c;C;s;S"); + put_packet("vCont;c;C;s;S"); } static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1881,11 +1877,11 @@ static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - res = gdb_handle_vcont(gdb_ctx->s, gdb_ctx->params[0].data); + res = gdb_handle_vcont(gdb_ctx->params[0].data); if ((res == -EINVAL) || (res == -ERANGE)) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); } else if (res) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } @@ -1900,31 +1896,31 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) goto cleanup; } - process = gdb_get_process(gdb_ctx->s, gdb_ctx->params[0].val_ul); + process = gdb_get_process(gdb_ctx->params[0].val_ul); if (!process) { goto cleanup; } - cpu = get_first_cpu_in_process(gdb_ctx->s, process); + cpu = get_first_cpu_in_process(process); if (!cpu) { goto cleanup; } process->attached = true; - gdb_ctx->s->g_cpu = cpu; - gdb_ctx->s->c_cpu = cpu; + gdbserver_state.g_cpu = cpu; + gdbserver_state.c_cpu = cpu; - gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, thread_id); cleanup: - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) { /* Kill the target */ - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); exit(0); } @@ -1961,10 +1957,10 @@ static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } @@ -1973,7 +1969,7 @@ static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user_ctx) snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", SSTEP_ENABLE, SSTEP_NOIRQ, SSTEP_NOTIMER); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1983,13 +1979,13 @@ static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) } sstep_flags = gdb_ctx->params[0].val_ul; - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) { snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_flags); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2003,33 +1999,32 @@ static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) * the first thread of the current process (gdb returns the * first thread). */ - process = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); - cpu = get_first_cpu_in_process(gdb_ctx->s, process); - gdb_fmt_thread_id(gdb_ctx->s, cpu, thread_id, sizeof(thread_id)); + process = gdb_get_cpu_process(gdbserver_state.g_cpu); + cpu = get_first_cpu_in_process(process); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) { char thread_id[16]; - if (!gdb_ctx->s->query_cpu) { - put_packet(gdb_ctx->s, "l"); + if (!gdbserver_state.query_cpu) { + put_packet("l"); return; } - gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->query_cpu, thread_id, + gdb_fmt_thread_id(gdbserver_state.query_cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); - gdb_ctx->s->query_cpu = - gdb_next_attached_cpu(gdb_ctx->s, gdb_ctx->s->query_cpu); + put_packet(gdb_ctx->str_buf); + gdbserver_state.query_cpu = gdb_next_attached_cpu(gdbserver_state.query_cpu); } static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_ctx) { - gdb_ctx->s->query_cpu = gdb_first_attached_cpu(gdb_ctx->s); + gdbserver_state.query_cpu = gdb_first_attached_cpu(); handle_query_threads(gdb_ctx, user_ctx); } @@ -2040,11 +2035,11 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) if (!gdb_ctx->num_params || gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } - cpu = gdb_get_cpu(gdb_ctx->s, gdb_ctx->params[0].thread_id.pid, + cpu = gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, gdb_ctx->params[0].thread_id.tid); if (!cpu) { return; @@ -2052,7 +2047,7 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) cpu_synchronize_state(cpu); - if (gdb_ctx->s->multiprocess && (gdb_ctx->s->process_num > 1)) { + if (gdbserver_state.multiprocess && (gdbserver_state.process_num > 1)) { /* Print the CPU model and name in multiprocess mode */ ObjectClass *oc = object_get_class(OBJECT(cpu)); const char *cpu_model = object_class_get_name(oc); @@ -2069,7 +2064,7 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) } trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } #ifdef CONFIG_USER_ONLY @@ -2077,14 +2072,14 @@ static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) { TaskState *ts; - ts = gdb_ctx->s->c_cpu->opaque; + ts = gdbserver_state.c_cpu->opaque; snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx ";Bss=" TARGET_ABI_FMT_lx, ts->info->code_offset, ts->info->data_offset, ts->info->data_offset); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2092,21 +2087,21 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) int len; if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } len = strlen(gdb_ctx->params[0].data); if (len % 2) { - put_packet(gdb_ctx->s, "E01"); + put_packet("E01"); return; } len = len / 2; hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); gdb_ctx->mem_buf[len++] = 0; - qemu_chr_be_write(gdb_ctx->s->mon_chr, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->s, "OK"); + qemu_chr_be_write(gdbserver_state.mon_chr, gdb_ctx->mem_buf, len); + put_packet("OK"); } #endif @@ -2125,11 +2120,11 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) if (gdb_ctx->num_params && strstr(gdb_ctx->params[0].data, "multiprocess+")) { - gdb_ctx->s->multiprocess = true; + gdbserver_state.multiprocess = true; } pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2141,22 +2136,22 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) const char *p; if (gdb_ctx->num_params < 3) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } - process = gdb_get_cpu_process(gdb_ctx->s, gdb_ctx->s->g_cpu); - cc = CPU_GET_CLASS(gdb_ctx->s->g_cpu); + process = gdb_get_cpu_process(gdbserver_state.g_cpu); + cc = CPU_GET_CLASS(gdbserver_state.g_cpu); if (!cc->gdb_core_xml_file) { - put_packet(gdb_ctx->s, ""); + put_packet(""); return; } gdb_has_xml = true; p = gdb_ctx->params[0].data; - xml = get_feature_xml(gdb_ctx->s, p, &p, process); + xml = get_feature_xml(p, &p, process); if (!xml) { - put_packet(gdb_ctx->s, "E00"); + put_packet("E00"); return; } @@ -2164,7 +2159,7 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) len = gdb_ctx->params[2].val_ul; total_len = strlen(xml); if (addr > total_len) { - put_packet(gdb_ctx->s, "E00"); + put_packet("E00"); return; } @@ -2180,12 +2175,12 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) len = memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); } - put_packet_binary(gdb_ctx->s, gdb_ctx->str_buf, len + 1, true); + put_packet_binary(gdb_ctx->str_buf, len + 1, true); } static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, GDB_ATTACHED); + put_packet(GDB_ATTACHED); } static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2194,7 +2189,7 @@ static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) #ifndef CONFIG_USER_ONLY pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); #endif - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } #ifndef CONFIG_USER_ONLY @@ -2202,13 +2197,13 @@ static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) { snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_mode); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); } static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) { if (!gdb_ctx->num_params) { - put_packet(gdb_ctx->s, "E22"); + put_packet("E22"); return; } @@ -2217,7 +2212,7 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) } else { phy_memory_mode = 1; } - put_packet(gdb_ctx->s, "OK"); + put_packet("OK"); } #endif @@ -2333,16 +2328,16 @@ static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } @@ -2352,16 +2347,16 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - if (!process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, gdb_ctx->params[0].data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { - put_packet(gdb_ctx->s, ""); + put_packet(""); } } @@ -2369,11 +2364,11 @@ static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) { char thread_id[16]; - gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id, + gdb_fmt_thread_id(gdbserver_state.c_cpu, thread_id, sizeof(thread_id)); snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, thread_id); - put_packet(gdb_ctx->s, gdb_ctx->str_buf); + put_packet(gdb_ctx->str_buf); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2382,7 +2377,7 @@ static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_breakpoint_remove_all(); } -static int gdb_handle_packet(GDBState *s, const char *line_buf) +static int gdb_handle_packet(const char *line_buf) { const GdbCmdParseEntry *cmd_parser = NULL; @@ -2390,7 +2385,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) switch (line_buf[0]) { case '!': - put_packet(s, "OK"); + put_packet("OK"); break; case '?': { @@ -2605,12 +2600,12 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; default: /* put empty packet */ - put_packet(s, ""); + put_packet(""); break; } if (cmd_parser) { - run_cmd_parser(s, line_buf, cmd_parser); + run_cmd_parser(line_buf, cmd_parser); } return RS_IDLE; @@ -2618,7 +2613,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) void gdb_set_stop_cpu(CPUState *cpu) { - GDBProcess *p = gdb_get_cpu_process(&gdbserver_state, cpu); + GDBProcess *p = gdb_get_cpu_process(cpu); if (!p->attached) { /* @@ -2635,19 +2630,18 @@ void gdb_set_stop_cpu(CPUState *cpu) #ifndef CONFIG_USER_ONLY static void gdb_vm_state_change(void *opaque, int running, RunState state) { - GDBState *s = &gdbserver_state; - CPUState *cpu = s->c_cpu; + CPUState *cpu = gdbserver_state.c_cpu; char buf[256]; char thread_id[16]; const char *type; int ret; - if (running || s->state == RS_INACTIVE) { + if (running || gdbserver_state.state == RS_INACTIVE) { return; } /* Is there a GDB syscall waiting to be sent? */ - if (s->current_syscall_cb) { - put_packet(s, s->syscall_buf); + if (gdbserver_state.current_syscall_cb) { + put_packet(gdbserver_state.syscall_buf); return; } @@ -2656,7 +2650,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) return; } - gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); switch (state) { case RUN_STATE_DEBUG: @@ -2721,7 +2715,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); send_packet: - put_packet(s, buf); + put_packet(buf); /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -2740,8 +2734,9 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) target_ulong addr; uint64_t i64; - if (!gdbserver_state.init) + if (!gdbserver_state.init) { return; + } gdbserver_state.current_syscall_cb = cb; #ifndef CONFIG_USER_ONLY @@ -2781,7 +2776,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } *p = 0; #ifdef CONFIG_USER_ONLY - put_packet(&gdbserver_state, gdbserver_state.syscall_buf); + put_packet(gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check @@ -2809,17 +2804,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) va_end(va); } -static void gdb_read_byte(GDBState *s, uint8_t ch) +static void gdb_read_byte(uint8_t ch) { uint8_t reply; #ifndef CONFIG_USER_ONLY - if (s->last_packet_len) { + if (gdbserver_state.last_packet_len) { /* Waiting for a response to the last packet. If we see the start of a new command then abandon the previous response. */ if (ch == '-') { trace_gdbstub_err_got_nack(); - put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); + put_buffer((uint8_t *)gdbserver_state.last_packet, gdbserver_state.last_packet_len); } else if (ch == '+') { trace_gdbstub_io_got_ack(); } else { @@ -2827,7 +2822,7 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) } if (ch == '+' || ch == '$') - s->last_packet_len = 0; + gdbserver_state.last_packet_len = 0; if (ch != '$') return; } @@ -2838,13 +2833,13 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) } else #endif { - switch(s->state) { + switch(gdbserver_state.state) { case RS_IDLE: if (ch == '$') { /* start of command packet */ - s->line_buf_index = 0; - s->line_sum = 0; - s->state = RS_GETLINE; + gdbserver_state.line_buf_index = 0; + gdbserver_state.line_sum = 0; + gdbserver_state.state = RS_GETLINE; } else { trace_gdbstub_err_garbage(ch); } @@ -2852,37 +2847,37 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) case RS_GETLINE: if (ch == '}') { /* start escape sequence */ - s->state = RS_GETLINE_ESC; - s->line_sum += ch; + gdbserver_state.state = RS_GETLINE_ESC; + gdbserver_state.line_sum += ch; } else if (ch == '*') { /* start run length encoding sequence */ - s->state = RS_GETLINE_RLE; - s->line_sum += ch; + gdbserver_state.state = RS_GETLINE_RLE; + gdbserver_state.line_sum += ch; } else if (ch == '#') { /* end of command, start of checksum*/ - s->state = RS_CHKSUM1; - } else if (s->line_buf_index >= sizeof(s->line_buf) - 1) { + gdbserver_state.state = RS_CHKSUM1; + } else if (gdbserver_state.line_buf_index >= sizeof(gdbserver_state.line_buf) - 1) { trace_gdbstub_err_overrun(); - s->state = RS_IDLE; + gdbserver_state.state = RS_IDLE; } else { /* unescaped command character */ - s->line_buf[s->line_buf_index++] = ch; - s->line_sum += ch; + gdbserver_state.line_buf[gdbserver_state.line_buf_index++] = ch; + gdbserver_state.line_sum += ch; } break; case RS_GETLINE_ESC: if (ch == '#') { /* unexpected end of command in escape sequence */ - s->state = RS_CHKSUM1; - } else if (s->line_buf_index >= sizeof(s->line_buf) - 1) { + gdbserver_state.state = RS_CHKSUM1; + } else if (gdbserver_state.line_buf_index >= sizeof(gdbserver_state.line_buf) - 1) { /* command buffer overrun */ trace_gdbstub_err_overrun(); - s->state = RS_IDLE; + gdbserver_state.state = RS_IDLE; } else { /* parse escaped character and leave escape state */ - s->line_buf[s->line_buf_index++] = ch ^ 0x20; - s->line_sum += ch; - s->state = RS_GETLINE; + gdbserver_state.line_buf[gdbserver_state.line_buf_index++] = ch ^ 0x20; + gdbserver_state.line_sum += ch; + gdbserver_state.state = RS_GETLINE; } break; case RS_GETLINE_RLE: @@ -2893,25 +2888,25 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) if (ch < ' ' || ch == '#' || ch == '$' || ch > 126) { /* invalid RLE count encoding */ trace_gdbstub_err_invalid_repeat(ch); - s->state = RS_GETLINE; + gdbserver_state.state = RS_GETLINE; } else { /* decode repeat length */ int repeat = ch - ' ' + 3; - if (s->line_buf_index + repeat >= sizeof(s->line_buf) - 1) { + if (gdbserver_state.line_buf_index + repeat >= sizeof(gdbserver_state.line_buf) - 1) { /* that many repeats would overrun the command buffer */ trace_gdbstub_err_overrun(); - s->state = RS_IDLE; - } else if (s->line_buf_index < 1) { + gdbserver_state.state = RS_IDLE; + } else if (gdbserver_state.line_buf_index < 1) { /* got a repeat but we have nothing to repeat */ trace_gdbstub_err_invalid_rle(); - s->state = RS_GETLINE; + gdbserver_state.state = RS_GETLINE; } else { /* repeat the last character */ - memset(s->line_buf + s->line_buf_index, - s->line_buf[s->line_buf_index - 1], repeat); - s->line_buf_index += repeat; - s->line_sum += ch; - s->state = RS_GETLINE; + memset(gdbserver_state.line_buf + gdbserver_state.line_buf_index, + gdbserver_state.line_buf[gdbserver_state.line_buf_index - 1], repeat); + gdbserver_state.line_buf_index += repeat; + gdbserver_state.line_sum += ch; + gdbserver_state.state = RS_GETLINE; } } break; @@ -2919,33 +2914,33 @@ static void gdb_read_byte(GDBState *s, uint8_t ch) /* get high hex digit of checksum */ if (!isxdigit(ch)) { trace_gdbstub_err_checksum_invalid(ch); - s->state = RS_GETLINE; + gdbserver_state.state = RS_GETLINE; break; } - s->line_buf[s->line_buf_index] = '\0'; - s->line_csum = fromhex(ch) << 4; - s->state = RS_CHKSUM2; + gdbserver_state.line_buf[gdbserver_state.line_buf_index] = '\0'; + gdbserver_state.line_csum = fromhex(ch) << 4; + gdbserver_state.state = RS_CHKSUM2; break; case RS_CHKSUM2: /* get low hex digit of checksum */ if (!isxdigit(ch)) { trace_gdbstub_err_checksum_invalid(ch); - s->state = RS_GETLINE; + gdbserver_state.state = RS_GETLINE; break; } - s->line_csum |= fromhex(ch); + gdbserver_state.line_csum |= fromhex(ch); - if (s->line_csum != (s->line_sum & 0xff)) { - trace_gdbstub_err_checksum_incorrect(s->line_sum, s->line_csum); + if (gdbserver_state.line_csum != (gdbserver_state.line_sum & 0xff)) { + trace_gdbstub_err_checksum_incorrect(gdbserver_state.line_sum, gdbserver_state.line_csum); /* send NAK reply */ reply = '-'; - put_buffer(s, &reply, 1); - s->state = RS_IDLE; + put_buffer(&reply, 1); + gdbserver_state.state = RS_IDLE; } else { /* send ACK reply */ reply = '+'; - put_buffer(s, &reply, 1); - s->state = gdb_handle_packet(s, s->line_buf); + put_buffer(&reply, 1); + gdbserver_state.state = gdb_handle_packet(gdbserver_state.line_buf); } break; default: @@ -2971,7 +2966,7 @@ void gdb_exit(CPUArchState *env, int code) trace_gdbstub_op_exiting((uint8_t)code); snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(&gdbserver_state, buf); + put_packet(buf); #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&gdbserver_state.chr, true); @@ -2988,7 +2983,7 @@ static void create_default_process(GDBState *s) GDBProcess *process; int max_pid = 0; - if (s->process_num) { + if (gdbserver_state.process_num) { max_pid = s->processes[s->process_num - 1].pid; } @@ -3020,7 +3015,7 @@ gdb_handlesig(CPUState *cpu, int sig) if (sig != 0) { snprintf(buf, sizeof(buf), "S%02x", target_signal_to_gdb(sig)); - put_packet(&gdbserver_state, buf); + put_packet(buf); } /* put_packet() might have detected that the peer terminated the connection. */ @@ -3037,7 +3032,7 @@ gdb_handlesig(CPUState *cpu, int sig) int i; for (i = 0; i < n; i++) { - gdb_read_byte(&gdbserver_state, buf[i]); + gdb_read_byte(buf[i]); } } else { /* XXX: Connection closed. Should probably wait for another @@ -3064,7 +3059,7 @@ void gdb_signalled(CPUArchState *env, int sig) } snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(&gdbserver_state, buf); + put_packet(buf); } static bool gdb_accept(void) @@ -3095,7 +3090,7 @@ static bool gdb_accept(void) init_gdbserver_state(); create_default_process(&gdbserver_state); gdbserver_state.processes[0].attached = true; - gdbserver_state.c_cpu = gdb_first_attached_cpu(&gdbserver_state); + gdbserver_state.c_cpu = gdb_first_attached_cpu(); gdbserver_state.g_cpu = gdbserver_state.c_cpu; gdbserver_state.fd = fd; gdb_has_xml = false; @@ -3172,7 +3167,7 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) int i; for (i = 0; i < size; i++) { - gdb_read_byte(&gdbserver_state, buf[i]); + gdb_read_byte(buf[i]); } } @@ -3188,7 +3183,7 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) s->processes[i].attached = !i; } - s->c_cpu = gdb_first_attached_cpu(s); + s->c_cpu = gdb_first_attached_cpu(); s->g_cpu = s->c_cpu; vm_stop(RUN_STATE_PAUSED); @@ -3199,7 +3194,7 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) } } -static void gdb_monitor_output(GDBState *s, const char *msg, int len) +static void gdb_monitor_output(const char *msg, int len) { char buf[MAX_PACKET_LENGTH]; @@ -3207,7 +3202,7 @@ static void gdb_monitor_output(GDBState *s, const char *msg, int len) if (len > (MAX_PACKET_LENGTH/2) - 1) len = (MAX_PACKET_LENGTH/2) - 1; memtohex(buf + 1, (uint8_t *)msg, len); - put_packet(s, buf); + put_packet(buf); } static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) @@ -3218,10 +3213,10 @@ static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) max_sz = (sizeof(gdbserver_state.last_packet) - 2) / 2; for (;;) { if (len <= max_sz) { - gdb_monitor_output(&gdbserver_state, p, len); + gdb_monitor_output(p, len); break; } - gdb_monitor_output(&gdbserver_state, p, max_sz); + gdb_monitor_output(p, max_sz); p += max_sz; len -= max_sz; } @@ -3305,9 +3300,9 @@ static void create_processes(GDBState *s) { object_child_foreach(object_get_root(), find_cpu_clusters, s); - if (s->processes) { + if (gdbserver_state.processes) { /* Sort by PID */ - qsort(s->processes, s->process_num, sizeof(s->processes[0]), pid_order); + qsort(gdbserver_state.processes, gdbserver_state.process_num, sizeof(gdbserver_state.processes[0]), pid_order); } create_default_process(s); @@ -3387,7 +3382,7 @@ int gdbserver_start(const char *device) void gdbserver_cleanup(void) { if (gdbserver_state.init) { - put_packet(&gdbserver_state, "W00"); + put_packet("W00"); } } From patchwork Tue Mar 17 17:50:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184645 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4435353ile; Tue, 17 Mar 2020 10:55:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vutL5S546vtZc8IHFJDd1zk5e3uuVCUB1Szz6bgvXXgG+hq3XlpSo2JQAjGdNOfqJFAcIJz X-Received: by 2002:a05:620a:1192:: with SMTP id b18mr56875qkk.334.1584467754199; Tue, 17 Mar 2020 10:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467754; cv=none; d=google.com; s=arc-20160816; b=cl+Fs5lpfdF7+YTTLkUw8rZZ2HA5sGV3K/9y3duUJj3Vaf9vEgAssuppZJn6RhYg2W L8WZcw1hDnfHqdgebq7fwVsPc3mfsDDCBJ8cn2VGlB4BJRt5EbdkIQo545WN4sXauLNY fbpA+25hreWX0619/ny4w+GHWniv/xlUy6f5rlcoqFRjQTB+tIxE90xtZuqY82TzXlLC c9rK6vWxJZGOAkfy4Umj8gdDR5s2SlOaXLI7oYkcBBBE71A0T1QR5iHAD4dzE0joycfy r+iF1LX1glMt5PGu3MwXXy7Abb0Iwf02fpcd0SNAB2qfJaqXxpFmgdDF/oI4nkw0HETb TjRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=kJ80yWt+yX6uNF4YuBgLbzkEVRAb2pW2kmt01goti6s=; b=cCt/lcM8/NjFizp0AymopKm5QCpj/4/HQpVMgRAlCyhlLYhFkkU8T9z+rD2Hy8E30v rZfmDRG2uOpkBbf4eOIC1vWSyuLRNgnDUQLtnT0OCT6MUvrhDyT4OPAdzmt6zeEMZgN4 juBYoXhAcjddGWUZnCMRu6CyzKoQ+/HZjB9b6PnffElI959gCXzoHWandgfOAx9QoGPk I/EDvqBnW0/vKtDalFbRlM2EyP70afFpWmNbxzGoCTOpztUb2FKZ4ApBOCvdvdjiWB/O jUf0SbOVZPLZ0lm0pfM1uaB0y2MAWZ3l8ULpHqe2V6InnRMPRYGPtxDwucZaq4xENcAO VT6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Goy0LoVw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d20si2563775qte.78.2020.03.17.10.55.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:55:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Goy0LoVw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGRV-0000CU-CR for patch@linaro.org; Tue, 17 Mar 2020 13:55:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56991) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMw-0000MF-3u for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMt-0002P4-J4 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:10 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:34162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMs-0002DD-9L for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:07 -0400 Received: by mail-wm1-x342.google.com with SMTP id x3so438553wmj.1 for ; Tue, 17 Mar 2020 10:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kJ80yWt+yX6uNF4YuBgLbzkEVRAb2pW2kmt01goti6s=; b=Goy0LoVwW7j4c5f5/eV3rLkXeJptLrisdPHwHIZNYzzckvu4ujh7CURx2sb3sW8pby oP51/KoCgCEqCRn8TwUlT8jIXUxMtfCik90/hvqb1WuQaunSn4pebBqV9zjmz5gs2AnC HlcfgJYe8dzgq0CJHXpHZrkzw5fqSl/idL8HbGul2nHUEVIk+TfvhhqN/BsZ9kywbkRT 4AOTi1GM2TxSR6YwsyH3Jrmp5Qx/rSl+q6MEFoc0tpKVPsThCUGdTTuuSjc9tVAjWJA7 cEhE0kiSfXT2iaOpvMgoiGtOl3RGykAEHfBCQdzlbCB/ZF0YQnlB5Jujjzssnr+gaC5O cvew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kJ80yWt+yX6uNF4YuBgLbzkEVRAb2pW2kmt01goti6s=; b=M6WjYFx9a7xU0akyJj+4BWvuwJzWh7WGH6MQXVkHIXkSTDEiVnShZnl7NkYAlJOHnc 8hnh6eqsc1T1bPn3RywtHxKeLBq1FkrG9x/C10uAvrLf9FwlvL+mCEdDy+oAY+OTqxDC wSG2X4hHj1JlWY6xikjEuE3TJUPMidkgygeF1yvGNz7vx2K8QOMEQPeTSpJc2/wR+TtA 3A74KcInvruKtX3/br1hgD/iAnubM78Mu3ZccqTDjFMgk+S3835FmceNjKNAnJJwPj/A ZEW8rsylmlxHYzxqyN3IJuZ5SLEuE/Q1UOCmtjRtjaFqfOs1MHjyFP3ifDTBvFclUrLT Nkbw== X-Gm-Message-State: ANhLgQ3GX4AWuaroC7YffAlChttTDSfn8XCgJj4X4+5ZZiAVhZ75zG4U JHcFrS/XoUtGhPTjRiGvHXnjzg== X-Received: by 2002:a05:600c:21d2:: with SMTP id x18mr164738wmj.75.1584467465028; Tue, 17 Mar 2020 10:51:05 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s7sm5341270wri.61.2020.03.17.10.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 058551FF96; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 08/28] gdbstub: move str_buf to GDBState and use GString Date: Tue, 17 Mar 2020 17:50:33 +0000 Message-Id: <20200317175053.5278-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than having a static buffer replace str_buf with a GString which we know can grow on demand. Convert the internal functions to take a GString instead of a char * and length. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Tested-by: Damien Hedde Message-Id: <20200316172155.971-9-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 7243a2f7af9..f6b42825445 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -366,6 +366,7 @@ typedef struct GDBState { int process_num; char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; + GString *str_buf; } GDBState; /* By default use no IRQs and no timers while single stepping so as to @@ -380,6 +381,7 @@ static void init_gdbserver_state(void) g_assert(!gdbserver_state.init); memset(&gdbserver_state, 0, sizeof(GDBState)); gdbserver_state.init = true; + gdbserver_state.str_buf = g_string_new(NULL); } #ifndef CONFIG_USER_ONLY @@ -563,17 +565,15 @@ static inline int tohex(int v) } /* writes 2*len+1 bytes in buf */ -static void memtohex(char *buf, const uint8_t *mem, int len) +static void memtohex(GString *buf, const uint8_t *mem, int len) { int i, c; - char *q; - q = buf; for(i = 0; i < len; i++) { c = mem[i]; - *q++ = tohex(c >> 4); - *q++ = tohex(c & 0xf); + g_string_append_c(buf, tohex(c >> 4)); + g_string_append_c(buf, tohex(c & 0xf)); } - *q = '\0'; + g_string_append_c(buf, '\0'); } static void hextomem(uint8_t *mem, const char *buf, int len) @@ -667,25 +667,28 @@ static int put_packet(const char *buf) return put_packet_binary(buf, strlen(buf), false); } +static void put_strbuf(void) +{ + put_packet(gdbserver_state.str_buf->str); +} + /* Encode data using the encoding for 'x' packets. */ -static int memtox(char *buf, const char *mem, int len) +static void memtox(GString *buf, const char *mem, int len) { - char *p = buf; char c; while (len--) { c = *(mem++); switch (c) { case '#': case '$': case '*': case '}': - *(p++) = '}'; - *(p++) = c ^ 0x20; + g_string_append_c(buf, '}'); + g_string_append_c(buf, c ^ 0x20); break; default: - *(p++) = c; + g_string_append_c(buf, c); break; } } - return p - buf; } static uint32_t gdb_get_cpu_pid(CPUState *cpu) @@ -1109,16 +1112,14 @@ static void gdb_set_cpu_pc(target_ulong pc) cpu_set_pc(cpu, pc); } -static char *gdb_fmt_thread_id(CPUState *cpu, char *buf, size_t buf_size) +static void gdb_append_thread_id(CPUState *cpu, GString *buf) { if (gdbserver_state.multiprocess) { - snprintf(buf, buf_size, "p%02x.%02x", - gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); + g_string_append_printf(buf, "p%02x.%02x", + gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); } else { - snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); + g_string_append_printf(buf, "%02x", cpu_gdb_index(cpu)); } - - return buf; } typedef enum GDBThreadIdKind { @@ -1412,7 +1413,6 @@ typedef struct GdbCmdContext { GdbCmdVariant *params; int num_params; uint8_t mem_buf[MAX_PACKET_LENGTH]; - char str_buf[MAX_PACKET_LENGTH + 1]; } GdbCmdContext; typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); @@ -1502,6 +1502,8 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) return; } + g_string_set_size(gdbserver_state.str_buf, 0); + /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ if (process_string_cmd(NULL, data, cmd, 1)) { @@ -1740,8 +1742,8 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, reg_size); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, reg_size); + put_strbuf(); } static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1789,8 +1791,8 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull); + put_strbuf(); } static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1827,8 +1829,8 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) addr); } - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->str_buf); + memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, len); + put_strbuf(); } static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1889,9 +1891,8 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) { GDBProcess *process; CPUState *cpu; - char thread_id[16]; - pstrcpy(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "E22"); + g_string_assign(gdbserver_state.str_buf, "E22"); if (!gdb_ctx->num_params) { goto cleanup; } @@ -1910,11 +1911,11 @@ static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.g_cpu = cpu; gdbserver_state.c_cpu = cpu; - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", - GDB_SIGNAL_TRAP, thread_id); + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); cleanup: - put_packet(gdb_ctx->str_buf); + put_strbuf(); } static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1966,10 +1967,9 @@ static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", SSTEP_ENABLE, - SSTEP_NOIRQ, SSTEP_NOTIMER); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", + SSTEP_ENABLE, SSTEP_NOIRQ, SSTEP_NOTIMER); + put_strbuf(); } static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -1984,15 +1984,14 @@ static void handle_set_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "0x%x", sstep_flags); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "0x%x", sstep_flags); + put_strbuf(); } static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) { CPUState *cpu; GDBProcess *process; - char thread_id[16]; /* * "Current thread" remains vague in the spec, so always return @@ -2001,24 +2000,21 @@ static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) */ process = gdb_get_cpu_process(gdbserver_state.g_cpu); cpu = get_first_cpu_in_process(process); - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "QC%s", thread_id); - put_packet(gdb_ctx->str_buf); + g_string_assign(gdbserver_state.str_buf, "QC"); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + put_strbuf(); } static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) { - char thread_id[16]; - if (!gdbserver_state.query_cpu) { put_packet("l"); return; } - gdb_fmt_thread_id(gdbserver_state.query_cpu, thread_id, - sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "m%s", thread_id); - put_packet(gdb_ctx->str_buf); + g_string_assign(gdbserver_state.str_buf, "m"); + gdb_append_thread_id(gdbserver_state.query_cpu, gdbserver_state.str_buf); + put_strbuf(); gdbserver_state.query_cpu = gdb_next_attached_cpu(gdbserver_state.query_cpu); } @@ -2030,8 +2026,8 @@ static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) { + g_autoptr(GString) rs = g_string_new(NULL); CPUState *cpu; - int len; if (!gdb_ctx->num_params || gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { @@ -2051,20 +2047,17 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) /* Print the CPU model and name in multiprocess mode */ ObjectClass *oc = object_get_class(OBJECT(cpu)); const char *cpu_model = object_class_get_name(oc); - char *cpu_name = object_get_canonical_path_component(OBJECT(cpu)); - len = snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf) / 2, - "%s %s [%s]", cpu_model, cpu_name, - cpu->halted ? "halted " : "running"); - g_free(cpu_name); + g_autofree char *cpu_name; + cpu_name = object_get_canonical_path_component(OBJECT(cpu)); + g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name, + cpu->halted ? "halted " : "running"); } else { - /* memtohex() doubles the required space */ - len = snprintf((char *)gdb_ctx->mem_buf, sizeof(gdb_ctx->str_buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, + g_string_printf(rs, "CPU#%d [%s]", cpu->cpu_index, cpu->halted ? "halted " : "running"); } - trace_gdbstub_op_extra_info((char *)gdb_ctx->mem_buf); - memtohex(gdb_ctx->str_buf, gdb_ctx->mem_buf, len); - put_packet(gdb_ctx->str_buf); + trace_gdbstub_op_extra_info(rs->str); + memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); + put_strbuf(); } #ifdef CONFIG_USER_ONLY @@ -2073,13 +2066,14 @@ static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) TaskState *ts; ts = gdbserver_state.c_cpu->opaque; - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx - ";Bss=" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, + "Text=" TARGET_ABI_FMT_lx + ";Data=" TARGET_ABI_FMT_lx + ";Bss=" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + put_strbuf(); } #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2110,12 +2104,10 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { CPUClass *cc; - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "PacketSize=%x", - MAX_PACKET_LENGTH); + g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH); cc = CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file) { - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), - ";qXfer:features:read+"); + g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } if (gdb_ctx->num_params && @@ -2123,8 +2115,8 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.multiprocess = true; } - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); - put_packet(gdb_ctx->str_buf); + g_string_append(gdbserver_state.str_buf, ";multiprocess+"); + put_strbuf(); } static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2168,14 +2160,15 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) } if (len < total_len - addr) { - gdb_ctx->str_buf[0] = 'm'; - len = memtox(gdb_ctx->str_buf + 1, xml + addr, len); + g_string_assign(gdbserver_state.str_buf, "m"); + memtox(gdbserver_state.str_buf, xml + addr, len); } else { - gdb_ctx->str_buf[0] = 'l'; - len = memtox(gdb_ctx->str_buf + 1, xml + addr, total_len - addr); + g_string_assign(gdbserver_state.str_buf, "l"); + memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); } - put_packet_binary(gdb_ctx->str_buf, len + 1, true); + put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); } static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2185,19 +2178,19 @@ static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "sstepbits;sstep"); + g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); #ifndef CONFIG_USER_ONLY - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";PhyMemMode"); + g_string_append(gdbserver_state.str_buf, ";PhyMemMode"); #endif - put_packet(gdb_ctx->str_buf); + put_strbuf(); } #ifndef CONFIG_USER_ONLY static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) { - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_mode); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); + put_strbuf(); } static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2362,13 +2355,10 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) { - char thread_id[16]; - - gdb_fmt_thread_id(gdbserver_state.c_cpu, thread_id, - sizeof(thread_id)); - snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", - GDB_SIGNAL_TRAP, thread_id); - put_packet(gdb_ctx->str_buf); + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); + gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + put_strbuf(); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2631,8 +2621,8 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { CPUState *cpu = gdbserver_state.c_cpu; - char buf[256]; - char thread_id[16]; + g_autoptr(GString) buf = g_string_new(NULL); + g_autoptr(GString) tid = g_string_new(NULL); const char *type; int ret; @@ -2650,7 +2640,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) return; } - gdb_fmt_thread_id(cpu, thread_id, sizeof(thread_id)); + gdb_append_thread_id(cpu, tid); switch (state) { case RUN_STATE_DEBUG: @@ -2668,10 +2658,9 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) } trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); - snprintf(buf, sizeof(buf), - "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, thread_id, type, - (target_ulong)cpu->watchpoint_hit->vaddr); + g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", + GDB_SIGNAL_TRAP, tid->str, type, + (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit = NULL; goto send_packet; } else { @@ -2712,10 +2701,10 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); + g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); send_packet: - put_packet(buf); + put_packet(buf->str); /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -3196,13 +3185,9 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) static void gdb_monitor_output(const char *msg, int len) { - char buf[MAX_PACKET_LENGTH]; - - buf[0] = 'O'; - if (len > (MAX_PACKET_LENGTH/2) - 1) - len = (MAX_PACKET_LENGTH/2) - 1; - memtohex(buf + 1, (uint8_t *)msg, len); - put_packet(buf); + g_autoptr(GString) buf = g_string_new("O"); + memtohex(buf, (uint8_t *)msg, len); + put_packet(buf->str); } static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) From patchwork Tue Mar 17 17:50:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184652 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4439014ile; Tue, 17 Mar 2020 11:00:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuEHZ7hsjSYvN0Liy5uVbjOO4sJGrcMUFWLZBXWtLo1v1lazqSQOZ7jAy+MxzT74MCBw+kq X-Received: by 2002:ac8:4cce:: with SMTP id l14mr320199qtv.383.1584468001090; Tue, 17 Mar 2020 11:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468001; cv=none; d=google.com; s=arc-20160816; b=JL+8i3fI8R5K60Z+XRSuXaSPEhC5xSnXbzcGv5TT+0tXUm1Ljx8VppsMKGFIElDTsa 7OJaM3W0BYW2KhHHyQj+hSMmFYwwGbpniQrhi2ww3lz2AJ+swlfdlhpPCcqn79feiraS JtVI3Eazjlvw0+i07i1acLaJp4b2pGI6O8v+TzscQNbWxcNcv0KcW2VYIrQ26lTtF5i2 DrYCGpeY6kgpL3TaFeUsz5IoE9IpUJR4nBIlHTRzmBGKxoalbItSbtZ4wGJCiRlcWBYt 7vmyEGwhW8gnh+xp5yPIrfNhsmuC+GkrGR0qeJF/kZiVkQV+TZcX3famhZbJJIS+2ojZ Z2QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WBHtCO5gmgzNG/otPgmM1/RdLWG0Gh9mdBCHeedK/+s=; b=rPNTIhWsy6L/80AdiE1HZDZC3gsAM8ucXxSmvANz7XIHoaDXVm12qm3D8XhGVVtVfr iSxrz0g4F0d4PGTQmfiqaICygSIUXgqo80Qx4wKMTuhm8NvXIQUwdjd8ass1hSjwyeqO Ejz4e33pReedfWm9uT88eMFOgnPzg1CvFQDFqIvjoqWksuiBw9EirRoHivbkBBjRIeR/ 1eR4wzAw0naw/608bQxhB1QOXjuCrcPZFqRMlJNX3zEfyENKKQqnxF4LhHPT+zp3a93w DS3kHhsN2SQB8Pdy7SK5YKc/YYOxlLgOSMvPXo0W+sUxzjrWW2rnkaP1z42vDzZRxhBD ja0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RDSXFQWk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o10si2578400qko.205.2020.03.17.11.00.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RDSXFQWk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGVU-00070w-EL for patch@linaro.org; Tue, 17 Mar 2020 14:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57019) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMx-0000Px-D0 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMv-0002aG-QJ for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:11 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMv-0002TH-JB for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:09 -0400 Received: by mail-wr1-x443.google.com with SMTP id y2so11393487wrn.11 for ; Tue, 17 Mar 2020 10:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WBHtCO5gmgzNG/otPgmM1/RdLWG0Gh9mdBCHeedK/+s=; b=RDSXFQWk81CtYA/xCXW18I4OAPMA4zkimNPiqPXSmKxmKiMjOKm+sRvklByb8YZjI1 P77CGpvuqOG3JL0WHwqZjTkhfbEAAOHBBPyKELpR+5gM5c2BoNe7kzrfO6REVwq0DuxL Oa53UQxtmvwyFo+1B4j4bp4MDibnvtYrRzSbR6v2RPc5pO9JOe0kW4U5Ub0eo0gRoers dFfzD/CCv7qGafyg/Y7YrOhQVM4VGiJgQ11V1785HKbQqvjf85MVMTKzyo/f/2xFFLos c7XyJ8LGUe7M1E176SQupS/Ee/1gU+HU9OlAk+5MnBU1wTL/Y7eHBcX7OD5XbH3vi7hg EIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WBHtCO5gmgzNG/otPgmM1/RdLWG0Gh9mdBCHeedK/+s=; b=tjUAs2OmcZKkPNf5W5CGWS1qIggPas3EcsBaRZciDxfVMQnouEElg5nHcJ9nXwqX4A d751EeZBgsh98NoyegUyZl0gMB9RkqB/eTJQXKV2CQVNH13g3N1E2BBr4WlISXedtnM6 T1a9yhmKNut4B5dyctalfq47cJpxsz1hd+r2pGcTLKTnj7NdoRI6g+TL5gSm2MQBz4tp WiMTha6dlKDci9ENoyzCryqoL4XwByoXfSR0I5IwXM3ANOAqZoMNDdY+z5k6oo/3TFRt GyEIP59xdyaor6Bl5r1cA/tmFcdUprOH01qsIyImiCVYIwQkCMVVC9KQgLxG1jrruUuv P65Q== X-Gm-Message-State: ANhLgQ2IOein+4bUvqiqW7DdBTUXCbPwA0PgHRkhB4GO3WJV3joxKPrt PlbCe5AXxika6GrXzIECoC9vKA== X-Received: by 2002:adf:f503:: with SMTP id q3mr150031wro.135.1584467468439; Tue, 17 Mar 2020 10:51:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x17sm2183968wrt.0.2020.03.17.10.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B5731FF98; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 09/28] gdbstub: move mem_buf to GDBState and use GByteArray Date: Tue, 17 Mar 2020 17:50:34 +0000 Message-Id: <20200317175053.5278-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation for further re-factoring of the register API with the rest of the code. Theoretically the read register function could overwrite the MAX_PACKET_LENGTH buffer although currently all registers are well within the size range. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Damien Hedde Tested-by: Damien Hedde Message-Id: <20200316172155.971-10-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index f6b42825445..db537a712cc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -367,6 +367,7 @@ typedef struct GDBState { char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; GString *str_buf; + GByteArray *mem_buf; } GDBState; /* By default use no IRQs and no timers while single stepping so as to @@ -382,6 +383,7 @@ static void init_gdbserver_state(void) memset(&gdbserver_state, 0, sizeof(GDBState)); gdbserver_state.init = true; gdbserver_state.str_buf = g_string_new(NULL); + gdbserver_state.mem_buf = g_byte_array_sized_new(MAX_PACKET_LENGTH); } #ifndef CONFIG_USER_ONLY @@ -576,12 +578,13 @@ static void memtohex(GString *buf, const uint8_t *mem, int len) g_string_append_c(buf, '\0'); } -static void hextomem(uint8_t *mem, const char *buf, int len) +static void hextomem(GByteArray *mem, const char *buf, int len) { int i; for(i = 0; i < len; i++) { - mem[i] = (fromhex(buf[0]) << 4) | fromhex(buf[1]); + guint8 byte = fromhex(buf[0]) << 4 | fromhex(buf[1]); + g_byte_array_append(mem, &byte, 1); buf += 2; } } @@ -1412,7 +1415,6 @@ static int cmd_parse_params(const char *data, const char *schema, typedef struct GdbCmdContext { GdbCmdVariant *params; int num_params; - uint8_t mem_buf[MAX_PACKET_LENGTH]; } GdbCmdContext; typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); @@ -1503,6 +1505,7 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) } g_string_set_size(gdbserver_state.str_buf, 0); + g_byte_array_set_size(gdbserver_state.mem_buf, 0); /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ @@ -1715,8 +1718,8 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) } reg_size = strlen(gdb_ctx->params[1].data) / 2; - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[1].data, reg_size); - gdb_write_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[1].data, reg_size); + gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->data, gdb_ctx->params[0].val_ull); put_packet("OK"); } @@ -1735,14 +1738,17 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - reg_size = gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf, + reg_size = gdb_read_register(gdbserver_state.g_cpu, + gdbserver_state.mem_buf->data, gdb_ctx->params[0].val_ull); if (!reg_size) { put_packet("E14"); return; + } else { + g_byte_array_set_size(gdbserver_state.mem_buf, reg_size); } - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, reg_size); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, reg_size); put_strbuf(); } @@ -1759,11 +1765,11 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[2].data, + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[2].data, gdb_ctx->params[1].val_ull); if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].val_ull, - gdb_ctx->mem_buf, - gdb_ctx->params[1].val_ull, true)) { + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, true)) { put_packet("E14"); return; } @@ -1784,14 +1790,17 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) return; } + g_byte_array_set_size(gdbserver_state.mem_buf, gdb_ctx->params[1].val_ull); + if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].val_ull, - gdb_ctx->mem_buf, - gdb_ctx->params[1].val_ull, false)) { + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, false)) { put_packet("E14"); return; } - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, gdb_ctx->params[1].val_ull); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len); put_strbuf(); } @@ -1806,9 +1815,9 @@ static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) } cpu_synchronize_state(gdbserver_state.g_cpu); - registers = gdb_ctx->mem_buf; len = strlen(gdb_ctx->params[0].data) / 2; - hextomem(registers, gdb_ctx->params[0].data, len); + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + registers = gdbserver_state.mem_buf->data; for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; addr++) { reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, addr); @@ -1825,11 +1834,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) cpu_synchronize_state(gdbserver_state.g_cpu); len = 0; for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++) { - len += gdb_read_register(gdbserver_state.g_cpu, gdb_ctx->mem_buf + len, + len += gdb_read_register(gdbserver_state.g_cpu, + gdbserver_state.mem_buf->data + len, addr); } + /* FIXME: This is after the fact sizing */ + g_byte_array_set_size(gdbserver_state.mem_buf, len); - memtohex(gdbserver_state.str_buf, gdb_ctx->mem_buf, len); + memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); put_strbuf(); } @@ -2078,6 +2090,7 @@ static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) #else static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) { + const guint8 zero = 0; int len; if (!gdb_ctx->num_params) { @@ -2091,12 +2104,13 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) return; } + g_assert(gdbserver_state.mem_buf->len == 0); len = len / 2; - hextomem(gdb_ctx->mem_buf, gdb_ctx->params[0].data, len); - gdb_ctx->mem_buf[len++] = 0; - qemu_chr_be_write(gdbserver_state.mon_chr, gdb_ctx->mem_buf, len); + hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); + qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len); put_packet("OK"); - } #endif From patchwork Tue Mar 17 17:50:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184643 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4434483ile; Tue, 17 Mar 2020 10:54:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu31DN6X+n4edPKUCk0TMTrtsoZEwVS5lpWsvBdsma/DahPJYV8a8n79eOS1Sn/hojtEqV7 X-Received: by 2002:ac8:5210:: with SMTP id r16mr322371qtn.173.1584467695820; Tue, 17 Mar 2020 10:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467695; cv=none; d=google.com; s=arc-20160816; b=dixLqqLQOX7ogAUCb9cWibVd+QQUTjq71Q8w75FTZcE3XNhlDdvgZEAzFsVjAqGcug uSc6/jXYLfUGRCBIjeBDispjKkmbpoVp8MkfYGZ10olcyDMHvSuFhyQ61OSpBzX4/xs3 8e9kmj2tJnYfau3VZewhXfFnG4Ql69OsxpdM/QlFCGMY6xMgTNdnJvAYt4wP5YXrzJu8 XTpkIfjCy7oacq2j/ZXgKqm5SXl9CIqp2TWmfSRQInoKebLlCWcURrijW6enbyUkfCpV RjER4in4sZT/5EWxWWHikcmvsfUK/BTPg/5QOO6bO38qtiCPyaShAOyetwieRaErMTc6 /cAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9z3Uw6JkfA9R4iTRQFeCE4m8VzCTOvZfkwPbB04egSU=; b=KFDvVAMsg4EUFlt4dkYZitqBs3nUJn25uJJgJpd+7TZY9zMIPCtfjFEgBHsFlXizzZ NwcmDHhMej7ZvQsm3cacdZijp58/bwCsEASRPpliRlO8CGVb3TX9gSiQNwuwPaYNGFD5 IcOsuHaewACFK6XrtZU3ejhVx+TR8VRckAtO3QbUWYWrN97Z8iE7mw9MEb1EEmw/ybh8 KSBaTwWXrD0i3FSL35xgsuDKGJyNDhm1h22J6Jp3GO7IK5l9bZraowh/ULJVn75rgFZz a6OZLuADKUR7S0eCDCcxmKPsvED22r5kHAMeIIk+GNOuabE/GspwJt4yLHUg05ZCCmv8 ExTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DWYoO7GS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p44si2268995qtp.119.2020.03.17.10.54.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DWYoO7GS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGQZ-0007Hc-7p for patch@linaro.org; Tue, 17 Mar 2020 13:54:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57034) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGMx-0000Qd-UE for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMw-0002go-RD for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:11 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:43060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMw-0002cI-K7 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:10 -0400 Received: by mail-wr1-x436.google.com with SMTP id b2so20645168wrj.10 for ; Tue, 17 Mar 2020 10:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9z3Uw6JkfA9R4iTRQFeCE4m8VzCTOvZfkwPbB04egSU=; b=DWYoO7GSUX2ngYSrdSeftZtjpURerAKPdm5tEAA3NXIx8m8gYKyUiXQ7GgcZ+KcAN1 osSKJRFgXN2dU85U1TAY9gkVYCmyEZYHAX1MeJikZqy4zNtfBnqTOLt5rmJNgmCI939B p6EpMCtX81b/IRmAfqgAQYgOK47Q+VduHF7ySv4BtJFT9TCbpqffPelnP/xiots34GZa gjtSYC312lw7l1mwxzNq3+Qka4KAoM4fdJIPxAr3KvGo2IVgGMOVD0UVv5+bfiQ6Z2jN S/dzN2PKUm/sF4bbz4luvnMllEQFiJIjmg8+48RIT7kWHpyA/jUYC3l1pWyd9xdVAAJW kLnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9z3Uw6JkfA9R4iTRQFeCE4m8VzCTOvZfkwPbB04egSU=; b=npKLHpCkConTa/1jOVjTSk4+vneSQV1Lz07G6cLeOaHpyWLQKdo6C7C1ntvh0+nvVO TDv0rftIXhtRn0B6/V3W4kJ6WrFEsdgp7utdiLYkBNldPDyjw4RB1zKReb9NmViMkQwz t8BbJSUWYtYIWQkImBXU9NG+1T/bpqlNstvd6g6taKzvWdliy/vYou3vJIVHX7rSpdWU SrkMT+BVVCzPP+GluLTayUAmJbVp9TgpRSz3ZRw11zgi72/tgdvJIkcp24FqUlM04EoP vtFPgVt1PHZr/kBQnuB7tyeDiiGWhDYpWcMz5xppfsh5ChGwE5tTD8zvsLTRQEZntwGB sEMA== X-Gm-Message-State: ANhLgQ2A0Z+SddtNuQ4A7+3ACU60LNP2D5/8K03HG2yG5IwxTvzICQf7 GIFBT0OQaO/dxO790nr9ShGIdw== X-Received: by 2002:adf:f30b:: with SMTP id i11mr180722wro.224.1584467469644; Tue, 17 Mar 2020 10:51:09 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r3sm3817870wrn.35.2020.03.17.10.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 319A21FF99; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 10/28] gdbstub: add helper for 128 bit registers Date: Tue, 17 Mar 2020 17:50:35 +0000 Message-Id: <20200317175053.5278-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-11-alex.bennee@linaro.org> -- 2.20.1 diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 08363969c14..59e366ba3af 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -102,6 +102,19 @@ static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val) return 8; } +static inline int gdb_get_reg128(uint8_t *mem_buf, uint64_t val_hi, + uint64_t val_lo) +{ +#ifdef TARGET_WORDS_BIGENDIAN + stq_p(mem_buf, val_hi); + stq_p(mem_buf + 8, val_lo); +#else + stq_p(mem_buf, val_lo); + stq_p(mem_buf + 8, val_hi); +#endif + return 16; +} + #if TARGET_LONG_BITS == 64 #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) #define ldtul_p(addr) ldq_p(addr) From patchwork Tue Mar 17 17:50:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184647 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4436344ile; Tue, 17 Mar 2020 10:57:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsMYGuyCcdVLnXf8LXD0MKA5DtSqvTCwycEPCsLuMSeEquTZ8FvoCtpwZL7cpLJHYpuHatC X-Received: by 2002:ac8:1111:: with SMTP id c17mr312561qtj.253.1584467821369; Tue, 17 Mar 2020 10:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467821; cv=none; d=google.com; s=arc-20160816; b=GgGCb3EVR9QheaitfnYIEMgf8eQspOY6F78O/HbnrEFb3BzQAyoT+C2T1ltwMDmVMu B3lBJuW9iphwp7W1pvU3bmGlOpugivoh/ClnS4BDWcXgJuxqvZVjqYwaZmA5NOJwR4uy 0FCfsikUZj09jSbs4eGaVdBp5KYrub1JVB+9IhdpxrYHoBe8A2K8c5T7U6dr5XQVXRTJ CUbpMU12MW8REQKJgGFzoxDvgpZRTWcPgCYqMo6yXcpL6TiXHVkG6maFkbS0Hc/rwUvZ QFjyFsZGg0l/PHGcS8DP7kWt0gaa4RnGLia784tabOuKPcFCZYaDlmFPcuTLy4EuEKxt FFxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UfXS/oThBLt+JELyaFOgYVQnoWMelkeLl6+REhHpyHg=; b=UAlH7IKfKeTomFS1gWULtRh1ALsoniKQ3q8HYGwkMWN9UQy/njSjsMsIvjrh0ZfkOG 1BGpCeWembitgD6WS73R13QaKrqz7YjrO57/sIrlovdoDc4El5Fm/azXCS2sGr7XcK+4 VdlsjZpLx9els3nhG4ZBqfPT0p3xhlRsQr66ZdsIy536bgjV1P+sRjW/Lr9uvZHl/fJ3 +CWseLOO7DL+AadlMlbw7c2PIxdTSomCpGw/PwfG1riKAg7zewxPiVJfZky77L7YG0zF 3WorXLWhJrTWgeSj/kwLxS0/ZWrRz4L4TZW5r+hc8RUyg7uX1Cm1zdt2WSz5moL0qWYu NRbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tLBireuq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o26si2319697qtr.270.2020.03.17.10.57.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:57:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tLBireuq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGSa-0002NI-S8 for patch@linaro.org; Tue, 17 Mar 2020 13:57:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57122) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN0-0000XL-Le for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGMz-00030J-Jr for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:14 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:37197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMz-0002nw-Cu for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:13 -0400 Received: by mail-wm1-x329.google.com with SMTP id a141so250299wme.2 for ; Tue, 17 Mar 2020 10:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UfXS/oThBLt+JELyaFOgYVQnoWMelkeLl6+REhHpyHg=; b=tLBireuqSFAK1uVbwzK2zK6JyKifxUC2wUwrNf0l/NCGUbm+RJZ5LOW1rFrFajTlgN zLtPpjHkkzizSSUYWVM1Crgkcdh9bp0uoS5NTuq69Hdn3RWKU3+H/llqTH73IAzEBXQe bjixboA7iNUZ59TjUXRXhHtWNSBu6YG5VP7FMyn73m5j63S5WiHylkjfPiHgmw+EoayF mpiaY5V3GU6QZBmINELSqIju6F6qG/OWduMLqc9irbCiA62o9Vk3QhkgVRSzEZKMJtKa s5pv85zmuZNfiGlH0bnOlTnnJpX/DAGr7dhAsVace8uBBT8cfzMaw9nii0pWWXr7SlG1 3CIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UfXS/oThBLt+JELyaFOgYVQnoWMelkeLl6+REhHpyHg=; b=FP8jH8eGLRQIkXmLCLexQQTyOU8zZvexQSX0Hapz1rp1clounB4kGuyTJ1/iNcHQ/a lIoFu0XKfZr/UQSb9AVT27SQoQCoH8YofVqndsYLLICCHt7blOUsksM4St3XLsOEKuB4 a4lo3RZFMC56fq0Ol0Y0gJEmRz0cFC8cwBCeUsG2+Fb3Mwitr+5ppBKwd/gGTf0Eq4gg sDQ7Sarev7ghKUl2NAO50gIsEuF7CS0z6YPNhnqfExd1a8/PegT7sI4KQrSynOz07nYx XxBPVW/LgwLugp2A5lFG7KTO3FJeeXrgm48kzOrMUWe+jlIgTW4UqhBQgW/Jq/Ys/bOE CSYw== X-Gm-Message-State: ANhLgQ18jUGRU3irXzAG/IT0ie/UOv2z7YOES25NJCJoxuznL+8aTIAs whLshA/vaKNFFcGasnOqopX15g== X-Received: by 2002:a1c:6285:: with SMTP id w127mr170378wmb.133.1584467471746; Tue, 17 Mar 2020 10:51:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 19sm238588wma.3.2020.03.17.10.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 466D51FF9A; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 11/28] target/arm: use gdb_get_reg helpers Date: Tue, 17 Mar 2020 17:50:36 +0000 Message-Id: <20200317175053.5278-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, "open list:ARM TCG CPUs" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-12-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index b61ee73d18a..69104fb351d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -106,21 +106,17 @@ static int aarch64_fpu_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) { switch (reg) { case 0 ... 31: - /* 128 bit FP register */ - { - uint64_t *q = aa64_vfp_qreg(env, reg); - stq_le_p(buf, q[0]); - stq_le_p(buf + 8, q[1]); - return 16; - } + { + /* 128 bit FP register - quads are in LE order */ + uint64_t *q = aa64_vfp_qreg(env, reg); + return gdb_get_reg128(buf, q[1], q[0]); + } case 32: /* FPSR */ - stl_p(buf, vfp_get_fpsr(env)); - return 4; + return gdb_get_reg32(buf, vfp_get_fpsr(env)); case 33: /* FPCR */ - stl_p(buf, vfp_get_fpcr(env)); - return 4; + return gdb_get_reg32(buf,vfp_get_fpcr(env)); default: return 0; } From patchwork Tue Mar 17 17:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184646 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4436303ile; Tue, 17 Mar 2020 10:56:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsZwJ/5ghjO/XBc7XHcRZ9msL4jyD7t18lfIWN3KhoIkaNUFwJL/IXl5Y07oFEkHH9Nxd0R X-Received: by 2002:aed:21c5:: with SMTP id m5mr377831qtc.42.1584467817823; Tue, 17 Mar 2020 10:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467817; cv=none; d=google.com; s=arc-20160816; b=Y43N94P2jLE4uwN3f48c81W01i34fEy0bAA/knUHQhhdDaGuKnqRxy8wP5VmY0uh4F S8n4/IAM0d6jKumJZqTyfYm42k0QMeYYAcVIlPX5wTS0pIjdxBTK0gNbV2mq1c5wlxKK bHogaj3MrX0Y/SpR968l/HTbRSYh+OjpqnAEyFO+jfVT/ydTeBUaoyl6aMvKFfDprieb F2bj2o0wkOp7GLPaeMYvHg1fB7RqY7W8LUQTvH8ZBSuKKMJdbLWRO5nFVWyWTOQuAiTj lIKNm6+K1YIedzKBl9og0I0hihtNu1ZSoSuC+cJ3eFNedLnGlc+VyuGQRsh/WTEa9r9m qvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Yf5LYbxQ7vZFI2e7ouWmWtLtY/JYKItbGmCRFHATcOA=; b=oSDZ+xZ43b0zWHIohRq1hNwS3V3/x8LY6uZSvTYkZDRQpT9+EdL2LEzv+WiVrRrM8Q SYVLV0vWP5VDLwnNHriVgpuzIzu4HpnhnzMeQ2wdJFmmXaw6tAKuj3AdW3Qph2xXVBqE luxhd1GNII3LZySvA65aFtcjWxLKpBGYShjWGbMwKB9imCh4tYtuBWSk8i1Wdd53r9Ii iMtzZj+F71ZJidlqY/D25Rmm3zRbxouGd/x2gxkpwI7YM8Ulo+ulP0iyMk3FUVl1iT4f GFT87sENBUOgACDsxJEmFVMPb9GaOdrW7omcV0PfMzJLzTKSIY0WPbQZb+kh/e1DhCei sjGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ar7YY6PN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k65si2509119qke.224.2020.03.17.10.56.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:56:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ar7YY6PN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGSX-0002DI-7s for patch@linaro.org; Tue, 17 Mar 2020 13:56:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57157) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN1-0000au-Ks for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN0-00034n-AC for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:15 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:52277) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGMz-0002wj-S4 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:14 -0400 Received: by mail-wm1-x336.google.com with SMTP id 11so256618wmo.2 for ; Tue, 17 Mar 2020 10:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yf5LYbxQ7vZFI2e7ouWmWtLtY/JYKItbGmCRFHATcOA=; b=ar7YY6PNDtBqwBxuuw77nK1CTRBikQxIeKKSjsbxOrQa+qHhyxe1YJP6AVKl8kRihS O3wyXI7Fl64axSinztzBt+J0flUQ//Y0waq5IO+gLyEVJcCKiiV9xAjM0HkIC3823aA3 b0zC0f8h3pvsSPtpdpbAUzMsHr86kQqgN5ojW+URw0cZSI80ICFJWPXseJGfhLUQ5B4v 6jeaDaEq3gL12l0XtMDXVlz34yw0kQBb0ZaJs/mTvc0FiwEYy9mFWxZYZTbmL78wklRv s+fQsLsHKDzE6Ps8PUx1S/CsX58hq1c5coU2PR6SAy7Qzl629XYyRIYIkn3kGFeZa3zk 6OcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yf5LYbxQ7vZFI2e7ouWmWtLtY/JYKItbGmCRFHATcOA=; b=KIjyLfDBgmrdMCUhuD+sguYXFcYsB+18+wdkKkFiWQpk7hYFt7W7lBUYXT8QWoesnb 8EvdCGRz6jUIZbYgBoHMapIMSBqcuiAG+5A3p4o7/Hluo6IXrLAIP+Hq37U5prkiznhW VXKUlhLTeb633+o7Kj2nJ6y58xbLkg2yn5FOG+Vz6It7V4exHLtp1BCWVqLBOxP/hOUG XvWw74mxak/Hiwp2/n79FbBOOZaaGtODx1x41inPOXRT/QyoxNXg93SK4z+ADmlRgOnq q/Dy6nGA6yAjawi+rJYTHqV+VcVY7UnpnQ7d44iyaMqtJpW+JRHpMmOQJn6EGjt7Ldzm zE8g== X-Gm-Message-State: ANhLgQ0VeFiJPm2KJ4EoWTs7LoV1tWLxIVjMzEFKzn7kG8qZM9HVIMgO oBlja9CZVKHc4sQ5V7CG3n6bkg== X-Received: by 2002:a1c:a584:: with SMTP id o126mr174541wme.49.1584467472729; Tue, 17 Mar 2020 10:51:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 133sm237427wmd.5.2020.03.17.10.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:00 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 59F201FF9B; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 12/28] target/m68k: use gdb_get_reg helpers Date: Tue, 17 Mar 2020 17:50:37 +0000 Message-Id: <20200317175053.5278-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-13-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/m68k/helper.c b/target/m68k/helper.c index baf7729af00..c23b70f854d 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -72,19 +72,15 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) { if (n < 8) { float_status s; - stfq_p(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); - return 8; + return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); } switch (n) { case 8: /* fpcontrol */ - stl_be_p(mem_buf, env->fpcr); - return 4; + return gdb_get_reg32(mem_buf, env->fpcr); case 9: /* fpstatus */ - stl_be_p(mem_buf, env->fpsr); - return 4; + return gdb_get_reg32(mem_buf, env->fpsr); case 10: /* fpiar, not implemented */ - memset(mem_buf, 0, 4); - return 4; + return gdb_get_reg32(mem_buf, 0); } return 0; } @@ -112,21 +108,18 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) static int m68k_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) { if (n < 8) { - stw_be_p(mem_buf, env->fregs[n].l.upper); - memset(mem_buf + 2, 0, 2); - stq_be_p(mem_buf + 4, env->fregs[n].l.lower); - return 12; + int len = gdb_get_reg16(mem_buf, env->fregs[n].l.upper); + len += gdb_get_reg16(mem_buf + len, 0); + len += gdb_get_reg64(mem_buf + len, env->fregs[n].l.lower); + return len; } switch (n) { case 8: /* fpcontrol */ - stl_be_p(mem_buf, env->fpcr); - return 4; + return gdb_get_reg32(mem_buf, env->fpcr); case 9: /* fpstatus */ - stl_be_p(mem_buf, env->fpsr); - return 4; + return gdb_get_reg32(mem_buf, env->fpsr); case 10: /* fpiar, not implemented */ - memset(mem_buf, 0, 4); - return 4; + return gdb_get_reg32(mem_buf, 0); } return 0; } From patchwork Tue Mar 17 17:50:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184658 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4446818ile; Tue, 17 Mar 2020 11:06:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuc1fmVDZu8AjyzknP5yHJxxhhFaSRM+7BYBpjDEIr8o5ZFHMImaswsyEa7hjRV73PhmtRQ X-Received: by 2002:a37:6311:: with SMTP id x17mr85250qkb.93.1584468380272; Tue, 17 Mar 2020 11:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468380; cv=none; d=google.com; s=arc-20160816; b=qPHA2AA/AJw4xlqoLm88bwFUho4abCLmXLFqAsVc233LFXV72kOqNYeE4hoQYm3EnB 6529NFnufSuAc8SQwZkdR0eY3UFKJcxTwqyWgjnA/A7LPFv5fMw3Ns70+cLGeTHS6rBt gXX0y0L87oXJkOsPv6eusDu8O5LRWgM8qQ/oi+JnBkIyFvsEZ1Ar6pB5sZmThDfmj3Hm /+3Hz7yB3bugHoMfUmJJz6BgizRpgEkjRqQaGNHgp0l0jj2yLT6qBk1hyhwCuuz4g6vt XtanJCFRR4saFddzArBmHbfZYwsbXfOrPFsy+arFffRUB2D+FmjhZ8KrH4BNL4MX8NZM SiGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0LurhQOzs6U/ZvFoMmo+r48W1bsv6y+gXlCttu3J7Bc=; b=Kd9uCpU5ttD7qEmvfGg5X9THIhNYmtMf6r09RvlUVgDRfkWt7pMa3TeuWrnNzYdlub nJaRmNdR5Ur6bkigcPcCpeUSTDbtrD9CfEZKZfRkaz9RHFPm5YuWIetp4kubSXXbGDNT DJGL5HGWnXKiI00vgewKVbzEdH2iqtVmSKRqyoDB9lb8STmYG9z2y2f4z6YjH49/cijY eywlcyCZQIiMyqBjnFEZxSu+jE0Kg2ak4b0zv2DAJLWCr0VngITPk7R1lGw0kx5bIHpE +Zl8dV8OSRbWurKb3sz82yG+9D6AHK9w7+BtMPC5Yk/COgTw+ZBjv24vxxETO0DPDZap sq3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o7v3m7Es; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si2251294qvp.1.2020.03.17.11.06.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=o7v3m7Es; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGbb-0005yI-MP for patch@linaro.org; Tue, 17 Mar 2020 14:06:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN9-0000uq-No for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN7-0003uw-MM for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:23 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:46439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGN7-0003pr-Dw for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:21 -0400 Received: by mail-wr1-x42b.google.com with SMTP id w16so10474003wrv.13 for ; Tue, 17 Mar 2020 10:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0LurhQOzs6U/ZvFoMmo+r48W1bsv6y+gXlCttu3J7Bc=; b=o7v3m7EsuzvyFIhhKoiL7J5MWwwfNigJd9ZkrUa3i3U/OkXXHVz5zu4lyebHyhWQ0X MthBOq8RAWwGnTG8CkW6lLLIYNc90rPwF8xK/QG8r2av8HTem3NODdT+mtz3pg4/mrER TdyD/Xyhnt4Aj1MvWXNkt0lC65IjodvZ2+kDeHjmVk2MXwpSI7CEMyp6mK8ftyewHa1D RsjeaN6EGAQ9sE7HxETNRhrojGqSj3M3vYxY79FRSmaavwcuN92PIHPOlMAIaCBq7axX xNiMRhUsfm1hHVPRSfY74RyCtSMnEqY0UR19eMv3iS5TFrHJMLEDYv+RO+SbwIgauGm9 6LRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0LurhQOzs6U/ZvFoMmo+r48W1bsv6y+gXlCttu3J7Bc=; b=ip+GU7YqwmNnFn34bhHhwdpuCpixQ7ZDDcp8DAyRapju6gWs+p3ee1T8o3fLj/Spf6 4uDIh3IRcIcNuMZNKXiWUl2TC/K8JorYPpEjFIjlYHgXa2+SxI6O9vEhpjCPVLPvnzDb b3Bctsx4AWuuQy2/P9LyTXhuxYmSTk5sYHMVR9swHtSNxp7VLDgntD48qr/6Y8btRF6p 5papU8bb+IAaMtMUYdxu3m815o/MpBImfruLGbntsb7AM6s2BhPybO3ANv9hBVYqJIpL TLBlccXLyD3RvC/zwqx3mDHnqrj0Sk1aMUHqXDsnQwxvIqFtFnQhQC5Bv3iL+YhnMd0R qj7w== X-Gm-Message-State: ANhLgQ2ZjmsIUUxR3QKuBdfAPipotMyBBELFxhQ1OqkHYp/M511yZlqs ciP/Y7Gy0SaGufzCLdCkSYnDfFqWPp0= X-Received: by 2002:adf:f510:: with SMTP id q16mr149860wro.43.1584467480343; Tue, 17 Mar 2020 10:51:20 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t22sm921219wra.27.2020.03.17.10.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6FED61FF9C; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 13/28] target/i386: use gdb_get_reg helpers Date: Tue, 17 Mar 2020 17:50:38 +0000 Message-Id: <20200317175053.5278-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is cleaner than poking memory directly and will make later clean-ups easier. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-14-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 572ead641ca..e4d8cb66c00 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -98,26 +98,22 @@ int x86_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) return gdb_get_reg64(mem_buf, env->regs[gpr_map[n]] & 0xffffffffUL); } else { - memset(mem_buf, 0, sizeof(target_ulong)); - return sizeof(target_ulong); + return gdb_get_regl(mem_buf, 0); } } else { return gdb_get_reg32(mem_buf, env->regs[gpr_map32[n]]); } } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) { -#ifdef USE_X86LDOUBLE - /* FIXME: byteswap float values - after fixing fpregs layout. */ - memcpy(mem_buf, &env->fpregs[n - IDX_FP_REGS], 10); -#else - memset(mem_buf, 0, 10); -#endif - return 10; + floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS]; + int len = gdb_get_reg64(mem_buf, cpu_to_le64(fp->low)); + len += gdb_get_reg16(mem_buf + len, cpu_to_le16(fp->high)); + return len; } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -= IDX_XMM_REGS; if (n < CPU_NB_REGS32 || TARGET_LONG_BITS == 64) { - stq_p(mem_buf, env->xmm_regs[n].ZMM_Q(0)); - stq_p(mem_buf + 8, env->xmm_regs[n].ZMM_Q(1)); - return 16; + return gdb_get_reg128(mem_buf, + env->xmm_regs[n].ZMM_Q(0), + env->xmm_regs[n].ZMM_Q(1)); } } else { switch (n) { @@ -290,10 +286,9 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 4; } } else if (n >= IDX_FP_REGS && n < IDX_FP_REGS + 8) { -#ifdef USE_X86LDOUBLE - /* FIXME: byteswap float values - after fixing fpregs layout. */ - memcpy(&env->fpregs[n - IDX_FP_REGS], mem_buf, 10); -#endif + floatx80 *fp = (floatx80 *) &env->fpregs[n - IDX_FP_REGS]; + fp->low = le64_to_cpu(* (uint64_t *) mem_buf); + fp->high = le16_to_cpu(* (uint16_t *) (mem_buf + 8)); return 10; } else if (n >= IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -= IDX_XMM_REGS; From patchwork Tue Mar 17 17:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184651 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4438472ile; Tue, 17 Mar 2020 10:59:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvQkX+CJaw3O25va1t5X9YA38goh5BsdLwVNv6TwtOgApo8yFRcLIM/KB1VIbXwxpwLij0z X-Received: by 2002:a05:620a:1671:: with SMTP id d17mr46850qko.53.1584467965042; Tue, 17 Mar 2020 10:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467965; cv=none; d=google.com; s=arc-20160816; b=li3vtyg9Sl108XFMHCCKkkfiTDg+lqKR/3g14FvEnOHk84cT+sZjTGHGkw9FqsVE7J Zv3Gpy3M/vbbec8kaTJ29jXNs5T68jrdBUiIB721u2O3wX2ilmM5FP59c0bTNWyQLIKV AI1moJhJfenO2rgo/crOLFI6WEocoKdnx6AilkV1UCmGK6Z7cUp4mWCNs+VWv0KkIwFq 8Y9Vok6hvvAnlAgX+Oy6X6gGjPH4n0d1EOj2tyj/E6QYa7EuFym9MZ3DNHrjZA4AVmTj m8xd5GDPt8KLjR+8QB8BMmb/qdYOnrMJlMM7oKT3OYWP2IozoJ5CR+UI25vs9iV8DgVD IR1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=crNmKYswmmMS6uA2RWcbxAnGGvc+R7IA3wd6VdlGl9A=; b=Xb/SB0AQpduRHxYEf7t6tAy0RDMCXRDjyEIe6YY0uhJPgiLgCn5wf87Dg6TE6gUpJj UliOQf6lOEDTPArrEO5VS/MiCYZcUNYA8bhd2uZdwWg5nU4Rq+fLuJatupP4ZZrLMsxb Wyv7nPt78CACj9XoztNbcviwZCCyj7iujIZw9ma2j+/ng6k2pgeiwQLgCsXp8ZYze4m/ KG+8Fd2hZLFCDmxLpslhLzED3fZJc9KfPsonFOhhtpf8GEocJE4FyHZAOFT/zuoLtTYv bx0cf3s5UVYvLYKLXhMnSG1SeXKxfN3Gq2Qoigg3GdzmT2dhEabdL/XFEQQg0qFwkWfv aqxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JQOTrV2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i2si2355672qtp.48.2020.03.17.10.59.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JQOTrV2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUu-0005wI-BS for patch@linaro.org; Tue, 17 Mar 2020 13:59:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57448) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGNC-00012z-Jh for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN4-0003bW-Cl for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:26 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGN3-0003U1-Sw for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:18 -0400 Received: by mail-wr1-x431.google.com with SMTP id f3so19914021wrw.7 for ; Tue, 17 Mar 2020 10:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crNmKYswmmMS6uA2RWcbxAnGGvc+R7IA3wd6VdlGl9A=; b=JQOTrV2oPCeGC2BhKqZMxmT8fblbX3D3sm5sBfAycNlb/9HcGNxYjfHGtxXh7vEtWU ltdRrPEuh1oLyQc9NlZ5gEoAJtTCc319thMcBz3Gr0oID6hyoN+5EJoQps8hZ3XlfU1x HOUeOsz/X+qVqdJ+Q3M/GBnDbznYquIynsAglm3ibq7dxYOb7xQi0o8Yu8+vKg2lEXbZ N/kga3E5YuKF/6KoA/pqk6U/yKPcr06HYJpaddIagCV6ba5nYUcXdsHM5rw/eXMB68lw qYDs4nAh7+iQIn/L7zZjHFrh5tjbUcWvMoZrTp9WAVxQN2AB4QDBmAQxw6C1MV3Nza9G RN3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=crNmKYswmmMS6uA2RWcbxAnGGvc+R7IA3wd6VdlGl9A=; b=BZ4dkoqL4Cy9OMDKok4xIu8aRQo1fSbQr1aTZuVy8Gldda5YI1fGaCruF2M1TOvpv/ vfeNJTLR8KGpeF0C1WiBWBkvKuwKytkl8NKALP7GKhSKBAc/kW2dn83x3t3KiFD/6xrn LjjfK5lOh+GgmiKyUahKw/isSY2hypkE0o9zpFynuwRG0lmZVaIC9FZEwADhUYt15y1v Ieomy477fP+aUyBAxg+oLgiZVsBa0zGIcfaBsoW9Y4jYTX2c+3TvfwKBMV0hx2MYpqu+ 5iow8UBUPAkgm2g7ob7pmoN58i0ChmV8rEMTWRRhj3qHj35uuQ2G/vHB4LSRgqFQR3+o PJfg== X-Gm-Message-State: ANhLgQ3xSfxyow9Auu7gADEDdpwg+atE6ErVVI9dXqedaxo+iXlSFxrm ocdXT7gKCzjqtEnW+H3lFDgUfQ== X-Received: by 2002:adf:e5cd:: with SMTP id a13mr135075wrn.275.1584467476166; Tue, 17 Mar 2020 10:51:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t193sm223362wmt.14.2020.03.17.10.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CACDB1FF9D; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 14/28] gdbstub: extend GByteArray to read register helpers Date: Tue, 17 Mar 2020 17:50:39 +0000 Message-Id: <20200317175053.5278-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , Sagar Karandikar , David Hildenbrand , Mark Cave-Ayland , qemu-devel@nongnu.org, Max Filippov , Alistair Francis , "Edgar E. Iglesias" , Marek Vasut , "open list:PowerPC TCG CPUs" , Aleksandar Rikalo , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Artyom Tarasenko , Eduardo Habkost , Richard Henderson , "open list:S390 general arch..." , "open list:ARM TCG CPUs" , Stafford Horne , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Damien Hedde , "open list:RISC-V TCG CPUs" , Bastian Koppelmann , Chris Wulff , Laurent Vivier , Michael Walle , Palmer Dabbelt , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Instead of passing a pointer to memory now just extend the GByteArray to all the read register helpers. They can then safely append their data through the normal way. We don't bother with this abstraction for write registers as we have already ensured the buffer being copied from is the correct size. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Acked-by: David Gibson Reviewed-by: Damien Hedde Message-Id: <20200316172155.971-15-alex.bennee@linaro.org> -- 2.20.1 diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 59e366ba3af..30b909ebd27 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -68,53 +68,76 @@ void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *); #endif /* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); +typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); void gdb_register_coprocessor(CPUState *cpu, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, int num_regs, const char *xml, int g_pos); -/* The GDB remote protocol transfers values in target byte order. This means - * we can use the raw memory access routines to access the value buffer. - * Conveniently, these also handle the case where the buffer is mis-aligned. +/* + * The GDB remote protocol transfers values in target byte order. As + * the gdbstub may be batching up several register values we always + * append to the array. */ -static inline int gdb_get_reg8(uint8_t *mem_buf, uint8_t val) +static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) { - stb_p(mem_buf, val); + g_byte_array_append(buf, &val, 1); return 1; } -static inline int gdb_get_reg16(uint8_t *mem_buf, uint16_t val) +static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) { - stw_p(mem_buf, val); + uint16_t to_word = tswap16(val); + g_byte_array_append(buf, (uint8_t *) &to_word, 2); return 2; } -static inline int gdb_get_reg32(uint8_t *mem_buf, uint32_t val) +static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) { - stl_p(mem_buf, val); + uint32_t to_long = tswap32(val); + g_byte_array_append(buf, (uint8_t *) &to_long, 4); return 4; } -static inline int gdb_get_reg64(uint8_t *mem_buf, uint64_t val) +static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) { - stq_p(mem_buf, val); + uint64_t to_quad = tswap64(val); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); return 8; } -static inline int gdb_get_reg128(uint8_t *mem_buf, uint64_t val_hi, +static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, uint64_t val_lo) { + uint64_t to_quad; #ifdef TARGET_WORDS_BIGENDIAN - stq_p(mem_buf, val_hi); - stq_p(mem_buf + 8, val_lo); + to_quad = tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad = tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); #else - stq_p(mem_buf, val_lo); - stq_p(mem_buf + 8, val_hi); + to_quad = tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad = tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); #endif return 16; } +/** + * gdb_get_reg_ptr: get pointer to start of last element + * @len: length of element + * + * This is a helper function to extract the pointer to the last + * element for additional processing. Some front-ends do additional + * dynamic swapping of the elements based on CPU state. + */ +static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len) +{ + return buf->data + buf->len - len; +} + #if TARGET_LONG_BITS == 64 #define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) #define ldtul_p(addr) ldq_p(addr) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 73e9a869a41..e1d6ee00b40 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -195,7 +195,7 @@ typedef struct CPUClass { hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs); - int (*gdb_read_register)(CPUState *cpu, uint8_t *buf, int reg); + int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); void (*debug_excp_handler)(CPUState *cpu); diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 3f782c0efe4..be29bdd5301 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -280,7 +280,7 @@ void alpha_cpu_do_interrupt(CPUState *cpu); bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req); void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int alpha_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4ffd991b6fc..4ab2cbfd417 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -968,7 +968,7 @@ bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); -int arm_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs from @@ -988,7 +988,7 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); #ifdef TARGET_AARCH64 -int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, diff --git a/target/cris/cpu.h b/target/cris/cpu.h index ca240bc7881..8f08d7628b2 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -195,8 +195,8 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags); hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int crisv10_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int cris_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int crisv10_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); +int cris_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int cris_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); /* you can call this signal handler from your SIGBUS and SIGSEGV diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 6713d04f111..801a4fb1bae 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -321,7 +321,7 @@ void cpu_hppa_change_prot_id(CPUHPPAState *env); int cpu_hppa_signal_handler(int host_signum, void *pinfo, void *puc); hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vaddr addr); -int hppa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 576f309bbfc..c2d89315b92 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1766,7 +1766,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags); hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); -int x86_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int x86_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void x86_cpu_exec_enter(CPUState *cpu); diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h index 064c6b1267e..01d408eb55d 100644 --- a/target/lm32/cpu.h +++ b/target/lm32/cpu.h @@ -202,7 +202,7 @@ void lm32_cpu_do_interrupt(CPUState *cpu); bool lm32_cpu_exec_interrupt(CPUState *cs, int int_req); void lm32_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr lm32_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int lm32_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int lm32_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int lm32_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); typedef enum { diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 3de8e06dfec..521ac67cdd0 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -168,7 +168,7 @@ void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int m68k_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void m68k_tcg_init(void); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 32522f606bd..1a700a880c5 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -313,7 +313,7 @@ void mb_cpu_do_interrupt(CPUState *cs); bool mb_cpu_exec_interrupt(CPUState *cs, int int_req); void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int mb_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void mb_tcg_init(void); diff --git a/target/mips/internal.h b/target/mips/internal.h index df55f845baf..1bf274b3ef5 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -82,7 +82,7 @@ void mips_cpu_do_interrupt(CPUState *cpu); bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int mips_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 0ad02eab794..d9484b802f3 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -320,7 +320,7 @@ void openrisc_cpu_do_interrupt(CPUState *cpu); bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int openrisc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void openrisc_translate_init(void); bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index b283042515f..5fd081573ef 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1218,8 +1218,8 @@ bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); void ppc_cpu_dump_statistics(CPUState *cpu, int flags); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int ppc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); -int ppc_cpu_gdb_read_register_apple(CPUState *cpu, uint8_t *buf, int reg); +int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); +int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg); int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg); #ifndef CONFIG_USER_ONLY diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 3dcdf922272..31458c5b4a7 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -293,7 +293,7 @@ extern const char * const riscv_excp_names[]; extern const char * const riscv_intr_names[]; void riscv_cpu_do_interrupt(CPUState *cpu); -int riscv_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request); bool riscv_cpu_fp_enabled(CPURISCVState *env); diff --git a/target/s390x/internal.h b/target/s390x/internal.h index d37816104dd..8c95c734dbe 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -292,7 +292,7 @@ uint16_t float128_dcmask(CPUS390XState *env, float128 f1); /* gdbstub.c */ -int s390_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int s390_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int s390_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void s390_cpu_gdb_init(CPUState *cs); diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 452a596e671..dbe58c7888f 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -208,7 +208,7 @@ void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int superh_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ae97c7d9f79..b9369398f24 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -571,7 +571,7 @@ extern const VMStateDescription vmstate_sparc_cpu; void sparc_cpu_do_interrupt(CPUState *cpu); void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -int sparc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 493f4fc80c5..c0d69fad96c 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -569,7 +569,7 @@ void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); -int xtensa_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); +int xtensa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int xtensa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/gdbstub.c b/gdbstub.c index db537a712cc..0bcfc47a7c5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -319,8 +319,8 @@ static int gdb_signal_to_target (int sig) typedef struct GDBRegisterState { int base_reg; int num_regs; - gdb_reg_cb get_reg; - gdb_reg_cb set_reg; + gdb_get_reg_cb get_reg; + gdb_set_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; @@ -905,19 +905,19 @@ static const char *get_feature_xml(const char *p, const char **newp, return name ? xml_builtin[i][1] : NULL; } -static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg) +static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); CPUArchState *env = cpu->env_ptr; GDBRegisterState *r; if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, mem_buf, reg); + return cc->gdb_read_register(cpu, buf, reg); } for (r = cpu->gdb_regs; r; r = r->next) { if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { - return r->get_reg(env, mem_buf, reg - r->base_reg); + return r->get_reg(env, buf, reg - r->base_reg); } } return 0; @@ -948,7 +948,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) */ void gdb_register_coprocessor(CPUState *cpu, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, + gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, int num_regs, const char *xml, int g_pos) { GDBRegisterState *s; @@ -1739,7 +1739,7 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) } reg_size = gdb_read_register(gdbserver_state.g_cpu, - gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf, gdb_ctx->params[0].val_ull); if (!reg_size) { put_packet("E14"); @@ -1832,14 +1832,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) target_ulong addr, len; cpu_synchronize_state(gdbserver_state.g_cpu); + g_byte_array_set_size(gdbserver_state.mem_buf, 0); len = 0; for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++) { len += gdb_read_register(gdbserver_state.g_cpu, - gdbserver_state.mem_buf->data + len, + gdbserver_state.mem_buf, addr); } - /* FIXME: This is after the fact sizing */ - g_byte_array_set_size(gdbserver_state.mem_buf, len); + g_assert(len == gdbserver_state.mem_buf->len); memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); put_strbuf(); diff --git a/hw/core/cpu.c b/hw/core/cpu.c index fe65ca62ace..3b2363f0431 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -177,7 +177,7 @@ static int cpu_common_write_elf64_note(WriteCoreDumpFunction f, } -static int cpu_common_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg) +static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { return 0; } diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 7f9cc092a9c..0cd76ddaa9e 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int alpha_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { AlphaCPU *cpu = ALPHA_CPU(cs); CPUAlphaState *env = &cpu->env; diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 1239abd9842..4557775d245 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -32,7 +32,7 @@ typedef struct RegisterSysregXmlParam { We hack round this by giving the FPA regs zero size when talking to a newer gdb. */ -int arm_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 665ebb3ef64..35d0b80c2de 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int aarch64_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; diff --git a/target/arm/helper.c b/target/arm/helper.c index 69104fb351d..c0e1ba17272 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -48,30 +48,27 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, static void switch_mode(CPUARMState *env, int mode); -static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) +static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu = env_archcpu(env); int nregs = cpu_isar_feature(aa32_simd_r32, cpu) ? 32 : 16; /* VFP data registers are always little-endian. */ if (reg < nregs) { - stq_le_p(buf, *aa32_vfp_dreg(env, reg)); - return 8; + return gdb_get_reg64(buf, *aa32_vfp_dreg(env, reg)); } if (arm_feature(env, ARM_FEATURE_NEON)) { /* Aliases for Q regs. */ nregs += 16; if (reg < nregs) { uint64_t *q = aa32_vfp_qreg(env, reg - 32); - stq_le_p(buf, q[0]); - stq_le_p(buf + 8, q[1]); - return 16; + return gdb_get_reg128(buf, q[0], q[1]); } } switch (reg - nregs) { - case 0: stl_p(buf, env->vfp.xregs[ARM_VFP_FPSID]); return 4; - case 1: stl_p(buf, vfp_get_fpscr(env)); return 4; - case 2: stl_p(buf, env->vfp.xregs[ARM_VFP_FPEXC]); return 4; + case 0: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPSID]); break; + case 1: return gdb_get_reg32(buf, vfp_get_fpscr(env)); break; + case 2: return gdb_get_reg32(buf, env->vfp.xregs[ARM_VFP_FPEXC]); break; } return 0; } @@ -102,7 +99,7 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) return 0; } -static int aarch64_fpu_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg) +static int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) { switch (reg) { case 0 ... 31: @@ -205,7 +202,7 @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, } } -static int arm_gdb_get_sysreg(CPUARMState *env, uint8_t *buf, int reg) +static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu = env_archcpu(env); const ARMCPRegInfo *ri; diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index a3d76d2e8c2..b01b2aa0811 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int crisv10_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; @@ -53,7 +53,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -int cris_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = &cpu->env; diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c index 341888a9da0..a6428a2893f 100644 --- a/target/hppa/gdbstub.c +++ b/target/hppa/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int hppa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { HPPACPU *cpu = HPPA_CPU(cs); CPUHPPAState *env = &cpu->env; diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index e4d8cb66c00..f3d23b614ee 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -79,7 +79,7 @@ static const int gpr_map32[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; #endif -int x86_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; diff --git a/target/lm32/gdbstub.c b/target/lm32/gdbstub.c index 82ede436e12..b6fe12e1d61 100644 --- a/target/lm32/gdbstub.c +++ b/target/lm32/gdbstub.c @@ -22,7 +22,7 @@ #include "exec/gdbstub.h" #include "hw/lm32/lm32_pic.h" -int lm32_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int lm32_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { LM32CPU *cpu = LM32_CPU(cs); CPULM32State *env = &cpu->env; diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index fdc96f57fff..eb2d030e148 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int m68k_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { M68kCPU *cpu = M68K_CPU(cs); CPUM68KState *env = &cpu->env; diff --git a/target/m68k/helper.c b/target/m68k/helper.c index c23b70f854d..014657c6372 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -68,7 +68,7 @@ void m68k_cpu_list(void) g_slist_free(list); } -static int cf_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) { if (n < 8) { float_status s; @@ -105,7 +105,7 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) return 0; } -static int m68k_fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n) +static int m68k_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n) { if (n < 8) { int len = gdb_get_reg16(mem_buf, env->fregs[n].l.upper); diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 30677b6d1f4..f41ebf1f33b 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int mb_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); CPUMBState *env = &cpu->env; diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index bbb25449391..98f56e660d2 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -22,7 +22,7 @@ #include "internal.h" #include "exec/gdbstub.h" -int mips_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 1c0c855a6f0..1856b7fcc7a 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -124,7 +124,7 @@ static void nios2_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) #endif } -static int nios2_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +static int nios2_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { Nios2CPU *cpu = NIOS2_CPU(cs); CPUClass *cc = CPU_GET_CLASS(cs); diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index 0fcdb79668c..095bf76c12c 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -int openrisc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 823759c92e7..eb362dd9aec 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -114,10 +114,11 @@ void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len) * the FP regs zero size when talking to a newer gdb. */ -int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; + uint8_t *mem_buf; int r = ppc_gdb_register_len(n); if (!r) { @@ -126,17 +127,17 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) if (n < 32) { /* gprs */ - gdb_get_regl(mem_buf, env->gpr[n]); + gdb_get_regl(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - stfq_p(mem_buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); } else { switch (n) { case 64: - gdb_get_regl(mem_buf, env->nip); + gdb_get_regl(buf, env->nip); break; case 65: - gdb_get_regl(mem_buf, env->msr); + gdb_get_regl(buf, env->msr); break; case 66: { @@ -145,31 +146,33 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) for (i = 0; i < 8; i++) { cr |= env->crf[i] << (32 - ((i + 1) * 4)); } - gdb_get_reg32(mem_buf, cr); + gdb_get_reg32(buf, cr); break; } case 67: - gdb_get_regl(mem_buf, env->lr); + gdb_get_regl(buf, env->lr); break; case 68: - gdb_get_regl(mem_buf, env->ctr); + gdb_get_regl(buf, env->ctr); break; case 69: - gdb_get_reg32(mem_buf, env->xer); + gdb_get_reg32(buf, env->xer); break; case 70: - gdb_get_reg32(mem_buf, env->fpscr); + gdb_get_reg32(buf, env->fpscr); break; } } + mem_buf = buf->data + buf->len - r; ppc_maybe_bswap_register(env, mem_buf, r); return r; } -int ppc_cpu_gdb_read_register_apple(CPUState *cs, uint8_t *mem_buf, int n) +int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; + uint8_t *mem_buf; int r = ppc_gdb_register_len_apple(n); if (!r) { @@ -178,21 +181,21 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, uint8_t *mem_buf, int n) if (n < 32) { /* gprs */ - gdb_get_reg64(mem_buf, env->gpr[n]); + gdb_get_reg64(buf, env->gpr[n]); } else if (n < 64) { /* fprs */ - stfq_p(mem_buf, *cpu_fpr_ptr(env, n - 32)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32)); } else if (n < 96) { /* Altivec */ - stq_p(mem_buf, n - 64); - stq_p(mem_buf + 8, 0); + gdb_get_reg64(buf, n - 64); + gdb_get_reg64(buf, 0); } else { switch (n) { case 64 + 32: - gdb_get_reg64(mem_buf, env->nip); + gdb_get_reg64(buf, env->nip); break; case 65 + 32: - gdb_get_reg64(mem_buf, env->msr); + gdb_get_reg64(buf, env->msr); break; case 66 + 32: { @@ -201,23 +204,24 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, uint8_t *mem_buf, int n) for (i = 0; i < 8; i++) { cr |= env->crf[i] << (32 - ((i + 1) * 4)); } - gdb_get_reg32(mem_buf, cr); + gdb_get_reg32(buf, cr); break; } case 67 + 32: - gdb_get_reg64(mem_buf, env->lr); + gdb_get_reg64(buf, env->lr); break; case 68 + 32: - gdb_get_reg64(mem_buf, env->ctr); + gdb_get_reg64(buf, env->ctr); break; case 69 + 32: - gdb_get_reg32(mem_buf, env->xer); + gdb_get_reg32(buf, env->xer); break; case 70 + 32: - gdb_get_reg64(mem_buf, env->fpscr); + gdb_get_reg64(buf, env->fpscr); break; } } + mem_buf = buf->data + buf->len - r; ppc_maybe_bswap_register(env, mem_buf, r); return r; } diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c index 53995f62eab..04ad54cff69 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -9857,7 +9857,7 @@ static int gdb_find_spr_idx(CPUPPCState *env, int n) return -1; } -static int gdb_get_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_spr_reg(CPUPPCState *env, GByteArray *buf, int n) { int reg; int len; @@ -9868,8 +9868,8 @@ static int gdb_get_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) } len = TARGET_LONG_SIZE; - stn_p(mem_buf, len, env->spr[reg]); - ppc_maybe_bswap_register(env, mem_buf, len); + gdb_get_regl(buf, env->spr[reg]); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, len), len); return len; } @@ -9891,15 +9891,18 @@ static int gdb_set_spr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) } #endif -static int gdb_get_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n) { + uint8_t *mem_buf; if (n < 32) { - stfq_p(mem_buf, *cpu_fpr_ptr(env, n)); + gdb_get_reg64(buf, *cpu_fpr_ptr(env, n)); + mem_buf = gdb_get_reg_ptr(buf, 8); ppc_maybe_bswap_register(env, mem_buf, 8); return 8; } if (n == 32) { - stl_p(mem_buf, env->fpscr); + gdb_get_reg32(buf, env->fpscr); + mem_buf = gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } @@ -9921,28 +9924,31 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n) { + uint8_t *mem_buf; + if (n < 32) { ppc_avr_t *avr = cpu_avr_ptr(env, n); if (!avr_need_swap(env)) { - stq_p(mem_buf, avr->u64[0]); - stq_p(mem_buf + 8, avr->u64[1]); + gdb_get_reg128(buf, avr->u64[0] , avr->u64[1]); } else { - stq_p(mem_buf, avr->u64[1]); - stq_p(mem_buf + 8, avr->u64[0]); + gdb_get_reg128(buf, avr->u64[1] , avr->u64[0]); } + mem_buf = gdb_get_reg_ptr(buf, 16); ppc_maybe_bswap_register(env, mem_buf, 8); ppc_maybe_bswap_register(env, mem_buf + 8, 8); return 16; } if (n == 32) { - stl_p(mem_buf, helper_mfvscr(env)); + gdb_get_reg32(buf, helper_mfvscr(env)); + mem_buf = gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } if (n == 33) { - stl_p(mem_buf, (uint32_t)env->spr[SPR_VRSAVE]); + gdb_get_reg32(buf, (uint32_t)env->spr[SPR_VRSAVE]); + mem_buf = gdb_get_reg_ptr(buf, 4); ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } @@ -9977,25 +9983,25 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_spe_reg(CPUPPCState *env, GByteArray *buf, int n) { if (n < 32) { #if defined(TARGET_PPC64) - stl_p(mem_buf, env->gpr[n] >> 32); - ppc_maybe_bswap_register(env, mem_buf, 4); + gdb_get_reg32(buf, env->gpr[n] >> 32); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 4), 4); #else - stl_p(mem_buf, env->gprh[n]); + gdb_get_reg32(buf, env->gprh[n]); #endif return 4; } if (n == 32) { - stq_p(mem_buf, env->spe_acc); - ppc_maybe_bswap_register(env, mem_buf, 8); + gdb_get_reg64(buf, env->spe_acc); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); return 8; } if (n == 33) { - stl_p(mem_buf, env->spe_fscr); - ppc_maybe_bswap_register(env, mem_buf, 4); + gdb_get_reg32(buf, env->spe_fscr); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 4), 4); return 4; } return 0; @@ -10030,11 +10036,11 @@ static int gdb_set_spe_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 0; } -static int gdb_get_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n) +static int gdb_get_vsx_reg(CPUPPCState *env, GByteArray *buf, int n) { if (n < 32) { - stq_p(mem_buf, *cpu_vsrl_ptr(env, n)); - ppc_maybe_bswap_register(env, mem_buf, 8); + gdb_get_reg64(buf, *cpu_vsrl_ptr(env, n)); + ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, 8), 8); return 8; } return 0; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 2f32750f2fb..eba12a86f2e 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -270,7 +270,7 @@ static int csr_register_map[] = { CSR_MHCOUNTEREN, }; -int riscv_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; @@ -301,14 +301,14 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) { if (n < 32) { if (env->misa & RVD) { - return gdb_get_reg64(mem_buf, env->fpr[n]); + return gdb_get_reg64(buf, env->fpr[n]); } if (env->misa & RVF) { - return gdb_get_reg32(mem_buf, env->fpr[n]); + return gdb_get_reg32(buf, env->fpr[n]); } /* there is hole between ft11 and fflags in fpu.xml */ } else if (n < 36 && n > 32) { @@ -322,7 +322,7 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) result = riscv_csrrw_debug(env, n - 33 + csr_register_map[8], &val, 0, 0); if (result == 0) { - return gdb_get_regl(mem_buf, val); + return gdb_get_regl(buf, val); } } return 0; @@ -351,7 +351,7 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_csr(CPURISCVState *env, uint8_t *mem_buf, int n) +static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) { if (n < ARRAY_SIZE(csr_register_map)) { target_ulong val = 0; @@ -359,7 +359,7 @@ static int riscv_gdb_get_csr(CPURISCVState *env, uint8_t *mem_buf, int n) result = riscv_csrrw_debug(env, csr_register_map[n], &val, 0, 0); if (result == 0) { - return gdb_get_regl(mem_buf, val); + return gdb_get_regl(buf, val); } } return 0; @@ -379,13 +379,13 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) return 0; } -static int riscv_gdb_get_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n) +static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n) { if (n == 0) { #ifdef CONFIG_USER_ONLY - return gdb_get_regl(mem_buf, 0); + return gdb_get_regl(buf, 0); #else - return gdb_get_regl(mem_buf, cs->priv); + return gdb_get_regl(buf, cs->priv); #endif } return 0; diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index e24a49f4a91..d6fce5ff1e1 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -27,7 +27,7 @@ #include "sysemu/hw_accel.h" #include "sysemu/tcg.h" -int s390_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; @@ -82,11 +82,11 @@ int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) /* total number of registers in s390-acr.xml */ #define S390_NUM_AC_REGS 16 -static int cpu_read_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_ac_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_A0_REGNUM ... S390_A15_REGNUM: - return gdb_get_reg32(mem_buf, env->aregs[n]); + return gdb_get_reg32(buf, env->aregs[n]); default: return 0; } @@ -111,13 +111,13 @@ static int cpu_write_ac_reg(CPUS390XState *env, uint8_t *mem_buf, int n) /* total number of registers in s390-fpr.xml */ #define S390_NUM_FP_REGS 17 -static int cpu_read_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_fp_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_FPC_REGNUM: - return gdb_get_reg32(mem_buf, env->fpc); + return gdb_get_reg32(buf, env->fpc); case S390_F0_REGNUM ... S390_F15_REGNUM: - return gdb_get_reg64(mem_buf, *get_freg(env, n - S390_F0_REGNUM)); + return gdb_get_reg64(buf, *get_freg(env, n - S390_F0_REGNUM)); default: return 0; } @@ -145,17 +145,17 @@ static int cpu_write_fp_reg(CPUS390XState *env, uint8_t *mem_buf, int n) /* total number of registers in s390-vx.xml */ #define S390_NUM_VREGS 32 -static int cpu_read_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_vreg(CPUS390XState *env, GByteArray *buf, int n) { int ret; switch (n) { case S390_V0L_REGNUM ... S390_V15L_REGNUM: - ret = gdb_get_reg64(mem_buf, env->vregs[n][1]); + ret = gdb_get_reg64(buf, env->vregs[n][1]); break; case S390_V16_REGNUM ... S390_V31_REGNUM: - ret = gdb_get_reg64(mem_buf, env->vregs[n][0]); - ret += gdb_get_reg64(mem_buf + 8, env->vregs[n][1]); + ret = gdb_get_reg64(buf, env->vregs[n][0]); + ret += gdb_get_reg64(buf, env->vregs[n][1]); break; default: ret = 0; @@ -186,11 +186,11 @@ static int cpu_write_vreg(CPUS390XState *env, uint8_t *mem_buf, int n) #define S390_NUM_C_REGS 16 #ifndef CONFIG_USER_ONLY -static int cpu_read_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_c_reg(CPUS390XState *env, GByteArray *buf, int n) { switch (n) { case S390_C0_REGNUM ... S390_C15_REGNUM: - return gdb_get_regl(mem_buf, env->cregs[n]); + return gdb_get_regl(buf, env->cregs[n]); default: return 0; } @@ -223,7 +223,7 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n) /* total number of registers in s390-virt.xml */ #define S390_NUM_VIRT_REGS 8 -static int cpu_read_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int n) { switch (n) { case S390_VIRT_CKC_REGNUM: @@ -296,9 +296,9 @@ static int cpu_write_virt_reg(CPUS390XState *env, uint8_t *mem_buf, int n) /* total number of registers in s390-gs.xml */ #define S390_NUM_GS_REGS 4 -static int cpu_read_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) +static int cpu_read_gs_reg(CPUS390XState *env, GByteArray *buf, int n) { - return gdb_get_regl(mem_buf, env->gscb[n]); + return gdb_get_regl(buf, env->gscb[n]); } static int cpu_write_gs_reg(CPUS390XState *env, uint8_t *mem_buf, int n) diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 44c1679e9db..49fc4a0cc69 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -24,7 +24,7 @@ /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ /* FIXME: We should use XML for this. */ -int superh_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { SuperHCPU *cpu = SUPERH_CPU(cs); CPUSH4State *env = &cpu->env; diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index 8be742b5a3d..78dc8dcc980 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -27,7 +27,7 @@ #define gdb_get_rega(buf, val) gdb_get_regl(buf, val) #endif -int sparc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index 54727881f38..0ee3feabe54 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -63,7 +63,7 @@ void xtensa_count_regs(const XtensaConfig *config, } } -int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) +int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { XtensaCPU *cpu = XTENSA_CPU(cs); CPUXtensaState *env = &cpu->env; From patchwork Tue Mar 17 17:50:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184653 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4439883ile; Tue, 17 Mar 2020 11:00:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt0N4Xh2SuSVDo+j1+FJ67JDjSph9eYHK2HoSFu/jFipN5L4ODnfNalMlWPS4rfbq5L8CHx X-Received: by 2002:a05:620a:200d:: with SMTP id c13mr90743qka.240.1584468040961; Tue, 17 Mar 2020 11:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468040; cv=none; d=google.com; s=arc-20160816; b=oIm2Is23o27F6VAao2ht7Q/R08i0+Kz7uJ1DfKDbFLTRZSUXRwNFpG9t765zbHwwNi 52laDaBUprLxoE+hUKxl0hS3jwc8g6mdsOmsD4kdxsPFxXPqCXoh7qviDPYFbZsnsKyE uPl5wWn29PYEozEMWlzFKZdQib2TZUmmPbpDE3iI4644At3zF+QX/9A1QPRfsXx5ZQum 2sHUqko4fXnYHvcbENXWdQvSH2yjr6KOEIJ6WBdGkKQiIzN9XA4XvcoS6cGnp51AV7M8 X48WF9KoCjbgffU0WK3DXUWH+jPU+x744/RW76PRqDjYdj3b8vfHLbdBsFkzO0yxYh35 It2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KRu/hQdw0xxxfyyGNoQ9AeZ+IGpH7Hzuo3e1uXmI2BY=; b=r7/fFvCTQov1KTGNyB90gYPDtFac4paEGj5+VWgpdQqVYj1qTL6Vdb43bicSXqcom7 YF0AW1u1qEntI2lIiTMvVM/yUFi2FUNjrlUXnHd7i5jnY8aMtNcYJ5/lIb8/VCvRbV4J aE33l/u1XvEdNxRUKJyk2VisKxsrAXf3RYdZesON9Vt3CJb1RrzFW4SwUi3Sl9Tn+ygS CrHb3rIXnt02nOLzl4D8WtxcrcJRwwVBk5l1QI2Xk1AY3oKa/5HmCLTZejcuINl55ot7 +DLlPK8ei1KvwkMuwlKk9OLkI3lPuE0Eix5ZEkBGkXTp5oEWm97gKE+VANRc+0E4M64x txLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EAyFhBBO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y130si2593386qkb.133.2020.03.17.11.00.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EAyFhBBO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGW8-0007Ai-C9 for patch@linaro.org; Tue, 17 Mar 2020 14:00:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57208) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN3-0000gR-Mw for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN2-0003Ii-2R for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:17 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:39901) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGN1-0003DD-R1 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:16 -0400 Received: by mail-wr1-x434.google.com with SMTP id h6so6538809wrs.6 for ; Tue, 17 Mar 2020 10:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KRu/hQdw0xxxfyyGNoQ9AeZ+IGpH7Hzuo3e1uXmI2BY=; b=EAyFhBBOR3t01CO9uElCTQsXLQg5qlfH7wzR75bJc69xi4GSSNHC/pjrR+MLxGsu1t d2aKPpSF65r21cYgW3rwPjkurB1lEQ8tob8DmgL3F6PJrQ+76vAzESDvwOlMtFZBPMpi EZF/xbWcxIP9+PT7H45V2fgi1s83H1hwLEvdPB4pebExbKizskrQow9WrtPkwyLn4MKL +kJKdI9+TTRSY43+ygd7nrhzUwaWbuWDnWPm4wXptjFPjA+fBujuLEpYKkQOnuOY1Yg5 8mGYzigC+KYjx1yzqxFtHaG+8NaLPrvVjOtDdPtM71R75UEy6YpEPatVSAJ/vHVn/Dv4 4siQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KRu/hQdw0xxxfyyGNoQ9AeZ+IGpH7Hzuo3e1uXmI2BY=; b=eQxitGQPz6mu1gyB5G7M9DtV4EX4EuWcn4FZ9IEN4/ckWMpNVeTvS+LFFDoSlOZ8ri I3ndsvT4QKWIlBI22faoeYiUtgWWd6K5fwgsLu2foO36NIFL4rm+6HirRCpjDEYQO3sD J4V7aoRuAcZ+c5v4rSXBQbbDfvZCP3p3MiGsUlxC2Lhrhq2Clg1i2JWEUxXXEsx/zKt5 ReD4wvIqqmk3RddBjKXjKHERrVob0Bh8krJ9K+Xj1UhqWkuP/iE68OETpc9TOMaI872D RIx7NFRM+5gxJW8hiGWKVFAmLWSJapXiTm0tNdOGdsfN5aBd8q7ccIEQTWhXXVM8OdAn 4gmA== X-Gm-Message-State: ANhLgQ2ISi4rwI3Y/j7ZCYjyho5rfJQGF4yfMwsCM4p5P+GKRopWS0br 2GIUccdwbKu1ou6fTEDaPXZXo8uIgoQ= X-Received: by 2002:adf:ab54:: with SMTP id r20mr139232wrc.197.1584467474758; Tue, 17 Mar 2020 10:51:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n2sm5729685wrr.62.2020.03.17.10.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E66BD1FF9E; Tue, 17 Mar 2020 17:50:54 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 15/28] target/arm: prepare for multiple dynamic XMLs Date: Tue, 17 Mar 2020 17:50:40 +0000 Message-Id: <20200317175053.5278-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will want to generate similar dynamic XML for gdbstub support of SVE registers (the upstream doesn't use XML). To that end lightly rename a few things to make the distinction. Signed-off-by: Alex Bennée Acked-by: Richard Henderson Message-Id: <20200316172155.971-16-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4ab2cbfd417..0ab82c987c3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -128,14 +128,20 @@ enum { /** * DynamicGDBXMLInfo: * @desc: Contains the XML descriptions. - * @num_cpregs: Number of the Coprocessor registers seen by GDB. - * @cpregs_keys: Array that contains the corresponding Key of - * a given cpreg with the same order of the cpreg in the XML description. + * @num: Number of the registers in this XML seen by GDB. + * @data: A union with data specific to the set of registers + * @cpregs_keys: Array that contains the corresponding Key of + * a given cpreg with the same order of the cpreg + * in the XML description. */ typedef struct DynamicGDBXMLInfo { char *desc; - int num_cpregs; - uint32_t *cpregs_keys; + int num; + union { + struct { + uint32_t *keys; + } cpregs; + } data; } DynamicGDBXMLInfo; /* CPU state for each instance of a generic timer (in cp15 c14) */ @@ -749,7 +755,7 @@ struct ARMCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; - DynamicGDBXMLInfo dyn_xml; + DynamicGDBXMLInfo dyn_sysreg_xml; /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; @@ -974,7 +980,7 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs from * the cp_regs hashtable. Returns the registered sysregs number. */ -int arm_gen_dynamic_xml(CPUState *cpu); +int arm_gen_dynamic_sysreg_xml(CPUState *cpu); /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 4557775d245..1f68ab98c3b 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -106,15 +106,15 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } -static void arm_gen_one_xml_reg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, - ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize) +static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, + ARMCPRegInfo *ri, uint32_t ri_key, + int bitsize) { g_string_append_printf(s, "name); g_string_append_printf(s, " bitsize=\"%d\"", bitsize); g_string_append_printf(s, " group=\"cp_regs\"/>"); - dyn_xml->num_cpregs++; - dyn_xml->cpregs_keys[dyn_xml->num_cpregs - 1] = ri_key; + dyn_xml->data.cpregs.keys[dyn_xml->num] = ri_key; + dyn_xml->num++; } static void arm_register_sysreg_for_xml(gpointer key, gpointer value, @@ -126,12 +126,12 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, GString *s = param->s; ARMCPU *cpu = ARM_CPU(param->cs); CPUARMState *env = &cpu->env; - DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_xml; + DynamicGDBXMLInfo *dyn_xml = &cpu->dyn_sysreg_xml; if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state == ARM_CP_STATE_AA64) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); } } else { if (ri->state == ARM_CP_STATE_AA32) { @@ -140,30 +140,30 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); } else { - arm_gen_one_xml_reg_tag(s , dyn_xml, ri, ri_key, 32); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32); } } } } } -int arm_gen_dynamic_xml(CPUState *cs) +int arm_gen_dynamic_sysreg_xml(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); GString *s = g_string_new(NULL); RegisterSysregXmlParam param = {cs, s}; - cpu->dyn_xml.num_cpregs = 0; - cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); + cpu->dyn_sysreg_xml.num = 0; + cpu->dyn_sysreg_xml.data.cpregs.keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); g_string_printf(s, ""); g_string_append_printf(s, ""); g_string_append_printf(s, ""); g_hash_table_foreach(cpu->cp_regs, arm_register_sysreg_for_xml, ¶m); g_string_append_printf(s, ""); - cpu->dyn_xml.desc = g_string_free(s, false); - return cpu->dyn_xml.num_cpregs; + cpu->dyn_sysreg_xml.desc = g_string_free(s, false); + return cpu->dyn_sysreg_xml.num; } const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) @@ -171,7 +171,7 @@ const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) ARMCPU *cpu = ARM_CPU(cs); if (strcmp(xmlname, "system-registers.xml") == 0) { - return cpu->dyn_xml.desc; + return cpu->dyn_sysreg_xml.desc; } return NULL; } diff --git a/target/arm/helper.c b/target/arm/helper.c index c0e1ba17272..b0e2a85b005 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -208,7 +208,7 @@ static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) const ARMCPRegInfo *ri; uint32_t key; - key = cpu->dyn_xml.cpregs_keys[reg]; + key = cpu->dyn_sysreg_xml.data.cpregs.keys[reg]; ri = get_arm_cp_reginfo(cpu->cp_regs, key); if (ri) { if (cpreg_field_is_64bit(ri)) { @@ -7973,7 +7973,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) 19, "arm-vfp.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_xml(cs), + arm_gen_dynamic_sysreg_xml(cs), "system-registers.xml", 0); } From patchwork Tue Mar 17 17:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184648 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4436699ile; Tue, 17 Mar 2020 10:57:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtCSKBC+HcmXk3Y44EOrOJ72hTulp+9/zbsieW4HAjFRvcx7n4xs60O0vzBoYTQ4jLzugEe X-Received: by 2002:aed:24c2:: with SMTP id u2mr315852qtc.269.1584467845176; Tue, 17 Mar 2020 10:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467845; cv=none; d=google.com; s=arc-20160816; b=sYp7VjC1HZ1mYDC1b08K59cODWqsESCTEOnUxoHwirxmrJxwR8vAryRj185b70D+OV 2qNJjpVrD3JGEPECOlbq4howXGBieyjRpOWypcWhxucw3VSkS0bvV3omVCK+hjqMIFfA VZ05077YgY7ubOg7MyHVLYxfuHewMRTvB9k2n3iwC4bdeZCM8Z5CVMqQj6pOk+Wpbh6O tn2lGYwNuGgm74ZJPIwVw7WCeSp6rBaiPAeTRdYCliMmIgzX7gWEhPeJqZ5SdKsmdz9O IlGamxW6+Fd/bS6yHB6hBxBn0qNdVQKxqBbFomTkujYMhoWiaHd/1i5bdBOOOVEf7bpU 6D+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eaqvREUV5VO11iN7oPytlJwUMSXhsFBqTn8ICBLOQCM=; b=t9mMu9F+LFGz4ozECR/f0I64SiTJtfO102aAPNmlGVfHyP/EKqWd1RammBCy09aOom SR56od7jAmugrBhvjw2FUCHN5QpQgWp8RdHu1WjypcF4gPxuzpQ3r543CRVDPS+Q4WK+ MQvC2W6z36HFDXzq3PG3mgZyvKy1M88dAYSjBdvXZ81u7hmQxSMIjJXlt53p9yHERbSN fhHNaXpsqZ0UhN+TIDZmwHd3C654HCU5S48SJ/IDGLiktKoBe3hZxzrOii1IgSqu0tjD WZhFLrAsTnlwwQabwEeL9ENn7PjVltiRZIdCQz545zpp+Vmre6WR02to8/hfi95nRTwr vuOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g4vBGbR5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r3si2732856qkd.153.2020.03.17.10.57.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g4vBGbR5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGSy-0002Ri-Kj for patch@linaro.org; Tue, 17 Mar 2020 13:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN8-0000qp-2t for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN5-0003kb-R3 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:21 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:38705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGN5-0003eQ-Hj for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:19 -0400 Received: by mail-wr1-x42a.google.com with SMTP id s1so5144015wrv.5 for ; Tue, 17 Mar 2020 10:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eaqvREUV5VO11iN7oPytlJwUMSXhsFBqTn8ICBLOQCM=; b=g4vBGbR5foez/fPhqL3znep8vnpvXRjT6ws79wzJgymHOI+MF18MasIPs5mYg0vLas e05VWFd3I0BFAxy4exIMfTR95kNB32gNCxQTdNm1EL347jBZF7exwc9WhCx6O/alPKPe qBmAzaK5pMRmBb+wilRdgjRLW/+RLOfkp0y/Ztu0oHinxMy88Cwmoy20oz3b0hsXuECs 5dXB2v0ekM23UF84dmZoEgpCYABuuEQnTvO9F9coJ91bTqx42U3yZgDsJdtPZodt803B q3La1a+jNwGq6xBTsVNHcqVmor2z0N2Fl7WcNmU5otSAAdRuTMDwaKcS9w0/bXmu86mD GGlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eaqvREUV5VO11iN7oPytlJwUMSXhsFBqTn8ICBLOQCM=; b=NitiDcSAh6ZigbDioTL1k/h+IPeIJORc4tUnG2kY1p7VjlVHRBULZR/idYR0Ujbmqv fMwP7i+LpyllM6P2BYy+PVbTviBNm/VZrqFXqfzXIyvoKQagb8ghbgfTJ9BW8gMIENKX mssPWy82TZUwSbaxGN8e+QciFMipTQ6HQ4V05AqDOCFZ+mrNOyvYge63zA8bAjInD4qK +Fw9THWeEjmtKisb/gnFFJq/NqdamsZfGbCE3Y1cI9w4m2LCqWEMnTZaNMWMJTTDjYW5 KqjGs2snyoG74lVycGe76xOcQIZoJzCSKwFdVe0PqZJDGz36OT1Po+ijONfeyKeTXDKX Jm7w== X-Gm-Message-State: ANhLgQ1QH0ILkDd6MxLXKLTm6maTkPPzTfgfNGWzsq+kuZGWyQIhPM1J zGbV1GsYrSaLwpDt9kYr2aIK3Q== X-Received: by 2002:adf:c44c:: with SMTP id a12mr198782wrg.172.1584467478348; Tue, 17 Mar 2020 10:51:18 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 98sm5388291wrk.52.2020.03.17.10.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0B5F31FF9F; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 16/28] target/arm: explicitly encode regnum in our XML Date: Tue, 17 Mar 2020 17:50:41 +0000 Message-Id: <20200317175053.5278-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is described as optional but I'm not convinced of the numbering when multiple target fragments are sent. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-17-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0ab82c987c3..fbfd73a7b5b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -980,7 +980,7 @@ int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); /* Dynamically generates for gdb stub an XML description of the sysregs from * the cp_regs hashtable. Returns the registered sysregs number. */ -int arm_gen_dynamic_sysreg_xml(CPUState *cpu); +int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 1f68ab98c3b..69c35462a63 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -24,6 +24,7 @@ typedef struct RegisterSysregXmlParam { CPUState *cs; GString *s; + int n; } RegisterSysregXmlParam; /* Old gdb always expect FPA registers. Newer (xml-aware) gdb only expect @@ -108,10 +109,11 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml, ARMCPRegInfo *ri, uint32_t ri_key, - int bitsize) + int bitsize, int regnum) { g_string_append_printf(s, "name); g_string_append_printf(s, " bitsize=\"%d\"", bitsize); + g_string_append_printf(s, " regnum=\"%d\"", regnum); g_string_append_printf(s, " group=\"cp_regs\"/>"); dyn_xml->data.cpregs.keys[dyn_xml->num] = ri_key; dyn_xml->num++; @@ -131,7 +133,8 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state == ARM_CP_STATE_AA64) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + param->n++); } } else { if (ri->state == ARM_CP_STATE_AA32) { @@ -140,20 +143,22 @@ static void arm_register_sysreg_for_xml(gpointer key, gpointer value, return; } if (ri->type & ARM_CP_64BIT) { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 64, + param->n++); } else { - arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32); + arm_gen_one_xml_sysreg_tag(s , dyn_xml, ri, ri_key, 32, + param->n++); } } } } } -int arm_gen_dynamic_sysreg_xml(CPUState *cs) +int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) { ARMCPU *cpu = ARM_CPU(cs); GString *s = g_string_new(NULL); - RegisterSysregXmlParam param = {cs, s}; + RegisterSysregXmlParam param = {cs, s, base_reg}; cpu->dyn_sysreg_xml.num = 0; cpu->dyn_sysreg_xml.data.cpregs.keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); diff --git a/target/arm/helper.c b/target/arm/helper.c index b0e2a85b005..90135731353 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7973,7 +7973,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) 19, "arm-vfp.xml", 0); } gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, - arm_gen_dynamic_sysreg_xml(cs), + arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), "system-registers.xml", 0); } From patchwork Tue Mar 17 17:50:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184662 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4452291ile; Tue, 17 Mar 2020 11:11:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv4K9GqI2Zjaao9bPZwe/BQ+41JneRqu4tYadk5J5kyTgt8VxjeGc8hgxGCfC0IM4CL+VPy X-Received: by 2002:a37:7a04:: with SMTP id v4mr131866qkc.340.1584468692169; Tue, 17 Mar 2020 11:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468692; cv=none; d=google.com; s=arc-20160816; b=Qa2mAdwSbG/9YPlf1K4NK2eEl6yomgc0XD7zv+dtCdyu6LV+fZ7+8nDw4ZRZA4KELm JnlKckbTKMTQ+H99sm4tYCgCTCKWsg+1E4UzUuoiOEdLc3+BekR/xzVebchvFZjYchw1 D79cxVDhUQrOp6xLiR9/KwlF7v4Ys3JjYWJXspGiKW63DKHTlPp8mVkgHoFCTVmsWxEY S6w6Hw/Q5MCC1Ll7/59vcNPSZ6QlA+m443xFjxp49EmX7YY+781IerQpifa8et2TUtze HtZqCFv76VQ8VndscL9iYWi/8DbT/w5HI8mxpB/5SlSvhKOpwoKW9DPmeNWxF5anufof BkRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=M48cU5ZUp7kKc2JaWuC8XHAXXhtPfcdV39imYH+qaek=; b=Xrtis5I2EFfS7W+22wyoT+bZJ1n4ZI6REuW04GfNFi5XF/68PZxDLp1llPXM+rpPpK yQb+04qHc5q58ydrfBIzqssMqeQLyDvSokaDEhinCFAY7lvEsaTOq2PBoywK497EdvdP Oq8WJnphwPzTa2CenmvRjF/W2LAhl5lFihbVsn60zEKcjzatnQieMt+l18dnkClH+Jgq e6NbKfMpzFlxiT8NHTe/1LdaUsB+yGXb1nY64rnpxaWixp+b8AJhTTcUeRjOpR+LVxyq 4qNR8lcBqbRPpqmv3e3FIgdi9XXzmNxXgS1KU1MhLidE/oemNyMsMYFPDxhZK6WaamNz hbWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VGczjF6f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s43si2427896qtj.330.2020.03.17.11.11.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VGczjF6f; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGgd-00041l-EM for patch@linaro.org; Tue, 17 Mar 2020 14:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36898) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUb-0005pJ-87 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUa-00012P-4v for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:05 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36506) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUZ-0000xO-Tf for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:04 -0400 Received: by mail-wm1-x342.google.com with SMTP id g62so284791wme.1 for ; Tue, 17 Mar 2020 10:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M48cU5ZUp7kKc2JaWuC8XHAXXhtPfcdV39imYH+qaek=; b=VGczjF6fWuU01syDM+MwafszV7e942MfzTNFFU+dND1iId9lkr7VUSDsJNYet3eOIU 0u76opveYLEtiKZEwAHUpWCOFfvuCxPBQHXgm0ucA2WF7Mrwb2hBmoqZTsLoto/JBU6f n/o+VAdRREoC+nguDZ3IKch6eZ9n8iP1BSq3BF5R3yE+BebltDh1IwCbSH6H+vGccEZH mB93aqe5YG/Gp9r17KEY3BXEROTq5TQIu9F2D2BBdo/5vM6SmuNiD6GMRMDHzg5y4m4j gWAlhevT3a9YddQ1LZND2qR/AIoZ5sDXYtClrW5bYiuHlL7W83hw7kInblpU8Me/vNBw 2fDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M48cU5ZUp7kKc2JaWuC8XHAXXhtPfcdV39imYH+qaek=; b=pYaBKITRE63TP0pnqrcWCu9H11193tETHRWQRlG3KH66wAyYKEKDyoDdLtrfYkfsnE nr5PZpr3qW9+O4Ct4Ua3sYGsUehunNlbLwXjhTWlx4t0dQ2vUBIFy6BJPXOHLAamk2oQ QCz1iNq+HL+iEhO5pDOy06tjeTt4R1XH83G3UeNuNQ5ypHHAwRL5igwS2HX1q6mRpqfv ytsP+tj6Q4DZYm1s5mImSidLwTACT+jVC8knzxortc8iAi4m1jC8wuBub6+1zZUMZhxJ Uwabmge0pmrpU2iAyHs0lBY6ZtBc+fhL1caGqkodsRQLub+7Be5wwvoz1IKFQhcIy5b4 sf9Q== X-Gm-Message-State: ANhLgQ23YdsYvjnPc8gvxW1OXdx7OdkE4vJyTYbB8yw/PFLaDjJ9bG9S ez7siuKyTN3Xn+25j8vv/NqykQ== X-Received: by 2002:a1c:de41:: with SMTP id v62mr236590wmg.60.1584467942841; Tue, 17 Mar 2020 10:59:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q8sm251177wmg.6.2020.03.17.10.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2112D1FFA5; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 17/28] target/arm: default SVE length to 64 bytes for linux-user Date: Tue, 17 Mar 2020 17:50:42 +0000 Message-Id: <20200317175053.5278-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Linux kernel chooses the default of 64 bytes for SVE registers on the basis that it is the largest size on known hardware that won't grow the signal frame. We still honour the sve-max-vq property and userspace can expand the number of lanes by calling PR_SVE_SET_VL. This should not make any difference to SVE enabled software as the SVE is of course vector length agnostic. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-18-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 3623ecefbd9..0909ce86a12 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -195,9 +195,10 @@ static void arm_cpu_reset(CPUState *s) env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); /* and to the SVE instructions */ env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); - /* with maximum vector length */ - env->vfp.zcr_el[1] = cpu_isar_feature(aa64_sve, cpu) ? - cpu->sve_max_vq - 1 : 0; + /* with reasonable vector length */ + if (cpu_isar_feature(aa64_sve, cpu)) { + env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); + } /* * Enable TBI0 and TBI1. While the real kernel only enables TBI0, * turning on both here will produce smaller code and otherwise From patchwork Tue Mar 17 17:50:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184659 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4449993ile; Tue, 17 Mar 2020 11:09:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vucoTxujIU0FbJ08fLWKU27QYGQV2C3lsfTROsI+xU0wf8lmhxuhrZ6MFTVNELsccClzNKu X-Received: by 2002:a05:6214:186f:: with SMTP id eh15mr345310qvb.249.1584468555549; Tue, 17 Mar 2020 11:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468555; cv=none; d=google.com; s=arc-20160816; b=wDlSYPJHJD3+sfF0QyipQHxbQ6VIqDf4kDsKJjRXL8jdCAtbB4f/tC5HFn2dy9XtWm z2yMHm4wVWtDw/p+jY3LJxemvMqO7XkVqAirk0S1ZFHgJKePOcq50LWdbk163rQLXpcX /arwRXAuDK9cUyDeK5P1FmefQngHutYuPp75n9c1M/R0p47WhbsylrywFP9qyBNh5OHX 65IZGalmbYZzCDxpknxcm8NGwE6DdOy0gMylOBLYi5VDc84pD0txG99O72L/TQTmfThL Ye69WhFRaEnbExGZP2Bru+RZjQ38NrS0C198/IByUhcZnGT2U6kklkqxVzBDTcViTkhC sUoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cu3KUkXmnV78ecgw6EvvkNrK6dkOUBK9syUxYkP1nbE=; b=OzbaYeXPNZUNFkuyQJiyDItZ3j8P35uVe0r+DzT55zaFd1gyiyuG+xbOsnJ7t18qVW 1aIon0i45tUiygbsHVIRQpHbLgLe72QA2j38WQhEE9tOz9p++bVV+6Cxv4vsMGR1xopz hBb9vt+e3Ff4d2oXtlEwIawpeou42Q2Gf1YeCUWRmmRtnlT0jiHW8O2j08tChhVttZ6b 5AjkHJPT0Fa9zDjihfGknyxQUSqLR+G1uyqPDfycvD+GRdDnFfMtQ76GNpAIh5mfOZRV Rou3YENYzrpAkWAX3cv2W2Cbk1AtVzP6xcEqoa94a+yszEu2XZYAcheqgjvF/PvlFrLR d+sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b+4nsU1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x36si2309640qtd.247.2020.03.17.11.09.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b+4nsU1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGeR-0000yX-0U for patch@linaro.org; Tue, 17 Mar 2020 14:09:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUT-0005XD-6E for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUQ-0008Ty-U2 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:57 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:40301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUQ-0008Ir-2G for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:54 -0400 Received: by mail-wr1-x434.google.com with SMTP id f3so19943899wrw.7 for ; Tue, 17 Mar 2020 10:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cu3KUkXmnV78ecgw6EvvkNrK6dkOUBK9syUxYkP1nbE=; b=b+4nsU1HdCgTCHNgwH/mMSr560Y46IzRpStCHJo1JOKUN9k8IaoFuokNud9pTpyKel 7i4tesc1BC2CoAckJCmyQISIMiqebHJcRd+0BcSiiiINxrtd5tbFadqt3geALwKSyrPK W6fV109fNvzf3Vb62QMjEo4aXjtcTR/GBcOh/5iaTsziNuQFsA39IU/KJKrfd5j1G7lI 2WZ0fRoesXJprJEcAQOAa1HgBLyDz3wPQcORFs4gdhJ1h4DXww0fN+ENJYlQ4Czh3PdK bdrkTGid8WI1aG/50vEHtf/N4pbTOR+Xf/KgPRWtWF0W6+wLKSRl2i1mNajOMYpk6Ilb F+NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cu3KUkXmnV78ecgw6EvvkNrK6dkOUBK9syUxYkP1nbE=; b=hlgW5e0gAfcj6FqFHvi6/9oEmmZr8zw0vaYREBnGh69gjyf/6GN3bM++8TosHAqyOH dXCelZXGAgRCqHGP0/rlheTdyF5PO9znAB5Rl93Robzyl6wxGkCGqPRCJrPvWrUrHbJC YFw9IPPRS6Va8yLEdk8XAgaPAr+Li+ouMwgazD2+Vf+Bmodr4u0caTkLEwgk2axV5/hj ZZ/bPT1Ba57ere7RFU1NgQj6D+N1v+TqbmOn88Fzo3YicUP5bHqaO+wfiZ2a33a7beMI YyUN8/DOsWTL9SGSo/xivizMwD8BPrPyGtvpPWhc8a5HtQRjKM9Li1aoI57NgCCxEeUl zqDw== X-Gm-Message-State: ANhLgQ3cQSnqDXHwMe7LezEwoRqi4E9PmsQb+VIz1lPcef0JtVrG0/TX tbg1aXtH+Ycs7mmABKogXbcJfg== X-Received: by 2002:a5d:5504:: with SMTP id b4mr164838wrv.181.1584467930676; Tue, 17 Mar 2020 10:58:50 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b10sm5676766wrm.30.2020.03.17.10.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3949B1FFA6; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 18/28] target/arm: generate xml description of our SVE registers Date: Tue, 17 Mar 2020 17:50:43 +0000 Message-Id: <20200317175053.5278-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We also expose a the helpers to read/write the the registers. Signed-off-by: Alex Bennée Acked-by: Richard Henderson Message-Id: <20200316172155.971-19-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index fbfd73a7b5b..8b9f2961ba0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -756,6 +756,7 @@ struct ARMCPU { int32_t cpreg_vmstate_array_len; DynamicGDBXMLInfo dyn_sysreg_xml; + DynamicGDBXMLInfo dyn_svereg_xml; /* Timers used by the generic (architected) timer */ QEMUTimer *gt_timer[NUM_GTIMERS]; @@ -977,10 +978,12 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, int arm_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int arm_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -/* Dynamically generates for gdb stub an XML description of the sysregs from - * the cp_regs hashtable. Returns the registered sysregs number. +/* + * Helpers to dynamically generates XML descriptions of the sysregs + * and SVE registers. Returns the number of registers in each set. */ int arm_gen_dynamic_sysreg_xml(CPUState *cpu, int base_reg); +int arm_gen_dynamic_svereg_xml(CPUState *cpu, int base_reg); /* Returns the dynamically generated XML for the gdb stub. * Returns a pointer to the XML contents for the specified XML file or NULL diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 69c35462a63..d9ef7d2187c 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -171,12 +171,146 @@ int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg) return cpu->dyn_sysreg_xml.num; } +struct TypeSize { + const char *gdb_type; + int size; + const char sz, suffix; +}; + +static const struct TypeSize vec_lanes[] = { + /* quads */ + { "uint128", 128, 'q', 'u' }, + { "int128", 128, 'q', 's' }, + /* 64 bit */ + { "uint64", 64, 'd', 'u' }, + { "int64", 64, 'd', 's' }, + { "ieee_double", 64, 'd', 'f' }, + /* 32 bit */ + { "uint32", 32, 's', 'u' }, + { "int32", 32, 's', 's' }, + { "ieee_single", 32, 's', 'f' }, + /* 16 bit */ + { "uint16", 16, 'h', 'u' }, + { "int16", 16, 'h', 's' }, + { "ieee_half", 16, 'h', 'f' }, + /* bytes */ + { "uint8", 8, 'b', 'u' }, + { "int8", 8, 'b', 's' }, +}; + + +int arm_gen_dynamic_svereg_xml(CPUState *cs, int base_reg) +{ + ARMCPU *cpu = ARM_CPU(cs); + GString *s = g_string_new(NULL); + DynamicGDBXMLInfo *info = &cpu->dyn_svereg_xml; + g_autoptr(GString) ts = g_string_new(""); + int i, bits, reg_width = (cpu->sve_max_vq * 128); + info->num = 0; + g_string_printf(s, ""); + g_string_append_printf(s, ""); + g_string_append_printf(s, ""); + + /* First define types and totals in a whole VL */ + for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { + int count = reg_width / vec_lanes[i].size; + g_string_printf(ts, "vq%d%c%c", count, + vec_lanes[i].sz, vec_lanes[i].suffix); + g_string_append_printf(s, + "", + ts->str, vec_lanes[i].gdb_type, count); + } + /* + * Now define a union for each size group containing unsigned and + * signed and potentially float versions of each size from 128 to + * 8 bits. + */ + for (bits = 128; bits >= 8; bits /= 2) { + int count = reg_width / bits; + g_string_append_printf(s, "", count); + for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { + if (vec_lanes[i].size == bits) { + g_string_append_printf(s, "", + vec_lanes[i].suffix, + count, + vec_lanes[i].sz, vec_lanes[i].suffix); + } + } + g_string_append(s, ""); + } + /* And now the final union of unions */ + g_string_append(s, ""); + for (bits = 128; bits >= 8; bits /= 2) { + int count = reg_width / bits; + for (i = 0; i < ARRAY_SIZE(vec_lanes); i++) { + if (vec_lanes[i].size == bits) { + g_string_append_printf(s, "", + vec_lanes[i].sz, count); + break; + } + } + } + g_string_append(s, ""); + + /* Then define each register in parts for each vq */ + for (i = 0; i < 32; i++) { + g_string_append_printf(s, + "", + i, reg_width, base_reg++); + info->num++; + } + /* fpscr & status registers */ + g_string_append_printf(s, "", base_reg++); + g_string_append_printf(s, "", base_reg++); + info->num += 2; + /* + * Predicate registers aren't so big they are worth splitting up + * but we do need to define a type to hold the array of quad + * references. + */ + g_string_append_printf(s, + "", + cpu->sve_max_vq); + for (i = 0; i < 16; i++) { + g_string_append_printf(s, + "", + i, cpu->sve_max_vq * 16, base_reg++); + info->num++; + } + g_string_append_printf(s, + "", + cpu->sve_max_vq * 16, base_reg++); + g_string_append_printf(s, + "", + base_reg++); + info->num += 2; + g_string_append_printf(s, ""); + cpu->dyn_svereg_xml.desc = g_string_free(s, false); + + return cpu->dyn_svereg_xml.num; +} + + const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname) { ARMCPU *cpu = ARM_CPU(cs); if (strcmp(xmlname, "system-registers.xml") == 0) { return cpu->dyn_sysreg_xml.desc; + } else if (strcmp(xmlname, "sve-registers.xml") == 0) { + return cpu->dyn_svereg_xml.desc; } return NULL; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 90135731353..7e560ea7db6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -202,6 +202,15 @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, } } +/** + * arm_get/set_gdb_*: get/set a gdb register + * @env: the CPU state + * @buf: a buffer to copy to/from + * @reg: register number (offset from start of group) + * + * We return the number of bytes copied + */ + static int arm_gdb_get_sysreg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu = env_archcpu(env); @@ -225,6 +234,102 @@ static int arm_gdb_set_sysreg(CPUARMState *env, uint8_t *buf, int reg) return 0; } +#ifdef TARGET_AARCH64 +static int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg) +{ + ARMCPU *cpu = env_archcpu(env); + + switch (reg) { + /* The first 32 registers are the zregs */ + case 0 ... 31: + { + int vq, len = 0; + for (vq = 0; vq < cpu->sve_max_vq; vq++) { + len += gdb_get_reg128(buf, + env->vfp.zregs[reg].d[vq * 2 + 1], + env->vfp.zregs[reg].d[vq * 2]); + } + return len; + } + case 32: + return gdb_get_reg32(buf, vfp_get_fpsr(env)); + case 33: + return gdb_get_reg32(buf, vfp_get_fpcr(env)); + /* then 16 predicates and the ffr */ + case 34 ... 50: + { + int preg = reg - 34; + int vq, len = 0; + for (vq = 0; vq < cpu->sve_max_vq; vq = vq + 4) { + len += gdb_get_reg64(buf, env->vfp.pregs[preg].p[vq / 4]); + } + return len; + } + case 51: + { + /* + * We report in Vector Granules (VG) which is 64bit in a Z reg + * while the ZCR works in Vector Quads (VQ) which is 128bit chunks. + */ + int vq = sve_zcr_len_for_el(env, arm_current_el(env)) + 1; + return gdb_get_reg32(buf, vq * 2); + } + default: + /* gdbstub asked for something out our range */ + qemu_log_mask(LOG_UNIMP, "%s: out of range register %d", __func__, reg); + break; + } + + return 0; +} + +static int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg) +{ + ARMCPU *cpu = env_archcpu(env); + + /* The first 32 registers are the zregs */ + switch (reg) { + /* The first 32 registers are the zregs */ + case 0 ... 31: + { + int vq, len = 0; + uint64_t *p = (uint64_t *) buf; + for (vq = 0; vq < cpu->sve_max_vq; vq++) { + env->vfp.zregs[reg].d[vq * 2 + 1] = *p++; + env->vfp.zregs[reg].d[vq * 2] = *p++; + len += 16; + } + return len; + } + case 32: + vfp_set_fpsr(env, *(uint32_t *)buf); + return 4; + case 33: + vfp_set_fpcr(env, *(uint32_t *)buf); + return 4; + case 34 ... 50: + { + int preg = reg - 34; + int vq, len = 0; + uint64_t *p = (uint64_t *) buf; + for (vq = 0; vq < cpu->sve_max_vq; vq = vq + 4) { + env->vfp.pregs[preg].p[vq / 4] = *p++; + len += 8; + } + return len; + } + case 51: + /* cannot set vg via gdbstub */ + return 0; + default: + /* gdbstub asked for something out our range */ + break; + } + + return 0; +} +#endif /* TARGET_AARCH64 */ + static bool raw_accessors_invalid(const ARMCPRegInfo *ri) { /* Return true if the regdef would cause an assertion if you called @@ -7959,9 +8064,22 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) CPUARMState *env = &cpu->env; if (arm_feature(env, ARM_FEATURE_AARCH64)) { - gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, - aarch64_fpu_gdb_set_reg, - 34, "aarch64-fpu.xml", 0); + /* + * The lower part of each SVE register aliases to the FPU + * registers so we don't need to include both. + */ +#ifdef TARGET_AARCH64 + if (isar_feature_aa64_sve(&cpu->isar)) { + gdb_register_coprocessor(cs, arm_gdb_get_svereg, arm_gdb_set_svereg, + arm_gen_dynamic_svereg_xml(cs, cs->gdb_num_regs), + "sve-registers.xml", 0); + } else +#endif + { + gdb_register_coprocessor(cs, aarch64_fpu_gdb_get_reg, + aarch64_fpu_gdb_set_reg, + 34, "aarch64-fpu.xml", 0); + } } else if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(cs, vfp_gdb_get_reg, vfp_gdb_set_reg, 51, "arm-neon.xml", 0); @@ -7975,6 +8093,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) gdb_register_coprocessor(cs, arm_gdb_get_sysreg, arm_gdb_set_sysreg, arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs), "system-registers.xml", 0); + } /* Sort alphabetically by type name, except for "any". */ From patchwork Tue Mar 17 17:50:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184656 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4445725ile; Tue, 17 Mar 2020 11:05:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvZahJwJ/YMZHkNM4UWmt+zgiKhI7ewJqzhV8WxBXrHFxueKXKTCmdsp3EyUkmR8CIosP0b X-Received: by 2002:a0c:c283:: with SMTP id b3mr398634qvi.180.1584468321385; Tue, 17 Mar 2020 11:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468321; cv=none; d=google.com; s=arc-20160816; b=F/b5ZZD64KoZsFjz5/xq29gWwKhbexiu6yRxKfmAH5wySPAflYJMT01rK9b7uYlEE1 1LK4CPpZ5YXdg9bcniFl0H+ffiz31p+se5RkcJkXzfG2eIRMNOhtg+6mvsJHra4glFF7 tPeJ/Xe20DQMnaCl2Xf4SiwfHGI8B2nEh5hiZBp17iqeMlrD8EdQCqSxuH3VjqSkhApg LbG+IikwALvkk+J71aZipkGqjxW/t64YOuTIB+EJOkq3F/G9ZRiiWwkw0UIcorYhH3dg Z2p2PY6NjnFG43TJ8auTxo167aZ/vAHRbRJSuAcwvsRFke3ww9+7eF51ab9dhrI8uhQ0 H2rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Z2YdO0eBBHYBuVAaMP2mXqLSUKwI7KCxJYvCQtmd2VM=; b=lGpAMUCg/QJGqUnlqdEaBmYnczv0fJ663see1MX6b9j4dS+KUOIkLyazzxoJbqazfY k3RoT+e3mOC3N4/z5qsz2nHndR/xKBMt8oH+6S80HzaWlOeNfe+3pV5CUkRbvqB/riTD 98dKzuvMw/DnP7YP2rwkmZfQflZojwqr1syZSj2byFXhCRA/v7n2gZ8FDGXf9tBKXxLL uHijR/iPbLyEfFaVIgcZVPXH+4j1g38o3DfsZUn0t27Ce1yK1AYMMoiYeCSVhc+Y3XEf PcHHM/HcwJvIwjwtfSoZP5ucyocEHDTpDUFWZ3HXQhf/0GXhySaiHKaswpWObHrH1ZXe uCHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eG87WYHX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k3si2219664qvr.132.2020.03.17.11.05.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eG87WYHX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGae-00047Q-Qo for patch@linaro.org; Tue, 17 Mar 2020 14:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUQ-0005S8-2Q for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUN-0008JA-Aa for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:53 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:40285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUL-0008Ca-Jf for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:50 -0400 Received: by mail-wm1-x32f.google.com with SMTP id z12so254032wmf.5 for ; Tue, 17 Mar 2020 10:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z2YdO0eBBHYBuVAaMP2mXqLSUKwI7KCxJYvCQtmd2VM=; b=eG87WYHXKlRUlu9pUbxueBEqwocJOn6lcQTvIf9lZdlcXHSAtYbrNk+X7NPsADue+/ AiJN+HhqoXheS95WS/Z+wdGUJYt7YdSlOFQm9nM2Hdw835iNvZxF8y6G9gc66UWhWgwy ZUcR0vdlRpIR7gXfurBjI58VbP27SoELi3tPA0AIl6v2RVJhXInip+PJ6azayduVQBeb /Is80Qe5MbtfldSlrgCWGeetq1WOVt0vGTHaq/3pMYuNFsF4KOCnyM/56oqwwKg1hvyh 6iRgUmmXh06GJJHrvFB/1VxjON+3RUwnpt+wIt2A9l1nff5HcNZn0QCIUDg1vUwuzvRS nL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2YdO0eBBHYBuVAaMP2mXqLSUKwI7KCxJYvCQtmd2VM=; b=kXJ2lDd4NicCVrEjg99dsmyWaeaj/fl8Vl8W8sfVRG3Z97cu5DjPgPxVM8LqFfpHxM yqX4+//rJzsAtMlMAWck/VIrLHe+oQucPxsqVWYgRxwFX02YecjIrTn/Nr9ek8DhVTeW 8Gs4XRKjGvF62gstXQ+JnyTBu+mFHySMJkGtGNOEVekgPzoIYRUyUuOqvCGn7RQWu+ov qw+To7T7fpj48T70H4c7RcIyvevbm7Rgv35qU3YxuUo+EeZP4padnpe9LFJLqvAYqeTD JYXH/q+NJyavDQhLgVmGGZB3B01WqgemrXX9RzoPef4lIZk2fc1DnKgR4WNPuYo9JDaW ZtKw== X-Gm-Message-State: ANhLgQ3tA4dzAyVRiO+MaIe39uvunmdeihw/fhPK4OljI/Q3cJFqwy4D Fh3bDyy99+pV7gsP90CUWOkVVA== X-Received: by 2002:a1c:5443:: with SMTP id p3mr169796wmi.149.1584467927282; Tue, 17 Mar 2020 10:58:47 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c23sm215647wme.39.2020.03.17.10.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5009E1FFA9; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 19/28] target/arm: don't bother with id_aa64pfr0_read for USER_ONLY Date: Tue, 17 Mar 2020 17:50:44 +0000 Message-Id: <20200317175053.5278-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For system emulation we need to check the state of the GIC before we report the value. However this isn't relevant to exporting of the value to linux-user and indeed breaks the exported value as set by modify_arm_cp_regs. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-20-alex.bennee@linaro.org> -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 7e560ea7db6..d2ec2c53510 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6697,6 +6697,7 @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) return pfr1; } +#ifndef CONFIG_USER_ONLY static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) { ARMCPU *cpu = env_archcpu(env); @@ -6707,6 +6708,7 @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) } return pfr0; } +#endif /* Shared logic between LORID and the rest of the LOR* registers. * Secure state has already been delt with. @@ -7280,16 +7282,24 @@ void register_cp_regs_for_features(ARMCPU *cpu) * define new registers here. */ ARMCPRegInfo v8_idregs[] = { - /* ID_AA64PFR0_EL1 is not a plain ARM_CP_CONST because we don't - * know the right value for the GIC field until after we - * define these regs. + /* + * ID_AA64PFR0_EL1 is not a plain ARM_CP_CONST in system + * emulation because we don't know the right value for the + * GIC field until after we define these regs. */ { .name = "ID_AA64PFR0_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 0, - .access = PL1_R, .type = ARM_CP_NO_RAW, + .access = PL1_R, +#ifdef CONFIG_USER_ONLY + .type = ARM_CP_CONST, + .resetvalue = cpu->isar.id_aa64pfr0 +#else + .type = ARM_CP_NO_RAW, .accessfn = access_aa64_tid3, .readfn = id_aa64pfr0_read, - .writefn = arm_cp_write_ignore }, + .writefn = arm_cp_write_ignore +#endif + }, { .name = "ID_AA64PFR1_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, From patchwork Tue Mar 17 17:50:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184654 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4445550ile; Tue, 17 Mar 2020 11:05:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuncmnWCozm+DiVo7LEAujstrsX2unEOLStllwIOTFeagcd6DIE0plIc5c1qIXchGNKPgdC X-Received: by 2002:a05:620a:22f5:: with SMTP id p21mr78116qki.41.1584468311575; Tue, 17 Mar 2020 11:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468311; cv=none; d=google.com; s=arc-20160816; b=QVcamUEtUDACzEYdDR4vJ5QEx9Q64GD7U1hwkCBlurOHlwEFX4XQG3eIJdEVj9h8vn YcO/R28Ea3Y8GIX5bGZVNvme4M5Ks300taB/kH/Jn7seQbx3zXoI5v5PJ1xqzt8nQO9O CNZ9czPb2b3DH2bAPPzePl+ytdRwNrP+6jQj2X/xh7JzkZokeeqyMiPzSGS6lXnlYa5D 5wWPRN2c6t4D+BxG1nqjcFf54l5r9ibQJ8KasI5QiEzcuQ3dF1f56TSF5NDUhNHn8Lxm 7a20aSPGD1n7Ebbp/jWYBcyvntXca5DjxjjGGpycuIoGI+UYiXW7zVbLpUuEf/h/ljjf OdDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sOZl7N+p3d0MtLvUQi+HFwBRKeEwP2nCuZe7lsQ+1tk=; b=JjRxwCbKXgMDW2/YlPHOC2XJ6njuUSdDEnBiy1G5rqmF1ZWC3hTTr8xNLUlrLpHNbe 37KRUGAvP10D2ezzPOWUy7Fw4BWaVU68GuoRNloDJjuKlagTDXPKjXljmPmVzA6GQRgp FXs4Y7YD+r3/FljL9vjo/GdKWJulljHCzIIN6qnxUKb1mQQE6+w6NuRUAyXI14Ufrak0 JeXHGLit9YRshVf0LYwvRtiy2xULgUwknPlPz7O4nMAqkmxnWKYIbY9ef/qFSy+Yvybu W2SdEZZ8K2cw4yooHR01oUtBkKUlHOhlLl8qla1S5dNP2TlSXhSQYCMCAi4lzTJRfFuB HaVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="sDjEU/vC"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m3si2453783qke.131.2020.03.17.11.05.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="sDjEU/vC"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGaV-0003Nh-1P for patch@linaro.org; Tue, 17 Mar 2020 14:05:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36634) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUT-0005Xp-DY for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUR-0008Vg-5E for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:57 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUQ-0008OZ-QA for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:55 -0400 Received: by mail-wr1-x443.google.com with SMTP id f3so19944012wrw.7 for ; Tue, 17 Mar 2020 10:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sOZl7N+p3d0MtLvUQi+HFwBRKeEwP2nCuZe7lsQ+1tk=; b=sDjEU/vC5XpYzrBk59Vs/9uz5vNuCsgw64KGFd2h3hHMlRdWqP9B7odldDBPszD08c pUzazi+IAioJXASXVJwNzGBhl4w7eOwzRQmO7QWcR9U0OjkkSyiMGQzpIbCHT3Clbl65 O05qFmV08MWPF+9XRMX9QxFjB9RC4CvqsRgyxEdeoqRzzNivT5g7rAeQdn5EQeXDscMD bCTCYAMdFZrf0OA0i0XK0qA9pfTbNM9JOLCleoZSGx+QowIfQ+DjqG9d74lgWP+rOj9C ggwpaJawtE58MMjHtE8HOAGr6ZIzaJmAnjCB2fU9Qmk+HO86fvIfWlXQ7uwlT3ENZlcG o8Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sOZl7N+p3d0MtLvUQi+HFwBRKeEwP2nCuZe7lsQ+1tk=; b=V3QCV2s6Das/i11MRCuLEUc4ERkQvIwtGX05iFjFEcLQXAFxZBy6YilGsewqqVHcOU jvEIpWyEnUd8+2wu1VrRbx3UTpDm7MqJ4QVNm40mtb5eqkD8YmxosurTICYQYNM0Oy8V nfn5jwF614i02Pv55ymBhyleeyHWxeAYD2yPGMqjmQnhdsC48AlJe2qpW9YXYpo3X6Lk NqaN6KAfT6FKvxt4jVTbEkJV6xEwQVnx3+JldYwp/F7zYj5ghZ/lztMt+p63FrMkU+zJ FLrcTAj0xW7OdUNeH4cM88Rb047dle34yblyMUScYk1cKhaXrVSF6MWYPMscn/i8aKNu LfuQ== X-Gm-Message-State: ANhLgQ0GpWhDVzQb3sQGX1kOIqDOyoHCWpNZxNkhxAcwq2nLzqdntQZZ TiBAo1E0b4R50WFqWYKj7/36TOsQUM4= X-Received: by 2002:adf:afdb:: with SMTP id y27mr216145wrd.208.1584467932107; Tue, 17 Mar 2020 10:58:52 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a184sm203819wmf.29.2020.03.17.10.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 65DBB1FFAA; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 20/28] tests/tcg/aarch64: userspace system register test Date: Tue, 17 Mar 2020 17:50:45 +0000 Message-Id: <20200317175053.5278-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This tests a bunch of registers that the kernel allows userspace to read including the CPUID registers. We need a SVE aware compiler as we are testing the id_aa64zfr0_el1 register in the set. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-21-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c new file mode 100644 index 00000000000..40cf8d2877e --- /dev/null +++ b/tests/tcg/aarch64/sysregs.c @@ -0,0 +1,172 @@ +/* + * Check emulated system register access for linux-user mode. + * + * See: https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt + * + * Copyright (c) 2019 Linaro + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif + +int failed_bit_count; + +/* Read and print system register `id' value */ +#define get_cpu_reg(id) ({ \ + unsigned long __val = 0xdeadbeef; \ + asm("mrs %0, "#id : "=r" (__val)); \ + printf("%-20s: 0x%016lx\n", #id, __val); \ + __val; \ + }) + +/* As above but also check no bits outside of `mask' are set*/ +#define get_cpu_reg_check_mask(id, mask) ({ \ + unsigned long __cval = get_cpu_reg(id); \ + unsigned long __extra = __cval & ~mask; \ + if (__extra) { \ + printf("%-20s: 0x%016lx\n", " !!extra bits!!", __extra); \ + failed_bit_count++; \ + } \ +}) + +/* As above but check RAZ */ +#define get_cpu_reg_check_zero(id) ({ \ + unsigned long __val = 0xdeadbeef; \ + asm("mrs %0, "#id : "=r" (__val)); \ + if (__val) { \ + printf("%-20s: 0x%016lx (not RAZ!)\n", #id, __val); \ + failed_bit_count++; \ + } \ +}) + +/* Chunk up mask into 63:48, 47:32, 31:16, 15:0 to ease counting */ +#define _m(a, b, c, d) (0x ## a ## b ## c ## d ##ULL) + +bool should_fail; +int should_fail_count; +int should_not_fail_count; +uintptr_t failed_pc[10]; + +void sigill_handler(int signo, siginfo_t *si, void *data) +{ + ucontext_t *uc = (ucontext_t *)data; + + if (should_fail) { + should_fail_count++; + } else { + uintptr_t pc = (uintptr_t) uc->uc_mcontext.pc; + failed_pc[should_not_fail_count++] = pc; + } + uc->uc_mcontext.pc += 4; +} + +int main(void) +{ + struct sigaction sa; + + /* Hook in a SIGILL handler */ + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_flags = SA_SIGINFO; + sa.sa_sigaction = &sigill_handler; + sigemptyset(&sa.sa_mask); + + if (sigaction(SIGILL, &sa, 0) != 0) { + perror("sigaction"); + return 1; + } + + /* Counter values have been exposed since Linux 4.12 */ + printf("Checking Counter registers\n"); + + get_cpu_reg(ctr_el0); + get_cpu_reg(cntvct_el0); + get_cpu_reg(cntfrq_el0); + + /* HWCAP_CPUID indicates we can read feature registers, since Linux 4.11 */ + if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { + printf("CPUID registers unavailable\n"); + return 1; + } else { + printf("Checking CPUID registers\n"); + } + + /* + * Some registers only expose some bits to user-space. Anything + * that is IMPDEF is exported as 0 to user-space. The _mask checks + * assert no extra bits are set. + * + * This check is *not* comprehensive as some fields are set to + * minimum valid fields - for the purposes of this check allowed + * to have non-zero values. + */ + get_cpu_reg_check_mask(id_aa64isar0_el1, _m(00ff,ffff,f0ff,fff0)); + get_cpu_reg_check_mask(id_aa64isar1_el1, _m(0000,00f0,ffff,ffff)); + /* TGran4 & TGran64 as pegged to -1 */ + get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(0000,0000,ff00,0000)); + get_cpu_reg_check_zero(id_aa64mmfr1_el1); + /* EL1/EL0 reported as AA64 only */ + get_cpu_reg_check_mask(id_aa64pfr0_el1, _m(000f,000f,00ff,0011)); + get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0000,00f0)); + /* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */ + get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006)); + get_cpu_reg_check_zero(id_aa64dfr1_el1); + get_cpu_reg_check_zero(id_aa64zfr0_el1); + + get_cpu_reg_check_zero(id_aa64afr0_el1); + get_cpu_reg_check_zero(id_aa64afr1_el1); + + get_cpu_reg_check_mask(midr_el1, _m(0000,0000,ffff,ffff)); + /* mpidr sets bit 31, everything else hidden */ + get_cpu_reg_check_mask(mpidr_el1, _m(0000,0000,8000,0000)); + /* REVIDR is all IMPDEF so should be all zeros to user-space */ + get_cpu_reg_check_zero(revidr_el1); + + /* + * There are a block of more registers that are RAZ in the rest of + * the Op0=3, Op1=0, CRn=0, CRm=0,4,5,6,7 space. However for + * brevity we don't check stuff that is currently un-allocated + * here. Feel free to add them ;-) + */ + + printf("Remaining registers should fail\n"); + should_fail = true; + + /* Unexposed register access causes SIGILL */ + get_cpu_reg(id_mmfr0_el1); + get_cpu_reg(id_mmfr1_el1); + get_cpu_reg(id_mmfr2_el1); + get_cpu_reg(id_mmfr3_el1); + + get_cpu_reg(mvfr0_el1); + get_cpu_reg(mvfr1_el1); + + if (should_not_fail_count > 0) { + int i; + for (i = 0; i < should_not_fail_count; i++) { + uintptr_t pc = failed_pc[i]; + uint32_t insn = *(uint32_t *) pc; + printf("insn %#x @ %#lx unexpected FAIL\n", insn, pc); + } + return 1; + } + + if (failed_bit_count > 0) { + printf("Extra information leaked to user-space!\n"); + return 1; + } + + return should_fail_count == 6 ? 0 : 1; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 8ed477d0d51..a25afc071cc 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -42,4 +42,10 @@ run-semiconsole: semiconsole run-plugin-semiconsole-with-%: $(call skip-test, $<, "MANUAL ONLY") +ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) +# System Registers Tests +AARCH64_TESTS += sysregs +sysregs: CFLAGS+=-march=armv8.1-a+sve +endif + TESTS += $(AARCH64_TESTS) From patchwork Tue Mar 17 17:50:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184663 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4452957ile; Tue, 17 Mar 2020 11:12:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvQJE40Yx7P+ki3rwN1AcOpyyyuRp/b2+FpVzed2v3V4mHxAFnpAJvgsMQOQ4d4TkAWyY61 X-Received: by 2002:a37:47d3:: with SMTP id u202mr142856qka.264.1584468728221; Tue, 17 Mar 2020 11:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468728; cv=none; d=google.com; s=arc-20160816; b=SQkIbh0WqKiWwYipJ+aNCzqwFnhIPQvAXINQeIuYw1TvMZuzndxje1IO3xHVfxYiPX 0KijXCuXBdeJO8gYceJZFZef9rToW6GIDPTAW9OeTxzF454D0lWh1KeVsu5JCLPhgu80 nkfXJmvnUXclPLNaaLeiDTGCGPY8fe+FyLH/+m6evYCJC9mAwnwrMQtvuYzU299Og49Q 4CbQ6qFbOIcWkfdjuK1x1NYDdorv7SEyNyvi+v0lH0Cls6pi0B/uVi58Yh82iSf5WdPq bN0TxRuVFqNwd+gXWVD8NqemekLWWdeJ6bTc2qI1G1x9VUuC8fykVLue5jmzzLym6Oes wczg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=w1gc8KtHt2EURW6KK00imtpWe3g+NUK+oh+i1JX/9Jo=; b=sXQtThqnA8sSJtYlu14BIyX49iBifxLV08/ubGfk4TdYJSc9rhuWFWC+CrY7SUttGX Swp2U4rYlFzMqcYqtOjwrssx/qGs1+8Zs+Gq4n9sK6EGOu63J4pr4dcyH2XhxwOfoMxm knWOmFeEQjNo3SEa5sqB8O0xZzYktAxqCDzGzcHWPXX7TKz1+G8+gF7a54bsp07yn9Kn 8TvzL1q5yDMsjc+dtLaVQ8bAhEO72MV7EfeyCpQrwqsdD/KYN7yM5SreBp0GB0Oa1w5P cwNCBgcPMgeMUcFTE6yTbcxRjgbfgeopeqvt8fHA7PLuXMDWBOXNUrENPWwIclxbchad cWNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=s4vMcThD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o11si2340389qki.50.2020.03.17.11.12.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=s4vMcThD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGhD-0005DW-ML for patch@linaro.org; Tue, 17 Mar 2020 14:12:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36784) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUX-0005hV-Nq for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUW-0000eN-Hd for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:01 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:36824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUW-0000Xp-A8 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:00 -0400 Received: by mail-wr1-x42d.google.com with SMTP id s5so26966433wrg.3 for ; Tue, 17 Mar 2020 10:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w1gc8KtHt2EURW6KK00imtpWe3g+NUK+oh+i1JX/9Jo=; b=s4vMcThDB+TdFLvmymz4rpTcWeX7CjMHH3pIz+ehSPTznZxiSVY/5HEMjFCsQADu8i rAAOnRoVwE2LAnE+wDzw13I4FnCTZxJ0imXAtQaFZMXLd4ypiFhrp+w3oAhT3ip7TDgV sYV8sRWrtvUBe/iyBGXLtja6EtgAchMEJLkijBje1+Y1KxaWTXoGQnXFFDbO5NbpWPwd ewR8WzAO7DnXKB69qSkuIb7nCeR91eDQteZB8JAZGgmzKrlL1uDmQ6Y/bckdADRyQd1W Dv8h1ZMxCDomeI/26XYg3b+zxET2AQ3GaUW7bSEVyd5dKI33N4g0ksA+QB8KBQOgGoIR c+Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w1gc8KtHt2EURW6KK00imtpWe3g+NUK+oh+i1JX/9Jo=; b=fJLZxD+OQK1OhKK68ulKwUVQznTv4bqiW0G/UhdAGUa6dqSJEU01KkHCAkCfu0kMk2 E1c+24uN3MPN1Xc9FZDPJTkEe8TIuudmldch3K9gJrJZ/RQgUwhb3wmF7hciYLEQanRJ oqzklihYQ7WmtmdGw9ZJDLIpAOZmD+/QZdxe6BK0UzjsIhuOedk6QXLZhR9FerRLeFPV TvkoUEAqrApQ/U2u25mxYqzI3U5G20BuVS7FABu0yo7rW33twONnsTWGH3MRmlEk0fJ2 8VtZkEUurrUXONlIjakl/Ud9xRbfHoFBKqTP/F6u3hx+Ix3vWMSUObUPoDZ4C/lMOD0N 5iVA== X-Gm-Message-State: ANhLgQ2d75cP25wDeqcqwgeGWssPbyjKg1eKUhoz9HfxmcI1qIKZiMKT 3YjRIwI1/H9rF1wroPHo0A2SExl4IYY= X-Received: by 2002:adf:ba48:: with SMTP id t8mr158619wrg.329.1584467939173; Tue, 17 Mar 2020 10:58:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a1sm5683791wro.72.2020.03.17.10.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:53 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7A0C61FF7E; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 21/28] configure: allow user to specify what gdb to use Date: Tue, 17 Mar 2020 17:50:46 +0000 Message-Id: <20200317175053.5278-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is useful, especially when testing relatively new gdbstub features that might not be in distro packages yet. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-22-alex.bennee@linaro.org> -- 2.20.1 diff --git a/configure b/configure index eb49bb6680c..057994bce69 100755 --- a/configure +++ b/configure @@ -303,6 +303,7 @@ libs_qga="" debug_info="yes" stack_protector="" use_containers="yes" +gdb_bin=$(command -v "gdb") if test -e "$source_path/.git" then @@ -1588,6 +1589,8 @@ for opt do ;; --disable-fuzzing) fuzzing=no ;; + --gdb=*) gdb_bin="$optarg" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1773,6 +1776,7 @@ Advanced options (experts only): --enable-plugins enable plugins via shared library loading --disable-containers don't use containers for cross-building + --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] Optional features, enabled with --enable-FEATURE and disabled with --disable-FEATURE, default is enabled if available: @@ -6734,6 +6738,7 @@ echo "libudev $libudev" echo "default devices $default_devices" echo "plugin support $plugins" echo "fuzzing support $fuzzing" +echo "gdb $gdb_bin" if test "$supported_cpu" = "no"; then echo @@ -7608,6 +7613,10 @@ if test "$plugins" = "yes" ; then fi fi +if test -n "$gdb_bin" ; then + echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak +fi + if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" = "sparc64" ; then From patchwork Tue Mar 17 17:50:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184655 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4445715ile; Tue, 17 Mar 2020 11:05:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs3IR0Cy+EWFyWQ9lVYAv3ObCHetz7rRepZ80gsUS4k8qmEJFCLNOAfWs2le2ZUXiK8jvvq X-Received: by 2002:a05:6214:8b:: with SMTP id n11mr419525qvr.72.1584468320857; Tue, 17 Mar 2020 11:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468320; cv=none; d=google.com; s=arc-20160816; b=GJuJxyhYTiM74ReY7rsdOeSPOJhTs4SLFn9cXESFSIPVbD4R+wom+M5T1yMTlpAQHY N7PgjR1xd6TlNAt1HCSh/QSNhNsAeKcno09pxfqGxM5Zay1AF69u41gAGWJmlv9JwwcI A7Q0FwBCnRZ5QCYWQBKLl/GHu5SrwbcxgFXB1q1DDrBEaBk/MIE1ENWWJF24h93vtPFh fiWV1VLRYhjhRY/gAZRNg8VlcbuD0UVRJ0VYaH2Mt4y39fyMEj9/llN5Ew2ge/fN9i0V m1h/Yutr3LIRAX5mLlVfNifjtZsauWhiAT6Ln7uwSqlDlzBUZ/eHOt7UjAcwB8BTBlje 4qjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7Q2lkx0fMNS8OCExFZJ/0oeLEFUXLbn1Ix69DopYAxs=; b=yQph/ZH/8+H1CKUAtEbKz4gFkx6kvfDynNGovqcglfxpRY4VcnB7odLLgm/Onn4ydw RNWG3z3NqeTM+QdSObAikGIY9WMMuAXfnEmv8HRebWnaat7uZXxweRv5P+cP8JR3y4aM LCJ4Ma27eSa0UDbs4/bGKEJzx1CUWa3ry8iQolWf7+AknIN46KZa5V8CR9nbF5UXZJDU tE/VARlrkddVhKTLS4gPmz6bvgKU/1CeY2OdN1iqGS8taXEtI7IbCWnwihjYhGUkrsfS 2tAnddwbBJ5ejB9NPreGape3pdZDYjHXDHMDkbYDXpsNB+Eqx9JVQwSiy5SzBNrv/mGU HDyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D6JustDb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j9si2286716qtn.326.2020.03.17.11.05.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:05:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=D6JustDb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGae-0003fo-8r for patch@linaro.org; Tue, 17 Mar 2020 14:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36739) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUW-0005eN-EX for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUV-0000Ul-5R for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:00 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUU-0000NR-Sk for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:59 -0400 Received: by mail-wr1-x432.google.com with SMTP id s1so5174395wrv.5 for ; Tue, 17 Mar 2020 10:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Q2lkx0fMNS8OCExFZJ/0oeLEFUXLbn1Ix69DopYAxs=; b=D6JustDbNPQ2mX7VegXxMpE5hOEiECnZZ7wfdxi45CoJ0gCwNGd1zthnUcecGPYbYZ SxnJ/xnRt46zm2ARPU1yLfZdijFAN8uyGGfqHQZmIHVNeweAwYaLGhhZfhWMufxE17yK +uLt0pvZKOfkFh6Q5xYrbuP24gTG2V3Diovvz3TZXEjB9zV+jPBj0An+kxrC8cibmlWZ N9X343Qh9VFRAU0FWSOsx9fMvVZC+zolgxxze4B2FccNsd4mkwNTskcyN2W2GA6chI92 Crh4ulwH53zyKysjqp3+c+1RsYZuTDnWOT1/xUhHQrlyp24cgvMVKVTCN3l8OYQqKKXb FDLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Q2lkx0fMNS8OCExFZJ/0oeLEFUXLbn1Ix69DopYAxs=; b=B43WAPoU7vjTVbtnoG+1VVhpX0oyZOzKCjTIgMzTDRFeMfUPQuCG+1mkAGgC+0B9nV vTmF0y1uOcV0Bqn9pehPLutFwCBuBCy2WgkqSK4dnmH9tgQXkhc+YPXFTJ4D5Qwdr7T/ Qx7JAuOUFIZH+7lpgVk7bzOCgpRbRU0wZhmURaVfg4pI7QBWlUvZnSs+NwBBDX8i1WMJ MsO6I6jusegScLqAWNR4clR6D4kqstVxuzw8hijJKQg+7Rl/irnx1zmQc0xVyYSTwevy Z+X/7xXG0Iqi2Ls8VkOPLrqe7AR9BTVMc3oN+0p5CPVD8bN/kgal55DVNrVLFTllfV/s SdWg== X-Gm-Message-State: ANhLgQ1TrxnAmktT3o5yiT/qr1IzxtnN7ev+3Cd46bxg8sSj98/NL/X7 Dzhltjjje3I45zKuDUyKkFsftQ== X-Received: by 2002:a5d:6ac3:: with SMTP id u3mr204731wrw.358.1584467937736; Tue, 17 Mar 2020 10:58:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k5sm233113wmj.18.2020.03.17.10.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:53 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8DE5F1FFAB; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 22/28] tests/guest-debug: add a simple test runner Date: Tue, 17 Mar 2020 17:50:47 +0000 Message-Id: <20200317175053.5278-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::432 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Ma?= =?utf-8?q?thieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The test runners job is to start QEMU with guest debug enabled and then spawn a gdb process running a test script that exercises the functionality it wants to test. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Tested-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-23-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py new file mode 100755 index 00000000000..8c49ee2f225 --- /dev/null +++ b/tests/guest-debug/run-test.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# Run a gdbstub test case +# +# Copyright (c) 2019 Linaro +# +# Author: Alex Bennée +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import subprocess +import shutil +import shlex + +def get_args(): + parser = argparse.ArgumentParser(description="A gdbstub test runner") + parser.add_argument("--qemu", help="Qemu binary for test", + required=True) + parser.add_argument("--qargs", help="Qemu arguments for test") + parser.add_argument("--binary", help="Binary to debug", + required=True) + parser.add_argument("--test", help="GDB test script", + required=True) + parser.add_argument("--gdb", help="The gdb binary to use", default=None) + + return parser.parse_args() + +if __name__ == '__main__': + args = get_args() + + # Search for a gdb we can use + if not args.gdb: + args.gdb = shutil.which("gdb-multiarch") + if not args.gdb: + args.gdb = shutil.which("gdb") + if not args.gdb: + print("We need gdb to run the test") + exit(-1) + + # Launch QEMU with binary + if "system" in args.qemu: + cmd = "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + else: + cmd = "%s %s -g 1234 %s" % (args.qemu, args.qargs, args.binary) + + inferior = subprocess.Popen(shlex.split(cmd)) + + # Now launch gdb with our test and collect the result + gdb_cmd = "%s %s -ex 'target remote localhost:1234' -x %s" % (args.gdb, args.binary, args.test) + + result = subprocess.call(gdb_cmd, shell=True); + + exit(result) From patchwork Tue Mar 17 17:50:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184650 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4438232ile; Tue, 17 Mar 2020 10:59:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsHtXlgazzYRzrXDDIjJvL//FsBQBxH/QGeGnAaov1OcJDrZfcbmafFY5J6VtetO9V9S05f X-Received: by 2002:ae9:e407:: with SMTP id q7mr101307qkc.206.1584467951598; Tue, 17 Mar 2020 10:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467951; cv=none; d=google.com; s=arc-20160816; b=lf1FCYaxmMP//3C+Kd79h3MoTYZp8Zxrpix6DVWsjOPS+4p5LKoPpqStvOtqYaSgSZ 4nuSP/Afy7Y22D4e0CJokM8iSy6qpXXX1Zg1OEtsTiahK+EA/oncgMhzKRSDYNrRNs1R L5FTwfvNPec+GavSMtho6mEaVm8o+XI/uqPVpLJhJRqVuQ+K7Iav/EnnQVMxqWJ3bOve 4WIkcZuSxN7AmWsN9OdO4TD+TwG+w0r+hXOhGJ72+D5OpeAsAYv3e+p2kj6VztAtjJd2 Z85a5qaVV2Ka+VpDkAvZsXG6Xq8YOomCpIBpBjaq/zHRUDbRMF9Pazi8D8ggXe0TYHp6 kteg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cqKq7MlHK53nbIqC1omFbmt09y3THTY7GXgnExfxVbk=; b=YaXxyXBNfsKVLkUSp44x7jQeZB27Kpx9iHppqqc6fEhNerdBWvmy1d3n10l/kPp3t3 k0yKtjrlBn74OcrmzzPb/PAAAKCXXZegX4Mqt+nNShfKQOvgNeVtZRRhyinlNAXA0yDH bhkqGq2RQb3MQClZJ7SUcNW1j4+XVNcBnGir5zFTH+zoQNJsQ4F0sT8fMqsyfcA831cW LCTDKlOrzFvqdDEeFV89O+Q4NjmoPZFIQDAha3YPt/HvIQAvwXmYaye9oT6dZGBXtW2o tZMTVuSEydyBUgf9jKIb8dEr2J8ZME69/vzYU+VF0vqsw5hpTA1ZuRo/xDFKHB0cPezk sbLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LBDI0sl7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g51si2318806qte.5.2020.03.17.10.59.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:59:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LBDI0sl7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUh-0005VX-11 for patch@linaro.org; Tue, 17 Mar 2020 13:59:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36499) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUN-0005RJ-H8 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUL-0008EI-Jx for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:51 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:39258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUJ-00089B-DO for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:47 -0400 Received: by mail-wm1-x32d.google.com with SMTP id f7so261701wml.4 for ; Tue, 17 Mar 2020 10:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cqKq7MlHK53nbIqC1omFbmt09y3THTY7GXgnExfxVbk=; b=LBDI0sl7amJCaml5FZsjxjTDsW20xiWIlpnwG8EdrMgJLRXsKHqlzOEnFnYDTKdwJa pG8BIl2CRNK1db550UVK0jC7eTiI8IUvrl+gMkv81L1H//FG+1Tg7esNf5cFdEAzRInk +M+zJUswKW0yU68su38rM4OITNzSi4h5QNjs5PpowJeoxRAd5UYOpH2YR7jxt5LAJXnU 0bofDM3j3Q6cwQiBOseyV6vCaHNKzArQYVu/5PTaDRHlFZ86NhoRldXZcfYW+0OpAq+X /+e6xVVeCBQSiyVvS93YJXp/BQ5XEBpQSENMbui6RLzr3itnq6Iv57CWLuct85iWyYnv tvdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cqKq7MlHK53nbIqC1omFbmt09y3THTY7GXgnExfxVbk=; b=PPDKo4mBCBDozdAE2XONvxiBSeBgl3T+N7p4HCMuftiz1sFqzJYl4H070k0QJ3Z/2G o4AP1uuiONyJO7CNk5KjkAl1ZyOpL3rHBkkemNdrqcOQYVC5xW2ZKN2uQTbDxNDr+ryg zqzuCC8RQXj9Grd9dpKMTIfAovIDxWzFXXnZu9JvdqsTLrqO5MN/Bg5zs7Sac6Ky+8XG fUq6OXA8WboAcRKSTVGHZs17DVHN8L0M1a4AT8niPMZdznu1Yvysgd5gBMGCRb1/cpg2 Tm9D9RjVgDrBA1kh/VYLJkl8hbPs3ZG8eozu+aedadYwqn/4XmdY4vNOItaIdzdabxNe 7vhw== X-Gm-Message-State: ANhLgQ172l11EWL1VpcH0qSLpvWJvPgE7+X7BMIc0RgAvvqXKPc3LLrg +e9VHOLYHUQkVSQbhh9nqib7mA== X-Received: by 2002:a05:600c:2214:: with SMTP id z20mr191207wml.61.1584467925985; Tue, 17 Mar 2020 10:58:45 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c124sm249927wma.10.2020.03.17.10.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A7D711FFAC; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 23/28] tests/tcg/aarch64: add a gdbstub testcase for SVE registers Date: Tue, 17 Mar 2020 17:50:48 +0000 Message-Id: <20200317175053.5278-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A very simple test case which sets and reads SVE registers while running a test case. We don't really need to compile a SVE binary for this case but we will later so keep it simple for now. Signed-off-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-24-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/.gitignore b/tests/.gitignore index 7306866f216..d03c037d772 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -10,6 +10,7 @@ qht-bench rcutorture test-* !test-*.c +!test-*.py !docker/test-* test-qapi-commands.[ch] test-qapi-init-commands.[ch] diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index a25afc071cc..b61b53e4dd1 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -46,6 +46,21 @@ ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) # System Registers Tests AARCH64_TESTS += sysregs sysregs: CFLAGS+=-march=armv8.1-a+sve + +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py + +AARCH64_TESTS += gdbstub-sysregs + +.PHONY: gdbstub-sysregs +run-gdbstub-sysregs: sysregs + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \ + "basic gdbstub SVE support") +endif + endif TESTS += $(AARCH64_TESTS) diff --git a/tests/tcg/aarch64/gdbstub/test-sve.py b/tests/tcg/aarch64/gdbstub/test-sve.py new file mode 100644 index 00000000000..dbe7f2aa932 --- /dev/null +++ b/tests/tcg/aarch64/gdbstub/test-sve.py @@ -0,0 +1,84 @@ +from __future__ import print_function +# +# Test the SVE registers are visable and changeable via gdbstub +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +MAGIC = 0xDEADBEEF + +failcount = 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print ("PASS: %s" % (msg)) + else: + print ("FAIL: %s" % (msg)) + global failcount + failcount += 1 + +def run_test(): + "Run through the tests one by one" + + gdb.execute("info registers") + report(True, "info registers") + + gdb.execute("info registers vector") + report(True, "info registers vector") + + # Now all the zregs + frame = gdb.selected_frame() + for i in range(0, 32): + rname = "z%d" % (i) + zreg = frame.read_register(rname) + report(True, "Reading %s" % rname) + for j in range(0, 4): + cmd = "set $%s.q.u[%d] = 0x%x" % (rname, j, MAGIC) + gdb.execute(cmd) + report(True, "%s" % cmd) + for j in range(0, 4): + reg = "$%s.q.u[%d]" % (rname, j) + v = gdb.parse_and_eval(reg) + report(str(v.type) == "uint128_t", "size of %s" % (reg)) + for j in range(0, 8): + cmd = "set $%s.d.u[%d] = 0x%x" % (rname, j, MAGIC) + gdb.execute(cmd) + report(True, "%s" % cmd) + for j in range(0, 8): + reg = "$%s.d.u[%d]" % (rname, j) + v = gdb.parse_and_eval(reg) + report(str(v.type) == "uint64_t", "size of %s" % (reg)) + report(int(v) == MAGIC, "%s is 0x%x" % (reg, MAGIC)) + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + if inferior.was_attached == False: + print("SKIPPING (failed to attach)", file=sys.stderr) + exit(0) + arch = inferior.architecture() + report(arch.name() == "aarch64", "connected to aarch64") +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except: + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + +print("All tests complete: %d failures" % failcount) + +exit(failcount) From patchwork Tue Mar 17 17:50:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184660 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4450688ile; Tue, 17 Mar 2020 11:09:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsDMnoGloqq65IMSs9Tn2adUhxrbH83idU9b/+uFppRdsCzHKLjLBHrbXfOjulSNJhFx7Sb X-Received: by 2002:ac8:5210:: with SMTP id r16mr397730qtn.173.1584468596565; Tue, 17 Mar 2020 11:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468596; cv=none; d=google.com; s=arc-20160816; b=jfEjq7zdWR+pA5CNuz0ZMML6sJ8I855frHEQuy7B/BLjkgjafg2mMY5dPmNN6KNzet s3XICr0jliH2bOBdFOuOSEBErGi9ojWhKGqjelOhJ3rVFPkJLuTf+XmadFztqu/jIcNM yzCMjGOHuTri9+Eoyx9lRnIWBS6jFuQttswF9C+5itn24C55S4bgEtokjGvSFyoG2HY5 CvIChfTx/nQ64lh0gszZBO+LP78WHCHHIk/+IbqhjNRHCkSey6P3E3ytnGIU0gunpv6D xQwX59x1W4qkAZhSRflJJcSZ5MjRi+RCkZoXVJdvJV5x3Hozbt/MV9higco+SasdLxzG OtoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ycpjWhBk4Z3jSaQx3qTk+zNIZ4G3K3ciPCO6mbRvIck=; b=Eo072BKwGLN0TctCoxpRNEE8KJ4jqa4Vjtp8WwbFIPvGhSoUnAmcwXlBzgDT8/HTk+ n8PJBiS3yad9Lqe4BxxrxyxKsVCfpxvIZix4bH73VStXIz1Z5m9W/6ziqcGgE/RibQzn qPXdxzvvi9i0heZaa2GqvkAIouGpHI/B+5K1fheHH91qvXWM4aQTOSSmisErq7oCb7eJ 1BM4Vc9jHBM9ggMxKM6ZaYDLqqPn5u6WBCik9iZ50HcvAU9GEoI9W93as33StgKKr0dx 2XjRzjszZu1ySMA/dmqSslG1i10oMuF9u4kdmyTsM/j9vrGfPBftGsehNCreWCVqbTs9 9L9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GrZYKwRk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c54si2511120qta.70.2020.03.17.11.09.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:09:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GrZYKwRk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGf6-0001jz-11 for patch@linaro.org; Tue, 17 Mar 2020 14:09:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36854) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUa-0005n0-2z for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUY-0000ub-T6 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:03 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUY-0000q9-Lo for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:02 -0400 Received: by mail-wr1-x436.google.com with SMTP id f3so19944637wrw.7 for ; Tue, 17 Mar 2020 10:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ycpjWhBk4Z3jSaQx3qTk+zNIZ4G3K3ciPCO6mbRvIck=; b=GrZYKwRkNggQoU4mAZZXM5HcZSS6CmTyiVIGmcjZmv6ydc+einah46k8tsuBP7jHPh YLisvKeBMipUnh6e4vzsHm/OavDbgjbIGVjcCau/G2AXMR7CTimnnI/uB6AzlUswGE+B LlMH7OIIGUUqX8eHKSzWl4OeYZODuobwFdtXEfgMOUvKfS67tlJZoxqHzt6sU2AwvY2F GJDIlMyOCbMiTd0I/fwx1xc8HKvFw8iOPKToW2/+adf11d/njsNd0xYvAYoyoIPa4ofW pBVC6ILRBBAp73M1BQ7u44ukztN4588wb+gqxn6eMk25xiQBKLPKE0uCz/sgK3VQwmfO rXCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ycpjWhBk4Z3jSaQx3qTk+zNIZ4G3K3ciPCO6mbRvIck=; b=nrFOL7LXxaXYm9pJL8Y5XRGVO7um7OHjnYqwdMWR2ld0K4RH4fEzDIg5iQK/DPEsT5 eRm+RnHD3evryuTU2Pal6WlCgFdEQWMTuj/tvO2mErF6+ZOqXq2NOMHbTTm08I6Kl/gP qY3bhLSl2HJK8fvetePnKcxGftbBQy+8E4bOQPYT80PUVzN0zYzpLAOkL13xMGrLaYwW YgtxLNCEHt/UDBgMZY4Y/yimNg6DpK1DWiBIgVChLQazr+m/iD7M50qZZTGjLl5ZFuWs PJx7EONCc38BRurXn7jeYh+siQzSD6BHm27hnTsY/4OwZUp8SRhWZPyf97x5bc2Ff9kV PRaw== X-Gm-Message-State: ANhLgQ0aCs6197Po31zW37V7FXoqz0tDRhY5VHyEEnKxN5WWf4tWuoia /C/q359EJdx4+BYkt3pDWuNf8Q== X-Received: by 2002:adf:e811:: with SMTP id o17mr187932wrm.422.1584467941533; Tue, 17 Mar 2020 10:59:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z4sm5557961wrr.6.2020.03.17.10.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:53 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BDC241FFAE; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 24/28] tests/tcg/aarch64: add SVE iotcl test Date: Tue, 17 Mar 2020 17:50:49 +0000 Message-Id: <20200317175053.5278-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a fairly bare-bones test of setting the various vector sizes for SVE which will only fail if the PR_SVE_SET_VL can't reduce the user-space vector length by powers of 2. However we will also be able to use it in a future test which exercises the GDB stub. Signed-off-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Message-Id: <20200316172155.971-25-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/tcg/aarch64/sve-ioctls.c b/tests/tcg/aarch64/sve-ioctls.c new file mode 100644 index 00000000000..9544dffa0ee --- /dev/null +++ b/tests/tcg/aarch64/sve-ioctls.c @@ -0,0 +1,70 @@ +/* + * SVE ioctls tests + * + * Test the SVE width setting ioctls work and provide a base for + * testing the gdbstub. + * + * Copyright (c) 2019 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include + +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif + +#define SVE_MAX_QUADS (2048 / 128) +#define BYTES_PER_QUAD (128 / 8) + +#define get_cpu_reg(id) ({ \ + unsigned long __val; \ + asm("mrs %0, "#id : "=r" (__val)); \ + __val; \ + }) + +static int do_sve_ioctl_test(void) +{ + int i, res, init_vq; + + res = prctl(PR_SVE_GET_VL, 0, 0, 0, 0); + if (res < 0) { + printf("FAILED to PR_SVE_GET_VL (%d)", res); + return -1; + } + init_vq = res & PR_SVE_VL_LEN_MASK; + + for (i = init_vq; i > 15; i /= 2) { + printf("Checking PR_SVE_SET_VL=%d\n", i); + res = prctl(PR_SVE_SET_VL, i, 0, 0, 0, 0); + if (res < 0) { + printf("FAILED to PR_SVE_SET_VL (%d)", res); + return -1; + } + asm("index z0.b, #0, #1\n" + ".global __sve_ld_done\n" + "__sve_ld_done:\n" + "mov z0.b, #0\n" + : /* no outputs kept */ + : /* no inputs */ + : "memory", "z0"); + } + printf("PASS\n"); + return 0; +} + +int main(int argc, char **argv) +{ + /* we also need to probe for the ioctl support */ + if (getauxval(AT_HWCAP) & HWCAP_SVE) { + return do_sve_ioctl_test(); + } else { + printf("SKIP: no HWCAP_SVE on this system\n"); + return 0; + } +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index b61b53e4dd1..c879932ff6c 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -47,6 +47,10 @@ ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_SVE),) AARCH64_TESTS += sysregs sysregs: CFLAGS+=-march=armv8.1-a+sve +# SVE ioctl test +AARCH64_TESTS += sve-ioctls +sve-ioctls: CFLAGS+=-march=armv8.1-a+sve + ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py From patchwork Tue Mar 17 17:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184649 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4437114ile; Tue, 17 Mar 2020 10:57:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuaQon9VV1XjPnyuhNaWIrhPKZZM0NxZqgoQBbxpwHhV2EIvuKtdrHzk2t3M1uguJYdFTHF X-Received: by 2002:aed:3a89:: with SMTP id o9mr311164qte.375.1584467875202; Tue, 17 Mar 2020 10:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467875; cv=none; d=google.com; s=arc-20160816; b=HzzgEO6TulSJNAJQ4zs4YebGA7U8V0q+DmbaPm2bwDItqviaqmGNG4MQZbEhfF9GgJ 8jfDZuRqdojAXELZnKLcgGVh2CRSOYLaklMGDHb9vckpw8dJoqFPpO3mkpPS5C4ZpDrm hX/LLqkf2ZZzbhfVqt8Qh3FKqt0ouD7arHkpCXNRRqvmVabaLIWFqyNdtShF4WPEJqUr eq57JP94/CAi/uzyKgU8HcyI0iSHQ0oTHGVlTjYI8BTmJNpKWnI8jqE6YCbViZeHvDfS N25vqCX9NwDuigBsc8I38S2oXQtVsoJtHH333elBbRdJR27ELo+5WSZLtyKCmfBxqxfW 6FNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1JELrzWETzcBlGGiIwsXPqXELauVLI0go+Dpvqy4RLQ=; b=lXcI7RJQ/QItfHNRz4+lLSHV3hnR9CLYI/BHOx41Ua9HssaRoYvsZW/N+ouulPfYfo nGZSMgEVfCzaI+5GGhWu5O9XI8Xy+YDHdohfEX9mJ5Yye4/4u4IvzhC9WWGlrbvCCTz2 MJDoy8VRwbhJNDhhMjZTQoIpN9H1g9aQoVhGEEUVYOQfUAzuJhS9R4ZtFIguIQOW7oZt z5RzlFfTcBfwYSAQB41YTfUrRkPmWB+fNzyMsqmHf9DSM/NPTHU0pStn83zU+l/I7mqn ywY+lCpjp8TlRaiW11UJypeUWTS4S+YxsyuvNw5ZWzjpsZfn299ES22WEXpsOQwFvVI2 /ZeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e9XYxBPD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o10si2575870qko.205.2020.03.17.10.57.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 10:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e9XYxBPD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGTS-0003Ru-Lr for patch@linaro.org; Tue, 17 Mar 2020 13:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57323) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGN8-0000r4-4K for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGN5-0003l2-Tn for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:21 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:38715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGN5-0003el-Kj for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:51:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id s1so5143931wrv.5 for ; Tue, 17 Mar 2020 10:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1JELrzWETzcBlGGiIwsXPqXELauVLI0go+Dpvqy4RLQ=; b=e9XYxBPDezqDY7XBWIopUR43GMrEt6AJzlctHRESgCg8d7sGjfAVt8L8kzk9LctGPk EhSFw29zvKUerqR0wsUYEXLrdqkf5horw9hS2gLY/0muiBAYL3NlM7UA25bpSjU+int9 og2C2osVEgs8yeI8UQ4MGObmlHNQDifn7YfZLFRQfFypM4pIYwTsAQDRVbmDlurhBOAG P9GYwVsupOLBrCjmOWWVSu8uDzBhYoL7eQ+RuvygOF8V5ydMQBjtCOjKkAxaj8ydqDn4 qzY0FlryehhmaB44WRkQH4qW8rg+JKKhOcLRSCNtf+84twLp3uukgWmXqbq1zJV/FRuH EphQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1JELrzWETzcBlGGiIwsXPqXELauVLI0go+Dpvqy4RLQ=; b=AvspxBpqE8jifU2BfE7vzfk2Uj/3H7bPTyg4HwqKYHVGqdlBE0Wp/QIzy9ezMkE+S6 2g2EEGlRpbEE41CCng+K3yWD5HkqAe0oIzCfAiLjRIJ0uRnyOlB25NXpTKa92AhiZ4R6 zoWJLWahHjbYpfEKbRKvkM7t1IoS6wuvJHmWHdhZ3zjrhzzSLNK7eYfDK1HfMP1d8xiK 8sgQV+X7Sz0yLUZunI2lFMcEpRykMXYIXKc58gh2utIhiHnrYMmCQ2yWWUHDIpY1U2ZW 2/tFbvI1B48OspNoDvgitdoc0F0EZQLigBnwv6M2sMavSm1FVCI63jr2fFXln7eSJuTa 0SWQ== X-Gm-Message-State: ANhLgQ2s1aKc29q+kAqQNFo5jQsOFlwctGtXhDpqwARrUXHJxLM5WT6W hTjDrYDUBFHv+e8zAoKn7VNVfBCxRsU= X-Received: by 2002:adf:f40f:: with SMTP id g15mr148569wro.213.1584467477290; Tue, 17 Mar 2020 10:51:17 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x17sm2184346wrt.0.2020.03.17.10.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:51:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D56561FFAF; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 25/28] tests/tcg/aarch64: add test-sve-ioctl guest-debug test Date: Tue, 17 Mar 2020 17:50:50 +0000 Message-Id: <20200317175053.5278-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This test exercises the gdbstub while runing the sve-iotcl test. I haven't plubmed it into make system as we need a way of verifying if gdb has the right support for SVE. Signed-off-by: Alex Bennée Message-Id: <20200316172155.971-26-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index c879932ff6c..d99b2a9eced 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -54,15 +54,22 @@ sve-ioctls: CFLAGS+=-march=armv8.1-a+sve ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py -AARCH64_TESTS += gdbstub-sysregs +AARCH64_TESTS += gdbstub-sysregs gdbstub-sve-ioctls -.PHONY: gdbstub-sysregs +.PHONY: gdbstub-sysregs gdbstub-sve-ioctls run-gdbstub-sysregs: sysregs $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(HAVE_GDB_BIN) \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \ "basic gdbstub SVE support") + +run-gdbstub-sve-ioctls: sve-ioctls + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \ + "basic gdbstub SVE ZLEN support") endif endif diff --git a/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py new file mode 100644 index 00000000000..984fbeb277e --- /dev/null +++ b/tests/tcg/aarch64/gdbstub/test-sve-ioctl.py @@ -0,0 +1,85 @@ +from __future__ import print_function +# +# Test the SVE ZReg reports the right amount of data. It uses the +# sve-ioctl test and examines the register data each time the +# __sve_ld_done breakpoint is hit. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +initial_vlen = 0 +failcount = 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print ("PASS: %s" % (msg)) + else: + print ("FAIL: %s" % (msg)) + global failcount + failcount += 1 + +class TestBreakpoint(gdb.Breakpoint): + def __init__(self, sym_name="__sve_ld_done"): + super(TestBreakpoint, self).__init__(sym_name) + # self.sym, ok = gdb.lookup_symbol(sym_name) + + def stop(self): + val_i = gdb.parse_and_eval('i') + global initial_vlen + try: + for i in range(0, int(val_i)): + val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) + report(int(val_z) == i, "z0.b.u[%d] == %d" % (i, i)) + for i in range(i + 1, initial_vlen): + val_z = gdb.parse_and_eval("$z0.b.u[%d]" % i) + report(int(val_z) == 0, "z0.b.u[%d] == 0" % (i)) + except gdb.error: + report(False, "checking zregs (out of range)") + + +def run_test(): + "Run through the tests one by one" + + print ("Setup breakpoint") + bp = TestBreakpoint() + + global initial_vlen + vg = gdb.parse_and_eval("$vg") + initial_vlen = int(vg) * 8 + + gdb.execute("c") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + if inferior.was_attached == False: + print("SKIPPING (failed to attach)", file=sys.stderr) + exit(0) + arch = inferior.architecture() + report(arch.name() == "aarch64", "connected to aarch64") +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except: + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + import code + code.InteractiveConsole(locals=globals()).interact() + raise + +print("All tests complete: %d failures" % failcount) +exit(failcount) From patchwork Tue Mar 17 17:50:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184661 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4451361ile; Tue, 17 Mar 2020 11:10:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtZd1rFGfXOzV5nAPkb+nCvnU7m9DdGOMM0BkeQg+0kChMQVbFPcYNrpcHusYXGVWXB/kaS X-Received: by 2002:ac8:7955:: with SMTP id r21mr364638qtt.289.1584468635427; Tue, 17 Mar 2020 11:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468635; cv=none; d=google.com; s=arc-20160816; b=wNWSA7KntdJAE3C5VtKoIx76dxbMMfmfPgDbsrA4qA6g1QPE6j7m85KP67+qlSZo9G DKZaHRMfuxMiEual1FziWJMRMMPQFDnoCpDD19t3+zh7mT6DIkBDpdl9e0RT3UfIGvoz +NgG+j2Cxuk/1k7O6tscoGSy+ZrYhHl/L8CzP3lS6K+gHaocwUmg2smjpl7Wi83Zru/x 2K3jI4uqh0yL0F84lEkRjCyi5S4YdF1t7Hh+beYuOobduMK1mxW955kAK37yqt7AApDp BowYyVnI8ayTsB/41nBbezmTGDJVjPLH75GPRRYsF9N8koAu0ydwl0EnEh0epR7U86eO LudA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=iBvEUDncqC3Mv+jQK3irHfsoAQSqaRXgCJbGIbs+9L0=; b=hON/Bs/n4Xw8hZHju8gYlnnz2yiHqO3J5tnjfFJZdIcr9ptuXgwVhxbql/pqU49x5v 8l21n8eCZ6H7hPGWjRwzyHU/MQJLHVgCYxukd4xVTXANi8OpNvOWH741YdF9za1meBeo UhWwBDbHHiAOyi79v58Mru3RAcn/YFou87s+GE0llWLxumjr3QdUvwIgWgtG+LUc0s4r kbuo68UaoXtwe70JkhqZRz2tKqK+mrfhrwyJsg4CUSgn3Vayjf5sM/xJuDYPeNVebaQs fNyUMLRedlkc78aa5KMJ+5gPdR9gg/yqo53M0kOsMZcNr2+dw90UiULPsy8sts8oSA2A PXHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cjMefkL6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f13si2533753qte.88.2020.03.17.11.10.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:10:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cjMefkL6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGfi-0002rZ-V1 for patch@linaro.org; Tue, 17 Mar 2020 14:10:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36692) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUU-0005az-Tq for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUT-0000Jq-GA for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:58 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:33219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUT-0000C2-7s for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:57 -0400 Received: by mail-wr1-x430.google.com with SMTP id a25so26922032wrd.0 for ; Tue, 17 Mar 2020 10:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iBvEUDncqC3Mv+jQK3irHfsoAQSqaRXgCJbGIbs+9L0=; b=cjMefkL6PhJUwi3KUx2Azk+AC6dnATdahMTgg26tZVAblnujyci6NtDK37CfVOR82c RTbCCOvvaVt2CF/Md/YcF16R/5UTz1bxKbLq5GlPGLcibnm240l8tNf8bBg1xP5YjpZC ywslHOvy6og+gQN9XEHpC/ST1ekVC1hVPXMcjuM5N5wTIBGnLL2uBtBZ+5b07yDQ0ZyA duC66lyDLm1bd8AR1oZFVePLaSbpv7ocvl+JJTZiAKCy3p8iGed7vJCSYlRM2HzNUD93 D4yg7ADL+wUdQsprudIPQYZSAwuH3Z8jkhJtMCem4jyhi74cLWxgtfAawGT0lbsn9gc4 R+Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iBvEUDncqC3Mv+jQK3irHfsoAQSqaRXgCJbGIbs+9L0=; b=NRVU+6ogFnGBrYWu201b0LEOH6nNMw1IpCKIJgrI33n+TrLMN1KoX9gNrnmBb/JtNm G53Ejdt5hrbVFx+FjGRbJB5/GcT80U1NwZMC1flOA4sLytVo9pdXX+O385W+k4UPWYLL QpVVQdjJEM5sRh0Mx/dDskjGkqKZN2coLKN+g0RdE3gZtLxjztTFYVqlgfWiOqGDUCZL b9LNiZYak+SJVEivGFJko0SZeJodYgJR+bItSdEjjMfFo3fczDuiBZgrTjBBU/XXYJNt x0ebkuQ230t0MQ4niGrDPQmRdssH8jp0RQ7bY8rgg8TNqTbckXdrYIN3ZJQMJuQ8Ef3d u9yg== X-Gm-Message-State: ANhLgQ1u9rfuGgwQbmBXoAL6O8B+LJl1vrml945iZ25NOPMpbUBMA9cQ mot+T/UC/etsyhxkU8r2hNlXuQ== X-Received: by 2002:adf:a3d3:: with SMTP id m19mr145865wrb.377.1584467936142; Tue, 17 Mar 2020 10:58:56 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k3sm5216743wro.59.2020.03.17.10.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:53 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EB9751FFB1; Tue, 17 Mar 2020 17:50:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 26/28] gdbstub: change GDBState.last_packet to GByteArray Date: Tue, 17 Mar 2020 17:50:51 +0000 Message-Id: <20200317175053.5278-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Damien Hedde Remove the packet size upper limit by using a GByteArray instead of a statically allocated array for last_packet. Thus we can now send big packets. Also remove the last_packet_len field and use last_packet->len instead. Signed-off-by: Damien Hedde Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20191211160514.58373-2-damien.hedde@greensocs.com> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200316172155.971-27-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 0bcfc47a7c5..a60ef5125eb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -351,8 +351,7 @@ typedef struct GDBState { int line_buf_index; int line_sum; /* running checksum */ int line_csum; /* checksum at the end of the packet */ - uint8_t last_packet[MAX_PACKET_LENGTH + 4]; - int last_packet_len; + GByteArray *last_packet; int signal; #ifdef CONFIG_USER_ONLY int fd; @@ -384,6 +383,7 @@ static void init_gdbserver_state(void) gdbserver_state.init = true; gdbserver_state.str_buf = g_string_new(NULL); gdbserver_state.mem_buf = g_byte_array_sized_new(MAX_PACKET_LENGTH); + gdbserver_state.last_packet = g_byte_array_sized_new(MAX_PACKET_LENGTH + 4); } #ifndef CONFIG_USER_ONLY @@ -626,28 +626,29 @@ static void hexdump(const char *buf, int len, static int put_packet_binary(const char *buf, int len, bool dump) { int csum, i; - uint8_t *p; - uint8_t *ps = &gdbserver_state.last_packet[0]; + uint8_t footer[3]; if (dump && trace_event_get_state_backends(TRACE_GDBSTUB_IO_BINARYREPLY)) { hexdump(buf, len, trace_gdbstub_io_binaryreply); } for(;;) { - p = ps; - *(p++) = '$'; - memcpy(p, buf, len); - p += len; + g_byte_array_set_size(gdbserver_state.last_packet, 0); + g_byte_array_append(gdbserver_state.last_packet, + (const uint8_t *) "$", 1); + g_byte_array_append(gdbserver_state.last_packet, + (const uint8_t *) buf, len); csum = 0; for(i = 0; i < len; i++) { csum += buf[i]; } - *(p++) = '#'; - *(p++) = tohex((csum >> 4) & 0xf); - *(p++) = tohex((csum) & 0xf); + footer[0] = '#'; + footer[1] = tohex((csum >> 4) & 0xf); + footer[2] = tohex((csum) & 0xf); + g_byte_array_append(gdbserver_state.last_packet, footer, 3); - gdbserver_state.last_packet_len = p - ps; - put_buffer(ps, gdbserver_state.last_packet_len); + put_buffer(gdbserver_state.last_packet->data, + gdbserver_state.last_packet->len); #ifdef CONFIG_USER_ONLY i = get_char(); @@ -2812,20 +2813,22 @@ static void gdb_read_byte(uint8_t ch) uint8_t reply; #ifndef CONFIG_USER_ONLY - if (gdbserver_state.last_packet_len) { + if (gdbserver_state.last_packet->len) { /* Waiting for a response to the last packet. If we see the start of a new command then abandon the previous response. */ if (ch == '-') { trace_gdbstub_err_got_nack(); - put_buffer((uint8_t *)gdbserver_state.last_packet, gdbserver_state.last_packet_len); + put_buffer(gdbserver_state.last_packet->data, + gdbserver_state.last_packet->len); } else if (ch == '+') { trace_gdbstub_io_got_ack(); } else { trace_gdbstub_io_got_unexpected(ch); } - if (ch == '+' || ch == '$') - gdbserver_state.last_packet_len = 0; + if (ch == '+' || ch == '$') { + g_byte_array_set_size(gdbserver_state.last_packet, 0); + } if (ch != '$') return; } @@ -3209,7 +3212,7 @@ static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) const char *p = (const char *)buf; int max_sz; - max_sz = (sizeof(gdbserver_state.last_packet) - 2) / 2; + max_sz = (MAX_PACKET_LENGTH / 2) + 1; for (;;) { if (len <= max_sz) { gdb_monitor_output(p, len); From patchwork Tue Mar 17 17:50:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184657 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4446064ile; Tue, 17 Mar 2020 11:05:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtnIuS6X8jyvn2niH7XSZw1UTrp5RxZwSLqqcs0Rb58as44czoDCdYhsbYwr9nZokttvnC/ X-Received: by 2002:ad4:436b:: with SMTP id u11mr353465qvt.117.1584468340561; Tue, 17 Mar 2020 11:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468340; cv=none; d=google.com; s=arc-20160816; b=JiVy0T70H+ZBJPsqVNeHdGkChbZOwAikCcGhj3t8jjiwSNZKUq8qd/SfTy0BKzHiuU F2DPPgdZRceNBLb3HoIoGy5q9easDnxH7NomZ+1WjlBilRm/40/n7AbkiIskKLhlm57T K2TuSVbq2ZijS44OSMdGRU5E9+ygvbZdwNe84zqpJnPT1ELgOmrV8qrwYxgtP6EImfSm +G1eGvD5fU/riJ/kPCHfq1AkfYa3C9Oo5KRhzHELN7mD8eZ4MC50N9uNDCBbZCKE7mw9 xF+oejt7BjvAvy8Z47O3BuZpJB3yXi6FKMo+u/zcw7uuYZWX3KRbaqKTMSGlmn/iFkxO rn+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=y70yduvZnlJuuEmJKz38qFwzokDPfNTPIIUVc1ktav0=; b=OVz1h81bU1bHAQIvdF3qdoDny+p5GHFgm7Qwx84zrOeo3oaDgaiTR2B3j5uaCg0cgy NEU2yHdDasHIqcPJOW177ZLDzqQ74YxcCQ/YBp8ph4eoMQKujevC9Mp/z2agDcAAiXed Yvp7tzXukZITSdvZrGqwqG1sZfcDl4qTiQvotxDlDoYOS5mYPl/FEcCTIHuULhy5/Omd /F9SPN7AIydZL99qL+I8krdNsTZ+orbDzSe8zpY5TG4r7If7u+86Zly5Fh0wGlOIUY5f 31TiY5R/h28S+igLipACcAlrRV0ENxr7v8IlCAhFykJMKJQFe4TQqea0xIiJAYoOO6Hb 7VGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lix2ZnYO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p65si2514699qkd.49.2020.03.17.11.05.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:05:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lix2ZnYO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGax-0004Lg-V0 for patch@linaro.org; Tue, 17 Mar 2020 14:05:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36616) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUS-0005WL-S6 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUR-0008Vq-6t for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:56 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:55848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUQ-0008PM-Rl for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:58:55 -0400 Received: by mail-wm1-x331.google.com with SMTP id 6so256663wmi.5 for ; Tue, 17 Mar 2020 10:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y70yduvZnlJuuEmJKz38qFwzokDPfNTPIIUVc1ktav0=; b=lix2ZnYOEUi01Log7I7WE+5KIg5Kmcf+6HH7/k98xE8P01xhpa5r1NzfZCM8CyQ/sJ +alaisFp2redPti1cORSloAKExOCo19GkBsiFiwsf6X8BqPXuKwRqr6YWwhsIkdHfTho IWi9PlPXyRLEYr34PWk2KIlfrtSRR1Z/ljgD097cJalxl5d2MnpyanQ8XMDerHctI0Xy w02crGpMwsGen4Pk0lkj6CBPxXl7wyzCha5/qUP4hbFs1lcSpJG/siErFWUQewlK8moz jiJ3IuUsrXa63cCFlzuiV+5WjzIharnoNd0ry7dp+kEu6YscXW0mw9evS1z0v0ro8FEc /ZGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y70yduvZnlJuuEmJKz38qFwzokDPfNTPIIUVc1ktav0=; b=PmYIloyFqInzf5nR4veiQjXopvivtOAPek4dhZYVZm8wFA1gHzREbOvUc5Z5ReI1P3 les0eJpGddkN/6MCcTx0n0TljwfJSteC6WfgZP5Lue5O8O7GLI8qOHGYcx+HRlYGVex6 3id35cXFEavVpVO3ASwa49ymuHawCBHk0mTJO2NVELXDSVuFmO7X7sB/W9g5At2+xcjy c5/ChUvg2KfUkRNPtg71Dc5BvaSyDf8fId+/YFFgXLX0mkqPlcKIJA+WOyWgv7XJItBH mpQRjV2ax3R8K3EIu4QIZdxMMTyub4l5l203ExHAEdT7IBg+5pv7CstokGVaLVG8/P+a B8hw== X-Gm-Message-State: ANhLgQ3STxedag/5oVYo4IKvvaR7bcCX7ckFTQJfU9yFqpP7Fh4b3MXj dwlaw4SVlbHbu7b4I3SkUmirAw== X-Received: by 2002:a1c:b789:: with SMTP id h131mr171297wmf.141.1584467933564; Tue, 17 Mar 2020 10:58:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u8sm5236356wrn.69.2020.03.17.10.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:44 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0D16C1FFB3; Tue, 17 Mar 2020 17:50:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 27/28] gdbstub: do not split gdb_monitor_write payload Date: Tue, 17 Mar 2020 17:50:52 +0000 Message-Id: <20200317175053.5278-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= , Richard Henderson , qemu-devel@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Luc Michel Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Damien Hedde Since we can now send packets of arbitrary length: simplify gdb_monitor_write() and send the whole payload in one packet. Suggested-by: Luc Michel Signed-off-by: Damien Hedde Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20191211160514.58373-3-damien.hedde@greensocs.com> Message-Id: <20200316172155.971-28-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index a60ef5125eb..9ae148cd1ff 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3200,28 +3200,11 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) } } -static void gdb_monitor_output(const char *msg, int len) -{ - g_autoptr(GString) buf = g_string_new("O"); - memtohex(buf, (uint8_t *)msg, len); - put_packet(buf->str); -} - static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) { - const char *p = (const char *)buf; - int max_sz; - - max_sz = (MAX_PACKET_LENGTH / 2) + 1; - for (;;) { - if (len <= max_sz) { - gdb_monitor_output(p, len); - break; - } - gdb_monitor_output(p, max_sz); - p += max_sz; - len -= max_sz; - } + g_autoptr(GString) hex_buf = g_string_new("O"); + memtohex(hex_buf, buf, len); + put_packet(hex_buf->str); return len; } From patchwork Tue Mar 17 17:50:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 184664 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4454057ile; Tue, 17 Mar 2020 11:13:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsFgDh88HZZ/DDB+u6dpHGtJpYAaBK1WlVIQBLkFh5/4Uw4tZNkeghNGuttkzZKD2aa/Ggm X-Received: by 2002:ac8:464a:: with SMTP id f10mr403282qto.169.1584468793897; Tue, 17 Mar 2020 11:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584468793; cv=none; d=google.com; s=arc-20160816; b=SBq91DAAXE/Nfg8GxzgtIzSFk5aFCiDuWS+jf46Pe40oGOEXTUSqaGYd3ElwY2cFQQ HdCfda1m90QPe/FEV5JdhsUdzymiAmNmo/34OjJ+XCoQlSYiMS4TP5yaUUL1qZSK1acZ 0z1Vovh7tSkDBaeKfpZVyx/VOr2y8rIeO3EYFML2wNA/qc8Ctrd2X47696pp/yjT37Ls QjcsOQ96FIi6D3vW0zUYb4nqbJ10FGd6PctQrKW5r0xtMDAk9CP4jhHUqtJBALeSsXKp 5H8qBs04ISOs6wcIreOGd2T6nOirss37b2TWUabWsPuh3G87pT2e6IJn3Pd+JS96So/t RVKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=/er0YYsHIwE0mZN9mnJ6X1m0HeTDXCeZYTdLs35Tmio=; b=roydh7QBEObv3dWJl0JE+caYO5bC8CLBKGQv0Iim1YOwfoHl0NQxoCy1cZTNEAbaV7 BsmFw8VkQ9KYJJDWzcMa+u5T4VZEp2BA/omyQMRBm3l89KbbCHeK05aKeph9aZk7iSv0 xGg0BOuG523i8ij1iS81QhoKnS6nGlsOV74RbJU/DDSrkpz27bmesSOaeh9rXO/DTS7M Lj+oh/ChLg5/FVg2dxkjcGkA+yXUU6brtarjqUOdFe+mT4wHIiuZl1tZ2lae++1WeUfY QUx1HgBkDJgSBlNtYvFGMY/c9RNGygElHaVNSWeWcKmhOK1hiYi6rcXUtEwCYtG9MCiA //YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z8emhfso; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z2si2450685qkz.343.2020.03.17.11.13.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Mar 2020 11:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z8emhfso; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGiH-0006Nc-F2 for patch@linaro.org; Tue, 17 Mar 2020 14:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36952) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEGUd-0005tZ-6W for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEGUb-0001D1-Td for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:07 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:52856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jEGUb-00017C-Li for qemu-devel@nongnu.org; Tue, 17 Mar 2020 13:59:05 -0400 Received: by mail-wm1-x342.google.com with SMTP id 11so282009wmo.2 for ; Tue, 17 Mar 2020 10:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/er0YYsHIwE0mZN9mnJ6X1m0HeTDXCeZYTdLs35Tmio=; b=z8emhfso8Got270aizEytcNYUCxFPHHSre6nGBDWQVuf1JopFRdnTOEYjkBk80UVEi p86OHjGiGfgiux1z5sti7OwuSiBW3svKHweTR6tqOTOUdVSTQtU6wDEroY/CJL9mvlyH WTp4+1IsCLGGD3s4ie4YKlH3GAIKwvnUMW1snNpYpvIxrDALlKqBftNvE6FT0xFmDn/a GMzGB/8sHAwGfO1oVsC+Qa+EDAwQWZO+ptM9ZtLwnbH6/zFe2E2Pc1cC2NWOsECP7Kkn pdkVJBymlrR8Q3DgVIPLSo7VNySm9twYqvaA2YDY4nSl1Eb0b1odtPFXupvyc7bHN1v8 EffA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/er0YYsHIwE0mZN9mnJ6X1m0HeTDXCeZYTdLs35Tmio=; b=fbRzt6FeJy5EnzIkIFQFsiB5ryV1IGqSiXiXeYAUO0My+UASZXCJeJg+hWQSOEi6IW KrmNkq0S+GRNICTZ0Q/Ah3iBuFCGAEazSDrqN/hwRrAn8oiVgjXk/WQLvW/mm6bVAWAd 0cUQIKIs3pRYpovu2RLeMeBapMGdaxHGmiFnQmxKwToEOngq6QgJcHhz+CAif3rityNL TfAiT0Qs0gy9rGTqNIqeAaKz0hP79r4qufzv63XqxdHNYTrGe6Y5MBdbQtsTh0wsRIra ndzFC8lxb7xAbzlG/kxG1Okdar95Bwr6fjbxsxKpvTFddw3Wggz1ZZY8TMr5g6+F+nOn 9kMQ== X-Gm-Message-State: ANhLgQ1/PPE+FuGjaTiKFpINLOCU/6cPVlFA3g07Id9hc5D0sK5SAM+K uqfCKsrfWyb3v8Wwi6/fa9IUWw== X-Received: by 2002:a7b:ce81:: with SMTP id q1mr236610wmj.156.1584467944667; Tue, 17 Mar 2020 10:59:04 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s131sm215016wmf.35.2020.03.17.10.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 10:58:54 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 244871FFB4; Tue, 17 Mar 2020 17:50:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 28/28] gdbstub: Fix single-step issue by confirming 'vContSupported+' feature to gdb Date: Tue, 17 Mar 2020 17:50:53 +0000 Message-Id: <20200317175053.5278-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317175053.5278-1-alex.bennee@linaro.org> References: <20200317175053.5278-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Luc Michel , Changbin Du Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Changbin Du Recently when debugging an arm32 system on qemu, I found sometimes the single-step command (stepi) is not working. This can be reproduced by below steps: 1) start qemu-system-arm -s -S .. and wait for gdb connection. 2) start gdb and connect to qemu. In my case, gdb gets a wrong value (0x60) for PC, which is an another bug. 3) After connected, type 'stepi' and expect it will stop at next ins. But, it has never stopped. This because: 1) We doesn't report ‘vContSupported’ feature to gdb explicitly and gdb think we do not support it. In this case, gdb use a software breakpoint to emulate single-step. 2) Since gdb gets a wrong initial value of PC, then gdb inserts a breakpoint to wrong place (PC+4). Not only for the arm target, Philippe has also encountered this on MIPS. Probably gdb has different assumption for different architectures. Since we do support ‘vContSupported’ query command, so let's tell gdb that we support it. Before this change, gdb send below 'Z0' packet to implement single-step: gdb_handle_packet: Z0,4,4 After this change, gdb send "vCont;s.." which is expected: gdb_handle_packet: vCont? put_packet: vCont;c;C;s;S gdb_handle_packet: vCont;s:p1.1;c:p1.-1 Signed-off-by: Changbin Du Tested-by: Philippe Mathieu-Daudé Message-Id: <20200221002559.6768-1-changbin.du@gmail.com> [AJB: fix for static gdbstub] Signed-off-by: Alex Bennée Reviewed-by: Luc Michel Message-Id: <20200316172155.971-29-alex.bennee@linaro.org> -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 9ae148cd1ff..013fb1ac0f1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2130,7 +2130,7 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.multiprocess = true; } - g_string_append(gdbserver_state.str_buf, ";multiprocess+"); + g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiprocess+"); put_strbuf(); }