From patchwork Tue Jun 27 16:09:39 2023 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: 696884 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3867773wrm; Tue, 27 Jun 2023 09:16:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dOZC4LLQ/EDO92AvexUD0tncykkK9Aldwc6L3V5AfZq/AoGv7VENjGdxgj529JnHlm5Y2 X-Received: by 2002:a05:6808:130c:b0:3a0:3773:f294 with SMTP id y12-20020a056808130c00b003a03773f294mr31847544oiv.8.1687882608372; Tue, 27 Jun 2023 09:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882608; cv=none; d=google.com; s=arc-20160816; b=L0J8snKuIrzcqahZ7KJq555lEW1mw8SFUpJUYl6ky/WHq82VWKuv35a/6rn/0MnFUp vbuO6h9pnMcoqbBdMbJDI8xnV3EJER2gsaNI9nPnR1vAStVfz2K5A+4R0nDuRapZWGLC qdClyv40GoDf/XnGo2MlS6uZZUASbczv3dVTPgkIkbnYhXw+buX09iB3sVmwaAuhJYNf SiY2zYbHd8og93uTF3zBVCC3hUgxibBF12zAkijwg643Z9kcpZneyMsKcdsSQp+Sxdvz becm2P7l8mL6u8IDM2mO2oPhNVRcDPMANkux3k9eCz92/knmGCXao47V2YX2xhotQiTb aAiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=81Ksm8uVTMPnt2+cnp4q2zmd0NQ6258gRF87FUOPn3E=; fh=B6/adVaiTRj/g/M/QPigvyXZO+x+u/FNsaNX2Qo1+tw=; b=eSpYF1g6//r8rAW0PlYte+je24CSyVGdm1pMYkZP+7b7UJTM0ZNuLHHrbYmJmIQ7s5 aSwjkOuMU6nhTuDaeMpZjr9lQt4ztl9+S+5FjVdYzJ0uoFJRDOWpEmsG2SB3xRj2K3g+ OpTaKSCBkDbuglMM4j0CCFBtHhSQYH9ttW66yYMcCjh9X4g48klyXRuXmBQ0GB1Ys00p Wv45Ky7Srscjn0FVMzupjtme1X0r+CkPoDjn8g8aWSpLcVt8Ut9byP5TClmdnIZOC4+y 5jr3XvSCiJqFzrhjrH0UsltFYvzXABVWLz/rWZQ1GFoJM5TPp6mi1bsdta6hOk9O907y 4JKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e08SsTOg; 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=pass (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 jl10-20020ad45e8a000000b0062deb8c3a1fsi3388487qvb.319.2023.06.27.09.16.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Jun 2023 09:16:48 -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=pass header.i=@linaro.org header.s=google header.b=e08SsTOg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEBMK-00016A-8K; Tue, 27 Jun 2023 12:16:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEBMH-00011M-2x for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:16:01 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEBMA-00088u-Gp for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:16:00 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fba64d9296so9233325e9.3 for ; Tue, 27 Jun 2023 09:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687882552; x=1690474552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=81Ksm8uVTMPnt2+cnp4q2zmd0NQ6258gRF87FUOPn3E=; b=e08SsTOg9xG2QdllDTmBh4BxNQ34xDnN0WEvIFDik4Q7Sb+otfh8AvdGlmDM8VbHNe 6U+RgzKtR9LLnI/QKhmLSGLFok6CiCzjWVfnW6TQyPUG4CXBgAmknPzD6NS8c7YB2Xd0 JaQUSBW7A5mGSUC8k2HGpnBJMNVyHM5QdrVcbNNO2d5P53aLflnDBAkGEvzXz7/UBwnk gXssVnwHV7OhGIgVYyBSYY61yDlMJRhdHPGsoEJtqZx5ALSxSktjBtxARKjoCgFbP3X5 9H6aG40AjAoRyiiB+JKSqHpIQfbjwAPh44ThRvVCqMkR6AqSQlb9qRpMcBQ3c1XlWnFE VZSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687882552; x=1690474552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=81Ksm8uVTMPnt2+cnp4q2zmd0NQ6258gRF87FUOPn3E=; b=UU8HTAhtzQwDJjr7p58BCqxW9NE8bFZLZFhD1GpWXqFfYEL5lFNXjQSm7lV3MX6Fuv pNHZKTBkjQc8kxkzvfviMaefV7UN5iGp27OWKbpR8SlA2qnPjkvGdWr5fl05AIqhML/B mB364CBNJJelxtuQ9HqFvwsqSgHrCSc4lFs0V7BX/N32c+n7O0l7YoTs1wWgcVefE3Kx E34JRdc+bMVyG/iKQz1FqkiL5MEW5xM2jRAmbGkZG0ZfaaAjQx4Kab6S1jqdTZ9IgA79 8C3s9V0eVqLPbz7VU57u584Mz+4sPTgbCQ8cSyAcSq8rnLYs2Yqrp3eJhsNqoOkuaheU PJ7g== X-Gm-Message-State: AC+VfDyww3LUCxVrTh9T8n0voCnZgVkaWSA+JMK+x+N7J5RNupHgokcL xjq1p2SMkCuRq4cbTrUP0aC3gw== X-Received: by 2002:a05:600c:219a:b0:3fa:993f:acc1 with SMTP id e26-20020a05600c219a00b003fa993facc1mr4264819wme.2.1687882552620; Tue, 27 Jun 2023 09:15:52 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a16-20020adfdd10000000b00313ef2150dcsm7136675wrm.45.2023.06.27.09.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:15:50 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A75691FFD9; Tue, 27 Jun 2023 17:09:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Juan Quintela , Thomas Huth , Cleber Rosa , Leonardo Bras , Beraldo Leal , Peter Maydell , Bin Meng , Yanan Wang , Darren Kenny , Alexander Bulekov , Marcel Apfelbaum , Peter Xu , Radoslaw Biernacki , Laurent Vivier , Paolo Bonzini , Eduardo Habkost , qemu-arm@nongnu.org, Stefan Hajnoczi , Richard Henderson , Bandan Das , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Dani?= =?utf-8?q?el_P=2E_Berrang=C3=A9?= , Alexandre Iooss , Marcin Juszkiewicz , Leif Lindholm , Laurent Vivier , Qiuhao Li , Mahmoud Mandour , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Ilya Leoshkevich Subject: [PATCH v3 32/36] gdbstub: Expose gdb_get_process() and gdb_get_first_cpu_in_process() Date: Tue, 27 Jun 2023 17:09:39 +0100 Message-Id: <20230627160943.2956928-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230627160943.2956928-1-alex.bennee@linaro.org> References: <20230627160943.2956928-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich These functions will be needed by user-target.c in order to retrieve the name of the executable. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich Message-Id: <20230621203627.1808446-5-iii@linux.ibm.com> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- gdbstub/internals.h | 2 ++ gdbstub/gdbstub.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 33d21d6488..25e4d5eeaa 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -129,6 +129,8 @@ void gdb_read_byte(uint8_t ch); */ bool gdb_got_immediate_ack(void); /* utility helpers */ +GDBProcess *gdb_get_process(uint32_t pid); +CPUState *gdb_get_first_cpu_in_process(GDBProcess *process); CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 49143c7d83..ce3e4a2671 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -211,7 +211,7 @@ static uint32_t gdb_get_cpu_pid(CPUState *cpu) return cpu->cluster_index + 1; } -static GDBProcess *gdb_get_process(uint32_t pid) +GDBProcess *gdb_get_process(uint32_t pid) { int i; @@ -247,7 +247,7 @@ static CPUState *find_cpu(uint32_t thread_id) return NULL; } -static CPUState *get_first_cpu_in_process(GDBProcess *process) +CPUState *gdb_get_first_cpu_in_process(GDBProcess *process) { CPUState *cpu; @@ -325,7 +325,7 @@ static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) return NULL; } - return get_first_cpu_in_process(process); + return gdb_get_first_cpu_in_process(process); } else { /* a specific thread */ cpu = find_cpu(tid); @@ -354,7 +354,7 @@ static const char *get_feature_xml(const char *p, const char **newp, size_t len; int i; const char *name; - CPUState *cpu = get_first_cpu_in_process(process); + CPUState *cpu = gdb_get_first_cpu_in_process(process); CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; @@ -490,7 +490,7 @@ void gdb_register_coprocessor(CPUState *cpu, static void gdb_process_breakpoint_remove_all(GDBProcess *p) { - CPUState *cpu = get_first_cpu_in_process(p); + CPUState *cpu = gdb_get_first_cpu_in_process(p); while (cpu) { gdb_breakpoint_remove_all(cpu); @@ -647,7 +647,7 @@ static int gdb_handle_vcont(const char *p) return -EINVAL; } - cpu = get_first_cpu_in_process(process); + cpu = gdb_get_first_cpu_in_process(process); while (cpu) { if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; @@ -1270,7 +1270,7 @@ static void handle_v_attach(GArray *params, void *user_ctx) goto cleanup; } - cpu = get_first_cpu_in_process(process); + cpu = gdb_get_first_cpu_in_process(process); if (!cpu) { goto cleanup; } @@ -1393,7 +1393,7 @@ static void handle_query_curr_tid(GArray *params, void *user_ctx) * first thread). */ process = gdb_get_cpu_process(gdbserver_state.g_cpu); - cpu = get_first_cpu_in_process(process); + cpu = gdb_get_first_cpu_in_process(process); g_string_assign(gdbserver_state.str_buf, "QC"); gdb_append_thread_id(cpu, gdbserver_state.str_buf); gdb_put_strbuf();