Added the ability to remove orphaned module shared pointers from a ModuleList.
This is helping us track down some extra references to ModuleSP objects that
are causing things to get kept around for too long.
Added a module pointer accessor to target and change a lot of code to use
it where it would be more efficient.
"taret delete" can now specify "--clean=1" which will cleanup the global module
list for any orphaned module in the shared module cache which can save memory
and also help track down module reference leaks like we have now.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137294 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 8ccdebb..2c22880 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -162,7 +162,7 @@
// If our listener is NULL, users aren't allows to launch
char filename[PATH_MAX];
- const Module *exe_module = target->GetExecutableModule().get();
+ const Module *exe_module = target->GetExecutableModulePointer();
if (exe_module == NULL)
{
@@ -762,22 +762,22 @@
{
// Okay, we're done. Last step is to warn if the executable module has changed:
char new_path[PATH_MAX];
+ ModuleSP new_exec_module_sp (target->GetExecutableModule());
if (!old_exec_module_sp)
{
// We might not have a module if we attached to a raw pid...
- ModuleSP new_module_sp (target->GetExecutableModule());
- if (new_module_sp)
+ if (new_exec_module_sp)
{
- new_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
+ new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
}
}
- else if (old_exec_module_sp->GetFileSpec() != target->GetExecutableModule()->GetFileSpec())
+ else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
{
char old_path[PATH_MAX];
- old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX);
- target->GetExecutableModule()->GetFileSpec().GetPath (new_path, PATH_MAX);
+ old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
+ new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
old_path, new_path);