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"
|
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(),
|
|
|
|
m_modules_mutex (Mutex::eMutexTypeRecursive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Copy constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ModuleList::ModuleList(const ModuleList& rhs) :
|
|
|
|
m_modules(rhs.m_modules)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Assignment operator
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const ModuleList&
|
|
|
|
ModuleList::operator= (const ModuleList& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
m_modules = rhs.m_modules;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ModuleList::~ModuleList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-24 08:52:29 +08:00
|
|
|
ModuleList::Append (const ModuleSP &module_sp)
|
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);
|
|
|
|
}
|
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.
|
|
|
|
m_modules.push_back(module_sp);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-09-24 08:52:29 +08:00
|
|
|
ModuleList::Remove (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)
|
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);
|
|
|
|
return true;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-11 10:48:45 +08:00
|
|
|
|
|
|
|
size_t
|
|
|
|
ModuleList::RemoveOrphans ()
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
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())
|
|
|
|
{
|
|
|
|
pos = m_modules.erase (pos);
|
|
|
|
++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()
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
m_modules.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
Module*
|
|
|
|
ModuleList::GetModulePointerAtIndex (uint32_t idx) const
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
if (idx < m_modules.size())
|
|
|
|
return m_modules[idx].get();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSP
|
|
|
|
ModuleList::GetModuleAtIndex(uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
ModuleSP module_sp;
|
|
|
|
if (idx < m_modules.size())
|
|
|
|
module_sp = m_modules[idx];
|
|
|
|
return module_sp;
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:59:51 +08:00
|
|
|
uint32_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindFunctions (const ConstString &name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
bool include_symbols,
|
|
|
|
bool append,
|
|
|
|
SymbolContextList &sc_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-27 08:55:47 +08:00
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
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)
|
|
|
|
{
|
2011-10-12 10:08:07 +08:00
|
|
|
(*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, true, sc_list);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-07-27 08:55:47 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sc_list.GetSize();
|
|
|
|
}
|
|
|
|
|
2011-07-07 09:59:51 +08:00
|
|
|
uint32_t
|
|
|
|
ModuleList::FindCompileUnits (const FileSpec &path,
|
|
|
|
bool append,
|
|
|
|
SymbolContextList &sc_list)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindGlobalVariables (const ConstString &name,
|
|
|
|
bool append,
|
|
|
|
uint32_t max_matches,
|
|
|
|
VariableList& variable_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
size_t initial_size = variable_list.GetSize();
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
2011-01-27 14:44:37 +08:00
|
|
|
ModuleList::FindGlobalVariables (const RegularExpression& regex,
|
|
|
|
bool append,
|
|
|
|
uint32_t max_matches,
|
|
|
|
VariableList& variable_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
size_t initial_size = variable_list.GetSize();
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
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,
|
|
|
|
bool append)
|
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();
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
collection::iterator pos, end = m_modules.end();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
|
|
|
|
lldb::SymbolType symbol_type,
|
|
|
|
SymbolContextList &sc_list,
|
|
|
|
bool append)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
class ModuleMatches
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
/// Construct with the user ID to look for.
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
ModuleMatches (const FileSpec *file_spec_ptr,
|
|
|
|
const ArchSpec *arch_ptr,
|
2011-02-05 02:53:10 +08:00
|
|
|
const lldb_private::UUID *uuid_ptr,
|
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
|
|
|
const ConstString *object_name,
|
|
|
|
bool file_spec_is_platform) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_file_spec_ptr (file_spec_ptr),
|
|
|
|
m_arch_ptr (arch_ptr),
|
|
|
|
m_uuid_ptr (uuid_ptr),
|
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
|
|
|
m_object_name (object_name),
|
|
|
|
m_file_spec_compare_basename_only (false),
|
|
|
|
m_file_spec_is_platform (file_spec_is_platform)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
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
|
|
|
if (file_spec_ptr)
|
|
|
|
m_file_spec_compare_basename_only = file_spec_ptr->GetDirectory();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//--------------------------------------------------------------
|
|
|
|
/// Unary predicate function object callback.
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
bool
|
|
|
|
operator () (const ModuleSP& module_sp) const
|
|
|
|
{
|
|
|
|
if (m_file_spec_ptr)
|
|
|
|
{
|
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
|
|
|
if (m_file_spec_is_platform)
|
|
|
|
{
|
|
|
|
if (!FileSpec::Equal (*m_file_spec_ptr,
|
|
|
|
module_sp->GetPlatformFileSpec(),
|
|
|
|
m_file_spec_compare_basename_only))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!FileSpec::Equal (*m_file_spec_ptr,
|
|
|
|
module_sp->GetFileSpec(),
|
|
|
|
m_file_spec_compare_basename_only))
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-12-08 13:08:21 +08:00
|
|
|
if (m_arch_ptr && m_arch_ptr->IsValid())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (module_sp->GetArchitecture() != *m_arch_ptr)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-08 13:08:21 +08:00
|
|
|
if (m_uuid_ptr && m_uuid_ptr->IsValid())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (module_sp->GetUUID() != *m_uuid_ptr)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_object_name)
|
|
|
|
{
|
|
|
|
if (module_sp->GetObjectName() != *m_object_name)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
// Member variables.
|
|
|
|
//--------------------------------------------------------------
|
2011-02-05 02:53:10 +08:00
|
|
|
const FileSpec * m_file_spec_ptr;
|
|
|
|
const ArchSpec * m_arch_ptr;
|
|
|
|
const lldb_private::UUID * m_uuid_ptr;
|
|
|
|
const ConstString * m_object_name;
|
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
|
|
|
bool m_file_spec_compare_basename_only;
|
|
|
|
bool m_file_spec_is_platform;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ModuleList::FindModules
|
|
|
|
(
|
|
|
|
const FileSpec *file_spec_ptr,
|
|
|
|
const ArchSpec *arch_ptr,
|
2011-02-05 02:53:10 +08:00
|
|
|
const lldb_private::UUID *uuid_ptr,
|
2010-06-09 00:52:24 +08:00
|
|
|
const ConstString *object_name,
|
|
|
|
ModuleList& matching_module_list
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
size_t existing_matches = matching_module_list.GetSize();
|
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
|
|
|
ModuleMatches matcher (file_spec_ptr, arch_ptr, uuid_ptr, object_name, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator end = m_modules.end();
|
|
|
|
collection::const_iterator pos;
|
|
|
|
|
|
|
|
for (pos = std::find_if (m_modules.begin(), end, matcher);
|
|
|
|
pos != end;
|
|
|
|
pos = std::find_if (++pos, end, matcher))
|
|
|
|
{
|
|
|
|
ModuleSP module_sp(*pos);
|
|
|
|
matching_module_list.Append(module_sp);
|
|
|
|
}
|
|
|
|
return matching_module_list.GetSize() - existing_matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModuleSP
|
2010-08-25 05:05:24 +08:00
|
|
|
ModuleList::FindModule (const Module *module_ptr)
|
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
|
|
|
|
ModuleList::FindModule (const UUID &uuid)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2010-08-03 09:26:16 +08:00
|
|
|
uint32_t
|
2011-07-30 03:53:35 +08:00
|
|
|
ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types)
|
2010-08-03 09:26:16 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
|
|
|
|
if (!append)
|
|
|
|
types.Clear();
|
|
|
|
|
|
|
|
uint32_t total_matches = 0;
|
|
|
|
collection::const_iterator pos, end = m_modules.end();
|
|
|
|
for (pos = m_modules.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (sc.module_sp.get() == NULL || sc.module_sp.get() == (*pos).get())
|
2011-10-12 10:08:07 +08:00
|
|
|
total_matches += (*pos)->FindTypes (sc, name, NULL, true, max_matches, types);
|
2010-08-03 09:26:16 +08:00
|
|
|
|
|
|
|
if (total_matches >= max_matches)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return total_matches;
|
|
|
|
}
|
|
|
|
|
2011-07-30 03:53:35 +08:00
|
|
|
// depending on implementation details, type lookup might fail because of
|
|
|
|
// embedded spurious namespace:: prefixes. this call strips them, paying
|
|
|
|
// attention to the fact that a type might have namespace'd type names as
|
|
|
|
// arguments to templates, and those must not be stripped off
|
|
|
|
static const char*
|
|
|
|
StripTypeName(const char* name_cstr)
|
|
|
|
{
|
|
|
|
const char* skip_namespace = strstr(name_cstr, "::");
|
|
|
|
const char* template_arg_char = strchr(name_cstr, '<');
|
|
|
|
while (skip_namespace != NULL)
|
|
|
|
{
|
|
|
|
if (template_arg_char != NULL &&
|
|
|
|
skip_namespace > template_arg_char) // but namespace'd template arguments are still good to go
|
|
|
|
break;
|
|
|
|
name_cstr = skip_namespace+2;
|
|
|
|
skip_namespace = strstr(name_cstr, "::");
|
|
|
|
}
|
|
|
|
return name_cstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types)
|
|
|
|
{
|
|
|
|
uint32_t retval = FindTypes_Impl(sc, name, append, max_matches, types);
|
|
|
|
|
|
|
|
if (retval == 0)
|
|
|
|
{
|
|
|
|
const char *stripped = StripTypeName(name.GetCString());
|
|
|
|
return FindTypes_Impl(sc, ConstString(stripped), append, max_matches, types);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
}
|
2010-08-03 09:26:16 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ModuleSP
|
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
|
|
|
ModuleList::FindFirstModuleForFileSpec (const FileSpec &file_spec,
|
|
|
|
const ArchSpec *arch_ptr,
|
|
|
|
const ConstString *object_name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ModuleSP 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
|
|
|
ModuleMatches matcher (&file_spec,
|
|
|
|
arch_ptr,
|
|
|
|
NULL,
|
|
|
|
object_name,
|
|
|
|
false);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Scope for "locker"
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator end = m_modules.end();
|
|
|
|
collection::const_iterator pos = m_modules.begin();
|
|
|
|
|
|
|
|
pos = std::find_if (pos, end, matcher);
|
|
|
|
if (pos != end)
|
|
|
|
module_sp = (*pos);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
ModuleList::FindFirstModuleForPlatormFileSpec (const FileSpec &file_spec,
|
|
|
|
const ArchSpec *arch_ptr,
|
|
|
|
const ConstString *object_name)
|
|
|
|
{
|
|
|
|
ModuleSP module_sp;
|
|
|
|
ModuleMatches matcher (&file_spec,
|
|
|
|
arch_ptr,
|
|
|
|
NULL,
|
|
|
|
object_name,
|
|
|
|
true);
|
|
|
|
|
|
|
|
// Scope for "locker"
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
collection::const_iterator end = m_modules.end();
|
|
|
|
collection::const_iterator pos = m_modules.begin();
|
|
|
|
|
|
|
|
pos = std::find_if (pos, end, matcher);
|
|
|
|
if (pos != end)
|
|
|
|
module_sp = (*pos);
|
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
ModuleList::LogUUIDAndPaths (LogSP &log_sp, const char *prefix_cstr)
|
|
|
|
{
|
|
|
|
if (log_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker(m_modules_mutex);
|
|
|
|
char uuid_cstr[256];
|
|
|
|
collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
Module *module = pos->get();
|
|
|
|
module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr));
|
|
|
|
const FileSpec &module_file_spec = module->GetFileSpec();
|
|
|
|
log_sp->Printf ("%s[%u] %s (%s) \"%s/%s\"",
|
|
|
|
prefix_cstr ? prefix_cstr : "",
|
|
|
|
(uint32_t)std::distance (begin, pos),
|
|
|
|
uuid_cstr,
|
2011-02-23 08:35:02 +08:00
|
|
|
module->GetArchitecture().GetArchitectureName(),
|
2010-12-14 10:59:59 +08:00
|
|
|
module_file_spec.GetDirectory().GetCString(),
|
|
|
|
module_file_spec.GetFilename().GetCString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
|
|
|
|
{
|
|
|
|
// The address is already section offset so it has a module
|
|
|
|
uint32_t resolved_flags = 0;
|
|
|
|
Module *module = so_addr.GetModule();
|
|
|
|
if (module)
|
|
|
|
{
|
|
|
|
resolved_flags = module->ResolveSymbolContextForAddress (so_addr,
|
|
|
|
resolve_scope,
|
|
|
|
sc);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
)
|
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
|
|
|
|
ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
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 ()
|
|
|
|
{
|
|
|
|
static ModuleList g_shared_module_list;
|
|
|
|
return g_shared_module_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lldb::ModuleSP
|
2010-08-25 05:05:24 +08:00
|
|
|
ModuleList::GetModuleSP (const Module *module_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
lldb::ModuleSP module_sp;
|
|
|
|
if (module_ptr)
|
|
|
|
{
|
|
|
|
ModuleList &shared_module_list = GetSharedModuleList ();
|
|
|
|
module_sp = shared_module_list.FindModule (module_ptr);
|
2010-12-21 07:42:12 +08:00
|
|
|
if (module_sp.get() == NULL)
|
|
|
|
{
|
|
|
|
char uuid_cstr[256];
|
|
|
|
const_cast<Module *>(module_ptr)->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr));
|
|
|
|
const FileSpec &module_file_spec = module_ptr->GetFileSpec();
|
2012-01-05 11:57:59 +08:00
|
|
|
Host::SystemLog (Host::eSystemLogWarning,
|
|
|
|
"warning: module not in shared module list: %s (%s) \"%s/%s\"\n",
|
|
|
|
uuid_cstr,
|
|
|
|
module_ptr->GetArchitecture().GetArchitectureName(),
|
|
|
|
module_file_spec.GetDirectory().GetCString(),
|
|
|
|
module_file_spec.GetFilename().GetCString());
|
2010-12-21 07:42:12 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
}
|
|
|
|
|
2010-06-29 07:51:11 +08:00
|
|
|
size_t
|
|
|
|
ModuleList::FindSharedModules
|
|
|
|
(
|
|
|
|
const FileSpec& in_file_spec,
|
|
|
|
const ArchSpec& arch,
|
2011-02-05 02:53:10 +08:00
|
|
|
const lldb_private::UUID *uuid_ptr,
|
2010-06-29 07:51:11 +08:00
|
|
|
const ConstString *object_name_ptr,
|
|
|
|
ModuleList &matching_module_list
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ModuleList &shared_module_list = GetSharedModuleList ();
|
|
|
|
return shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-08-11 10:48:45 +08:00
|
|
|
uint32_t
|
|
|
|
ModuleList::RemoveOrphanSharedModules ()
|
|
|
|
{
|
|
|
|
return GetSharedModuleList ().RemoveOrphans();
|
|
|
|
}
|
2011-08-13 05:40:01 +08:00
|
|
|
//#define ENABLE_MODULE_SP_LOGGING
|
|
|
|
#if defined (ENABLE_MODULE_SP_LOGGING)
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Host/Host.h"
|
|
|
|
static void
|
|
|
|
ModuleSharedPtrLogger(void* p, const ModuleSP& sp, bool will_decrement)
|
|
|
|
{
|
|
|
|
if (sp.get())
|
|
|
|
{
|
|
|
|
const char *module_basename = sp->GetFileSpec().GetFilename().GetCString();
|
|
|
|
// If "p" is set, then it is the basename of a module to watch for. This
|
|
|
|
// basename MUST be uniqued first by getting it from a ConstString or this
|
|
|
|
// won't work.
|
|
|
|
if (p && p != module_basename)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
long use_count = sp.use_count();
|
|
|
|
if (will_decrement)
|
|
|
|
--use_count;
|
|
|
|
|
|
|
|
printf("\nModuleSP(%p): %c %p {%lu} %s/%s\n", &sp, will_decrement ? '-' : '+', sp.get(), use_count, sp->GetFileSpec().GetDirectory().GetCString(), module_basename);
|
|
|
|
StreamFile stdout_strm(stdout, false);
|
|
|
|
Host::Backtrace (stdout_strm, 512);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-08-11 10:48:45 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Error
|
|
|
|
ModuleList::GetSharedModule
|
|
|
|
(
|
|
|
|
const FileSpec& in_file_spec,
|
|
|
|
const ArchSpec& arch,
|
2011-02-05 02:53:10 +08:00
|
|
|
const lldb_private::UUID *uuid_ptr,
|
2010-06-09 00:52:24 +08:00
|
|
|
const ConstString *object_name_ptr,
|
|
|
|
off_t object_offset,
|
|
|
|
ModuleSP &module_sp,
|
|
|
|
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];
|
|
|
|
char uuid_cstr[64];
|
|
|
|
|
|
|
|
Error error;
|
|
|
|
|
|
|
|
module_sp.reset();
|
|
|
|
|
|
|
|
if (did_create_ptr)
|
|
|
|
*did_create_ptr = false;
|
|
|
|
if (old_module_sp_ptr)
|
|
|
|
old_module_sp_ptr->reset();
|
|
|
|
|
|
|
|
|
|
|
|
// First just try and get the file where it purports to be (path in
|
|
|
|
// in_file_spec), then check and uuid.
|
|
|
|
|
|
|
|
if (in_file_spec)
|
|
|
|
{
|
|
|
|
// 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.
|
2011-03-15 11:56:33 +08:00
|
|
|
if (always_create == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-15 11:56:33 +08:00
|
|
|
ModuleList matching_module_list;
|
|
|
|
const size_t num_matching_modules = shared_module_list.FindModules (&in_file_spec, &arch, NULL, object_name_ptr, matching_module_list);
|
|
|
|
if (num_matching_modules > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-15 11:56:33 +08:00
|
|
|
for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-15 11:56:33 +08:00
|
|
|
module_sp = matching_module_list.GetModuleAtIndex(module_idx);
|
|
|
|
if (uuid_ptr && uuid_ptr->IsValid())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-15 11:56:33 +08:00
|
|
|
// We found the module we were looking for.
|
|
|
|
if (module_sp->GetUUID() == *uuid_ptr)
|
|
|
|
return error;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-03-15 11:56:33 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// 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!
|
|
|
|
TimeValue file_spec_mod_time(in_file_spec.GetModificationTime());
|
|
|
|
if (file_spec_mod_time.IsValid())
|
|
|
|
{
|
|
|
|
if (file_spec_mod_time == module_sp->GetModificationTime())
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (old_module_sp_ptr && !old_module_sp_ptr->get())
|
|
|
|
*old_module_sp_ptr = module_sp;
|
|
|
|
shared_module_list.Remove (module_sp);
|
|
|
|
module_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-15 11:56:33 +08:00
|
|
|
if (module_sp)
|
|
|
|
return error;
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-08-13 05:40:01 +08:00
|
|
|
#if defined ENABLE_MODULE_SP_LOGGING
|
|
|
|
ModuleSP logging_module_sp (new Module (in_file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, (void *)ConstString("a.out").GetCString());
|
|
|
|
module_sp = logging_module_sp;
|
|
|
|
#else
|
2010-06-09 00:52:24 +08:00
|
|
|
module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset));
|
2011-08-13 05:40:01 +08:00
|
|
|
#endif
|
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 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
|
|
|
|
{
|
|
|
|
if (did_create_ptr)
|
|
|
|
*did_create_ptr = true;
|
2011-08-10 10:10:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
shared_module_list.Append(module_sp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2011-07-19 11:57:15 +08:00
|
|
|
FileSpec file_spec = Symbols::LocateExecutableObjectFile (in_file_spec ? &in_file_spec : NULL,
|
|
|
|
arch.IsValid() ? &arch : NULL,
|
|
|
|
uuid_ptr);
|
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...
|
|
|
|
if (file_spec != in_file_spec)
|
|
|
|
{
|
|
|
|
if (!file_spec.Exists())
|
|
|
|
{
|
|
|
|
file_spec.GetPath(path, sizeof(path));
|
|
|
|
if (file_spec.Exists())
|
|
|
|
{
|
|
|
|
if (uuid_ptr && uuid_ptr->IsValid())
|
|
|
|
uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr));
|
|
|
|
else
|
|
|
|
uuid_cstr[0] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
if (arch.IsValid())
|
|
|
|
{
|
|
|
|
if (uuid_cstr[0])
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_cstr);
|
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
|
|
|
}
|
|
|
|
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.
|
|
|
|
ModuleList matching_module_list;
|
|
|
|
if (shared_module_list.FindModules (&file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list) > 0)
|
|
|
|
{
|
|
|
|
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!
|
|
|
|
if (uuid_ptr == NULL)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2011-08-13 05:40:01 +08:00
|
|
|
#if defined ENABLE_MODULE_SP_LOGGING
|
|
|
|
ModuleSP logging_module_sp (new Module (file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, 0);
|
|
|
|
module_sp = logging_module_sp;
|
|
|
|
#else
|
2010-06-09 00:52:24 +08:00
|
|
|
module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset));
|
2011-08-13 05:40:01 +08:00
|
|
|
#endif
|
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;
|
|
|
|
|
|
|
|
shared_module_list.Append(module_sp);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if (uuid_ptr && uuid_ptr->IsValid())
|
|
|
|
uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr));
|
|
|
|
else
|
|
|
|
uuid_cstr[0] = '\0';
|
|
|
|
|
|
|
|
if (uuid_cstr[0])
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_cstr);
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|