[Lldb-commits] [lldb] r186211 - Fixed GetModuleSpecifications() to work better overall:
Greg Clayton
gclayton at apple.com
Fri Jul 12 15:07:46 PDT 2013
Author: gclayton
Date: Fri Jul 12 17:07:46 2013
New Revision: 186211
URL: http://llvm.org/viewvc/llvm-project?rev=186211&view=rev
Log:
Fixed GetModuleSpecifications() to work better overall:
- MachO files now correctly extract the UUID all the time
- More file size and offset verification done for universal mach-o files to watch for truncated files
- ObjectContainerBSDArchive now supports enumerating all objects in BSD archives (.a files)
- lldb_private::Module() can not be properly constructed using a ModuleSpec for a .o file in a .a file
- The BSD archive plug-in shares its cache for GetModuleSpecifications() and the create callback
- Improved printing for ModuleSpec objects
Modified:
lldb/trunk/include/lldb/Core/ModuleSpec.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
lldb/trunk/source/API/SBModuleSpec.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Target/TargetList.cpp
Modified: lldb/trunk/include/lldb/Core/ModuleSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleSpec.h?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleSpec.h Fri Jul 12 17:07:46 2013
@@ -350,7 +350,6 @@ public:
strm.PutCString("uuid = ");
m_uuid.Dump(&strm);
dumped_something = true;
-
}
if (m_object_name)
{
@@ -359,6 +358,20 @@ public:
strm.Printf("object_name = %s", m_object_name.GetCString());
dumped_something = true;
}
+ if (m_object_offset > 0)
+ {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_offset = 0x%" PRIx64, m_object_offset);
+ dumped_something = true;
+ }
+ if (m_object_mod_time.IsValid())
+ {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_mod_time = 0x%" PRIx64, m_object_mod_time.GetAsSecondsSinceJan1_1970());
+ dumped_something = true;
+ }
}
bool
@@ -479,6 +492,13 @@ public:
m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
}
+ // The index "i" must be valid and this can't be used in
+ // multi-threaded code as no mutex lock is taken.
+ ModuleSpec &
+ GetModuleSpecRefAtIndex (size_t i)
+ {
+ return m_specs[i];
+ }
bool
GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const
{
Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Jul 12 17:07:46 2013
@@ -182,6 +182,7 @@ public:
static size_t
GetModuleSpecifications (const FileSpec &file,
lldb::offset_t file_offset,
+ lldb::offset_t file_size,
ModuleSpecList &specs);
static size_t
@@ -189,7 +190,7 @@ public:
lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset,
lldb::offset_t file_offset,
- lldb::offset_t length,
+ lldb::offset_t file_size,
lldb_private::ModuleSpecList &specs);
//------------------------------------------------------------------
/// Split a path into a file path with object name.
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Jul 12 17:07:46 2013
@@ -100,12 +100,6 @@
ReferencedContainer = "container:lldb.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
- <CommandLineArguments>
- <CommandLineArgument
- argument = "/Volumes/ThePlayground/Users/jingham/Projects/Sketch/build/Debug/Sketch.app"
- isEnabled = "YES">
- </CommandLineArgument>
- </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR"
Modified: lldb/trunk/source/API/SBModuleSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModuleSpec.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModuleSpec.cpp (original)
+++ lldb/trunk/source/API/SBModuleSpec.cpp Fri Jul 12 17:07:46 2013
@@ -175,7 +175,7 @@ SBModuleSpecList::GetModuleSpecification
SBModuleSpecList specs;
FileSpec file_spec(path, true);
Host::ResolveExecutableInBundle(file_spec);
- ObjectFile::GetModuleSpecifications(file_spec, 0, *specs.m_opaque_ap);
+ ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap);
return specs;
}
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Jul 12 17:07:46 2013
@@ -4285,7 +4285,7 @@ protected:
size_t num_matches = 0;
// First extract all module specs from the symbol file
lldb_private::ModuleSpecList symfile_module_specs;
- if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(), 0, symfile_module_specs))
+ if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(), 0, 0, symfile_module_specs))
{
// Now extract the module spec that matches the target architecture
ModuleSpec target_arch_module_spec;
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Fri Jul 12 17:07:46 2013
@@ -1097,23 +1097,27 @@ Module::GetObjectFile()
Mutex::Locker locker (m_mutex);
if (m_did_load_objfile == false)
{
- m_did_load_objfile = true;
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
DataBufferSP data_sp;
lldb::offset_t data_offset = 0;
- m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
- &m_file,
- m_object_offset,
- m_file.GetByteSize(),
- data_sp,
- data_offset);
- if (m_objfile_sp)
+ const lldb::offset_t file_size = m_file.GetByteSize();
+ if (file_size > m_object_offset)
{
- // 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.
- m_objfile_sp->GetArchitecture (m_arch);
+ 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.
+ m_objfile_sp->GetArchitecture (m_arch);
+ }
}
}
return m_objfile_sp.get();
Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Fri Jul 12 17:07:46 2013
@@ -11,10 +11,12 @@
#include <ar.h>
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -105,10 +107,12 @@ ObjectContainerBSDArchive::Archive::Arch
(
const lldb_private::ArchSpec &arch,
const lldb_private::TimeValue &time,
+ lldb::offset_t file_offset,
lldb_private::DataExtractor &data
) :
m_arch (arch),
m_time (time),
+ m_file_offset (file_offset),
m_objects(),
m_data (data)
{
@@ -176,7 +180,7 @@ ObjectContainerBSDArchive::Archive::Find
ObjectContainerBSDArchive::Archive::shared_ptr
-ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time)
+ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time, lldb::offset_t file_offset)
{
Mutex::Locker locker(Archive::GetArchiveCacheMutex ());
shared_ptr archive_sp;
@@ -186,7 +190,12 @@ ObjectContainerBSDArchive::Archive::Find
// delete an archive entry...
while (pos != archive_map.end() && pos->first == file)
{
- if (pos->second->GetArchitecture().IsCompatibleMatch(arch))
+ bool match = true;
+ if (arch.IsValid() && pos->second->GetArchitecture().IsCompatibleMatch(arch) == false)
+ match = false;
+ else if (file_offset != LLDB_INVALID_OFFSET && pos->second->GetFileOffset() != file_offset)
+ match = false;
+ if (match)
{
if (pos->second->GetModificationTime() == time)
{
@@ -204,7 +213,7 @@ ObjectContainerBSDArchive::Archive::Find
// remove the old and outdated entry.
archive_map.erase (pos);
pos = archive_map.find (file);
- continue;
+ continue; // Continue to next iteration so we don't increment pos below...
}
}
++pos;
@@ -218,13 +227,15 @@ ObjectContainerBSDArchive::Archive::Pars
const FileSpec &file,
const ArchSpec &arch,
const TimeValue &time,
+ lldb::offset_t file_offset,
DataExtractor &data
)
{
- shared_ptr archive_sp(new Archive (arch, time, data));
+ shared_ptr archive_sp(new Archive (arch, time, file_offset, data));
if (archive_sp)
{
- if (archive_sp->ParseObjects () > 0)
+ const size_t num_objects = archive_sp->ParseObjects ();
+ if (num_objects > 0)
{
Mutex::Locker locker(Archive::GetArchiveCacheMutex ());
Archive::GetArchiveCache().insert(std::make_pair(file, archive_sp));
@@ -314,7 +325,10 @@ ObjectContainerBSDArchive::CreateInstanc
DataBufferSP archive_data_sp (file->MemoryMapFileContents(file_offset, length));
lldb::offset_t archive_data_offset = 0;
- Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module_sp->GetArchitecture(), module_sp->GetModificationTime()));
+ Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file,
+ module_sp->GetArchitecture(),
+ module_sp->GetModificationTime(),
+ file_offset));
std::unique_ptr<ObjectContainerBSDArchive> container_ap(new ObjectContainerBSDArchive (module_sp,
archive_data_sp,
archive_data_offset,
@@ -338,7 +352,10 @@ ObjectContainerBSDArchive::CreateInstanc
else
{
// No data, just check for a cached archive
- Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module_sp->GetArchitecture(), module_sp->GetModificationTime()));
+ Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file,
+ module_sp->GetArchitecture(),
+ module_sp->GetModificationTime(),
+ file_offset));
if (archive_sp)
{
std::unique_ptr<ObjectContainerBSDArchive> container_ap(new ObjectContainerBSDArchive (module_sp, data_sp, data_offset, file, file_offset, length));
@@ -409,6 +426,7 @@ ObjectContainerBSDArchive::ParseHeader (
m_archive_sp = Archive::ParseAndCacheArchiveForFile (m_file,
module_sp->GetArchitecture(),
module_sp->GetModificationTime(),
+ m_offset,
m_data);
}
// Clear the m_data that contains the entire archive
@@ -492,8 +510,76 @@ ObjectContainerBSDArchive::GetModuleSpec
lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset,
lldb::offset_t file_offset,
- lldb::offset_t length,
+ lldb::offset_t file_size,
lldb_private::ModuleSpecList &specs)
{
+
+ // We have data, which means this is the first 512 bytes of the file
+ // Check to see if the magic bytes match and if they do, read the entire
+ // table of contents for the archive and cache it
+ DataExtractor data;
+ data.SetData (data_sp, data_offset, data_sp->GetByteSize());
+ if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data))
+ {
+ const size_t initial_count = specs.GetSize();
+ TimeValue file_mod_time = file.GetModificationTime();
+ Archive::shared_ptr archive_sp (Archive::FindCachedArchive (file, ArchSpec(), file_mod_time, file_offset));
+ bool set_archive_arch = false;
+ if (!archive_sp)
+ {
+ set_archive_arch = true;
+ DataBufferSP data_sp (file.MemoryMapFileContents(file_offset, file_size));
+ data.SetData (data_sp, 0, data_sp->GetByteSize());
+ archive_sp = Archive::ParseAndCacheArchiveForFile(file, ArchSpec(), file_mod_time, file_offset, data);
+ }
+
+ if (archive_sp)
+ {
+ const size_t num_objects = archive_sp->GetNumObjects();
+ for (size_t idx = 0; idx < num_objects; ++idx)
+ {
+ const Object *object = archive_sp->GetObjectAtIndex (idx);
+ if (object)
+ {
+ const lldb::offset_t object_file_offset = file_offset + object->ar_file_offset;
+ if (object->ar_file_offset < file_size && file_size > object_file_offset)
+ {
+ if (ObjectFile::GetModuleSpecifications(file,
+ object_file_offset,
+ file_size - object_file_offset,
+ specs))
+ {
+ ModuleSpec &spec = specs.GetModuleSpecRefAtIndex (specs.GetSize() - 1);
+ TimeValue object_mod_time;
+ object_mod_time.OffsetWithSeconds(object->ar_date);
+ spec.GetObjectName () = object->ar_name;
+ spec.SetObjectOffset(object_file_offset);
+ spec.GetObjectModificationTime () = object_mod_time;
+ }
+ }
+ }
+ }
+ }
+ const size_t end_count = specs.GetSize();
+ size_t num_specs_added = end_count - initial_count;
+ if (set_archive_arch && num_specs_added > 0)
+ {
+ // The archive was created but we didn't have an architecture
+ // so we need to set it
+ for (size_t i=initial_count; i<end_count; ++ i)
+ {
+ ModuleSpec module_spec;
+ if (specs.GetModuleSpecAtIndex(i, module_spec))
+ {
+ if (module_spec.GetArchitecture().IsValid())
+ {
+ archive_sp->SetArchitecture (module_spec.GetArchitecture());
+ break;
+ }
+ }
+ }
+ }
+ return num_specs_added;
+ }
return 0;
}
Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h Fri Jul 12 17:07:46 2013
@@ -136,16 +136,19 @@ protected:
static Archive::shared_ptr
FindCachedArchive (const lldb_private::FileSpec &file,
const lldb_private::ArchSpec &arch,
- const lldb_private::TimeValue &mod_time);
+ const lldb_private::TimeValue &mod_time,
+ lldb::offset_t file_offset);
static Archive::shared_ptr
ParseAndCacheArchiveForFile (const lldb_private::FileSpec &file,
const lldb_private::ArchSpec &arch,
const lldb_private::TimeValue &mod_time,
+ lldb::offset_t file_offset,
lldb_private::DataExtractor &data);
Archive (const lldb_private::ArchSpec &arch,
const lldb_private::TimeValue &mod_time,
+ lldb::offset_t file_offset,
lldb_private::DataExtractor &data);
~Archive ();
@@ -156,6 +159,14 @@ protected:
return m_objects.size();
}
+ const Object *
+ GetObjectAtIndex (size_t idx)
+ {
+ if (idx < m_objects.size())
+ return &m_objects[idx];
+ return NULL;
+ }
+
size_t
ParseObjects ();
@@ -163,6 +174,12 @@ protected:
FindObject (const lldb_private::ConstString &object_name,
const lldb_private::TimeValue &object_mod_time);
+ lldb::offset_t
+ GetFileOffset () const
+ {
+ return m_file_offset;
+ }
+
const lldb_private::TimeValue &
GetModificationTime()
{
@@ -170,11 +187,17 @@ protected:
}
const lldb_private::ArchSpec &
- GetArchitecture ()
+ GetArchitecture () const
{
return m_arch;
}
-
+
+ void
+ SetArchitecture (const lldb_private::ArchSpec &arch)
+ {
+ m_arch = arch;
+ }
+
bool
HasNoExternalReferences() const;
@@ -191,6 +214,7 @@ protected:
//----------------------------------------------------------------------
lldb_private::ArchSpec m_arch;
lldb_private::TimeValue m_time;
+ lldb::offset_t m_file_offset;
Object::collection m_objects;
ObjectNameToIndexMap m_object_name_to_index_map;
lldb_private::DataExtractor m_data; ///< The data for this object container so we don't lose data if the .a files gets modified
Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Fri Jul 12 17:07:46 2013
@@ -278,13 +278,13 @@ ObjectContainerUniversalMachO::GetModule
lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset,
lldb::offset_t file_offset,
- lldb::offset_t length,
+ lldb::offset_t file_size,
lldb_private::ModuleSpecList &specs)
{
const size_t initial_count = specs.GetSize();
DataExtractor data;
- data.SetData (data_sp, data_offset, length);
+ data.SetData (data_sp, data_offset, data_sp->GetByteSize());
if (ObjectContainerUniversalMachO::MagicBytesMatch(data))
{
@@ -294,9 +294,14 @@ ObjectContainerUniversalMachO::GetModule
{
for (const llvm::MachO::fat_arch &fat_arch : fat_archs)
{
- ObjectFile::GetModuleSpecifications (file,
- fat_arch.offset + file_offset,
- specs);
+ const lldb::offset_t slice_file_offset = fat_arch.offset + file_offset;
+ if (fat_arch.offset < file_size && file_size > slice_file_offset)
+ {
+ ObjectFile::GetModuleSpecifications (file,
+ slice_file_offset,
+ file_size - slice_file_offset,
+ specs);
+ }
}
}
}
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Jul 12 17:07:46 2013
@@ -513,7 +513,8 @@ ObjectFileMachO::GetModuleSpecifications
if (header.sizeofcmds >= data_sp->GetByteSize())
{
data_sp = file.ReadFileContents(file_offset, header.sizeofcmds);
- data_offset = MachHeaderSizeFromMagic(header.magic) + file_offset;
+ data.SetData(data_sp);
+ data_offset = MachHeaderSizeFromMagic(header.magic);
}
if (data_sp)
{
Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Fri Jul 12 17:07:46 2013
@@ -186,16 +186,25 @@ ObjectFile::FindPlugin (const lldb::Modu
size_t
ObjectFile::GetModuleSpecifications (const FileSpec &file,
lldb::offset_t file_offset,
+ lldb::offset_t file_size,
ModuleSpecList &specs)
{
DataBufferSP data_sp (file.ReadFileContents(file_offset, 512));
if (data_sp)
- return ObjectFile::GetModuleSpecifications (file, // file spec
- data_sp, // data bytes
- 0, // data offset
- file_offset, // file offset
- data_sp->GetByteSize(), // data length
+ {
+ 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
specs);
+ }
return 0;
}
@@ -204,7 +213,7 @@ ObjectFile::GetModuleSpecifications (con
lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset,
lldb::offset_t file_offset,
- lldb::offset_t length,
+ lldb::offset_t file_size,
lldb_private::ModuleSpecList &specs)
{
const size_t initial_count = specs.GetSize();
@@ -213,14 +222,14 @@ ObjectFile::GetModuleSpecifications (con
// Try the ObjectFile plug-ins
for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
{
- if (callback (file, data_sp, data_offset, file_offset, length, specs) > 0)
+ if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
return specs.GetSize() - initial_count;
}
// Try the ObjectContainer plug-ins
for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
{
- if (callback (file, data_sp, data_offset, file_offset, length, specs) > 0)
+ if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
return specs.GetSize() - initial_count;
}
return 0;
Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=186211&r1=186210&r2=186211&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Fri Jul 12 17:07:46 2013
@@ -92,7 +92,8 @@ TargetList::CreateTarget (Debugger &debu
ModuleSpec module_spec;
module_spec.GetFileSpec().SetFile(user_exe_path, true);
lldb::offset_t file_offset = 0;
- const size_t num_specs = ObjectFile::GetModuleSpecifications (module_spec.GetFileSpec(), file_offset, module_specs);
+ lldb::offset_t file_size = 0;
+ const size_t num_specs = ObjectFile::GetModuleSpecifications (module_spec.GetFileSpec(), file_offset, file_size, module_specs);
if (num_specs > 0)
{
ModuleSpec matching_module_spec;
More information about the lldb-commits
mailing list