<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.

llvm-svn: 194106
This commit is contained in:
Greg Clayton 2013-11-05 23:28:00 +00:00
parent 5ede5cc9ba
commit 095eeaa025
8 changed files with 39 additions and 30 deletions

View File

@ -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);

View File

@ -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.
///

View File

@ -204,13 +204,13 @@ BreakpointList::GetBreakpointAtIndex (size_t i) const
}
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);
}

View File

@ -1335,7 +1335,7 @@ DynamicLoaderDarwinKernel::ParseKextSummaries (const Address &kext_summary_addr,
// 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);
}
}

View File

@ -370,7 +370,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules()
}
}
loaded_modules.Remove(old_modules);
m_process->GetTarget().ModulesDidUnload(old_modules);
m_process->GetTarget().ModulesDidUnload(old_modules, false);
}
}

View File

@ -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();
}

View File

@ -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 ModuleSP &module_sp, Target *target)
}
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 &arch_spec)
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& module_list, const ModuleSP &module_sp)
// 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 &module_list)
{
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 &module_list)
}
}
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 *

View File

@ -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")