[cfe-dev] Clang generates wrong RTTI or Debug info?

Roman Popov via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 25 21:03:44 PST 2018


Hello,

I'm using Clang++ together with GDB. I've noticed that for some polymorphic
classes GDB does not shows correct dynamic type.  After some investigation
it turned out that Clang puts different typenames in DWARF and RTTI :

I have a template class:

template< class T, sc_writer_policy POL>
class sc_signal : public sc_object

where sc_writer_policy is an enum:

enum sc_writer_policy
{
  SC_ONE_WRITER        = 0,
  SC_MANY_WRITERS      = 1,
  SC_UNCHECKED_WRITERS = 3
};


When I debug polymorphic objects of this class I got GDB errors like this:

warning: RTTI symbol not found for class 'sc_core::sc_signal<int,
(sc_core::sc_writer_policy)0>'


The source of the problem is that it type name seems to be saved
differently in RTTI and Debug info.

>From GDB:
(gdb) info types sc_signal<int
All types matching regular expression "sc_signal<int":

*sc_core::sc_signal<int, sc_core::SC_ONE_WRITER>*

Using RTTI:

cout << typeid(*obj).name();
N7sc_core9sc_signalIiLNS_16*sc_writer_policyE0*EEE

So in RTTI we have mangled sc_core::sc_signal<int,
(sc_core::sc_writer_policy)0>


Is it possible to make Clang emitting same type-name in both cases?


Originally I've discovered this issue with Clang++5.0.  Just tried with
Clang++6.0 and it is still there.
g++ 5.4 and g++7.0 both work fine, (sc_core::sc_signal<int,
(sc_core::sc_writer_policy)0> is generated in both cases)

Thanks,
Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180125/c97dd50e/attachment.html>


More information about the cfe-dev mailing list