Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: Skip declarations in "info variables"
Date: Mon, 28 Dec 2009 21:05:00 -0000	[thread overview]
Message-ID: <20091228210526.GA30551@caradoc.them.org> (raw)
In-Reply-To: <833a4ho3ej.fsf@gnu.org>

I forgot to come back to this patch.

On Sat, Nov 14, 2009 at 11:35:00AM +0200, Eli Zaretskii wrote:
> To decide whether or not this is a Good Thing, we need to answer a
> question: What is the purpose of "info variables"?  More specifically,
> what are the main use-cases for using it?  Can people please share
> their experience with this command?

Based on the feedback we received, I think definitions are the useful
part of the "info variables" output.

> This is an almost mechanical change, so okay.  But I think we need a
> NEWS entry about the behavior change.

Agreed.  How about this?

-- 
Daniel Jacobowitz
CodeSourcery

2009-12-28  Daniel Jacobowitz  <dan@codesourcery.com>

	* NEWS: Document "info variables" change.
	* dwarf2read.c (new_symbol): Add file-scope external unresolved
	symbols to global_symbols.
	* symtab.c (search_symbols): Skip LOC_UNRESOLVED symbols.

	* gdb.texinfo (Symbols): "info variables" prints definitions, not
	declarations.

---
 gdb/doc/gdb.texinfo |    2 +-
 gdb/dwarf2read.c    |    9 ++++++++-
 gdb/symtab.c        |    5 ++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2009-11-13 16:22:50.000000000 -0500
+++ src/gdb/dwarf2read.c	2009-11-13 16:27:57.000000000 -0500
@@ -8441,8 +8441,15 @@ new_symbol (struct die_info *die, struct
 	      if (attr2 && (DW_UNSND (attr2) != 0)
 		  && dwarf2_attr (die, DW_AT_type, cu) != NULL)
 		{
+		  struct pending **list_to_add;
+
+		  /* A variable with DW_AT_external is never static, but it
+		     may be block-scoped.  */
+		  list_to_add = (cu->list_in_scope == &file_symbols
+				 ? &global_symbols : cu->list_in_scope);
+
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
-		  add_symbol_to_list (sym, cu->list_in_scope);
+		  add_symbol_to_list (sym, list_to_add);
 		}
 	      else if (!die_is_declaration (die, cu))
 		{
Index: src/gdb/symtab.c
===================================================================
--- src.orig/gdb/symtab.c	2009-11-13 16:22:50.000000000 -0500
+++ src/gdb/symtab.c	2009-11-13 16:27:57.000000000 -0500
@@ -3234,7 +3234,9 @@ search_symbols (char *regexp, domain_enu
 		&& ((regexp == NULL
 		     || re_exec (SYMBOL_NATURAL_NAME (*psym)) != 0)
 		    && ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
-			 && SYMBOL_CLASS (*psym) != LOC_BLOCK)
+			 && SYMBOL_CLASS (*psym) != LOC_UNRESOLVED
+			 && SYMBOL_CLASS (*psym) != LOC_BLOCK
+			 && SYMBOL_CLASS (*psym) != LOC_CONST)
 			|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK)
 			|| (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))))
 	      {
@@ -3310,6 +3312,7 @@ search_symbols (char *regexp, domain_enu
 		  && ((regexp == NULL
 		       || re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
 		      && ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+			   && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
 			   && SYMBOL_CLASS (sym) != LOC_BLOCK
 			   && SYMBOL_CLASS (sym) != LOC_CONST)
 			  || (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK)
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2009-11-13 16:28:20.000000000 -0500
+++ src/gdb/doc/gdb.texinfo	2009-11-13 16:28:43.000000000 -0500
@@ -12920,7 +12920,7 @@ that conflict with the regular expressio
 
 @kindex info variables
 @item info variables
-Print the names and data types of all variables that are declared
+Print the names and data types of all variables that are defined
 outside of functions (i.e.@: excluding local variables).
 
 @item info variables @var{regexp}
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.340
diff -u -p -r1.340 NEWS
--- NEWS	8 Dec 2009 00:17:45 -0000	1.340
+++ NEWS	28 Dec 2009 21:04:33 -0000
@@ -30,6 +30,10 @@ disassemble
   The disassemble command, when invoked with two arguments, now requires
   the arguments to be comma-separated.
 
+info variables
+  The info variables command now displays variable definitions.  Files
+  which only declare a variable are not shown.
+
 * New commands (for set/show, see "New options" below)
 
 record save [<FILENAME>]


  parent reply	other threads:[~2009-12-28 21:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-13 21:44 Daniel Jacobowitz
2009-11-13 22:27 ` Joel Brobecker
2009-11-14  9:36 ` Eli Zaretskii
2009-11-14 15:54   ` Daniel Jacobowitz
2009-11-14 16:03     ` Paul Pluzhnikov
2009-12-28 21:05   ` Daniel Jacobowitz [this message]
2009-12-28 21:21     ` Eli Zaretskii
2009-12-28 21:31       ` Daniel Jacobowitz

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=20091228210526.GA30551@caradoc.them.org \
    --to=drow@false.org \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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