<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hello Enrico / All,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
I debugged it and it seems like a bug in my code.</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">To get the frame locals (function args and locals) I was using this call:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">frame.GetBlock().GetVariables()</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
While I should have simply call to frame.GetVariables()</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Which fixes the problem.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">However, I am facing another issue:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">It seems like the function "const char* SBValue::GetValue()" returns the pointer address as string instead of the actual content</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Any quick way to get the data as an actual c-str?</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">For example:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">int main(int argc, char** argv) {</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">return 0;</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">}</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
My lldb UI for the "locals" view looks like this (best viewed in monospace font ;)) :</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"> </div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
--------------------------------------------------------------------------------</div><div class="gmail_default" style="font-size:small"><font face="courier new, monospace">name | type | value</font></div>
<div class="gmail_default" style="font-size:small"><span style="font-family:verdana,sans-serif">--------------------------------------------------------------------------------</span><br></div><div class="gmail_default" style="font-size:small">
<font face="courier new, monospace">argc | int | 1</font></div><div class="gmail_default" style="font-size:small"><font face="courier new, monospace">argv | const char** | 0xfffffab123 (some random address)</font></div>
<div class="gmail_default" style="font-size:small"><font face="courier new, monospace"> | | | </font></div><div class="gmail_default" style="font-size:small"><font face="courier new, monospace"> +-*argv | const char* | </font><span style="font-family:'courier new',monospace">0xfffffab124 (some other address)</span></div>
<div class="gmail_default" style="font-size:small"><font face="courier new, monospace"> | | |</font></div><div class="gmail_default" style="font-size:small"><font face="courier new, monospace"> +- **argv| char | '/'</font></div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">In the code, I can identify that *argv is of type lldb::eBasicType*Char, however, I can't find a way to extract the string itself (it should be "/home/eran/test/TestLLDB")</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Any hints?</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks!</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default">
<font face="verdana, sans-serif"><br>
</font></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 7, 2014 at 5:31 AM, Eran Ifrah <span dir="ltr"><<a href="mailto:eran.ifrah@gmail.com" target="_blank">eran.ifrah@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks, will debug this and see where it fails</div>
<span class="HOEnZb"><font color="#888888"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Eran</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 7, 2014 at 1:43 AM, Enrico Granata <span dir="ltr"><<a href="mailto:egranata@apple.com" target="_blank">egranata@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Yeah the const char* definitely should have a value.</div><div>I am guessing the variable is in scope all right. Does it have a summary if you ask for that?</div>
<div>Does the same API call work if you stop directly within LLDB and use the Python API?</div><div>More context (e.g. a repro case) would also help - or maybe if you can step through the LLDB code and see where we fail. If these are just frame locals I expect the relevant code to be in ValueObject.cpp GetValueAsCString</div>
<div><div><br>Sent from the iPhone of<div><i>Enrico Granata</i> <egranata@🍎.com></div></div></div><div><div><div><br>On Apr 6, 2014, at 12:26 PM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com" target="_blank">eran.ifrah@gmail.com</a>> wrote:<br>
<br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">One of the local variables was 'const char*' so I would expect it to have a value and others were of type of 'wxString'</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">In the UI I expanded all the way to the _M_data which is of type 'wchar_t*' - and still nothing</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Eran</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sun, Apr 6, 2014 at 9:13 PM, Enrico Granata <span dir="ltr"><<a href="mailto:egranata@apple.com" target="_blank">egranata@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto"><div>What is the data type of your variables?</div><div><br></div><div>If they are aggregate types (structs, classes, ...) they won't have a value.</div><div><br></div><div>Only basic types (int, float, char, ..., you get the idea - and pointers) have a value.</div>
<div><br></div><div>For other types, they might have a summary, or they might have children, but definitely no value.</div><div><br>Sent from the iPhone of<div><i>Enrico Granata</i> <egranata@🍎.com></div></div><div>
<div><div><br>On Apr 6, 2014, at 7:02 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com" target="_blank">eran.ifrah@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Hello all,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
I am at a phase where I want to display the current frame local variables whenever the debugger "stops"</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I was able to get a list of the selected frame's variables in the following manner:</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default"><font face="courier new, monospace">lldb::SBFrame frame = m_target.GetProcess().GetSelectedThread().GetSelectedFrame();<br>
</font></div><div class="gmail_default"><font face="courier new, monospace">...</font></div><div class="gmail_default"><font face="courier new, monospace">lldb::SBValueList args = frame.GetBlock().GetVariables(m_target, true, true, false);<br>
</font></div><div><div class="gmail_default"><font face="courier new, monospace">for(size_t i=0; i<args.GetSize(); ++i) {</font></div><div class="gmail_default"><font face="courier new, monospace"> lldb::SBValue value = args.GetValueAtIndex(i);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> if ( value.IsValid() ) {</font></div><div class="gmail_default"><font face="courier new, monospace"> LLDBLocalVariable::Ptr_t var( new LLDBLocalVariable(value) );</font></div>
<div class="gmail_default"><font face="courier new, monospace"> locals.push_back( var );</font></div><div class="gmail_default"><font face="courier new, monospace"> }</font></div><div class="gmail_default">
<font face="courier new, monospace">}<span style="font-size:small"></span></font></div><br></div><div><div class="gmail_default" style="font-size:small"><font face="verdana, sans-serif">Now, LLDBLocalVariable is a thin wrapper class for UI purposes.</font></div>
<div class="gmail_default" style="font-size:small"><font face="verdana, sans-serif">What it does is basically copies values from lldb::SBValue:</font></div><div class="gmail_default" style="font-size:small"><font face="verdana, sans-serif"><br>
</font></div><div class="gmail_default" style="font-size:small"><font face="courier new, monospace">LLDBLocalVariable::LLDBLocalVariable(lldb::SBValue value) {<br></font></div><div class="gmail_default"><div class="gmail_default">
<font face="courier new, monospace"> SetName( value.GetName() );</font></div><div class="gmail_default"><font face="courier new, monospace"> SetType( value.GetTypeName() );</font></div><div class="gmail_default"><font face="courier new, monospace"> SetValue( value.GetValue() ); // always returns null</font></div>
<div class="gmail_default"><font face="courier new, monospace"> ... // code that handles children of value</font></div><div class="gmail_default"><font face="courier new, monospace">}</font></div><div class="gmail_default" style="font-family:verdana,sans-serif">
<br></div></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">value.GetName() and value.GetTypeName() are working as expected (i.e. I get the correct type name and its name)</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
However, I can't get the value as "string". I was naive enough to think that const char* SBValue::GetValue() will do the trick... but this always returns NULL.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Any suggestions on what am I doing wrong? an example on how to extract the variable's value in string format will be really appreciated</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">P.S.</div></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">This is Linux 13.10 / 64 bit</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Self compiled lldb</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div>-- <br><div dir="ltr">
Eran Ifrah<br>
Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br><div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org" target="_blank">wxcrafter.codelite.org</a></div>
</div>
</div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>lldb-dev mailing list</span><br><span><a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a></span><br>
<span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a></span><br></div></blockquote></div></blockquote></div><br><br clear="all"><div><br>
</div>-- <br><div dir="ltr">Eran Ifrah<br>Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br><div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org" target="_blank">wxcrafter.codelite.org</a></div>
</div>
</div>
</div></blockquote></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Eran Ifrah<br>Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br>
<div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org" target="_blank">wxcrafter.codelite.org</a></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Eran Ifrah<br>Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org" target="_blank">http://www.codelite.org</a><br>
<div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org" target="_blank">wxcrafter.codelite.org</a></div></div>
</div>