Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC/WIP PATCH 06/14] Add base itsets support
Date: Wed, 30 Nov 2011 18:54:00 -0000	[thread overview]
Message-ID: <m3zkfdh267.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20111128153926.17761.97553.stgit@localhost6.localdomain6> (Pedro	Alves's message of "Mon, 28 Nov 2011 15:39:26 +0000")

>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:

Pedro> This started out by reusing the itsets parsing code in the old
Pedro> multi-process branch in CVS, but was actually quite limited, and in
Pedro> need of a full rewrite.  I found that Tromey's struct itset & co from
Pedro> the archer-tromey-multi-inferior arch branch was a good clean start
Pedro> design-wise (thanks Tom! :-) ).

My pleasure.

Pedro>  - A `[' command.  This is a prefix command, used to execute a command
Pedro>    with a given focus, without having to flip the current focus with
Pedro>    itfocus.

Cute implementation approach :)

I don't think completion will work right for this, even if you add a
completer for the new command.  It would be good to have a way do
"command" completion but then further delegate to the command's
completer as appropriate.

Pedro> Having played with this a lot, I'm not sure anymore requiring []
Pedro> everywhere is a good idea.  It's a bit hard to type.  We can get rid
Pedro> of the need for '[]' if we forbid spaces in specs.  Then the [] prefix
Pedro> command could be replaced with the "itfocus" command taking an
Pedro> optional command to execute, much like TotalView's dfocus command.
Pedro> We could add an 'f' alias for itfocus.  E.g.,

It would be fine by me.  Actually, since you have used it, I think you
should present it exactly as you would like it, then see what happens.
It is generally better, I think, to have a concrete proposal, as worked
out as possible.  Otherwise the discussion can be speculative and veer
into the bikesheddy.

Pedro> +  /* Add this itset to the end of the chain so that a list of
Pedro> +     breakpoints will come out in order of increasing numbers.  */

s/breakpoints/itsets/

Pedro> +static int
Pedro> +exec_contains_inferior (struct itset_elt *base, struct inferior *inf)
Pedro> +{
Pedro> +  struct itset_elt_exec *exec = (struct itset_elt_exec *) base;
Pedro> +
Pedro> +  /* FIXME: smarter compare.  */
Pedro> +  return (inf->pspace->ebfd != NULL
Pedro> +	  && strcmp (exec->exec_name,
Pedro> +		     bfd_get_filename (inf->pspace->ebfd)) == 0);

The FIXME is my fault; but still should be fixed.

I wonder whether the 'exec' style should be extended to:

1. Allow matching any objfile in the inferior, not just the main
   executable.  If not, it seems like a useful new sort of itset to
   provide.

2. Match just the path components provided by the user, so that the BFD
   /usr/bin/gdb will match user inputs "gdb" and "bin/gdb".

Pedro> +static void
Pedro> +restore_itset (void *arg)
Pedro> +{
Pedro> +  struct itset *saved_itset = arg;
Pedro> +
Pedro> +  current_itset = saved_itset;
Pedro> +}
Pedro> +
Pedro> +/* Save the current itset so that it may be restored by a later call
Pedro> +   to do_cleanups.  Returns the struct cleanup pointer needed for
Pedro> +   later doing the cleanup.  */
Pedro> +
Pedro> +static struct cleanup *
Pedro> +save_current_itset (void)
Pedro> +{
Pedro> +  struct cleanup *old_chain = make_cleanup (restore_itset,
Pedro> +					    current_itset);
Pedro> +
Pedro> +  return old_chain;
Pedro> +}

I think save_current_itset should acquire a reference, and restore_itset
should release it.  Otherwise I think the right call to
temp_itfocus_command can free current_itset, causing a crash.

Pedro> +static int
Pedro> +exec_contains_thread (struct itset_elt *base, struct thread_info *thr)

I think this one should delegate to exec_contains_inferior for better
maintenance.

Pedro> +void
Pedro> +dump_itset (struct itset *itset)
Pedro> +{
Pedro> +}

:-)

Pedro> +static void
Pedro> +itfocus_command (char *spec, int from_tty)

I wonder if it would be better to put the guts of this into a utility
function and then call that from MI as well.

Also I suspect we'd want some kind of MI async notification for changes
to the current itset..?

Pedro> +static void
Pedro> +itsets_info (char *arg, int from_tty)
Pedro> +{
[...]
Pedro> +    if (e->number > 0)

It would be nice to have a "maint info" variant that skips this check.

Pedro> +static void
Pedro> +temp_itfocus_command (char *spec, int from_tty)
Pedro> +{
Pedro> +  struct itset *itset;
Pedro> +  struct cleanup *old_chain;
Pedro> +
Pedro> +  if (spec == NULL)
Pedro> +    error_no_arg (_("i/t set"));
Pedro> +
Pedro> +  /* Evil hack.  We know the command is `['.  */
Pedro> +  spec--;

I forget, are leading spaces skipped by the CLI command processor?

Pedro> +  add_com ("[", no_class, temp_itfocus_command, _("\
Pedro> +Change the set of current inferiors/threads."));

I'm a little surprised that this didn't need some change in the CLI
code, like "!" did.

Pedro> +  add_com ("undefset", no_class, undefset_command, _("\

How about "delete itset ..." instead?

Pedro> +  add_com ("whichsets", no_class, whichsets_command, _("\
[...]
Pedro> +  add_com ("viewset", no_class, viewset_command, _("\
[...]

How about "info" subcommands for these instead?


As an aside, I have been thinking that some important (non-command)
concepts in gdb should be in the online help.  For example, I think it
would be nice if "help linespec" described the possible linespecs; then
other things like "help break" could refer to that.

Anyway, "help itset" might be nice to have.

Pedro> +/* Create a new I/T set which represents the current inferior, at the
Pedro> +   time that this call is made.  */
Pedro> +
Pedro> +struct itset *itset_create_current (void);

Reading this again, I realize that the comment should specify whether a
static or dynamic set is returned.

Pedro> +/* Return true if the inferior is contained in the I/T set.  */
Pedro> +
Pedro> +int itset_contains_inferior (struct itset *itset, struct inferior *inf);

Pedro> +/* Return true if the inferior is contained in the I/T set.  */
Pedro> +
Pedro> +int itset_member (struct itset *itset, int inf_id, int thread_id);

Perhaps the names should be closer to indicate that these are just
overloads.

Pedro> +const char *itset_name (const struct itset *itset);
Pedro> +const char *itset_spec (const struct itset *itset);
Pedro> +
Pedro> +int itset_is_empty (const struct itset *itset);

These need comments.  For this module I took the API comments in the
header file approach...

Pedro> +extern struct itset *current_itset;

Ditto.

Tom


  parent reply	other threads:[~2011-11-30 18:54 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28 15:39 [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 02/14] Mask software breakpoints from memory writes too Pedro Alves
2011-12-06 20:40   ` Pedro Alves
2011-12-13 21:26     ` Andreas Schwab
2011-12-13 21:38       ` Pedro Alves
2011-12-14  2:08         ` Andreas Schwab
2011-12-14 12:53           ` Pedro Alves
2011-12-14 12:53             ` Andreas Schwab
2011-12-14 15:06               ` Pedro Alves
2011-12-14 15:38                 ` Joel Brobecker
2011-11-28 15:39 ` [RFC/WIP PATCH 01/14] Breakpoints always-inserted and the record target Pedro Alves
2011-11-29 21:09   ` Tom Tromey
2011-12-05 17:04     ` Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 03/14] Flip to set target-async on by default Pedro Alves
2011-11-29 21:18   ` Tom Tromey
2011-12-02 19:16   ` Marc Khouzam
2011-11-28 15:39 ` [RFC/WIP PATCH 05/14] Add a small helper to get at a thread's inferior Pedro Alves
2011-11-29 21:19   ` Tom Tromey
2011-11-28 15:40 ` [RFC/WIP PATCH 04/14] Implement all-stop on top of a target running non-stop mode Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 12/14] Fix deref of stale pointer Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 09/14] I/T set support for breakpoints - trigger set, and stop set Pedro Alves
2011-11-29 22:02   ` Tom Tromey
2011-11-30 19:38     ` Tom Tromey
2011-12-16 19:29     ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 10/14] Comment out new info breakpoints output, in order to not break the test suite Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 07/14] Expand %ITSET% in the prompt to the current I/T set Pedro Alves
2011-11-29 21:22   ` Tom Tromey
2011-12-16 19:07     ` Pedro Alves
2011-12-16 19:09       ` Tom Tromey
2011-12-16 19:38         ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 13/14] Make "thread apply all" only loop over threads in the current set Pedro Alves
2011-11-28 18:40   ` Eli Zaretskii
2011-11-28 18:56     ` Pedro Alves
2011-11-29 21:47   ` Tom Tromey
2011-12-16 18:47     ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 08/14] Add support for the '@' core operator Pedro Alves
2011-11-30 17:29   ` Tom Tromey
2011-11-28 15:45 ` [RFC/WIP PATCH 14/14] Fix manythreads.exp test Pedro Alves
2011-11-28 15:45 ` [RFC/WIP PATCH 06/14] Add base itsets support Pedro Alves
2011-11-28 18:47   ` Eli Zaretskii
2011-11-28 18:56     ` Pedro Alves
2011-11-29 22:07   ` Tom Tromey
2011-11-30 18:54   ` Tom Tromey [this message]
2011-12-16 17:26     ` Pedro Alves
2011-11-28 15:46 ` [RFC/WIP PATCH 11/14] Add I/T set support to most execution commands Pedro Alves
2011-11-30 19:27   ` Tom Tromey
2011-11-28 18:10 ` [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-30 19:35 ` Tom Tromey
2011-12-16 19:40   ` Pedro Alves
2012-02-09  7:51 ` Tomas Östlund
2012-02-09  8:19 ` [RFC/WIP PATCH 00/14] I/T sets (resend) Tomas Östlund
2012-02-09 14:36   ` Pedro Alves
2012-02-15  9:48     ` Tomas Östlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zkfdh267.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox