Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb] Print user/includes fields for maint commands
Date: Tue, 24 Mar 2020 13:04:49 -0400	[thread overview]
Message-ID: <0e3c47b7-9cec-5efa-c3cf-8bff63042886@simark.ca> (raw)
In-Reply-To: <20200324112241.GA23197@delia>

On 2020-03-24 7:22 a.m., Tom de Vries wrote:
> diff --git a/gdb/symmisc.c b/gdb/symmisc.c
> index 3df526bddb..f7a36905f2 100644
> --- a/gdb/symmisc.c
> +++ b/gdb/symmisc.c
> @@ -279,8 +279,12 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
>    const struct block *b;
>    int depth;
>  
> -  fprintf_filtered (outfile, "\nSymtab for file %s\n",
> +  fprintf_filtered (outfile, "\nSymtab for file %s",
>  		    symtab_to_filename_for_display (symtab));
> +  fprintf_filtered (outfile, " at ");
> +  gdb_print_host_address (symtab, outfile);
> +  fprintf_filtered (outfile, "\n");

You could use a single fprintf_filtered call, with host_address_to_string.

> +
>    if (SYMTAB_DIRNAME (symtab) != NULL)
>      fprintf_filtered (outfile, "Compilation directory is %s\n",
>  		      SYMTAB_DIRNAME (symtab));
> @@ -371,6 +375,32 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
>  			"\nBlockvector same as owning compunit: %s\n\n",
>  			compunit_filename);
>      }
> +
> +  if (symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)))

I find it hard to understand the intent of this line.  Would it be possible to introduce
a helper function (probably in symtab.h)?  Something like

/* Return true if this symtab is the "main" symtab of its compunit_symtab.  */

static inline bool
is_main_symtab_of_compunit_symtab (struct symtab *symtab)
{
  return symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab));
}

> +    {
> +      struct compunit_symtab *cust = SYMTAB_COMPUNIT (symtab);
> +
> +      if (cust->user)

!= nullptr

> +	{
> +	  fprintf_filtered (outfile, "Compunit user: ");
> +	  gdb_print_host_address (COMPUNIT_FILETABS (cust->user), outfile);
> +	  fprintf_filtered (outfile, "\n");

Single fprintf_filtered call, with host_address_to_string.

> +	}
> +      if (cust->includes)

!= nullptr

> +	{
> +	  struct compunit_symtab *include;

Declare this within loop, when it's initialized.

> +	  for (i = 0; ; ++i)
> +	    {
> +	      include = cust->includes[i];
> +	      if (!include)

include == nullptr

> +		break;
> +	      fprintf_filtered (outfile, "Compunit include: ");
> +	      gdb_print_host_address (COMPUNIT_FILETABS (include), outfile);
> +	      fprintf_filtered (outfile, "\n");

Single fprintf_filtered called here too.

> +	    }
> +	}
> +    }
> +
>  }
>  
>  static void
> @@ -809,6 +839,30 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
>  					 " ((struct blockvector *) %s)\n",
>  					 host_address_to_string
>  				         (COMPUNIT_BLOCKVECTOR (cust)));
> +			printf_filtered ("    user"
> +					 " ((struct compunit_symtab *) %s)\n",
> +					 cust->user

!= nullptr

> +					 ? host_address_to_string (cust->user)
> +					 : "(null)");
> +			if (cust->includes)

!= nullptr

> +			  {
> +			    struct compunit_symtab *include;
> +			    int i;

Declare both variables at initialize-time.

> +
> +			    printf_filtered ("    ( includes\n");
> +			    for (i = 0; ; ++i)
> +			      {
> +				include = cust->includes[i];
> +				if (!include)

include == nullptr

Simon


  reply	other threads:[~2020-03-24 17:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 11:22 Tom de Vries
2020-03-24 17:04 ` Simon Marchi [this message]
2020-03-24 22:28   ` Tom de Vries
2020-03-24 22:41     ` Simon Marchi
2020-03-24 22:55       ` Tom de Vries
2020-03-24 23:14         ` Simon Marchi
2020-03-24 23:15           ` Simon Marchi

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=0e3c47b7-9cec-5efa-c3cf-8bff63042886@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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