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]

[PATCH] Fix dynamic_cast operator


For my debug methods patch, I have used value_cast instead of
value_dyamic_cast at a few places as the latter was spewing errors.
Digging a bit, I discovered that value_dynamic_cast has been broken
since it was added. The tests have been passing because, 1) some tests
had a strange expected result pattern and, 2) tests are not thorough
enough IMO.

The attached patch fixes the dynamic_cast operator and addresses the
shortcoming #1 of the tests.

Consider the following GDB session to understand #2:

(gdb) p dynamic_cast<B *>(ap)
$1 = (B *) 0x7fffffffdf00

The tests do not verify the hex addresses printed by the dynamic_cast
operator; they merely verify that a hex number is being printed. I
think the tests should verify the address printed (in some direct or
indirect manner). I feel this is important because the target
subobject could be present at different locations in/around the most
derived object based on the type of inheritance. I do not know of a
straight forward way to add this check, but I think it can addressed
in a different patch if required.

ChangeLog:
2014-04-07  Siva Chandra Reddy  <sivachandra@google.com>

        * valops.c (value_dynamic_cast): Fix mixup between rtti_type
        and resolved_type.

        testsuite/
        * gdb.cp/casts.exp: Adjust expected result for few tests.

Attachment: fix_dynamic_cast_v1.txt
Description: Text document


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