summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2012-05-19 09:59:08 +0000
committerFilipe Cabecinhas <me@filcab.net>2012-05-19 09:59:08 +0000
commit721ba3ff77ed456f0c96640636c7ca9b2d2e58b6 (patch)
tree32a08ff9e40396ebada3dcf2c9dd1d914c1eeed6
parent6166178573651d6436a19184508d38c75ef83d38 (diff)
downloadbcm5719-llvm-721ba3ff77ed456f0c96640636c7ca9b2d2e58b6.tar.gz
bcm5719-llvm-721ba3ff77ed456f0c96640636c7ca9b2d2e58b6.zip
Fixes the case where we created a dummy target, deleted it, and then tried to evaluate an expression with no target.
llvm-svn: 157110
-rw-r--r--lldb/include/lldb/Target/Target.h7
-rw-r--r--lldb/source/API/SBTarget.cpp2
-rw-r--r--lldb/source/Host/common/Host.cpp30
-rw-r--r--lldb/source/Target/Target.cpp2
4 files changed, 27 insertions, 14 deletions
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 00aedfe2b3d..ab5205b3b59 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -414,6 +414,12 @@ public:
const lldb::ProcessSP &
GetProcessSP () const;
+ bool
+ IsValid()
+ {
+ return m_valid;
+ }
+
void
Destroy();
@@ -1156,6 +1162,7 @@ protected:
// 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;
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 1ec639763ba..d1275e6392b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -502,7 +502,7 @@ SBTarget::GetBroadcasterClassName ()
bool
SBTarget::IsValid () const
{
- return m_opaque_sp.get() != NULL;
+ return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
}
SBProcess
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 1e3cb0a14da..7fda1b7a772 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -1227,19 +1227,23 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
lldb::TargetSP
Host::GetDummyTarget (lldb_private::Debugger &debugger)
{
- lldb::TargetSP 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);
-
- return dummy_target_sp;
+ static TargetSP g_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 g_dummy_target_sp;
}
struct ShellInfo
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index a1caed4b9c5..5fe1f5e08e0 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -64,6 +64,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::Plat
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 @@ void
Target::Destroy()
{
Mutex::Locker locker (m_mutex);
+ m_valid = false;
DeleteCurrentProcess ();
m_platform_sp.reset();
m_arch.Clear();
OpenPOWER on IntegriCloud