From patchwork Thu May 20 17:42:56 2021 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: 443304 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp199509jac; Thu, 20 May 2021 10:47:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLI3gvWF/tabz0EjK+lV7FOUqGk8S/5ru4k8oJUttByBFUviZgOFkJP8E/wmZcIyNw955P X-Received: by 2002:a02:cb4f:: with SMTP id k15mr8171863jap.3.1621532853844; Thu, 20 May 2021 10:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532853; cv=none; d=google.com; s=arc-20160816; b=cO3/8cWRDBK7OwWakwkeQMmKzvdRLJbGtirXKliIkzk5cHWUcIV4kqMVOmawvvbgkE NvIpeH+Jzaa5isxN+pAaX7BfZ0vkp1JBTC+9h+Gd4bwBXudC1VAMHua5g79U048a9Uwo 72R3Ig4I7ATQUs+D7zLHbq69gIdyxbWiRkAclFQnxmWcnw4nsGWy7Is2A6gDfdv+d9KV 32zkj5OC/u7nMaqVAiFhxEzm3r0GEn1n2Zx5lMqQeFhw3YnTeZdWvviGqec3/74GVZpc be5QP+BbXBmXOcgr7D5vpTN+obLO0+DKPjHlx/HyA2c4VkbkMPG/tFNq49x/yDieEXcO h4FA== 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=RQhUkmM1hd8VG9HynbCnkI01fYn9Z50vQ7P065/2YIg=; b=DeW+AQ+oN5v7RWu1RVRqNrihCr70W95sCHdSrVzLNEWQc5VPyjRUXkuQKEyGBmEdPR f9vKLCSaitOzFuermsucKmLyf6W6DFE/R//L8Qq6DbcMXRLJlZUHCI/e6ShAokr5gDq+ +w945jPOSS86haTGZpGQh9GzYzG+rveKMWXByz4+tJyzmDe8KDZ23pAAD+MuJx9SnUdj 0doVuknaDhZH/JPyU+JllyTze8br6MPeC727Avdj8KQlhudy/ZzzDK/bZTAiUewol1eY 2bNZE6KkbWJB1w2ziYOFTQLsOSx4zDbxoWLVcEpZ52Mw1p/EiDIr7fiAPQAgbgqmC6eR nNsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OAqW6QLH; 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 t14si2767971iol.93.2021.05.20.10.47.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:47:33 -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=OAqW6QLH; 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]:50848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmlh-0000ML-6H for patch@linaro.org; Thu, 20 May 2021 13:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhT-0003CJ-6q for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:11 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:41618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhP-00013N-Gu for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:10 -0400 Received: by mail-wr1-x433.google.com with SMTP id d11so18489385wrw.8 for ; Thu, 20 May 2021 10:43:07 -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=RQhUkmM1hd8VG9HynbCnkI01fYn9Z50vQ7P065/2YIg=; b=OAqW6QLHWBXgM0vR6YjUEK9p2adLS/VOZjljA1lCjYbXRkX3CvlDcLAfXiGn6TH9nt bXYBQeJpyPtOEDy6aO7HTnLqH2m4OqV/NEjZL5b1WCNdiUdVm7oTmkJbmgB0Bld8z4c0 M4Slt8t+LNIC7JXgUP9+wJo9LCC+2dR4OWIQCHiJ/hntlzConHiz/sAUqueBD81uQcmQ 8ETfA6BCA00HVSA3Hef3FldTpOGZbEvgWKw98uXuqI116Fbk+AZbisX3ak/kshS9Qs/f PAWTZbem1Anw+w7VzOMvtBLVfqSKsCiXrM3Iy/2fm1MZh9dkAEesStOm88P8tUOtaJfc lvvg== 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=RQhUkmM1hd8VG9HynbCnkI01fYn9Z50vQ7P065/2YIg=; b=awpRknsGc9TyiRMZIDzW4P69yk4OWa6aYhv3FKDCqOWBrKoxTukLH+uJ7wJVBHiJGd e388w5RnzjVpVLhMibxvQNmolx4bX962hJcBJVL/Oc0kdPiZgFuvD1oiVRyVa68RtDdT kLRGixKhcO5mqy0DoldnjfVDxKzJjuhj0+oEpfCUNGUCsW6wLPNpbkz2c5t4zaVkCiKg Km+lZmRXw345cckRjk3nHJ2Rzg0x2XTz4sUJbo8swJUH79EY5GdVNMiyzYAv3wHh9pUe 5RbwuSHM7vlyd8Qn33V2B57fAKQViy8iTU47sk7+wMfFwUlz/my1BQ9Rk48OY2TSw2hX t8iQ== X-Gm-Message-State: AOAM532//cmi/baVZkGXf/JR7Zmpr8G9NUVJ0pTJ48L1Rv5mgDlghXTN GHXiHWQpPiM5yz8rIQAeiAH3vA== X-Received: by 2002:adf:e8c3:: with SMTP id k3mr5488691wrn.255.1621532585880; Thu, 20 May 2021 10:43:05 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b8sm4219135wrx.15.2021.05.20.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9353E1FF87; Thu, 20 May 2021 18:43:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 1/8] tests/tcg: add a multiarch signals test to stress test signal delivery Date: Thu, 20 May 2021 18:42:56 +0100 Message-Id: <20210520174303.12310-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, Richard Henderson , f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds a simple signal test that combines the POSIX timer_create with signal delivery across multiple threads. The aim is to provide a bit more of a stress test to flush out signal handling issues for easily than the occasional random crash we sometimes see in linux-test or threadcount. Signed-off-by: Alex Bennée Message-Id: <20210504100223.25427-29-alex.bennee@linaro.org> --- tests/tcg/multiarch/signals.c | 149 ++++++++++++++++++++++++++++ tests/tcg/alpha/Makefile.target | 7 ++ tests/tcg/multiarch/Makefile.target | 2 + tests/tcg/sparc64/Makefile.target | 7 ++ 4 files changed, 165 insertions(+) create mode 100644 tests/tcg/multiarch/signals.c -- 2.20.1 diff --git a/tests/tcg/multiarch/signals.c b/tests/tcg/multiarch/signals.c new file mode 100644 index 0000000000..998c8fdefd --- /dev/null +++ b/tests/tcg/multiarch/signals.c @@ -0,0 +1,149 @@ +/* + * linux-user signal handling tests. + * + * Copyright (c) 2021 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void error1(const char *filename, int line, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s:%d: ", filename, line); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + exit(1); +} + +static int __chk_error(const char *filename, int line, int ret) +{ + if (ret < 0) { + error1(filename, line, "%m (ret=%d, errno=%d/%s)", + ret, errno, strerror(errno)); + } + return ret; +} + +#define error(fmt, ...) error1(__FILE__, __LINE__, fmt, ## __VA_ARGS__) + +#define chk_error(ret) __chk_error(__FILE__, __LINE__, (ret)) + +/* + * Thread handling + */ +typedef struct ThreadJob ThreadJob; + +struct ThreadJob { + int number; + int sleep; + int count; +}; + +static pthread_t *threads; +static int max_threads = 10; +__thread int signal_count; +int total_signal_count; + +static void *background_thread_func(void *arg) +{ + ThreadJob *job = (ThreadJob *) arg; + + printf("thread%d: started\n", job->number); + while (total_signal_count < job->count) { + usleep(job->sleep); + } + printf("thread%d: saw %d alarms from %d\n", job->number, + signal_count, total_signal_count); + return NULL; +} + +static void spawn_threads(void) +{ + int i; + threads = calloc(sizeof(pthread_t), max_threads); + + for (i = 0; i < max_threads; i++) { + ThreadJob *job = calloc(sizeof(ThreadJob), 1); + job->number = i; + job->sleep = i * 1000; + job->count = i * 100; + pthread_create(threads + i, NULL, background_thread_func, job); + } +} + +static void close_threads(void) +{ + int i; + for (i = 0; i < max_threads; i++) { + pthread_join(threads[i], NULL); + } + free(threads); + threads = NULL; +} + +static void sig_alarm(int sig, siginfo_t *info, void *puc) +{ + if (sig != SIGRTMIN) { + error("unexpected signal"); + } + signal_count++; + __atomic_fetch_add(&total_signal_count, 1, __ATOMIC_SEQ_CST); +} + +static void test_signals(void) +{ + struct sigaction act; + struct itimerspec it; + timer_t tid; + struct sigevent sev; + + /* Set up SIG handler */ + act.sa_sigaction = sig_alarm; + sigemptyset(&act.sa_mask); + act.sa_flags = SA_SIGINFO; + chk_error(sigaction(SIGRTMIN, &act, NULL)); + + /* Create POSIX timer */ + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGRTMIN; + sev.sigev_value.sival_ptr = &tid; + chk_error(timer_create(CLOCK_REALTIME, &sev, &tid)); + + it.it_interval.tv_sec = 0; + it.it_interval.tv_nsec = 1000000; + it.it_value.tv_sec = 0; + it.it_value.tv_nsec = 1000000; + chk_error(timer_settime(tid, 0, &it, NULL)); + + spawn_threads(); + + do { + usleep(1000); + } while (total_signal_count < 2000); + + printf("shutting down after: %d signals\n", total_signal_count); + + close_threads(); + + chk_error(timer_delete(tid)); +} + +int main(int argc, char **argv) +{ + test_signals(); + return 0; +} diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.target index a585080328..49ce5cd69f 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -14,5 +14,12 @@ test-cmov: test-cond.c run-test-cmov: test-cmov +# currently broken: executes a halt on sigreturn leading to being terminated by signal SIGILL (Illegal instruction) +run-signals: signals + $(call skip-test, $<, "BROKEN") + +run-plugin-signals-with-%: signals + $(call skip-test, $<, "BROKEN") + # On Alpha Linux only supports 8k pages EXTRA_RUNS+=run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index a3a751723d..3f283eabe6 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -30,6 +30,8 @@ testthread: LDFLAGS+=-lpthread threadcount: LDFLAGS+=-lpthread +signals: LDFLAGS+=-lrt -lpthread + # We define the runner for test-mmap after the individual # architectures have defined their supported pages sizes. If no # additional page sizes are defined we only run the default test. diff --git a/tests/tcg/sparc64/Makefile.target b/tests/tcg/sparc64/Makefile.target index 408dace783..279362391d 100644 --- a/tests/tcg/sparc64/Makefile.target +++ b/tests/tcg/sparc64/Makefile.target @@ -2,5 +2,12 @@ # # sparc specific tweaks +# currently broken: hangs after the first thread exits +run-signals: signals + $(call skip-test, $<, "BROKEN") + +run-plugin-signals-with-%: signals + $(call skip-test, $<, "BROKEN") + # On Sparc64 Linux support 8k pages EXTRA_RUNS+=run-test-mmap-8192 From patchwork Thu May 20 17:42:57 2021 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: 443302 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp197347jac; Thu, 20 May 2021 10:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwg+ffEZrKK5vZQqmmJSothblX6Oyqi7rzlhgwYINlil6Eh1pJZ3N6xD9iQFVo919DSd2+k X-Received: by 2002:a05:6e02:ea1:: with SMTP id u1mr6235384ilj.49.1621532689467; Thu, 20 May 2021 10:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532689; cv=none; d=google.com; s=arc-20160816; b=t6njzK/sVgCEMDUep0gBUDZhMChc0N/dH1flETQAy9dbKH/bQAnt+/kA7nJbLhSuS5 weuFPdLa5BnBfUwjOjiUeaGVjGpG2midoNmGiqzTVRwZPVt4tATOGveX/tr+IunElYHA 4AAcimnOXQPw/5gUbZLtyDdxRHBnyB/3AFxPOOxZ8p2U1qihsBJ56WqX3m2xLwpmk/0h k2UqC205gKHNa6C3Bz6VPlSPSqA+Tq6NZeQYWEnmxbIgOyXtA4nSVO/7LtZZugB7lbgW a5xcnmkAA/zWv7jGF90XaN7TKqk4gtQrUrWXs9MRalhzy9xEt9TYkbjfBClvAlaVaS/M BmTg== 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=lRpwbl4DEv/eEA7OU49eaRq4xSF4MJNiaXldaMKBRug=; b=ueucfNCKs2h0IsZq6iql3WzdvQbantLf3FG2ToxpEyZQyxc7fIFoaLX9sVkdAURjlg qG5QjOug6rASHU1PFFxUhQEMjnQdUeiaFtgS+JWIH1PlG44CuydWa7Ts2Ws3F8lxQBPu uBy0aOJ4ZhkVWQvaPlPLbU8IyWcuZtAIj3Qs79fWRAjzHCgneXxuEeOm/WnaUo1AYg1s XF6j0V2DVnaXeXv11TEPbDGmnhGji3zgPtyKSWKF603lG+Rtb//LIQjMzj3FyyWQySWN n/T1CkJJ0wB5OURxwnIJxTvol3+bXEP532e4pSr9V8T9aLOvHcAMEhTjegwXwGWb+SiL oxMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rKVt4BsK; 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 z11si2786408ioq.81.2021.05.20.10.44.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:44:49 -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=rKVt4BsK; 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]:43926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmj2-00048f-Sh for patch@linaro.org; Thu, 20 May 2021 13:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhU-0003FW-2I for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:12 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhR-000157-67 for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:11 -0400 Received: by mail-wr1-x434.google.com with SMTP id y14so16436367wrm.13 for ; Thu, 20 May 2021 10:43:08 -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=lRpwbl4DEv/eEA7OU49eaRq4xSF4MJNiaXldaMKBRug=; b=rKVt4BsKqB1XsDy3SD0DVeqwrhKoultdAbReL2X73FqplJg1eNNxapG6DCrLkDLSUj 1zbo9NfKqfDzkkF4/GrAYi83tuQfQFgL3Fs+NQzDAGxRWGlvK4vq9L5DYrLp55k8JKdc Fe3pf31WOfiJeb4zeTnk5BStWpaMCu4Dm7+R9MKQtdDQpERwGay7Iszl9S00aOqfJ0RE LINAErKPoFbxcvW8I6eqwbaY7I6KX9ot04Yak78euRWEy9ZJlNNWPEfDfJNle3EwXbgl NuDOoDFpE7sVQQsyUFq2X8b9UDu4ZrnXLLZdAAoxn/9u4wG91h8gvEgirUm2C1dwbika d7fQ== 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=lRpwbl4DEv/eEA7OU49eaRq4xSF4MJNiaXldaMKBRug=; b=egEZmzFIYKCCBPeAtfTSySE9JANFkV75kdqW3XyQkwwNRLHhXl/gpeYCN8TpazkV2H sS70gsceVYd69aHk5DzzkDcwk/zIzPrBPhPmvNdobEah0/KTQmWsASiSfgP6UPOlqvIQ oZMXpt+Su5Y4NAI2pIiqhW7u6j+tGTVKvZ0uqAklw+bXj/+aBx2KD63SLdhe6vdbO+5/ c37lRga45vlHX8osI82d4y2UJ+ToUU/fpCO2nA/x8zRuYzid/QSp3dXubCPalqBNA9zJ +tOXcHpu+5Kl2EJSBBSZQ6cY1x4UI0hGH9lKNz5ezGGqpboSGDgAVtW57TMGRkZFiztZ 19Eg== X-Gm-Message-State: AOAM530fBS0ahUgQW1SF0XkLL9NNnmo5BSgq/07TG6h/BdA+ai0XzN4j aU955tO1Y9M4Kjt4ZkX6pm0TEQ== X-Received: by 2002:a05:6000:504:: with SMTP id a4mr5565132wrf.51.1621532587858; Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k20sm3835964wrc.1.2021.05.20.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:06 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B3E4C1FF8C; Thu, 20 May 2021 18:43:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 2/8] gitlab: explicitly reference the upstream registry Date: Thu, 20 May 2021 18:42:57 +0100 Message-Id: <20210520174303.12310-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, Thomas Huth , berrange@redhat.com, f4bug@amsat.org, Wainer dos Santos Moschetta , Willian Rampazzo , stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since c8e6793903 ("containers.yml: build with docker.py tooling") we don't need to manually pull stuff from the upstream repository. Just set the -r field to explicitly use that rather than the current registry. Signed-off-by: Alex Bennée --- .gitlab-ci.d/containers.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Willian Rampazzo Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 765408ae27..3fb3c14f06 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -12,10 +12,9 @@ script: - echo "TAG:$TAG" - echo "COMMON_TAG:$COMMON_TAG" - - docker pull "$TAG" || docker pull "$COMMON_TAG" || true - ./tests/docker/docker.py --engine docker build -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker" - -r $CI_REGISTRY_IMAGE + -r $CI_REGISTRY/qemu-project/qemu - docker tag "qemu/$NAME" "$TAG" - docker push "$TAG" after_script: From patchwork Thu May 20 17:42:58 2021 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: 443306 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp201178jac; Thu, 20 May 2021 10:50:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuI3iBTtaf2AbfO4E918KbawgDqvTz5wIl5MByDhWC+jyJ2cdy8kjc/OhawDUC4JAJDcyG X-Received: by 2002:a05:6e02:e10:: with SMTP id a16mr5700035ilk.56.1621533003408; Thu, 20 May 2021 10:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621533003; cv=none; d=google.com; s=arc-20160816; b=Bsr4EVwZnZmh9vHj61zMQ7aHFLZ+sdFxgAcMxBFtoScxN5rguDDEpgzw504DyjKJ3R SbA/4jpPnStPYuHw9AW1UJp+ujq32gonrOuEi0IIQOJ0wowS9u8Yzk7M5cmMBIcbMmUZ y5tkGGi6i3GbgKCLlpAYXOJ8mh0zmxj/jMIQo2oznGPlvj15gg0g4N4xueYb0MSayQid HRIdQLUfldYLfZmBv8eSyAxuo+Ks7dZesel4kwSAodrs3jTzM6FSkBThPJutk2w3ZnOJ PRtrAB56D+b5MV0qDdyE37jwe2xMLpUtuMSQjKfmWsg596R75PIimJdX4oImU7+Gr2Sx nnEA== 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=ZqZq31xIHMpm7PrjzBNfBJf8EWF7gp75FhioXeH7/II=; b=AEyaD9YVtaZ9mM9T+N7x8w8hyA1z7MrgZelEiX7/mIR2Ev3n/6JDyRgNVapKDEyb57 6q9lYsQEq+HFO0yb515m55Cua0kgIEW0qkyqB0nlv6IUQpXnSc30Xl1mIh6VoVyRa+Q3 kYP6QdYNWBOMCl5rMse5iQYp0rpDgoNy3jlpTGEOMva0d7eisl4zWxepgDLj3gaKTR9l p4tAlsNBjtTW6ND7Fy0n7HnYWsIlirdUkH3k4ekIfc1sBceRY/vF2SUFSzIzDfSv2BBg xRmmDFOTY6E263CeIxwncJDR9qi7h0CKwL/tPT0ws0Qt9/2oTsGiZZUSex1jWE7Nk4wB Tp3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zNfSRLNp; 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 u12si3011410jak.73.2021.05.20.10.50.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:50:03 -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=zNfSRLNp; 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]:58114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmo6-0005Jp-RP for patch@linaro.org; Thu, 20 May 2021 13:50:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhT-0003Dw-Qa for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:11 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:37723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhR-00015C-VV for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:11 -0400 Received: by mail-wm1-x334.google.com with SMTP id f19-20020a05600c1553b02901794fafcfefso5289621wmg.2 for ; Thu, 20 May 2021 10:43: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=ZqZq31xIHMpm7PrjzBNfBJf8EWF7gp75FhioXeH7/II=; b=zNfSRLNpt/dQDSEvgY+LQ3B5iZjfyPMbVVG9mbCFiH7+ZsBJ4T/NtaO9nP6lYOT4jR D7lPteeDf3rFgWduHhoywRAX1bNvS7YpM9STXGQKD5eUfWkH5zzRNgcYg9Z2WJCAiXSH J7e1LdmQyWDhpvGhSkOLYUWYV0vqdCk1OmsSKsxfbbhjZZxi7uJ+mThiI9u1Op/EwtOz mvCMVLgoXBigizwLewxc7FWWJBKb6x03GIlsOi3ohVXDJ4XW4jkkPWzkiYFnkibza1xo +BR2qY3LISBWGn6MI5hyiHzz1fF8CcqIw+ISscuj5m7yXbWnyMVsXhGpebTBpETcHePb FKSA== 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=ZqZq31xIHMpm7PrjzBNfBJf8EWF7gp75FhioXeH7/II=; b=WoZqhDqXSKew7b8PnxCVubYDcrwi+HpMXg3IfIwfFT8faDPQNGJGk/XBKci4NzPCuD IHjivwJBshVrRO6YddMxfaoGO/HxbzJvKUuX+7s0f4ovUdOfeVGHvGAiJyq9zzqgR9Be XSot8sVilsWSi6EkKnksfObtCjAAhqm2csAZ1DW3bzWBGVPMKUjKdbCx0pKaoVFpovsB /cbGEMzCGKq2nKTGF/gHMjNmO1Viv3thO3PuBr2KKBTUab7POolZQliSjcKNIfoWz8sI c56RqSXpw2wYPoRRkXj3ciZezvQcUh4TP9wGXWcYYN1M8rLxY8sXEIwwsMaAnhk4r2bu FPTA== X-Gm-Message-State: AOAM531v98NONPR2XITGt7c08mvlb40PciXAZ4p2rM/lQSvRqS/lqnPk JEQJFi5KELAemWWSwODxixurjA== X-Received: by 2002:a1c:b403:: with SMTP id d3mr4780296wmf.79.1621532588557; Thu, 20 May 2021 10:43:08 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s11sm7492865wmf.14.2021.05.20.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DCBAF1FF8F; Thu, 20 May 2021 18:43:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 3/8] gitlab: add special rule for the hexagon container Date: Thu, 20 May 2021 18:42:58 +0100 Message-Id: <20210520174303.12310-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, Thomas Huth , berrange@redhat.com, Cornelia Huck , f4bug@amsat.org, Wainer dos Santos Moschetta , Willian Rampazzo , stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The hexagon container is always manually built but of course not everyone will be building it themselves and pushing to their registries. We still need to create a "local" registry copy for the actual gitlab tests to run. We don't build it in this case, just pull it across from the upstream registry. We disable this rule from running on the qemu-project itself so it doesn't accidentally wipe out our master copy. Fixes: 910c40ee94 ("gitlab: add build-user-hexagon test") Signed-off-by: Alex Bennée Tested-by: Cornelia Huck Reviewed-by: Willian Rampazzo Cc: Cornelia Huck --- v2 - fix silly typo --- .gitlab-ci.d/containers.yml | 27 +++++++++++++++++++++++++++ .gitlab-ci.yml | 2 ++ 2 files changed, 29 insertions(+) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 3fb3c14f06..088c7e68c3 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -101,6 +101,33 @@ armhf-debian-cross-container: variables: NAME: debian-armhf-cross +# We never want to build hexagon in the CI system and by default we +# always want to refer to the master registry where it lives. +hexagon-cross-container: + image: docker:stable + stage: containers + except: + variables: + - $CI_PROJECT_NAMESPACE == 'qemu-project' + variables: + NAME: debian-hexagon-cross + GIT_DEPTH: 1 + services: + - docker:dind + before_script: + - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" + - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest" + - docker info + - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" + script: + - echo "TAG:$TAG" + - echo "COMMON_TAG:$COMMON_TAG" + - docker pull $COMMON_TAG + - docker tag $COMMON_TAG $TAG + - docker push "$TAG" + after_script: + - docker logout + hppa-debian-cross-container: extends: .container_job_template stage: containers-layer2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f718b61fa7..b2f929c758 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -421,6 +421,8 @@ build-user-static: # declared. The image is manually uploaded. build-user-hexagon: extends: .native_build_job_template + needs: + job: hexagon-cross-container variables: IMAGE: debian-hexagon-cross TARGETS: hexagon-linux-user From patchwork Thu May 20 17:42:59 2021 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: 443300 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp196993jac; Thu, 20 May 2021 10:44:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcaCVzjghy61h5VXZL/UNoJgqpmouJwOOng70ambPLhqp2Zon85fyr1CPAKbwJqzpnhM2F X-Received: by 2002:a02:900b:: with SMTP id w11mr7530775jaf.5.1621532663290; Thu, 20 May 2021 10:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532663; cv=none; d=google.com; s=arc-20160816; b=l59Yg6yEJguoQfQnd1kkbxC0vXUUaIGcRdWwgkRE+K7/9Y17E8q0IeSsFuQ0taROzW p9ceTlBGW4/6O02cZiWhK2fObjUm0qH2T59KIM3FwVNp1KgiOXmc3AKb44mChLCyXG44 oQ79C8Rl2A0+WMRicKNQ4dPumxb8XVfWoSacAeSbtuwxtdjgtJa9gwYJBdIDR2xghUAC 3YAMpaoRliszdiiwht8yFg6/WgcW1NNmswKyIWxkyvuJfz5IN0le45q+N3HLa91xEV8c KsPr+VSxUrUHtqjfKsJdEZ+DGhseQb1Ox78X5zzW0X//8KTTJMZpHbm51T2ayvDhYEis pvjQ== 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=IIiaXXWvs7n+iPufxQMNc/1JVO6hJcCtlhG0IxEVHLs=; b=fm35LwKw7K0MfoHR/lPA332RdbTe53sWsWqyqv920/JJjNoI186hgCV0t7LRh/vyWq kz1frh2VpTdA4AV07pEod+JmYMELAMJFiN55wnwI0t2cR4l5D9BF41FRT2BbOkGHkVhy GfelMt1JRQZ2MxP8aoGwuqzMjEIVrkZWAZhAotjgmFeqgJk4qR55f9WRwfGlU5zPQQHs szhb13MwTXGICnNxA42vm3/S8wZoUZKIPqnZ+llr93kKn/hV5OoAswnB232LHaaDFe38 +CWLqzc5YdlyItYb7PSaSs4rlkm3z9j8T2Rq5TyqV2FCgkqGNys6naTfWFRRruLzSOaz bhXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x6SurHdZ; 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 g5si3079781ilq.106.2021.05.20.10.44.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:44:23 -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=x6SurHdZ; 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]:42806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmic-0003OH-Nh for patch@linaro.org; Thu, 20 May 2021 13:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhV-0003J9-N0 for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:13 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:54909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhT-000160-P3 for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:13 -0400 Received: by mail-wm1-x32f.google.com with SMTP id o127so9683532wmo.4 for ; Thu, 20 May 2021 10:43:11 -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=IIiaXXWvs7n+iPufxQMNc/1JVO6hJcCtlhG0IxEVHLs=; b=x6SurHdZGHF4s/ndxsgeItdovn9gVa7pgKZGQesAsOvMi81fO0OaBxQIGSRfhPg/Lt 8uhIIvgzNUQqfPL9urti+p8LXJVI3vr3sF+dWuutFLXRBV+QUJbtaU2DEpJUoeUt7Zqb GrTMx9YAZ2g2KVjX5b6RD4XmzTTyGSERaWLf3qro7BJqkJw5+XHkaTKmbi8frArmoOJF hwsVX67PapkPRJKQRCdiPETDowHjqN8uM4t7sT8KoSzkYf4A5pALbi/muBqcfAPccAwG p/E+FDQXy5xOQgPelzGfrS8xOiWVUrNqGQhcyPOJPyqY3TO3fglVDAHhiM1OlTLfPHfw oppw== 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=IIiaXXWvs7n+iPufxQMNc/1JVO6hJcCtlhG0IxEVHLs=; b=PFCrFoLyK8Vrx0nmGEy1dH3StyVpsR1XF9QFZzNsTqw8EZ1ilYYio3T7KLdrwuiKpi y3ZeVWrY5KL4j8jXV6S60uCbtHmtZz24JvyBntC4pNzha4Mqn4xFTA+uW5U2UmfgFHDd g98GKMrne3KVxdIfpGkGtp2+jZzB4mBTDD3WnhFH7Kfh3aioUK2Vebbm06wjBYpZ1P/d A3md2LjM8dO92GBKDx39EdmiSp9u0HYUepb0hfSaXpB/8B51a6yPSoVHmMSH2tHyHreo pen2ePc7C6UNFC1pSGUh97ysHtmZHeinFrrzfE6J4Os+o2yDGVM4CG0uG39LgHDt/4LX BHIw== X-Gm-Message-State: AOAM530q8NPoxKwyuEJs1pCdc0jGpvbc9xtzgJEJJN2ITiybg5W8p8D4 EAMyZxxxXSIP4kg52VRiHzsRPQ== X-Received: by 2002:a05:600c:19c8:: with SMTP id u8mr5242353wmq.50.1621532590318; Thu, 20 May 2021 10:43:10 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i15sm1554489wru.17.2021.05.20.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 102D51FF90; Thu, 20 May 2021 18:43:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 4/8] gdbstub: Constify GdbCmdParseEntry Date: Thu, 20 May 2021 18:42:59 +0100 Message-Id: <20210520174303.12310-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20210505170055.1415360-3-philmd@redhat.com> --- gdbstub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/gdbstub.c b/gdbstub.c index 9103ffc902..83d47c6732 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1981,7 +1981,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) exit(0); } -static GdbCmdParseEntry gdb_v_commands_table[] = { +static const GdbCmdParseEntry gdb_v_commands_table[] = { /* Order is important if has same prefix */ { .handler = handle_v_cont_query, @@ -2324,7 +2324,7 @@ static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) } #endif -static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { +static const GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ { .handler = handle_query_qemu_sstepbits, @@ -2342,7 +2342,7 @@ static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { }, }; -static GdbCmdParseEntry gdb_gen_query_table[] = { +static const GdbCmdParseEntry gdb_gen_query_table[] = { { .handler = handle_query_curr_tid, .cmd = "C", @@ -2420,7 +2420,7 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { #endif }; -static GdbCmdParseEntry gdb_gen_set_table[] = { +static const GdbCmdParseEntry gdb_gen_set_table[] = { /* Order is important if has same prefix */ { .handler = handle_set_qemu_sstep, From patchwork Thu May 20 17:43:00 2021 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: 443303 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp199302jac; Thu, 20 May 2021 10:47:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzok//FRTG70q8c1bqHfSjOXIbm1mwprF1kQtDALN3mnvBb/u8ulKtFp4vYLYt6X4p4n6nH X-Received: by 2002:a6b:7d0b:: with SMTP id c11mr6921013ioq.8.1621532836883; Thu, 20 May 2021 10:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532836; cv=none; d=google.com; s=arc-20160816; b=QWKxL+jzjfwKa8FI4qDf58fVO8Lv68xh9O6FNTK38xTq0t7C1NE97lsvmM658o5+jG TVztUCalyuCiezSqyaHh6sd16w4DuxcSA0eo9XckmvrC/st3wH49ZRLXc36aTK8ZEW9Q I/f9xbCbCzO+8X2tEGgxIzlkYvEPRTX+Ou6voHw7LcqcJNHj6RrBbUnxuxiZ09+wos/0 K0gvLwGVDrv1mSSmDb97FTlwwhfoozFPFZUEL58SDiTK3d/LWMH2j7SFfv85AmBetcPQ Gak0eaKNKyxGBFQUDQ7s3um6PBcyPcWSN46Nk/TqFQUWBzP+/9pa2uCXWpcyDPT1xIB6 KppQ== 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=u9Mp8qXcR4iIAJ83/3fieCimQZgfESq9GMyz74DDHFY=; b=Eu9JIHNKJ7U0kRsgdOa8PDrDDlAx026Sm6ZyTz6+U0p4h2duUwjG2cC9VzYmKzD7O4 /vZG2+/wJo+HHVggbYrwGN0I2AurrRGBkF/x9IDstAG9aetrDSOIMNdbGKpsTkDVB51u +GIzFZvffD9YO8yDKjuGfNrvVGP1xuBucE8+9HfGxhDQJZs3GNImYL0faSYlegRhQfg1 vZGDbHMvE7vRQaOAdhSYjRCf+9l3PQeK1vw7iGGNKdkC8l9e9RQcCOViB0aoOBxlQAGt 0+mInQk35EP5/VyLQS7x8njeC0pF2NO1/7N/1DKGNrWx4y+ROvz6bDvBUiFvHKzzzz5r 1WqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZXfcrIdF; 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 s16si2498806jas.113.2021.05.20.10.47.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:47: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=ZXfcrIdF; 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]:52194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmlQ-0001JE-8g for patch@linaro.org; Thu, 20 May 2021 13:47:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhY-0003QX-CX for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:16 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:42960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhU-00017J-Ne for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:16 -0400 Received: by mail-wr1-x430.google.com with SMTP id x8so18508180wrq.9 for ; Thu, 20 May 2021 10:43:12 -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=u9Mp8qXcR4iIAJ83/3fieCimQZgfESq9GMyz74DDHFY=; b=ZXfcrIdFRLV45uj9mmg9Fba39eelbz6WzY1eJhQNNyUd6Q075oN59/jK0TGRkkI9jr r1zaYCkI9LSMQyf5y119akiqdRrM92m2EeVM0TVwkUsxyr5JhTF5Je79kSgpPr+Rj1Y7 1VtGHYOWIMUc/wkG6brcUItGDn1EDotLsAt3lQFUtTfnrLzQDPHXBiLWgdj1UM/Lg5Kt pdDMPNc5wol0G5FkUS7EIXABzp30URAOMiOBJYNuRh4e/nTXKR0iOevC6OKixoAFun6+ lf3U6NxLrIXDvryQj7HkT+RiR/0yfwURFaobUl6TP200L6r40Oe95PvlefjAJWUwLKYn ckWQ== 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=u9Mp8qXcR4iIAJ83/3fieCimQZgfESq9GMyz74DDHFY=; b=Vf/kdyNdpOxrzZyQ8QYYMiTiOMlrn+nYKqz906CEDBeBh9JsKgJ0wGrNESeLdsA+kJ 71Er9jTWHI4f2udQDhNMI5xICV29wJLtvcPrhpTYWAS0dkS5mtlNuz498si/ON7xdMCR bScbOhL0RN24568HalpeSUpsfQR98GiARBsYPbryfNwefq0soSdG+9TE2oncbrp8vyTZ hvCbooH83196OxhhAtslrI+DimmU1kGi5IvAGkDHhyT5QN0RwQlN2ZTWGtXVw3mghepe M1K/LSQ+x2a/ahgbX5xd1xYnWB0/ThzbyGGfUwLnKzsaymqnDYxxcSkxRYBQzwiOwZsk jarA== X-Gm-Message-State: AOAM531UVV0RSvq8InRy/BQ+TLcFoYYBcndZa6x1GsjBzmx38ZNfuXza o2dAHr/I5Q5JbrdY/qMyAp3FQQ== X-Received: by 2002:adf:e684:: with SMTP id r4mr5330407wrm.378.1621532591103; Thu, 20 May 2021 10:43:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g66sm3322648wma.11.2021.05.20.10.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3CE3A1FF91; Thu, 20 May 2021 18:43:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 5/8] gdbstub: Replace GdbCmdContext with plain g_array() Date: Thu, 20 May 2021 18:43:00 +0100 Message-Id: <20210520174303.12310-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?b?ZMOp?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Instead of jumping through hoops let glib deal with both tracking the number of elements and auto freeing the memory once we are done. This allows is to drop the usage of ALLOCA(3) which the man-page mentions its "use is discouraged". Signed-off-by: Alex Bennée --- v2 - don't automatically append the variable - fix some long lines --- gdbstub.c | 322 ++++++++++++++++++++++++++---------------------------- 1 file changed, 154 insertions(+), 168 deletions(-) -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index 83d47c6732..84ce770a04 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1338,6 +1338,8 @@ typedef union GdbCmdVariant { } thread_id; } GdbCmdVariant; +#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) + static const char *cmd_next_param(const char *param, const char delimiter) { static const char all_delimiters[] = ",;:="; @@ -1363,55 +1365,52 @@ static const char *cmd_next_param(const char *param, const char delimiter) } static int cmd_parse_params(const char *data, const char *schema, - GdbCmdVariant *params, int *num_params) + GArray *params) { - int curr_param; const char *curr_schema, *curr_data; - *num_params = 0; - - if (!schema) { - return 0; - } + g_assert(schema); + g_assert(params->len == 0); curr_schema = schema; - curr_param = 0; curr_data = data; while (curr_schema[0] && curr_schema[1] && *curr_data) { + GdbCmdVariant this_param; + switch (curr_schema[0]) { case 'l': if (qemu_strtoul(curr_data, &curr_data, 16, - ¶ms[curr_param].val_ul)) { + &this_param.val_ul)) { return -EINVAL; } - curr_param++; curr_data = cmd_next_param(curr_data, curr_schema[1]); + g_array_append_val(params, this_param); break; case 'L': if (qemu_strtou64(curr_data, &curr_data, 16, - (uint64_t *)¶ms[curr_param].val_ull)) { + (uint64_t *)&this_param.val_ull)) { return -EINVAL; } - curr_param++; curr_data = cmd_next_param(curr_data, curr_schema[1]); + g_array_append_val(params, this_param); break; case 's': - params[curr_param].data = curr_data; - curr_param++; + this_param.data = curr_data; curr_data = cmd_next_param(curr_data, curr_schema[1]); + g_array_append_val(params, this_param); break; case 'o': - params[curr_param].opcode = *(uint8_t *)curr_data; - curr_param++; + this_param.opcode = *(uint8_t *)curr_data; curr_data = cmd_next_param(curr_data, curr_schema[1]); + g_array_append_val(params, this_param); break; case 't': - params[curr_param].thread_id.kind = + this_param.thread_id.kind = read_thread_id(curr_data, &curr_data, - ¶ms[curr_param].thread_id.pid, - ¶ms[curr_param].thread_id.tid); - curr_param++; + &this_param.thread_id.pid, + &this_param.thread_id.tid); curr_data = cmd_next_param(curr_data, curr_schema[1]); + g_array_append_val(params, this_param); break; case '?': curr_data = cmd_next_param(curr_data, curr_schema[1]); @@ -1422,16 +1421,10 @@ static int cmd_parse_params(const char *data, const char *schema, curr_schema += 2; } - *num_params = curr_param; return 0; } -typedef struct GdbCmdContext { - GdbCmdVariant *params; - int num_params; -} GdbCmdContext; - -typedef void (*GdbCmdHandler)(GdbCmdContext *gdb_ctx, void *user_ctx); +typedef void (*GdbCmdHandler)(GArray *params, void *user_ctx); /* * cmd_startswith -> cmd is compared using startswith @@ -1471,8 +1464,8 @@ static inline int startswith(const char *string, const char *pattern) 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; - GdbCmdContext gdb_ctx; + int i; + g_autoptr(GArray) params = g_array_new(false, true, sizeof(GdbCmdVariant)); if (!cmds) { return -1; @@ -1488,24 +1481,13 @@ static int process_string_cmd(void *user_ctx, const char *data, } if (cmd->schema) { - schema_len = strlen(cmd->schema); - if (schema_len % 2) { - return -2; + if (cmd_parse_params(&data[strlen(cmd->cmd)], + cmd->schema, params)) { + return -1; } - - max_num_params = schema_len / 2; - } - - gdb_ctx.params = - (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_params); - memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params); - - if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema, - gdb_ctx.params, &gdb_ctx.num_params)) { - return -1; } - cmd->handler(&gdb_ctx, user_ctx); + cmd->handler(params, user_ctx); return 0; } @@ -1528,18 +1510,18 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) } } -static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_detach(GArray *params, void *user_ctx) { GDBProcess *process; uint32_t pid = 1; if (gdbserver_state.multiprocess) { - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } - pid = gdb_ctx->params[0].val_ul; + pid = get_param(params, 0)->val_ul; } process = gdb_get_process(pid); @@ -1562,22 +1544,22 @@ static void handle_detach(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet("OK"); } -static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_thread_alive(GArray *params, void *user_ctx) { CPUState *cpu; - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } - if (gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { + if (get_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) { put_packet("E22"); return; } - cpu = gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, - gdb_ctx->params[0].thread_id.tid); + cpu = gdb_get_cpu(get_param(params, 0)->thread_id.pid, + get_param(params, 0)->thread_id.tid); if (!cpu) { put_packet("E22"); return; @@ -1586,17 +1568,17 @@ static void handle_thread_alive(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet("OK"); } -static void handle_continue(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_continue(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params) { - gdb_set_cpu_pc(gdb_ctx->params[0].val_ull); + if (params->len) { + gdb_set_cpu_pc(get_param(params, 0)->val_ull); } gdbserver_state.signal = 0; gdb_continue(); } -static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_cont_with_sig(GArray *params, void *user_ctx) { unsigned long signal = 0; @@ -1604,8 +1586,8 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) * Note: C sig;[addr] is currently unsupported and we simply * omit the addr parameter */ - if (gdb_ctx->num_params) { - signal = gdb_ctx->params[0].val_ul; + if (params->len) { + signal = get_param(params, 0)->val_ul; } gdbserver_state.signal = gdb_signal_to_target(signal); @@ -1615,27 +1597,27 @@ static void handle_cont_with_sig(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(); } -static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_set_thread(GArray *params, void *user_ctx) { CPUState *cpu; - if (gdb_ctx->num_params != 2) { + if (params->len != 2) { put_packet("E22"); return; } - if (gdb_ctx->params[1].thread_id.kind == GDB_READ_THREAD_ERR) { + if (get_param(params, 1)->thread_id.kind == GDB_READ_THREAD_ERR) { put_packet("E22"); return; } - if (gdb_ctx->params[1].thread_id.kind != GDB_ONE_THREAD) { + if (get_param(params, 1)->thread_id.kind != GDB_ONE_THREAD) { put_packet("OK"); return; } - cpu = gdb_get_cpu(gdb_ctx->params[1].thread_id.pid, - gdb_ctx->params[1].thread_id.tid); + cpu = gdb_get_cpu(get_param(params, 1)->thread_id.pid, + get_param(params, 1)->thread_id.tid); if (!cpu) { put_packet("E22"); return; @@ -1645,7 +1627,7 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) * Note: This command is deprecated and modern gdb's will be using the * vCont command instead. */ - switch (gdb_ctx->params[0].opcode) { + switch (get_param(params, 0)->opcode) { case 'c': gdbserver_state.c_cpu = cpu; put_packet("OK"); @@ -1660,18 +1642,18 @@ static void handle_set_thread(GdbCmdContext *gdb_ctx, void *user_ctx) } } -static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_insert_bp(GArray *params, void *user_ctx) { int res; - if (gdb_ctx->num_params != 3) { + if (params->len != 3) { put_packet("E22"); return; } - res = gdb_breakpoint_insert(gdb_ctx->params[0].val_ul, - gdb_ctx->params[1].val_ull, - gdb_ctx->params[2].val_ull); + res = gdb_breakpoint_insert(get_param(params, 0)->val_ul, + get_param(params, 1)->val_ull, + get_param(params, 2)->val_ull); if (res >= 0) { put_packet("OK"); return; @@ -1683,18 +1665,18 @@ static void handle_insert_bp(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet("E22"); } -static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_remove_bp(GArray *params, void *user_ctx) { int res; - if (gdb_ctx->num_params != 3) { + if (params->len != 3) { put_packet("E22"); return; } - res = gdb_breakpoint_remove(gdb_ctx->params[0].val_ul, - gdb_ctx->params[1].val_ull, - gdb_ctx->params[2].val_ull); + res = gdb_breakpoint_remove(get_param(params, 0)->val_ul, + get_param(params, 1)->val_ull, + get_param(params, 2)->val_ull); if (res >= 0) { put_packet("OK"); return; @@ -1717,7 +1699,7 @@ static void handle_remove_bp(GdbCmdContext *gdb_ctx, void *user_ctx) * the remote gdb to fallback to older methods. */ -static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_set_reg(GArray *params, void *user_ctx) { int reg_size; @@ -1726,19 +1708,19 @@ static void handle_set_reg(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - if (gdb_ctx->num_params != 2) { + if (params->len != 2) { put_packet("E22"); return; } - reg_size = strlen(gdb_ctx->params[1].data) / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[1].data, reg_size); + reg_size = strlen(get_param(params, 1)->data) / 2; + hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_size); gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->data, - gdb_ctx->params[0].val_ull); + get_param(params, 0)->val_ull); put_packet("OK"); } -static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_get_reg(GArray *params, void *user_ctx) { int reg_size; @@ -1747,14 +1729,14 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E14"); return; } reg_size = gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - gdb_ctx->params[0].val_ull); + get_param(params, 0)->val_ull); if (!reg_size) { put_packet("E14"); return; @@ -1766,22 +1748,24 @@ static void handle_get_reg(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } -static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_write_mem(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params != 3) { + if (params->len != 3) { put_packet("E22"); return; } /* hextomem() reads 2*len bytes */ - if (gdb_ctx->params[1].val_ull > strlen(gdb_ctx->params[2].data) / 2) { + if (get_param(params, 1)->val_ull > + strlen(get_param(params, 2)->data) / 2) { put_packet("E22"); return; } - 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, + hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, + get_param(params, 1)->val_ull); + if (target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, true)) { put_packet("E14"); @@ -1791,22 +1775,24 @@ static void handle_write_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet("OK"); } -static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_read_mem(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params != 2) { + if (params->len != 2) { put_packet("E22"); return; } /* memtohex() doubles the required space */ - if (gdb_ctx->params[1].val_ull > MAX_PACKET_LENGTH / 2) { + if (get_param(params, 1)->val_ull > MAX_PACKET_LENGTH / 2) { put_packet("E22"); return; } - g_byte_array_set_size(gdbserver_state.mem_buf, gdb_ctx->params[1].val_ull); + g_byte_array_set_size(gdbserver_state.mem_buf, + get_param(params, 1)->val_ull); - if (target_memory_rw_debug(gdbserver_state.g_cpu, gdb_ctx->params[0].val_ull, + if (target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, false)) { put_packet("E14"); @@ -1818,19 +1804,19 @@ static void handle_read_mem(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } -static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_write_all_regs(GArray *params, void *user_ctx) { target_ulong addr, len; uint8_t *registers; int reg_size; - if (!gdb_ctx->num_params) { + if (!params->len) { return; } cpu_synchronize_state(gdbserver_state.g_cpu); - len = strlen(gdb_ctx->params[0].data) / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + len = strlen(get_param(params, 0)->data) / 2; + hextomem(gdbserver_state.mem_buf, get_param(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++) { @@ -1841,7 +1827,7 @@ static void handle_write_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet("OK"); } -static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_read_all_regs(GArray *params, void *user_ctx) { target_ulong addr, len; @@ -1859,14 +1845,14 @@ static void handle_read_all_regs(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } -static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_file_io(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params >= 1 && gdbserver_state.current_syscall_cb) { + if (params->len >= 1 && gdbserver_state.current_syscall_cb) { target_ulong ret, err; - ret = (target_ulong)gdb_ctx->params[0].val_ull; - if (gdb_ctx->num_params >= 2) { - err = (target_ulong)gdb_ctx->params[1].val_ull; + ret = (target_ulong)get_param(params, 0)->val_ull; + if (params->len >= 2) { + err = (target_ulong)get_param(params, 1)->val_ull; } else { err = 0; } @@ -1874,7 +1860,7 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.current_syscall_cb = NULL; } - if (gdb_ctx->num_params >= 3 && gdb_ctx->params[2].opcode == (uint8_t)'C') { + if (params->len >= 3 && get_param(params, 2)->opcode == (uint8_t)'C') { put_packet("T02"); return; } @@ -1882,23 +1868,23 @@ static void handle_file_io(GdbCmdContext *gdb_ctx, void *user_ctx) gdb_continue(); } -static void handle_step(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_step(GArray *params, void *user_ctx) { - if (gdb_ctx->num_params) { - gdb_set_cpu_pc((target_ulong)gdb_ctx->params[0].val_ull); + if (params->len) { + gdb_set_cpu_pc((target_ulong)get_param(params, 0)->val_ull); } cpu_single_step(gdbserver_state.c_cpu, get_sstep_flags()); gdb_continue(); } -static void handle_backward(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_backward(GArray *params, void *user_ctx) { if (replay_mode != REPLAY_MODE_PLAY) { put_packet("E22"); } - if (gdb_ctx->num_params == 1) { - switch (gdb_ctx->params[0].opcode) { + if (params->len == 1) { + switch (get_param(params, 0)->opcode) { case 's': if (replay_reverse_step()) { gdb_continue(); @@ -1920,20 +1906,20 @@ static void handle_backward(GdbCmdContext *gdb_ctx, void *user_ctx) put_packet(""); } -static void handle_v_cont_query(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_cont_query(GArray *params, void *user_ctx) { put_packet("vCont;c;C;s;S"); } -static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_cont(GArray *params, void *user_ctx) { int res; - if (!gdb_ctx->num_params) { + if (!params->len) { return; } - res = gdb_handle_vcont(gdb_ctx->params[0].data); + res = gdb_handle_vcont(get_param(params, 0)->data); if ((res == -EINVAL) || (res == -ERANGE)) { put_packet("E22"); } else if (res) { @@ -1941,17 +1927,17 @@ static void handle_v_cont(GdbCmdContext *gdb_ctx, void *user_ctx) } } -static void handle_v_attach(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_attach(GArray *params, void *user_ctx) { GDBProcess *process; CPUState *cpu; g_string_assign(gdbserver_state.str_buf, "E22"); - if (!gdb_ctx->num_params) { + if (!params->len) { goto cleanup; } - process = gdb_get_process(gdb_ctx->params[0].val_ul); + process = gdb_get_process(get_param(params, 0)->val_ul); if (!process) { goto cleanup; } @@ -1972,7 +1958,7 @@ cleanup: put_strbuf(); } -static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_kill(GArray *params, void *user_ctx) { /* Kill the target */ put_packet("OK"); @@ -2007,43 +1993,43 @@ static const GdbCmdParseEntry gdb_v_commands_table[] = { }, }; -static void handle_v_commands(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_v_commands(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { put_packet(""); } } -static void handle_query_qemu_sstepbits(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_qemu_sstepbits(GArray *params, void *user_ctx) { 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) +static void handle_set_qemu_sstep(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } - sstep_flags = gdb_ctx->params[0].val_ul; + sstep_flags = get_param(params, 0)->val_ul; put_packet("OK"); } -static void handle_query_qemu_sstep(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_qemu_sstep(GArray *params, void *user_ctx) { 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) +static void handle_query_curr_tid(GArray *params, void *user_ctx) { CPUState *cpu; GDBProcess *process; @@ -2060,7 +2046,7 @@ static void handle_query_curr_tid(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } -static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_threads(GArray *params, void *user_ctx) { if (!gdbserver_state.query_cpu) { put_packet("l"); @@ -2073,25 +2059,25 @@ static void handle_query_threads(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.query_cpu = gdb_next_attached_cpu(gdbserver_state.query_cpu); } -static void handle_query_first_threads(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_first_threads(GArray *params, void *user_ctx) { gdbserver_state.query_cpu = gdb_first_attached_cpu(); - handle_query_threads(gdb_ctx, user_ctx); + handle_query_threads(params, user_ctx); } -static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_thread_extra(GArray *params, void *user_ctx) { g_autoptr(GString) rs = g_string_new(NULL); CPUState *cpu; - if (!gdb_ctx->num_params || - gdb_ctx->params[0].thread_id.kind == GDB_READ_THREAD_ERR) { + if (!params->len || + get_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) { put_packet("E22"); return; } - cpu = gdb_get_cpu(gdb_ctx->params[0].thread_id.pid, - gdb_ctx->params[0].thread_id.tid); + cpu = gdb_get_cpu(get_param(params, 0)->thread_id.pid, + get_param(params, 0)->thread_id.tid); if (!cpu) { return; } @@ -2116,7 +2102,7 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) } #ifdef CONFIG_USER_ONLY -static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_offsets(GArray *params, void *user_ctx) { TaskState *ts; @@ -2131,17 +2117,17 @@ static void handle_query_offsets(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } #else -static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_rcmd(GArray *params, void *user_ctx) { const guint8 zero = 0; int len; - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } - len = strlen(gdb_ctx->params[0].data); + len = strlen(get_param(params, 0)->data); if (len % 2) { put_packet("E01"); return; @@ -2149,7 +2135,7 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) g_assert(gdbserver_state.mem_buf->len == 0); len = len / 2; - hextomem(gdbserver_state.mem_buf, gdb_ctx->params[0].data, len); + hextomem(gdbserver_state.mem_buf, get_param(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); @@ -2157,7 +2143,7 @@ static void handle_query_rcmd(GdbCmdContext *gdb_ctx, void *user_ctx) } #endif -static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_supported(GArray *params, void *user_ctx) { CPUClass *cc; @@ -2178,8 +2164,8 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) } #endif - if (gdb_ctx->num_params && - strstr(gdb_ctx->params[0].data, "multiprocess+")) { + if (params->len && + strstr(get_param(params, 0)->data, "multiprocess+")) { gdbserver_state.multiprocess = true; } @@ -2187,7 +2173,7 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) put_strbuf(); } -static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_xfer_features(GArray *params, void *user_ctx) { GDBProcess *process; CPUClass *cc; @@ -2195,7 +2181,7 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) const char *xml; const char *p; - if (gdb_ctx->num_params < 3) { + if (params->len < 3) { put_packet("E22"); return; } @@ -2208,15 +2194,15 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) } gdb_has_xml = true; - p = gdb_ctx->params[0].data; + p = get_param(params, 0)->data; xml = get_feature_xml(p, &p, process); if (!xml) { put_packet("E00"); return; } - addr = gdb_ctx->params[1].val_ul; - len = gdb_ctx->params[2].val_ul; + addr = get_param(params, 1)->val_ul; + len = get_param(params, 2)->val_ul; total_len = strlen(xml); if (addr > total_len) { put_packet("E00"); @@ -2240,18 +2226,18 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) } #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) -static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_xfer_auxv(GArray *params, void *user_ctx) { TaskState *ts; unsigned long offset, len, saved_auxv, auxv_len; - if (gdb_ctx->num_params < 2) { + if (params->len < 2) { put_packet("E22"); return; } - offset = gdb_ctx->params[0].val_ul; - len = gdb_ctx->params[1].val_ul; + offset = get_param(params, 0)->val_ul; + len = get_param(params, 1)->val_ul; ts = gdbserver_state.c_cpu->opaque; saved_auxv = ts->info->saved_auxv; auxv_len = ts->info->auxv_len; @@ -2286,12 +2272,12 @@ static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx) } #endif -static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_attached(GArray *params, void *user_ctx) { put_packet(GDB_ATTACHED); } -static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_query_qemu_supported(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); #ifndef CONFIG_USER_ONLY @@ -2301,21 +2287,21 @@ static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) } #ifndef CONFIG_USER_ONLY -static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, +static void handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx) { 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) +static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { put_packet("E22"); return; } - if (!gdb_ctx->params[0].val_ul) { + if (!get_param(params, 0)->val_ul) { phy_memory_mode = 0; } else { phy_memory_mode = 1; @@ -2438,45 +2424,45 @@ static const GdbCmdParseEntry gdb_gen_set_table[] = { #endif }; -static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_gen_query(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } - if (!process_string_cmd(NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { put_packet(""); } } -static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_gen_set(GArray *params, void *user_ctx) { - if (!gdb_ctx->num_params) { + if (!params->len) { return; } - if (!process_string_cmd(NULL, gdb_ctx->params[0].data, + if (!process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_set_common_table, ARRAY_SIZE(gdb_gen_query_set_common_table))) { return; } - if (process_string_cmd(NULL, gdb_ctx->params[0].data, + if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { put_packet(""); } } -static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +static void handle_target_halt(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); From patchwork Thu May 20 17:43:01 2021 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: 443307 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp202630jac; Thu, 20 May 2021 10:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+IbhCSvf/OIRr9ESKub/qFdDdi1YlYL0c/c4SfUOaEgQXvsfNaApULamFwXZPRcZltboo X-Received: by 2002:a5e:8a42:: with SMTP id o2mr6415720iom.144.1621533129846; Thu, 20 May 2021 10:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621533129; cv=none; d=google.com; s=arc-20160816; b=leH4zl0fiCQp/IdcA3gJ0feQpp0MA/ELK0yRbHtjwUzC9HIK3sIigvgpu32k6e1exB htpzQWwiSQboxGMHvcWw2KoZeoojF9PXdHEfLKTD8X8TqRSX+xAPUruYkMi6WnK3M7EZ RYJrpyB1bFV54jeWGU5ZZTFP1CqwG42TbEjfTXpWhmZJirKxSKWzRLoJwlzG9pXsneGg MJYcHtEeMQGbw0r2SbxrwYm8wuNsSYZ+6QaAScBaAIucVbR4abK2RmGMPRVhe4UB7gNZ 90nPNx4h9P5cnDi45CyrHcele41vVg185EUHNTNfG/PBfpaZ3vTUXr2x8jWqWEXCPr4y 9kfw== 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=ZV3N7vnnmqaJzn/30LSs3DhmDhZm3N/TXQLXuUEcexg=; b=gz488L+7Tq3df0MDLARQVFg0YOxpkvUcwirsykWUjFQxVnjLrvmg1tFQuatd7h5ZAr J5ghWmp+o4UZ97zhGYPQa+PgrUfAiWUZaePbE9SpivWs2o6eRS7fRV5YyC+dhzhy7vFf AdpG0jx1EtwQQVBBW/zW5aDaFI+NEWH1WPx3doqOpZNntmT+xboJ3R72bg43m4DH5WBb 6ZJaVsJyEY5gZGuaM7dj9M3Rd3VUCwZZEEWz2BTWz6YLyPk/WkEM9M440owru3eW4E6Z gLD0B3aVhfAAyo7YEWOBKXxDJbiz4j0N13B3VwcJQ5FLmdA/yTSqi5atg5GOtfJQ6Nvk 4QFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Osr6nupv; 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 k5si3509613ilv.81.2021.05.20.10.52.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:52:09 -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=Osr6nupv; 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]:35326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmq9-0000c2-Bb for patch@linaro.org; Thu, 20 May 2021 13:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhX-0003Nh-HG for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:15 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:40475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhV-00018i-Rt for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:15 -0400 Received: by mail-wm1-x32a.google.com with SMTP id f6-20020a1c1f060000b0290175ca89f698so5911444wmf.5 for ; Thu, 20 May 2021 10:43: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=ZV3N7vnnmqaJzn/30LSs3DhmDhZm3N/TXQLXuUEcexg=; b=Osr6nupvyy/ebvMvYoSScVh79l1sIpaxKT9F8xPAMCMkXGNDt0DVfaJsFEL23hOglY NDWpITF+Rt7zLotTXyzkZMI1idrirX0+gMhjJDA57O3RDCTCu95Mi8NOgTS1r9mBaCPu CIX9uG1TxKDcqkSTIT61apDylkLWXgzSPcSZzzUuOfP/LyD9rEWAo2HVDK8MBIZU/13v HLRYVTiK+uGpyVxtT0LK/UbXj7RZr8lY743rcLCuw3R5m5LZxNuPSaugXLesoJNpB+CF YpgyWcHdR8yyp+Pse+gAU6FSpivYY7UsrSZsfLnorFi6xRcth9oEnQeODYjBPnzkuK+b NGyA== 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=ZV3N7vnnmqaJzn/30LSs3DhmDhZm3N/TXQLXuUEcexg=; b=ZyGYuAxgaEPce+N5f+Gik0HK8xUOrnBGmt0Zeo0qeLGpJiJ4JX9q5efjB7W60m8MW9 cYakgYK7yr3BFRgbyLq5bUC8UdFxAKowXFg9WBhO1ZDYibU1H9wF/z9FJXZczPjHK1lz rhyRyM2B5WsTg1gNCaMkPMNq7QmyUhCv/xnSMnXSFfnopGnhtfwDpeX2qwYeeiUrS1jI Kd6pb/BYyCCcVYl+irNygXz17sMNqWzl0xM6Fcbspq0c3tFtqUQtcShUnYSbR5CPoVmg WUb1FtyYRYTYo74CRREJ1OnCWw+Jlo1Psha86B1OzfMoUmw/u6W5gzbcK+PcMZoouSmH 2Ctg== X-Gm-Message-State: AOAM531nY0w/JHmCPuFx6p28dB/akQ8Ztuq9PZta2Ofm8rnsCA8xlz/1 vKlFlte+sVjYtp+n21P6P0cbMg== X-Received: by 2002:a1c:f618:: with SMTP id w24mr4763803wmc.93.1621532592510; Thu, 20 May 2021 10:43:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y2sm11339624wmq.45.2021.05.20.10.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 649721FF92; Thu, 20 May 2021 18:43:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 6/8] hmp-commands: expand type of icount to "l" in replay commands Date: Thu, 20 May 2021 18:43:01 +0100 Message-Id: <20210520174303.12310-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, f4bug@amsat.org, "Dr. David Alan Gilbert" , stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, Pavel Dovgalyuk , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is not a 32 bit number, it can (and most likely will) be quite a big one. Signed-off-by: Alex Bennée Reviewed-by: Pavel Dovgalyuk --- hmp-commands.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/hmp-commands.hx b/hmp-commands.hx index 435c591a1c..5ee9cfd520 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1667,7 +1667,7 @@ ERST { .name = "replay_break", - .args_type = "icount:i", + .args_type = "icount:l", .params = "icount", .help = "set breakpoint at the specified instruction count", .cmd = hmp_replay_break, @@ -1699,7 +1699,7 @@ ERST { .name = "replay_seek", - .args_type = "icount:i", + .args_type = "icount:l", .params = "icount", .help = "replay execution to the specified instruction count", .cmd = hmp_replay_seek, From patchwork Thu May 20 17:43:02 2021 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: 443305 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp199765jac; Thu, 20 May 2021 10:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFeoeqXDoy8+dtZ6ca3rhLr1QGO3o9lzuc2b3KRtQytAvQ7QDdqRzL0lJ0GAs2+bLMLI79 X-Received: by 2002:a02:7f57:: with SMTP id r84mr8195769jac.108.1621532874624; Thu, 20 May 2021 10:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532874; cv=none; d=google.com; s=arc-20160816; b=vbDoghPnN4ljns1jctvpo0IpDcEI82KPAZhADE4CL3SlI6k1QwFVhAXvxhvKSUM5/L 6YKroho45e2Ir4rXCK5ASd1aqAUYq5EDqHaHGKzzlRpqRbUV9EsPqfYO0d35V8Z+CODe 7P2I1k5XG+3oDEU+4zgeFyNNiNw3p9JwgJQ1lYm99WFYK93oCFCKMY1M++AI8Dk6XZ0z BP/EFhZMUmLhqnC8ozC4JQ/zu15F5PYXJJg/ClLPuXf6D1B/S9/VwwkCzvXLJUXE9fxO AF39KsodKUiNTDZ0ttjGWnW7QrE7Wc5oyct3kQv9iDZOaQ1g+ZiJ3Hj4ZNKZ5d0v9O5j pHOQ== 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=xKAsfqZlgQlw53LEWwrI3OJPttiUgB7fACa4Oi4oEMo=; b=WN0Mq0GxHvkzpd2Pq65WacOMCqDZSyNlpKSMhSIQ6jHVv4ehV7qZxvwx6xo7TNLrsP zWA4eCMvbatHtuDCiPh2nHWTTJVR69Gn48uFDfq04t45y64sxt1TMVMWZeCzEIqftk0g BOUtYqMbOXp4Pz/EyQ/2iuSu6v8xANgbQSc0N8qqeVeMVFy+zqRFol0/EOMfpqs+uo3X 44idnS82RboRswCXLAROuW+LR1Ns6HKkI4OIoSAlHUVfxxvozgYasPB4LIVxgBVrgCgk Gepa7JU4mPICt8q+yaisUBzve7ZqP8ZOmwyMTg6fM+13XmLjvGuGMaA63KW2/XAegVbo jkbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bqHD+lij; 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 z13si3350129ilu.28.2021.05.20.10.47.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:47: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=bqHD+lij; 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]:51604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmm2-0000sW-2g for patch@linaro.org; Thu, 20 May 2021 13:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmhc-0003cm-3d for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:20 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:45019) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhY-0001AH-5F for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:19 -0400 Received: by mail-wm1-x32f.google.com with SMTP id y184-20020a1ce1c10000b02901769b409001so5741058wmg.3 for ; Thu, 20 May 2021 10:43: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=xKAsfqZlgQlw53LEWwrI3OJPttiUgB7fACa4Oi4oEMo=; b=bqHD+lij5L2oDyyUpb6mch2z5/zFUVEMoGbvGk5czA5kkmS/e6k6lTgKY8wzdNR2oP 8Rxmf432QDipJy551BXPnaT4dDlDZbDPxhD/4FrQez0U7ogpDhvuZEwo80nlWIdl0whd JlfNfJGD8JWIjEhIqw6KeTNxMCnukTEg2ngZGska+Xf8zDwO75d8IKFsy4ngu1Nh3UZB JL/4USirrCjQyQbIVikhsZK3QK3QWJbmEzEYOcGqhlZVSkZCsVS43Gp3RWCDsY8EhqEe dW97XCOHi0pMEWuYdIi3DuseBrX095djRbdomabem2BcT9akK5FUHG9yC4fwvejPe1Tu rAhQ== 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=xKAsfqZlgQlw53LEWwrI3OJPttiUgB7fACa4Oi4oEMo=; b=fNG+hCD3Vwky9VHJaSEi1qlO5BGyihzG3iG3w9kT4sbAuoFwp3UXTHBx/8apgKuhVB t1AvVxR4MvAgYOaMYHVT0EuEv5bfSAQYHaA/nDObJ+GOS/+YItDAiQmnk3CVLMoqDYOK yau/qvbhcC31Q9XGY3tWiYQ3qHeF/Ik5xYzALmRGCY8dZZcjUiz85nCj0pg72jJ9aQ2r IzYI6FVo7h6f9zWaYSWAM1ibACPI+V745lKkp7I0FmFvIZ62reUX3rj1hFiCuy6uwF13 GejYS+FK2i1Z8ydyyalqJ7C68DTcQCGhnefkqBrw6UkcEw6FillfyvYwHJA0tdy701H6 XBWg== X-Gm-Message-State: AOAM532CVK+O014uFacTtxP3sGkv3TN+q4CiBQ5859358pLJhSS2gcR9 XtX79XxE6Tz9hPWgj9XE8z+pPw== X-Received: by 2002:a7b:cb85:: with SMTP id m5mr5262138wmi.118.1621532594868; Thu, 20 May 2021 10:43:14 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w20sm3540607wmc.44.2021.05.20.10.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8D5B11FF93; Thu, 20 May 2021 18:43:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 7/8] gdbstub: tidy away reverse debugging check into function Date: Thu, 20 May 2021 18:43:02 +0100 Message-Id: <20210520174303.12310-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In theory we don't need an actual record/replay to enact reverse debugging on a purely deterministic system (i.e one with no external inputs running under icount). Tidy away the logic into a little function. Signed-off-by: Alex Bennée --- gdbstub.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé diff --git a/gdbstub.c b/gdbstub.c index 84ce770a04..52bde5bdc9 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -465,6 +465,15 @@ int use_gdb_syscalls(void) return gdb_syscall_mode == GDB_SYS_ENABLED; } +static bool stub_can_reverse(void) +{ +#ifdef CONFIG_USER_ONLY + return false; +#else + return replay_mode == REPLAY_MODE_PLAY; +#endif +} + /* Resume execution. */ static inline void gdb_continue(void) { @@ -1880,7 +1889,7 @@ static void handle_step(GArray *params, void *user_ctx) static void handle_backward(GArray *params, void *user_ctx) { - if (replay_mode != REPLAY_MODE_PLAY) { + if (!stub_can_reverse()) { put_packet("E22"); } if (params->len == 1) { @@ -2153,7 +2162,7 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } - if (replay_mode == REPLAY_MODE_PLAY) { + if (stub_can_reverse()) { g_string_append(gdbserver_state.str_buf, ";ReverseStep+;ReverseContinue+"); } From patchwork Thu May 20 17:43:03 2021 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: 443301 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp197124jac; Thu, 20 May 2021 10:44:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd9cMhxZejNjCDQGjeJeUN/Madi9V0c52TxWpQ17Cp27dBVBWBCcWE7TvuNLjVIwvW0PK1 X-Received: by 2002:a92:c884:: with SMTP id w4mr7082698ilo.117.1621532673249; Thu, 20 May 2021 10:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532673; cv=none; d=google.com; s=arc-20160816; b=KWCtImg+DAKctX2Fuw79EbS0D1rwK2MjwwR82PPd6bOks0mErZIi0Af5khbSnyxnok T6OiLqRFgxpvkMUS0EDrDcDStq6dhI9n/kYmmxhe+p6Niyi5T6UK5eKlPftyLQ1Ws2D2 IPqjwwUUqOXs/t5MctrFaiczMVq9A0/BiRMFu6NuGjQpJNYSZVxA7z6zTZZf93UbHPoC 6X92wWtUZSwI+rjUwHTRh2xo1IEnWDPqDWRxuPtYCulOJXkORoaSvkCYbvqirUyXAlfy B95kcfJfsyBYyEX/Qj0/i+8wUMwG2uqaD7CIEx1M1oaakszqDilPVHND/o1j1hOrBmnD OyYQ== 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=AMEc95i31AY77+bT+r3OtP0SO6eeuibPTNGNNWAs+D0=; b=ij442LPpb5KeCtI5QZhJvLKnx98CqvdKpV3q6FYA6pT2m1i1VphsG57XUi9QIn2FRz BKzAcjxd0olL+v3PIjeVGi8WtrdhwU03thWE2IjZeAz7btluRFYubgawCEKCY4Ks7f9t ECjJIfZgKQqVjGJ2EzSdX6sK1SINb/AiUu7BogKxN0dy8PlRERRrfzoOljKXNWiYwtTw RdZjqg4EkWGhk15rCLxEF3T6hNZotMm7iO9MkcWLccoesVL6GqVnbNnTbhfGo20XYekq V4vCjKdwmgV/LhJFcc6d5/xZnH5F8Q0mCfs0gYjv0Zs5/V6VZ7jLKe22AwG++dcXNBfr PXNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bKXtC5cL; 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 h31si3120177jav.116.2021.05.20.10.44.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 May 2021 10:44:33 -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=bKXtC5cL; 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]:43180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmim-0003dV-Lz for patch@linaro.org; Thu, 20 May 2021 13:44:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljmha-0003Ya-Rj for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:18 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:33548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljmhZ-0001Ay-0C for qemu-devel@nongnu.org; Thu, 20 May 2021 13:43:18 -0400 Received: by mail-wr1-x435.google.com with SMTP id n2so18597822wrm.0 for ; Thu, 20 May 2021 10:43:16 -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=AMEc95i31AY77+bT+r3OtP0SO6eeuibPTNGNNWAs+D0=; b=bKXtC5cLcTmq1F9vbjI+y9SXz2J16eIUOO009GcodDmX1BeY9Zp856KHOIzpHtJJC3 NqBKRh4XEWYx9mJqELAGBt8QlOyux4w+SkCvUIp/mwwKbC2yatIuJG7EKS0k6nk8qh2h yKCNhxNFoaijlp/ahqSUr5+vVIn29liFUb9di1C5ukrfRNxrSpTNNjA1RTNpyYJS8iCf 5sAh55I6nVx86iGc8RlIfkvdFEdU53Z4S8c3TtLPvwWTXhauYTvz+HofM8+euYQFLBW+ vykQnVOQxeqE1C3DBLgqLwGGE3hPGWa+94hdAxhD8jWqgErhXmG4bvzUgaTN+5StWUlS mYCQ== 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=AMEc95i31AY77+bT+r3OtP0SO6eeuibPTNGNNWAs+D0=; b=Cd4TAQUaZk6c1I8tw+Ic9c2X9d9TvCiu7hsu5bRRzFhi4yLDY98kac3dWz1VC9m/bv AD/CuAqQnknVWIyVByVfGKEVNyrbnuYBbNjRYJcc9r8H9r+IQPWq3WnapDH5jWeAHOeD 92RrZBwe84BuX1egK8BQGgefxP+IFg7pnSR/lcKKJztpnLI7IycUQ8x7XK4SVffD+Ky+ 0K5H5ii/5In0h1CWqqTn3gprRhiBLLAO77lDJ7lKDU284Q6RxB2kl21bzLMlg1E6NB+y b61J7CVrJijNcLOE6LaH7bJIO89ybTZwIvhtIflw+KXhWLlu9FqLCpngiZnEzU4xV83F ujVg== X-Gm-Message-State: AOAM530COG80noApBKpFw3liXop/0no7yVaMLJfao5FAMEG236kKZNYT lr/YJLP7n3QoWyBfbwPJV2+Q2w== X-Received: by 2002:adf:f20b:: with SMTP id p11mr1389889wro.190.1621532595683; Thu, 20 May 2021 10:43:15 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e26sm3281333wmh.39.2021.05.20.10.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 10:43:07 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C19461FF96; Thu, 20 May 2021 18:43:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 8/8] plugins/syscall: Added a table-like summary output Date: Thu, 20 May 2021 18:43:03 +0100 Message-Id: <20210520174303.12310-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210520174303.12310-1-alex.bennee@linaro.org> References: <20210520174303.12310-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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@euphon.net, berrange@redhat.com, f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, Mahmoud Mandour , =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Mahmoud Mandour Added a table-like output which contains the total number of calls for each used syscall along with the number of errors that occurred. Per-call tracing is still available through supplying the argument ``print`` to the plugin. Signed-off-by: Mahmoud Mandour Signed-off-by: Alex Bennée Message-Id: <20210519032409.3041-1-ma.mandourr@gmail.com> --- tests/plugin/syscall.c | 98 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/tests/plugin/syscall.c b/tests/plugin/syscall.c index 53ee2ab6c4..6dd71092e1 100644 --- a/tests/plugin/syscall.c +++ b/tests/plugin/syscall.c @@ -16,32 +16,120 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; +typedef struct { + int64_t num; + int64_t calls; + int64_t errors; +} SyscallStats; + +static GMutex lock; +static GHashTable *statistics; + +static SyscallStats *get_or_create_entry(int64_t num) +{ + SyscallStats *entry = + (SyscallStats *) g_hash_table_lookup(statistics, GINT_TO_POINTER(num)); + + if (!entry) { + entry = g_new0(SyscallStats, 1); + entry->num = num; + g_hash_table_insert(statistics, GINT_TO_POINTER(num), (gpointer) entry); + } + + return entry; +} + static void vcpu_syscall(qemu_plugin_id_t id, unsigned int vcpu_index, int64_t num, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8) { - g_autofree gchar *out = g_strdup_printf("syscall #%" PRIi64 "\n", num); - qemu_plugin_outs(out); + if (statistics) { + SyscallStats *entry; + g_mutex_lock(&lock); + entry = get_or_create_entry(num); + entry->calls++; + g_mutex_unlock(&lock); + } else { + g_autofree gchar *out = g_strdup_printf("syscall #%" PRIi64 "\n", num); + qemu_plugin_outs(out); + } } static void vcpu_syscall_ret(qemu_plugin_id_t id, unsigned int vcpu_idx, int64_t num, int64_t ret) +{ + if (statistics) { + SyscallStats *entry; + + g_mutex_lock(&lock); + /* Should always return an existent entry. */ + entry = get_or_create_entry(num); + if (ret < 0) { + entry->errors++; + } + g_mutex_unlock(&lock); + } else { + g_autofree gchar *out; + out = g_strdup_printf("syscall #%" PRIi64 " returned -> %" PRIi64 "\n", + num, ret); + qemu_plugin_outs(out); + } +} + +static void print_entry(gpointer val, gpointer user_data) { g_autofree gchar *out; - out = g_strdup_printf("syscall #%" PRIi64 " returned -> %" PRIi64 "\n", - num, ret); + SyscallStats *entry = (SyscallStats *) val; + int64_t syscall_num = entry->num; + out = g_strdup_printf( + "%-13" PRIi64 "%-6" PRIi64 " %" PRIi64 "\n", + syscall_num, entry->calls, entry->errors); qemu_plugin_outs(out); } +static gint comp_func(gconstpointer ea, gconstpointer eb) +{ + SyscallStats *ent_a = (SyscallStats *) ea; + SyscallStats *ent_b = (SyscallStats *) eb; + + return ent_a->calls > ent_b->calls ? -1 : 1; +} + /* ************************************************************************* */ +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + if (!statistics) { + return; + } + + g_mutex_lock(&lock); + GList *entries = g_hash_table_get_values(statistics); + entries = g_list_sort(entries, comp_func); + qemu_plugin_outs("syscall no. calls errors\n"); -static void plugin_exit(qemu_plugin_id_t id, void *p) {} + g_list_foreach(entries, print_entry, NULL); + + g_list_free(entries); + g_hash_table_destroy(statistics); + g_mutex_unlock(&lock); +} QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { + if (argc == 0) { + statistics = g_hash_table_new_full(NULL, g_direct_equal, NULL, g_free); + } else { + for (int i = 0; i < argc; i++) { + if (g_strcmp0(argv[i], "print") != 0) { + fprintf(stderr, "unsupported argument: %s\n", argv[i]); + return -1; + } + } + } + qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall); qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);