2010-06-09 00:52:24 +08:00
|
|
|
//===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/lldb-private.h"
|
2011-09-19 02:59:15 +08:00
|
|
|
#include "lldb/lldb-private-log.h"
|
2012-01-12 13:25:17 +08:00
|
|
|
#include "lldb/Core/DataBuffer.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/Core/DataBufferHeap.h"
|
2011-09-19 02:59:15 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2013-04-25 06:29:28 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
#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"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Timer.h"
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/ObjectContainer.h"
|
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2012-02-05 10:38:54 +08:00
|
|
|
#include "lldb/Target/Process.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 "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2011-09-19 02:59:15 +08:00
|
|
|
ObjectFileSP
|
2013-02-07 01:22:03 +08:00
|
|
|
ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp,
|
|
|
|
const FileSpec* file,
|
|
|
|
lldb::offset_t file_offset,
|
|
|
|
lldb::offset_t file_size,
|
|
|
|
DataBufferSP &data_sp,
|
|
|
|
lldb::offset_t &data_offset)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-09-19 02:59:15 +08:00
|
|
|
ObjectFileSP object_file_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
if (module_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
Timer scoped_timer (__PRETTY_FUNCTION__,
|
2013-04-30 01:25:54 +08:00
|
|
|
"ObjectFile::FindPlugin (module = %s, file = %p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
|
|
|
|
module_sp->GetFileSpec().GetPath().c_str(),
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<const void*>(file),
|
|
|
|
static_cast<uint64_t>(file_offset),
|
|
|
|
static_cast<uint64_t>(file_size));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (file)
|
|
|
|
{
|
2013-02-07 01:22:03 +08:00
|
|
|
FileSpec archive_file;
|
|
|
|
ObjectContainerCreateInstance create_object_container_callback;
|
|
|
|
|
|
|
|
const bool file_exists = file->Exists();
|
|
|
|
if (!data_sp)
|
2012-01-12 13:25:17 +08:00
|
|
|
{
|
2013-02-07 01:22:03 +08:00
|
|
|
// We have an object name which most likely means we have
|
|
|
|
// a .o file in a static archive (.a file). Try and see if
|
|
|
|
// we have a cached archive first without reading any data
|
|
|
|
// first
|
|
|
|
if (file_exists && module_sp->GetObjectName())
|
|
|
|
{
|
2014-04-20 21:17:36 +08:00
|
|
|
for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
2013-02-07 01:22:03 +08:00
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (object_container_ap.get())
|
|
|
|
object_file_sp = object_container_ap->GetObjectFile(file);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (object_file_sp.get())
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Ok, we didn't find any containers that have a named object, now
|
|
|
|
// lets read the first 512 bytes from the file so the object file
|
|
|
|
// and object container plug-ins can use these bytes to see if they
|
|
|
|
// can parse this file.
|
|
|
|
if (file_size > 0)
|
|
|
|
{
|
|
|
|
data_sp = file->ReadFileContents(file_offset, std::min<size_t>(512, file_size));
|
|
|
|
data_offset = 0;
|
|
|
|
}
|
2012-01-12 13:25:17 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (!data_sp || data_sp->GetByteSize() == 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// Check for archive file with format "/path/to/archive.a(object.o)"
|
|
|
|
char path_with_object[PATH_MAX*2];
|
2012-02-24 09:59:29 +08:00
|
|
|
module_sp->GetFileSpec().GetPath(path_with_object, sizeof(path_with_object));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
<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
|
|
|
ConstString archive_object;
|
2013-02-06 08:38:25 +08:00
|
|
|
const bool must_exist = true;
|
|
|
|
if (ObjectFile::SplitArchivePathWithObject (path_with_object, archive_file, archive_object, must_exist))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
<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
|
|
|
file_size = archive_file.GetByteSize();
|
|
|
|
if (file_size > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-02-07 01:22:03 +08:00
|
|
|
file = &archive_file;
|
<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
|
|
|
module_sp->SetFileSpecAndObjectName (archive_file, archive_object);
|
2013-02-07 01:22:03 +08:00
|
|
|
// Check if this is a object container by iterating through all object
|
|
|
|
// container plugin instances and then trying to get an object file
|
|
|
|
// from the container plugins since we had a name. Also, don't read
|
|
|
|
// ANY data in case there is data cached in the container plug-ins
|
|
|
|
// (like BSD archives caching the contained objects within an file).
|
2014-04-20 21:17:36 +08:00
|
|
|
for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
2013-02-07 01:22:03 +08:00
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (object_container_ap.get())
|
|
|
|
object_file_sp = object_container_ap->GetObjectFile(file);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (object_file_sp.get())
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
|
|
|
// We failed to find any cached object files in the container
|
|
|
|
// plug-ins, so lets read the first 512 bytes and try again below...
|
|
|
|
data_sp = archive_file.ReadFileContents(file_offset, 512);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-07 01:22:03 +08:00
|
|
|
if (data_sp && data_sp->GetByteSize() > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-12 13:25:17 +08:00
|
|
|
// Check if this is a normal object file by iterating through
|
|
|
|
// all object file plugin instances.
|
|
|
|
ObjectFileCreateInstance create_object_file_callback;
|
2014-04-20 21:17:36 +08:00
|
|
|
for (uint32_t idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
2012-01-12 13:25:17 +08:00
|
|
|
{
|
2013-02-07 01:22:03 +08:00
|
|
|
object_file_sp.reset (create_object_file_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
|
2012-01-12 13:25:17 +08:00
|
|
|
if (object_file_sp.get())
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-12 13:25:17 +08:00
|
|
|
// Check if this is a object container by iterating through
|
|
|
|
// all object container plugin instances and then trying to get
|
|
|
|
// an object file from the container.
|
2014-04-20 21:17:36 +08:00
|
|
|
for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
2012-01-12 13:25:17 +08:00
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
|
2012-01-12 13:25:17 +08:00
|
|
|
|
|
|
|
if (object_container_ap.get())
|
|
|
|
object_file_sp = object_container_ap->GetObjectFile(file);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-12 13:25:17 +08:00
|
|
|
if (object_file_sp.get())
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-19 02:59:15 +08:00
|
|
|
// We didn't find it, so clear our shared pointer in case it
|
|
|
|
// contains anything and return an empty shared pointer
|
|
|
|
object_file_sp.reset();
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
ObjectFileSP
|
2012-02-24 09:59:29 +08:00
|
|
|
ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp,
|
2012-02-05 10:38:54 +08:00
|
|
|
const ProcessSP &process_sp,
|
|
|
|
lldb::addr_t header_addr,
|
2013-02-07 01:22:03 +08:00
|
|
|
DataBufferSP &data_sp)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
|
|
|
ObjectFileSP object_file_sp;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
if (module_sp)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
Timer scoped_timer (__PRETTY_FUNCTION__,
|
2013-04-30 01:25:54 +08:00
|
|
|
"ObjectFile::FindPlugin (module = %s, process = %p, header_addr = 0x%" PRIx64 ")",
|
|
|
|
module_sp->GetFileSpec().GetPath().c_str(),
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(process_sp.get()), header_addr);
|
2012-02-05 10:38:54 +08:00
|
|
|
uint32_t idx;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
// Check if this is a normal object file by iterating through
|
|
|
|
// all object file plugin instances.
|
|
|
|
ObjectFileCreateMemoryInstance create_callback;
|
2014-04-20 21:17:36 +08:00
|
|
|
for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != nullptr; ++idx)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2013-02-07 01:22:03 +08:00
|
|
|
object_file_sp.reset (create_callback(module_sp, data_sp, process_sp, header_addr));
|
2012-02-05 10:38:54 +08:00
|
|
|
if (object_file_sp.get())
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
// We didn't find it, so clear our shared pointer in case it
|
|
|
|
// contains anything and return an empty shared pointer
|
|
|
|
object_file_sp.reset();
|
|
|
|
return object_file_sp;
|
|
|
|
}
|
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
size_t
|
|
|
|
ObjectFile::GetModuleSpecifications (const FileSpec &file,
|
|
|
|
lldb::offset_t file_offset,
|
2013-07-13 06:07:46 +08:00
|
|
|
lldb::offset_t file_size,
|
2013-04-25 06:29:28 +08:00
|
|
|
ModuleSpecList &specs)
|
|
|
|
{
|
|
|
|
DataBufferSP data_sp (file.ReadFileContents(file_offset, 512));
|
|
|
|
if (data_sp)
|
2013-07-13 06:07:46 +08:00
|
|
|
{
|
|
|
|
if (file_size == 0)
|
|
|
|
{
|
|
|
|
const lldb::offset_t actual_file_size = file.GetByteSize();
|
|
|
|
if (actual_file_size > file_offset)
|
|
|
|
file_size = actual_file_size - file_offset;
|
|
|
|
}
|
|
|
|
return ObjectFile::GetModuleSpecifications (file, // file spec
|
|
|
|
data_sp, // data bytes
|
|
|
|
0, // data offset
|
|
|
|
file_offset,// file offset
|
|
|
|
file_size, // file length
|
2013-04-25 06:29:28 +08:00
|
|
|
specs);
|
2013-07-13 06:07:46 +08:00
|
|
|
}
|
2013-04-25 06:29:28 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ObjectFile::GetModuleSpecifications (const lldb_private::FileSpec& file,
|
|
|
|
lldb::DataBufferSP& data_sp,
|
|
|
|
lldb::offset_t data_offset,
|
|
|
|
lldb::offset_t file_offset,
|
2013-07-13 06:07:46 +08:00
|
|
|
lldb::offset_t file_size,
|
2013-04-25 06:29:28 +08:00
|
|
|
lldb_private::ModuleSpecList &specs)
|
|
|
|
{
|
|
|
|
const size_t initial_count = specs.GetSize();
|
|
|
|
ObjectFileGetModuleSpecifications callback;
|
|
|
|
uint32_t i;
|
|
|
|
// Try the ObjectFile plug-ins
|
2014-04-20 21:17:36 +08:00
|
|
|
for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != nullptr; ++i)
|
2013-04-25 06:29:28 +08:00
|
|
|
{
|
2013-07-13 06:07:46 +08:00
|
|
|
if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
|
2013-04-25 06:29:28 +08:00
|
|
|
return specs.GetSize() - initial_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try the ObjectContainer plug-ins
|
2014-04-20 21:17:36 +08:00
|
|
|
for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != nullptr; ++i)
|
2013-04-25 06:29:28 +08:00
|
|
|
{
|
2013-07-13 06:07:46 +08:00
|
|
|
if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
|
2013-04-25 06:29:28 +08:00
|
|
|
return specs.GetSize() - initial_count;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp,
|
|
|
|
const FileSpec *file_spec_ptr,
|
2013-02-07 01:22:03 +08:00
|
|
|
lldb::offset_t file_offset,
|
|
|
|
lldb::offset_t length,
|
2014-03-25 07:10:19 +08:00
|
|
|
const lldb::DataBufferSP& data_sp,
|
2013-02-07 01:22:03 +08:00
|
|
|
lldb::offset_t data_offset
|
|
|
|
) :
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleChild (module_sp),
|
2011-09-19 02:59:15 +08:00
|
|
|
m_file (), // This file could be different from the original module's file
|
|
|
|
m_type (eTypeInvalid),
|
|
|
|
m_strata (eStrataInvalid),
|
2013-02-07 01:22:03 +08:00
|
|
|
m_file_offset (file_offset),
|
|
|
|
m_length (length),
|
2012-01-12 13:25:17 +08:00
|
|
|
m_data (),
|
2012-02-05 10:38:54 +08:00
|
|
|
m_unwind_table (*this),
|
|
|
|
m_process_wp(),
|
2013-03-05 05:46:16 +08:00
|
|
|
m_memory_addr (LLDB_INVALID_ADDRESS),
|
2013-07-10 09:23:25 +08:00
|
|
|
m_sections_ap(),
|
|
|
|
m_symtab_ap ()
|
2013-03-05 05:46:16 +08:00
|
|
|
{
|
2011-09-19 02:59:15 +08:00
|
|
|
if (file_spec_ptr)
|
|
|
|
m_file = *file_spec_ptr;
|
2013-02-07 01:22:03 +08:00
|
|
|
if (data_sp)
|
|
|
|
m_data.SetData (data_sp, data_offset, length);
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2011-09-19 02:59:15 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
|
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(module_sp.get()),
|
|
|
|
module_sp->GetSpecificationDescription().c_str(),
|
|
|
|
m_file ? m_file.GetPath().c_str() : "<NULL>",
|
|
|
|
m_file_offset, m_length);
|
2011-09-19 02:59:15 +08:00
|
|
|
}
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp,
|
2012-02-05 10:38:54 +08:00
|
|
|
const ProcessSP &process_sp,
|
|
|
|
lldb::addr_t header_addr,
|
|
|
|
DataBufferSP& header_data_sp) :
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleChild (module_sp),
|
2012-02-05 10:38:54 +08:00
|
|
|
m_file (),
|
|
|
|
m_type (eTypeInvalid),
|
|
|
|
m_strata (eStrataInvalid),
|
2013-02-07 01:22:03 +08:00
|
|
|
m_file_offset (0),
|
2012-02-05 10:38:54 +08:00
|
|
|
m_length (0),
|
|
|
|
m_data (),
|
|
|
|
m_unwind_table (*this),
|
|
|
|
m_process_wp (process_sp),
|
2013-03-05 05:46:16 +08:00
|
|
|
m_memory_addr (header_addr),
|
2013-07-10 09:23:25 +08:00
|
|
|
m_sections_ap(),
|
|
|
|
m_symtab_ap ()
|
2013-03-05 05:46:16 +08:00
|
|
|
{
|
2012-02-05 10:38:54 +08:00
|
|
|
if (header_data_sp)
|
|
|
|
m_data.SetData (header_data_sp, 0, header_data_sp->GetByteSize());
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2012-02-05 10:38:54 +08:00
|
|
|
if (log)
|
2013-04-30 01:25:54 +08:00
|
|
|
log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, header_addr = 0x%" PRIx64,
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(module_sp.get()),
|
2013-04-30 01:25:54 +08:00
|
|
|
module_sp->GetSpecificationDescription().c_str(),
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(process_sp.get()), m_memory_addr);
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-19 02:59:15 +08:00
|
|
|
ObjectFile::~ObjectFile()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2011-09-19 02:59:15 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("%p ObjectFile::~ObjectFile ()\n",
|
|
|
|
static_cast<void*>(this));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-10 07:31:02 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch)
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp (GetModule());
|
|
|
|
if (module_sp)
|
|
|
|
return module_sp->SetArchitecture (new_arch);
|
|
|
|
return false;
|
2010-08-10 07:31:02 +08:00
|
|
|
}
|
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
AddressClass
|
2011-09-19 02:59:15 +08:00
|
|
|
ObjectFile::GetAddressClass (addr_t file_addr)
|
2011-03-19 09:12:21 +08:00
|
|
|
{
|
2013-07-10 09:23:25 +08:00
|
|
|
Symtab *symtab = GetSymtab();
|
2011-03-19 09:12:21 +08:00
|
|
|
if (symtab)
|
|
|
|
{
|
|
|
|
Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
|
|
|
|
if (symbol)
|
|
|
|
{
|
2012-03-08 05:03:09 +08:00
|
|
|
if (symbol->ValueIsAddress())
|
2011-03-19 09:12:21 +08:00
|
|
|
{
|
2012-03-08 05:03:09 +08:00
|
|
|
const SectionSP section_sp (symbol->GetAddress().GetSection());
|
2012-02-24 09:59:29 +08:00
|
|
|
if (section_sp)
|
2011-03-19 09:12:21 +08:00
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
const SectionType section_type = section_sp->GetType();
|
2011-03-19 09:12:21 +08:00
|
|
|
switch (section_type)
|
|
|
|
{
|
2014-04-04 12:06:10 +08:00
|
|
|
case eSectionTypeInvalid:
|
|
|
|
return eAddressClassUnknown;
|
|
|
|
case eSectionTypeCode:
|
|
|
|
return eAddressClassCode;
|
|
|
|
case eSectionTypeContainer:
|
|
|
|
return eAddressClassUnknown;
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-28 01:55:14 +08:00
|
|
|
case eSectionTypeData:
|
|
|
|
case eSectionTypeDataCString:
|
|
|
|
case eSectionTypeDataCStringPointers:
|
|
|
|
case eSectionTypeDataSymbolAddress:
|
|
|
|
case eSectionTypeData4:
|
|
|
|
case eSectionTypeData8:
|
|
|
|
case eSectionTypeData16:
|
|
|
|
case eSectionTypeDataPointers:
|
|
|
|
case eSectionTypeZeroFill:
|
|
|
|
case eSectionTypeDataObjCMessageRefs:
|
|
|
|
case eSectionTypeDataObjCCFStrings:
|
|
|
|
return eAddressClassData;
|
|
|
|
case eSectionTypeDebug:
|
|
|
|
case eSectionTypeDWARFDebugAbbrev:
|
|
|
|
case eSectionTypeDWARFDebugAranges:
|
|
|
|
case eSectionTypeDWARFDebugFrame:
|
|
|
|
case eSectionTypeDWARFDebugInfo:
|
|
|
|
case eSectionTypeDWARFDebugLine:
|
|
|
|
case eSectionTypeDWARFDebugLoc:
|
|
|
|
case eSectionTypeDWARFDebugMacInfo:
|
|
|
|
case eSectionTypeDWARFDebugPubNames:
|
|
|
|
case eSectionTypeDWARFDebugPubTypes:
|
|
|
|
case eSectionTypeDWARFDebugRanges:
|
|
|
|
case eSectionTypeDWARFDebugStr:
|
|
|
|
case eSectionTypeDWARFAppleNames:
|
|
|
|
case eSectionTypeDWARFAppleTypes:
|
|
|
|
case eSectionTypeDWARFAppleNamespaces:
|
|
|
|
case eSectionTypeDWARFAppleObjC:
|
|
|
|
return eAddressClassDebug;
|
2014-04-04 12:06:10 +08:00
|
|
|
case eSectionTypeEHFrame:
|
2014-12-08 11:09:00 +08:00
|
|
|
case eSectionTypeCompactUnwind:
|
2014-04-04 12:06:10 +08:00
|
|
|
return eAddressClassRuntime;
|
2013-07-02 03:45:50 +08:00
|
|
|
case eSectionTypeELFSymbolTable:
|
|
|
|
case eSectionTypeELFDynamicSymbols:
|
|
|
|
case eSectionTypeELFRelocationEntries:
|
|
|
|
case eSectionTypeELFDynamicLinkInfo:
|
2014-04-04 12:06:10 +08:00
|
|
|
case eSectionTypeOther:
|
|
|
|
return eAddressClassUnknown;
|
2011-03-19 09:12:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
const SymbolType symbol_type = symbol->GetType();
|
2011-03-19 09:12:21 +08:00
|
|
|
switch (symbol_type)
|
|
|
|
{
|
|
|
|
case eSymbolTypeAny: return eAddressClassUnknown;
|
|
|
|
case eSymbolTypeAbsolute: return eAddressClassUnknown;
|
|
|
|
case eSymbolTypeCode: return eAddressClassCode;
|
|
|
|
case eSymbolTypeTrampoline: return eAddressClassCode;
|
2013-02-28 05:16:04 +08:00
|
|
|
case eSymbolTypeResolver: return eAddressClassCode;
|
2011-03-19 09:12:21 +08:00
|
|
|
case eSymbolTypeData: return eAddressClassData;
|
|
|
|
case eSymbolTypeRuntime: return eAddressClassRuntime;
|
|
|
|
case eSymbolTypeException: return eAddressClassRuntime;
|
|
|
|
case eSymbolTypeSourceFile: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeHeaderFile: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeObjectFile: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeCommonBlock: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeBlock: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeLocal: return eAddressClassData;
|
|
|
|
case eSymbolTypeParam: return eAddressClassData;
|
|
|
|
case eSymbolTypeVariable: return eAddressClassData;
|
|
|
|
case eSymbolTypeVariableType: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeLineEntry: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeLineHeader: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeScopeBegin: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeScopeEnd: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeAdditional: return eAddressClassUnknown;
|
|
|
|
case eSymbolTypeCompiler: return eAddressClassDebug;
|
|
|
|
case eSymbolTypeInstrumentation:return eAddressClassDebug;
|
|
|
|
case eSymbolTypeUndefined: return eAddressClassUnknown;
|
2011-12-03 10:30:59 +08:00
|
|
|
case eSymbolTypeObjCClass: return eAddressClassRuntime;
|
|
|
|
case eSymbolTypeObjCMetaClass: return eAddressClassRuntime;
|
|
|
|
case eSymbolTypeObjCIVar: return eAddressClassRuntime;
|
2013-10-22 02:40:51 +08:00
|
|
|
case eSymbolTypeReExported: return eAddressClassRuntime;
|
2011-03-19 09:12:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return eAddressClassUnknown;
|
|
|
|
}
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
DataBufferSP
|
|
|
|
ObjectFile::ReadMemory (const ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size)
|
|
|
|
{
|
|
|
|
DataBufferSP data_sp;
|
|
|
|
if (process_sp)
|
|
|
|
{
|
2013-04-19 06:45:39 +08:00
|
|
|
std::unique_ptr<DataBufferHeap> data_ap (new DataBufferHeap (byte_size, 0));
|
2012-02-05 10:38:54 +08:00
|
|
|
Error error;
|
|
|
|
const size_t bytes_read = process_sp->ReadMemory (addr,
|
|
|
|
data_ap->GetBytes(),
|
|
|
|
data_ap->GetByteSize(),
|
|
|
|
error);
|
|
|
|
if (bytes_read == byte_size)
|
|
|
|
data_sp.reset (data_ap.release());
|
|
|
|
}
|
|
|
|
return data_sp;
|
|
|
|
}
|
|
|
|
|
2012-01-12 13:25:17 +08:00
|
|
|
size_t
|
2014-07-03 01:24:07 +08:00
|
|
|
ObjectFile::GetData (lldb::offset_t offset, size_t length, DataExtractor &data) const
|
2012-01-12 13:25:17 +08:00
|
|
|
{
|
|
|
|
// The entire file has already been mmap'ed into m_data, so just copy from there
|
|
|
|
// as the back mmap buffer will be shared with shared pointers.
|
|
|
|
return data.SetData (m_data, offset, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2014-07-03 01:24:07 +08:00
|
|
|
ObjectFile::CopyData (lldb::offset_t offset, size_t length, void *dst) const
|
2012-01-12 13:25:17 +08:00
|
|
|
{
|
|
|
|
// The entire file has already been mmap'ed into m_data, so just copy from there
|
2013-10-10 04:34:25 +08:00
|
|
|
// Note that the data remains in target byte order.
|
|
|
|
return m_data.CopyData (offset, length, dst);
|
2012-01-12 13:25:17 +08:00
|
|
|
}
|
2011-03-19 09:12:21 +08:00
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
|
|
|
|
size_t
|
2014-07-03 01:24:07 +08:00
|
|
|
ObjectFile::ReadSectionData (const Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) const
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2014-09-29 16:02:24 +08:00
|
|
|
assert(section);
|
|
|
|
section_offset *= section->GetTargetByteSize();
|
|
|
|
|
2013-07-02 03:45:50 +08:00
|
|
|
// If some other objectfile owns this data, pass this to them.
|
|
|
|
if (section->GetObjectFile() != this)
|
|
|
|
return section->GetObjectFile()->ReadSectionData (section, section_offset, dst, dst_len);
|
|
|
|
|
2012-02-09 14:16:32 +08:00
|
|
|
if (IsInMemory())
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
|
|
|
ProcessSP process_sp (m_process_wp.lock());
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
Error error;
|
2013-02-02 05:38:35 +08:00
|
|
|
const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
|
|
|
|
if (base_load_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
return process_sp->ReadMemory (base_load_addr + section_offset, dst, dst_len, error);
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-03 01:24:07 +08:00
|
|
|
const lldb::offset_t section_file_size = section->GetFileSize();
|
|
|
|
if (section_offset < section_file_size)
|
2012-02-22 01:34:25 +08:00
|
|
|
{
|
2014-07-03 01:24:07 +08:00
|
|
|
const size_t section_bytes_left = section_file_size - section_offset;
|
|
|
|
size_t section_dst_len = dst_len;
|
2012-02-22 01:34:25 +08:00
|
|
|
if (section_dst_len > section_bytes_left)
|
|
|
|
section_dst_len = section_bytes_left;
|
|
|
|
return CopyData (section->GetFileOffset() + section_offset, section_dst_len, dst);
|
|
|
|
}
|
2013-01-05 07:20:01 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (section->GetType() == eSectionTypeZeroFill)
|
|
|
|
{
|
|
|
|
const uint64_t section_size = section->GetByteSize();
|
|
|
|
const uint64_t section_bytes_left = section_size - section_offset;
|
|
|
|
uint64_t section_dst_len = dst_len;
|
|
|
|
if (section_dst_len > section_bytes_left)
|
|
|
|
section_dst_len = section_bytes_left;
|
2013-08-23 20:44:05 +08:00
|
|
|
memset(dst, 0, section_dst_len);
|
2013-01-05 07:20:01 +08:00
|
|
|
return section_dst_len;
|
|
|
|
}
|
|
|
|
}
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Get the section data the file on disk
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
size_t
|
|
|
|
ObjectFile::ReadSectionData (const Section *section, DataExtractor& section_data) const
|
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
// If some other objectfile owns this data, pass this to them.
|
|
|
|
if (section->GetObjectFile() != this)
|
|
|
|
return section->GetObjectFile()->ReadSectionData (section, section_data);
|
|
|
|
|
2012-02-09 14:16:32 +08:00
|
|
|
if (IsInMemory())
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
|
|
|
ProcessSP process_sp (m_process_wp.lock());
|
|
|
|
if (process_sp)
|
|
|
|
{
|
2013-02-02 05:38:35 +08:00
|
|
|
const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
|
|
|
|
if (base_load_addr != LLDB_INVALID_ADDRESS)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2013-02-02 05:38:35 +08:00
|
|
|
DataBufferSP data_sp (ReadMemory (process_sp, base_load_addr, section->GetByteSize()));
|
|
|
|
if (data_sp)
|
|
|
|
{
|
|
|
|
section_data.SetData (data_sp, 0, data_sp->GetByteSize());
|
|
|
|
section_data.SetByteOrder (process_sp->GetByteOrder());
|
|
|
|
section_data.SetAddressByteSize (process_sp->GetAddressByteSize());
|
|
|
|
return section_data.GetByteSize();
|
|
|
|
}
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The object file now contains a full mmap'ed copy of the object file data, so just use this
|
|
|
|
return MemoryMapSectionData (section, section_data);
|
|
|
|
}
|
|
|
|
section_data.Clear();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ObjectFile::MemoryMapSectionData (const Section *section, DataExtractor& section_data) const
|
|
|
|
{
|
2013-07-02 03:45:50 +08:00
|
|
|
// If some other objectfile owns this data, pass this to them.
|
|
|
|
if (section->GetObjectFile() != this)
|
|
|
|
return section->GetObjectFile()->MemoryMapSectionData (section, section_data);
|
|
|
|
|
2012-02-09 14:16:32 +08:00
|
|
|
if (IsInMemory())
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
|
|
|
return ReadSectionData (section, section_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The object file now contains a full mmap'ed copy of the object file data, so just use this
|
2012-03-27 10:40:46 +08:00
|
|
|
return GetData(section->GetFileOffset(), section->GetFileSize(), section_data);
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
<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
|
|
|
|
|
|
|
bool
|
2013-02-06 08:38:25 +08:00
|
|
|
ObjectFile::SplitArchivePathWithObject (const char *path_with_object, FileSpec &archive_file, ConstString &archive_object, bool must_exist)
|
<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
|
|
|
{
|
|
|
|
RegularExpression g_object_regex("(.*)\\(([^\\)]+)\\)$");
|
2013-04-04 05:37:16 +08:00
|
|
|
RegularExpression::Match regex_match(2);
|
|
|
|
if (g_object_regex.Execute (path_with_object, ®ex_match))
|
<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
|
|
|
{
|
|
|
|
std::string path;
|
|
|
|
std::string obj;
|
2013-04-04 05:37:16 +08:00
|
|
|
if (regex_match.GetMatchAtIndex (path_with_object, 1, path) &&
|
|
|
|
regex_match.GetMatchAtIndex (path_with_object, 2, obj))
|
<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
|
|
|
{
|
|
|
|
archive_file.SetFile (path.c_str(), false);
|
|
|
|
archive_object.SetCString(obj.c_str());
|
2013-02-06 08:38:25 +08:00
|
|
|
if (must_exist && !archive_file.Exists())
|
|
|
|
return false;
|
<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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-05 05:46:16 +08:00
|
|
|
void
|
2013-07-10 09:23:25 +08:00
|
|
|
ObjectFile::ClearSymtab ()
|
2013-03-05 05:46:16 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp(GetModule());
|
|
|
|
if (module_sp)
|
|
|
|
{
|
|
|
|
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
|
2013-03-05 05:46:16 +08:00
|
|
|
if (log)
|
2013-07-10 09:23:25 +08:00
|
|
|
log->Printf ("%p ObjectFile::ClearSymtab () symtab = %p",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(this),
|
|
|
|
static_cast<void*>(m_symtab_ap.get()));
|
2013-07-10 09:23:25 +08:00
|
|
|
m_symtab_ap.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionList *
|
|
|
|
ObjectFile::GetSectionList()
|
|
|
|
{
|
2014-04-20 21:17:36 +08:00
|
|
|
if (m_sections_ap.get() == nullptr)
|
2013-07-10 09:23:25 +08:00
|
|
|
{
|
|
|
|
ModuleSP module_sp(GetModule());
|
|
|
|
if (module_sp)
|
2014-06-17 03:44:24 +08:00
|
|
|
{
|
|
|
|
lldb_private::Mutex::Locker locker(module_sp->GetMutex());
|
2013-07-10 09:23:25 +08:00
|
|
|
CreateSections(*module_sp->GetUnifiedSectionList());
|
2014-06-17 03:44:24 +08:00
|
|
|
}
|
2013-03-05 05:46:16 +08:00
|
|
|
}
|
2013-07-10 09:23:25 +08:00
|
|
|
return m_sections_ap.get();
|
2013-03-05 05:46:16 +08:00
|
|
|
}
|