[lldb-dev] Getting the address of a variable
Bogdan Hopulele via lldb-dev
lldb-dev at lists.llvm.org
Wed Jun 29 09:51:31 PDT 2016
Hi all,
Given a file name, line number and variable name, I am trying to determine the address. I tried the following approach:
* First I got the block corresponding to the file and line:
o from the file name I got a SBCompileUnit
o using the SBCompileUnit and line number I got a SBLineEntry
? for FindLineEntryIndex the "exact" parameter needs to be false else it will return empty if the line is on a function
o get the SBBlock: lineEntry.GetStartAddress().GetBlock()
* Now I got the variables for that block and search by name
o block.GetVariables(target, True, True, True)
o I still need to figure out if on the given line there is a function static and a function argument since both will show up in the list
o Search for the variable by name and get its address - there is no address :(
The problem is that for line 3 in the code below, my SBValue object in the list doesn't have an address, just "<Invalid stack frame in context for DW_OP_fbreg opcode.>". Any ideas how to solve this?
Also, how can I set the context for evaluating an expression to a file and line number? (on line 8, evaluate "v" to 1)
1 void foo()
2 {
3 int v = 1;
4 {
5 int v = 2;
--> 6 ++v;
7 }
8 v += 5;
9 }
Thanks,
Bogdan
National Instruments Romania S.R.L.
------------------------------------------------------
B-dul 21 Decembrie 1989, nr. 77, A2
Cluj-Napoca 400604, Romania
C.I.F.: RO17961616 | O.R.C.: J12/3337/2005
Telefon: +40 264 406428 | Fax: +40 264 406429
E-mail: office.cluj at ni.com
Web: romania.ni.com
Vanzari si suport tehnic:
Telefon gratuit : 0800 070071
E-mail vanzari: ni.romania at ni.com
E-mail suport tehnic: techsupport at ni.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160629/28584ea1/attachment.html>
More information about the lldb-dev
mailing list