Author: gclayton
Date: Tue Nov 5 17:28:00 2013
New Revision: 194106
URL: http://llvm.org/viewvc/llvm-project?rev=194106&view=rev
Log:
<rdar://problem/15367122>
Fixed the test case for "test/functionalities/exec/TestExec.py" on Darwin.
The issue was breakpoints were persisting and causing problems. When we exec,
we need to clear out the process and target and start fresh with nothing and
let the breakpoints populate themselves again. This patch correctly clears out
the breakpoints and also flushes the process so that the objects
(process/thread/frame) give out valid information.
Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Breakpoint/BreakpointList.cpp
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/test/functionalities/exec/TestExec.py
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Tue Nov 5 17:28:00 2013
@@ -149,11 +149,17 @@ public:
/// @param[in] module_list
/// The module list that has changed.
///
- /// @param[in] added
+ /// @param[in] load
/// \b true if the modules are loaded, \b false if unloaded.
+ ///
+ /// @param[in] delete_locations
+ /// If \a load is \b false, then delete breakpoint locations when
+ /// when updating breakpoints.
//------------------------------------------------------------------
void
- UpdateBreakpoints (ModuleList &module_list, bool added);
+ UpdateBreakpoints (ModuleList &module_list,
+ bool load,
+ bool delete_locations);
void
UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp,
lldb::ModuleSP new_module_sp);
Modified: lldb/trunk/include/lldb/Target/Target.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Nov 5 17:28:00 2013
@@ -735,11 +735,14 @@ public:
ModulesDidLoad (ModuleList &module_list);
void
- ModulesDidUnload (ModuleList &module_list);
+ ModulesDidUnload (ModuleList &module_list, bool delete_locations);
void
SymbolsDidLoad (ModuleList &module_list);
+ void
+ ClearModules();
+
//------------------------------------------------------------------
/// Gets the module for the main executable.
///
Modified: lldb/trunk/source/Breakpoint/BreakpointList.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointList.cpp?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointList.cpp Tue Nov 5 17:28:00 2013
@@ -204,13 +204,13 @@ BreakpointList::GetBreakpointAtIndex (si
}
void
-BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added)
+BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool
delete_locations)
{
Mutex::Locker locker(m_mutex);
bp_collection::iterator end = m_breakpoints.end();
bp_collection::iterator pos;
for (pos = m_breakpoints.begin(); pos != end; ++pos)
- (*pos)->ModulesChanged (module_list, added);
+ (*pos)->ModulesChanged (module_list, added, delete_locations);
}
Modified:
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
---
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
(original)
+++
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
Tue Nov 5 17:28:00 2013
@@ -1335,7 +1335,7 @@ DynamicLoaderDarwinKernel::ParseKextSumm
// the to_be_removed bool vector; leaving it in place once
Cleared() is relatively harmless.
}
}
- m_process->GetTarget().ModulesDidUnload (unloaded_module_list);
+ m_process->GetTarget().ModulesDidUnload (unloaded_module_list,
false);
}
}
Modified:
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
---
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
(original)
+++
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
Tue Nov 5 17:28:00 2013
@@ -370,7 +370,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
}
}
loaded_modules.Remove(old_modules);
- m_process->GetTarget().ModulesDidUnload(old_modules);
+ m_process->GetTarget().ModulesDidUnload(old_modules, false);
}
}
Modified: lldb/trunk/source/Target/Process.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Nov 5 17:28:00 2013
@@ -5633,9 +5633,7 @@ Process::DidExec ()
{
Target &target = GetTarget();
target.CleanupProcess ();
- ModuleList unloaded_modules (target.GetImages());
- target.ModulesDidUnload (unloaded_modules);
- target.GetSectionLoadList().Clear();
+ target.ClearModules();
m_dynamic_checkers_ap.reset();
m_abi_sp.reset();
m_system_runtime_ap.reset();
@@ -5648,4 +5646,8 @@ Process::DidExec ()
m_memory_cache.Clear(true);
DoDidExec();
CompleteAttach ();
+ // Flush the process (threads and all stack frames) after running
CompleteAttach()
+ // in case the dynamic loader loaded things in new locations.
+ Flush();
}
+
Modified: lldb/trunk/source/Target/Target.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Nov 5 17:28:00 2013
@@ -192,7 +192,7 @@ Target::Destroy()
DeleteCurrentProcess ();
m_platform_sp.reset();
m_arch.Clear();
- m_images.Clear();
+ ClearModules();
m_section_load_list.Clear();
const bool notify = false;
m_breakpoint_list.RemoveAll(notify);
@@ -201,9 +201,6 @@ Target::Destroy()
m_last_created_watchpoint.reset();
m_search_filter_sp.reset();
m_image_search_paths.Clear(notify);
- m_scratch_ast_context_ap.reset();
- m_scratch_ast_source_ap.reset();
- m_ast_importer_ap.reset();
m_persistent_variables.Clear();
m_stop_hooks.clear();
m_stop_hook_next_id = 0;
@@ -1017,13 +1014,21 @@ LoadScriptingResourceForModule (const Mo
}
void
-Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
+Target::ClearModules()
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
+ ModulesDidUnload (m_images, true);
+ GetSectionLoadList().Clear();
m_images.Clear();
m_scratch_ast_context_ap.reset();
m_scratch_ast_source_ap.reset();
m_ast_importer_ap.reset();
+}
+
+void
+Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
+ ClearModules();
if (executable_sp.get())
{
@@ -1092,10 +1097,8 @@ Target::SetArchitecture (const ArchSpec
log->Printf ("Target::SetArchitecture changing architecture to %s
(%s)", arch_spec.GetArchitectureName(),
arch_spec.GetTriple().getTriple().c_str());
m_arch = arch_spec;
ModuleSP executable_sp = GetExecutableModule ();
- m_images.Clear();
- m_scratch_ast_context_ap.reset();
- m_scratch_ast_source_ap.reset();
- m_ast_importer_ap.reset();
+
+ ClearModules();
// Need to do something about unsetting breakpoints.
if (executable_sp)
@@ -1140,7 +1143,7 @@ Target::ModuleRemoved (const ModuleList&
// A module is being added to this target for the first time
ModuleList my_module_list;
my_module_list.Append(module_sp);
- ModulesDidUnload (my_module_list);
+ ModulesDidUnload (my_module_list, false);
}
void
@@ -1155,7 +1158,7 @@ Target::ModulesDidLoad (ModuleList &modu
{
if (module_list.GetSize())
{
- m_breakpoint_list.UpdateBreakpoints (module_list, true);
+ m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
if (m_process_sp)
{
SystemRuntime *sys_runtime = m_process_sp->GetSystemRuntime();
@@ -1184,17 +1187,17 @@ Target::SymbolsDidLoad (ModuleList &modu
}
}
- m_breakpoint_list.UpdateBreakpoints (module_list, true);
+ m_breakpoint_list.UpdateBreakpoints (module_list, true, false);
BroadcastEvent(eBroadcastBitSymbolsLoaded, NULL);
}
}
void
-Target::ModulesDidUnload (ModuleList &module_list)
+Target::ModulesDidUnload (ModuleList &module_list, bool delete_locations)
{
if (module_list.GetSize())
{
- m_breakpoint_list.UpdateBreakpoints (module_list, false);
+ m_breakpoint_list.UpdateBreakpoints (module_list, false,
delete_locations);
// TODO: make event data that packages up the module_list
BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
}
@@ -1737,10 +1740,7 @@ Target::ImageSearchPathsChanged
Target *target = (Target *)baton;
ModuleSP exe_module_sp (target->GetExecutableModule());
if (exe_module_sp)
- {
- target->m_images.Clear();
target->SetExecutableModule (exe_module_sp, true);
- }
}
ClangASTContext *
Modified: lldb/trunk/test/functionalities/exec/TestExec.py
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/exec/TestExec.py?rev=194106&r1=194105&r2=194106&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/exec/TestExec.py (original)
+++ lldb/trunk/test/functionalities/exec/TestExec.py Tue Nov 5 17:28:00 2013
@@ -24,7 +24,6 @@ class ExecTestCase(TestBase):
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
- @unittest2.expectedFailure("rdar://15367122")
def test_with_dsym (self):
if self.getArchitecture() == 'x86_64':
source = os.path.join (os.getcwd(), "main.cpp")
@@ -38,7 +37,6 @@ class ExecTestCase(TestBase):
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dwarf_test
- @unittest2.expectedFailure("rdar://15367122")
def test_with_dwarf (self):
if self.getArchitecture() == 'x86_64':
source = os.path.join (os.getcwd(), "main.cpp")
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits