From patchwork Tue Jan 8 16:30:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 154992 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5070170jaa; Tue, 8 Jan 2019 08:30:17 -0800 (PST) X-Received: by 2002:a5d:50c5:: with SMTP id f5mr1884385wrt.37.1546965017287; Tue, 08 Jan 2019 08:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546965017; cv=none; d=google.com; s=arc-20160816; b=By6FlmUct2Id41xqUY1PswEhBw//oEMmEsMfis7VZ2Fa11h/UhD0gXSUiwN7qhsJt+ 2IsphyjpSfeZC1a837pZLJ0R5SO4hv/M6Fca7lww07E9SvN5vtRfTE5kshJfzWLp71Pl UeSSTBFJEdirnKVO5BppQ0SPWmXkfQEGQPpi7wmLwIQtiP1ObCf7NVnoaihqEjh/Eh6j 0wRxPm1tzRDP2Q/UQSNRC2wlnbRJbz//OkJlOz1zEVo7tjTAH3TvuqHHi8+pMBDj0ioF 0zHSkzGXzMGjq2iWwa4d2WpKrdYXkemKYCgJSyLmwEh5SBuXy4TYKO8bFTNhtYieBwed ElBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=lHw25Aq6KmkJUqEwitBkXgdSRY6pkgGYnAbHYsqk6tg=; b=OIYuRPN1x8TzebK985TgdeRTma83xUvOH3Qgld5wuJSf825hX7EDgzUSRjY3YVhTAj gIEtyu39Fyqq30I74TuR/VPHqgKHIsWDTctghWqjdvda0NkltqiH9E1N1I4EeeFyAjGm VIDPaaSxq/CjkfAF7Wpjv0HZusi4uvRxOE652YMDE2CkiLTwKlB9sSMvRlPRtXDm5ISN 2NqC/mN0/D+FiSaLaVO7EjJ92u0XIc+r6FcYSXZGhPAy6V75ZoaDm3Z5STo+E06LW4um ktRBGHHz/6T6ZerdaaVCssNLn9JO28YCaX9pmMLrW4WU/zBl7eAFw0+jROMXBI81mXcR w2mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PFC02pyT; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id j10sor36799249wrx.15.2019.01.08.08.30.17 for (Google Transport Security); Tue, 08 Jan 2019 08:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PFC02pyT; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=lHw25Aq6KmkJUqEwitBkXgdSRY6pkgGYnAbHYsqk6tg=; b=PFC02pyTYUTf7RVgboMHb9D890vfTPFjCqcMDUTi7873obKgsYCxfGUgXSthXTt196 OtFBZ19j3LcARz0wiN6DK23UhPjZLNU60Zc3hpmlGejtigi1pm9xKQDQdHq+qovfwPgw b6kuvmHx39Agf/S49EDAMJ+gIXoTe7kAN/0TY= 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=lHw25Aq6KmkJUqEwitBkXgdSRY6pkgGYnAbHYsqk6tg=; b=r+tPIGpRIiasSHS23j8cE0CHMYXyldhAm5nE9tJQGNWeJazgfL6teqAb2duiSOly2G bjVYSlnUQ/OeZ4Pd7JNtNgyqhgdvenLEYhEySCiZXAHqd+bdXR3NgM4iK422JtceAovK 812lTWqgMGe2/XA7qs3x9D5FvQ1G6VgvKJVL9y12AqPuAeGee/lenOBB/q+GLSXtwtKU Y27bS9BpJUOKGKJOXcbxjmbRU1UfaipGGpi8dU7UX6M5kc2yDeDtMwAcgbUwOzyalsSu YNlYjMDGUkj7qyeGFMd2u9v4v7CVe9ur/qHEPBbMEaUJaelSeoHipowIn7WFAn/7dCcE kRaQ== X-Gm-Message-State: AJcUukfSspBdp4iKeGod23ENFRTd/8qJfhMdiexVyUxuUfmWQ0DD7cpJ nOFef/g0iWvr+/Z7jvoViV3dx0ak X-Google-Smtp-Source: ALg8bN5ZIj1zsnqZt+8hHJKF99Se4N2TvoP0ilqbwTvpKPL6Anjr+Ck6457bk6lJLwIJhm0Q6aotSA== X-Received: by 2002:a5d:47d1:: with SMTP id l17mr1925630wrs.319.1546965016893; Tue, 08 Jan 2019 08:30:16 -0800 (PST) Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x81sm11278839wmg.17.2019.01.08.08.30.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Jan 2019 08:30:16 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson , Peter Crosthwaite , Paolo Bonzini , Alistair Francis , "Edgar E. Iglesias" , Eduardo Habkost , Marcel Apfelbaum , "Emilio G . Cota" Subject: [PATCH 4/4] gdbstub: Simplify gdb_get_cpu_pid() to use cpu->cluster_index Date: Tue, 8 Jan 2019 16:30:08 +0000 Message-Id: <20190108163008.7006-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190108163008.7006-1-peter.maydell@linaro.org> References: <20190108163008.7006-1-peter.maydell@linaro.org> MIME-Version: 1.0 Now we're keeping the cluster index in the CPUState, we don't need to jump through hoops in gdb_get_cpu_pid() to find the associated cluster object. Signed-off-by: Peter Maydell --- gdbstub.c | 48 +++++------------------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) -- 2.19.2 Reviewed-by: Luc Michel diff --git a/gdbstub.c b/gdbstub.c index bfc7afb5096..5d6cbea9d35 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -644,50 +644,12 @@ static int memtox(char *buf, const char *mem, int len) static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) { -#ifndef CONFIG_USER_ONLY - gchar *path, *name = NULL; - Object *obj; - CPUClusterState *cluster; - uint32_t ret; - - path = object_get_canonical_path(OBJECT(cpu)); - - if (path == NULL) { - /* Return the default process' PID */ - ret = s->processes[s->process_num - 1].pid; - goto out; - } - - name = object_get_canonical_path_component(OBJECT(cpu)); - assert(name != NULL); - - /* - * Retrieve the CPU parent path by removing the last '/' and the CPU name - * from the CPU canonical path. - */ - path[strlen(path) - strlen(name) - 1] = '\0'; - - obj = object_resolve_path_type(path, TYPE_CPU_CLUSTER, NULL); - - if (obj == NULL) { - /* Return the default process' PID */ - ret = s->processes[s->process_num - 1].pid; - goto out; - } - - cluster = CPU_CLUSTER(obj); - ret = cluster->cluster_id + 1; - -out: - g_free(name); - g_free(path); - - return ret; - -#else /* TODO: In user mode, we should use the task state PID */ - return s->processes[s->process_num - 1].pid; -#endif + if (cpu->cluster_index == UNASSIGNED_CLUSTER_INDEX) { + /* Return the default process' PID */ + return s->processes[s->process_num - 1].pid; + } + return cpu->cluster_index + 1; } static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid)