Type Validation and Dexter

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

LLDB’s equivalent to GDB’s “ptype” feature is "image lookup --type ". When using GDB’s ptype command it’s possible to query the type of a template parameter, see example below:

1 template
2 T foo(const T & bar) {
3 return bar + bar;
4 }
5
6 int main() {
7 return foo(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.

Kindest regards,
Tom Weaver.

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

LLDB’s equivalent to GDB’s “ptype” feature is "image lookup --type ". When using GDB’s ptype command it’s possible to query the type of a template parameter, see example below:

1 template
2 T foo(const T & bar) {
3 return bar + bar;
4 }
5
6 int main() {
7 return foo(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?