public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/10953] New: gdb.Type does not give access to Base classes
@ 2009-11-13 15:55 andre dot poenitz at nokia dot com
  2009-11-17 17:03 ` [Bug python/10953] " pmuldoon at redhat dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: andre dot poenitz at nokia dot com @ 2009-11-13 15:55 UTC (permalink / raw)
  To: gdb-prs

That's archer-tromey-python, at dad6b53fe4

The problem is that gdb.selected_frame().read_var("d").type.fields()  reports an
empty list. The list becomes non-empty as soon as the contents of derived.cpp is
moved to main.cpp.

------------------ Makefile ------------------
run:
        g++ -g base.cpp derived.cpp main.cpp -o yy
        ~/bin/gdb-archer -ex 'b main' -ex 'run' \
          -ex 'python print gdb.selected_frame().read_var("d").type.fields()' \
          ./yy


------------------ base.h ------------------
#ifndef BASE_H
struct Base
{
    virtual ~Base();
};
#endif


------------------ base.cpp ------------------
#include "base.h"

Base::~Base() {}


------------------ derived.h ------------------
#ifndef DERIVED_H

#include "base.h"

struct Derived : Base
{
    virtual ~Derived();
};
#endif


------------------ derived.cpp ------------------
#include "derived.h"

Derived::~Derived() {}


------------------ main.cpp ------------------

#include "derived.h"

int main()
{
    Derived d;
}
~

-- 
           Summary: gdb.Type does not give access to Base classes
           Product: gdb
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: andre dot poenitz at nokia dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
@ 2009-11-17 17:03 ` pmuldoon at redhat dot com
  2009-11-18  8:08 ` dodji at redhat dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pmuldoon at redhat dot com @ 2009-11-17 17:03 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pmuldoon at redhat dot com  2009-11-17 17:03 -------
If you add a call to strip_typedef() it will work:

python print
gdb.selected_frame().read_var("d").type.strip_typedefs().fields()[0].name
Base

I asked Dodji to help with this bug, and he should be updating the "why" this is
necessary in a far more eloquent way than I could ;)

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
  2009-11-17 17:03 ` [Bug python/10953] " pmuldoon at redhat dot com
@ 2009-11-18  8:08 ` dodji at redhat dot com
  2009-11-24 17:06 ` pmuldoon at redhat dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at redhat dot com @ 2009-11-18  8:08 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From dodji at redhat dot com  2009-11-18 08:08 -------
The short story is that the "Derived" type is considered "not complete" by GCC -
in the compilation unit main.cpp - so, no debug info is emitted for its
*definition*, in that compilation unit. The DIE describing "Derived" then has a
DW_AT_declaration set. So GDB has to go lookup the DIE of the *definitin* of
"Derived" in another compilation unit.

Now I guess the outstanding question is "why is Derived considered not complete?".
GCC implements a scheme to reduce debug info size. In that scheme, when a type
has as virtual table (like Derived, because it has a virtual destructor
declared), GCC only emits full debug info for said type _only_ if the virtual
table is emitted. In this case, as the virtual destructor of Derived is not
*defined* in main.cpp, no virtual table is emitted in that compilation unit. I
guess the virtual table for Derived will be emitted in another compilation unit
where the virtual destructor would be emitted.

To wrap things up in another way, no virtual destructor defined in current CU =>
no vtable emitted for Derived in current CU => no full debug info for Derived in
current CU => GDB has to fetch the full debug info for Derived in another CU.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
  2009-11-17 17:03 ` [Bug python/10953] " pmuldoon at redhat dot com
  2009-11-18  8:08 ` dodji at redhat dot com
@ 2009-11-24 17:06 ` pmuldoon at redhat dot com
  2009-11-24 17:27 ` pmuldoon at redhat dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pmuldoon at redhat dot com @ 2009-11-24 17:06 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|pmuldoon at redhat dot com
                   |org                         |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (2 preceding siblings ...)
  2009-11-24 17:06 ` pmuldoon at redhat dot com
@ 2009-11-24 17:27 ` pmuldoon at redhat dot com
  2010-05-26 13:54 ` andre dot poenitz at nokia dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pmuldoon at redhat dot com @ 2009-11-24 17:27 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From pmuldoon at redhat dot com  2009-11-24 17:27 -------
More a GCC quirk than anything else.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (3 preceding siblings ...)
  2009-11-24 17:27 ` pmuldoon at redhat dot com
@ 2010-05-26 13:54 ` andre dot poenitz at nokia dot com
  2010-05-26 14:24 ` andre dot poenitz at nokia dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-05-26 13:54 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From andre dot poenitz at nokia dot com  2010-05-26 13:54 -------
Would there be a way to detect this situation within gdb and possibly do
"something" to gain access to the "missing" information?

