public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/14077] New: Dynamic type of references cannot be accessed
@ 2012-05-08 10:22 andre.poenitz at nokia dot com
  2012-05-08 17:02 ` [Bug python/14077] " andre.poenitz at nokia dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: andre.poenitz at nokia dot com @ 2012-05-08 10:22 UTC (permalink / raw)
  To: gdb-prs

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

             Bug #: 14077
           Summary: Dynamic type of references cannot be accessed
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: andre.poenitz@nokia.com
    Classification: Unclassified


echo "
struct A { virtual ~A() {} int a; };
struct B : A {};

int main()
{
    B b;
    A *b1 = &b;
    A &b2 = b;
    return b1->a + b2.a;
}
" | g++ -g -xc++ -

~/debugger/gdb-git-i586/gdb/gdb \
    -ex "set confirm off" \
    -ex "file ./a.out" \
    -ex "b 10" \
    -ex run \
    -ex "python print 'Pointer   static  type : %s' %
gdb.parse_and_eval('b1').type" \
    -ex "python print 'Pointer   dynamic type : %s' %
gdb.parse_and_eval('b1').dynamic_type" \
    -ex "python print 'Reference static  type : %s' %
gdb.parse_and_eval('b2').type" \
    -ex "python print 'Reference dynamic type : %s' %
gdb.parse_and_eval('b2').dynamic_type" 



yields:

    Pointer   static  type : A *
    Pointer   dynamic type : B *
    Reference static  type : A &
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    gdb.error: Attempt to take contents of a non-pointer value.
    Error while executing Python code.


It would be convenient to see   

    Reference dynamic type : B &

in the last line

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/14077] Dynamic type of references cannot be accessed
  2012-05-08 10:22 [Bug python/14077] New: Dynamic type of references cannot be accessed andre.poenitz at nokia dot com
@ 2012-05-08 17:02 ` andre.poenitz at nokia dot com
  2013-06-13 16:29 ` tromey at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: andre.poenitz at nokia dot com @ 2012-05-08 17:02 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Andre Poenitz <andre.poenitz at nokia dot com> 2012-05-08 17:01:31 UTC ---

The following seems to fix the issue for me:

diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 6f67bdb..bfb7260 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -310,7 +310,11 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
          struct value *target;
          int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR;

-         target = value_ind (val);
+         if (was_pointer)
+           target = value_ind (val);
+         else
+           target = coerce_ref (val);
+
          type = value_rtti_type (target, NULL, NULL, NULL);

          if (type)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug python/14077] Dynamic type of references cannot be accessed
  2012-05-08 10:22 [Bug python/14077] New: Dynamic type of references cannot be accessed andre.poenitz at nokia dot com
  2012-05-08 17:02 ` [Bug python/14077] " andre.poenitz at nokia dot com
@ 2013-06-13 16:29 ` tromey at redhat dot com
  2014-03-24 16:05 ` poenitz at htwm dot de
  2020-04-28 16:24 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2013-06-13 16:29 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #2 from Tom Tromey <tromey at redhat dot com> ---
Thread is here:
http://sourceware.org/ml/gdb-patches/2012-05/msg00394.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug python/14077] Dynamic type of references cannot be accessed
  2012-05-08 10:22 [Bug python/14077] New: Dynamic type of references cannot be accessed andre.poenitz at nokia dot com
  2012-05-08 17:02 ` [Bug python/14077] " andre.poenitz at nokia dot com
  2013-06-13 16:29 ` tromey at redhat dot com
@ 2014-03-24 16:05 ` poenitz at htwm dot de
  2020-04-28 16:24 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: poenitz at htwm dot de @ 2014-03-24 16:05 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14077

Andre' <poenitz at htwm dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |poenitz at htwm dot de

--- Comment #3 from Andre' <poenitz at htwm dot de> ---
There has been another patch on the list, see
https://sourceware.org/ml/gdb-patches/2014-03/msg00542.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug python/14077] Dynamic type of references cannot be accessed
  2012-05-08 10:22 [Bug python/14077] New: Dynamic type of references cannot be accessed andre.poenitz at nokia dot com
                   ` (2 preceding siblings ...)
  2014-03-24 16:05 ` poenitz at htwm dot de
@ 2020-04-28 16:24 ` ssbssa at sourceware dot org
  3 siblings, 0 replies; 5+ messages in thread
From: ssbssa at sourceware dot org @ 2020-04-28 16:24 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=14077

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |7.8
         Resolution|---                         |FIXED

--- Comment #4 from Hannes Domani <ssbssa at sourceware dot org> ---
Fixed since version 7.8, with this commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=7af389b892404edc76e1a60c59b354b785378fa5

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-04-28 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-08 10:22 [Bug python/14077] New: Dynamic type of references cannot be accessed andre.poenitz at nokia dot com
2012-05-08 17:02 ` [Bug python/14077] " andre.poenitz at nokia dot com
2013-06-13 16:29 ` tromey at redhat dot com
2014-03-24 16:05 ` poenitz at htwm dot de
2020-04-28 16:24 ` ssbssa at sourceware dot org

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).