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]

Re: [RFA] c++/11734 revisited


On Mon, 24 Jan 2011 18:37:45 +0100, Jan Kratochvil wrote:
> > Revised patch attached.
> 
> As a summary:
> 
> "physname" patch I call:
> 	42284fdf9d8cdb20c8e833bdbdb2b56977fea525
> 	http://sourceware.org/ml/gdb-cvs/2010-03/msg00082.html
> 	dwarf2_physname patchset:
> 	[RFA] dwarf2_physname FINAL
> 	http://sourceware.org/ml/gdb-patches/2010-03/msg00220.html
> 
> Original pre-physname code for pr11734::foo() did not call decode_compound but
> called decode_variable which resolved it from the fully qualified name.
> 
> post-physname code tried to resolve pr11734::foo() via decode_compound which
> did not support such case and it fails now on HEAD.
> 
> Alternatively to your patch the current HEAD can be modified to call
> decode_variable again as in pre-physname era which resolves it correctly but
> for some reason you prefer to resolve pr11734::foo() via decode_compound
> instead which makes sense.

I have to withdraw my preliminary approval.  Together with
	[RFA] c++/12273
	http://sourceware.org/ml/gdb-patches/2010-12/msg00264.html

both patches duplicate the decode_variable functionality by the new
implementation in decode_compound.

But this duplication is still not complete, for example it does not handle
properly namespaces.  It had only a luck the existing namespace tests
(nsusing.exp) do not exploit it.

I have attached such testcase on top of your this patch:
	Re: [RFA] c++/11734 revisited
	http://sourceware.org/ml/gdb-patches/2010-12/msg00263.html

with results:
PASS: gdb.cp/pr11734.exp: break func
PASS: gdb.cp/pr11734.exp: break 'func'
^^^^ = test like nsusing.exp
FAIL: gdb.cp/pr11734.exp: break pr11734::foo() (got interactive prompt)
FAIL: gdb.cp/pr11734.exp: break 'pr11734::foo()' (got interactive prompt)
FAIL: gdb.cp/pr11734.exp: break pr11734::foo(char*) (got interactive prompt)
FAIL: gdb.cp/pr11734.exp: break 'pr11734::foo(char*)' (got interactive prompt)
FAIL: gdb.cp/pr11734.exp: break pr11734::foo(int) (got interactive prompt)
FAIL: gdb.cp/pr11734.exp: break 'pr11734::foo(int)' (got interactive prompt)
^^^^ = these funcs get called by the C++ inferior but GDB cannot resolve them.

decode_compound itself should comply to namespacing, just dropping to
decode_variable as before is not enough anyway as decode_variable cannot
resolve class fields which have no global symbols/minsym.

The new plan of G++ parser/plugin is probably not considerable now as a fix.

With the very hacky drop into decode_variable the testcase works but this
patch of mine is sure not usable.



Thanks,
Jan


--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -783,7 +783,7 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
 
   /* Does it look like there actually were two parts?  */
 
-  if (p[0] == ':' || p[0] == '.')
+if (0) //  if (p[0] == ':' || p[0] == '.')
     {
       /* Is it a C++ or Java compound data structure?
 	 The check on p[1] == ':' is capturing the case of "::",
@@ -868,7 +868,22 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
     }
   else
     {
-      p = skip_quoted (*argptr);
+      const char *lang_breakchars;
+      char *breakchars, *s, *end;
+
+      lang_breakchars = current_language->la_word_break_characters ();
+
+      breakchars = alloca (strlen (lang_breakchars) + 1);
+      strcpy (breakchars, lang_breakchars);
+      end = &breakchars[strlen (breakchars)];
+
+      s = strchr (breakchars, ':');
+      if (s != NULL)
+	{
+	  *s = *--end;
+	  *end = 0;
+	}
+      p = skip_quoted_chars (*argptr, NULL, breakchars);
     }
 
   /* Keep any template parameters.  */
--- a/gdb/testsuite/gdb.cp/pr11734-1.cc
+++ b/gdb/testsuite/gdb.cp/pr11734-1.cc
@@ -20,11 +20,21 @@
 
 #include "pr11734.h"
 
+namespace A { void func () {} }
+
+using namespace A;
+
 int
 main ()
 {
   pr11734 *p = new pr11734;
   p->foo ();
+
+  func ();
+
+  pr11734::foo ();
+  pr11734::foo ((char *) "");
+  pr11734::foo (0);
+
   return 0;
 }
-
--- a/gdb/testsuite/gdb.cp/pr11734-2.cc
+++ b/gdb/testsuite/gdb.cp/pr11734-2.cc
@@ -20,8 +20,11 @@
 
 #include "pr11734.h"
 
+namespace A {
+
 void
 pr11734::foo(void)
 {
 }
 
+}
--- a/gdb/testsuite/gdb.cp/pr11734-3.cc
+++ b/gdb/testsuite/gdb.cp/pr11734-3.cc
@@ -20,8 +20,11 @@
 
 #include "pr11734.h"
 
+namespace A {
+
 void
 pr11734::foo (int a)
 {
 }
 
+}
--- a/gdb/testsuite/gdb.cp/pr11734-4.cc
+++ b/gdb/testsuite/gdb.cp/pr11734-4.cc
@@ -20,8 +20,11 @@
 
 #include "pr11734.h"
 
+namespace A {
+
 void
 pr11734::foo (char *a)
 {
 }
 
+}
--- a/gdb/testsuite/gdb.cp/pr11734.exp
+++ b/gdb/testsuite/gdb.cp/pr11734.exp
@@ -34,6 +34,15 @@ if {![runto_main]} {
     continue
 }
 
+if [gdb_breakpoint "func"] {
+  pass "break func"
+}
+if [gdb_breakpoint "'func'"] {
+  pass "break 'func'"
+}
+
+gdb_test "ptype ${class}::l" "type = long"
+
 # An array holding the overload types for the method pr11734::foo.  The
 # first element is the overloaded method parameter.  The second element
 # is the expected source file number, e.g. "pr11734-?.cc".
--- a/gdb/testsuite/gdb.cp/pr11734.h
+++ b/gdb/testsuite/gdb.cp/pr11734.h
@@ -18,11 +18,15 @@
    Please email any bugs, comments, and/or additions to this file to:
    bug-gdb@gnu.org  */
 
+namespace A {
+
 class pr11734
 {
  public:
-  void foo ();
-  void foo (int);
-  void foo (char *);
+  static void foo ();
+  static void foo (int);
+  static void foo (char *);
+  long l;
 };
 
+}


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