If so, maybe the "type" access in Python could trigger this automatically?


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (4 preceding siblings ...)
  2010-05-26 13:54 ` andre dot poenitz at nokia dot com
@ 2010-05-26 14:24 ` andre dot poenitz at nokia dot com
  2010-05-26 15:07 ` andre dot poenitz at nokia dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-05-26 14:24 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From andre dot poenitz at nokia dot com  2010-05-26 14:24 -------

This will get more even more "interesting" when gcc 4.5 hits the masses as a
'print b' in

void Derived::foo()
{
    Base *b = this;
    Base &br = *b;
}

yields  "$1 = (void *) 0xbfffee38", i.e. the type information for 'b' is
completely lost.



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (5 preceding siblings ...)
  2010-05-26 14:24 ` andre dot poenitz at nokia dot com
@ 2010-05-26 15:07 ` andre dot poenitz at nokia dot com
  2010-08-11 20:54 ` tromey at redhat dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-05-26 15:07 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From andre dot poenitz at nokia dot com  2010-05-26 15:07 -------

The second example seems to be unrelated, I opened
http://sourceware.org/bugzilla/show_bug.cgi?id=11639 for it.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (6 preceding siblings ...)
  2010-05-26 15:07 ` andre dot poenitz at nokia dot com
@ 2010-08-11 20:54 ` tromey at redhat dot com
  2010-08-11 21:14 ` pmuldoon at redhat dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at redhat dot com @ 2010-08-11 20:54 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-08-11 20:54 -------
I don't think this is invalid.

Instead I tend to think that the "fields" method should call check_typedef first.
This seems a lot more useful than the current behavior.
If there is a case where someone really needs to know that a type is incomplete,
we can add an attribute indicating that.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (7 preceding siblings ...)
  2010-08-11 20:54 ` tromey at redhat dot com
@ 2010-08-11 21:14 ` pmuldoon at redhat dot com
  2010-08-20 18:27 ` tromey at redhat dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pmuldoon at redhat dot com @ 2010-08-11 21:14 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|pmuldoon at redhat dot com  |unassigned at sourceware dot
                   |                            |org
             Status|REOPENED                    |NEW


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (8 preceding siblings ...)
  2010-08-11 21:14 ` pmuldoon at redhat dot com
@ 2010-08-20 18:27 ` tromey at redhat dot com
  2010-08-20 18:34 ` tromey at redhat dot com
  2010-08-23 20:31 ` tromey at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at redhat dot com @ 2010-08-20 18:27 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-08-20 18:27 -------
*** Bug 11777 has been marked as a duplicate of this bug. ***

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (9 preceding siblings ...)
  2010-08-20 18:27 ` tromey at redhat dot com
@ 2010-08-20 18:34 ` tromey at redhat dot com
  2010-08-23 20:31 ` tromey at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at redhat dot com @ 2010-08-20 18:34 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-08-20 18:34 -------
Testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|tromey at redhat dot com
                   |org                         |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-20 18:34:45
               date|                            |


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug python/10953] gdb.Type does not give access to Base classes
  2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
                   ` (10 preceding siblings ...)
  2010-08-20 18:34 ` tromey at redhat dot com
@ 2010-08-23 20:31 ` tromey at redhat dot com
  11 siblings, 0 replies; 13+ messages in thread
From: tromey at redhat dot com @ 2010-08-23 20:31 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2010-08-23 20:24 -------
Subject: Bug 10953

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-08-23 20:23:55

Modified files:
	gdb            : ChangeLog 
	gdb/python     : py-type.c 

Log message:
	PR python/10953:
	* python/py-type.c (typy_fields): Call check_typedef.
	(typy_template_argument): Add TRY_CATCH.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12106&r2=1.12107
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.12&r2=1.13


------- Additional Comments From tromey at redhat dot com  2010-08-23 20:31 -------
I checked in the fix.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|7.1                         |7.3


http://sourceware.org/bugzilla/show_bug.cgi?id=10953

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-08-23 20:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-13 15:55 [Bug python/10953] New: gdb.Type does not give access to Base classes andre dot poenitz at nokia dot com
2009-11-17 17:03 ` [Bug python/10953] " pmuldoon at redhat dot com
2009-11-18  8:08 ` dodji at redhat dot com
2009-11-24 17:06 ` pmuldoon at redhat dot com
2009-11-24 17:27 ` pmuldoon at redhat dot com
2010-05-26 13:54 ` andre dot poenitz at nokia dot com
2010-05-26 14:24 ` andre dot poenitz at nokia dot com
2010-05-26 15:07 ` andre dot poenitz at nokia dot com
2010-08-11 20:54 ` tromey at redhat dot com
2010-08-11 21:14 ` pmuldoon at redhat dot com
2010-08-20 18:27 ` tromey at redhat dot com
2010-08-20 18:34 ` tromey at redhat dot com
2010-08-23 20:31 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).