This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: remove `not_found_ptr' from linespec


I'm checking this in on the trunk.

While working on linespec, I noticed that the `not_found_ptr' argument
is redundant -- in the cases where it is set, the code in linespec also
throws a NOT_FOUND_ERROR.

This patch simplifies linespec by removing this argument and updating
the callers that used it.

I'm not really sure about the (pre-existing) `found' logic in
addr_string_to_sals, but I didn't try to address that here.

Built and regtested on x86-64 (compile farm).

Tom

2011-04-04  Tom Tromey  <tromey@redhat.com>

	* tracepoint.c (scope_info): Update.
	* symtab.c (decode_line_spec): Update.
	* python/python.c (gdbpy_decode_line): Update.
	* linespec.h (decode_line_1): Update.
	* linespec.c (decode_line_1): Remove 'not_found_ptr' argument.
	(decode_compound, find_method, symtab_from_filename)
	(decode_variable): Likewise.
	* cli/cli-cmds.c (edit_command): Update.
	(list_command): Update.
	* breakpoint.c (parse_breakpoint_sals): Remove 'not_found_ptr'
	argument.
	(create_breakpoint): Update.
	(until_break_command): Update.
	(addr_string_to_sals): Update.
	(decode_line_spec_1): Update.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.563
diff -u -r1.563 breakpoint.c
--- breakpoint.c	4 Apr 2011 15:22:51 -0000	1.563
+++ breakpoint.c	4 Apr 2011 17:30:14 -0000
@@ -7645,8 +7645,7 @@
 static void
 parse_breakpoint_sals (char **address,
 		       struct symtabs_and_lines *sals,
-		       struct linespec_result *canonical,
-		       int *not_found_ptr)
+		       struct linespec_result *canonical)
 {
   char *addr_start = *address;
 
@@ -7698,11 +7697,10 @@
  	      || ((strchr ("+-", (*address)[0]) != NULL)
  		  && ((*address)[1] != '['))))
 	*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
-			       default_breakpoint_line, canonical, 
-			       not_found_ptr);
+			       default_breakpoint_line, canonical);
       else
 	*sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0,
-		               canonical, not_found_ptr);
+		               canonical);
     }
   /* For any SAL that didn't have a canonical string, fill one in.  */
   if (sals->nelts > 0 && canonical->canonical == NULL)
@@ -7911,7 +7909,6 @@
   struct cleanup *bkpt_chain = NULL;
   int i;
   int pending = 0;
-  int not_found = 0;
   int task = 0;
   int prev_bkpt_count = breakpoint_count;
 
@@ -7934,7 +7931,7 @@
 
   TRY_CATCH (e, RETURN_MASK_ALL)
     {
-      parse_breakpoint_sals (&arg, &sals, &canonical, &not_found);
+      parse_breakpoint_sals (&arg, &sals, &canonical);
     }
 
   /* If caller is interested in rc value from parse, set value.  */
@@ -8545,7 +8542,7 @@
   while (*arg == ' ' || *arg == '\t')
     arg++;
 
-  parse_breakpoint_sals (&arg, &sals_start, &canonical_start, NULL);
+  parse_breakpoint_sals (&arg, &sals_start, &canonical_start);
 
   sal_start = sals_start.sals[0];
   addr_string_start = canonical_start.canonical[0];
@@ -8579,7 +8576,7 @@
      range.  This makes it possible to have ranges like "foo.c:27, +14",
      where +14 means 14 lines from the start location.  */
   sals_end = decode_line_1 (&arg, 1, sal_start.symtab, sal_start.line,
-			    &canonical_end, NULL);
+			    &canonical_end);
 
   /* canonical_end can be NULL if it was of the form "*0xdeadbeef".  */
   if (canonical_end.canonical == NULL)
@@ -9282,9 +9279,9 @@
 
   if (default_breakpoint_valid)
     sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
-			  default_breakpoint_line, NULL, NULL);
+			  default_breakpoint_line, NULL);
   else
-    sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, NULL, NULL);
+    sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, NULL);
 
   if (sals.nelts != 1)
     error (_("Couldn't get information on specified line."));
@@ -10934,7 +10931,7 @@
 addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 {
   char *s;
-  int marker_spec, not_found;
+  int marker_spec;
   struct symtabs_and_lines sals = {0};
   struct gdb_exception e;
 
@@ -10955,8 +10952,7 @@
 	    error (_("marker %s not found"), b->static_trace_marker_id);
 	}
       else
