[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- Section.cpp -------------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/Section.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Core/Address.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2013-12-06 09:12:00 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2010-09-15 07:36:40 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
|
|
|
#include "lldb/Utility/VMRange.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2018-11-12 07:16:43 +08:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <limits>
|
|
|
|
#include <utility>
|
2017-04-07 05:28:29 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
class DataExtractor;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2018-04-30 03:47:48 +08:00
|
|
|
const char *Section::GetTypeAsCString() const {
|
|
|
|
switch (m_type) {
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeInvalid:
|
|
|
|
return "invalid";
|
|
|
|
case eSectionTypeCode:
|
|
|
|
return "code";
|
|
|
|
case eSectionTypeContainer:
|
|
|
|
return "container";
|
|
|
|
case eSectionTypeData:
|
|
|
|
return "data";
|
|
|
|
case eSectionTypeDataCString:
|
|
|
|
return "data-cstr";
|
|
|
|
case eSectionTypeDataCStringPointers:
|
|
|
|
return "data-cstr-ptr";
|
|
|
|
case eSectionTypeDataSymbolAddress:
|
|
|
|
return "data-symbol-addr";
|
|
|
|
case eSectionTypeData4:
|
|
|
|
return "data-4-byte";
|
|
|
|
case eSectionTypeData8:
|
|
|
|
return "data-8-byte";
|
|
|
|
case eSectionTypeData16:
|
|
|
|
return "data-16-byte";
|
|
|
|
case eSectionTypeDataPointers:
|
|
|
|
return "data-ptrs";
|
|
|
|
case eSectionTypeDebug:
|
|
|
|
return "debug";
|
|
|
|
case eSectionTypeZeroFill:
|
|
|
|
return "zero-fill";
|
|
|
|
case eSectionTypeDataObjCMessageRefs:
|
|
|
|
return "objc-message-refs";
|
|
|
|
case eSectionTypeDataObjCCFStrings:
|
|
|
|
return "objc-cfstrings";
|
|
|
|
case eSectionTypeDWARFDebugAbbrev:
|
|
|
|
return "dwarf-abbrev";
|
2018-11-14 21:01:15 +08:00
|
|
|
case eSectionTypeDWARFDebugAbbrevDwo:
|
|
|
|
return "dwarf-abbrev-dwo";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugAddr:
|
|
|
|
return "dwarf-addr";
|
|
|
|
case eSectionTypeDWARFDebugAranges:
|
|
|
|
return "dwarf-aranges";
|
2017-08-25 21:56:14 +08:00
|
|
|
case eSectionTypeDWARFDebugCuIndex:
|
|
|
|
return "dwarf-cu-index";
|
2020-02-20 20:42:52 +08:00
|
|
|
case eSectionTypeDWARFDebugTuIndex:
|
|
|
|
return "dwarf-tu-index";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugFrame:
|
|
|
|
return "dwarf-frame";
|
|
|
|
case eSectionTypeDWARFDebugInfo:
|
|
|
|
return "dwarf-info";
|
2018-11-14 21:01:15 +08:00
|
|
|
case eSectionTypeDWARFDebugInfoDwo:
|
|
|
|
return "dwarf-info-dwo";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugLine:
|
|
|
|
return "dwarf-line";
|
2018-09-14 01:06:47 +08:00
|
|
|
case eSectionTypeDWARFDebugLineStr:
|
|
|
|
return "dwarf-line-str";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugLoc:
|
|
|
|
return "dwarf-loc";
|
2019-12-23 23:31:36 +08:00
|
|
|
case eSectionTypeDWARFDebugLocDwo:
|
|
|
|
return "dwarf-loc-dwo";
|
2018-10-23 17:46:15 +08:00
|
|
|
case eSectionTypeDWARFDebugLocLists:
|
|
|
|
return "dwarf-loclists";
|
2019-12-23 23:31:36 +08:00
|
|
|
case eSectionTypeDWARFDebugLocListsDwo:
|
|
|
|
return "dwarf-loclists-dwo";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugMacInfo:
|
|
|
|
return "dwarf-macinfo";
|
|
|
|
case eSectionTypeDWARFDebugMacro:
|
|
|
|
return "dwarf-macro";
|
|
|
|
case eSectionTypeDWARFDebugPubNames:
|
|
|
|
return "dwarf-pubnames";
|
|
|
|
case eSectionTypeDWARFDebugPubTypes:
|
|
|
|
return "dwarf-pubtypes";
|
|
|
|
case eSectionTypeDWARFDebugRanges:
|
|
|
|
return "dwarf-ranges";
|
2018-10-10 16:11:15 +08:00
|
|
|
case eSectionTypeDWARFDebugRngLists:
|
|
|
|
return "dwarf-rnglists";
|
2019-11-26 18:00:23 +08:00
|
|
|
case eSectionTypeDWARFDebugRngListsDwo:
|
|
|
|
return "dwarf-rnglists-dwo";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugStr:
|
|
|
|
return "dwarf-str";
|
2018-11-14 21:01:15 +08:00
|
|
|
case eSectionTypeDWARFDebugStrDwo:
|
|
|
|
return "dwarf-str-dwo";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeDWARFDebugStrOffsets:
|
|
|
|
return "dwarf-str-offsets";
|
2018-11-14 21:01:15 +08:00
|
|
|
case eSectionTypeDWARFDebugStrOffsetsDwo:
|
|
|
|
return "dwarf-str-offsets-dwo";
|
2018-05-09 01:19:24 +08:00
|
|
|
case eSectionTypeDWARFDebugTypes:
|
|
|
|
return "dwarf-types";
|
2019-06-12 19:42:42 +08:00
|
|
|
case eSectionTypeDWARFDebugTypesDwo:
|
|
|
|
return "dwarf-types-dwo";
|
2018-06-01 20:06:45 +08:00
|
|
|
case eSectionTypeDWARFDebugNames:
|
|
|
|
return "dwarf-names";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeELFSymbolTable:
|
|
|
|
return "elf-symbol-table";
|
|
|
|
case eSectionTypeELFDynamicSymbols:
|
|
|
|
return "elf-dynamic-symbols";
|
|
|
|
case eSectionTypeELFRelocationEntries:
|
|
|
|
return "elf-relocation-entries";
|
|
|
|
case eSectionTypeELFDynamicLinkInfo:
|
|
|
|
return "elf-dynamic-link-info";
|
|
|
|
case eSectionTypeDWARFAppleNames:
|
|
|
|
return "apple-names";
|
|
|
|
case eSectionTypeDWARFAppleTypes:
|
|
|
|
return "apple-types";
|
|
|
|
case eSectionTypeDWARFAppleNamespaces:
|
|
|
|
return "apple-namespaces";
|
|
|
|
case eSectionTypeDWARFAppleObjC:
|
|
|
|
return "apple-objc";
|
|
|
|
case eSectionTypeEHFrame:
|
|
|
|
return "eh-frame";
|
|
|
|
case eSectionTypeARMexidx:
|
|
|
|
return "ARM.exidx";
|
|
|
|
case eSectionTypeARMextab:
|
|
|
|
return "ARM.extab";
|
|
|
|
case eSectionTypeCompactUnwind:
|
|
|
|
return "compact-unwind";
|
|
|
|
case eSectionTypeGoSymtab:
|
|
|
|
return "go-symtab";
|
|
|
|
case eSectionTypeAbsoluteAddress:
|
|
|
|
return "absolute";
|
2018-04-30 03:47:48 +08:00
|
|
|
case eSectionTypeDWARFGNUDebugAltLink:
|
|
|
|
return "dwarf-gnu-debugaltlink";
|
2017-02-02 03:45:14 +08:00
|
|
|
case eSectionTypeOther:
|
|
|
|
return "regular";
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
2016-06-10 00:34:06 +08:00
|
|
|
Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
|
2019-03-07 05:22:25 +08:00
|
|
|
user_id_t sect_id, ConstString name,
|
2012-02-24 09:59:29 +08:00
|
|
|
SectionType sect_type, addr_t file_addr, addr_t byte_size,
|
2016-06-10 00:34:06 +08:00
|
|
|
lldb::offset_t file_offset, lldb::offset_t file_size,
|
|
|
|
uint32_t log2align, uint32_t flags,
|
|
|
|
uint32_t target_byte_size /*=1*/)
|
|
|
|
: ModuleChild(module_sp), UserID(sect_id), Flags(flags),
|
|
|
|
m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
|
|
|
|
m_file_addr(file_addr), m_byte_size(byte_size),
|
|
|
|
m_file_offset(file_offset), m_file_size(file_size),
|
|
|
|
m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
|
|
|
|
m_thread_specific(false), m_readable(false), m_writable(false),
|
2017-10-02 22:35:07 +08:00
|
|
|
m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
|
2012-11-30 05:49:15 +08:00
|
|
|
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ",
|
|
|
|
// addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 "
|
|
|
|
// - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s\n",
|
2012-02-24 09:59:29 +08:00
|
|
|
// this, module_sp.get(), sect_id, file_addr, file_addr +
|
|
|
|
// byte_size, file_offset, file_offset + file_size, flags,
|
|
|
|
// name.GetCString());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-06-10 00:34:06 +08:00
|
|
|
Section::Section(const lldb::SectionSP &parent_section_sp,
|
|
|
|
const ModuleSP &module_sp, ObjectFile *obj_file,
|
2019-03-07 05:22:25 +08:00
|
|
|
user_id_t sect_id, ConstString name,
|
2016-06-10 00:34:06 +08:00
|
|
|
SectionType sect_type, addr_t file_addr, addr_t byte_size,
|
|
|
|
lldb::offset_t file_offset, lldb::offset_t file_size,
|
|
|
|
uint32_t log2align, uint32_t flags,
|
|
|
|
uint32_t target_byte_size /*=1*/)
|
2012-11-30 05:49:15 +08:00
|
|
|
: ModuleChild(module_sp), UserID(sect_id), Flags(flags),
|
2016-06-10 00:34:06 +08:00
|
|
|
m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
|
|
|
|
m_file_addr(file_addr), m_byte_size(byte_size),
|
2012-02-24 09:59:29 +08:00
|
|
|
m_file_offset(file_offset), m_file_size(file_size),
|
2016-06-10 00:34:06 +08:00
|
|
|
m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
|
|
|
|
m_thread_specific(false), m_readable(false), m_writable(false),
|
2017-10-02 22:35:07 +08:00
|
|
|
m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
|
2012-11-30 05:49:15 +08:00
|
|
|
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ",
|
|
|
|
// addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 "
|
|
|
|
// - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s.%s\n",
|
2012-02-24 09:59:29 +08:00
|
|
|
// this, module_sp.get(), sect_id, file_addr, file_addr +
|
|
|
|
// byte_size, file_offset, file_offset + file_size, flags,
|
|
|
|
// parent_section_sp->GetName().GetCString(), name.GetCString());
|
|
|
|
if (parent_section_sp)
|
|
|
|
m_parent_wp = parent_section_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
Section::~Section() {
|
|
|
|
// printf ("Section::~Section(%p)\n", this);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
addr_t Section::GetFileAddress() const {
|
2012-02-24 09:59:29 +08:00
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// This section has a parent which means m_file_addr is an offset into the
|
|
|
|
// parent section, so the file address for this section is the file address
|
|
|
|
// of the parent plus the offset
|
2012-02-24 09:59:29 +08:00
|
|
|
return parent_sp->GetFileAddress() + m_file_addr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
// This section has no parent, so m_file_addr is the file base address
|
|
|
|
return m_file_addr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 11:20:42 +08:00
|
|
|
bool Section::SetFileAddress(lldb::addr_t file_addr) {
|
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp) {
|
|
|
|
if (m_file_addr >= file_addr)
|
|
|
|
return parent_sp->SetFileAddress(m_file_addr - file_addr);
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
|
|
|
// This section has no parent, so m_file_addr is the file base address
|
2013-08-16 11:20:42 +08:00
|
|
|
m_file_addr = file_addr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
lldb::addr_t Section::GetOffset() const {
|
|
|
|
// This section has a parent which means m_file_addr is an offset.
|
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp)
|
|
|
|
return m_file_addr;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// This section has no parent, so there is no offset to be had
|
2012-02-24 09:59:29 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-09-15 07:36:40 +08:00
|
|
|
addr_t Section::GetLoadBaseAddress(Target *target) const {
|
2010-06-09 00:52:24 +08:00
|
|
|
addr_t load_base_addr = LLDB_INVALID_ADDRESS;
|
2013-03-05 05:46:16 +08:00
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp) {
|
|
|
|
load_base_addr = parent_sp->GetLoadBaseAddress(target);
|
2011-08-22 10:49:39 +08:00
|
|
|
if (load_base_addr != LLDB_INVALID_ADDRESS)
|
2013-03-05 05:46:16 +08:00
|
|
|
load_base_addr += GetOffset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2014-06-25 06:22:43 +08:00
|
|
|
if (load_base_addr == LLDB_INVALID_ADDRESS) {
|
2013-03-05 05:46:16 +08:00
|
|
|
load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress(
|
|
|
|
const_cast<Section *>(this)->shared_from_this());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return load_base_addr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2017-06-08 21:26:35 +08:00
|
|
|
bool Section::ResolveContainedAddress(addr_t offset, Address &so_addr,
|
|
|
|
bool allow_section_end) const {
|
2013-01-26 02:06:21 +08:00
|
|
|
const size_t num_children = m_children.GetSize();
|
2017-06-08 21:26:35 +08:00
|
|
|
for (size_t i = 0; i < num_children; i++) {
|
|
|
|
Section *child_section = m_children.GetSectionAtIndex(i).get();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-06-08 21:26:35 +08:00
|
|
|
addr_t child_offset = child_section->GetOffset();
|
|
|
|
if (child_offset <= offset &&
|
|
|
|
offset - child_offset <
|
|
|
|
child_section->GetByteSize() + (allow_section_end ? 1 : 0))
|
|
|
|
return child_section->ResolveContainedAddress(offset - child_offset,
|
|
|
|
so_addr, allow_section_end);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
so_addr.SetOffset(offset);
|
2013-03-05 05:46:16 +08:00
|
|
|
so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-03-07 03:19:06 +08:00
|
|
|
// Ensure that there are no orphaned (i.e., moduleless) sections.
|
2013-03-05 05:46:16 +08:00
|
|
|
assert(GetModule().get());
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Section::ContainsFileAddress(addr_t vm_addr) const {
|
|
|
|
const addr_t file_addr = GetFileAddress();
|
2019-08-06 18:04:27 +08:00
|
|
|
if (file_addr != LLDB_INVALID_ADDRESS && !IsThreadSpecific()) {
|
2010-06-09 00:52:24 +08:00
|
|
|
if (file_addr <= vm_addr) {
|
2014-09-29 16:02:24 +08:00
|
|
|
const addr_t offset = (vm_addr - file_addr) * m_target_byte_size;
|
2010-06-09 00:52:24 +08:00
|
|
|
return offset < GetByteSize();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
void Section::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
|
|
|
|
uint32_t depth) const {
|
|
|
|
s.indent(indent);
|
|
|
|
s << llvm::format("0x%8.8" PRIx64 " %-16s ", GetID(), GetTypeAsCString());
|
2010-06-09 00:52:24 +08:00
|
|
|
bool resolved = true;
|
|
|
|
addr_t addr = LLDB_INVALID_ADDRESS;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (GetByteSize() == 0)
|
2020-05-13 17:13:19 +08:00
|
|
|
s.indent(39);
|
2016-09-07 04:57:50 +08:00
|
|
|
else {
|
2013-03-05 05:46:16 +08:00
|
|
|
if (target)
|
2010-09-15 07:36:40 +08:00
|
|
|
addr = GetLoadBaseAddress(target);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (addr == LLDB_INVALID_ADDRESS) {
|
2010-09-15 07:36:40 +08:00
|
|
|
if (target)
|
2010-06-09 00:52:24 +08:00
|
|
|
resolved = false;
|
|
|
|
addr = GetFileAddress();
|
|
|
|
}
|
|
|
|
|
2016-06-10 00:34:06 +08:00
|
|
|
VMRange range(addr, addr + m_byte_size);
|
2020-05-13 17:13:19 +08:00
|
|
|
range.Dump(s, 0);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
s << llvm::format("%c %c%c%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ",
|
|
|
|
resolved ? ' ' : '*', m_readable ? 'r' : '-',
|
|
|
|
m_writable ? 'w' : '-', m_executable ? 'x' : '-',
|
|
|
|
m_file_offset, m_file_size, Get());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
DumpName(s);
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
s << "\n";
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-12-08 13:08:21 +08:00
|
|
|
if (depth > 0)
|
2020-05-13 17:13:19 +08:00
|
|
|
m_children.Dump(s, indent, target, false, depth - 1);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
void Section::DumpName(llvm::raw_ostream &s) const {
|
2012-02-24 09:59:29 +08:00
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp) {
|
|
|
|
parent_sp->DumpName(s);
|
2020-05-13 17:13:19 +08:00
|
|
|
s << '.';
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
2012-02-24 09:59:29 +08:00
|
|
|
// The top most section prints the module basename
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
const char *name = nullptr;
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp(GetModule());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
Improve LLDB's handling of non-local minidumps
Normally, LLDB is creating a high-fidelity representation of a live
process, including a list of modules and sections, with the
associated memory address ranges. In order to build the module and
section map LLDB tries to locate the local module image (object file)
and will parse it.
This does not work for postmortem debugging scenarios where the crash
dump (minidump in this case) was captured on a different machine.
Fortunately the minidump format encodes enough information about
each module's memory range to allow us to create placeholder modules.
This enables most LLDB functionality involving address-to-module
translations.
Also, we may want to completly disable the search for matching
local object files if we load minidumps unless we can prove that the
local image matches the one from the crash origin.
(not part of this change, see: llvm.org/pr35193)
Example: Identify the module from a stack frame PC:
Before:
thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
frame #0: 0x00164d14
frame #1: 0x00167c79
frame #2: 0x00167e6d
frame #3: 0x7510336a
frame #4: 0x77759882
frame #5: 0x77759855
After:
thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
frame #0: 0x00164d14 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #1: 0x00167c79 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #2: 0x00167e6d C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #3: 0x7510336a C:\Windows\SysWOW64\kernel32.dll
frame #4: 0x77759882 C:\Windows\SysWOW64\ntdll.dll
frame #5: 0x77759855 C:\Windows\SysWOW64\ntdll.dll
Example: target modules list
Before:
error: the target has no associated executable images
After:
[ 0] C:\Windows\System32\MSVCP120D.dll
[ 1] C:\Windows\SysWOW64\kernel32.dll
[ 2] C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
[ 3] C:\Windows\System32\MSVCR120D.dll
[ 4] C:\Windows\SysWOW64\KERNELBASE.dll
[ 5] C:\Windows\SysWOW64\ntdll.dll
NOTE: the minidump format also includes the debug info GUID, so we can
fill-in the module UUID from it, but this part was excluded from this change
to keep the changes simple (the LLDB UUID is hardcoded to be either 16 or
20 bytes, while the CodeView GUIDs are normally 24 bytes)
Differential Revision: https://reviews.llvm.org/D45700
llvm-svn: 330302
2018-04-19 07:10:46 +08:00
|
|
|
if (m_obj_file) {
|
|
|
|
const FileSpec &file_spec = m_obj_file->GetFileSpec();
|
2013-07-02 03:45:50 +08:00
|
|
|
name = file_spec.GetFilename().AsCString();
|
Improve LLDB's handling of non-local minidumps
Normally, LLDB is creating a high-fidelity representation of a live
process, including a list of modules and sections, with the
associated memory address ranges. In order to build the module and
section map LLDB tries to locate the local module image (object file)
and will parse it.
This does not work for postmortem debugging scenarios where the crash
dump (minidump in this case) was captured on a different machine.
Fortunately the minidump format encodes enough information about
each module's memory range to allow us to create placeholder modules.
This enables most LLDB functionality involving address-to-module
translations.
Also, we may want to completly disable the search for matching
local object files if we load minidumps unless we can prove that the
local image matches the one from the crash origin.
(not part of this change, see: llvm.org/pr35193)
Example: Identify the module from a stack frame PC:
Before:
thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
frame #0: 0x00164d14
frame #1: 0x00167c79
frame #2: 0x00167e6d
frame #3: 0x7510336a
frame #4: 0x77759882
frame #5: 0x77759855
After:
thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
frame #0: 0x00164d14 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #1: 0x00167c79 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #2: 0x00167e6d C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
frame #3: 0x7510336a C:\Windows\SysWOW64\kernel32.dll
frame #4: 0x77759882 C:\Windows\SysWOW64\ntdll.dll
frame #5: 0x77759855 C:\Windows\SysWOW64\ntdll.dll
Example: target modules list
Before:
error: the target has no associated executable images
After:
[ 0] C:\Windows\System32\MSVCP120D.dll
[ 1] C:\Windows\SysWOW64\kernel32.dll
[ 2] C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
[ 3] C:\Windows\System32\MSVCR120D.dll
[ 4] C:\Windows\SysWOW64\KERNELBASE.dll
[ 5] C:\Windows\SysWOW64\ntdll.dll
NOTE: the minidump format also includes the debug info GUID, so we can
fill-in the module UUID from it, but this part was excluded from this change
to keep the changes simple (the LLDB UUID is hardcoded to be either 16 or
20 bytes, while the CodeView GUIDs are normally 24 bytes)
Differential Revision: https://reviews.llvm.org/D45700
llvm-svn: 330302
2018-04-19 07:10:46 +08:00
|
|
|
}
|
2013-07-02 03:45:50 +08:00
|
|
|
if ((!name || !name[0]) && module_sp)
|
|
|
|
name = module_sp->GetFileSpec().GetFilename().AsCString();
|
|
|
|
if (name && name[0])
|
2020-05-13 17:13:19 +08:00
|
|
|
s << name << '.';
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2020-05-22 15:36:37 +08:00
|
|
|
s << m_name;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Section::IsDescendant(const Section *section) {
|
|
|
|
if (this == section)
|
|
|
|
return true;
|
2012-02-24 09:59:29 +08:00
|
|
|
SectionSP parent_sp(GetParent());
|
|
|
|
if (parent_sp)
|
|
|
|
return parent_sp->IsDescendant(section);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Section::Slide(addr_t slide_amount, bool slide_children) {
|
|
|
|
if (m_file_addr != LLDB_INVALID_ADDRESS) {
|
|
|
|
if (slide_amount == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
m_file_addr += slide_amount;
|
|
|
|
|
|
|
|
if (slide_children)
|
|
|
|
m_children.Slide(slide_amount, slide_children);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-10 00:34:06 +08:00
|
|
|
/// Get the permissions as OR'ed bits from lldb::Permissions
|
|
|
|
uint32_t Section::GetPermissions() const {
|
|
|
|
uint32_t permissions = 0;
|
|
|
|
if (m_readable)
|
|
|
|
permissions |= ePermissionsReadable;
|
|
|
|
if (m_writable)
|
|
|
|
permissions |= ePermissionsWritable;
|
|
|
|
if (m_executable)
|
|
|
|
permissions |= ePermissionsExecutable;
|
|
|
|
return permissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set the permissions using bits OR'ed from lldb::Permissions
|
|
|
|
void Section::SetPermissions(uint32_t permissions) {
|
|
|
|
m_readable = (permissions & ePermissionsReadable) != 0;
|
|
|
|
m_writable = (permissions & ePermissionsWritable) != 0;
|
|
|
|
m_executable = (permissions & ePermissionsExecutable) != 0;
|
|
|
|
}
|
|
|
|
|
2015-11-04 09:02:43 +08:00
|
|
|
lldb::offset_t Section::GetSectionData(void *dst, lldb::offset_t dst_len,
|
|
|
|
lldb::offset_t offset) {
|
|
|
|
if (m_obj_file)
|
|
|
|
return m_obj_file->ReadSectionData(this, offset, dst, dst_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-02 22:35:07 +08:00
|
|
|
lldb::offset_t Section::GetSectionData(DataExtractor §ion_data) {
|
2015-11-04 09:02:43 +08:00
|
|
|
if (m_obj_file)
|
|
|
|
return m_obj_file->ReadSectionData(this, section_data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark SectionList
|
|
|
|
|
2013-07-10 09:23:25 +08:00
|
|
|
SectionList &SectionList::operator=(const SectionList &rhs) {
|
|
|
|
if (this != &rhs)
|
|
|
|
m_sections = rhs.m_sections;
|
|
|
|
return *this;
|
2013-07-02 03:45:50 +08:00
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
size_t SectionList::AddSection(const lldb::SectionSP §ion_sp) {
|
2014-05-14 09:12:09 +08:00
|
|
|
if (section_sp) {
|
|
|
|
size_t section_index = m_sections.size();
|
|
|
|
m_sections.push_back(section_sp);
|
|
|
|
return section_index;
|
|
|
|
}
|
2014-05-15 00:15:43 +08:00
|
|
|
|
|
|
|
return std::numeric_limits<size_t>::max();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-07-02 03:45:50 +08:00
|
|
|
// Warning, this can be slow as it's removing items from a std::vector.
|
|
|
|
bool SectionList::DeleteSection(size_t idx) {
|
|
|
|
if (idx < m_sections.size()) {
|
|
|
|
m_sections.erase(m_sections.begin() + idx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
size_t SectionList::FindSectionIndex(const Section *sect) {
|
2013-01-26 02:06:21 +08:00
|
|
|
iterator sect_iter;
|
|
|
|
iterator begin = m_sections.begin();
|
2010-06-09 00:52:24 +08:00
|
|
|
iterator end = m_sections.end();
|
|
|
|
for (sect_iter = begin; sect_iter != end; ++sect_iter) {
|
|
|
|
if (sect_iter->get() == sect) {
|
|
|
|
// The secton was already in this section list
|
|
|
|
return std::distance(begin, sect_iter);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t SectionList::AddUniqueSection(const lldb::SectionSP §_sp) {
|
|
|
|
size_t sect_idx = FindSectionIndex(sect_sp.get());
|
|
|
|
if (sect_idx == UINT32_MAX) {
|
|
|
|
sect_idx = AddSection(sect_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sect_idx;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
bool SectionList::ReplaceSection(user_id_t sect_id,
|
2010-06-09 00:52:24 +08:00
|
|
|
const lldb::SectionSP §_sp,
|
|
|
|
uint32_t depth) {
|
|
|
|
iterator sect_iter, end = m_sections.end();
|
|
|
|
for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
|
|
|
|
if ((*sect_iter)->GetID() == sect_id) {
|
|
|
|
*sect_iter = sect_sp;
|
|
|
|
return true;
|
|
|
|
} else if (depth > 0) {
|
|
|
|
if ((*sect_iter)
|
|
|
|
->GetChildren()
|
|
|
|
.ReplaceSection(sect_id, sect_sp, depth - 1))
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t SectionList::GetNumSections(uint32_t depth) const {
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t count = m_sections.size();
|
2012-02-24 09:59:29 +08:00
|
|
|
if (depth > 0) {
|
2010-06-09 00:52:24 +08:00
|
|
|
const_iterator sect_iter, end = m_sections.end();
|
|
|
|
for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
|
2014-05-14 09:12:09 +08:00
|
|
|
count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionSP SectionList::GetSectionAtIndex(size_t idx) const {
|
|
|
|
SectionSP sect_sp;
|
|
|
|
if (idx < m_sections.size())
|
|
|
|
sect_sp = m_sections[idx];
|
|
|
|
return sect_sp;
|
|
|
|
}
|
|
|
|
|
2010-07-22 05:49:46 +08:00
|
|
|
SectionSP
|
2019-03-07 05:22:25 +08:00
|
|
|
SectionList::FindSectionByName(ConstString section_dstr) const {
|
2010-07-22 05:49:46 +08:00
|
|
|
SectionSP sect_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
// Check if we have a valid section string
|
2013-01-26 02:06:21 +08:00
|
|
|
if (section_dstr && !m_sections.empty()) {
|
2010-06-09 00:52:24 +08:00
|
|
|
const_iterator sect_iter;
|
2013-01-26 02:06:21 +08:00
|
|
|
const_iterator end = m_sections.end();
|
2010-06-09 00:52:24 +08:00
|
|
|
for (sect_iter = m_sections.begin();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
|
2013-01-26 02:06:21 +08:00
|
|
|
Section *child_section = sect_iter->get();
|
|
|
|
if (child_section) {
|
2010-07-22 05:49:46 +08:00
|
|
|
if (child_section->GetName() == section_dstr) {
|
|
|
|
sect_sp = *sect_iter;
|
2010-07-22 06:54:26 +08:00
|
|
|
} else {
|
|
|
|
sect_sp =
|
|
|
|
child_section->GetChildren().FindSectionByName(section_dstr);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-07-22 05:49:46 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-07-22 05:49:46 +08:00
|
|
|
return sect_sp;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SectionSP SectionList::FindSectionByID(user_id_t sect_id) const {
|
|
|
|
SectionSP sect_sp;
|
|
|
|
if (sect_id) {
|
|
|
|
const_iterator sect_iter;
|
|
|
|
const_iterator end = m_sections.end();
|
|
|
|
for (sect_iter = m_sections.begin();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
|
2010-06-09 00:52:24 +08:00
|
|
|
if ((*sect_iter)->GetID() == sect_id) {
|
|
|
|
sect_sp = *sect_iter;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sect_sp;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SectionSP SectionList::FindSectionByType(SectionType sect_type,
|
2013-01-26 02:06:21 +08:00
|
|
|
bool check_children,
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t start_idx) const {
|
|
|
|
SectionSP sect_sp;
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t num_sections = m_sections.size();
|
2010-06-09 00:52:24 +08:00
|
|
|
for (size_t idx = start_idx; idx < num_sections; ++idx) {
|
|
|
|
if (m_sections[idx]->GetType() == sect_type) {
|
2010-12-08 13:08:21 +08:00
|
|
|
sect_sp = m_sections[idx];
|
|
|
|
break;
|
|
|
|
} else if (check_children) {
|
2010-12-08 02:05:22 +08:00
|
|
|
sect_sp = m_sections[idx]->GetChildren().FindSectionByType(
|
2010-06-09 00:52:24 +08:00
|
|
|
sect_type, check_children, 0);
|
|
|
|
if (sect_sp)
|
2016-06-10 00:34:06 +08:00
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sect_sp;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-06-10 00:34:06 +08:00
|
|
|
SectionSP SectionList::FindSectionContainingFileAddress(addr_t vm_addr,
|
2012-02-24 09:59:29 +08:00
|
|
|
uint32_t depth) const {
|
2010-06-09 00:52:24 +08:00
|
|
|
SectionSP sect_sp;
|
|
|
|
const_iterator sect_iter;
|
|
|
|
const_iterator end = m_sections.end();
|
|
|
|
for (sect_iter = m_sections.begin();
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
|
2010-12-08 13:08:21 +08:00
|
|
|
Section *sect = sect_iter->get();
|
|
|
|
if (sect->ContainsFileAddress(vm_addr)) {
|
|
|
|
// The file address is in this section. We need to make sure one of our
|
2018-05-01 00:49:04 +08:00
|
|
|
// child sections doesn't contain this address as well as obeying the
|
|
|
|
// depth limit that was passed in.
|
2010-06-09 00:52:24 +08:00
|
|
|
if (depth > 0)
|
|
|
|
sect_sp = sect->GetChildren().FindSectionContainingFileAddress(
|
2010-12-08 13:08:21 +08:00
|
|
|
vm_addr, depth - 1);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
if (sect_sp.get() == nullptr && !sect->IsFake())
|
2014-05-14 09:12:09 +08:00
|
|
|
sect_sp = *sect_iter;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sect_sp;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool SectionList::ContainsSection(user_id_t sect_id) const {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return FindSectionByID(sect_id).get() != nullptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
void SectionList::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
|
|
|
|
bool show_header, uint32_t depth) const {
|
2016-06-10 00:34:06 +08:00
|
|
|
bool target_has_loaded_sections =
|
2010-12-08 02:05:22 +08:00
|
|
|
target && !target->GetSectionLoadList().IsEmpty();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (show_header && !m_sections.empty()) {
|
2020-05-13 17:13:19 +08:00
|
|
|
s.indent(indent);
|
|
|
|
s << llvm::formatv(
|
|
|
|
"SectID Type {0} Address "
|
|
|
|
" Perm File Off. File Size Flags "
|
|
|
|
" Section Name\n",
|
|
|
|
target_has_loaded_sections ? "Load" : "File");
|
|
|
|
s.indent(indent);
|
|
|
|
s << "---------- ---------------- "
|
|
|
|
"--------------------------------------- ---- ---------- "
|
|
|
|
"---------- "
|
|
|
|
"---------- ----------------------------\n";
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-13 17:13:19 +08:00
|
|
|
for (const auto §ion_sp : m_sections)
|
|
|
|
section_sp->Dump(s, indent, target_has_loaded_sections ? target : nullptr,
|
|
|
|
depth);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t SectionList::Slide(addr_t slide_amount, bool slide_children) {
|
|
|
|
size_t count = 0;
|
|
|
|
const_iterator pos, end = m_sections.end();
|
|
|
|
for (pos = m_sections.begin(); pos != end; ++pos) {
|
|
|
|
if ((*pos)->Slide(slide_amount, slide_children))
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|