bool
IsLoadedInTarget (Target *target);
+ bool
+ LoadScriptingResourceInTarget (Target *target, Error& error);
+
//------------------------------------------------------------------
/// Get the number of compile units for this module.
///
class ModuleList
{
public:
+
+ class Notifier
+ {
+ public:
+ virtual void
+ ModuleAdded (const lldb::ModuleSP& module_sp) = 0;
+ virtual void
+ ModuleRemoved (const lldb::ModuleSP& module_sp) = 0;
+ virtual void
+ ModuleUpdated (const lldb::ModuleSP& old_module_sp,
+ const lldb::ModuleSP& new_module_sp) = 0;
+ virtual void
+ WillClearList () = 0;
+
+ virtual
+ ~Notifier ()
+ {}
+ };
+
//------------------------------------------------------------------
/// Default constructor.
///
/// Another module list object.
//------------------------------------------------------------------
ModuleList (const ModuleList& rhs);
+
+ ModuleList (ModuleList::Notifier* notifier);
//------------------------------------------------------------------
/// Destructor.
bool
AppendIfNeeded (const lldb::ModuleSP &module_sp);
+ void
+ Append (const ModuleList& module_list);
+
+ bool
+ AppendIfNeeded (const ModuleList& module_list);
+
+ bool
+ ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp);
+
//------------------------------------------------------------------
/// Clear the object's state.
///
const char *prefix_cstr);
Mutex &
- GetMutex ()
+ GetMutex () const
{
return m_modules_mutex;
}
/// @see ModuleList::GetSize()
//------------------------------------------------------------------
lldb::ModuleSP
- GetModuleAtIndex (uint32_t idx);
+ GetModuleAtIndex (uint32_t idx) const;
//------------------------------------------------------------------
/// Get the module shared pointer for the module at index \a idx without
/// @see ModuleList::GetSize()
//------------------------------------------------------------------
lldb::ModuleSP
- GetModuleAtIndexUnlocked (uint32_t idx);
+ GetModuleAtIndexUnlocked (uint32_t idx) const;
//------------------------------------------------------------------
/// Get the module pointer for the module at index \a idx.
uint32_t
FindCompileUnits (const FileSpec &path,
bool append,
- SymbolContextList &sc_list);
+ SymbolContextList &sc_list) const;
//------------------------------------------------------------------
/// @see Module::FindFunctions ()
bool include_symbols,
bool include_inlines,
bool append,
- SymbolContextList &sc_list);
+ SymbolContextList &sc_list) const;
//------------------------------------------------------------------
/// Find global and static variables by name.
FindGlobalVariables (const ConstString &name,
bool append,
uint32_t max_matches,
- VariableList& variable_list);
+ VariableList& variable_list) const;
//------------------------------------------------------------------
/// Find global and static variables by regular exression.
FindGlobalVariables (const RegularExpression& regex,
bool append,
uint32_t max_matches,
- VariableList& variable_list);
+ VariableList& variable_list) const;
//------------------------------------------------------------------
/// Finds the first module whose file specification matches \a
ModuleList& matching_module_list) const;
lldb::ModuleSP
- FindModule (const Module *module_ptr);
+ FindModule (const Module *module_ptr) const;
//------------------------------------------------------------------
// Find a module by UUID
// finding modules by UUID values is very efficient and accurate.
//------------------------------------------------------------------
lldb::ModuleSP
- FindModule (const UUID &uuid);
+ FindModule (const UUID &uuid) const;
lldb::ModuleSP
- FindFirstModule (const ModuleSpec &module_spec);
+ FindFirstModule (const ModuleSpec &module_spec) const;
size_t
FindSymbolsWithNameAndType (const ConstString &name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
- bool append = false);
+ bool append = false) const;
size_t
FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
- bool append = false);
+ bool append = false) const;
//------------------------------------------------------------------
/// Find types by name.
const ConstString &name,
bool name_is_fully_qualified,
uint32_t max_matches,
- TypeList& types);
+ TypeList& types) const;
bool
FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
bool
ResolveFileAddress (lldb::addr_t vm_addr,
- Address& so_addr);
+ Address& so_addr) const;
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextForAddress (const Address &,uint32_t,SymbolContext&)
uint32_t
ResolveSymbolContextForAddress (const Address& so_addr,
uint32_t resolve_scope,
- SymbolContext& sc);
+ SymbolContext& sc) const;
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextForFilePath (const char *,uint32_t,bool,uint32_t,SymbolContextList&)
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
- SymbolContextList& sc_list);
+ SymbolContextList& sc_list) const;
//------------------------------------------------------------------
/// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec &,uint32_t,bool,uint32_t,SymbolContextList&)
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
- SymbolContextList& sc_list);
+ SymbolContextList& sc_list) const;
//------------------------------------------------------------------
/// Gets the size of the module list.
//------------------------------------------------------------------
typedef std::vector<lldb::ModuleSP> collection; ///< The module collection type.
+ void
+ AppendImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ bool
+ RemoveImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ collection::iterator
+ RemoveImpl (collection::iterator pos, bool use_notifier = true);
+
+ void
+ ClearImpl (bool use_notifier = true);
+
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
collection m_modules; ///< The collection of modules.
mutable Mutex m_modules_mutex;
+ Notifier* m_notifier;
+
};
} // namespace lldb_private
//----------------------------------------------------------------------
static FileSpec
LocateExecutableSymbolFile (const ModuleSpec &module_spec);
-
+
static FileSpec
FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
const lldb_private::UUID *uuid,
const UUID *uuid_ptr,
FileSpec &local_file);
+ //----------------------------------------------------------------------
+ // Locate the scripting resource given a module specification.
+ //
+ // Locating the file should happen only on the local computer or using
+ // the current computers global settings.
+ //----------------------------------------------------------------------
+ virtual FileSpec
+ LocateExecutableScriptingResource (const ModuleSpec &module_spec);
+
virtual Error
GetSharedModule (const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
eInlineBreakpointsAlways
} InlineStrategy;
-
//----------------------------------------------------------------------
// TargetProperties
//----------------------------------------------------------------------
public STD_ENABLE_SHARED_FROM_THIS(Target),
public TargetProperties,
public Broadcaster,
- public ExecutionContextScope
+ public ExecutionContextScope,
+ public ModuleList::Notifier
{
public:
friend class TargetList;
bool
IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count);
- void
- ModulesDidLoad (ModuleList &module_list);
-
- void
- ModulesDidUnload (ModuleList &module_list);
-
-
//------------------------------------------------------------------
/// Get \a load_addr as a callable code load address for this target
///
GetOpcodeLoadAddress (lldb::addr_t load_addr, lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
protected:
- void
- ModuleAdded (lldb::ModuleSP &module_sp);
+ //------------------------------------------------------------------
+ /// Implementing of ModuleList::Notifier.
+ //------------------------------------------------------------------
+
+ virtual void
+ ModuleAdded (const lldb::ModuleSP& module_sp);
+
+ virtual void
+ ModuleRemoved (const lldb::ModuleSP& module_sp);
+
+ virtual void
+ ModuleUpdated (const lldb::ModuleSP& old_module_sp,
+ const lldb::ModuleSP& new_module_sp);
+ virtual void
+ WillClearList ();
+public:
+
void
- ModuleUpdated (lldb::ModuleSP &old_module_sp, lldb::ModuleSP &new_module_sp);
+ ModulesDidLoad (ModuleList &module_list);
-public:
+ void
+ ModulesDidUnload (ModuleList &module_list);
+
//------------------------------------------------------------------
/// Gets the module for the main executable.
///
/// @return
/// A list of Module objects in a module list.
//------------------------------------------------------------------
- ModuleList&
- GetImages ()
- {
- return m_images;
- }
-
const ModuleList&
GetImages () const
{
return m_images;
}
+ ModuleList&
+ GetImages ()
+ {
+ return m_images;
+ }
//------------------------------------------------------------------
/// Return whether this FileSpec corresponds to a module that should be considered for general searches.
if (command.GetArgumentCount() == 0)
{
// Dump all sections for all modules images
- ModuleList &target_modules = target->GetImages();
+ const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
const uint32_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
FileSpec file_spec(arg_cstr, false);
- ModuleList &target_modules = target->GetImages();
+ const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
const uint32_t num_modules = target_modules.GetSize();
if (num_modules > 0)
Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
// Otherwise it will lock the AllocationModuleCollectionMutex when accessing
// the global module list directly.
- ModuleList *module_list_ptr = NULL;
+ const ModuleList *module_list_ptr = NULL;
const size_t argc = command.GetArgumentCount();
if (argc == 0)
{
// Dump all sections for all other modules
- ModuleList &target_modules = target->GetImages();
+ const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
const uint32_t num_modules = target_modules.GetSize();
if (num_modules > 0)
//
//===----------------------------------------------------------------------===//
+#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/Symbols.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/lldb-private-log.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
}
return false;
}
-bool
+
+bool
+Module::LoadScriptingResourceInTarget (Target *target, Error& error)
+{
+ if (!target)
+ {
+ error.SetErrorString("invalid destination Target");
+ return false;
+ }
+
+ PlatformSP platform_sp(target->GetPlatform());
+
+ if (!platform_sp)
+ {
+ error.SetErrorString("invalid Platform");
+ return false;
+ }
+
+ ModuleSpec module_spec(GetFileSpec());
+ FileSpec scripting_fspec = platform_sp->LocateExecutableScriptingResource(module_spec);
+ Debugger &debugger(target->GetDebugger());
+ if (scripting_fspec && scripting_fspec.Exists())
+ {
+ ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
+ if (script_interpreter)
+ {
+ StreamString scripting_stream;
+ scripting_fspec.Dump(&scripting_stream);
+ bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(), false, true, error);
+ if (!did_load)
+ return false;
+ }
+ else
+ {
+ error.SetErrorString("invalid ScriptInterpreter");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool
Module::SetArchitecture (const ArchSpec &new_arch)
{
if (!m_arch.IsValid())
//----------------------------------------------------------------------
ModuleList::ModuleList() :
m_modules(),
- m_modules_mutex (Mutex::eMutexTypeRecursive)
+ m_modules_mutex (Mutex::eMutexTypeRecursive),
+ m_notifier(NULL)
{
}
Mutex::Locker lhs_locker(m_modules_mutex);
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
+ m_notifier = rhs.m_notifier;
+}
+
+ModuleList::ModuleList (ModuleList::Notifier* notifier) :
+ m_modules(),
+ m_modules_mutex (Mutex::eMutexTypeRecursive),
+ m_notifier(notifier)
+{
}
//----------------------------------------------------------------------
Mutex::Locker lhs_locker(m_modules_mutex);
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
+ m_notifier = rhs.m_notifier;
}
return *this;
}
}
void
-ModuleList::Append (const ModuleSP &module_sp)
+ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
{
if (module_sp)
{
Mutex::Locker locker(m_modules_mutex);
m_modules.push_back(module_sp);
+ if (use_notifier && m_notifier)
+ m_notifier->ModuleAdded(module_sp);
}
}
void
+ModuleList::Append (const ModuleSP &module_sp)
+{
+ AppendImpl (module_sp);
+}
+
+void
ModuleList::ReplaceEquivalent (const ModuleSP &module_sp)
{
if (module_sp)
{
ModuleSP module_sp (m_modules[idx]);
if (module_sp->MatchesModuleSpec (equivalent_module_spec))
- m_modules.erase(m_modules.begin() + idx);
+ RemoveImpl(m_modules.begin() + idx);
else
++idx;
}
// Now add the new module to the list
- m_modules.push_back(module_sp);
+ Append(module_sp);
}
}
return false; // Already in the list
}
// Only push module_sp on the list if it wasn't already in there.
- m_modules.push_back(module_sp);
+ Append(module_sp);
return true;
}
return false;
}
+void
+ModuleList::Append (const ModuleList& module_list)
+{
+ for (auto pos : module_list.m_modules)
+ Append(pos);
+}
+
bool
-ModuleList::Remove (const ModuleSP &module_sp)
+ModuleList::AppendIfNeeded (const ModuleList& module_list)
+{
+ bool any_in = false;
+ for (auto pos : module_list.m_modules)
+ any_in = AppendIfNeeded(pos) | any_in;
+ return any_in;
+}
+
+bool
+ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier)
{
if (module_sp)
{
if (pos->get() == module_sp.get())
{
m_modules.erase (pos);
+ if (use_notifier && m_notifier)
+ m_notifier->ModuleRemoved(module_sp);
return true;
}
}
return false;
}
+ModuleList::collection::iterator
+ModuleList::RemoveImpl (ModuleList::collection::iterator pos, bool use_notifier)
+{
+ ModuleSP module_sp(*pos);
+ collection::iterator retval = m_modules.erase(pos);
+ if (use_notifier && m_notifier)
+ m_notifier->ModuleRemoved(module_sp);
+ return retval;
+}
+
+bool
+ModuleList::Remove (const ModuleSP &module_sp)
+{
+ return RemoveImpl (module_sp);
+}
+
+bool
+ModuleList::ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
+{
+ if (!RemoveImpl(old_module_sp, false))
+ return false;
+ AppendImpl (new_module_sp, false);
+ if (m_notifier)
+ m_notifier->ModuleUpdated(old_module_sp,new_module_sp);
+ return true;
+}
+
bool
ModuleList::RemoveIfOrphaned (const Module *module_ptr)
{
{
if (pos->unique())
{
- pos = m_modules.erase (pos);
+ pos = RemoveImpl(pos);
return true;
}
else
{
if (pos->unique())
{
- pos = m_modules.erase (pos);
+ pos = RemoveImpl(pos);
++remove_count;
}
else
}
-
void
ModuleList::Clear()
{
- Mutex::Locker locker(m_modules_mutex);
- m_modules.clear();
+ ClearImpl();
}
void
ModuleList::Destroy()
{
+ ClearImpl();
+}
+
+void
+ModuleList::ClearImpl (bool use_notifier)
+{
Mutex::Locker locker(m_modules_mutex);
- collection empty;
- m_modules.swap(empty);
+ if (use_notifier && m_notifier)
+ m_notifier->WillClearList();
+ m_modules.clear();
}
Module*
}
ModuleSP
-ModuleList::GetModuleAtIndex(uint32_t idx)
+ModuleList::GetModuleAtIndex(uint32_t idx) const
{
Mutex::Locker locker(m_modules_mutex);
return GetModuleAtIndexUnlocked(idx);
}
ModuleSP
-ModuleList::GetModuleAtIndexUnlocked(uint32_t idx)
+ModuleList::GetModuleAtIndexUnlocked(uint32_t idx) const
{
ModuleSP module_sp;
if (idx < m_modules.size())
bool include_symbols,
bool include_inlines,
bool append,
- SymbolContextList &sc_list)
+ SymbolContextList &sc_list) const
{
if (!append)
sc_list.Clear();
uint32_t
ModuleList::FindCompileUnits (const FileSpec &path,
bool append,
- SymbolContextList &sc_list)
+ SymbolContextList &sc_list) const
{
if (!append)
sc_list.Clear();
ModuleList::FindGlobalVariables (const ConstString &name,
bool append,
uint32_t max_matches,
- VariableList& variable_list)
+ VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
- collection::iterator pos, end = m_modules.end();
+ collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
ModuleList::FindGlobalVariables (const RegularExpression& regex,
bool append,
uint32_t max_matches,
- VariableList& variable_list)
+ VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
- collection::iterator pos, end = m_modules.end();
+ collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables (regex, append, max_matches, variable_list);
ModuleList::FindSymbolsWithNameAndType (const ConstString &name,
SymbolType symbol_type,
SymbolContextList &sc_list,
- bool append)
+ bool append) const
{
Mutex::Locker locker(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
- collection::iterator pos, end = m_modules.end();
+ collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsWithNameAndType (name, symbol_type, sc_list);
return sc_list.GetSize() - initial_size;
ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
- bool append)
+ bool append) const
{
Mutex::Locker locker(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
- collection::iterator pos, end = m_modules.end();
+ collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsMatchingRegExAndType (regex, symbol_type, sc_list);
return sc_list.GetSize() - initial_size;
}
ModuleSP
-ModuleList::FindModule (const Module *module_ptr)
+ModuleList::FindModule (const Module *module_ptr) const
{
ModuleSP module_sp;
}
ModuleSP
-ModuleList::FindModule (const UUID &uuid)
+ModuleList::FindModule (const UUID &uuid) const
{
ModuleSP module_sp;
uint32_t
-ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types)
+ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types) const
{
Mutex::Locker locker(m_modules_mutex);
ModuleSP
-ModuleList::FindFirstModule (const ModuleSpec &module_spec)
+ModuleList::FindFirstModule (const ModuleSpec &module_spec) const
{
ModuleSP module_sp;
Mutex::Locker locker(m_modules_mutex);
}
bool
-ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
+ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
}
uint32_t
-ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
+ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) const
{
// The address is already section offset so it has a module
uint32_t resolved_flags = 0;
bool check_inlines,
uint32_t resolve_scope,
SymbolContextList& sc_list
-)
+) const
{
FileSpec file_spec(file_path, false);
return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
}
uint32_t
-ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
+ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
}
else
{
- ModuleList &target_images = m_target_sp->GetImages();
+ const ModuleList &target_images = m_target_sp->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
size_t n_modules = target_images.GetSize();
// filespec that passes. Otherwise, we need to go through all modules and
// find the ones that match the file name.
- ModuleList &target_modules = m_target_sp->GetImages();
+ const ModuleList &target_modules = m_target_sp->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize ();
// filespec that passes. Otherwise, we need to go through all modules and
// find the ones that match the file name.
- ModuleList &target_modules = m_target_sp->GetImages();
+ const ModuleList &target_modules = m_target_sp->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize ();
// find the ones that match the file name.
ModuleList matching_modules;
- ModuleList &target_images = m_target_sp->GetImages();
+ const ModuleList &target_images = m_target_sp->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
const size_t num_modules = target_images.GetSize ();
ConstString name(tag_decl->getName().str().c_str());
ClangNamespaceDecl namespace_decl;
- ModuleList &module_list = m_target->GetImages();
+ const ModuleList &module_list = m_target->GetImages();
bool exact_match = false;
module_list.FindTypes (null_sc, name, exact_match, UINT32_MAX, types);
}
else
{
- ModuleList &target_images = m_target->GetImages();
+ const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker (target_images.GetMutex());
for (uint32_t i = 0, e = target_images.GetSize();
}
else
{
- ModuleList &target_images = m_target->GetImages();
+ const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
ClangNamespaceDecl null_namespace_decl;
{
if (uuid_is_valid)
{
- ModuleList &target_images = target.GetImages();
+ const ModuleList &target_images = target.GetImages();
module_sp = target_images.FindModule(uuid);
if (!module_sp)
loaded_module_list.AppendIfNeeded (image_infos[idx].module_sp);
}
- if (loaded_module_list.GetSize() > 0)
- {
- m_process->GetTarget().ModulesDidLoad (loaded_module_list);
- }
+ m_process->GetTarget().ModulesDidLoad (loaded_module_list);
return true;
}
{
if (did_create_ptr)
*did_create_ptr = false;
- ModuleList &target_images = m_process->GetTarget().GetImages();
+
+
+ const ModuleList &target_images = m_process->GetTarget().GetImages();
ModuleSpec module_spec (image_info.file_spec, image_info.GetArchitecture ());
module_spec.GetUUID() = image_info.uuid;
ModuleSP module_sp (target_images.FindFirstModule (module_spec));
Section *commpage_section = sections->FindSectionByName(commpage_dbstr).get();
if (commpage_section)
{
- ModuleList& target_images = m_process->GetTarget().GetImages();
+ const ModuleList& target_images = m_process->GetTarget().GetImages();
ModuleSpec module_spec (objfile->GetFileSpec(), image_infos[idx].GetArchitecture ());
module_spec.GetObjectName() = commpage_dbstr;
ModuleSP commpage_image_module_sp(target_images.FindFirstModule (module_spec));
log->PutCString("Unloaded:");
unloaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidUnload");
}
- m_process->GetTarget().ModulesDidUnload (unloaded_module_list);
+ m_process->GetTarget().GetImages().Remove (unloaded_module_list);
}
m_dyld_image_infos_stop_id = m_process->GetStopID();
return true;
// to an equivalent version. We don't want it to stay in the target's module list or it will confuse
// us, so unload it here.
Target &target = m_process->GetTarget();
- ModuleList &target_modules = target.GetImages();
+ const ModuleList &target_modules = target.GetImages();
ModuleList not_loaded_modules;
Mutex::Locker modules_locker(target_modules.GetMutex());
if (not_loaded_modules.GetSize() != 0)
{
- target.ModulesDidUnload(not_loaded_modules);
+ target.GetImages().Remove(not_loaded_modules);
}
return true;
{
SymbolContextList target_symbols;
TargetSP target_sp (thread.CalculateTarget());
- ModuleList &images = target_sp->GetImages();
+ const ModuleList &images = target_sp->GetImages();
images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols);
FileSpec file(I->path.c_str(), true);
ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr);
if (module_sp.get())
- new_modules.Append(module_sp);
+ loaded_modules.AppendIfNeeded(module_sp);
}
- m_process->GetTarget().ModulesDidLoad(new_modules);
}
if (m_rendezvous.ModulesDidUnload())
if (module_sp.get())
old_modules.Append(module_sp);
}
- m_process->GetTarget().ModulesDidUnload(old_modules);
+ loaded_modules.Remove(old_modules);
}
}
SymbolContextList target_symbols;
Target &target = thread.GetProcess()->GetTarget();
- ModuleList &images = target.GetImages();
+ const ModuleList &images = target.GetImages();
images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols);
size_t num_targets = target_symbols.GetSize();
void
DynamicLoaderStatic::LoadAllImagesAtFileAddresses ()
{
- ModuleList &module_list = m_process->GetTarget().GetImages();
+ const ModuleList &module_list = m_process->GetTarget().GetImages();
ModuleList loaded_module_list;
}
}
- if (loaded_module_list.GetSize())
- m_process->GetTarget().ModulesDidLoad (loaded_module_list);
+ m_process->GetTarget().ModulesDidLoad (loaded_module_list);
}
ThreadPlanSP
Process *process = GetProcess();
if (process)
{
- ModuleList& modules = process->GetTarget().GetImages();
+ const ModuleList& modules = process->GetTarget().GetImages();
for (uint32_t idx = 0; idx < modules.GetSize(); idx++)
{
module_sp = modules.GetModuleAtIndex(idx);
{
if (!m_PrintForDebugger_addr.get())
{
- ModuleList &modules = m_process->GetTarget().GetImages();
+ const ModuleList &modules = m_process->GetTarget().GetImages();
SymbolContextList contexts;
SymbolContext context;
return eObjC_VersionUnknown;
Target &target = process->GetTarget();
- ModuleList &target_modules = target.GetImages();
+ const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_images = target_modules.GetSize();
{
if (!target_sp)
return eLazyBoolCalculate;
- ModuleList& modules = target_sp->GetImages();
+ const ModuleList& modules = target_sp->GetImages();
for (uint32_t idx = 0; idx < modules.GetSize(); idx++)
{
lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx);
return true;
Target &target = m_process_sp->GetTarget();
- ModuleList &target_modules = target.GetImages();
+ const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
if (!m_objc_module_sp)
#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Symbol/ObjectFile.h"
{
}
+FileSpec
+PlatformDarwin::LocateExecutableScriptingResource (const ModuleSpec &module_spec)
+{
+ const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+ const ArchSpec *arch = module_spec.GetArchitecturePtr();
+ const UUID *uuid = module_spec.GetUUIDPtr();
+
+ Timer scoped_timer (__PRETTY_FUNCTION__,
+ "LocateExecutableScriptingResource (file = %s, arch = %s, uuid = %p)",
+ exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
+ arch ? arch->GetArchitectureName() : "<NULL>",
+ uuid);
+
+
+ FileSpec symbol_fspec (Symbols::LocateExecutableSymbolFile(module_spec));
+
+ FileSpec script_fspec;
+
+ if (symbol_fspec && symbol_fspec.Exists())
+ {
+ // for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename>
+ // let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists
+ StreamString path_string;
+ path_string.Printf("%s/../Python/%s.py",symbol_fspec.GetDirectory().GetCString(),module_spec.GetFileSpec().GetFileNameStrippingExtension().GetCString());
+ script_fspec.SetFile(path_string.GetData(), true);
+ if (!script_fspec.Exists())
+ script_fspec.Clear();
+ }
+
+ return script_fspec;
+}
Error
PlatformDarwin::ResolveExecutable (const FileSpec &exe_file,
const lldb_private::ModuleSpec &sym_spec,
lldb_private::FileSpec &sym_file);
+ lldb_private::FileSpec
+ LocateExecutableScriptingResource (const lldb_private::ModuleSpec &module_spec);
+
virtual lldb_private::Error
GetSharedModule (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
m_complete_class_cache.erase(name);
}
- ModuleList &modules = m_process->GetTarget().GetImages();
+ const ModuleList &modules = m_process->GetTarget().GetImages();
SymbolContextList sc_list;
const size_t matching_symbols = modules.FindSymbolsWithNameAndType (name,
return Error();
}
+FileSpec
+Platform::LocateExecutableScriptingResource (const ModuleSpec &module_spec)
+{
+ return FileSpec();
+}
+
Error
Platform::GetSharedModule (const ModuleSpec &module_spec,
ModuleSP &module_sp,
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
- ModuleList &target_modules = m_target.GetImages();
+ const ModuleList &target_modules = m_target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
ModuleSP new_executable_module_sp;
m_platform_sp (platform_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_arch (target_arch),
- m_images (),
+ m_images (this),
m_section_load_list (),
m_breakpoint_list (false),
m_internal_breakpoint_list (true),
return m_images.GetModulePointerAtIndex(0);
}
+static void
+LoadScriptingResourceForModule (const ModuleSP &module_sp, Target *target)
+{
+ Error error;
+ if (module_sp && !module_sp->LoadScriptingResourceInTarget(target, error))
+ {
+ target->GetDebugger().GetOutputStream().Printf("unable to load scripting data for module %s - error reported was %s\n",
+ module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
+ error.AsCString());
+ }
+}
+
void
Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
{
}
void
-Target::ModuleAdded (ModuleSP &module_sp)
+Target::WillClearList ()
+{
+}
+
+void
+Target::ModuleAdded (const ModuleSP &module_sp)
{
// A module is being added to this target for the first time
ModuleList module_list;
module_list.Append(module_sp);
+ LoadScriptingResourceForModule(module_sp, this);
ModulesDidLoad (module_list);
}
void
-Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp)
+Target::ModuleRemoved (const ModuleSP &module_sp)
+{
+ // A module is being added to this target for the first time
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ ModulesDidUnload (module_list);
+}
+
+void
+Target::ModuleUpdated (const ModuleSP &old_module_sp, const ModuleSP &new_module_sp)
{
// A module is replacing an already added module
m_breakpoint_list.UpdateBreakpointsWhenModuleIsReplaced(old_module_sp, new_module_sp);
void
Target::ModulesDidLoad (ModuleList &module_list)
{
- m_breakpoint_list.UpdateBreakpoints (module_list, true);
- // TODO: make event data that packages up the module_list
- BroadcastEvent (eBroadcastBitModulesLoaded, NULL);
+ if (module_list.GetSize())
+ {
+ m_breakpoint_list.UpdateBreakpoints (module_list, true);
+ // TODO: make event data that packages up the module_list
+ BroadcastEvent (eBroadcastBitModulesLoaded, NULL);
+ }
}
void
Target::ModulesDidUnload (ModuleList &module_list)
{
- m_breakpoint_list.UpdateBreakpoints (module_list, false);
-
- // Remove the images from the target image list
- m_images.Remove(module_list);
-
- // TODO: make event data that packages up the module_list
- BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
+ if (module_list.GetSize())
+ {
+ m_breakpoint_list.UpdateBreakpoints (module_list, false);
+ // TODO: make event data that packages up the module_list
+ BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
+ }
}
-
bool
Target::ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_file_spec)
{
-
if (GetBreakpointsConsultPlatformAvoidList())
{
ModuleList matchingModules;
}
}
- m_images.Append (module_sp);
if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32)
{
- ModuleUpdated(old_module_sp, module_sp);
- m_images.Remove (old_module_sp);
+ m_images.ReplaceModule(old_module_sp, module_sp);
Module *old_module_ptr = old_module_sp.get();
old_module_sp.reset();
ModuleList::RemoveSharedModuleIfOrphaned (old_module_ptr);
}
else
- ModuleAdded(module_sp);
+ m_images.Append(module_sp);
}
}
if (error_ptr)