From patchwork Thu Apr 26 02:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 26986 Received: (qmail 77523 invoked by alias); 26 Apr 2018 02:42:31 -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 77470 invoked by uid 89); 26 Apr 2018 02:42:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HK_RANDOM_ENVFROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*m:gmail X-HELO: mail-lf0-f66.google.com Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Apr 2018 02:42:22 +0000 Received: by mail-lf0-f66.google.com with SMTP id h4-v6so1587594lfc.1 for ; Wed, 25 Apr 2018 19:42:21 -0700 (PDT) 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; bh=9xtZSzA2T5cFCasS0in0/7yfzXOIQ6zBZpHl+XPrrr8=; b=rLplZAjtPz/sRYM7DEMG4lC+8UFxmCPdEfGirnzKykGMPiWF6n7Hr2ZZ9CxxKaJjny VxNTL4JB3+DuK9WNjh6AHvS2yZYsDaHqIOF75IHK05paCOGWOPsAUFB6V1GThcCv/Pff 4s8La5xoaaZBgjO5DJwRIloz8bsYY2inFXX9r7avSxU5Sx/JUUuJtm4wGfoaIdPHoJ6A hiutPgd8PcBuJyzoU06puQIRrqZw7TE9lilOmSsSy4eixIVT1Qf8IznARINXvJWhdWIM P0jjS6zT+ZEINFAHSUNhXmcC7JXyFPgq8bYPa/00akHeiS1Dk5higk0mdDGIFa47OoyI ncZA== X-Gm-Message-State: ALQs6tBlC2O3rliA2b+kVpsdsK/3PamaytbHaZGlS4wUcn6k96EUqxCg qQI+/np0+RvJXIkhbFqXF9I6Og== X-Google-Smtp-Source: AB8JxZqU96YAKQ5OmzpKKZCNDl2mCm4lMnP8CV2yonjDWLq6HMChCoA2b0Zg698TkdS4G6ZfKNUgrw== X-Received: by 10.46.56.6 with SMTP id f6mr1546509lja.25.1524710539761; Wed, 25 Apr 2018 19:42:19 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net. (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id r83-v6sm2806664lff.93.2018.04.25.19.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 19:42:18 -0700 (PDT) From: Max Filippov To: gdb-patches@sourceware.org Cc: Woody LaRue , Max Filippov Subject: [PATCH] gdb: xtensa: handle privileged registers Date: Wed, 25 Apr 2018 19:41:54 -0700 Message-Id: <20180426024154.5913-1-jcmvbkbc@gmail.com> X-IsSubscribed: yes gdb/ 2018-04-25 Max Filippov * xtensa-linux-tdep.c (xtensa-tdep.h): New include. (xtensa_linux_init_abi): Limit tdep->num_regs by tdep->num_nopriv_regs. * xtensa-tdep.c (xtensa_derive_tdep): Calculate tdep->num_nopriv_regs and only copy it to tdep->num_regs if it's not initialized. --- gdb/xtensa-linux-tdep.c | 6 ++++++ gdb/xtensa-tdep.c | 12 ++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c index a9b30c73f7bf..b62085de2fcb 100644 --- a/gdb/xtensa-linux-tdep.c +++ b/gdb/xtensa-linux-tdep.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "defs.h" +#include "xtensa-tdep.h" #include "osabi.h" #include "linux-tdep.h" #include "solib-svr4.h" @@ -97,6 +98,11 @@ xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch, static void xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (tdep->num_nopriv_regs < tdep->num_regs) + tdep->num_regs = tdep->num_nopriv_regs; + linux_init_abi (info, gdbarch); set_solib_svr4_fetch_link_map_offsets diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index a1ecf5f56a42..01f96165dc8d 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -3145,16 +3145,12 @@ xtensa_derive_tdep (struct gdbarch_tdep *tdep) max_size = rmap->byte_size; if (rmap->mask != 0 && tdep->num_regs == 0) tdep->num_regs = n; - /* Find out out how to deal with priveleged registers. - - if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0 - && tdep->num_nopriv_regs == 0) - tdep->num_nopriv_regs = n; - */ if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0 - && tdep->num_regs == 0) - tdep->num_regs = n; + && tdep->num_nopriv_regs == 0) + tdep->num_nopriv_regs = n; } + if (tdep->num_regs == 0) + tdep->num_regs = tdep->num_nopriv_regs; /* Number of pseudo registers. */ tdep->num_pseudo_regs = n - tdep->num_regs;