<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks for the clarification!</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><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 12, 2014 at 2:00 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Clear just releases the shared pointer to the target that you have. So in your IDE, when you are done with a target, you can call clear to ensure that your IDE isn't the only thing holding onto the target and keeping it and all shared libraries in memory:<br>
<br>
void<br>
SBTarget::Clear ()<br>
{<br>
m_opaque_sp.reset();<br>
}<br>
<br>
Delete target will call "Target::Destroy()" which will kill the process if it is still around, and also clear the target's image list, then it will remove any shared libraries from the global shared library cache in LLDB that were only referenced by the target you were destroying:<br>
<br>
bool<br>
SBDebugger::DeleteTarget (lldb::SBTarget &target)<br>
{<br>
bool result = false;<br>
if (m_opaque_sp)<br>
{<br>
TargetSP target_sp(target.GetSP());<br>
if (target_sp)<br>
{<br>
// No need to lock, the target list is thread safe<br>
result = m_opaque_sp->GetTargetList().DeleteTarget (target_sp);<br>
target_sp->Destroy();<br>
target.Clear();<br>
const bool mandatory = true;<br>
ModuleList::RemoveOrphanSharedModules(mandatory);<br>
}<br>
}<br>
...<br>
<br>
<br>
<br>
So this is a great way for an IDE, which might have one or more debug windows open, to reclaim the memory that was solely associated with a given target.<br>
<br>
LLDB permanently caches the shared libraries that it loads in a global cache so the next time you debug, we have all those shared libraries instantly loaded and ready for you to use. This can greatly increase your restart performance, so don't call SBDebugger::DeleteTarget() if you are going to immediately debug again using the same target. Try and keep the existing target around for all of your runs of that process so the module cache works in your favor.<br>
<div><div class="h5"><br>
<br>
On Apr 11, 2014, at 3:22 PM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
<br>
> Sorry, meant the difference between:<br>
><br>
> target.Clear() and debugger.DeleteTarget( &target );<br>
><br>
> Thanks<br>
><br>
><br>
> On Sat, Apr 12, 2014 at 1:20 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I could not find it in the docs, so I am asking here:<br>
><br>
> Assuming that I have an instance of type SBTarget:<br>
><br>
> SBTraget target;<br>
><br>
> Whats the difference between calling:<br>
><br>
> target.Clear()<br>
><br>
> and<br>
><br>
> lldb::SBDebugger::Destroy( &target ) ?<br>
><br>
> Thanks,<br>
><br>
> --<br>
> 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>
> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org" target="_blank">http://wxcrafter.codelite.org</a><br>
><br>
><br>
><br>
> --<br>
> 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>
> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org" target="_blank">http://wxcrafter.codelite.org</a><br>
</div></div>> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</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>