2010-06-09 00:52:24 +08:00
|
|
|
//===-- Module.cpp ----------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
#include "llvm/Support/raw_os_ostream.h"
|
|
|
|
#include "llvm/Support/Signals.h"
|
|
|
|
|
|
|
|
// Project includes
|
2013-09-12 10:20:34 +08:00
|
|
|
#include "lldb/Core/AddressResolverFileLine.h"
|
2012-11-08 10:22:02 +08:00
|
|
|
#include "lldb/Core/Error.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/Core/DataBuffer.h"
|
|
|
|
#include "lldb/Core/DataBufferHeap.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/ModuleList.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
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/Core/PluginManager.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/RegularExpression.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-11-28 09:45:00 +08:00
|
|
|
#include "lldb/Core/StreamString.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Timer.h"
|
2012-01-05 11:57:59 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2012-11-08 10:22:02 +08:00
|
|
|
#include "lldb/Host/Symbols.h"
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/ScriptInterpreter.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/CompileUnit.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.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/SymbolFile.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.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"
|
2015-09-02 09:06:46 +08:00
|
|
|
#include "lldb/Target/Language.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-06 09:12:00 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2015-09-02 09:59:14 +08:00
|
|
|
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
|
|
|
|
#include "Plugins/Language/ObjC/ObjCLanguage.h"
|
2015-10-08 17:45:41 +08:00
|
|
|
#include "lldb/Symbol/TypeMap.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2011-08-09 08:01:09 +08:00
|
|
|
// Shared pointers to modules track module lifetimes in
|
|
|
|
// targets and in the global module, but this collection
|
|
|
|
// will track all module objects that are still alive
|
|
|
|
typedef std::vector<Module *> ModuleCollection;
|
|
|
|
|
|
|
|
static ModuleCollection &
|
|
|
|
GetModuleCollection()
|
|
|
|
{
|
2011-11-01 07:47:10 +08:00
|
|
|
// This module collection needs to live past any module, so we could either make it a
|
|
|
|
// shared pointer in each module or just leak is. Since it is only an empty vector by
|
|
|
|
// the time all the modules have gone away, we just leak it for now. If we decide this
|
|
|
|
// is a big problem we can introduce a Finalize method that will tear everything down in
|
|
|
|
// a predictable order.
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
static ModuleCollection *g_module_collection = nullptr;
|
|
|
|
if (g_module_collection == nullptr)
|
2011-11-01 07:47:10 +08:00
|
|
|
g_module_collection = new ModuleCollection();
|
|
|
|
|
|
|
|
return *g_module_collection;
|
2011-08-09 08:01:09 +08:00
|
|
|
}
|
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
std::recursive_mutex &
|
2011-08-09 08:01:09 +08:00
|
|
|
Module::GetAllocationModuleCollectionMutex()
|
|
|
|
{
|
2012-01-28 02:08:35 +08:00
|
|
|
// NOTE: The mutex below must be leaked since the global module list in
|
|
|
|
// the ModuleList class will get torn at some point, and we can't know
|
|
|
|
// if it will tear itself down before the "g_module_collection_mutex" below
|
|
|
|
// will. So we leak a Mutex object below to safeguard against that
|
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
static std::recursive_mutex *g_module_collection_mutex = nullptr;
|
2016-03-12 04:20:38 +08:00
|
|
|
if (g_module_collection_mutex == nullptr)
|
2016-05-18 09:59:10 +08:00
|
|
|
g_module_collection_mutex = new std::recursive_mutex; // NOTE: known leak
|
|
|
|
return *g_module_collection_mutex;
|
2011-08-09 08:01:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
Module::GetNumberAllocatedModules ()
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2011-08-09 08:01:09 +08:00
|
|
|
return GetModuleCollection().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
Module *
|
|
|
|
Module::GetAllocatedModuleAtIndex (size_t idx)
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2011-08-09 08:01:09 +08:00
|
|
|
ModuleCollection &modules = GetModuleCollection();
|
|
|
|
if (idx < modules.size())
|
|
|
|
return modules[idx];
|
2016-03-12 04:20:38 +08:00
|
|
|
return nullptr;
|
2011-08-09 08:01:09 +08:00
|
|
|
}
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
#if 0
|
2012-01-28 02:45:39 +08:00
|
|
|
// These functions help us to determine if modules are still loaded, yet don't require that
|
|
|
|
// you have a command interpreter and can easily be called from an external debugger.
|
|
|
|
namespace lldb {
|
2011-08-09 08:01:09 +08:00
|
|
|
|
2012-01-28 02:45:39 +08:00
|
|
|
void
|
|
|
|
ClearModuleInfo (void)
|
|
|
|
{
|
2012-04-10 04:22:01 +08:00
|
|
|
const bool mandatory = true;
|
|
|
|
ModuleList::RemoveOrphanSharedModules(mandatory);
|
2012-01-28 02:45:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DumpModuleInfo (void)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (Module::GetAllocationModuleCollectionMutex());
|
|
|
|
ModuleCollection &modules = GetModuleCollection();
|
|
|
|
const size_t count = modules.size();
|
2016-08-10 07:06:08 +08:00
|
|
|
printf ("%s: %" PRIu64 " modules:\n", LLVM_PRETTY_FUNCTION, (uint64_t)count);
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t i = 0; i < count; ++i)
|
2012-01-28 02:45:39 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
StreamString strm;
|
|
|
|
Module *module = modules[i];
|
|
|
|
const bool in_shared_module_list = ModuleList::ModuleIsInCache (module);
|
|
|
|
module->GetDescription(&strm, eDescriptionLevelFull);
|
|
|
|
printf ("%p: shared = %i, ref_count = %3u, module = %s\n",
|
|
|
|
module,
|
|
|
|
in_shared_module_list,
|
|
|
|
(uint32_t)module->use_count(),
|
|
|
|
strm.GetString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2012-10-09 06:41:53 +08:00
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
Module::Module(const ModuleSpec &module_spec)
|
|
|
|
: m_mutex(),
|
|
|
|
m_mod_time(),
|
|
|
|
m_arch(),
|
|
|
|
m_uuid(),
|
|
|
|
m_file(),
|
|
|
|
m_platform_file(),
|
|
|
|
m_remote_install_file(),
|
|
|
|
m_symfile_spec(),
|
|
|
|
m_object_name(),
|
|
|
|
m_object_offset(),
|
|
|
|
m_object_mod_time(),
|
|
|
|
m_objfile_sp(),
|
|
|
|
m_symfile_ap(),
|
|
|
|
m_type_system_map(),
|
|
|
|
m_source_mappings(),
|
|
|
|
m_sections_ap(),
|
|
|
|
m_did_load_objfile(false),
|
|
|
|
m_did_load_symbol_vendor(false),
|
|
|
|
m_did_parse_uuid(false),
|
|
|
|
m_file_has_changed(false),
|
|
|
|
m_first_file_changed_log(false)
|
2012-02-26 13:51:37 +08:00
|
|
|
{
|
|
|
|
// Scope for locker below...
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2012-02-26 13:51:37 +08:00
|
|
|
GetModuleCollection().push_back(this);
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES));
|
2016-03-12 04:20:38 +08:00
|
|
|
if (log != nullptr)
|
2016-05-18 09:59:10 +08:00
|
|
|
log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this),
|
|
|
|
module_spec.GetArchitecture().GetArchitectureName(), module_spec.GetFileSpec().GetPath().c_str(),
|
|
|
|
module_spec.GetObjectName().IsEmpty() ? "" : "(",
|
|
|
|
module_spec.GetObjectName().IsEmpty() ? "" : module_spec.GetObjectName().AsCString(""),
|
|
|
|
module_spec.GetObjectName().IsEmpty() ? "" : ")");
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2014-03-05 05:20:23 +08:00
|
|
|
// First extract all module specifications from the file using the local
|
|
|
|
// file path. If there are no specifications, then don't fill anything in
|
|
|
|
ModuleSpecList modules_specs;
|
|
|
|
if (ObjectFile::GetModuleSpecifications(module_spec.GetFileSpec(), 0, 0, modules_specs) == 0)
|
|
|
|
return;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2014-03-05 05:20:23 +08:00
|
|
|
// Now make sure that one of the module specifications matches what we just
|
|
|
|
// extract. We might have a module specification that specifies a file "/usr/lib/dyld"
|
|
|
|
// with UUID XXX, but we might have a local version of "/usr/lib/dyld" that has
|
|
|
|
// UUID YYY and we don't want those to match. If they don't match, just don't
|
|
|
|
// fill any ivars in so we don't accidentally grab the wrong file later since
|
|
|
|
// they don't match...
|
|
|
|
ModuleSpec matching_module_spec;
|
|
|
|
if (modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec) == 0)
|
|
|
|
return;
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-05-30 05:33:45 +08:00
|
|
|
if (module_spec.GetFileSpec())
|
|
|
|
m_mod_time = module_spec.GetFileSpec().GetModificationTime();
|
|
|
|
else if (matching_module_spec.GetFileSpec())
|
|
|
|
m_mod_time = matching_module_spec.GetFileSpec().GetModificationTime();
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-05-30 05:33:45 +08:00
|
|
|
// Copy the architecture from the actual spec if we got one back, else use the one that was specified
|
|
|
|
if (matching_module_spec.GetArchitecture().IsValid())
|
|
|
|
m_arch = matching_module_spec.GetArchitecture();
|
|
|
|
else if (module_spec.GetArchitecture().IsValid())
|
2014-03-05 05:20:23 +08:00
|
|
|
m_arch = module_spec.GetArchitecture();
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-07-02 05:22:11 +08:00
|
|
|
// Copy the file spec over and use the specified one (if there was one) so we
|
2014-05-30 05:33:45 +08:00
|
|
|
// don't use a path that might have gotten resolved a path in 'matching_module_spec'
|
|
|
|
if (module_spec.GetFileSpec())
|
|
|
|
m_file = module_spec.GetFileSpec();
|
|
|
|
else if (matching_module_spec.GetFileSpec())
|
|
|
|
m_file = matching_module_spec.GetFileSpec();
|
|
|
|
|
|
|
|
// Copy the platform file spec over
|
|
|
|
if (module_spec.GetPlatformFileSpec())
|
|
|
|
m_platform_file = module_spec.GetPlatformFileSpec();
|
|
|
|
else if (matching_module_spec.GetPlatformFileSpec())
|
|
|
|
m_platform_file = matching_module_spec.GetPlatformFileSpec();
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-05-30 05:33:45 +08:00
|
|
|
// Copy the symbol file spec over
|
|
|
|
if (module_spec.GetSymbolFileSpec())
|
|
|
|
m_symfile_spec = module_spec.GetSymbolFileSpec();
|
|
|
|
else if (matching_module_spec.GetSymbolFileSpec())
|
|
|
|
m_symfile_spec = matching_module_spec.GetSymbolFileSpec();
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-05-30 05:33:45 +08:00
|
|
|
// Copy the object name over
|
|
|
|
if (matching_module_spec.GetObjectName())
|
|
|
|
m_object_name = matching_module_spec.GetObjectName();
|
2014-03-05 05:20:23 +08:00
|
|
|
else
|
2014-05-30 05:33:45 +08:00
|
|
|
m_object_name = module_spec.GetObjectName();
|
2016-05-18 09:59:10 +08:00
|
|
|
|
2014-05-30 05:33:45 +08:00
|
|
|
// Always trust the object offset (file offset) and object modification
|
|
|
|
// time (for mod time in a BSD static archive) of from the matching
|
|
|
|
// module specification
|
2014-05-30 01:52:46 +08:00
|
|
|
m_object_offset = matching_module_spec.GetObjectOffset();
|
|
|
|
m_object_mod_time = matching_module_spec.GetObjectModificationTime();
|
2012-02-26 13:51:37 +08:00
|
|
|
}
|
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name,
|
|
|
|
lldb::offset_t object_offset, const TimeValue *object_mod_time_ptr)
|
|
|
|
: m_mutex(),
|
|
|
|
m_mod_time(file_spec.GetModificationTime()),
|
|
|
|
m_arch(arch),
|
|
|
|
m_uuid(),
|
|
|
|
m_file(file_spec),
|
|
|
|
m_platform_file(),
|
|
|
|
m_remote_install_file(),
|
|
|
|
m_symfile_spec(),
|
|
|
|
m_object_name(),
|
|
|
|
m_object_offset(object_offset),
|
|
|
|
m_object_mod_time(),
|
|
|
|
m_objfile_sp(),
|
|
|
|
m_symfile_ap(),
|
|
|
|
m_type_system_map(),
|
|
|
|
m_source_mappings(),
|
|
|
|
m_sections_ap(),
|
|
|
|
m_did_load_objfile(false),
|
|
|
|
m_did_load_symbol_vendor(false),
|
|
|
|
m_did_parse_uuid(false),
|
|
|
|
m_file_has_changed(false),
|
|
|
|
m_first_file_changed_log(false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-08-09 08:01:09 +08:00
|
|
|
// Scope for locker below...
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2011-08-09 08:01:09 +08:00
|
|
|
GetModuleCollection().push_back(this);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (object_name)
|
|
|
|
m_object_name = *object_name;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
if (object_mod_time_ptr)
|
|
|
|
m_object_mod_time = *object_mod_time_ptr;
|
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES));
|
2016-03-12 04:20:38 +08:00
|
|
|
if (log != nullptr)
|
2016-05-18 09:59:10 +08:00
|
|
|
log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this), m_arch.GetArchitectureName(),
|
|
|
|
m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
|
|
|
|
m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
Module::Module()
|
|
|
|
: m_mutex(),
|
|
|
|
m_mod_time(),
|
|
|
|
m_arch(),
|
|
|
|
m_uuid(),
|
|
|
|
m_file(),
|
|
|
|
m_platform_file(),
|
|
|
|
m_remote_install_file(),
|
|
|
|
m_symfile_spec(),
|
|
|
|
m_object_name(),
|
|
|
|
m_object_offset(0),
|
|
|
|
m_object_mod_time(),
|
|
|
|
m_objfile_sp(),
|
|
|
|
m_symfile_ap(),
|
|
|
|
m_type_system_map(),
|
|
|
|
m_source_mappings(),
|
|
|
|
m_sections_ap(),
|
|
|
|
m_did_load_objfile(false),
|
|
|
|
m_did_load_symbol_vendor(false),
|
|
|
|
m_did_parse_uuid(false),
|
|
|
|
m_file_has_changed(false),
|
|
|
|
m_first_file_changed_log(false)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2014-03-25 07:10:19 +08:00
|
|
|
GetModuleCollection().push_back(this);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Module::~Module()
|
|
|
|
{
|
2013-05-23 04:13:22 +08:00
|
|
|
// Lock our module down while we tear everything down to make sure
|
|
|
|
// we don't get any access to the module while it is being destroyed
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2011-08-09 08:01:09 +08:00
|
|
|
// Scope for locker below...
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
|
2011-08-09 08:01:09 +08:00
|
|
|
ModuleCollection &modules = GetModuleCollection();
|
|
|
|
ModuleCollection::iterator end = modules.end();
|
|
|
|
ModuleCollection::iterator pos = std::find(modules.begin(), end, this);
|
2012-10-09 06:41:53 +08:00
|
|
|
assert (pos != end);
|
|
|
|
modules.erase(pos);
|
2011-08-09 08:01:09 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
|
2016-03-12 04:20:38 +08:00
|
|
|
if (log != nullptr)
|
2013-04-30 01:25:54 +08:00
|
|
|
log->Printf ("%p Module::~Module((%s) '%s%s%s%s')",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(this),
|
2011-02-23 08:35:02 +08:00
|
|
|
m_arch.GetArchitectureName(),
|
2013-04-30 01:25:54 +08:00
|
|
|
m_file.GetPath().c_str(),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_object_name.IsEmpty() ? "" : "(",
|
|
|
|
m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
|
|
|
|
m_object_name.IsEmpty() ? "" : ")");
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// Release any auto pointers before we start tearing down our member
|
|
|
|
// variables since the object file and symbol files might need to make
|
|
|
|
// function calls back into this module object. The ordering is important
|
|
|
|
// here because symbol files can require the module object file. So we tear
|
|
|
|
// down the symbol file first, then the object file.
|
2013-07-10 09:23:25 +08:00
|
|
|
m_sections_ap.reset();
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_symfile_ap.reset();
|
2011-09-19 02:59:15 +08:00
|
|
|
m_objfile_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-25 05:55:59 +08:00
|
|
|
ObjectFile *
|
2014-03-05 18:12:43 +08:00
|
|
|
Module::GetMemoryObjectFile (const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, Error &error, size_t size_to_read)
|
2012-02-25 05:55:59 +08:00
|
|
|
{
|
|
|
|
if (m_objfile_sp)
|
|
|
|
{
|
|
|
|
error.SetErrorString ("object file already exists");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2012-02-25 05:55:59 +08:00
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
m_did_load_objfile = true;
|
2014-03-05 18:12:43 +08:00
|
|
|
std::unique_ptr<DataBufferHeap> data_ap (new DataBufferHeap (size_to_read, 0));
|
2012-02-25 05:55:59 +08:00
|
|
|
Error readmem_error;
|
|
|
|
const size_t bytes_read = process_sp->ReadMemory (header_addr,
|
|
|
|
data_ap->GetBytes(),
|
|
|
|
data_ap->GetByteSize(),
|
|
|
|
readmem_error);
|
2014-03-05 18:12:43 +08:00
|
|
|
if (bytes_read == size_to_read)
|
2012-02-25 05:55:59 +08:00
|
|
|
{
|
|
|
|
DataBufferSP data_sp(data_ap.release());
|
|
|
|
m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp, header_addr, data_sp);
|
|
|
|
if (m_objfile_sp)
|
|
|
|
{
|
2012-04-21 03:50:20 +08:00
|
|
|
StreamString s;
|
2012-11-30 05:49:15 +08:00
|
|
|
s.Printf("0x%16.16" PRIx64, header_addr);
|
2012-04-21 03:50:20 +08:00
|
|
|
m_object_name.SetCString (s.GetData());
|
|
|
|
|
|
|
|
// Once we get the object file, update our module with the object file's
|
2012-02-25 05:55:59 +08:00
|
|
|
// architecture since it might differ in vendor/os if some parts were
|
|
|
|
// unknown.
|
|
|
|
m_objfile_sp->GetArchitecture (m_arch);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to find suitable object file plug-in");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat ("unable to read header from memory: %s", readmem_error.AsCString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("invalid process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_objfile_sp.get();
|
|
|
|
}
|
|
|
|
|
2011-02-05 02:53:10 +08:00
|
|
|
const lldb_private::UUID&
|
2010-06-09 00:52:24 +08:00
|
|
|
Module::GetUUID()
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_parse_uuid.load())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_parse_uuid.load())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2015-07-25 07:38:01 +08:00
|
|
|
ObjectFile * obj_file = GetObjectFile ();
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
if (obj_file != nullptr)
|
2015-07-25 07:38:01 +08:00
|
|
|
{
|
|
|
|
obj_file->GetUUID(&m_uuid);
|
|
|
|
m_did_parse_uuid = true;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_uuid;
|
|
|
|
}
|
|
|
|
|
2015-08-15 04:02:05 +08:00
|
|
|
TypeSystem *
|
|
|
|
Module::GetTypeSystemForLanguage (LanguageType language)
|
|
|
|
{
|
2015-10-09 05:04:34 +08:00
|
|
|
return m_type_system_map.GetTypeSystemForLanguage(language, this, true);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
Module::ParseAllDebugSymbols()
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t num_comp_units = GetNumCompileUnits();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (num_comp_units == 0)
|
|
|
|
return;
|
|
|
|
|
2011-09-17 15:23:18 +08:00
|
|
|
SymbolContext sc;
|
2012-01-30 04:56:30 +08:00
|
|
|
sc.module_sp = shared_from_this();
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
|
|
|
|
if (sc.comp_unit)
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
sc.function = nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
symbols->ParseVariablesForContext(sc);
|
|
|
|
|
|
|
|
symbols->ParseCompileUnitFunctions(sc);
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != nullptr; ++func_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
symbols->ParseFunctionBlocks(sc);
|
|
|
|
|
|
|
|
// Parse the variables for this function and all its blocks
|
|
|
|
symbols->ParseVariablesForContext(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse all types for this compile unit
|
2016-03-12 04:20:38 +08:00
|
|
|
sc.function = nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
symbols->ParseTypes(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Module::CalculateSymbolContext(SymbolContext* sc)
|
|
|
|
{
|
2012-01-30 04:56:30 +08:00
|
|
|
sc->module_sp = shared_from_this();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP
|
2011-08-13 05:40:01 +08:00
|
|
|
Module::CalculateSymbolContextModule ()
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
return shared_from_this();
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
Module::DumpSymbolContext(Stream *s)
|
|
|
|
{
|
2014-04-04 12:06:10 +08:00
|
|
|
s->Printf(", Module{%p}", static_cast<void*>(this));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2010-06-09 00:52:24 +08:00
|
|
|
Module::GetNumCompileUnits()
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2014-04-04 12:06:10 +08:00
|
|
|
"Module::GetNumCompileUnits (module = %p)",
|
|
|
|
static_cast<void*>(this));
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
return symbols->GetNumCompileUnits();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CompUnitSP
|
2013-01-26 02:06:21 +08:00
|
|
|
Module::GetCompileUnitAtIndex (size_t index)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t num_comp_units = GetNumCompileUnits ();
|
2010-06-09 00:52:24 +08:00
|
|
|
CompUnitSP cu_sp;
|
|
|
|
|
|
|
|
if (index < num_comp_units)
|
|
|
|
{
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
cu_sp = symbols->GetCompileUnitAtIndex(index);
|
|
|
|
}
|
|
|
|
return cu_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr);
|
2013-07-10 09:23:25 +08:00
|
|
|
SectionList *section_list = GetSectionList();
|
|
|
|
if (section_list)
|
|
|
|
return so_addr.ResolveAddressUsingFileSections(vm_addr, section_list);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2013-09-24 23:34:13 +08:00
|
|
|
Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc,
|
|
|
|
bool resolve_tail_call_address)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t resolved_flags = 0;
|
|
|
|
|
2013-02-23 12:12:47 +08:00
|
|
|
// Clear the result symbol context in case we don't find anything, but don't clear the target
|
|
|
|
sc.Clear(false);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Get the section from the section/offset address.
|
2012-02-24 09:59:29 +08:00
|
|
|
SectionSP section_sp (so_addr.GetSection());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Make sure the section matches this module before we try and match anything
|
2012-02-24 09:59:29 +08:00
|
|
|
if (section_sp && section_sp->GetModule().get() == this)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// If the section offset based address resolved itself, then this
|
|
|
|
// is the right module.
|
2012-01-30 04:56:30 +08:00
|
|
|
sc.module_sp = shared_from_this();
|
2010-06-09 00:52:24 +08:00
|
|
|
resolved_flags |= eSymbolContextModule;
|
|
|
|
|
2013-09-17 06:00:17 +08:00
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
|
|
|
if (!sym_vendor)
|
|
|
|
return resolved_flags;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Resolve the compile unit, function, block, line table or line
|
|
|
|
// entry if requested.
|
|
|
|
if (resolve_scope & eSymbolContextCompUnit ||
|
|
|
|
resolve_scope & eSymbolContextFunction ||
|
|
|
|
resolve_scope & eSymbolContextBlock ||
|
2016-06-22 04:00:36 +08:00
|
|
|
resolve_scope & eSymbolContextLineEntry ||
|
|
|
|
resolve_scope & eSymbolContextVariable )
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-09-17 06:00:17 +08:00
|
|
|
resolved_flags |= sym_vendor->ResolveSymbolContext (so_addr, resolve_scope, sc);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-01 07:51:36 +08:00
|
|
|
// Resolve the symbol if requested, but don't re-look it up if we've already found it.
|
|
|
|
if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-09-17 06:00:17 +08:00
|
|
|
Symtab *symtab = sym_vendor->GetSymtab();
|
|
|
|
if (symtab && so_addr.IsSectionOffset())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-01-23 18:36:06 +08:00
|
|
|
Symbol *matching_symbol = nullptr;
|
2016-01-26 08:58:09 +08:00
|
|
|
|
|
|
|
symtab->ForEachSymbolContainingFileAddress(so_addr.GetFileAddress(),
|
|
|
|
[&matching_symbol](Symbol *symbol) -> bool {
|
|
|
|
if (symbol->GetType() != eSymbolTypeInvalid)
|
|
|
|
{
|
|
|
|
matching_symbol = symbol;
|
|
|
|
return false; // Stop iterating
|
|
|
|
}
|
|
|
|
return true; // Keep iterating
|
|
|
|
});
|
2016-01-23 18:36:06 +08:00
|
|
|
sc.symbol = matching_symbol;
|
2013-09-24 23:34:13 +08:00
|
|
|
if (!sc.symbol &&
|
|
|
|
resolve_scope & eSymbolContextFunction && !(resolved_flags & eSymbolContextFunction))
|
|
|
|
{
|
|
|
|
bool verify_unique = false; // No need to check again since ResolveSymbolContext failed to find a symbol at this address.
|
|
|
|
if (ObjectFile *obj_file = sc.module_sp->GetObjectFile())
|
|
|
|
sc.symbol = obj_file->ResolveSymbolForAddress(so_addr, verify_unique);
|
|
|
|
}
|
|
|
|
|
2013-09-17 06:00:17 +08:00
|
|
|
if (sc.symbol)
|
2013-10-12 06:03:48 +08:00
|
|
|
{
|
|
|
|
if (sc.symbol->IsSynthetic())
|
|
|
|
{
|
|
|
|
// We have a synthetic symbol so lets check if the object file
|
|
|
|
// from the symbol file in the symbol vendor is different than
|
|
|
|
// the object file for the module, and if so search its symbol
|
|
|
|
// table to see if we can come up with a better symbol. For example
|
|
|
|
// dSYM files on MacOSX have an unstripped symbol table inside of
|
|
|
|
// them.
|
|
|
|
ObjectFile *symtab_objfile = symtab->GetObjectFile();
|
|
|
|
if (symtab_objfile && symtab_objfile->IsStripped())
|
|
|
|
{
|
|
|
|
SymbolFile *symfile = sym_vendor->GetSymbolFile();
|
|
|
|
if (symfile)
|
|
|
|
{
|
|
|
|
ObjectFile *symfile_objfile = symfile->GetObjectFile();
|
|
|
|
if (symfile_objfile != symtab_objfile)
|
|
|
|
{
|
|
|
|
Symtab *symfile_symtab = symfile_objfile->GetSymtab();
|
|
|
|
if (symfile_symtab)
|
|
|
|
{
|
|
|
|
Symbol *symbol = symfile_symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
|
|
|
|
if (symbol && !symbol->IsSynthetic())
|
|
|
|
{
|
|
|
|
sc.symbol = symbol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-17 06:00:17 +08:00
|
|
|
resolved_flags |= eSymbolContextSymbol;
|
2013-10-12 06:03:48 +08:00
|
|
|
}
|
2013-09-17 06:00:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// For function symbols, so_addr may be off by one. This is a convention consistent
|
|
|
|
// with FDE row indices in eh_frame sections, but requires extra logic here to permit
|
|
|
|
// symbol lookup for disassembly and unwind.
|
|
|
|
if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol) &&
|
2013-09-24 23:34:13 +08:00
|
|
|
resolve_tail_call_address && so_addr.IsSectionOffset())
|
2013-09-17 06:00:17 +08:00
|
|
|
{
|
|
|
|
Address previous_addr = so_addr;
|
2013-09-19 04:03:31 +08:00
|
|
|
previous_addr.Slide(-1);
|
2013-09-17 06:00:17 +08:00
|
|
|
|
2013-09-24 23:34:13 +08:00
|
|
|
bool do_resolve_tail_call_address = false; // prevent recursion
|
|
|
|
const uint32_t flags = ResolveSymbolContextForAddress(previous_addr, resolve_scope, sc,
|
|
|
|
do_resolve_tail_call_address);
|
2013-09-17 06:00:17 +08:00
|
|
|
if (flags & eSymbolContextSymbol)
|
|
|
|
{
|
|
|
|
AddressRange addr_range;
|
|
|
|
if (sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, addr_range))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-09-17 06:00:17 +08:00
|
|
|
if (addr_range.GetBaseAddress().GetSection() == so_addr.GetSection())
|
|
|
|
{
|
|
|
|
// If the requested address is one past the address range of a function (i.e. a tail call),
|
|
|
|
// or the decremented address is the start of a function (i.e. some forms of trampoline),
|
|
|
|
// indicate that the symbol has been resolved.
|
|
|
|
if (so_addr.GetOffset() == addr_range.GetBaseAddress().GetOffset() ||
|
|
|
|
so_addr.GetOffset() == addr_range.GetBaseAddress().GetOffset() + addr_range.GetByteSize())
|
|
|
|
{
|
|
|
|
resolved_flags |= flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-09-17 06:00:17 +08:00
|
|
|
sc.symbol = nullptr; // Don't trust the symbol if the sections didn't match.
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resolved_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2010-10-21 04:54:39 +08:00
|
|
|
Module::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
|
|
|
|
Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2013-04-30 01:25:54 +08:00
|
|
|
"Module::ResolveSymbolContextForFilePath (%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)",
|
|
|
|
file_spec.GetPath().c_str(),
|
2010-06-09 00:52:24 +08:00
|
|
|
line,
|
|
|
|
check_inlines ? "yes" : "no",
|
|
|
|
resolve_scope);
|
|
|
|
|
|
|
|
const uint32_t initial_count = sc_list.GetSize();
|
|
|
|
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
symbols->ResolveSymbolContext (file_spec, line, check_inlines, resolve_scope, sc_list);
|
|
|
|
|
|
|
|
return sc_list.GetSize() - initial_count;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
|
|
|
Module::FindGlobalVariables (const ConstString &name,
|
2015-08-25 07:46:31 +08:00
|
|
|
const CompilerDeclContext *parent_decl_ctx,
|
2013-01-26 02:06:21 +08:00
|
|
|
bool append,
|
|
|
|
size_t max_matches,
|
|
|
|
VariableList& variables)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
2015-08-25 07:46:31 +08:00
|
|
|
return symbols->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables);
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2013-01-26 02:06:21 +08:00
|
|
|
|
|
|
|
size_t
|
|
|
|
Module::FindGlobalVariables (const RegularExpression& regex,
|
|
|
|
bool append,
|
|
|
|
size_t max_matches,
|
|
|
|
VariableList& variables)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
return symbols->FindGlobalVariables(regex, append, max_matches, variables);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-07-07 09:59:51 +08:00
|
|
|
Module::FindCompileUnits (const FileSpec &path,
|
|
|
|
bool append,
|
|
|
|
SymbolContextList &sc_list)
|
|
|
|
{
|
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t start_size = sc_list.GetSize();
|
|
|
|
const size_t num_compile_units = GetNumCompileUnits();
|
2011-07-07 09:59:51 +08:00
|
|
|
SymbolContext sc;
|
2012-01-30 04:56:30 +08:00
|
|
|
sc.module_sp = shared_from_this();
|
2013-10-04 06:27:29 +08:00
|
|
|
const bool compare_directory = (bool)path.GetDirectory();
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t i = 0; i < num_compile_units; ++i)
|
2011-07-07 09:59:51 +08:00
|
|
|
{
|
|
|
|
sc.comp_unit = GetCompileUnitAtIndex(i).get();
|
2012-04-24 06:00:21 +08:00
|
|
|
if (sc.comp_unit)
|
|
|
|
{
|
|
|
|
if (FileSpec::Equal (*sc.comp_unit, path, compare_directory))
|
|
|
|
sc_list.Append(sc);
|
|
|
|
}
|
2011-07-07 09:59:51 +08:00
|
|
|
}
|
|
|
|
return sc_list.GetSize() - start_size;
|
|
|
|
}
|
|
|
|
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
Module::LookupInfo::LookupInfo(const ConstString &name, uint32_t name_type_mask, lldb::LanguageType language) :
|
|
|
|
m_name(name),
|
|
|
|
m_lookup_name(),
|
|
|
|
m_language(language),
|
|
|
|
m_name_type_mask(0),
|
|
|
|
m_match_name_after_lookup(false)
|
|
|
|
{
|
|
|
|
const char *name_cstr = name.GetCString();
|
|
|
|
llvm::StringRef basename;
|
|
|
|
llvm::StringRef context;
|
|
|
|
|
|
|
|
if (name_type_mask & eFunctionNameTypeAuto)
|
|
|
|
{
|
|
|
|
if (CPlusPlusLanguage::IsCPPMangledName (name_cstr))
|
|
|
|
m_name_type_mask = eFunctionNameTypeFull;
|
|
|
|
else if ((language == eLanguageTypeUnknown ||
|
|
|
|
Language::LanguageIsObjC(language)) &&
|
|
|
|
ObjCLanguage::IsPossibleObjCMethodName (name_cstr))
|
|
|
|
m_name_type_mask = eFunctionNameTypeFull;
|
|
|
|
else if (Language::LanguageIsC(language))
|
|
|
|
{
|
|
|
|
m_name_type_mask = eFunctionNameTypeFull;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((language == eLanguageTypeUnknown ||
|
|
|
|
Language::LanguageIsObjC(language)) &&
|
|
|
|
ObjCLanguage::IsPossibleObjCSelector(name_cstr))
|
|
|
|
m_name_type_mask |= eFunctionNameTypeSelector;
|
|
|
|
|
|
|
|
CPlusPlusLanguage::MethodName cpp_method (name);
|
|
|
|
basename = cpp_method.GetBasename();
|
|
|
|
if (basename.empty())
|
|
|
|
{
|
|
|
|
if (CPlusPlusLanguage::ExtractContextAndIdentifier (name_cstr, context, basename))
|
|
|
|
m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
|
|
|
|
else
|
|
|
|
m_name_type_mask |= eFunctionNameTypeFull;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_name_type_mask = name_type_mask;
|
|
|
|
if (name_type_mask & eFunctionNameTypeMethod || name_type_mask & eFunctionNameTypeBase)
|
|
|
|
{
|
|
|
|
// If they've asked for a CPP method or function name and it can't be that, we don't
|
|
|
|
// even need to search for CPP methods or names.
|
|
|
|
CPlusPlusLanguage::MethodName cpp_method (name);
|
|
|
|
if (cpp_method.IsValid())
|
|
|
|
{
|
|
|
|
basename = cpp_method.GetBasename();
|
|
|
|
|
|
|
|
if (!cpp_method.GetQualifiers().empty())
|
|
|
|
{
|
|
|
|
// There is a "const" or other qualifier following the end of the function parens,
|
|
|
|
// this can't be a eFunctionNameTypeBase
|
|
|
|
m_name_type_mask &= ~(eFunctionNameTypeBase);
|
|
|
|
if (m_name_type_mask == eFunctionNameTypeNone)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If the CPP method parser didn't manage to chop this up, try to fill in the base name if we can.
|
|
|
|
// If a::b::c is passed in, we need to just look up "c", and then we'll filter the result later.
|
|
|
|
CPlusPlusLanguage::ExtractContextAndIdentifier (name_cstr, context, basename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name_type_mask & eFunctionNameTypeSelector)
|
|
|
|
{
|
|
|
|
if (!ObjCLanguage::IsPossibleObjCSelector(name_cstr))
|
|
|
|
{
|
|
|
|
m_name_type_mask &= ~(eFunctionNameTypeSelector);
|
|
|
|
if (m_name_type_mask == eFunctionNameTypeNone)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Still try and get a basename in case someone specifies a name type mask of
|
|
|
|
// eFunctionNameTypeFull and a name like "A::func"
|
|
|
|
if (basename.empty())
|
|
|
|
{
|
|
|
|
if (name_type_mask & eFunctionNameTypeFull)
|
|
|
|
{
|
|
|
|
CPlusPlusLanguage::MethodName cpp_method (name);
|
|
|
|
basename = cpp_method.GetBasename();
|
|
|
|
if (basename.empty())
|
|
|
|
CPlusPlusLanguage::ExtractContextAndIdentifier (name_cstr, context, basename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!basename.empty())
|
|
|
|
{
|
|
|
|
// The name supplied was a partial C++ path like "a::count". In this case we want to do a
|
|
|
|
// lookup on the basename "count" and then make sure any matching results contain "a::count"
|
|
|
|
// so that it would match "b::a::count" and "a::count". This is why we set "match_name_after_lookup"
|
|
|
|
// to true
|
|
|
|
m_lookup_name.SetString(basename);
|
|
|
|
m_match_name_after_lookup = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The name is already correct, just use the exact name as supplied, and we won't need
|
|
|
|
// to check if any matches contain "name"
|
|
|
|
m_lookup_name = name;
|
|
|
|
m_match_name_after_lookup = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Module::LookupInfo::Prune(SymbolContextList &sc_list, size_t start_idx) const
|
|
|
|
{
|
|
|
|
if (m_match_name_after_lookup && m_name)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
size_t i = start_idx;
|
|
|
|
while (i < sc_list.GetSize())
|
|
|
|
{
|
|
|
|
if (!sc_list.GetContextAtIndex(i, sc))
|
|
|
|
break;
|
|
|
|
ConstString full_name(sc.GetFunctionName());
|
|
|
|
if (full_name && ::strstr(full_name.GetCString(), m_name.GetCString()) == nullptr)
|
|
|
|
{
|
|
|
|
sc_list.RemoveContextAtIndex(i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we have only full name matches we might have tried to set breakpoint on "func"
|
|
|
|
// and specified eFunctionNameTypeFull, but we might have found "a::func()",
|
|
|
|
// "a::b::func()", "c::func()", "func()" and "func". Only "func()" and "func" should
|
|
|
|
// end up matching.
|
|
|
|
if (m_name_type_mask == eFunctionNameTypeFull)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
size_t i = start_idx;
|
|
|
|
while (i < sc_list.GetSize())
|
|
|
|
{
|
|
|
|
if (!sc_list.GetContextAtIndex(i, sc))
|
|
|
|
break;
|
|
|
|
ConstString full_name(sc.GetFunctionName());
|
|
|
|
CPlusPlusLanguage::MethodName cpp_method(full_name);
|
|
|
|
if (cpp_method.IsValid())
|
|
|
|
{
|
|
|
|
if (cpp_method.GetContext().empty())
|
|
|
|
{
|
|
|
|
if (cpp_method.GetBasename().compare(m_name.GetStringRef()) != 0)
|
|
|
|
{
|
|
|
|
sc_list.RemoveContextAtIndex(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string qualified_name = cpp_method.GetScopeQualifiedName();
|
|
|
|
if (qualified_name.compare(m_name.GetCString()) != 0)
|
|
|
|
{
|
|
|
|
sc_list.RemoveContextAtIndex(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-10-12 10:08:07 +08:00
|
|
|
Module::FindFunctions (const ConstString &name,
|
2015-08-25 07:46:31 +08:00
|
|
|
const CompilerDeclContext *parent_decl_ctx,
|
2013-01-26 02:06:21 +08:00
|
|
|
uint32_t name_type_mask,
|
2012-02-11 06:52:19 +08:00
|
|
|
bool include_symbols,
|
|
|
|
bool include_inlines,
|
2011-01-27 14:44:37 +08:00
|
|
|
bool append,
|
|
|
|
SymbolContextList& sc_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 14:44:37 +08:00
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
2013-04-03 10:00:15 +08:00
|
|
|
const size_t old_size = sc_list.GetSize();
|
2011-01-27 14:44:37 +08:00
|
|
|
|
|
|
|
// Find all the functions (not symbols, but debug information functions...
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
2013-04-03 10:00:15 +08:00
|
|
|
|
|
|
|
if (name_type_mask & eFunctionNameTypeAuto)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
|
|
|
|
|
2013-04-03 10:00:15 +08:00
|
|
|
if (symbols)
|
2013-07-02 03:45:50 +08:00
|
|
|
{
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
symbols->FindFunctions(lookup_info.GetLookupName(),
|
2015-08-25 07:46:31 +08:00
|
|
|
parent_decl_ctx,
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
lookup_info.GetNameTypeMask(),
|
2013-04-03 10:00:15 +08:00
|
|
|
include_inlines,
|
|
|
|
append,
|
|
|
|
sc_list);
|
|
|
|
|
2013-07-02 03:45:50 +08:00
|
|
|
// Now check our symbol table for symbols that are code symbols if requested
|
|
|
|
if (include_symbols)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = symbols->GetSymtab();
|
2013-04-03 10:00:15 +08:00
|
|
|
if (symtab)
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
symtab->FindFunctionSymbols(lookup_info.GetLookupName(), lookup_info.GetNameTypeMask(), sc_list);
|
2013-04-03 10:00:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-14 01:12:24 +08:00
|
|
|
const size_t new_size = sc_list.GetSize();
|
|
|
|
|
|
|
|
if (old_size < new_size)
|
|
|
|
lookup_info.Prune (sc_list, old_size);
|
2011-01-27 14:44:37 +08:00
|
|
|
}
|
2013-04-03 10:00:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (symbols)
|
2013-07-02 03:45:50 +08:00
|
|
|
{
|
2015-08-25 07:46:31 +08:00
|
|
|
symbols->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list);
|
2013-04-03 10:00:15 +08:00
|
|
|
|
2013-07-02 03:45:50 +08:00
|
|
|
// Now check our symbol table for symbols that are code symbols if requested
|
|
|
|
if (include_symbols)
|
2013-04-03 10:00:15 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = symbols->GetSymtab();
|
2013-04-03 10:00:15 +08:00
|
|
|
if (symtab)
|
|
|
|
symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sc_list.GetSize() - old_size;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-01-27 14:44:37 +08:00
|
|
|
Module::FindFunctions (const RegularExpression& regex,
|
2012-02-11 06:52:19 +08:00
|
|
|
bool include_symbols,
|
|
|
|
bool include_inlines,
|
2011-01-27 14:44:37 +08:00
|
|
|
bool append,
|
|
|
|
SymbolContextList& sc_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 14:44:37 +08:00
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t start_size = sc_list.GetSize();
|
2011-01-27 14:44:37 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
symbols->FindFunctions(regex, include_inlines, append, sc_list);
|
|
|
|
|
|
|
|
// Now check our symbol table for symbols that are code symbols if requested
|
|
|
|
if (include_symbols)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = symbols->GetSymtab();
|
2011-01-27 14:44:37 +08:00
|
|
|
if (symtab)
|
|
|
|
{
|
|
|
|
std::vector<uint32_t> symbol_indexes;
|
2013-02-28 04:13:38 +08:00
|
|
|
symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeAny, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t num_matches = symbol_indexes.size();
|
2011-01-27 14:44:37 +08:00
|
|
|
if (num_matches)
|
|
|
|
{
|
|
|
|
SymbolContext sc(this);
|
2013-06-12 08:46:38 +08:00
|
|
|
const size_t end_functions_added_index = sc_list.GetSize();
|
|
|
|
size_t num_functions_added_to_sc_list = end_functions_added_index - start_size;
|
|
|
|
if (num_functions_added_to_sc_list == 0)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2013-06-12 08:46:38 +08:00
|
|
|
// No functions were added, just symbols, so we can just append them
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t i = 0; i < num_matches; ++i)
|
2013-06-12 08:46:38 +08:00
|
|
|
{
|
|
|
|
sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
|
|
|
|
SymbolType sym_type = sc.symbol->GetType();
|
|
|
|
if (sc.symbol && (sym_type == eSymbolTypeCode ||
|
|
|
|
sym_type == eSymbolTypeResolver))
|
|
|
|
sc_list.Append(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
|
|
|
|
FileAddrToIndexMap file_addr_to_index;
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t i = start_size; i < end_functions_added_index; ++i)
|
2013-06-12 08:46:38 +08:00
|
|
|
{
|
|
|
|
const SymbolContext &sc = sc_list[i];
|
|
|
|
if (sc.block)
|
|
|
|
continue;
|
|
|
|
file_addr_to_index[sc.function->GetAddressRange().GetBaseAddress().GetFileAddress()] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
|
|
|
|
// Functions were added so we need to merge symbols into any
|
|
|
|
// existing function symbol contexts
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t i = start_size; i < num_matches; ++i)
|
2013-06-12 08:46:38 +08:00
|
|
|
{
|
|
|
|
sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
|
|
|
|
SymbolType sym_type = sc.symbol->GetType();
|
2015-06-26 05:46:34 +08:00
|
|
|
if (sc.symbol && sc.symbol->ValueIsAddress() && (sym_type == eSymbolTypeCode || sym_type == eSymbolTypeResolver))
|
2013-06-12 08:46:38 +08:00
|
|
|
{
|
2015-06-26 05:46:34 +08:00
|
|
|
FileAddrToIndexMap::const_iterator pos = file_addr_to_index.find(sc.symbol->GetAddressRef().GetFileAddress());
|
2013-06-12 08:46:38 +08:00
|
|
|
if (pos == end)
|
|
|
|
sc_list.Append(sc);
|
|
|
|
else
|
|
|
|
sc_list[pos->second].symbol = sc.symbol;
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 14:44:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sc_list.GetSize() - start_size;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
void
|
|
|
|
Module::FindAddressesForLine (const lldb::TargetSP target_sp,
|
|
|
|
const FileSpec &file, uint32_t line,
|
|
|
|
Function *function,
|
|
|
|
std::vector<Address> &output_local, std::vector<Address> &output_extern)
|
|
|
|
{
|
|
|
|
SearchFilterByModule filter(target_sp, m_file);
|
|
|
|
AddressResolverFileLine resolver(file, line, true);
|
|
|
|
resolver.ResolveAddress (filter);
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
for (size_t n = 0; n < resolver.GetNumberOfAddresses(); n++)
|
2013-09-12 10:20:34 +08:00
|
|
|
{
|
|
|
|
Address addr = resolver.GetAddressRangeAtIndex(n).GetBaseAddress();
|
|
|
|
Function *f = addr.CalculateSymbolContextFunction();
|
|
|
|
if (f && f == function)
|
|
|
|
output_local.push_back (addr);
|
|
|
|
else
|
|
|
|
output_extern.push_back (addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2012-03-27 07:03:23 +08:00
|
|
|
Module::FindTypes_Impl (const SymbolContext& sc,
|
|
|
|
const ConstString &name,
|
2015-08-25 07:46:31 +08:00
|
|
|
const CompilerDeclContext *parent_decl_ctx,
|
2012-03-27 07:03:23 +08:00
|
|
|
bool append,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t max_matches,
|
2016-02-11 05:28:13 +08:00
|
|
|
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
2015-10-08 17:45:41 +08:00
|
|
|
TypeMap& types)
|
2010-08-03 09:26:16 +08:00
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!sc.module_sp || sc.module_sp.get() == this)
|
2010-08-03 09:26:16 +08:00
|
|
|
{
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
2016-02-11 05:28:13 +08:00
|
|
|
return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches, searched_symbol_files, types);
|
2010-08-03 09:26:16 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2012-03-27 07:03:23 +08:00
|
|
|
Module::FindTypesInNamespace (const SymbolContext& sc,
|
|
|
|
const ConstString &type_name,
|
2015-08-25 07:46:31 +08:00
|
|
|
const CompilerDeclContext *parent_decl_ctx,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t max_matches,
|
2012-03-27 07:03:23 +08:00
|
|
|
TypeList& type_list)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-03-27 07:03:23 +08:00
|
|
|
const bool append = true;
|
2015-10-08 17:45:41 +08:00
|
|
|
TypeMap types_map;
|
2016-02-11 05:28:13 +08:00
|
|
|
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
|
|
|
|
size_t num_types = FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, searched_symbol_files, types_map);
|
2015-10-08 17:45:41 +08:00
|
|
|
if (num_types > 0)
|
|
|
|
sc.SortTypeList(types_map, type_list);
|
|
|
|
return num_types;
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
|
2012-12-06 05:24:42 +08:00
|
|
|
lldb::TypeSP
|
|
|
|
Module::FindFirstType (const SymbolContext& sc,
|
|
|
|
const ConstString &name,
|
|
|
|
bool exact_match)
|
|
|
|
{
|
|
|
|
TypeList type_list;
|
2016-02-11 05:28:13 +08:00
|
|
|
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
|
|
|
|
const size_t num_matches = FindTypes (sc, name, exact_match, 1, searched_symbol_files, type_list);
|
2012-12-06 05:24:42 +08:00
|
|
|
if (num_matches)
|
|
|
|
return type_list.GetTypeAtIndex(0);
|
|
|
|
return TypeSP();
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2012-03-27 07:03:23 +08:00
|
|
|
Module::FindTypes (const SymbolContext& sc,
|
|
|
|
const ConstString &name,
|
|
|
|
bool exact_match,
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t max_matches,
|
2016-02-11 05:28:13 +08:00
|
|
|
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
2012-03-27 07:03:23 +08:00
|
|
|
TypeList& types)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t num_matches = 0;
|
2012-03-27 07:03:23 +08:00
|
|
|
const char *type_name_cstr = name.GetCString();
|
|
|
|
std::string type_scope;
|
|
|
|
std::string type_basename;
|
|
|
|
const bool append = true;
|
2012-10-23 00:19:56 +08:00
|
|
|
TypeClass type_class = eTypeClassAny;
|
2015-10-08 17:45:41 +08:00
|
|
|
TypeMap typesmap;
|
2012-10-23 00:19:56 +08:00
|
|
|
if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename, type_class))
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-03-27 07:03:23 +08:00
|
|
|
// Check if "name" starts with "::" which means the qualified type starts
|
|
|
|
// from the root namespace and implies and exact match. The typenames we
|
|
|
|
// get back from clang do not start with "::" so we need to strip this off
|
2014-07-02 05:22:11 +08:00
|
|
|
// in order to get the qualified names to match
|
2012-03-27 07:03:23 +08:00
|
|
|
|
|
|
|
if (type_scope.size() >= 2 && type_scope[0] == ':' && type_scope[1] == ':')
|
|
|
|
{
|
|
|
|
type_scope.erase(0,2);
|
|
|
|
exact_match = true;
|
|
|
|
}
|
|
|
|
ConstString type_basename_const_str (type_basename.c_str());
|
2016-03-12 04:20:38 +08:00
|
|
|
if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append, max_matches, searched_symbol_files, typesmap))
|
2012-03-27 07:03:23 +08:00
|
|
|
{
|
2015-10-08 17:45:41 +08:00
|
|
|
typesmap.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
|
|
|
|
num_matches = typesmap.GetSize();
|
2012-03-27 07:03:23 +08:00
|
|
|
}
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
else
|
2012-03-27 07:03:23 +08:00
|
|
|
{
|
|
|
|
// The type is not in a namespace/class scope, just search for it by basename
|
2012-10-23 00:19:56 +08:00
|
|
|
if (type_class != eTypeClassAny)
|
|
|
|
{
|
|
|
|
// The "type_name_cstr" will have been modified if we have a valid type class
|
|
|
|
// prefix (like "struct", "class", "union", "typedef" etc).
|
2016-03-12 04:20:38 +08:00
|
|
|
FindTypes_Impl(sc, ConstString(type_name_cstr), nullptr, append, max_matches, searched_symbol_files, typesmap);
|
2015-10-08 17:45:41 +08:00
|
|
|
typesmap.RemoveMismatchedTypes (type_class);
|
|
|
|
num_matches = typesmap.GetSize();
|
2012-10-23 00:19:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches, searched_symbol_files, typesmap);
|
2012-10-23 00:19:56 +08:00
|
|
|
}
|
2012-03-27 07:03:23 +08:00
|
|
|
}
|
2015-10-08 17:45:41 +08:00
|
|
|
if (num_matches > 0)
|
|
|
|
sc.SortTypeList(typesmap, types);
|
2012-03-27 07:03:23 +08:00
|
|
|
return num_matches;
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendor*
|
2012-12-14 10:15:00 +08:00
|
|
|
Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_load_symbol_vendor.load())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_load_symbol_vendor.load() && can_create)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2015-07-25 07:38:01 +08:00
|
|
|
ObjectFile *obj_file = GetObjectFile ();
|
2016-03-12 04:20:38 +08:00
|
|
|
if (obj_file != nullptr)
|
2015-07-25 07:38:01 +08:00
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
|
2015-07-25 07:38:01 +08:00
|
|
|
m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
|
|
|
|
m_did_load_symbol_vendor = true;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_symfile_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Module::SetFileSpecAndObjectName (const FileSpec &file, const ConstString &object_name)
|
|
|
|
{
|
|
|
|
// Container objects whose paths do not specify a file directly can call
|
|
|
|
// this function to correct the file and object names.
|
|
|
|
m_file = file;
|
|
|
|
m_mod_time = file.GetModificationTime();
|
|
|
|
m_object_name = object_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ArchSpec&
|
|
|
|
Module::GetArchitecture () const
|
|
|
|
{
|
|
|
|
return m_arch;
|
|
|
|
}
|
|
|
|
|
2013-04-30 01:25:54 +08:00
|
|
|
std::string
|
|
|
|
Module::GetSpecificationDescription () const
|
|
|
|
{
|
|
|
|
std::string spec(GetFileSpec().GetPath());
|
|
|
|
if (m_object_name)
|
|
|
|
{
|
|
|
|
spec += '(';
|
|
|
|
spec += m_object_name.GetCString();
|
|
|
|
spec += ')';
|
|
|
|
}
|
|
|
|
return spec;
|
|
|
|
}
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
void
|
2011-11-28 09:45:00 +08:00
|
|
|
Module::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
2010-10-26 11:11:13 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2011-11-28 09:45:00 +08:00
|
|
|
if (level >= eDescriptionLevelFull)
|
|
|
|
{
|
|
|
|
if (m_arch.IsValid())
|
|
|
|
s->Printf("(%s) ", m_arch.GetArchitectureName());
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2011-11-28 09:45:00 +08:00
|
|
|
if (level == eDescriptionLevelBrief)
|
|
|
|
{
|
|
|
|
const char *filename = m_file.GetFilename().GetCString();
|
|
|
|
if (filename)
|
|
|
|
s->PutCString (filename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
if (m_file.GetPath(path, sizeof(path)))
|
|
|
|
s->PutCString(path);
|
|
|
|
}
|
2010-10-31 11:01:06 +08:00
|
|
|
|
|
|
|
const char *object_name = m_object_name.GetCString();
|
|
|
|
if (object_name)
|
|
|
|
s->Printf("(%s)", object_name);
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2011-11-28 09:45:00 +08:00
|
|
|
void
|
|
|
|
Module::ReportError (const char *format, ...)
|
|
|
|
{
|
2012-01-05 11:57:59 +08:00
|
|
|
if (format && format[0])
|
|
|
|
{
|
|
|
|
StreamString strm;
|
|
|
|
strm.PutCString("error: ");
|
|
|
|
GetDescription(&strm, lldb::eDescriptionLevelBrief);
|
2012-01-11 09:59:18 +08:00
|
|
|
strm.PutChar (' ');
|
2012-01-05 11:57:59 +08:00
|
|
|
va_list args;
|
|
|
|
va_start (args, format);
|
|
|
|
strm.PrintfVarArg(format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
const int format_len = strlen(format);
|
|
|
|
if (format_len > 0)
|
|
|
|
{
|
|
|
|
const char last_char = format[format_len-1];
|
|
|
|
if (last_char != '\n' || last_char != '\r')
|
|
|
|
strm.EOL();
|
|
|
|
}
|
|
|
|
Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 06:51:12 +08:00
|
|
|
bool
|
|
|
|
Module::FileHasChanged () const
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_file_has_changed)
|
2012-07-13 06:51:12 +08:00
|
|
|
m_file_has_changed = (m_file.GetModificationTime() != m_mod_time);
|
|
|
|
return m_file_has_changed;
|
|
|
|
}
|
|
|
|
|
2012-01-05 11:57:59 +08:00
|
|
|
void
|
|
|
|
Module::ReportErrorIfModifyDetected (const char *format, ...)
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_first_file_changed_log)
|
2012-01-05 11:57:59 +08:00
|
|
|
{
|
2012-07-13 06:51:12 +08:00
|
|
|
if (FileHasChanged ())
|
2012-01-05 11:57:59 +08:00
|
|
|
{
|
2012-07-13 06:51:12 +08:00
|
|
|
m_first_file_changed_log = true;
|
|
|
|
if (format)
|
2012-01-05 11:57:59 +08:00
|
|
|
{
|
2012-07-13 06:51:12 +08:00
|
|
|
StreamString strm;
|
|
|
|
strm.PutCString("error: the object file ");
|
|
|
|
GetDescription(&strm, lldb::eDescriptionLevelFull);
|
|
|
|
strm.PutCString (" has been modified\n");
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start (args, format);
|
|
|
|
strm.PrintfVarArg(format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
const int format_len = strlen(format);
|
|
|
|
if (format_len > 0)
|
|
|
|
{
|
|
|
|
const char last_char = format[format_len-1];
|
|
|
|
if (last_char != '\n' || last_char != '\r')
|
|
|
|
strm.EOL();
|
|
|
|
}
|
|
|
|
strm.PutCString("The debug session should be aborted as the original debug information has been overwritten.\n");
|
|
|
|
Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
|
2012-01-05 11:57:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-28 09:45:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Module::ReportWarning (const char *format, ...)
|
|
|
|
{
|
2012-01-05 11:57:59 +08:00
|
|
|
if (format && format[0])
|
|
|
|
{
|
|
|
|
StreamString strm;
|
|
|
|
strm.PutCString("warning: ");
|
2012-01-11 09:59:18 +08:00
|
|
|
GetDescription(&strm, lldb::eDescriptionLevelFull);
|
|
|
|
strm.PutChar (' ');
|
2012-01-05 11:57:59 +08:00
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start (args, format);
|
|
|
|
strm.PrintfVarArg(format, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
const int format_len = strlen(format);
|
|
|
|
if (format_len > 0)
|
|
|
|
{
|
|
|
|
const char last_char = format[format_len-1];
|
|
|
|
if (last_char != '\n' || last_char != '\r')
|
|
|
|
strm.EOL();
|
|
|
|
}
|
|
|
|
Host::SystemLog (Host::eSystemLogWarning, "%s", strm.GetString().c_str());
|
|
|
|
}
|
2011-11-28 09:45:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Module::LogMessage (Log *log, const char *format, ...)
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (log != nullptr)
|
2011-11-28 09:45:00 +08:00
|
|
|
{
|
|
|
|
StreamString log_message;
|
2012-01-11 09:59:18 +08:00
|
|
|
GetDescription(&log_message, lldb::eDescriptionLevelFull);
|
2011-11-28 09:45:00 +08:00
|
|
|
log_message.PutCString (": ");
|
|
|
|
va_list args;
|
|
|
|
va_start (args, format);
|
|
|
|
log_message.PrintfVarArg (format, args);
|
|
|
|
va_end (args);
|
|
|
|
log->PutCString(log_message.GetString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 06:55:20 +08:00
|
|
|
void
|
|
|
|
Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (log != nullptr)
|
2012-04-24 06:55:20 +08:00
|
|
|
{
|
|
|
|
StreamString log_message;
|
|
|
|
GetDescription(&log_message, lldb::eDescriptionLevelFull);
|
|
|
|
log_message.PutCString (": ");
|
|
|
|
va_list args;
|
|
|
|
va_start (args, format);
|
|
|
|
log_message.PrintfVarArg (format, args);
|
|
|
|
va_end (args);
|
|
|
|
if (log->GetVerbose())
|
2015-03-07 04:45:43 +08:00
|
|
|
{
|
|
|
|
std::string back_trace;
|
|
|
|
llvm::raw_string_ostream stream(back_trace);
|
|
|
|
llvm::sys::PrintStackTrace(stream);
|
|
|
|
log_message.PutCString(back_trace.c_str());
|
|
|
|
}
|
2012-04-24 06:55:20 +08:00
|
|
|
log->PutCString(log_message.GetString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
Module::Dump(Stream *s)
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2010-10-08 08:21:05 +08:00
|
|
|
//s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->Indent();
|
2013-04-30 01:25:54 +08:00
|
|
|
s->Printf("Module %s%s%s%s\n",
|
|
|
|
m_file.GetPath().c_str(),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_object_name ? "(" : "",
|
|
|
|
m_object_name ? m_object_name.GetCString() : "",
|
|
|
|
m_object_name ? ")" : "");
|
|
|
|
|
|
|
|
s->IndentMore();
|
2013-07-02 03:45:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectFile *objfile = GetObjectFile ();
|
|
|
|
if (objfile)
|
|
|
|
objfile->Dump(s);
|
|
|
|
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
symbols->Dump(s);
|
|
|
|
|
|
|
|
s->IndentLess();
|
|
|
|
}
|
|
|
|
|
|
|
|
TypeList*
|
|
|
|
Module::GetTypeList ()
|
|
|
|
{
|
|
|
|
SymbolVendor *symbols = GetSymbolVendor ();
|
|
|
|
if (symbols)
|
|
|
|
return &symbols->GetTypeList();
|
2016-03-12 04:20:38 +08:00
|
|
|
return nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const ConstString &
|
|
|
|
Module::GetObjectName() const
|
|
|
|
{
|
|
|
|
return m_object_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectFile *
|
|
|
|
Module::GetObjectFile()
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_load_objfile.load())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_did_load_objfile.load())
|
2011-09-21 11:57:31 +08:00
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2015-07-25 07:38:01 +08:00
|
|
|
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
|
|
|
|
DataBufferSP data_sp;
|
|
|
|
lldb::offset_t data_offset = 0;
|
|
|
|
const lldb::offset_t file_size = m_file.GetByteSize();
|
|
|
|
if (file_size > m_object_offset)
|
2014-09-05 22:48:49 +08:00
|
|
|
{
|
2015-07-25 07:38:01 +08:00
|
|
|
m_did_load_objfile = true;
|
|
|
|
m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
|
|
|
|
&m_file,
|
|
|
|
m_object_offset,
|
|
|
|
file_size - m_object_offset,
|
|
|
|
data_sp,
|
|
|
|
data_offset);
|
|
|
|
if (m_objfile_sp)
|
|
|
|
{
|
|
|
|
// Once we get the object file, update our module with the object file's
|
|
|
|
// architecture since it might differ in vendor/os if some parts were
|
|
|
|
// unknown. But since the matching arch might already be more specific
|
|
|
|
// than the generic COFF architecture, only merge in those values that
|
|
|
|
// overwrite unspecified unknown values.
|
|
|
|
ArchSpec new_arch;
|
|
|
|
m_objfile_sp->GetArchitecture(new_arch);
|
|
|
|
m_arch.MergeFrom(new_arch);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ReportError ("failed to load objfile for %s", GetFileSpec().GetPath().c_str());
|
|
|
|
}
|
2014-09-05 22:48:49 +08:00
|
|
|
}
|
2011-09-21 11:57:31 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-09-19 02:59:15 +08:00
|
|
|
return m_objfile_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-10 09:23:25 +08:00
|
|
|
SectionList *
|
|
|
|
Module::GetSectionList()
|
|
|
|
{
|
|
|
|
// Populate m_unified_sections_ap with sections from objfile.
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_sections_ap)
|
2013-07-10 09:23:25 +08:00
|
|
|
{
|
|
|
|
ObjectFile *obj_file = GetObjectFile();
|
2016-03-12 04:20:38 +08:00
|
|
|
if (obj_file != nullptr)
|
2013-07-10 09:23:25 +08:00
|
|
|
obj_file->CreateSections(*GetUnifiedSectionList());
|
|
|
|
}
|
|
|
|
return m_sections_ap.get();
|
|
|
|
}
|
|
|
|
|
2014-08-22 10:46:46 +08:00
|
|
|
void
|
|
|
|
Module::SectionFileAddressesChanged ()
|
|
|
|
{
|
|
|
|
ObjectFile *obj_file = GetObjectFile ();
|
|
|
|
if (obj_file)
|
|
|
|
obj_file->SectionFileAddressesChanged ();
|
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
2016-03-12 04:20:38 +08:00
|
|
|
if (sym_vendor != nullptr)
|
2014-08-22 10:46:46 +08:00
|
|
|
sym_vendor->SectionFileAddressesChanged ();
|
|
|
|
}
|
|
|
|
|
2013-07-02 03:45:50 +08:00
|
|
|
SectionList *
|
|
|
|
Module::GetUnifiedSectionList()
|
|
|
|
{
|
2013-07-10 09:23:25 +08:00
|
|
|
// Populate m_unified_sections_ap with sections from objfile.
|
2016-03-12 04:20:38 +08:00
|
|
|
if (!m_sections_ap)
|
2013-07-10 09:23:25 +08:00
|
|
|
m_sections_ap.reset(new SectionList());
|
|
|
|
return m_sections_ap.get();
|
2013-07-02 03:45:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
const Symbol *
|
|
|
|
Module::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type)
|
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2010-06-09 00:52:24 +08:00
|
|
|
"Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
|
|
|
|
name.AsCString(),
|
|
|
|
symbol_type);
|
2013-07-02 03:45:50 +08:00
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
|
|
|
if (sym_vendor)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = sym_vendor->GetSymtab();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (symtab)
|
2010-09-11 11:13:28 +08:00
|
|
|
return symtab->FindFirstSymbolWithNameAndType (name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-03-12 04:20:38 +08:00
|
|
|
return nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
void
|
|
|
|
Module::SymbolIndicesToSymbolContextList (Symtab *symtab, std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list)
|
|
|
|
{
|
|
|
|
// No need to protect this call using m_mutex all other method calls are
|
|
|
|
// already thread safe.
|
|
|
|
|
|
|
|
size_t num_indices = symbol_indexes.size();
|
|
|
|
if (num_indices > 0)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext (&sc);
|
|
|
|
for (size_t i = 0; i < num_indices; i++)
|
|
|
|
{
|
|
|
|
sc.symbol = symtab->SymbolAtIndex (symbol_indexes[i]);
|
|
|
|
if (sc.symbol)
|
|
|
|
sc_list.Append (sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-08 08:01:36 +08:00
|
|
|
size_t
|
|
|
|
Module::FindFunctionSymbols (const ConstString &name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
SymbolContextList& sc_list)
|
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2013-01-08 08:01:36 +08:00
|
|
|
"Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
|
|
|
|
name.AsCString(),
|
|
|
|
name_type_mask);
|
2013-07-02 03:45:50 +08:00
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
|
|
|
if (sym_vendor)
|
2013-01-08 08:01:36 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = sym_vendor->GetSymtab();
|
2013-01-08 08:01:36 +08:00
|
|
|
if (symtab)
|
|
|
|
return symtab->FindFunctionSymbols (name, name_type_mask, sc_list);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t
|
2011-10-14 00:49:47 +08:00
|
|
|
Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// No need to protect this call using m_mutex all other method calls are
|
|
|
|
// already thread safe.
|
|
|
|
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2010-06-09 00:52:24 +08:00
|
|
|
"Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
|
|
|
|
name.AsCString(),
|
|
|
|
symbol_type);
|
|
|
|
const size_t initial_size = sc_list.GetSize();
|
2013-07-02 03:45:50 +08:00
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
|
|
|
if (sym_vendor)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = sym_vendor->GetSymtab();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (symtab)
|
|
|
|
{
|
|
|
|
std::vector<uint32_t> symbol_indexes;
|
|
|
|
symtab->FindAllSymbolsWithNameAndType (name, symbol_type, symbol_indexes);
|
|
|
|
SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sc_list.GetSize() - initial_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
Module::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex, SymbolType symbol_type, SymbolContextList &sc_list)
|
|
|
|
{
|
|
|
|
// No need to protect this call using m_mutex all other method calls are
|
|
|
|
// already thread safe.
|
|
|
|
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION,
|
2010-06-09 00:52:24 +08:00
|
|
|
"Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
|
|
|
|
regex.GetText(),
|
|
|
|
symbol_type);
|
|
|
|
const size_t initial_size = sc_list.GetSize();
|
2013-07-02 03:45:50 +08:00
|
|
|
SymbolVendor* sym_vendor = GetSymbolVendor();
|
|
|
|
if (sym_vendor)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
Symtab *symtab = sym_vendor->GetSymtab();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (symtab)
|
|
|
|
{
|
|
|
|
std::vector<uint32_t> symbol_indexes;
|
2010-09-11 11:13:28 +08:00
|
|
|
symtab->FindAllSymbolsMatchingRexExAndType (regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sc_list.GetSize() - initial_size;
|
|
|
|
}
|
|
|
|
|
2013-04-19 02:10:51 +08:00
|
|
|
void
|
|
|
|
Module::SetSymbolFileFileSpec (const FileSpec &file)
|
|
|
|
{
|
2015-04-01 05:01:48 +08:00
|
|
|
if (!file.Exists())
|
|
|
|
return;
|
2013-07-02 03:45:50 +08:00
|
|
|
if (m_symfile_ap)
|
|
|
|
{
|
2015-04-01 05:01:48 +08:00
|
|
|
// Remove any sections in the unified section list that come from the current symbol vendor.
|
2013-07-10 09:23:25 +08:00
|
|
|
SectionList *section_list = GetSectionList();
|
2013-07-02 03:45:50 +08:00
|
|
|
SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
|
|
|
|
if (section_list && symbol_file)
|
|
|
|
{
|
|
|
|
ObjectFile *obj_file = symbol_file->GetObjectFile();
|
2013-08-14 00:46:35 +08:00
|
|
|
// Make sure we have an object file and that the symbol vendor's objfile isn't
|
|
|
|
// the same as the module's objfile before we remove any sections for it...
|
2015-04-01 05:01:48 +08:00
|
|
|
if (obj_file)
|
2013-07-02 03:45:50 +08:00
|
|
|
{
|
2015-04-01 05:01:48 +08:00
|
|
|
// Check to make sure we aren't trying to specify the file we already have
|
|
|
|
if (obj_file->GetFileSpec() == file)
|
2013-07-02 03:45:50 +08:00
|
|
|
{
|
2015-04-01 05:01:48 +08:00
|
|
|
// We are being told to add the exact same file that we already have
|
|
|
|
// we don't have to do anything.
|
|
|
|
return;
|
|
|
|
}
|
2015-07-30 20:38:18 +08:00
|
|
|
|
|
|
|
// Cleare the current symtab as we are going to replace it with a new one
|
|
|
|
obj_file->ClearSymtab();
|
2015-04-01 05:01:48 +08:00
|
|
|
|
|
|
|
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead
|
|
|
|
// of a full path to the symbol file within the bundle
|
|
|
|
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to check this
|
|
|
|
|
|
|
|
if (file.IsDirectory())
|
|
|
|
{
|
|
|
|
std::string new_path(file.GetPath());
|
|
|
|
std::string old_path(obj_file->GetFileSpec().GetPath());
|
|
|
|
if (old_path.find(new_path) == 0)
|
2013-07-02 03:45:50 +08:00
|
|
|
{
|
2015-04-01 05:01:48 +08:00
|
|
|
// We specified the same bundle as the symbol file that we already have
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj_file != m_objfile_sp.get())
|
|
|
|
{
|
|
|
|
size_t num_sections = section_list->GetNumSections (0);
|
|
|
|
for (size_t idx = num_sections; idx > 0; --idx)
|
|
|
|
{
|
|
|
|
lldb::SectionSP section_sp (section_list->GetSectionAtIndex (idx - 1));
|
|
|
|
if (section_sp->GetObjectFile() == obj_file)
|
|
|
|
{
|
|
|
|
section_list->DeleteSection (idx - 1);
|
|
|
|
}
|
2013-07-02 03:45:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-01 05:01:48 +08:00
|
|
|
// Keep all old symbol files around in case there are any lingering type references in
|
|
|
|
// any SBValue objects that might have been handed out.
|
|
|
|
m_old_symfiles.push_back(std::move(m_symfile_ap));
|
2013-07-02 03:45:50 +08:00
|
|
|
}
|
2013-04-19 02:10:51 +08:00
|
|
|
m_symfile_spec = file;
|
|
|
|
m_symfile_ap.reset();
|
|
|
|
m_did_load_symbol_vendor = false;
|
|
|
|
}
|
|
|
|
|
2010-08-10 07:31:02 +08:00
|
|
|
bool
|
|
|
|
Module::IsExecutable ()
|
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
if (GetObjectFile() == nullptr)
|
2010-08-10 07:31:02 +08:00
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return GetObjectFile()->IsExecutable();
|
|
|
|
}
|
|
|
|
|
2011-08-03 09:03:17 +08:00
|
|
|
bool
|
|
|
|
Module::IsLoadedInTarget (Target *target)
|
|
|
|
{
|
|
|
|
ObjectFile *obj_file = GetObjectFile();
|
|
|
|
if (obj_file)
|
|
|
|
{
|
2013-07-10 09:23:25 +08:00
|
|
|
SectionList *sections = GetSectionList();
|
2016-03-12 04:20:38 +08:00
|
|
|
if (sections != nullptr)
|
2011-08-03 09:03:17 +08:00
|
|
|
{
|
|
|
|
size_t num_sections = sections->GetSize();
|
|
|
|
for (size_t sect_idx = 0; sect_idx < num_sections; sect_idx++)
|
|
|
|
{
|
|
|
|
SectionSP section_sp = sections->GetSectionAtIndex(sect_idx);
|
|
|
|
if (section_sp->GetLoadBaseAddress(target) != LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-08 10:22:02 +08:00
|
|
|
|
|
|
|
bool
|
2013-05-21 08:00:30 +08:00
|
|
|
Module::LoadScriptingResourceInTarget (Target *target, Error& error, Stream* feedback_stream)
|
2012-11-08 10:22:02 +08:00
|
|
|
{
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
error.SetErrorString("invalid destination Target");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-02 05:22:11 +08:00
|
|
|
LoadScriptFromSymFile should_load = target->TargetProperties::GetLoadScriptFromSymbolFile();
|
2013-05-14 01:03:52 +08:00
|
|
|
|
2014-08-19 05:08:44 +08:00
|
|
|
if (should_load == eLoadScriptFromSymFileFalse)
|
|
|
|
return false;
|
|
|
|
|
2013-01-12 07:44:27 +08:00
|
|
|
Debugger &debugger = target->GetDebugger();
|
|
|
|
const ScriptLanguage script_language = debugger.GetScriptLanguage();
|
|
|
|
if (script_language != eScriptLanguageNone)
|
2012-11-08 10:22:02 +08:00
|
|
|
{
|
2013-01-12 07:44:27 +08:00
|
|
|
|
|
|
|
PlatformSP platform_sp(target->GetPlatform());
|
|
|
|
|
|
|
|
if (!platform_sp)
|
|
|
|
{
|
|
|
|
error.SetErrorString("invalid Platform");
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-08 10:22:02 +08:00
|
|
|
|
2013-03-23 08:50:58 +08:00
|
|
|
FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources (target,
|
2014-08-16 08:32:58 +08:00
|
|
|
*this,
|
|
|
|
feedback_stream);
|
2016-03-12 04:20:38 +08:00
|
|
|
|
2013-03-23 08:50:58 +08:00
|
|
|
const uint32_t num_specs = file_specs.GetSize();
|
|
|
|
if (num_specs)
|
2012-11-08 10:22:02 +08:00
|
|
|
{
|
2013-03-23 08:50:58 +08:00
|
|
|
ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
|
|
|
|
if (script_interpreter)
|
2013-01-12 07:44:27 +08:00
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
for (uint32_t i = 0; i < num_specs; ++i)
|
2013-01-12 07:44:27 +08:00
|
|
|
{
|
|
|
|
FileSpec scripting_fspec (file_specs.GetFileSpecAtIndex(i));
|
|
|
|
if (scripting_fspec && scripting_fspec.Exists())
|
|
|
|
{
|
2014-07-02 05:22:11 +08:00
|
|
|
if (should_load == eLoadScriptFromSymFileWarn)
|
2013-05-14 01:03:52 +08:00
|
|
|
{
|
2013-05-22 04:13:34 +08:00
|
|
|
if (feedback_stream)
|
2013-07-02 02:49:43 +08:00
|
|
|
feedback_stream->Printf("warning: '%s' contains a debug script. To run this script in "
|
|
|
|
"this debug session:\n\n command script import \"%s\"\n\n"
|
|
|
|
"To run all discovered debug scripts in this session:\n\n"
|
|
|
|
" settings set target.load-script-from-symbol-file true\n",
|
|
|
|
GetFileSpec().GetFileNameStrippingExtension().GetCString(),
|
|
|
|
scripting_fspec.GetPath().c_str());
|
2013-05-14 01:03:52 +08:00
|
|
|
return false;
|
|
|
|
}
|
2013-01-12 07:44:27 +08:00
|
|
|
StreamString scripting_stream;
|
|
|
|
scripting_fspec.Dump(&scripting_stream);
|
2013-05-31 09:03:09 +08:00
|
|
|
const bool can_reload = true;
|
2013-01-12 07:44:27 +08:00
|
|
|
const bool init_lldb_globals = false;
|
2013-07-02 02:49:43 +08:00
|
|
|
bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(),
|
|
|
|
can_reload,
|
|
|
|
init_lldb_globals,
|
|
|
|
error);
|
2013-01-12 07:44:27 +08:00
|
|
|
if (!did_load)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-23 08:50:58 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString("invalid ScriptInterpreter");
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-08 10:22:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-08-10 07:31:02 +08:00
|
|
|
Module::SetArchitecture (const ArchSpec &new_arch)
|
|
|
|
{
|
2011-02-23 08:35:02 +08:00
|
|
|
if (!m_arch.IsValid())
|
2010-08-10 07:31:02 +08:00
|
|
|
{
|
|
|
|
m_arch = new_arch;
|
|
|
|
return true;
|
2011-02-23 08:35:02 +08:00
|
|
|
}
|
2015-02-27 06:15:16 +08:00
|
|
|
return m_arch.IsCompatibleMatch(new_arch);
|
2010-08-10 07:31:02 +08:00
|
|
|
}
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
bool
|
2014-02-08 06:54:47 +08:00
|
|
|
Module::SetLoadAddress (Target &target, lldb::addr_t value, bool value_is_offset, bool &changed)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2014-02-07 03:02:19 +08:00
|
|
|
ObjectFile *object_file = GetObjectFile();
|
2016-03-12 04:20:38 +08:00
|
|
|
if (object_file != nullptr)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2014-02-08 06:54:47 +08:00
|
|
|
changed = object_file->SetLoadAddress(target, value, value_is_offset);
|
2014-02-07 04:10:16 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changed = false;
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
2014-02-07 03:02:19 +08:00
|
|
|
return false;
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
|
2012-02-26 13:51:37 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
Module::MatchesModuleSpec (const ModuleSpec &module_ref)
|
|
|
|
{
|
|
|
|
const UUID &uuid = module_ref.GetUUID();
|
|
|
|
|
|
|
|
if (uuid.IsValid())
|
|
|
|
{
|
|
|
|
// If the UUID matches, then nothing more needs to match...
|
2016-03-12 04:20:38 +08:00
|
|
|
return (uuid == GetUUID());
|
2012-02-26 13:51:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const FileSpec &file_spec = module_ref.GetFileSpec();
|
|
|
|
if (file_spec)
|
|
|
|
{
|
2015-09-04 20:42:41 +08:00
|
|
|
if (!FileSpec::Equal (file_spec, m_file, (bool)file_spec.GetDirectory()) &&
|
|
|
|
!FileSpec::Equal (file_spec, m_platform_file, (bool)file_spec.GetDirectory()))
|
2012-02-26 13:51:37 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
|
|
|
|
if (platform_file_spec)
|
|
|
|
{
|
2013-10-04 06:27:29 +08:00
|
|
|
if (!FileSpec::Equal (platform_file_spec, GetPlatformFileSpec (), (bool)platform_file_spec.GetDirectory()))
|
2012-02-26 13:51:37 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ArchSpec &arch = module_ref.GetArchitecture();
|
|
|
|
if (arch.IsValid())
|
|
|
|
{
|
2012-12-14 06:07:14 +08:00
|
|
|
if (!m_arch.IsCompatibleMatch(arch))
|
2012-02-26 13:51:37 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ConstString &object_name = module_ref.GetObjectName();
|
|
|
|
if (object_name)
|
|
|
|
{
|
|
|
|
if (object_name != GetObjectName())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-16 05:01:31 +08:00
|
|
|
bool
|
|
|
|
Module::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2012-03-16 05:01:31 +08:00
|
|
|
return m_source_mappings.FindFile (orig_spec, new_spec);
|
|
|
|
}
|
|
|
|
|
2012-03-20 06:22:41 +08:00
|
|
|
bool
|
|
|
|
Module::RemapSourceFile (const char *path, std::string &new_path) const
|
|
|
|
{
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2012-03-20 06:22:41 +08:00
|
|
|
return m_source_mappings.RemapPath(path, new_path);
|
|
|
|
}
|
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
uint32_t
|
|
|
|
Module::GetVersion (uint32_t *versions, uint32_t num_versions)
|
|
|
|
{
|
|
|
|
ObjectFile *obj_file = GetObjectFile();
|
|
|
|
if (obj_file)
|
|
|
|
return obj_file->GetVersion (versions, num_versions);
|
|
|
|
|
2016-03-12 04:20:38 +08:00
|
|
|
if (versions != nullptr && num_versions != 0)
|
2012-09-05 02:47:54 +08:00
|
|
|
{
|
2016-03-12 04:20:38 +08:00
|
|
|
for (uint32_t i = 0; i < num_versions; ++i)
|
2014-03-26 04:53:33 +08:00
|
|
|
versions[i] = LLDB_INVALID_MODULE_VERSION;
|
2012-09-05 02:47:54 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-03 10:00:15 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
ModuleSP
|
|
|
|
Module::CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp)
|
|
|
|
{
|
|
|
|
if (delegate_sp)
|
|
|
|
{
|
|
|
|
// Must create a module and place it into a shared pointer before
|
|
|
|
// we can create an object file since it has a std::weak_ptr back
|
|
|
|
// to the module, so we need to control the creation carefully in
|
|
|
|
// this static function
|
|
|
|
ModuleSP module_sp(new Module());
|
|
|
|
module_sp->m_objfile_sp.reset (new ObjectFileJIT (module_sp, delegate_sp));
|
|
|
|
if (module_sp->m_objfile_sp)
|
|
|
|
{
|
|
|
|
// Once we get the object file, update our module with the object file's
|
|
|
|
// architecture since it might differ in vendor/os if some parts were
|
|
|
|
// unknown.
|
|
|
|
module_sp->m_objfile_sp->GetArchitecture (module_sp->m_arch);
|
|
|
|
}
|
|
|
|
return module_sp;
|
|
|
|
}
|
|
|
|
return ModuleSP();
|
|
|
|
}
|
|
|
|
|
2015-02-05 10:01:34 +08:00
|
|
|
bool
|
|
|
|
Module::GetIsDynamicLinkEditor()
|
|
|
|
{
|
|
|
|
ObjectFile * obj_file = GetObjectFile ();
|
|
|
|
|
|
|
|
if (obj_file)
|
|
|
|
return obj_file->GetIsDynamicLinkEditor();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|