本文整理汇总了C++中Section::GetFileOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::GetFileOffset方法的具体用法?C++ Section::GetFileOffset怎么用?C++ Section::GetFileOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::GetFileOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
Error
ProcessMachCore::DoLoadCore ()
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER | LIBLLDB_LOG_PROCESS));
Error error;
if (!m_core_module_sp)
{
error.SetErrorString ("invalid core module");
return error;
}
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
if (core_objfile == NULL)
{
error.SetErrorString ("invalid core object file");
return error;
}
if (core_objfile->GetNumThreadContexts() == 0)
{
error.SetErrorString ("core file doesn't contain any LC_THREAD load commands, or the LC_THREAD architecture is not supported in this lldb");
return error;
}
SectionList *section_list = core_objfile->GetSectionList();
if (section_list == NULL)
{
error.SetErrorString ("core file has no sections");
return error;
}
const uint32_t num_sections = section_list->GetNumSections(0);
if (num_sections == 0)
{
error.SetErrorString ("core file has no sections");
return error;
}
SetCanJIT(false);
llvm::MachO::mach_header header;
DataExtractor data (&header,
sizeof(header),
m_core_module_sp->GetArchitecture().GetByteOrder(),
m_core_module_sp->GetArchitecture().GetAddressByteSize());
bool ranges_are_sorted = true;
addr_t vm_addr = 0;
for (uint32_t i=0; i<num_sections; ++i)
{
Section *section = section_list->GetSectionAtIndex (i).get();
if (section)
{
lldb::addr_t section_vm_addr = section->GetFileAddress();
FileRange file_range (section->GetFileOffset(), section->GetFileSize());
VMRangeToFileOffset::Entry range_entry (section_vm_addr,
section->GetByteSize(),
file_range);
if (vm_addr > section_vm_addr)
ranges_are_sorted = false;
vm_addr = section->GetFileAddress();
VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
// printf ("LC_SEGMENT[%u] arange=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), frange=[0x%8.8x - 0x%8.8x)\n",
// i,
// range_entry.GetRangeBase(),
// range_entry.GetRangeEnd(),
// range_entry.data.GetRangeBase(),
// range_entry.data.GetRangeEnd());
if (last_entry &&
last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase())
{
last_entry->SetRangeEnd (range_entry.GetRangeEnd());
last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
//puts("combine");
}
else
{
m_core_aranges.Append(range_entry);
}
// Some core files don't fill in the permissions correctly. If that is the case
// assume read + execute so clients don't think the memory is not readable,
// or executable. The memory isn't writable since this plug-in doesn't implement
// DoWriteMemory.
uint32_t permissions = section->GetPermissions();
if (permissions == 0)
permissions = lldb::ePermissionsReadable | lldb::ePermissionsExecutable;
m_core_range_infos.Append(
VMRangeToPermissions::Entry(section_vm_addr, section->GetByteSize(), permissions));
}
}
if (!ranges_are_sorted)
{
m_core_aranges.Sort();
m_core_range_infos.Sort();
//.........这里部分代码省略.........
示例2: data
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
Error
ProcessMachCore::DoLoadCore ()
{
Error error;
if (!m_core_module_sp)
{
error.SetErrorString ("invalid core module");
return error;
}
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
if (core_objfile == NULL)
{
error.SetErrorString ("invalid core object file");
return error;
}
if (core_objfile->GetNumThreadContexts() == 0)
{
error.SetErrorString ("core file doesn't contain any LC_THREAD load commands, or the LC_THREAD architecture is not supported in this lldb");
return error;
}
SectionList *section_list = core_objfile->GetSectionList();
if (section_list == NULL)
{
error.SetErrorString ("core file has no sections");
return error;
}
const uint32_t num_sections = section_list->GetNumSections(0);
if (num_sections == 0)
{
error.SetErrorString ("core file has no sections");
return error;
}
SetCanJIT(false);
llvm::MachO::mach_header header;
DataExtractor data (&header,
sizeof(header),
m_core_module_sp->GetArchitecture().GetByteOrder(),
m_core_module_sp->GetArchitecture().GetAddressByteSize());
bool ranges_are_sorted = true;
addr_t vm_addr = 0;
for (uint32_t i=0; i<num_sections; ++i)
{
Section *section = section_list->GetSectionAtIndex (i).get();
if (section)
{
lldb::addr_t section_vm_addr = section->GetFileAddress();
FileRange file_range (section->GetFileOffset(), section->GetFileSize());
VMRangeToFileOffset::Entry range_entry (section_vm_addr,
section->GetByteSize(),
file_range);
if (vm_addr > section_vm_addr)
ranges_are_sorted = false;
vm_addr = section->GetFileAddress();
VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
// printf ("LC_SEGMENT[%u] arange=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), frange=[0x%8.8x - 0x%8.8x)\n",
// i,
// range_entry.GetRangeBase(),
// range_entry.GetRangeEnd(),
// range_entry.data.GetRangeBase(),
// range_entry.data.GetRangeEnd());
if (last_entry &&
last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase())
{
last_entry->SetRangeEnd (range_entry.GetRangeEnd());
last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
//puts("combine");
}
else
{
m_core_aranges.Append(range_entry);
}
}
}
if (!ranges_are_sorted)
{
m_core_aranges.Sort();
}
if (m_dyld_addr == LLDB_INVALID_ADDRESS || m_mach_kernel_addr == LLDB_INVALID_ADDRESS)
{
// We need to locate the main executable in the memory ranges
// we have in the core file. We need to search for both a user-process dyld binary
// and a kernel binary in memory; we must look at all the pages in the binary so
// we don't miss one or the other. If we find a user-process dyld binary, stop
// searching -- that's the one we'll prefer over the mach kernel.
const size_t num_core_aranges = m_core_aranges.GetSize();
for (size_t i=0; i<num_core_aranges && m_dyld_addr == LLDB_INVALID_ADDRESS; ++i)
//.........这里部分代码省略.........
示例3: data
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
Error
ProcessMachCore::DoLoadCore ()
{
Error error;
if (!m_core_module_sp)
{
error.SetErrorString ("invalid core module");
return error;
}
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
if (core_objfile == NULL)
{
error.SetErrorString ("invalid core object file");
return error;
}
if (core_objfile->GetNumThreadContexts() == 0)
{
error.SetErrorString ("core file doesn't contain any LC_THREAD load commands, or the LC_THREAD architecture is not supported in this lldb");
return error;
}
SectionList *section_list = core_objfile->GetSectionList();
if (section_list == NULL)
{
error.SetErrorString ("core file has no sections");
return error;
}
const uint32_t num_sections = section_list->GetNumSections(0);
if (num_sections == 0)
{
error.SetErrorString ("core file has no sections");
return error;
}
SetCanJIT(false);
llvm::MachO::mach_header header;
DataExtractor data (&header,
sizeof(header),
m_core_module_sp->GetArchitecture().GetByteOrder(),
m_core_module_sp->GetArchitecture().GetAddressByteSize());
bool ranges_are_sorted = true;
addr_t vm_addr = 0;
for (uint32_t i=0; i<num_sections; ++i)
{
Section *section = section_list->GetSectionAtIndex (i).get();
if (section)
{
lldb::addr_t section_vm_addr = section->GetFileAddress();
FileRange file_range (section->GetFileOffset(), section->GetFileSize());
VMRangeToFileOffset::Entry range_entry (section_vm_addr,
section->GetByteSize(),
file_range);
if (vm_addr > section_vm_addr)
ranges_are_sorted = false;
vm_addr = section->GetFileAddress();
VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
// printf ("LC_SEGMENT[%u] arange=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), frange=[0x%8.8x - 0x%8.8x)\n",
// i,
// range_entry.GetRangeBase(),
// range_entry.GetRangeEnd(),
// range_entry.data.GetRangeBase(),
// range_entry.data.GetRangeEnd());
if (last_entry &&
last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase())
{
last_entry->SetRangeEnd (range_entry.GetRangeEnd());
last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
//puts("combine");
}
else
{
m_core_aranges.Append(range_entry);
}
// After we have added this section to our m_core_aranges map,
// we can check the start of the section to see if it might
// contain dyld for user space apps, or the mach kernel file
// for kernel cores.
if (m_dyld_addr == LLDB_INVALID_ADDRESS)
GetDynamicLoaderAddress (section_vm_addr);
}
}
if (!ranges_are_sorted)
{
m_core_aranges.Sort();
}
// Even if the architecture is set in the target, we need to override
// it to match the core file which is always single arch.
//.........这里部分代码省略.........