[binutils-gdb] Use outermost_context_p in more places

Tom Tromey tromey@sourceware.org
Mon Jul 16 15:17:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=edb0470b99a9f399ccb5d666173c4315f6cb02c0

commit edb0470b99a9f399ccb5d666173c4315f6cb02c0
Author: Tom Tromey <tom@tromey.com>
Date:   Sun May 20 23:42:01 2018 -0600

    Use outermost_context_p in more places
    
    This changes a few explicit checks of context_stack_depth to use
    outermost_context_p instead.  This simplifies some future work.
    
    gdb/ChangeLog
    2018-07-16  Tom Tromey  <tom@tromey.com>
    
    	* xcoffread.c (read_xcoff_symtab): Use outermost_context_p.
    	* dwarf2read.c (using_directives, new_symbol): Use
    	outermost_context_p.
    	* dbxread.c (process_one_symbol): Use outermost_context_p.
    	* coffread.c (coff_symtab_read): Use outermost_context_p.

Diff:
---
 gdb/ChangeLog    | 8 ++++++++
 gdb/coffread.c   | 8 ++++----
 gdb/dbxread.c    | 6 +++---
 gdb/dwarf2read.c | 4 ++--
 gdb/xcoffread.c  | 8 ++++----
 5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0474bef..af19524 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2018-07-16  Tom Tromey  <tom@tromey.com>
 
+	* xcoffread.c (read_xcoff_symtab): Use outermost_context_p.
+	* dwarf2read.c (using_directives, new_symbol): Use
+	outermost_context_p.
+	* dbxread.c (process_one_symbol): Use outermost_context_p.
+	* coffread.c (coff_symtab_read): Use outermost_context_p.
+
+2018-07-16  Tom Tromey  <tom@tromey.com>
+
 	* dwarf2read.c (using_directives, read_func_scope)
 	(read_lexical_block_scope): Update.
 	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 0ba5bab..b13d901 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1088,7 +1088,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	      /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
 	         contains number of lines to '}' */
 
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  complaint (_("`.ef' symbol without matching `.bf' "
 			       "symbol ignored starting at symnum %d"),
@@ -1099,7 +1099,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 
 	      newobj = pop_context ();
 	      /* Stack must be empty now.  */
-	      if (context_stack_depth > 0 || newobj == NULL)
+	      if (!outermost_context_p () || newobj == NULL)
 		{
 		  complaint (_("Unmatched .ef symbol(s) ignored "
 			       "starting at symnum %d"),
@@ -1152,7 +1152,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 	    }
 	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  complaint (_("`.eb' symbol without matching `.bb' "
 			       "symbol ignored starting at symnum %d"),
@@ -1168,7 +1168,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 			     symnum);
 		  break;
 		}
-	      if (local_symbols && context_stack_depth > 0)
+	      if (local_symbols && !outermost_context_p ())
 		{
 		  tmpaddr =
 		    cs->c_value + ANOFFSET (objfile->section_offsets,
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 5d4b978..996da27 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2493,7 +2493,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	     the current block.  */
 	  struct block *block;
 
- 	  if (context_stack_depth <= 0)
+	  if (outermost_context_p ())
  	    {
 	      lbrac_mismatch_complaint (symnum);
  	      break;
@@ -2562,7 +2562,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
       valu += function_start_offset;
 
-      if (context_stack_depth <= 0)
+      if (outermost_context_p ())
 	{
 	  lbrac_mismatch_complaint (symnum);
 	  break;
@@ -2883,7 +2883,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 		  break;
 		}
 
-	      if (context_stack_depth > 0)
+	      if (!outermost_context_p ())
 		{
 		  struct block *block;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 74da35c..b7933de 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11103,7 +11103,7 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu)
 static struct using_direct **
 using_directives (enum language language)
 {
-  if (language == language_ada && context_stack_depth == 0)
+  if (language == language_ada && outermost_context_p ())
     return get_global_using_directives ();
   else
     return get_local_using_directives ();
@@ -21353,7 +21353,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	     when we do not have enough information to show inlined frames;
 	     pretend it's a local variable in that case so that the user can
 	     still see it.  */
-	  if (context_stack_depth > 0
+	  if (!outermost_context_p ()
 	      && context_stack[context_stack_depth - 1].name != NULL)
 	    SYMBOL_IS_ARGUMENT (sym) = 1;
 	  attr = dwarf2_attr (die, DW_AT_location, cu);
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index f9f19e7..7f4e63e 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1391,7 +1391,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	      /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
 	         contains number of lines to '}' */
 
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  ef_complaint (cs->c_symnum);
 		  within_function = 0;
@@ -1399,7 +1399,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		}
 	      newobj = pop_context ();
 	      /* Stack must be empty now.  */
-	      if (context_stack_depth > 0 || newobj == NULL)
+	      if (!outermost_context_p () || newobj == NULL)
 		{
 		  ef_complaint (cs->c_symnum);
 		  within_function = 0;
@@ -1483,7 +1483,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	    }
 	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
-	      if (context_stack_depth <= 0)
+	      if (outermost_context_p ())
 		{	/* We attempted to pop an empty context stack.  */
 		  eb_complaint (cs->c_symnum);
 		  break;
@@ -1494,7 +1494,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 		  eb_complaint (cs->c_symnum);
 		  break;
 		}
-	      if (local_symbols && context_stack_depth > 0)
+	      if (local_symbols && !outermost_context_p ())
 		{
 		  /* Make a block for the local symbols within.  */
 		  finish_block (newobj->name, &local_symbols,



More information about the Gdb-cvs mailing list