From 5a8bbadf3dc9bf701545c3592911351932810ece Mon Sep 17 00:00:00 2001
From: Matt Rice <ratmice@gmail.com>
Date: Fri, 11 Sep 2009 01:54:50 -0700
Subject: [PATCH 2/2] Add enable_ambiguous argument to decode_line_1.

---
 gdb/breakpoint.c   |   14 +++++++-------
 gdb/cli/cli-cmds.c |    8 ++++----
 gdb/linespec.c     |   17 +++++++++--------
 gdb/linespec.h     |    3 ++-
 gdb/symtab.c       |    2 +-
 gdb/tracepoint.c   |    2 +-
 6 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9f50872..d242d43 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5793,10 +5793,10 @@ parse_breakpoint_sals (char **address,
  		  && ((*address)[1] != '['))))
 	*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
 			       default_breakpoint_line, addr_string, 
-			       not_found_ptr);
+			       not_found_ptr, 1);
       else
 	*sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0,
-		               addr_string, not_found_ptr);
+		               addr_string, not_found_ptr, 1);
     }
   /* For any SAL that didn't have a canonical string, fill one in. */
   if (sals->nelts > 0 && *addr_string == NULL)
@@ -6697,10 +6697,10 @@ until_break_command (char *arg, int from_tty, int anywhere)
 
   if (default_breakpoint_valid)
     sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
-			  default_breakpoint_line, (char ***) NULL, NULL);
+			  default_breakpoint_line, (char ***) NULL, NULL, 1);
   else
     sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 
-			  0, (char ***) NULL, NULL);
+			  0, (char ***) NULL, NULL, 1);
 
   if (sals.nelts != 1)
     error (_("Couldn't get information on specified line."));
@@ -7903,7 +7903,7 @@ breakpoint_re_set_one (void *bint)
       TRY_CATCH (e, RETURN_MASK_ERROR)
 	{
 	  sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL,
-				not_found_ptr);
+				not_found_ptr, 0);
 	}
       if (e.reason < 0)
 	{
@@ -8427,10 +8427,10 @@ decode_line_spec_1 (char *string, int funfirstline)
     sals = decode_line_1 (&string, funfirstline,
 			  default_breakpoint_symtab,
 			  default_breakpoint_line,
-			  (char ***) NULL, NULL);
+			  (char ***) NULL, NULL, 1);
   else
     sals = decode_line_1 (&string, funfirstline,
-			  (struct symtab *) NULL, 0, (char ***) NULL, NULL);
+			  (struct symtab *) NULL, 0, (char ***) NULL, NULL, 1);
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
   return sals;
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index ce7c2a6..1f03305 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -650,7 +650,7 @@ edit_command (char *arg, int from_tty)
       /* 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, 0, 1);
 
       if (! sals.nelts)
 	{
@@ -777,7 +777,7 @@ list_command (char *arg, int from_tty)
     dummy_beg = 1;
   else
     {
-      sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0);
+      sals = decode_line_1 (&arg1, 0, 0, 0, 0, 0, 1);
 
       if (!sals.nelts)
 	return;			/*  C++  */
@@ -810,9 +810,9 @@ list_command (char *arg, int from_tty)
       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, 0, 1);
 	  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, 0, 1);
 	  if (sals_end.nelts == 0)
 	    return;
 	  if (sals_end.nelts > 1)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 3e943a1..7cb6858 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -679,7 +679,7 @@ See set/show multiple-symbol."));
 
 struct symtabs_and_lines
 decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
-	       int default_line, char ***canonical, int *not_found_ptr)
+	       int default_line, char ***canonical, int *not_found_ptr, int enable_ambiguity)
 {
   char *p;
   char *q;
@@ -738,13 +738,14 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
 
   /* Check if the symbol could be an Objective-C selector.  */
 
-  {
-    struct symtabs_and_lines values;
-    values = decode_objc (argptr, funfirstline, NULL,
-			  canonical, saved_arg);
-    if (values.sals != NULL)
-      return values;
-  }
+  if (enable_ambiguity)
+    {
+       struct symtabs_and_lines values;
+       values = decode_objc (argptr, funfirstline, NULL,
+			     canonical, saved_arg);
+       if (values.sals != NULL)
+         return values;
+    }
 
   /* Does it look like there actually were two parts?  */
 
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 8ac6ea7..d80aee9 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -22,6 +22,7 @@ struct symtab;
 extern struct symtabs_and_lines
 	decode_line_1 (char **argptr, int funfirstline,
 		       struct symtab *default_symtab, int default_line,
-		       char ***canonical, int *not_found_ptr);
+		       char ***canonical, int *not_found_ptr,
+		       int enable_ambiguity);
 
 #endif /* defined (LINESPEC_H) */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8d9d72c..dae40d5 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4471,7 +4471,7 @@ decode_line_spec (char *string, int funfirstline)
 
   sals = decode_line_1 (&string, funfirstline,
 			cursal.symtab, cursal.line,
-			(char ***) NULL, NULL);
+			(char ***) NULL, NULL, 1);
 
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 0d439ef..c7b1d2d 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1852,7 +1852,7 @@ scope_info (char *args, int from_tty)
   if (args == 0 || *args == 0)
     error (_("requires an argument (function, line or *addr) to define a scope"));
 
-  sals = decode_line_1 (&args, 1, NULL, 0, &canonical, NULL);
+  sals = decode_line_1 (&args, 1, NULL, 0, &canonical, NULL, 1);
   if (sals.nelts == 0)
     return;		/* presumably decode_line_1 has already warned */
 
-- 
1.6.2.5

