From patchwork Thu May 21 22:17:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 6858 Received: (qmail 36921 invoked by alias); 21 May 2015 22:17:34 -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 36912 invoked by uid 89); 21 May 2015 22:17:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: mail-wg0-f45.google.com Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 21 May 2015 22:17:33 +0000 Received: by wgez8 with SMTP id z8so1143063wge.0 for ; Thu, 21 May 2015 15:17:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=SqHVcJeyjWxm8JdnGu+q6nZKtvtVJskw6nvl9isdfkI=; b=aabTzjfaAy3LoLaxRr0RhSuIE5DuHriCeSuZ2Cue1Cisj3Uw2BUvwIx6BNdW3iGBUT zkbBKWTBBtTHJbCer0N8AmtiboTbqWG1UliOvvNslDXw7jTfxXdON9SP9/q+IUzcXTlo V0/pP89ptv6b6fjYMLSwKrdelPcQ+EQyl/gv6nhDvvVJ/gjk6e8BrP/XqJ7cyXNzSwlV gd1fQGlg6/DJx1Pef5IEZVeyI0jBaXIeFtD254fkzvvk8C5obVnuVlgaQraNSv1Sv+k1 9F+XAmJ5fQ2UARY0dE301FHP0ooIEecT3VLq/3zcKRFA9jVJ37dQXRn3r8weuqs3Z3vk AcvQ== X-Gm-Message-State: ALoCoQlHpwR5Ti1VQbbqTKH/GzRtG6RDnuBWCUBxL/QxW4rz3Q8TiL1aBSz1NHpVv4KljOAp3YKx X-Received: by 10.180.94.39 with SMTP id cz7mr1539873wib.66.1432246650122; Thu, 21 May 2015 15:17:30 -0700 (PDT) Received: from localhost ([46.189.28.220]) by mx.google.com with ESMTPSA id v3sm4611308wix.8.2015.05.21.15.17.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 15:17:29 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/2] gdb: Add 'tui reg prev' command. Date: Fri, 22 May 2015 00:17:11 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes There is already a 'tui reg next' command, this adds a symmetric 'tui reg prev' command. gdb/ChangeLog: * tui/tui-regs.c (tui_reg_prev_command): New function. (_initialize_tui_regs): Add 'prev' command for 'tui reg'. * reggroups.c (reggroup_prev): New function. * reggroups.h (reggroup_prev): Add declaration. Update comment. gdb/doc/ChangeLog: * gdb.texinfo (TUI Commands): Add 'tui reg prev' details. --- gdb/ChangeLog | 7 +++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 6 ++++++ gdb/reggroups.c | 30 ++++++++++++++++++++++++++++++ gdb/reggroups.h | 9 ++++++--- gdb/tui/tui-regs.c | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 42ef67d..b19e3ca 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2015-05-21 Andrew Burgess + * tui/tui-regs.c (tui_reg_prev_command): New function. + (_initialize_tui_regs): Add 'prev' command for 'tui reg'. + * reggroups.c (reggroup_prev): New function. + * reggroups.h (reggroup_prev): Add declaration. Update comment. + +2015-05-21 Andrew Burgess + * tui/tui-regs.c (tui_reg_next_command): Use NULL not 0. 2015-05-21 Andrew Burgess diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index f8b0487..ef38740 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-05-21 Andrew Burgess + + * gdb.texinfo (TUI Commands): Add 'tui reg prev' details. + 2015-05-16 Doug Evans * guile.texi (Memory Ports in Guile): Document support for unbuffered diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 1665372..44dff6e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -25003,6 +25003,12 @@ their order is target specific. The predefined register groups are the following: @code{general}, @code{float}, @code{system}, @code{vector}, @code{all}, @code{save}, @code{restore}. +@item tui reg prev +Show the previous register group. The list of register groups as well +as their order is target specific. The predefined register groups are +the following: @code{general}, @code{float}, @code{system}, +@code{vector}, @code{all}, @code{save}, @code{restore}. + @item tui reg system Show the system registers in the register window. diff --git a/gdb/reggroups.c b/gdb/reggroups.c index cbafc01..27be704 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -150,6 +150,36 @@ reggroup_next (struct gdbarch *gdbarch, struct reggroup *last) return NULL; } +struct reggroup * +reggroup_prev (struct gdbarch *gdbarch, struct reggroup *last) +{ + struct reggroups *groups; + struct reggroup_el *el; + struct reggroup *prev; + + /* Don't allow this function to be called during architecture + creation. If there are no groups, use the default groups list. */ + groups = gdbarch_data (gdbarch, reggroups_data); + gdb_assert (groups != NULL); + if (groups->first == NULL) + { + groups = &default_groups; + gdb_assert (groups->first != NULL); + } + + /* Return the first/next reggroup. */ + if (last == NULL) + return groups->first->group; + prev = NULL; + for (el = groups->first; el != NULL; el = el->next) + { + if (el->group == last) + return prev; + prev = el->group; + } + return NULL; +} + /* Is REGNUM a member of REGGROUP? */ int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum, diff --git a/gdb/reggroups.h b/gdb/reggroups.h index 2ad74bc..bb0d6e7 100644 --- a/gdb/reggroups.h +++ b/gdb/reggroups.h @@ -49,11 +49,14 @@ extern void reggroup_add (struct gdbarch *gdbarch, struct reggroup *group); extern const char *reggroup_name (struct reggroup *reggroup); extern enum reggroup_type reggroup_type (struct reggroup *reggroup); -/* Interator for the architecture's register groups. Pass in NULL, - returns the first group. Pass in a group, returns the next group, - or NULL when the last group is reached. */ +/* Iterators for the architecture's register groups. Pass in NULL, returns + the first group. Pass in a group, returns the next or previous group, + or NULL when either the end or the beginning of the group list is + reached. */ extern struct reggroup *reggroup_next (struct gdbarch *gdbarch, struct reggroup *last); +extern struct reggroup *reggroup_prev (struct gdbarch *gdbarch, + struct reggroup *last); /* Is REGNUM a member of REGGROUP? */ extern int default_register_reggroup_p (struct gdbarch *gdbarch, int regnum, diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 8d4c0f8..8dbcda1 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -576,6 +576,36 @@ tui_reg_next_command (char *arg, int from_tty) } static void +tui_reg_prev_command (char *arg, int from_tty) +{ + struct gdbarch *gdbarch = get_current_arch (); + + if (TUI_DATA_WIN != NULL) + { + struct reggroup *group + = TUI_DATA_WIN->detail.data_display_info.current_group; + + group = reggroup_prev (gdbarch, group); + if (group == NULL) + { + struct reggroup *prev, *next; + + next = reggroup_next (gdbarch, NULL); + prev = NULL; + while (next) + { + prev = next; + next = reggroup_next (gdbarch, next); + } + group = prev; + } + + if (group) + tui_show_registers (group); + } +} + +static void tui_reg_float_command (char *arg, int from_tty) { tui_show_registers (float_reggroup); @@ -630,6 +660,9 @@ _initialize_tui_regs (void) add_cmd ("next", class_tui, tui_reg_next_command, _("Display next register group."), &tuireglist); + add_cmd ("prev", class_tui, tui_reg_prev_command, + _("Display previous register group."), + &tuireglist); }