[lldb-dev] Type Validation and Dexter

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Wed Jul 17 07:45:00 PDT 2019



> On Jul 15, 2019, at 5:56 AM, Tom Weaver via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Dear LLDB dev community
> 
> 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.
> 
> 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.
> 
> 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.
> 
> However, I can't find a way to validate the type of a template parameter. According to the "GDB to LLDB command map" article :
> 
>   https://lldb.llvm.org/use/map.html <https://lldb.llvm.org/use/map.html>
> 
> 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:
> 
> 1 template<class T>
> 2 T foo(const T & bar) {
> 3   return bar + bar;
> 4 }
> 5
> 6 int main() {
> 7   return foo<int>(5);
> 8 }
> 
> 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.
> 
> 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.
> 
> 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.
> 
> 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".
> 
> So, I'd like to ask, is LLDB capable of validating template parameter types? 
> 
> 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.

The better way to get this information in LLDB would be to get the type for the variable "bar" and then work from there.

In python this would can easily be done with the python API:

>>> var = frame.FindVariable('bar')
>>> print var
(const int &) bar = 0x00007ffeefbff768 (&bar = 5)
>>> var_type = var.GetType()
>>> print var_type
const int &
>>> var_type = var_type.GetDereferencedType()
>>> print var_type
const int
>>> var_type = var_type.GetUnqualifiedType()
>>> print var_type
int

To do this all in one step you can do:
>>> var_type = var.GetType().GetDereferencedType().GetUnqualifiedType()
>>> print var_type
int

Will this help? 
> 
> Kindest regards,
> Tom Weaver.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190717/f86acf1f/attachment.html>


More information about the lldb-dev mailing list