[lldb-dev] Support of a lookup of variables values with PDB

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Wed Jun 27 07:38:42 PDT 2018



> On Jun 27, 2018, at 5:25 AM, Aleksandr Urakov via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hello!
> 
> We want to add to LLDB a support of a lookup of variables values with PDB.
> 
> Now SymbolFilePDB::ParseVariableForPDBData function uses an empty location for variables, so e.g. `fr v` prints values as '<empty constant data>'. Symbol location information is available in a PDB (through PDBSymbolData::getLocationType and so on), but not in the format of DWARF expression. Do I understand correctly, that it is necessary to write some converter of a PDB symbol location to a DWARF expression bytecode? Is this the preferable way of solving the issue? What are pitfalls there? Please, share your thoughts on this.

DWARF expressions are pretty powerful and provide all the opcode need to describe variable locations. You will need to covert the PDB location to the DWARF expression opcodes.

Some examples:
variable is at SP + 4 = DW_OP_bregXXX(4)

DW_OP_bregXXX where XXX is the register number for your stack pointer. This opcode takes a single operand that is the offset from the register in question. The variable value is expected to be at the load address in memory.

variable is in register 12 = DW_OP_reg12

There are 32 DW_OP_regXXX opcodes DW_OP_reg0 - DW_OP_reg31. If your register value is higher than 32, then use DW_OP_regx which takes a ULEB128 parameter which is the register number:

variable is in register 46 = DW_OP_regx(46)

Global variables:

variable is at file address 0x12340000 = DW_OP_addr(0x12340000)

The address here is a file address, or the file VM address of the global as it is known in the object file. This address will be slid and covered to a load address if needed at runtime.

IF you have any other questions on converting your locations, let me know. But the above examples should give you a good start.

Greg

> 
> Regards,
> Aleksandr
> 
> -- 
> Aleksandr Urakov
> Software Developer
> JetBrains
> http://www.jetbrains.com <http://www.jetbrains.com/>
> The Drive to Develop
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://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/20180627/be299f3d/attachment.html>


More information about the lldb-dev mailing list