Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] Add -file-list-shared-libraries MI command
Date: Thu, 20 Oct 2016 05:05:00 -0000	[thread overview]
Message-ID: <d28e4754f90f9b102c17ec4f6bd6fc71@simark.ca> (raw)
In-Reply-To: <1473712054-30417-3-git-send-email-marc-andre.laperle@ericsson.com>

The patch looks good to me in general.  I wrote a few minor comments 
inline.

On 2016-09-12 16:27, Marc-Andre Laperle wrote:
> @@ -108,3 +111,67 @@ mi_cmd_file_list_exec_source_files (char
> *command, char **argv, int argc)
> 
>    ui_out_end (uiout, ui_out_type_list);
>  }
> +
> +void
> +mi_cmd_file_list_shared_libraries (char *command, char **argv, int 
> argc)
> +{
> +  struct ui_out *uiout = current_uiout;
> +  const char *pattern;
> +  struct so_list *so = NULL;
> +  struct gdbarch *gdbarch = target_gdbarch ();
> +
> +  switch (argc)
> +    {
> +    case 0:
> +      pattern = NULL;
> +      break;
> +    case 1:
> +      pattern = argv[0];
> +      break;
> +    default:
> +      error (_("Usage: -file-list-shared-libraries [REGEXP]"));
> +      break;
> +    }
> +
> +  if (pattern != NULL)
> +    {
> +      char *re_err = re_comp (pattern);

const ?

> +
> +      if (re_err != NULL)
> +	error (_("Invalid regexp: %s"), re_err);
> +    }
> +
> +  update_solib_list (1);
> +
> +  /* Print the table header.  */
> +  ui_out_begin (uiout, ui_out_type_list, "shared-libraries");

It's not a big deal, but you could use 
make_cleanup_ui_out_list_begin_end, which avoids accidentally forgetting 
the corresponding ui_out_end.

> +
> +  ALL_SO_LIBS (so)
> +    {
> +      if (so->so_name[0] == '\0')
> +	continue;
> +      if (pattern != NULL && !re_exec (so->so_name))
> +	continue;
> +
> +      ui_out_begin (uiout, ui_out_type_tuple, NULL);

Same here, but with make_cleanup_ui_out_tuple_begin_end.

> +      if (so->addr_high != 0)
> +	{
> +	  ui_out_field_core_addr (uiout, "from", gdbarch, so->addr_low);
> +	  ui_out_field_core_addr (uiout, "to", gdbarch, so->addr_high);
> +	}
> +      else
> +	{
> +	  ui_out_field_skip (uiout, "from");
> +	  ui_out_field_skip (uiout, "to");
> +	}

You might be able to just remove the else.  I think ui_out_field_skip is 
only relevant for tables (which was used in the code that you took 
inspiration from), since you need to explicitly tell if you want to skip 
a table cell.  For tuples, if you want to omit a field, you just don't 
emit it.

> diff --git a/gdb/solib.h b/gdb/solib.h
> index 75490b6..ee621ce 100644
> --- a/gdb/solib.h
> +++ b/gdb/solib.h
> @@ -73,6 +73,24 @@ extern void no_shared_libraries (char *ignored, int
> from_tty);
>  extern void set_solib_ops (struct gdbarch *gdbarch,
>  			   const struct target_so_ops *new_ops);
> 
> +/* Synchronize GDB's shared object list with inferior's.
> +
> +   Extract the list of currently loaded shared objects from the
> +   inferior, and compare it with the list of shared objects currently
> +   in GDB's so_list_head list.  Edit so_list_head to bring it in sync
> +   with the inferior's new list.
> +
> +   If we notice that the inferior has unloaded some shared objects,
> +   free any symbolic info GDB had read about those shared objects.
> +
> +   Don't load symbolic info for any new shared objects; just add them
> +   to the list, and leave their symbols_loaded flag clear.
> +
> +   If FROM_TTY is non-null, feel free to print messages about what
> +   we're doing.  */

I noticed that this comment, which you moved from the .c to the .h, 
refers so_list_head.  so_list_head is a define present in the .c, so the 
comment makes less sense now.  What about bringing the define to the .h, 
and at the same time you could use it in the definition of ALL_SO_LIBS?

> +    mi_gdb_test "222-file-list-shared-libraries" \
> +	"222\\^done,shared-libraries=\\\[.*\{from=\".*\",to=\".*\",syms-read=\"1\",name=\".*${libname}.so\"\}.*]"
> \
> +	"Getting a list of shared libraries."

For consistency with all tests, I would suggest changing the test name 
to "get the list of shared libraries" (no period at the end, 
non-capitalized, neutral verb tense which I don't the name).

>  }
> 
> -mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
> +test_stop_on_solib_events
> +test_file_list_shared_libraries
> +mi_gdb_exit

I often see some tests ending with gdb_exit or mi_gdb_exit, but I don't 
think it's really required.  The code in lib/gdb.exp (e.g. gdb_exit) 
should take care of that, but I could be mistaken.


  parent reply	other threads:[~2016-10-20  5:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 20:28 [PATCH 1/3] Remove unused parameter in solib_add and update_solib_list Marc-Andre Laperle
2016-09-12 20:28 ` [PATCH 3/3] Add -file-list-shared-libraries MI command Marc-Andre Laperle
2016-10-14 21:20   ` Marc-André Laperle
2016-10-20  5:05   ` Simon Marchi [this message]
2016-11-23 13:06   ` Pedro Alves
2017-01-04 17:19     ` Marc-André Laperle
2017-01-12 16:15       ` Pedro Alves
2016-09-12 20:28 ` [PATCH 2/3] Add a better diagnostic message in mi_gdb_test Marc-Andre Laperle
2016-10-20  4:24   ` Simon Marchi
2016-11-23 13:03   ` Pedro Alves
2016-10-20  4:20 ` [PATCH 1/3] Remove unused parameter in solib_add and update_solib_list Simon Marchi
2016-11-23 13:03 ` Pedro Alves
2017-02-03 17:17 ` [PATCH v2 0/3] Shared libraries MI command Marc-Andre Laperle
2017-02-03 17:16   ` [PATCH v2 3/3] Add -file-list-shared-libraries " Marc-Andre Laperle
2017-02-06 12:40     ` Pedro Alves
2017-02-28 22:08       ` [Patch v3] " Marc-Andre Laperle
2017-03-01 15:50         ` Marc-André Laperle
2017-03-01 16:12         ` Eli Zaretskii
2017-03-01 16:38           ` [Patch v4] " Marc-Andre Laperle
2017-03-01 17:09             ` Eli Zaretskii
2017-03-02 14:56               ` [Patch v5] " Marc-Andre Laperle
2017-03-09 19:12                 ` Marc-André Laperle
2017-03-17 16:55                 ` Pedro Alves
2017-03-20 19:07                   ` Marc-André Laperle
2017-02-03 17:16   ` [PATCH v2 1/3] Remove unused parameter in solib_add and update_solib_list Marc-Andre Laperle
2017-02-03 17:16   ` [PATCH v2 2/3] Add a better diagnostic message in mi_gdb_test Marc-Andre Laperle

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=d28e4754f90f9b102c17ec4f6bd6fc71@simark.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=marc-andre.laperle@ericsson.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