From patchwork Wed Jan 18 23:50:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 18948 Received: (qmail 14818 invoked by alias); 18 Jan 2017 23:51:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14384 invoked by uid 89); 18 Jan 2017 23:51:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_ENVFROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=overlays, 946, H*Ad:U*marc, 9620 X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Jan 2017 23:51:08 +0000 Received: by mail-pf0-f195.google.com with SMTP id e4so1997491pfg.0 for ; Wed, 18 Jan 2017 15:51:08 -0800 (PST) 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; bh=qOGmdOdhAswMkxommjNHp9+ILCobX/59dQDPEke+45c=; b=s5S6M0DlQtKAclzSTLa7TJS1kHffJXmEU0LF9vtlR10T20hw+5PBYQpxvj9XkfRiWR LcPbSxfo33mfwIKSWGgcBc06quE9gSN4gstYb9MwiFI1QU/ykoPaV8L7akylwofVGUGV HqNTMZLAnKKwM0pguwxvGW8Hdb2BqoGVGkID94wBDZt7mUYHv5S9DlGeHEuqIWYyF1hX 9k78aZMoAQXoNERL0XoiYPNO9U1fXK1o0SSZKS+DvZQXZt+HfTCWhvCDjau+qMoRyGtK 4w9LgcFbpArtZfkJ26MyiSmIsJQTo3vQvsYWmSX/OKakSH4Zbn469rEksp49BZyuaFR1 bTcQ== X-Gm-Message-State: AIkVDXIN40b2UiqjM/2jHWbiP1G9hYYx8lTEWlCG/01Pg6R8MTjO7EQZRtanzIoZKQ/WXA== X-Received: by 10.84.232.201 with SMTP id x9mr8940792plm.102.1484783467235; Wed, 18 Jan 2017 15:51:07 -0800 (PST) Received: from octofox.metropolis (corp.Cadence.COM. [158.140.1.28]) by smtp.gmail.com with ESMTPSA id u14sm3320413pfg.18.2017.01.18.15.51.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 15:51:06 -0800 (PST) From: Max Filippov To: gdb-patches@sourceware.org Cc: Maxim Grigoriev , Woody LaRue , Marc Gauthier , Max Filippov Subject: [PATCH 2/3] gdb: xtensa-linux: add call0 support Date: Wed, 18 Jan 2017 15:50:37 -0800 Message-Id: <1484783438-13780-3-git-send-email-jcmvbkbc@gmail.com> In-Reply-To: <1484783438-13780-1-git-send-email-jcmvbkbc@gmail.com> References: <1484783438-13780-1-git-send-email-jcmvbkbc@gmail.com> Correctly handle a0- registers. This allows debugging call0 code in linux natively. The register structure is the same for windowed and call0 ABIs because currently linux kernel internally requires windowed registers, so they are always present. 2017-01-18 Max Filippov gdb/ * xtensa-linux-nat.c (C0_NREGS): New definition. (fill_gregset): Call regcache_raw_collect for a single specified register or for all registers in a0_base..a0_base + C0_NREGS range. (supply_gregset_reg): Call regcache_raw_supply for a single specified register or for all registers in a0_base..a0_base + C0_NREGS range. --- gdb/xtensa-linux-nat.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c index afe15f6..2693939 100644 --- a/gdb/xtensa-linux-nat.c +++ b/gdb/xtensa-linux-nat.c @@ -45,6 +45,8 @@ hardware-specific overlays. */ #include "xtensa-xtregs.c" +#define C0_NREGS 16 /* Number of A-registers to track. */ + void fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum) @@ -94,6 +96,20 @@ fill_gregset (const struct regcache *regcache, gdbarch_tdep (gdbarch)->ar_base + i, ®s->ar[i]); } + if (regnum >= gdbarch_tdep (gdbarch)->a0_base + && regnum < gdbarch_tdep (gdbarch)->a0_base + C0_NREGS) + regcache_raw_collect (regcache, regnum, + ®s->ar[(4 * regs->windowbase + regnum + - gdbarch_tdep (gdbarch)->a0_base) + % gdbarch_tdep (gdbarch)->num_aregs]); + else if (regnum == -1) + { + for (i = 0; i < C0_NREGS; ++i) + regcache_raw_collect (regcache, + gdbarch_tdep (gdbarch)->a0_base + i, + ®s->ar[(4 * regs->windowbase + i) + % gdbarch_tdep (gdbarch)->num_aregs]); + } } static void @@ -146,6 +162,20 @@ supply_gregset_reg (struct regcache *regcache, gdbarch_tdep (gdbarch)->ar_base + i, ®s->ar[i]); } + if (regnum >= gdbarch_tdep (gdbarch)->a0_base + && regnum < gdbarch_tdep (gdbarch)->a0_base + C0_NREGS) + regcache_raw_supply (regcache, regnum, + ®s->ar[(4 * regs->windowbase + regnum + - gdbarch_tdep (gdbarch)->a0_base) + % gdbarch_tdep (gdbarch)->num_aregs]); + else if (regnum == -1) + { + for (i = 0; i < C0_NREGS; ++i) + regcache_raw_supply (regcache, + gdbarch_tdep (gdbarch)->a0_base + i, + ®s->ar[(4 * regs->windowbase + i) + % gdbarch_tdep (gdbarch)->num_aregs]); + } } void