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: [PATCH] locate members in multiple-inheritance hierarchy


On Sun, Feb 26, 2006 at 11:44:04PM +0100, Thomas Richter wrote:
> Hi folks,
> 
> sorry to say that gdb-6.4 has (just another) bug in locating class
> members in multiple-inheritance class hierarchies. The bug seems to
> be in lookup_struct_elt_type(), gdbtypes.c, lines 1234ff.
> 
> Specifically, this code *aborts* the scan by means of "noerr" when
> detecting a subclass that does not contain the member being searched
> for. However, it should instead continue to search subclasses.

The most useful thing you could include with future bug reports is a
description of how to reproduce the problem.  I was able to reverse
engineer one from the patch in this case.

>   for (i = TYPE_N_BASECLASSES (type) - 1; i1 >= 0; i--)
>     {
>       struct type *t = check_typedef (TYPE_BASECLASS (type, i)); 
>       /* FIX: THOR (25.2.2006):
>       ** must check for typedefs, must not error on first tried subclass.
>       */

The call to check_typedef is obviously unnecessary,
lookup_struct_elt_type will do it during the recursion.

I've checked in the attached, which also adds testcases for this and
another bug that I noticed (but do not have time to fix presently).

-- 
Daniel Jacobowitz
CodeSourcery

2006-03-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdbtypes.c (lookup_struct_elt_type): Correct noerr for recursive
	calls.

2006-03-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.cp/inherit.exp (test_print_mi_member_types): New function.
	(do_tests): Call it.

Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.104
diff -u -p -r1.104 gdbtypes.c
--- gdbtypes.c	1 Feb 2006 23:14:10 -0000	1.104
+++ gdbtypes.c	1 Mar 2006 18:51:41 -0000
@@ -1271,7 +1271,7 @@ lookup_struct_elt_type (struct type *typ
     {
       struct type *t;
 
-      t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr);
+      t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 1);
       if (t != NULL)
 	{
 	  return t;
Index: testsuite/gdb.cp/inherit.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/inherit.exp,v
retrieving revision 1.7
diff -u -p -r1.7 inherit.exp
--- testsuite/gdb.cp/inherit.exp	13 Aug 2004 10:24:52 -0000	1.7
+++ testsuite/gdb.cp/inherit.exp	1 Mar 2006 18:51:42 -0000
@@ -1,5 +1,5 @@
 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
-# 2004 Free Software Foundation, Inc.
+# 2004, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -373,6 +373,127 @@ proc test_print_mi_members {} {
     gdb_test "print g_E.E::x" "$vhn = 32"
 }
 
+# Multiple inheritance, print individual member types.
+
+proc test_print_mi_member_types {} {
+    global gdb_prompt
+    global nl
+    global vhn
+
+    # Print the types of some members of g_D without qualifying them.
+    gdb_test "ptype g_D.b" "type = int"
+    gdb_test "ptype g_D.c" "type = int"
+    gdb_test "ptype g_D.d" "type = int"
+
+    # Print the types of qualified members; none of these tests pass today.
+
+    # Print all members of g_A.
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_A.A::a" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_A.A::x" "type = int"
+
+    # Print all members of g_B.
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_B.A::a" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_B.A::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_B.B::b" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_B.B::x" "type = int"
+
+    # Print all members of g_C.
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_C.A::a" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_C.A::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_C.C::c" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_C.C::x" "type = int"
+
+    # Print all members of g_D.
+    #
+    # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb
+    # should detect these.  There are no ways to PASS these tests
+    # because I don't know what the gdb message will be.  -- chastain
+    # 2004-01-27.
+
+    set name "ptype g_D.A::a"
+    gdb_test_multiple "ptype g_D.A::a" $name {
+	-re "Attempt to take address of non-lval$nl$gdb_prompt $" {
+	    kfail "gdb/2092" "$name"
+	}
+	-re "type = int$nl$gdb_prompt $" {
+	    kfail "gdb/68" "ptype g_D.A::a"
+	}
+    }
+
+    set name "ptype g_D.A::x"
+    gdb_test_multiple "ptype g_D.A::x" $name {
+	-re "Attempt to take address of non-lval$nl$gdb_prompt $" {
+	    kfail "gdb/2092" "$name"
+	}
+	-re "type = int$nl$gdb_prompt $" {
+	    kfail "gdb/68" "ptype g_D.A::x"
+	}
+    }
+
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.B::b" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.B::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.C::c" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.C::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.D::d" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_D.D::x" "type = int"
+
+    # Print all members of g_E.
+    # g_E.A::a and g_E.A::x are ambiguous.
+
+    set name "ptype g_E.A::a"
+    gdb_test_multiple "ptype g_E.A::a" $name {
+	-re "Attempt to take address of non-lval$nl$gdb_prompt $" {
+	    kfail "gdb/2092" "$name"
+	}
+	-re "type = int$nl$gdb_prompt $" {
+	    kfail "gdb/68" "ptype g_E.A::a"
+	}
+    }
+
+    set name "ptype g_E.A::x"
+    gdb_test_multiple "ptype g_E.A::x" $name {
+	-re "Attempt to take address of non-lval$nl$gdb_prompt $" {
+	    kfail "gdb/2092" "$name"
+	}
+	-re "type = int$nl$gdb_prompt $" {
+	    kfail "gdb/68" "ptype g_E.A::x"
+	}
+    }
+
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.B::b" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.B::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.C::c" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.C::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.D::d" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.D::x" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.E::e" "type = int"
+    setup_kfail "gdb/2092" "*-*-*"
+    gdb_test "ptype g_E.E::x" "type = int"
+}
+
 # Multiple inheritance, print complete classes.
 
 proc test_print_mi_classes { } {
@@ -668,6 +789,7 @@ proc do_tests { } {
     test_print_si_members
     test_print_si_classes
     test_print_mi_members
+    test_print_mi_member_types
     test_print_mi_classes
     test_print_anon_union
 


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