-	sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0,
-			      NULL, &not_found);
+	sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL);
     }
   if (e.reason < 0)
     {
@@ -10968,7 +10964,7 @@
 	 state, then user already saw the message about that
 	 breakpoint being disabled, and don't want to see more
 	 errors.  */
-      if (not_found 
+      if (e.error == NOT_FOUND_ERROR
 	  && (b->condition_not_parsed 
 	      || (b->loc && b->loc->shlib_disabled)
 	      || b->enable_state == bp_disabled))
@@ -10987,7 +10983,7 @@
 	}
     }
 
-  if (!not_found)
+  if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
     {
       gdb_assert (sals.nelts == 1);
 
@@ -11009,9 +11005,11 @@
 
       if (b->type == bp_static_tracepoint && !marker_spec)
 	sals.sals[0] = update_static_tracepoint (b, sals.sals[0]);
-    }
 
-  *found = !not_found;
+      *found = 1;
+    }
+  else
+    *found = 0;
 
   return sals;
 }
@@ -11650,10 +11648,10 @@
     sals = decode_line_1 (&string, funfirstline,
 			  default_breakpoint_symtab,
 			  default_breakpoint_line,
-			  NULL, NULL);
+			  NULL);
   else
     sals = decode_line_1 (&string, funfirstline,
-			  (struct symtab *) NULL, 0, NULL, NULL);
+			  (struct symtab *) NULL, 0, NULL);
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
   return sals;
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.117
diff -u -r1.117 linespec.c
--- linespec.c	25 Mar 2011 17:13:12 -0000	1.117
+++ linespec.c	4 Apr 2011 17:30:14 -0000
@@ -67,8 +67,7 @@
 						 int funfirstline,
 						 struct linespec_result *canonical,
 						 char *saved_arg,
-						 char *p,
-						 int *not_found_ptr);
+						 char *p);
 
 static struct symbol *lookup_prefix_sym (char **argptr, char *p);
 
@@ -77,8 +76,7 @@
 					     char *saved_arg,
 					     char *copy,
 					     struct type *t,
-					     struct symbol *sym_class,
-					     int *not_found_ptr);
+					     struct symbol *sym_class);
 
 static void cplusplus_error (const char *name, const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
@@ -108,8 +106,7 @@
 					       struct linespec_result *);
 
 static struct symtab *symtab_from_filename (char **argptr,
-					    char *p, int is_quote_enclosed,
-					    int *not_found_ptr);
+					    char *p, int is_quote_enclosed);
 
 static struct symbol *find_function_symbol (char **argptr, char *p,
 					    int is_quote_enclosed);
@@ -135,8 +132,7 @@
 static struct symtabs_and_lines decode_variable (char *copy,
 						 int funfirstline,
 						 struct linespec_result *canonical,
-						 struct symtab *file_symtab,
-						 int *not_found_ptr);
+						 struct symtab *file_symtab);
 
 static struct
 symtabs_and_lines symbol_found (int funfirstline,
@@ -783,12 +779,7 @@
 
    Note that it is possible to return zero for the symtab
    if no file is validly specified.  Callers must check that.
-   Also, the line number returned may be invalid.  
- 
-   If NOT_FOUND_PTR is not null, store a boolean true/false value at
-   the location, based on whether or not failure occurs due to an
-   unknown function or file.  In the case where failure does occur due
-   to an unknown function or file, do not issue an error message.  */
+   Also, the line number returned may be invalid.  */
 
 /* We allow single quotes in various places.  This is a hideous
    kludge, which exists because the completer can't yet deal with the
@@ -797,8 +788,7 @@
 
 struct symtabs_and_lines
 decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
-	       int default_line, struct linespec_result *canonical,
-	       int *not_found_ptr)
+	       int default_line, struct linespec_result *canonical)
 {
   char *p;
   char *q;
@@ -825,9 +815,6 @@
      was thrown when trying to parse a filename.  */
   volatile struct gdb_exception file_exception;
 
-  if (not_found_ptr)
-    *not_found_ptr = 0;
-
   /* Defaults have defaults.  */
 
   initialize_defaults (&default_symtab, &default_line);
@@ -888,7 +875,7 @@
 	  if (is_quote_enclosed)
 	    ++saved_arg;
 	  values = decode_compound (argptr, funfirstline, canonical,
-				    saved_arg, p, not_found_ptr);
+				    saved_arg, p);
 	  if (is_quoted && **argptr == '\'')
 	    *argptr = *argptr + 1;
 	  return values;
