From patchwork Wed Jul 21 19:59:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 483344 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp6534440jao; Wed, 21 Jul 2021 13:28:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8URagAMcKYJtDah8rCcelUPb22eIWILp00QDeUkCrnlmXDXJ8l7KCMZVX5hRiS4HURvFu X-Received: by 2002:a25:dc4d:: with SMTP id y74mr51228718ybe.289.1626899322001; Wed, 21 Jul 2021 13:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626899321; cv=none; d=google.com; s=arc-20160816; b=y0z5dfHW/srwphwYiPDp38yFVa0qSO5J6rxB4LKH/qXCREhL6YN9kK6FDHTlCJq94a nhgHp1cwpqodkAIXPsD3rbvSdL/mGpFHLL8F7osQCIkGAXt2LO22i+rhqzzU0WpOHjC7 scOAEE3PhlSUUgQTIFPD9hGVSjetQpJp7Y9Ou27EeGIM5GiVhvR8p84KIhrh4soXmXF9 ieY0SiW7jEfIUk0mPJFQFXJ12St4uGpXJzyuOzLowfrBMgLFmHaHoUS8bIqz74Eezn6T JcxlUGVKa1oZfiWn2gF4uIk+F3FFcf09dOhq2hmMp/7eZM0MHo3yIuyQQn5Guur3D0N5 lOPA== 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=lKfL9kcE9bZaAS1wP7b8UNPiK9t3sVn3RcrRasY3aLw=; b=AEuiTHYKT1vUfGEaGzA2VtBdcNdUsDQeDFdjKQ9riyBM+DzETsBrDm85yOLpTc4gMq xqR1VrWQuhhVG/tJXc46cONBsBj7iMLtsdI0pnw5dexYMhTL9TseyosXjyktlvy8stRe njR9ulqlSletjvNsIU9Qgfo6Q8z6tEId6UDSFQE9kqpkxTEN6333Ubh3qC3r6KnSAcro foJJ7+xdYi76Ccc1roYDrkxFkexmYZuhro2AhHz1o2ixGlbXKEEOD93dr0kB+CO+87Vc sRQMrJt6KGpi/y+4FYTyDQth2zyquQCmprEqVRoC03lAMvayjjLDXiCvUY6IjUOt8C3f GJhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hvhnNmV4; 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 d9si27951236ybi.215.2021.07.21.13.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Jul 2021 13:28:41 -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=hvhnNmV4; 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]:39864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6Ipd-0003kW-Do for patch@linaro.org; Wed, 21 Jul 2021 16:28:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6IOP-00031a-CN for qemu-devel@nongnu.org; Wed, 21 Jul 2021 16:00:37 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:40846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m6IOK-0005vE-CR for qemu-devel@nongnu.org; Wed, 21 Jul 2021 16:00:33 -0400 Received: by mail-pl1-x62e.google.com with SMTP id q13so721318plx.7 for ; Wed, 21 Jul 2021 13:00:27 -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=lKfL9kcE9bZaAS1wP7b8UNPiK9t3sVn3RcrRasY3aLw=; b=hvhnNmV4+jjMyuhtuHvPUAq25townmD4SgweCj20USzmdwXqEg4FhhBFKXlU8vcn7p fMgPk09SE51Lzacoc/vgYMHCg+5imEnnHxKcesTklka3smzScSQXY7btbCp2mRpxZa2l RA41KNViCcWqWkWizJtOc6BaElMcmMFY4yZOHr8//5bpokuc4ay32aZ2wjigrehMpLWt JE2fzMOzldckv805G8ty644Wk84+YwA9RDagOCMXtHjG/gngvoUICAI6CEeaMzoYP7Xm 7WMe7KZBCe1o13ACz5P94SLmbJUl4YVGiGussYQA6niBvfuuuE5DIi+mOkpqkMuVEiNC /mPg== 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=lKfL9kcE9bZaAS1wP7b8UNPiK9t3sVn3RcrRasY3aLw=; b=Vi2zFuTAs4kgTeWMgUPI+ZIn7R2N8X37605PRIKjUy7zfTrH6a2/d3BJ0r08M4m4fF pR2JQ3tbRccVWKNS43kSboL+2Z1Nb0KXt27SnAKznVdID3fc2bo0HNxRQFkaW/xxtDT2 ydXtL8LHcRsBFw0gF91aA3ELCfOJZFG80Z60bTtNEuMHf0FwAfoUmUaewdFKSjNbO+tc UZKG21zi2pyiwHaeo0eMGzPNrfg8KHtoZMCw55vc59bqGCv1e69zA83CT52nVNgQlWZb jh59iqp97pqxVJRoBx2u2MvJaZmnK1xFdDh0ScKI8zbmXcvadJVbG+mv4/Wv9PSSVyv0 +xag== X-Gm-Message-State: AOAM530TS5yqUxI56a/KMv4VKDx1Eiq69DETYJQ9f2ReCyMCo5EKAmJn ewL+sQEPPXMm2owrL7sRIXZd7wUE65BYAg== X-Received: by 2002:aa7:980d:0:b029:32e:2373:cd63 with SMTP id e13-20020aa7980d0000b029032e2373cd63mr38092358pfl.51.1626897626849; Wed, 21 Jul 2021 13:00:26 -0700 (PDT) Received: from localhost.localdomain (204-210-126-223.res.spectrum.com. [204.210.126.223]) by smtp.gmail.com with ESMTPSA id w3sm706028pjq.12.2021.07.21.13.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 13:00:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/27] target/avr: Implement gdb_adjust_breakpoint Date: Wed, 21 Jul 2021 09:59:49 -1000 Message-Id: <20210721195954.879535-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210721195954.879535-1-richard.henderson@linaro.org> References: <20210721195954.879535-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Ensure at registration that all breakpoints are in code space, not data space. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/avr/cpu.h | 1 + target/avr/cpu.c | 1 + target/avr/gdbstub.c | 13 +++++++++++++ target/avr/translate.c | 14 -------------- 4 files changed, 15 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/target/avr/cpu.h b/target/avr/cpu.h index d148e8c75a..93e3faa0a9 100644 --- a/target/avr/cpu.h +++ b/target/avr/cpu.h @@ -162,6 +162,7 @@ hwaddr avr_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int avr_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int avr_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); int avr_print_insn(bfd_vma addr, disassemble_info *info); +vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr); static inline int avr_feature(CPUAVRState *env, AVRFeature feature) { diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 57e3fab4a0..ea14175ca5 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -223,6 +223,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = avr_cpu_disas_set_info; cc->gdb_read_register = avr_cpu_gdb_read_register; cc->gdb_write_register = avr_cpu_gdb_write_register; + cc->gdb_adjust_breakpoint = avr_cpu_gdb_adjust_breakpoint; cc->gdb_num_core_regs = 35; cc->gdb_core_xml_file = "avr-cpu.xml"; cc->tcg_ops = &avr_tcg_ops; diff --git a/target/avr/gdbstub.c b/target/avr/gdbstub.c index c28ed67efe..1c1b908c92 100644 --- a/target/avr/gdbstub.c +++ b/target/avr/gdbstub.c @@ -82,3 +82,16 @@ int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) return 0; } + +vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr) +{ + /* + * This is due to some strange GDB behavior + * Let's assume main has address 0x100: + * b main - sets breakpoint at address 0x00000100 (code) + * b *0x100 - sets breakpoint at address 0x00800100 (data) + * + * Force all breakpoints into code space. + */ + return addr % OFFSET_DATA; +} diff --git a/target/avr/translate.c b/target/avr/translate.c index 8237a03c23..f7202a646b 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -2958,20 +2958,6 @@ static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) DisasContext *ctx = container_of(dcbase, DisasContext, base); TCGLabel *skip_label = NULL; - /* - * This is due to some strange GDB behavior - * Let's assume main has address 0x100: - * b main - sets breakpoint at address 0x00000100 (code) - * b *0x100 - sets breakpoint at address 0x00800100 (data) - * - * The translator driver has already taken care of the code pointer. - */ - if (!ctx->base.singlestep_enabled && - cpu_breakpoint_test(cs, OFFSET_DATA + ctx->base.pc_next, BP_ANY)) { - gen_breakpoint(ctx); - return; - } - /* Conditionally skip the next instruction, if indicated. */ if (ctx->skip_cond != TCG_COND_NEVER) { skip_label = gen_new_label();