zturner updated this revision to Diff 48414.
zturner added a comment.
This should make sure it happens if and only if the directory was successfully
created earlier during program execution.
http://reviews.llvm.org/D17420
Files:
include/lldb/Host/HostInfoBase.h
source/Host/common/HostInfoBase.cpp
source/Initialization/SystemInitializerCommon.cpp
Index: source/Initialization/SystemInitializerCommon.cpp
===================================================================
--- source/Initialization/SystemInitializerCommon.cpp
+++ source/Initialization/SystemInitializerCommon.cpp
@@ -197,6 +197,7 @@
#endif
OperatingSystemGo::Terminate();
+ HostInfoBase::Terminate();
Log::Terminate();
#if defined(_MSC_VER)
Index: source/Host/common/HostInfoBase.cpp
===================================================================
--- source/Host/common/HostInfoBase.cpp
+++ source/Host/common/HostInfoBase.cpp
@@ -31,19 +31,6 @@
namespace
{
- void
- CleanupProcessSpecificLLDBTempDir()
- {
- // Get the process specific LLDB temporary directory and delete it.
- FileSpec tmpdir_file_spec;
- if (!HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir,
tmpdir_file_spec))
- return;
-
- // Remove the LLDB temporary directory if we have one. Set "recurse" to
- // true to all files that were created for the LLDB process can be
cleaned up.
- FileSystem::DeleteDirectory(tmpdir_file_spec, true);
- }
-
//----------------------------------------------------------------------
// The HostInfoBaseFields is a work around for windows not supporting
// static variables correctly in a thread safe way. Really each of the
@@ -74,6 +61,17 @@
};
HostInfoBaseFields *g_fields = nullptr;
+
+ void
+ CleanupProcessSpecificLLDBTempDir()
+ {
+ if (g_fields && g_fields->m_lldb_process_tmp_dir.Exists())
+ {
+ // Remove the LLDB temporary directory if we have one. Set
"recurse" to
+ // true to all files that were created for the LLDB process can be
cleaned up.
+ FileSystem::DeleteDirectory(g_fields->m_lldb_process_tmp_dir,
true);
+ }
+ }
}
void
@@ -82,6 +80,14 @@
g_fields = new HostInfoBaseFields();
}
+void
+HostInfoBase::Terminate()
+{
+ CleanupProcessSpecificLLDBTempDir();
+ delete g_fields;
+ g_fields = nullptr;
+}
+
uint32_t
HostInfoBase::GetNumberCPUS()
{
@@ -335,9 +341,6 @@
if (!FileSystem::MakeDirectory(temp_file_spec,
eFilePermissionsDirectoryDefault).Success())
return false;
- // Make an atexit handler to clean up the process specify LLDB temp dir
- // and all of its contents.
- ::atexit(CleanupProcessSpecificLLDBTempDir);
file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
return true;
}
Index: include/lldb/Host/HostInfoBase.h
===================================================================
--- include/lldb/Host/HostInfoBase.h
+++ include/lldb/Host/HostInfoBase.h
@@ -34,6 +34,8 @@
public:
static void Initialize();
+ static void
+ Terminate();
//------------------------------------------------------------------
/// Returns the number of CPUs on this current host.
Index: source/Initialization/SystemInitializerCommon.cpp
===================================================================
--- source/Initialization/SystemInitializerCommon.cpp
+++ source/Initialization/SystemInitializerCommon.cpp
@@ -197,6 +197,7 @@
#endif
OperatingSystemGo::Terminate();
+ HostInfoBase::Terminate();
Log::Terminate();
#if defined(_MSC_VER)
Index: source/Host/common/HostInfoBase.cpp
===================================================================
--- source/Host/common/HostInfoBase.cpp
+++ source/Host/common/HostInfoBase.cpp
@@ -31,19 +31,6 @@
namespace
{
- void
- CleanupProcessSpecificLLDBTempDir()
- {
- // Get the process specific LLDB temporary directory and delete it.
- FileSpec tmpdir_file_spec;
- if (!HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
- return;
-
- // Remove the LLDB temporary directory if we have one. Set "recurse" to
- // true to all files that were created for the LLDB process can be cleaned up.
- FileSystem::DeleteDirectory(tmpdir_file_spec, true);
- }
-
//----------------------------------------------------------------------
// The HostInfoBaseFields is a work around for windows not supporting
// static variables correctly in a thread safe way. Really each of the
@@ -74,6 +61,17 @@
};
HostInfoBaseFields *g_fields = nullptr;
+
+ void
+ CleanupProcessSpecificLLDBTempDir()
+ {
+ if (g_fields && g_fields->m_lldb_process_tmp_dir.Exists())
+ {
+ // Remove the LLDB temporary directory if we have one. Set "recurse" to
+ // true to all files that were created for the LLDB process can be cleaned up.
+ FileSystem::DeleteDirectory(g_fields->m_lldb_process_tmp_dir, true);
+ }
+ }
}
void
@@ -82,6 +80,14 @@
g_fields = new HostInfoBaseFields();
}
+void
+HostInfoBase::Terminate()
+{
+ CleanupProcessSpecificLLDBTempDir();
+ delete g_fields;
+ g_fields = nullptr;
+}
+
uint32_t
HostInfoBase::GetNumberCPUS()
{
@@ -335,9 +341,6 @@
if (!FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault).Success())
return false;
- // Make an atexit handler to clean up the process specify LLDB temp dir
- // and all of its contents.
- ::atexit(CleanupProcessSpecificLLDBTempDir);
file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
return true;
}
Index: include/lldb/Host/HostInfoBase.h
===================================================================
--- include/lldb/Host/HostInfoBase.h
+++ include/lldb/Host/HostInfoBase.h
@@ -34,6 +34,8 @@
public:
static void Initialize();
+ static void
+ Terminate();
//------------------------------------------------------------------
/// Returns the number of CPUs on this current host.
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits