From patchwork Fri May 22 16:37:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 6889 Received: (qmail 123571 invoked by alias); 22 May 2015 16:37:47 -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 123560 invoked by uid 89); 22 May 2015 16:37:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-wg0-f49.google.com Received: from mail-wg0-f49.google.com (HELO mail-wg0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 22 May 2015 16:37:45 +0000 Received: by wgfl8 with SMTP id l8so22906596wgf.2 for ; Fri, 22 May 2015 09:37:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=YaptLqQRSXJHCJ6PKpGJFP6EIgwoQlpJKdSOhjCqzbk=; b=lMUR8QlMibaSvMiP5fPxGvAOa9jcezbNerS9zq18v+BWZD6wW9qf7Fm2zJIuQJjyXb NThIeiSQKUmbyGX4A5CFUt1ow+stryeu/9WHoWlcvpvYkeWVmLC+shkWQjm2BCOozh4x l/FXeJ4KYUhA5iBPymJAJGndPEGcJ9ihlL6KcVLOUov8xc9kFPMDGh97JamHtjGlqHnP NgZ2TrRsD94CAr5Nh/QxecAqHEBqA2TQghLBUSHyP3khv6icOHeQ3W0mx+rEVi8QnqK5 lu4RCej+wlqWo8Tc5HibZ+DP1XNxQrusw2DjEfwmrDYaq1mNqNe+7Lehfolaxp6dpalB WknA== X-Gm-Message-State: ALoCoQkE7dlcQdtVRhQjnz9jjHfv/b7OeBEOokVDWuTbPCkFHK3kKeXlxxYfmvgPt7or680PUqvb X-Received: by 10.180.91.40 with SMTP id cb8mr9156442wib.64.1432312662142; Fri, 22 May 2015 09:37:42 -0700 (PDT) Received: from localhost ([62.116.9.99]) by mx.google.com with ESMTPSA id ei8sm3881957wjd.32.2015.05.22.09.37.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 09:37:41 -0700 (PDT) Date: Fri, 22 May 2015 18:37:39 +0200 From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: Re: [PATCH 1/2] gdb: Add 'tui reg prev' command. Message-ID: <20150522163739.GM2880@embecosm.com> References: <555E8104.9030305@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <555E8104.9030305@redhat.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes * Pedro Alves [2015-05-22 02:06:12 +0100]: > On 05/21/2015 11:17 PM, Andrew Burgess wrote: > > There is already a 'tui reg next' command, this adds a symmetric 'tui > > reg prev' command. > > Thanks! New version. I've addressed your comments from the first review. The reggroup_prev iterator has been fixed along the lines you suggested. Thanks, Andrew --- gdb: Add 'tui reg prev' command. 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. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 42ef67d..51cacf0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2015-05-22 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. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index f8b0487..7842ef5 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-05-22 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..745c5ea 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -150,6 +150,35 @@ reggroup_next (struct gdbarch *gdbarch, struct reggroup *last) return NULL; } +/* See reggroups.h. */ + +struct reggroup * +reggroup_prev (struct gdbarch *gdbarch, struct reggroup *curr) +{ + 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; + + prev = NULL; + for (el = groups->first; el != NULL; el = el->next) + { + gdb_assert (el->group != NULL); + if (el->group == curr) + return prev; + prev = el->group; + } + if (curr == NULL) + return prev; + 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..425a25c 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 (for next), or last (for prev) 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 *curr); /* 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..62ecaf0 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -575,6 +575,29 @@ tui_reg_next_command (char *arg, int from_tty) } } +/* Implementation of the "tui reg prev" command. Cycle the register group + displayed in the tui REG window, moving backwards through the list of + available register groups. */ + +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) + group = reggroup_prev (gdbarch, NULL); + + if (group) + tui_show_registers (group); + } +} + static void tui_reg_float_command (char *arg, int from_tty) { @@ -630,6 +653,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); }