2010-06-09 00:52:24 +08:00
|
|
|
//===-- ModuleList.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/ModuleList.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2010-12-14 10:59:59 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
2012-01-05 11:57:59 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Host/Symbols.h"
|
2011-10-12 10:08:07 +08:00
|
|
|
#include "lldb/Symbol/ClangNamespaceDecl.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// ModuleList constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ModuleList::ModuleList() :
|
|
|
|
m_modules(),
|
2012-11-08 10:22:02 +08:00
|
|
|
m_modules_mutex (Mutex::eMutexTypeRecursive),
|
|
|
|
m_notifier(NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Copy constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ModuleList::ModuleList(const ModuleList& rhs) :
|
2012-06-28 03:59:26 +08:00
|
|
|
m_modules(),
|
|
|
|
m_modules_mutex (Mutex::eMutexTypeRecursive)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-06-28 03:59:26 +08:00
|
|
|
Mutex::Locker lhs_locker(m_modules_mutex);
|
|
|
|
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
|
|
|
|
m_modules = rhs.m_modules;
|
2012-11-08 10:22:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ModuleList::ModuleList (ModuleList::Notifier* notifier) :
|
|
|
|
m_modules(),
|
|
|
|
m_modules_mutex (Mutex::eMutexTypeRecursive),
|
|
|
|
m_notifier(notifier)
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Assignment operator
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const ModuleList&
|
|
|
|
ModuleList::operator= (const ModuleList& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
2012-06-28 03:59:26 +08:00
|
|
|
Mutex::Locker lhs_locker(m_modules_mutex);
|
|
|
|
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
m_modules = rhs.m_modules;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ModuleList::~ModuleList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
if (module_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
m_modules.push_back(module_sp);
|
2012-11-08 10:22:02 +08:00
|
|
|
if (use_notifier && m_notifier)
|
2012-11-09 03:16:03 +08:00
|
|
|
m_notifier->ModuleAdded(*this, module_sp);
|
2011-04-12 13:54:46 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-11-08 10:22:02 +08:00
|
|
|
void
|
|
|
|
ModuleList::Append (const ModuleSP &module_sp)
|
|
|
|
{
|
|
|
|
AppendImpl (module_sp);
|
|
|
|
}
|
|
|
|
|
2012-07-13 04:32:19 +08:00
|
|
|
void
|
|
|
|
ModuleList::ReplaceEquivalent (const ModuleSP &module_sp)
|
|
|
|
{
|
|
|
|
if (module_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
|
|
|
|
// First remove any equivalent modules. Equivalent modules are modules
|
|
|
|
// whose path, platform path and architecture match.
|
|
|
|
ModuleSpec equivalent_module_spec (module_sp->GetFileSpec(), module_sp->GetArchitecture());
|
|
|
|
equivalent_module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec();
|
|
|
|
|
|
|
|
size_t idx = 0;
|
|
|
|
while (idx < m_modules.size())
|
|
|
|
{
|
|
|
|
ModuleSP module_sp (m_modules[idx]);
|
|
|
|
if (module_sp->MatchesModuleSpec (equivalent_module_spec))
|
2012-11-08 10:22:02 +08:00
|
|
|
RemoveImpl(m_modules.begin() + idx);
|
2012-07-13 04:32:19 +08:00
|
|
|
else
|
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
// Now add the new module to the list
|
2012-11-08 10:22:02 +08:00
|
|
|
Append(module_sp);
|
2012-07-13 04:32:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2011-09-24 08:52:29 +08:00
|
|
|
ModuleList::AppendIfNeeded (const ModuleSP &module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
if (module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (pos->get() == module_sp.get())
|
|
|
|
return false; // Already in the list
|
|
|
|
}
|
|
|
|
// Only push module_sp on the list if it wasn't already in there.
|
2012-11-08 10:22:02 +08:00
|
|
|
Append(module_sp);
|
2011-04-12 13:54:46 +08:00
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-12 13:54:46 +08:00
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-11-08 10:22:02 +08:00
|
|
|
void
|
|
|
|
ModuleList::Append (const ModuleList& module_list)
|
|
|
|
{
|
|
|
|
for (auto pos : module_list.m_modules)
|
|
|
|
Append(pos);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::AppendIfNeeded (const ModuleList& module_list)
|
|
|
|
{
|
|
|
|
bool any_in = false;
|
|
|
|
for (auto pos : module_list.m_modules)
|
2013-08-13 09:42:25 +08:00
|
|
|
{
|
|
|
|
if (AppendIfNeeded(pos))
|
|
|
|
any_in = true;
|
|
|
|
}
|
2012-11-08 10:22:02 +08:00
|
|
|
return any_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
if (module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-12 13:54:46 +08:00
|
|
|
if (pos->get() == module_sp.get())
|
|
|
|
{
|
|
|
|
m_modules.erase (pos);
|
2012-11-08 10:22:02 +08:00
|
|
|
if (use_notifier && m_notifier)
|
2012-11-09 03:16:03 +08:00
|
|
|
m_notifier->ModuleRemoved(*this, module_sp);
|
2011-04-12 13:54:46 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-08 10:22:02 +08:00
|
|
|
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)
|
2012-11-09 03:16:03 +08:00
|
|
|
m_notifier->ModuleRemoved(*this, module_sp);
|
2012-11-08 10:22:02 +08:00
|
|
|
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)
|
2012-11-09 03:16:03 +08:00
|
|
|
m_notifier->ModuleUpdated(*this, old_module_sp,new_module_sp);
|
2012-11-08 10:22:02 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:38:42 +08:00
|
|
|
bool
|
|
|
|
ModuleList::RemoveIfOrphaned (const Module *module_ptr)
|
|
|
|
{
|
|
|
|
if (module_ptr)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (pos->get() == module_ptr)
|
|
|
|
{
|
|
|
|
if (pos->unique())
|
|
|
|
{
|
2012-11-08 10:22:02 +08:00
|
|
|
pos = RemoveImpl(pos);
|
2012-05-18 02:38:42 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-11 10:48:45 +08:00
|
|
|
|
|
|
|
size_t
|
2012-04-10 04:22:01 +08:00
|
|
|
ModuleList::RemoveOrphans (bool mandatory)
|
2011-08-11 10:48:45 +08:00
|
|
|
{
|
2012-04-10 04:22:01 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
|
|
|
|
if (mandatory)
|
|
|
|
{
|
2012-05-05 07:02:50 +08:00
|
|
|
locker.Lock (m_modules_mutex);
|
2012-04-10 04:22:01 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not mandatory, remove orphans if we can get the mutex
|
2012-05-05 07:02:50 +08:00
|
|
|
if (!locker.TryLock(m_modules_mutex))
|
2012-04-10 04:22:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-11 12:30:39 +08:00
|
|
|
collection::iterator pos = m_modules.begin();
|
2011-08-11 10:48:45 +08:00
|
|
|
size_t remove_count = 0;
|
2011-08-11 12:30:39 +08:00
|
|
|
while (pos != m_modules.end())
|
2011-08-11 10:48:45 +08:00
|
|
|
{
|
|
|
|
if (pos->unique())
|
|
|
|
{
|
2012-11-08 10:22:02 +08:00
|
|
|
pos = RemoveImpl(pos);
|
2011-08-11 10:48:45 +08:00
|
|
|
++remove_count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return remove_count;
|
|
|
|
}
|
|
|
|
|
2010-12-07 07:51:26 +08:00
|
|
|
size_t
|
|
|
|
ModuleList::Remove (ModuleList &module_list)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
size_t num_removed = 0;
|
|
|
|
collection::iterator pos, end = module_list.m_modules.end();
|
|
|
|
for (pos = module_list.m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (Remove (*pos))
|
|
|
|
++num_removed;
|
|
|
|
}
|
|
|
|
return num_removed;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
ModuleList::Clear()
|
|
|
|
{
|
2012-11-08 10:22:02 +08:00
|
|
|
ClearImpl();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-01-28 02:45:39 +08:00
|
|
|
void
|
|
|
|
ModuleList::Destroy()
|
2012-11-08 10:22:02 +08:00
|
|
|
{
|
|
|
|
ClearImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ModuleList::ClearImpl (bool use_notifier)
|
2012-01-28 02:45:39 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-11-08 10:22:02 +08:00
|
|
|
if (use_notifier && m_notifier)
|
2012-11-09 03:16:03 +08:00
|
|
|
m_notifier->WillClearList(*this);
|
2012-11-08 10:22:02 +08:00
|
|
|
m_modules.clear();
|
2012-01-28 02:45:39 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Module*
|
2013-01-26 02:06:21 +08:00
|
|
|
ModuleList::GetModulePointerAtIndex (size_t idx) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-05-30 10:19:25 +08:00
|
|
|
return GetModulePointerAtIndexUnlocked(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Module*
|
2013-01-26 02:06:21 +08:00
|
|
|
ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
|
2012-05-30 10:19:25 +08:00
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
if (idx < m_modules.size())
|
|
|
|
return m_modules[idx].get();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSP
|
2013-01-26 02:06:21 +08:00
|
|
|
ModuleList::GetModuleAtIndex(size_t idx) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-05-30 10:19:25 +08:00
|
|
|
return GetModuleAtIndexUnlocked(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSP
|
2013-01-26 02:06:21 +08:00
|
|
|
ModuleList::GetModuleAtIndexUnlocked(size_t idx) const
|
2012-05-30 10:19:25 +08:00
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleSP module_sp;
|
|
|
|
if (idx < m_modules.size())
|
|
|
|
module_sp = m_modules[idx];
|
|
|
|
return module_sp;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindFunctions (const ConstString &name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
bool include_symbols,
|
2012-02-11 06:52:19 +08:00
|
|
|
bool include_inlines,
|
2011-01-27 14:44:37 +08:00
|
|
|
bool append,
|
2012-11-08 10:22:02 +08:00
|
|
|
SymbolContextList &sc_list) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-27 08:55:47 +08:00
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
2013-04-03 10:00:15 +08:00
|
|
|
const size_t old_size = sc_list.GetSize();
|
|
|
|
|
|
|
|
if (name_type_mask & eFunctionNameTypeAuto)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-04-03 10:00:15 +08:00
|
|
|
ConstString lookup_name;
|
|
|
|
uint32_t lookup_name_type_mask = 0;
|
|
|
|
bool match_name_after_lookup = false;
|
|
|
|
Module::PrepareForFunctionNameLookup (name, name_type_mask,
|
|
|
|
lookup_name,
|
|
|
|
lookup_name_type_mask,
|
|
|
|
match_name_after_lookup);
|
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindFunctions (lookup_name,
|
|
|
|
NULL,
|
|
|
|
lookup_name_type_mask,
|
|
|
|
include_symbols,
|
|
|
|
include_inlines,
|
|
|
|
true,
|
|
|
|
sc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match_name_after_lookup)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
size_t i = old_size;
|
|
|
|
while (i<sc_list.GetSize())
|
|
|
|
{
|
|
|
|
if (sc_list.GetContextAtIndex(i, sc))
|
|
|
|
{
|
|
|
|
const char *func_name = sc.GetFunctionName().GetCString();
|
|
|
|
if (func_name && strstr (func_name, name.GetCString()) == NULL)
|
|
|
|
{
|
|
|
|
// Remove the current context
|
|
|
|
sc_list.RemoveContextAtIndex(i);
|
|
|
|
// Don't increment i and continue in the loop
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-04-03 10:00:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sc_list.GetSize() - old_size;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-12 00:40:56 +08:00
|
|
|
size_t
|
|
|
|
ModuleList::FindFunctionSymbols (const ConstString &name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
SymbolContextList& sc_list)
|
|
|
|
{
|
|
|
|
const size_t old_size = sc_list.GetSize();
|
|
|
|
|
|
|
|
if (name_type_mask & eFunctionNameTypeAuto)
|
|
|
|
{
|
|
|
|
ConstString lookup_name;
|
|
|
|
uint32_t lookup_name_type_mask = 0;
|
|
|
|
bool match_name_after_lookup = false;
|
|
|
|
Module::PrepareForFunctionNameLookup (name, name_type_mask,
|
|
|
|
lookup_name,
|
|
|
|
lookup_name_type_mask,
|
|
|
|
match_name_after_lookup);
|
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindFunctionSymbols (lookup_name,
|
|
|
|
lookup_name_type_mask,
|
|
|
|
sc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match_name_after_lookup)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
size_t i = old_size;
|
|
|
|
while (i<sc_list.GetSize())
|
|
|
|
{
|
|
|
|
if (sc_list.GetContextAtIndex(i, sc))
|
|
|
|
{
|
|
|
|
const char *func_name = sc.GetFunctionName().GetCString();
|
|
|
|
if (func_name && strstr (func_name, name.GetCString()) == NULL)
|
|
|
|
{
|
|
|
|
// Remove the current context
|
|
|
|
sc_list.RemoveContextAtIndex(i);
|
|
|
|
// Don't increment i and continue in the loop
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindFunctionSymbols (name, name_type_mask, sc_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc_list.GetSize() - old_size;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-07-07 09:59:51 +08:00
|
|
|
ModuleList::FindCompileUnits (const FileSpec &path,
|
|
|
|
bool append,
|
2012-11-08 10:22:02 +08:00
|
|
|
SymbolContextList &sc_list) const
|
2011-07-07 09:59:51 +08:00
|
|
|
{
|
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindCompileUnits (path, true, sc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc_list.GetSize();
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindGlobalVariables (const ConstString &name,
|
|
|
|
bool append,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t max_matches,
|
2012-11-08 10:22:02 +08:00
|
|
|
VariableList& variable_list) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
size_t initial_size = variable_list.GetSize();
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-11-08 10:22:02 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
2011-10-12 10:08:07 +08:00
|
|
|
(*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return variable_list.GetSize() - initial_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindGlobalVariables (const RegularExpression& regex,
|
|
|
|
bool append,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t max_matches,
|
2012-11-08 10:22:02 +08:00
|
|
|
VariableList& variable_list) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
size_t initial_size = variable_list.GetSize();
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-11-08 10:22:02 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindGlobalVariables (regex, append, max_matches, variable_list);
|
|
|
|
}
|
|
|
|
return variable_list.GetSize() - initial_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindSymbolsWithNameAndType (const ConstString &name,
|
|
|
|
SymbolType symbol_type,
|
2011-11-19 08:19:25 +08:00
|
|
|
SymbolContextList &sc_list,
|
2012-11-08 10:22:02 +08:00
|
|
|
bool append) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2011-11-19 08:19:25 +08:00
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
size_t initial_size = sc_list.GetSize();
|
|
|
|
|
2012-11-08 10:22:02 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
2011-10-14 00:49:47 +08:00
|
|
|
(*pos)->FindSymbolsWithNameAndType (name, symbol_type, sc_list);
|
2011-11-19 08:19:25 +08:00
|
|
|
return sc_list.GetSize() - initial_size;
|
|
|
|
}
|
|
|
|
|
2012-07-13 04:32:19 +08:00
|
|
|
size_t
|
2011-11-19 08:19:25 +08:00
|
|
|
ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
|
|
|
|
lldb::SymbolType symbol_type,
|
|
|
|
SymbolContextList &sc_list,
|
2012-11-08 10:22:02 +08:00
|
|
|
bool append) const
|
2011-11-19 08:19:25 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
size_t initial_size = sc_list.GetSize();
|
|
|
|
|
2012-11-08 10:22:02 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
2011-11-19 08:19:25 +08:00
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
(*pos)->FindSymbolsMatchingRegExAndType (regex, symbol_type, sc_list);
|
|
|
|
return sc_list.GetSize() - initial_size;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleList::FindModules (const ModuleSpec &module_spec, ModuleList& matching_module_list) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
size_t existing_matches = matching_module_list.GetSize();
|
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
2012-02-26 13:51:37 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp(*pos);
|
2012-02-26 13:51:37 +08:00
|
|
|
if (module_sp->MatchesModuleSpec (module_spec))
|
|
|
|
matching_module_list.Append(module_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return matching_module_list.GetSize() - existing_matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSP
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::FindModule (const Module *module_ptr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp;
|
|
|
|
|
|
|
|
// Scope for "locker"
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos).get() == module_ptr)
|
|
|
|
{
|
|
|
|
module_sp = (*pos);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
|
|
|
ModuleSP
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::FindModule (const UUID &uuid) const
|
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp;
|
|
|
|
|
|
|
|
if (uuid.IsValid())
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos)->GetUUID() == uuid)
|
|
|
|
{
|
|
|
|
module_sp = (*pos);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
|
|
|
ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, TypeList& types) const
|
2010-08-03 09:26:16 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t total_matches = 0;
|
2010-08-03 09:26:16 +08:00
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
2012-04-07 02:09:43 +08:00
|
|
|
if (sc.module_sp)
|
2010-08-03 09:26:16 +08:00
|
|
|
{
|
2012-04-07 02:09:43 +08:00
|
|
|
// The symbol context "sc" contains a module so we want to search that
|
|
|
|
// one first if it is in our list...
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (sc.module_sp.get() == (*pos).get())
|
|
|
|
{
|
|
|
|
total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types);
|
2010-08-03 09:26:16 +08:00
|
|
|
|
2012-04-07 02:09:43 +08:00
|
|
|
if (total_matches >= max_matches)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (total_matches < max_matches)
|
|
|
|
{
|
2012-10-04 05:31:35 +08:00
|
|
|
SymbolContext world_sc;
|
2012-04-07 02:09:43 +08:00
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
// Search the module if the module is not equal to the one in the symbol
|
|
|
|
// context "sc". If "sc" contains a empty module shared pointer, then
|
|
|
|
// the comparisong will always be true (valid_module_ptr != NULL).
|
|
|
|
if (sc.module_sp.get() != (*pos).get())
|
2012-10-04 05:31:35 +08:00
|
|
|
total_matches += (*pos)->FindTypes (world_sc, name, name_is_fully_qualified, max_matches, types);
|
2012-04-07 02:09:43 +08:00
|
|
|
|
|
|
|
if (total_matches >= max_matches)
|
|
|
|
break;
|
|
|
|
}
|
2010-08-03 09:26:16 +08:00
|
|
|
}
|
2012-04-07 02:09:43 +08:00
|
|
|
|
2010-08-03 09:26:16 +08:00
|
|
|
return total_matches;
|
|
|
|
}
|
|
|
|
|
2012-03-16 05:01:31 +08:00
|
|
|
bool
|
|
|
|
ModuleList::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos)->FindSourceFile (orig_spec, new_spec))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
void
|
|
|
|
ModuleList::FindAddressesForLine (const lldb::TargetSP target_sp,
|
|
|
|
const FileSpec &file, uint32_t line,
|
|
|
|
Function *function,
|
|
|
|
std::vector<Address> &output_local, std::vector<Address> &output_extern)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->FindAddressesForLine(target_sp, file, line, function, output_local, output_extern);
|
|
|
|
}
|
|
|
|
}
|
2012-03-16 05:01:31 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleSP
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::FindFirstModule (const ModuleSpec &module_spec) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp;
|
2012-02-26 13:51:37 +08:00
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleSP module_sp(*pos);
|
|
|
|
if (module_sp->MatchesModuleSpec (module_spec))
|
|
|
|
return module_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ModuleList::GetSize() const
|
|
|
|
{
|
|
|
|
size_t size = 0;
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
size = m_modules.size();
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ModuleList::Dump(Stream *s) const
|
|
|
|
{
|
|
|
|
// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
|
|
|
|
// s.Indent();
|
|
|
|
// s << "ModuleList\n";
|
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->Dump(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
void
|
2013-03-28 07:08:40 +08:00
|
|
|
ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
|
2010-12-14 10:59:59 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
if (log)
|
2010-12-14 10:59:59 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
Module *module = pos->get();
|
|
|
|
const FileSpec &module_file_spec = module->GetFileSpec();
|
2013-04-30 01:25:54 +08:00
|
|
|
log->Printf ("%s[%u] %s (%s) \"%s\"",
|
2013-03-28 07:08:40 +08:00
|
|
|
prefix_cstr ? prefix_cstr : "",
|
|
|
|
(uint32_t)std::distance (begin, pos),
|
2013-05-04 07:56:12 +08:00
|
|
|
module->GetUUID().GetAsString().c_str(),
|
2013-03-28 07:08:40 +08:00
|
|
|
module->GetArchitecture().GetArchitectureName(),
|
2013-04-30 01:25:54 +08:00
|
|
|
module_file_spec.GetPath().c_str());
|
2010-12-14 10:59:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos)->ResolveFileAddress (vm_addr, so_addr))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// The address is already section offset so it has a module
|
|
|
|
uint32_t resolved_flags = 0;
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp (so_addr.GetModule());
|
|
|
|
if (module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
resolved_flags = module_sp->ResolveSymbolContextForAddress (so_addr,
|
|
|
|
resolve_scope,
|
|
|
|
sc);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
resolved_flags = (*pos)->ResolveSymbolContextForAddress (so_addr,
|
|
|
|
resolve_scope,
|
|
|
|
sc);
|
|
|
|
if (resolved_flags != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolved_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2010-10-21 04:54:39 +08:00
|
|
|
ModuleList::ResolveSymbolContextForFilePath
|
|
|
|
(
|
|
|
|
const char *file_path,
|
|
|
|
uint32_t line,
|
|
|
|
bool check_inlines,
|
|
|
|
uint32_t resolve_scope,
|
|
|
|
SymbolContextList& sc_list
|
2012-11-08 10:22:02 +08:00
|
|
|
) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-21 04:54:39 +08:00
|
|
|
FileSpec file_spec(file_path, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2012-11-08 10:22:02 +08:00
|
|
|
ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc_list.GetSize();
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleList::GetIndexForModule (const Module *module) const
|
|
|
|
{
|
|
|
|
if (module)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator pos;
|
|
|
|
collection::const_iterator begin = m_modules.begin();
|
|
|
|
collection::const_iterator end = m_modules.end();
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos).get() == module)
|
|
|
|
return std::distance (begin, pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return LLDB_INVALID_INDEX32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ModuleList &
|
|
|
|
GetSharedModuleList ()
|
|
|
|
{
|
2012-09-19 07:50:22 +08:00
|
|
|
// NOTE: Intentionally leak the module list so a program doesn't have to
|
|
|
|
// cleanup all modules and object files as it exits. This just wastes time
|
|
|
|
// doing a bunch of cleanup that isn't required.
|
|
|
|
static ModuleList *g_shared_module_list = NULL;
|
|
|
|
if (g_shared_module_list == NULL)
|
|
|
|
g_shared_module_list = new ModuleList(); // <--- Intentional leak!!!
|
|
|
|
|
|
|
|
return *g_shared_module_list;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-01-28 02:45:39 +08:00
|
|
|
bool
|
|
|
|
ModuleList::ModuleIsInCache (const Module *module_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (module_ptr)
|
|
|
|
{
|
|
|
|
ModuleList &shared_module_list = GetSharedModuleList ();
|
2012-01-28 02:45:39 +08:00
|
|
|
return shared_module_list.FindModule (module_ptr).get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2012-01-28 02:45:39 +08:00
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-29 07:51:11 +08:00
|
|
|
size_t
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleList::FindSharedModules (const ModuleSpec &module_spec, ModuleList &matching_module_list)
|
2010-06-29 07:51:11 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
return GetSharedModuleList ().FindModules (module_spec, matching_module_list);
|
2010-06-29 07:51:11 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2012-04-10 04:22:01 +08:00
|
|
|
ModuleList::RemoveOrphanSharedModules (bool mandatory)
|
2011-08-11 10:48:45 +08:00
|
|
|
{
|
2012-04-10 04:22:01 +08:00
|
|
|
return GetSharedModuleList ().RemoveOrphans(mandatory);
|
2011-08-11 10:48:45 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Error
|
|
|
|
ModuleList::GetSharedModule
|
|
|
|
(
|
2012-02-26 13:51:37 +08:00
|
|
|
const ModuleSpec &module_spec,
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleSP &module_sp,
|
2012-02-14 07:10:39 +08:00
|
|
|
const FileSpecList *module_search_paths_ptr,
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleSP *old_module_sp_ptr,
|
2011-03-15 11:56:33 +08:00
|
|
|
bool *did_create_ptr,
|
|
|
|
bool always_create
|
2010-06-09 00:52:24 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ModuleList &shared_module_list = GetSharedModuleList ();
|
2011-03-15 11:56:33 +08:00
|
|
|
Mutex::Locker locker(shared_module_list.m_modules_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
char path[PATH_MAX];
|
|
|
|
|
|
|
|
Error error;
|
|
|
|
|
|
|
|
module_sp.reset();
|
|
|
|
|
|
|
|
if (did_create_ptr)
|
|
|
|
*did_create_ptr = false;
|
|
|
|
if (old_module_sp_ptr)
|
|
|
|
old_module_sp_ptr->reset();
|
|
|
|
|
2012-02-26 13:51:37 +08:00
|
|
|
const UUID *uuid_ptr = module_spec.GetUUIDPtr();
|
|
|
|
const FileSpec &module_file_spec = module_spec.GetFileSpec();
|
|
|
|
const ArchSpec &arch = module_spec.GetArchitecture();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-02-26 13:51:37 +08:00
|
|
|
// Make sure no one else can try and get or create a module while this
|
|
|
|
// function is actively working on it by doing an extra lock on the
|
|
|
|
// global mutex list.
|
|
|
|
if (always_create == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleList matching_module_list;
|
|
|
|
const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list);
|
|
|
|
if (num_matching_modules > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
for (size_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
module_sp = matching_module_list.GetModuleAtIndex(module_idx);
|
2012-07-13 06:51:12 +08:00
|
|
|
|
|
|
|
// Make sure the file for the module hasn't been modified
|
|
|
|
if (module_sp->FileHasChanged())
|
|
|
|
{
|
|
|
|
if (old_module_sp_ptr && !old_module_sp_ptr->get())
|
|
|
|
*old_module_sp_ptr = module_sp;
|
2012-10-09 06:41:53 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
|
2012-10-09 06:41:53 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("module changed: %p, removing from global module list", module_sp.get());
|
|
|
|
|
2012-07-13 06:51:12 +08:00
|
|
|
shared_module_list.Remove (module_sp);
|
|
|
|
module_sp.reset();
|
|
|
|
}
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-07-13 06:51:12 +08:00
|
|
|
// The module matches and the module was not modified from
|
|
|
|
// when it was last loaded.
|
|
|
|
return error;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-26 13:51:37 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-02-26 13:51:37 +08:00
|
|
|
if (module_sp)
|
|
|
|
return error;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
module_sp.reset (new Module (module_spec));
|
|
|
|
// Make sure there are a module and an object file since we can specify
|
|
|
|
// a valid file path with an architecture that might not be in that file.
|
|
|
|
// By getting the object file we can guarantee that the architecture matches
|
2011-03-15 11:56:33 +08:00
|
|
|
if (module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
if (module_sp->GetObjectFile())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
// If we get in here we got the correct arch, now we just need
|
|
|
|
// to verify the UUID if one was given
|
|
|
|
if (uuid_ptr && *uuid_ptr != module_sp->GetUUID())
|
|
|
|
module_sp.reset();
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
if (did_create_ptr)
|
|
|
|
*did_create_ptr = true;
|
|
|
|
|
2012-07-13 04:32:19 +08:00
|
|
|
shared_module_list.ReplaceEquivalent(module_sp);
|
2012-02-26 13:51:37 +08:00
|
|
|
return error;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2012-02-26 13:51:37 +08:00
|
|
|
else
|
|
|
|
module_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Either the file didn't exist where at the path, or no path was given, so
|
|
|
|
// we now have to use more extreme measures to try and find the appropriate
|
|
|
|
// module.
|
|
|
|
|
|
|
|
// Fixup the incoming path in case the path points to a valid file, yet
|
|
|
|
// the arch or UUID (if one was passed in) don't match.
|
2012-02-26 13:51:37 +08:00
|
|
|
FileSpec file_spec = Symbols::LocateExecutableObjectFile (module_spec);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Don't look for the file if it appears to be the same one we already
|
|
|
|
// checked for above...
|
2012-02-26 13:51:37 +08:00
|
|
|
if (file_spec != module_file_spec)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (!file_spec.Exists())
|
|
|
|
{
|
|
|
|
file_spec.GetPath(path, sizeof(path));
|
2012-01-12 13:25:17 +08:00
|
|
|
if (path[0] == '\0')
|
2012-02-26 13:51:37 +08:00
|
|
|
module_file_spec.GetPath(path, sizeof(path));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (file_spec.Exists())
|
|
|
|
{
|
2013-05-04 07:56:12 +08:00
|
|
|
std::string uuid_str;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (uuid_ptr && uuid_ptr->IsValid())
|
2013-05-04 07:56:12 +08:00
|
|
|
uuid_str = uuid_ptr->GetAsString();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (arch.IsValid())
|
|
|
|
{
|
2013-05-04 07:56:12 +08:00
|
|
|
if (!uuid_str.empty())
|
|
|
|
error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_str.c_str());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("'%s' does not exist", path);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2012-02-05 10:38:54 +08:00
|
|
|
if (error.Fail())
|
|
|
|
module_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure no one else can try and get or create a module while this
|
|
|
|
// function is actively working on it by doing an extra lock on the
|
|
|
|
// global mutex list.
|
2012-03-21 12:25:00 +08:00
|
|
|
ModuleSpec platform_module_spec(module_spec);
|
|
|
|
platform_module_spec.GetFileSpec() = file_spec;
|
|
|
|
platform_module_spec.GetPlatformFileSpec() = file_spec;
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleList matching_module_list;
|
2012-03-21 12:25:00 +08:00
|
|
|
if (shared_module_list.FindModules (platform_module_spec, matching_module_list) > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
module_sp = matching_module_list.GetModuleAtIndex(0);
|
|
|
|
|
|
|
|
// If we didn't have a UUID in mind when looking for the object file,
|
|
|
|
// then we should make sure the modification time hasn't changed!
|
2012-03-21 12:25:00 +08:00
|
|
|
if (platform_module_spec.GetUUIDPtr() == NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
TimeValue file_spec_mod_time(file_spec.GetModificationTime());
|
|
|
|
if (file_spec_mod_time.IsValid())
|
|
|
|
{
|
|
|
|
if (file_spec_mod_time != module_sp->GetModificationTime())
|
|
|
|
{
|
|
|
|
if (old_module_sp_ptr)
|
|
|
|
*old_module_sp_ptr = module_sp;
|
|
|
|
shared_module_list.Remove (module_sp);
|
|
|
|
module_sp.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (module_sp.get() == NULL)
|
|
|
|
{
|
2012-03-21 12:25:00 +08:00
|
|
|
module_sp.reset (new Module (platform_module_spec));
|
2011-08-10 10:10:13 +08:00
|
|
|
// Make sure there are a module and an object file since we can specify
|
|
|
|
// a valid file path with an architecture that might not be in that file.
|
|
|
|
// By getting the object file we can guarantee that the architecture matches
|
|
|
|
if (module_sp && module_sp->GetObjectFile())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (did_create_ptr)
|
|
|
|
*did_create_ptr = true;
|
|
|
|
|
2012-07-13 04:32:19 +08:00
|
|
|
shared_module_list.ReplaceEquivalent(module_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file_spec.GetPath(path, sizeof(path));
|
|
|
|
|
|
|
|
if (file_spec)
|
|
|
|
{
|
|
|
|
if (arch.IsValid())
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("unable to open %s architecture in '%s'", arch.GetArchitectureName(), path);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("unable to open '%s'", path);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-04 07:56:12 +08:00
|
|
|
std::string uuid_str;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (uuid_ptr && uuid_ptr->IsValid())
|
2013-05-04 07:56:12 +08:00
|
|
|
uuid_str = uuid_ptr->GetAsString();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-05-04 07:56:12 +08:00
|
|
|
if (!uuid_str.empty())
|
|
|
|
error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_str.c_str());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("cannot locate a module");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-03-15 11:56:33 +08:00
|
|
|
bool
|
|
|
|
ModuleList::RemoveSharedModule (lldb::ModuleSP &module_sp)
|
|
|
|
{
|
|
|
|
return GetSharedModuleList ().Remove (module_sp);
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:38:42 +08:00
|
|
|
bool
|
|
|
|
ModuleList::RemoveSharedModuleIfOrphaned (const Module *module_ptr)
|
|
|
|
{
|
|
|
|
return GetSharedModuleList ().RemoveIfOrphaned (module_ptr);
|
|
|
|
}
|
|
|
|
|
2013-05-21 06:29:23 +08:00
|
|
|
bool
|
|
|
|
ModuleList::LoadScriptingResourcesInTarget (Target *target,
|
|
|
|
std::list<Error>& errors,
|
2013-05-21 08:00:30 +08:00
|
|
|
Stream *feedback_stream,
|
2013-05-21 06:29:23 +08:00
|
|
|
bool continue_on_error)
|
|
|
|
{
|
|
|
|
if (!target)
|
|
|
|
return false;
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
for (auto module : m_modules)
|
|
|
|
{
|
|
|
|
Error error;
|
|
|
|
if (module)
|
|
|
|
{
|
2013-05-21 08:00:30 +08:00
|
|
|
if (!module->LoadScriptingResourceInTarget(target, error, feedback_stream))
|
2013-05-21 06:29:23 +08:00
|
|
|
{
|
2013-05-21 08:00:30 +08:00
|
|
|
if (error.Fail() && error.AsCString())
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat("unable to load scripting data for module %s - error reported was %s",
|
|
|
|
module->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
|
|
|
|
error.AsCString());
|
|
|
|
errors.push_back(error);
|
|
|
|
}
|
|
|
|
if (!continue_on_error)
|
|
|
|
return false;
|
2013-05-21 06:29:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return errors.size() == 0;
|
|
|
|
}
|