[Lldb-commits] [lldb] r157110 - in /lldb/trunk: include/lldb/Target/Target.h source/API/SBTarget.cpp source/Host/common/Host.cpp source/Target/Target.cpp
Filipe Cabecinhas
me at filcab.net
Sat May 19 02:59:08 PDT 2012
Author: filcab
Date: Sat May 19 04:59:08 2012
New Revision: 157110
URL: http://llvm.org/viewvc/llvm-project?rev=157110&view=rev
Log:
Fixes the case where we created a dummy target, deleted it, and then tried to evaluate an expression with no target.
Modified:
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=157110&r1=157109&r2=157110&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Sat May 19 04:59:08 2012
@@ -414,6 +414,12 @@
const lldb::ProcessSP &
GetProcessSP () const;
+ bool
+ IsValid()
+ {
+ return m_valid;
+ }
+
void
Destroy();
@@ -1156,6 +1162,7 @@
// we can correctly tear down everything that we need to, so the only
// class that knows about the process lifespan is this target class.
lldb::ProcessSP m_process_sp;
+ bool m_valid;
lldb::SearchFilterSP m_search_filter_sp;
PathMappingList m_image_search_paths;
std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=157110&r1=157109&r2=157110&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Sat May 19 04:59:08 2012
@@ -502,7 +502,7 @@
bool
SBTarget::IsValid () const
{
- return m_opaque_sp.get() != NULL;
+ return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
}
SBProcess
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=157110&r1=157109&r2=157110&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Sat May 19 04:59:08 2012
@@ -1227,19 +1227,23 @@
lldb::TargetSP
Host::GetDummyTarget (lldb_private::Debugger &debugger)
{
- lldb::TargetSP dummy_target_sp;
+ static TargetSP g_dummy_target_sp;
- ArchSpec arch(Target::GetDefaultArchitecture());
- if (!arch.IsValid())
- arch = Host::GetArchitecture ();
- Error err = debugger.GetTargetList().CreateTarget(debugger,
- FileSpec(),
- arch.GetTriple().getTriple().c_str(),
- false,
- NULL,
- dummy_target_sp);
+ // FIXME: Maybe the dummy target should be per-Debugger
+ if (!g_dummy_target_sp || !g_dummy_target_sp->IsValid())
+ {
+ ArchSpec arch(Target::GetDefaultArchitecture());
+ if (!arch.IsValid())
+ arch = Host::GetArchitecture ();
+ Error err = debugger.GetTargetList().CreateTarget(debugger,
+ FileSpec(),
+ arch.GetTriple().getTriple().c_str(),
+ false,
+ NULL,
+ g_dummy_target_sp);
+ }
- return dummy_target_sp;
+ return g_dummy_target_sp;
}
struct ShellInfo
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=157110&r1=157109&r2=157110&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Sat May 19 04:59:08 2012
@@ -64,6 +64,7 @@
m_internal_breakpoint_list (true),
m_watchpoint_list (),
m_process_sp (),
+ m_valid (true),
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
m_scratch_ast_context_ap (NULL),
@@ -165,6 +166,7 @@
Target::Destroy()
{
Mutex::Locker locker (m_mutex);
+ m_valid = false;
DeleteCurrentProcess ();
m_platform_sp.reset();
m_arch.Clear();
More information about the lldb-commits
mailing list