PTYPE replacement in LLDB

Hi All,

I see in the command Mapping Documnet, we can use “image lookup -type” in place of “ptype” from gdb. Currently, this can be used only for Type(link int, char) , or gloal, static variable or function symbol.

This is not as efficient as GDB, where it will whole structure if we point to variable.
Here we have to find the variable type first and then we have to do “image lookup”.

do we have a single command which will do that ?
If not, shall we implement one or integrating with one of existing command is good ?

thanks,
vigneshbalu

Hi All,

I see in the command Mapping Documnet, we can use "image lookup -type" in place of "ptype" from gdb. Currently, this can be used only for Type(link int, char) , or gloal, static variable or function symbol.

Another option is:

(lldb) type lookup

This is not as efficient as GDB, where it will whole structure if we point to variable.
Here we have to find the variable type first and then we have to do "image lookup".

do we have a single command which will do that ?

Not at the moment.

If not, shall we implement one or integrating with one of existing command is good ?

The question is where does it belong? We could add it in one of two places as far as I see:

(lldb) frame variable --type my_var [my_var2]

The "--type" option (no arguments for the option) would indicate we want to dump the types of any variable names listed as arguments to the command.

(lldb) type lookup --variable my_var --variable my_var2

where "--variable <VARNAME>" means to look at the type of a variable.

I think both would be useful as they would be easy to add.

Please let me know if anyone has any other ideas.

BTW: it would be easy to add this as a python command for now until we get this into lldb. If you want to know more about the lldb commands, let me know.

Greg Clayton.

Hi All,

I see in the command Mapping Documnet, we can use "image lookup -type" in place of "ptype" from gdb. Currently, this can be used only for Type(link int, char) , or gloal, static variable or function symbol.

Another option is:

(lldb) type lookup

This is not as efficient as GDB, where it will whole structure if we point to variable.
Here we have to find the variable type first and then we have to do "image lookup".

do we have a single command which will do that ?

Not at the moment.

If not, shall we implement one or integrating with one of existing command is good ?

The question is where does it belong? We could add it in one of two places as far as I see:

(lldb) frame variable --type my_var [my_var2]

The "--type" option (no arguments for the option) would indicate we want to dump the types of any variable names listed as arguments to the command.

(lldb) type lookup --variable my_var --variable my_var2

where "--variable <VARNAME>" means to look at the type of a variable.

I think both would be useful as they would be easy to add.

Please let me know if anyone has any other ideas.

BTW: it would be easy to add this as a python command for now until we get this into lldb.

The original plan was to add a "type eval" to go alongside "type lookup". "type eval" would take an expression, evaluate it, and then print the resulting type. gdb's type takes either a type name or an expression, but there's no way to disambiguate if you have a type that has the same name as a local variable, so I'm more inclined to make them separate commands or use options.

Note, gdb also has "whatis" which doesn't do any evaluation, just looks up the argument asa name. That is pretty much the --variable option that Greg suggests. That could be done either by having "type eval" first try local vars and then evaluate the expression or by having an explicit "--vars" flag.

Jim