<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 15, 2019, at 5:56 AM, Tom Weaver via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Dear LLDB dev community<br class=""><br class="">I'm currently working on an open source project called DExTer. DExTer is used to help validate and check the debugging experience a user might have when debugging a program. The LLVM community is interested in using DExTer as a means to run DebugInfo-Integration tests. A needed feature of DExTer is to be able to validate arbitrary type information during program execution.<br class=""><br class="">We're currently trying to implement support for correct type testing in DExTer. We'd like test writers to be able to validate arbitrary types exists at some point during program execution. We'd like to be able to validate the types of PODs, class types, template types amongst others.<br class=""><br class="">Dexter supports multiple debuggers, of which LLDB is one and as we're pushing for use with LLVM DebugInfo-Integration tests, I've been working on implementing this functionality with LLDB first.<br class=""><br class="">However, I can't find a way to validate the type of a template parameter. According to the "GDB to LLDB command map" article :<br class=""><br class=""> <a href="https://lldb.llvm.org/use/map.html" class="">https://lldb.llvm.org/use/map.html</a><br class=""><br class="">LLDB's equivalent to GDB's "ptype" feature is "image lookup --type <type>". When using GDB's ptype command it's possible to query the type of a template parameter, see example below:<br class=""><br class="">1 template<class T><br class="">2 T foo(const T & bar) {<br class="">3 return bar + bar;<br class="">4 }<br class="">5<br class="">6 int main() {<br class="">7 return foo<int>(5);<br class="">8 }<br class=""><br class="">I'd like to be able to break on line 3 in the above example and find out what the type of "T" is in the instantiated template function foo.<br class=""><br class="">With GDB's ptype function, I'm able to type "ptype T" and get back the type name "int". This doesn't seem to be possible with LLDBs "image lookup --type" command.<br class=""><br class="">With LLDB, breaking on line 3 and executing the following command "image lookup --type T" I get back an empty string. I can however, lookup the type "int" and get back a result.<br class=""><br class="">Similarly, when using the LLDB python API, I can't call "lldb.SBTarget.FindFirstType('T')" and get back anything other than an empty SBType object. Again, I can look up the type "int".<br class=""><br class="">So, I'd like to ask, is LLDB capable of validating template parameter types? <br class=""><br class="">If there isn't support for arbitrary type validating of template parameters in LLDB, then are there plans for future work to support it? We'd really like to have this functionality for our DebugInfo-Integration test suite.<br class=""></div></div></blockquote><div><br class=""></div>The better way to get this information in LLDB would be to get the type for the variable "bar" and then work from there.</div><div><br class=""></div><div>In python this would can easily be done with the python API:</div><div><br class=""></div><div>>>> var = frame.FindVariable('bar')<br class="">>>> print var<br class="">(const int &) bar = 0x00007ffeefbff768 (&bar = 5)<br class="">>>> var_type = var.GetType()<br class="">>>> print var_type<br class="">const int &<br class="">>>> var_type = var_type.GetDereferencedType()<br class="">>>> print var_type<br class="">const int<br class="">>>> var_type = var_type.GetUnqualifiedType()<br class="">>>> print var_type<br class="">int</div><div><br class=""></div><div>To do this all in one step you can do:</div><div>>>> var_type = var.GetType().GetDereferencedType().GetUnqualifiedType()<br class=""><div>>>> print var_type<br class="">int</div><div class=""><br class=""></div></div><div>Will this help? </div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><br class="">Kindest regards,<br class="">Tom Weaver.<br class=""></div>
_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br class=""></div></blockquote></div><br class=""></body></html>