We shouldn't save g_dummy_target_sp. Other code will simply call Destroy() on it.
authorFilipe Cabecinhas <me@filcab.net>
Thu, 17 May 2012 15:48:02 +0000 (15:48 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Thu, 17 May 2012 15:48:02 +0000 (15:48 +0000)
TestBackticksWithoutATarget.BackticksWithNoTargetTestCase was calling
GetDummyTarget() when executing for x86_64. When performing session
tearDown, it would get destroyed (and everything would be invalid (arch,
etc).

Then the test would run for i386. The dummy target wasn't being
reinitialized and was invalid. lldb complained that 'current process state
is unsuitable for expression parsing'.

llvm-svn: 156994

lldb/source/Host/common/Host.cpp

index 62a0b9e..1e3cb0a 100644 (file)
@@ -1227,22 +1227,19 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
 lldb::TargetSP
 Host::GetDummyTarget (lldb_private::Debugger &debugger)
 {
-    static TargetSP g_dummy_target_sp;
-    
-    if (!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, 
-                                                          g_dummy_target_sp);
-    }
-    
-    return g_dummy_target_sp;
+    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;
 }
 
 struct ShellInfo