From patchwork Fri Aug 5 19:55:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 595516 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp1561146maz; Fri, 5 Aug 2022 12:59:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6GrB5Wow3Lvyp7lE6fcaUSk/DvedG4py+TyIt1jceWCq3OdNNDfbA3JS9giGeFleCSP7Eh X-Received: by 2002:a05:622a:287:b0:31f:32f6:1db1 with SMTP id z7-20020a05622a028700b0031f32f61db1mr7400090qtw.480.1659729583833; Fri, 05 Aug 2022 12:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659729583; cv=none; d=google.com; s=arc-20160816; b=k/YBwDbI22GkUYuF3H/8+Jw0kOrd9Jx+lEXsmnYVs5IN3cJxbWDL7QlRL5TLvbPYVA V3Jemd5iucGm6wuGmBMcTwZRAAtgV+MbsExP1PWiOBCOLee59ob+AsRAFKWRbwiAnXVA WghYyECxXrBLaY1RVjDKkAo2qFb95wAj8JWwrR1BIt4s1M+Ow5/FVP8pflUfqyWjbUxu v+3Cj97TMrmH5d4uxSBzIzsMf+BB5PZMMoUpOLQo13PVjw3Owoo5Qqbm8XxtC526/Qyd Vpcv1rXEBuXEgOVnhiYsM3rny7DjJlOibvntzWbhtQmyMkksjGB/KEzIKK0A8Vpu3rHE d8JA== 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=IDbgFIeEevSSdSTdjElX+eMs94p5XOKIDT8YgfUxWj8=; b=KKap000oE5CQE9KezmQ+mFH+9pyafiMz67pjywxSp9ZT3b+HXBQMP+xe1/0WFIAnib f3JoGbS9vKjq1j3dY+FE6RSUTXE8YnJyoHgNHZT8pz6CFVny+YuLIriXfztqO84gRxsn i2obLf9l4K+CSGW+DoMG3V5BogbaZOzFV5NiCsmZqu+ltqNSxO5I4WSKBqaGeGAK5GRa xTBQOAo8jhnP9UUapvVZwO6j0tKZ1kOX3JsN03NsLgoZsrXJOxrnpUETMsPwYVs5RgUV ltQ/zDGuj+j61A0wese8vNwbRw7E85IK5tN1fyxuxemfiObv1RCCQoByOv3oz67beZEY ciLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FuER+dFB; 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 g10-20020a0562140aca00b004795f05dd57si1174130qvi.66.2022.08.05.12.59.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Aug 2022 12:59:43 -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=FuER+dFB; 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]:45956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oK3Tz-0005Ml-Ei for patch@linaro.org; Fri, 05 Aug 2022 15:59:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oK3Po-0006Ue-IS for qemu-devel@nongnu.org; Fri, 05 Aug 2022 15:55:24 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:40893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oK3Pm-0004Vy-R8 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 15:55:24 -0400 Received: by mail-pj1-x1035.google.com with SMTP id s5-20020a17090a13c500b001f4da9ffe5fso9184950pjf.5 for ; Fri, 05 Aug 2022 12:55:22 -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=IDbgFIeEevSSdSTdjElX+eMs94p5XOKIDT8YgfUxWj8=; b=FuER+dFB+hNh+OwvWV/DAyxCJ40PNyEhfYQs1+zFLHBtDvW/j3QWy/sRhvT4bSf24T 0j/EBgMPPSHP2R6GtaVytn9jHvJBrbbaM/F+irAGNVyl1AmD5KRR8lFGtM0UVDxe7POF MG0DJjtkRI2yKZ9y6WqXOXhFmTDNZZhNppCmOP9boJz3JSiHBhcs1IVZmF8dg2O9agCU aNWkKVBrlAE9ztcKpQ7HZdHcoicGgCMP4VZqPyIqjoyOC96NibchdGCDq6GykYA2JNcF Ab+vtvvDlbcCVWo7e7t0LdIWGHf9raHc+PUhR5MRyjyc2LRqsDvDbyxQvEoyAHeliEY5 fvXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IDbgFIeEevSSdSTdjElX+eMs94p5XOKIDT8YgfUxWj8=; b=6nGcSn2vTakr36iz1CRyUZZg5D/jumBknYNJi6GAdNqhyuCGwn5RLHOAqMEoH1WVFC fCKrCbDkMka+ivJjm7X49GAFHABX/HQfSHePCBC2wxpABeKL8hvpPn4wMrLt9COwaGk6 EkejAXyAtH3O7J8XHfFFMa3eCe4JjrSgMea6Z2xp4rsafLsDdLFai0WLh/J46y5V2ya1 AkH3ZKdEaWXA2jyhDTJWufGKDpQtgwNMbhc+sVYqcgmuJaw9tIVjhAI/lRUt3R08paW3 /RWQg0feUdEvuKbYgsfATAGpu1gjk4aMnUblTOnsMb+lLgTOa/5rTa6HVZAs86eF7NXA A2Rw== X-Gm-Message-State: ACgBeo2EffwLQsqaE9jVIqTQtAnC9w6uTFygR9xukzOGx5N2Lse8vEIx bQrWGqltNLPCyrDMbwrwB9bJdLGXNDWkJg== X-Received: by 2002:a17:902:e548:b0:16f:8df8:90d3 with SMTP id n8-20020a170902e54800b0016f8df890d3mr6138794plf.90.1659729321572; Fri, 05 Aug 2022 12:55:21 -0700 (PDT) Received: from stoup.. ([2602:ae:154e:e201:abf8:e436:f4c:9089]) by smtp.gmail.com with ESMTPSA id h13-20020a170902f70d00b0016f0c2ea158sm3393048plo.157.2022.08.05.12.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 12:55:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Song Gao , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 3/7] target/loongarch: Fix GDB get the wrong pc Date: Fri, 5 Aug 2022 12:55:11 -0700 Message-Id: <20220805195515.349768-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220805195515.349768-1-richard.henderson@linaro.org> References: <20220805195515.349768-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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" From: Song Gao GDB LoongArch add a register orig_a0, see the base64.xml [1]. We should add the orig_a0 to match the upstream GDB. [1]: https://github.com/bminor/binutils-gdb/blob/master/gdb/features/loongarch/base64.xml Signed-off-by: Song Gao Reviewed-by: Richard Henderson Acked-by: Alex Bennée Message-Id: <20220805033523.1416837-2-gaosong@loongson.cn> --- target/loongarch/cpu.c | 2 +- target/loongarch/gdbstub.c | 7 +++++-- gdb-xml/loongarch-base64.xml | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 1c69a76f2b..d84ec38cf7 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -683,7 +683,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data) cc->gdb_read_register = loongarch_cpu_gdb_read_register; cc->gdb_write_register = loongarch_cpu_gdb_write_register; cc->disas_set_info = loongarch_cpu_disas_set_info; - cc->gdb_num_core_regs = 34; + cc->gdb_num_core_regs = 35; cc->gdb_core_xml_file = "loongarch-base64.xml"; cc->gdb_stop_before_watchpoint = true; diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 24e126fb2d..5feb43445f 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -19,8 +19,11 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) if (0 <= n && n < 32) { return gdb_get_regl(mem_buf, env->gpr[n]); } else if (n == 32) { - return gdb_get_regl(mem_buf, env->pc); + /* orig_a0 */ + return gdb_get_regl(mem_buf, 0); } else if (n == 33) { + return gdb_get_regl(mem_buf, env->pc); + } else if (n == 34) { return gdb_get_regl(mem_buf, env->CSR_BADV); } return 0; @@ -36,7 +39,7 @@ int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) if (0 <= n && n < 32) { env->gpr[n] = tmp; length = sizeof(target_ulong); - } else if (n == 32) { + } else if (n == 33) { env->pc = tmp; length = sizeof(target_ulong); } diff --git a/gdb-xml/loongarch-base64.xml b/gdb-xml/loongarch-base64.xml index 4962bdbd28..a1dd4f2208 100644 --- a/gdb-xml/loongarch-base64.xml +++ b/gdb-xml/loongarch-base64.xml @@ -39,6 +39,7 @@ +