<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Roman,<div class=""><br class=""></div><div class="">Thanks for verifying. I am trying to see how far this goes.</div><div class=""><br class=""></div><div class="">It would be interesting to look at the GCC DWARF for this. If you can attach a copy of the binary, I would like to take a look to see if the DWARF itself has any offending type info where it sometimes has the 'u' and other times doesn't. We know and understand that clang does this, but we don't know if GCC does this as well and it would be good to know.<div class=""><br class=""></div><div class="">Greg</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 10, 2017, at 12:24 PM, Roman Popov <<a href="mailto:ripopov@gmail.com" class="">ripopov@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Yes, you're right. When I replaced unsigned with signed int it works properly.<div class="gmail_extra"><br class=""><div class="gmail_quote">2017-02-10 19:46 GMT+03:00 Greg Clayton <span dir="ltr" class=""><<a href="mailto:gclayton@apple.com" target="_blank" class="">gclayton@apple.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Feb 10, 2017, at 12:55 AM, Roman Popov <<a href="mailto:ripopov@gmail.com" target="_blank" class="">ripopov@gmail.com</a>> wrote:</div><br class="m_-4770005415838583099Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks Greg,<div class=""><br class=""></div><div class="">So here is another case when LLDB fails to resolve dynamic type.  Compiled with G++5.4 on Ubuntu 16.04.</div><div class=""><br class=""></div><div class="">Here I want to get dynamic type for some variable apb_memories</div><div class=""><br class=""></div><div class=""><div class="">(lldb) expr -d no-run -- apb_memories<br class=""></div><div class="">(sc_core::sc_object *) $3 = 0x0000000000cb6aa8</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">(lldb) memory read --format address apb_memories</div><div class="">0x00cb6aa8: 0x00000000004e33f8 test_design`vtable for demo::apb_memory<sc_dt::sc_uin<wbr class="">t<32>, sc_dt::sc_uint<32>, 1024u> + 24</div><div class="">...</div><div class=""><br class=""></div><div class="">(lldb) image lookup -t "demo::apb_memory<sc_dt::sc_ui<wbr class="">nt<32>, sc_dt::sc_uint<32>, 1024u>"<br class=""></div><div class=""><br class=""></div><div class="">(lldb) image lookup -t "apb_memory<sc_dt::sc_uint<32><wbr class="">, sc_dt::sc_uint<32>, 1024u>"</div><div class="">Best match found in ...</div><div class="">id = {0x0002cc4b}, name = "apb_memory<sc_dt::sc_uint<32><wbr class="">, sc_dt::sc_uint<32>, 1024u>", qualified = "demo::apb_memory<sc_dt::sc_ui<wbr class="">nt<32>, sc_dt::sc_uint<32>, 1024>", byte-size = 27384, decl = apb_memory.h:15, compiler_type = "class apb_memory : public sc_core::sc_module, public demo::clk_rstn_sif, public demo::apb_if<sc_dt::sc_uint<32<wbr class="">>, sc_dt::sc_uint<32> > {</div><div class="">..}"<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div></span>If you look at the "qualified" name in the type info you dumped, we see a 'u' mismatch on the last 1024:</div><span class=""><div class=""><br class=""></div><div class="">qualified = "demo::apb_memory<sc_dt::sc_<wbr class="">uint<32>, sc_dt::sc_uint<32>, 1024>"</div><div class=""><br class=""></div></span><div class="">Note the missing 'u'. In the case of GCC and everything linux, we manually create the accelerator tables by indexing the DWARF manually. I am guessing that since the "qualified" name is wrong, this is what is keeping us from finding it. So this is the same problem, though this one is an LLDB bug if the qualified name is dropping the 'u'. We are presumably using the same code path that clang uses (which is causing this bug) to generate the qualified name.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Greg</div></font></span><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Looks like in that case the problem is with namespace specifier. G++ did not put it into debug info.</div><div class=""><br class=""></div><div class="">I hope it will be fixed soon, at least for Clang+LLDB combo. Probably you need to write a unit-test that will check typeinfo against debug info for various scenarios. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-02-09 4:04 GMT+03:00 Greg Clayton <span dir="ltr" class=""><<a href="mailto:gclayton@apple.com" target="_blank" class="">gclayton@apple.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_-4770005415838583099m_-5178498351258891521gmail-"><br class="">
> On Feb 6, 2017, at 5:58 PM, Roman Popov <<a href="mailto:ripopov@gmail.com" target="_blank" class="">ripopov@gmail.com</a>> wrote:<br class="">
><br class="">
> Hello,<br class="">
> I just found out that sometimes I don't get correct dynamic type in LLDB even if I compile with g++.  How can I get typeinfo/vtable dump from LLDB to check if it is still the same name matching issue?<br class="">
<br class="">
<br class="">
</span>Stop where dynamic typing fails, and take the pointer that is failing to be properly typed and do:<br class="">
<br class="">
(lldb) memory read --format address my_ptr<br class="">
<br class="">
Then look at the first entry that is in the output and it should be "vtable for " and take all the characters that follow this and are before the " + XXX" and check to see if LLDB knows about this type.<br class="">
<br class="">
If we use your previous source:<br class="">
<span class="m_-4770005415838583099m_-5178498351258891521gmail-"><br class="">
#include <iostream><br class="">
#include <typeinfo><br class="">
<br class="">
using namespace std;<br class="">
<br class="">
struct base_type {  virtual ~base_type(){} };<br class="">
<br class="">
template <class T1, class T2, unsigned SIZE><br class="">
struct derived0 : base_type {};<br class="">
<br class="">
template <class T1, class T2><br class="">
struct derived1 : base_type {};<br class="">
<br class="">
int main(int argc, char ** argv) {<br class="">
<br class="">
    base_type * bptr0 = new derived0<int, int, 1024>();<br class="">
    base_type * bptr1 = new derived1<int, int >();<br class="">
<br class="">
    cout << typeid(*bptr0).name() << endl;<br class="">
    cout << typeid(*bptr1).name() << endl;<br class="">
<br class="">
    return 0;<br class="">
}<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
</span>If we compile this into "a.out":<br class="">
<br class="">
% lldb a.out<br class="">
(lldb) b /return 0/<br class="">
(lldb) r<br class="">
(lldb) memory read --format address bptr0<br class="">
0x1001002f0: 0x0000000100002120 vtable for derived0<int, int, 1024u> + 16<br class="">
....<br class="">
<br class="">
We now take all text past the "vtable for " and before the " + 16" and lookup the type by name:<br class="">
<br class="">
(lldb) image lookup -t "derived0<int, int, 1024u>"<br class="">
<br class="">
Note this doesn't work, but if we remove the 'u' from 1024 it does work:<br class="">
<br class="">
(lldb) image lookup -t "derived0<int, int, 1024>"<br class="">
Best match found in /tmp/a.out:<br class="">
id = {0x000065da}, name = "derived0<int, int, 1024>", byte-size = 8, decl = main.cpp:9, compiler_type = "class derived0 : public base_type {<br class="">
}"<br class="">
<br class="">
<br class="">
<br class="">
</blockquote></div><br class=""></div></div></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></body></html>