@@ -899,8 +886,7 @@
 
       TRY_CATCH (file_exception, RETURN_MASK_ERROR)
 	{
-	  file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed,
-					      not_found_ptr);
+	  file_symtab = symtab_from_filename (argptr, p, is_quote_enclosed);
 	}
       /* If that failed, maybe we have `function:label'.  */
       if (file_exception.reason < 0)
@@ -910,8 +896,6 @@
 	     exception.  */
 	  if (!function_symbol)
 	    throw_exception (file_exception);
-	  if (not_found_ptr)
-	    *not_found_ptr = 0;
 	}
 
       /* Check for single quotes on the non-filename part.  */
@@ -1016,17 +1000,12 @@
     }
 
   if (function_symbol)
-    {
-      if (not_found_ptr)
-	*not_found_ptr = 1;
-      throw_exception (file_exception);
-    }
+    throw_exception (file_exception);
 
   /* Look up that token as a variable.
      If file specified, use that file's per-file block to start with.  */
 
-  return decode_variable (copy, funfirstline, canonical,
-			  file_symtab, not_found_ptr);
+  return decode_variable (copy, funfirstline, canonical, file_symtab);
 }
 
 
@@ -1333,7 +1312,7 @@
 static struct symtabs_and_lines
 decode_compound (char **argptr, int funfirstline,
 		 struct linespec_result *canonical,
-		 char *the_real_saved_arg, char *p, int *not_found_ptr)
+		 char *the_real_saved_arg, char *p)
 {
   struct symtabs_and_lines values;
   char *p2;
@@ -1568,7 +1547,7 @@
 	 we'll lookup the whole string in the symbol tables.  */
 
       values = find_method (funfirstline, canonical, saved_arg,
-			    copy, t, sym_class, not_found_ptr);
+			    copy, t, sym_class);
       if (saved_java_argptr != NULL && values.nelts == 1)
 	{
 	  /* The user specified a specific return type for a java method.
@@ -1622,8 +1601,6 @@
     }    
 
   /* Couldn't find a minimal symbol, either, so give up.  */
-  if (not_found_ptr)
-    *not_found_ptr = 1;
   cplusplus_error (the_real_saved_arg,
 		   "Can't find member of namespace, "
 		   "class, struct, or union named \"%s\"\n",
@@ -1693,8 +1670,7 @@
 static struct symtabs_and_lines
 find_method (int funfirstline, struct linespec_result *canonical,
 	     char *saved_arg,
-	     char *copy, struct type *t, struct symbol *sym_class,
-	     int *not_found_ptr)
+	     char *copy, struct type *t, struct symbol *sym_class)
 {
   struct symtabs_and_lines values;
   struct symbol *sym = NULL;
@@ -1782,8 +1758,6 @@
     }
   else
     {
-      if (not_found_ptr)
-        *not_found_ptr = 1;
       if (copy[0] == '~')
 	cplusplus_error (saved_arg,
 			 "the class `%s' does not have destructor defined\n",
@@ -1798,14 +1772,10 @@
 
 
 /* Return the symtab associated to the filename given by the substring
-   of *ARGPTR ending at P, and advance ARGPTR past that filename.  If
-   NOT_FOUND_PTR is not null and the source file is not found, store
-   boolean true at the location pointed to and do not issue an
-   error message.  */
+   of *ARGPTR ending at P, and advance ARGPTR past that filename.  */
 
 static struct symtab *
-symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, 
-		      int *not_found_ptr)
+symtab_from_filename (char **argptr, char *p, int is_quote_enclosed)
 {
   char *p1;
   char *copy;
@@ -1829,8 +1799,6 @@
   file_symtab = lookup_symtab (copy);
   if (file_symtab == 0)
     {
-      if (not_found_ptr)
-	*not_found_ptr = 1;
       if (!have_full_symbols () && !have_partial_symbols ())
 	throw_error (NOT_FOUND_ERROR,
 		     _("No symbol table is loaded.  "
@@ -2094,14 +2062,12 @@
 }
 
 /* Decode a linespec that's a variable.  If FILE_SYMTAB is non-NULL,
-   look in that symtab's static variables first.  If NOT_FOUND_PTR is
-   not NULL and the function cannot be found, store boolean true in
-   the location pointed to and do not issue an error message.  */ 
+   look in that symtab's static variables first.  */ 
 
 static struct symtabs_and_lines
 decode_variable (char *copy, int funfirstline,
 		 struct linespec_result *canonical,
-		 struct symtab *file_symtab, int *not_found_ptr)
+		 struct symtab *file_symtab)
 {
   struct symbol *sym;
   struct minimal_symbol *msymbol;
@@ -2121,9 +2087,6 @@
   if (msymbol != NULL)
     return minsym_found (funfirstline, msymbol);
 
-  if (not_found_ptr)
-    *not_found_ptr = 1;
-
   if (!have_full_symbols ()
       && !have_partial_symbols ()
       && !have_minimal_symbols ())
Index: linespec.h
===================================================================
RCS file: /cvs/src/src/gdb/linespec.h,v
retrieving revision 1.13
diff -u -r1.13 linespec.h
--- linespec.h	24 Mar 2011 19:47:17 -0000	1.13
+++ linespec.h	4 Apr 2011 17:30:14 -0000
@@ -46,6 +46,6 @@
 extern struct symtabs_and_lines
 	decode_line_1 (char **argptr, int funfirstline,
 		       struct symtab *default_symtab, int default_line,
-		       struct linespec_result *canonical, int *not_found_ptr);
+		       struct linespec_result *canonical);
 
 #endif /* defined (LINESPEC_H) */
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.263
diff -u -r1.263 symtab.c
--- symtab.c	4 Apr 2011 14:10:12 -0000	1.263
+++ symtab.c	4 Apr 2011 17:30:14 -0000
@@ -4375,7 +4375,7 @@
 
   sals = decode_line_1 (&string, funfirstline,
 			cursal.symtab, cursal.line,
-			NULL, NULL);
+			NULL);
 
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.220
diff -u -r1.220 tracepoint.c
--- tracepoint.c	18 Mar 2011 18:47:56 -0000	1.220
+++ tracepoint.c	4 Apr 2011 17:30:15 -0000
@@ -2333,7 +2333,7 @@
     error (_("requires an argument (function, "
 	     "line or *addr) to define a scope"));
 
-  sals = decode_line_1 (&args, 1, NULL, 0, NULL, NULL);
+  sals = decode_line_1 (&args, 1, NULL, 0, NULL);
   if (sals.nelts == 0)
     return;		/* Presumably decode_line_1 has already warned.  */
 
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.112
diff -u -r1.112 cli-cmds.c
--- cli/cli-cmds.c	9 Mar 2011 12:48:56 -0000	1.112
+++ cli/cli-cmds.c	4 Apr 2011 17:30:15 -0000
@@ -787,7 +787,7 @@
       /* Now should only be one argument -- decode it in SAL.  */
 
       arg1 = arg;
-      sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0);
+      sals = decode_line_1 (&arg1, 0, 0, 0, 0);
 
       if (! sals.nelts)
 	{
@@ -917,7 +917,7 @@
     dummy_beg = 1;
   else
     {
-      sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0);
+      sals = decode_line_1 (&arg1, 0, 0, 0, 0);
 
       if (!sals.nelts)
 	return;			/*  C++  */
@@ -950,9 +950,9 @@
       else
 	{
 	  if (dummy_beg)
-	    sals_end = decode_line_1 (&arg1, 0, 0, 0, 0, 0);
+	    sals_end = decode_line_1 (&arg1, 0, 0, 0, 0);
 	  else
-	    sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0, 0);
+	    sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line, 0);
 	  if (sals_end.nelts == 0)
 	    return;
 	  if (sals_end.nelts > 1)
Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.63
diff -u -r1.63 python.c
--- python/python.c	18 Mar 2011 08:44:47 -0000	1.63
+++ python/python.c	4 Apr 2011 17:30:15 -0000
@@ -454,7 +454,7 @@
 	  arg = xstrdup (arg);
 	  make_cleanup (xfree, arg);
 	  copy = arg;
-	  sals = decode_line_1 (&copy, 0, 0, 0, 0, 0);
+	  sals = decode_line_1 (&copy, 0, 0, 0, 0);
 	  make_cleanup (xfree, sals.sals);
 	}
       else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]