2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBModule.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/API/SBModule.h"
|
2010-09-11 02:31:35 +08:00
|
|
|
#include "lldb/API/SBAddress.h"
|
|
|
|
#include "lldb/API/SBFileSpec.h"
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
#include "lldb/API/SBModuleSpec.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2011-06-21 09:34:41 +08:00
|
|
|
#include "lldb/API/SBSymbolContextList.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/Section.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2016-02-11 05:28:13 +08:00
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2011-07-30 03:53:35 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/Symtab.h"
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-10-26 11:11:13 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::SBModule() : m_opaque_sp() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() {
|
|
|
|
ModuleSP module_sp;
|
|
|
|
Error error = ModuleList::GetSharedModule(*module_spec.m_opaque_ap, module_sp,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
if (module_sp)
|
|
|
|
SetSP(module_sp);
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
|
2010-11-06 07:17:00 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr)
|
|
|
|
: m_opaque_sp() {
|
|
|
|
ProcessSP process_sp(process.GetSP());
|
|
|
|
if (process_sp) {
|
|
|
|
m_opaque_sp = process_sp->ReadModuleFromMemory(FileSpec(), header_addr);
|
|
|
|
if (m_opaque_sp) {
|
|
|
|
Target &target = process_sp->GetTarget();
|
|
|
|
bool changed = false;
|
|
|
|
m_opaque_sp->SetLoadAddress(target, 0, true, changed);
|
|
|
|
target.GetImages().Append(m_opaque_sp);
|
2012-02-14 07:10:39 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBModule &SBModule::operator=(const SBModule &rhs) {
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::~SBModule() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBModule::IsValid() const { return m_opaque_sp.get() != NULL; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBModule::Clear() { m_opaque_sp.reset(); }
|
2011-12-20 04:39:44 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFileSpec SBModule::GetFileSpec() const {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFileSpec file_spec;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
file_spec.SetFileSpec(module_sp->GetFileSpec());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)",
|
|
|
|
static_cast<void *>(module_sp.get()),
|
|
|
|
static_cast<const void *>(file_spec.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return file_spec;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBFileSpec SBModule::GetPlatformFileSpec() const {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBFileSpec file_spec;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
file_spec.SetFileSpec(module_sp->GetPlatformFileSpec());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)",
|
|
|
|
static_cast<void *>(module_sp.get()),
|
|
|
|
static_cast<const void *>(file_spec.get()));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return file_spec;
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) {
|
|
|
|
bool result = false;
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
module_sp->SetPlatformFileSpec(*platform_file);
|
|
|
|
result = true;
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i",
|
|
|
|
static_cast<void *>(module_sp.get()),
|
|
|
|
static_cast<const void *>(platform_file.get()),
|
|
|
|
platform_file->GetPath().c_str(), result);
|
|
|
|
return result;
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBFileSpec SBModule::GetRemoteInstallFileSpec() {
|
|
|
|
SBFileSpec sb_file_spec;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
sb_file_spec.SetFileSpec(module_sp->GetRemoteInstallFileSpec());
|
|
|
|
return sb_file_spec;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
module_sp->SetRemoteInstallFileSpec(file.ref());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t *SBModule::GetUUIDBytes() const {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
const uint8_t *uuid_bytes = NULL;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
uuid_bytes = (const uint8_t *)module_sp->GetUUID().GetBytes();
|
|
|
|
|
|
|
|
if (log) {
|
|
|
|
if (uuid_bytes) {
|
|
|
|
StreamString s;
|
|
|
|
module_sp->GetUUID().Dump(&s);
|
|
|
|
log->Printf("SBModule(%p)::GetUUIDBytes () => %s",
|
|
|
|
static_cast<void *>(module_sp.get()), s.GetData());
|
|
|
|
} else
|
|
|
|
log->Printf("SBModule(%p)::GetUUIDBytes () => NULL",
|
|
|
|
static_cast<void *>(module_sp.get()));
|
|
|
|
}
|
|
|
|
return uuid_bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBModule::GetUUIDString() const {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
const char *uuid_cstr = NULL;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
// We are going to return a "const char *" value through the public
|
|
|
|
// API, so we need to constify it so it gets added permanently the
|
|
|
|
// string pool and then we don't need to worry about the lifetime of the
|
|
|
|
// string as it will never go away once it has been put into the ConstString
|
|
|
|
// string pool
|
|
|
|
uuid_cstr = ConstString(module_sp->GetUUID().GetAsString()).GetCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uuid_cstr && uuid_cstr[0]) {
|
2015-02-12 03:16:38 +08:00
|
|
|
if (log)
|
2016-09-07 04:57:50 +08:00
|
|
|
log->Printf("SBModule(%p)::GetUUIDString () => %s",
|
|
|
|
static_cast<void *>(module_sp.get()), uuid_cstr);
|
|
|
|
return uuid_cstr;
|
|
|
|
}
|
2011-04-01 08:35:55 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("SBModule(%p)::GetUUIDString () => NULL",
|
|
|
|
static_cast<void *>(module_sp.get()));
|
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBModule::operator==(const SBModule &rhs) const {
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBModule::operator!=(const SBModule &rhs) const {
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
|
|
|
return false;
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ModuleSP SBModule::GetSP() const { return m_opaque_sp; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBModule::SetSP(const ModuleSP &module_sp) { m_opaque_sp = module_sp; }
|
|
|
|
|
|
|
|
SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) {
|
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
Address addr;
|
|
|
|
if (module_sp->ResolveFileAddress(vm_addr, addr))
|
|
|
|
sb_addr.ref() = addr;
|
|
|
|
}
|
|
|
|
return sb_addr;
|
2010-09-11 02:31:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBSymbolContext
|
2016-09-07 04:57:50 +08:00
|
|
|
SBModule::ResolveSymbolContextForAddress(const SBAddress &addr,
|
|
|
|
uint32_t resolve_scope) {
|
|
|
|
SBSymbolContext sb_sc;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp && addr.IsValid())
|
|
|
|
module_sp->ResolveSymbolContextForAddress(addr.ref(), resolve_scope,
|
|
|
|
*sb_sc);
|
|
|
|
return sb_sc;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBModule::GetDescription(SBStream &description) {
|
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
module_sp->GetDescription(&strm);
|
|
|
|
} else
|
|
|
|
strm.PutCString("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBModule::GetNumCompileUnits() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
return module_sp->GetNumCompileUnits();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) {
|
|
|
|
SBCompileUnit sb_cu;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(index);
|
|
|
|
sb_cu.reset(cu_sp.get());
|
|
|
|
}
|
|
|
|
return sb_cu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) {
|
|
|
|
if (module_sp) {
|
|
|
|
SymbolVendor *symbols = module_sp->GetSymbolVendor();
|
|
|
|
if (symbols)
|
|
|
|
return symbols->GetSymtab();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBModule::GetNumSymbols() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
|
|
|
|
if (symtab)
|
|
|
|
return symtab->GetNumSymbols();
|
|
|
|
}
|
|
|
|
return 0;
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
2010-12-07 13:40:31 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBSymbol SBModule::GetSymbolAtIndex(size_t idx) {
|
|
|
|
SBSymbol sb_symbol;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
|
|
|
|
if (symtab)
|
|
|
|
sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx));
|
|
|
|
return sb_symbol;
|
2012-03-17 04:46:10 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBSymbol SBModule::FindSymbol(const char *name,
|
|
|
|
lldb::SymbolType symbol_type) {
|
|
|
|
SBSymbol sb_symbol;
|
|
|
|
if (name && name[0]) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
|
|
|
|
if (symtab)
|
|
|
|
sb_symbol.SetSymbol(symtab->FindFirstSymbolWithNameAndType(
|
|
|
|
ConstString(name), symbol_type, Symtab::eDebugAny,
|
|
|
|
Symtab::eVisibilityAny));
|
|
|
|
}
|
|
|
|
return sb_symbol;
|
2012-03-17 04:46:10 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBSymbolContextList SBModule::FindSymbols(const char *name,
|
|
|
|
lldb::SymbolType symbol_type) {
|
|
|
|
SBSymbolContextList sb_sc_list;
|
|
|
|
if (name && name[0]) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
|
|
|
|
if (symtab) {
|
|
|
|
std::vector<uint32_t> matching_symbol_indexes;
|
|
|
|
const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(
|
|
|
|
ConstString(name), symbol_type, matching_symbol_indexes);
|
|
|
|
if (num_matches) {
|
|
|
|
SymbolContext sc;
|
|
|
|
sc.module_sp = module_sp;
|
|
|
|
SymbolContextList &sc_list = *sb_sc_list;
|
|
|
|
for (size_t i = 0; i < num_matches; ++i) {
|
|
|
|
sc.symbol = symtab->SymbolAtIndex(matching_symbol_indexes[i]);
|
|
|
|
if (sc.symbol)
|
|
|
|
sc_list.Append(sc);
|
|
|
|
}
|
|
|
|
}
|
2013-07-02 03:45:50 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return sb_sc_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBModule::GetNumSections() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
// Give the symbol vendor a chance to add to the unified section list.
|
|
|
|
module_sp->GetSymbolVendor();
|
|
|
|
SectionList *section_list = module_sp->GetSectionList();
|
|
|
|
if (section_list)
|
|
|
|
return section_list->GetSize();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBSection SBModule::GetSectionAtIndex(size_t idx) {
|
|
|
|
SBSection sb_section;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
// Give the symbol vendor a chance to add to the unified section list.
|
|
|
|
module_sp->GetSymbolVendor();
|
|
|
|
SectionList *section_list = module_sp->GetSectionList();
|
|
|
|
|
|
|
|
if (section_list)
|
|
|
|
sb_section.SetSP(section_list->GetSectionAtIndex(idx));
|
|
|
|
}
|
|
|
|
return sb_section;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
|
|
|
|
uint32_t name_type_mask) {
|
|
|
|
lldb::SBSymbolContextList sb_sc_list;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (name && module_sp) {
|
|
|
|
const bool append = true;
|
|
|
|
const bool symbols_ok = true;
|
|
|
|
const bool inlines_ok = true;
|
|
|
|
module_sp->FindFunctions(ConstString(name), NULL, name_type_mask,
|
|
|
|
symbols_ok, inlines_ok, append, *sb_sc_list);
|
|
|
|
}
|
|
|
|
return sb_sc_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
|
|
|
|
uint32_t max_matches) {
|
|
|
|
SBValueList sb_value_list;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (name && module_sp) {
|
|
|
|
VariableList variable_list;
|
|
|
|
const uint32_t match_count = module_sp->FindGlobalVariables(
|
|
|
|
ConstString(name), NULL, false, max_matches, variable_list);
|
|
|
|
|
|
|
|
if (match_count > 0) {
|
|
|
|
for (uint32_t i = 0; i < match_count; ++i) {
|
|
|
|
lldb::ValueObjectSP valobj_sp;
|
|
|
|
TargetSP target_sp(target.GetSP());
|
|
|
|
valobj_sp = ValueObjectVariable::Create(
|
|
|
|
target_sp.get(), variable_list.GetVariableAtIndex(i));
|
|
|
|
if (valobj_sp)
|
|
|
|
sb_value_list.Append(SBValue(valobj_sp));
|
|
|
|
}
|
2010-12-07 13:40:31 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_value_list;
|
2010-12-07 13:40:31 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target,
|
|
|
|
const char *name) {
|
|
|
|
SBValueList sb_value_list(FindGlobalVariables(target, name, 1));
|
|
|
|
if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
|
|
|
|
return sb_value_list.GetValueAtIndex(0);
|
|
|
|
return SBValue();
|
2012-12-04 10:22:16 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBType SBModule::FindFirstType(const char *name_cstr) {
|
|
|
|
SBType sb_type;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (name_cstr && module_sp) {
|
|
|
|
SymbolContext sc;
|
|
|
|
const bool exact_match = false;
|
|
|
|
ConstString name(name_cstr);
|
2012-12-04 10:22:16 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match));
|
2012-12-04 10:22:16 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!sb_type.IsValid()) {
|
|
|
|
TypeSystem *type_system =
|
|
|
|
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
if (type_system)
|
|
|
|
sb_type = SBType(type_system->GetBuiltinTypeByName(name));
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return sb_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBType SBModule::GetBasicType(lldb::BasicType type) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
TypeSystem *type_system =
|
|
|
|
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
if (type_system)
|
|
|
|
return SBType(type_system->GetBasicTypeFromAST(type));
|
|
|
|
}
|
|
|
|
return SBType();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBTypeList SBModule::FindTypes(const char *type) {
|
|
|
|
SBTypeList retval;
|
|
|
|
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (type && module_sp) {
|
|
|
|
SymbolContext sc;
|
|
|
|
TypeList type_list;
|
|
|
|
const bool exact_match = false;
|
|
|
|
ConstString name(type);
|
|
|
|
llvm::DenseSet<SymbolFile *> searched_symbol_files;
|
|
|
|
const uint32_t num_matches = module_sp->FindTypes(
|
|
|
|
sc, name, exact_match, UINT32_MAX, searched_symbol_files, type_list);
|
|
|
|
|
|
|
|
if (num_matches > 0) {
|
|
|
|
for (size_t idx = 0; idx < num_matches; idx++) {
|
|
|
|
TypeSP type_sp(type_list.GetTypeAtIndex(idx));
|
|
|
|
if (type_sp)
|
|
|
|
retval.Append(SBType(type_sp));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TypeSystem *type_system =
|
|
|
|
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
if (type_system) {
|
|
|
|
CompilerType compiler_type = type_system->GetBuiltinTypeByName(name);
|
|
|
|
if (compiler_type)
|
|
|
|
retval.Append(SBType(compiler_type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return retval;
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
SymbolVendor *vendor = module_sp->GetSymbolVendor();
|
|
|
|
if (vendor) {
|
|
|
|
Type *type_ptr = vendor->ResolveTypeUID(uid);
|
|
|
|
if (type_ptr)
|
|
|
|
return SBType(type_ptr->shared_from_this());
|
2011-06-21 09:34:41 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return SBType();
|
2012-12-06 05:24:42 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) {
|
|
|
|
SBTypeList sb_type_list;
|
2011-07-30 03:53:35 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
SymbolVendor *vendor = module_sp->GetSymbolVendor();
|
|
|
|
if (vendor) {
|
|
|
|
TypeList type_list;
|
|
|
|
vendor->GetTypes(NULL, type_mask, type_list);
|
|
|
|
sb_type_list.m_opaque_ap->Append(type_list);
|
2014-01-24 05:38:34 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return sb_type_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBSection SBModule::FindSection(const char *sect_name) {
|
|
|
|
SBSection sb_section;
|
|
|
|
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (sect_name && module_sp) {
|
|
|
|
// Give the symbol vendor a chance to add to the unified section list.
|
|
|
|
module_sp->GetSymbolVendor();
|
|
|
|
SectionList *section_list = module_sp->GetSectionList();
|
|
|
|
if (section_list) {
|
|
|
|
ConstString const_sect_name(sect_name);
|
|
|
|
SectionSP section_sp(section_list->FindSectionByName(const_sect_name));
|
|
|
|
if (section_sp) {
|
|
|
|
sb_section.SetSP(section_sp);
|
|
|
|
}
|
2013-06-19 06:51:05 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return sb_section;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ByteOrder SBModule::GetByteOrder() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
return module_sp->GetArchitecture().GetByteOrder();
|
|
|
|
return eByteOrderInvalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBModule::GetTriple() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
std::string triple(module_sp->GetArchitecture().GetTriple().str());
|
|
|
|
// Unique the string so we don't run into ownership issues since
|
|
|
|
// the const strings put the string into the string pool once and
|
|
|
|
// the strings never comes out
|
|
|
|
ConstString const_triple(triple.c_str());
|
|
|
|
return const_triple.GetCString();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBModule::GetAddressByteSize() {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
return module_sp->GetArchitecture().GetAddressByteSize();
|
|
|
|
return sizeof(void *);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp)
|
|
|
|
return module_sp->GetVersion(versions, num_versions);
|
|
|
|
else {
|
|
|
|
if (versions && num_versions) {
|
|
|
|
for (uint32_t i = 0; i < num_versions; ++i)
|
|
|
|
versions[i] = UINT32_MAX;
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
|
|
|
|
lldb::SBFileSpec sb_file_spec;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
SymbolVendor *symbol_vendor_ptr = module_sp->GetSymbolVendor();
|
|
|
|
if (symbol_vendor_ptr)
|
|
|
|
sb_file_spec.SetFileSpec(symbol_vendor_ptr->GetMainFileSpec());
|
|
|
|
}
|
|
|
|
return sb_file_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const {
|
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
ModuleSP module_sp(GetSP());
|
|
|
|
if (module_sp) {
|
|
|
|
ObjectFile *objfile_ptr = module_sp->GetObjectFile();
|
|
|
|
if (objfile_ptr)
|
|
|
|
sb_addr.ref() = objfile_ptr->GetHeaderAddress();
|
|
|
|
}
|
|
|
|
return sb_addr;
|
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-11 05:59:55 +08:00
|
|
|
}
|