diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 | 
| commit | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch) | |
| tree | 4adf86a776049cbf7f69a1929c4babcbbef925eb /lldb/source/Utility | |
| parent | 7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff) | |
Notes
Diffstat (limited to 'lldb/source/Utility')
| -rw-r--r-- | lldb/source/Utility/ArchSpec.cpp | 41 | ||||
| -rw-r--r-- | lldb/source/Utility/Baton.cpp | 5 | ||||
| -rw-r--r-- | lldb/source/Utility/Broadcaster.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Utility/ConstString.cpp | 1 | ||||
| -rw-r--r-- | lldb/source/Utility/DataBufferLLVM.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Utility/DataEncoder.cpp | 52 | ||||
| -rw-r--r-- | lldb/source/Utility/DataExtractor.cpp | 58 | ||||
| -rw-r--r-- | lldb/source/Utility/Environment.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Utility/FileSpec.cpp | 57 | ||||
| -rw-r--r-- | lldb/source/Utility/GDBRemote.cpp | 73 | ||||
| -rw-r--r-- | lldb/source/Utility/LLDBAssert.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Utility/PPC64LE_ehframe_Registers.h | 193 | ||||
| -rw-r--r-- | lldb/source/Utility/ProcessInfo.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Utility/RegisterValue.cpp | 34 | ||||
| -rw-r--r-- | lldb/source/Utility/Reproducer.cpp | 66 | ||||
| -rw-r--r-- | lldb/source/Utility/Scalar.cpp | 23 | ||||
| -rw-r--r-- | lldb/source/Utility/Status.cpp | 21 | ||||
| -rw-r--r-- | lldb/source/Utility/Stream.cpp | 82 | ||||
| -rw-r--r-- | lldb/source/Utility/StreamString.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Utility/StructuredData.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Utility/VMRange.cpp | 7 | 
21 files changed, 234 insertions, 514 deletions
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 40cc4a092b0d..3dae25ceacd6 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -9,17 +9,13 @@  #include "lldb/Utility/ArchSpec.h"  #include "lldb/Utility/Log.h" -#include "lldb/Utility/NameMatches.h" -#include "lldb/Utility/Stream.h"  #include "lldb/Utility/StringList.h"  #include "lldb/lldb-defines.h"  #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/Twine.h"  #include "llvm/BinaryFormat/COFF.h"  #include "llvm/BinaryFormat/ELF.h"  #include "llvm/BinaryFormat/MachO.h"  #include "llvm/Support/Compiler.h" -#include "llvm/Support/Host.h"  using namespace lldb;  using namespace lldb_private; @@ -61,6 +57,8 @@ static const CoreDefinition g_core_definitions[] = {       "armv6m"},      {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7,       "armv7"}, +    {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7l, +     "armv7l"},      {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7f,       "armv7f"},      {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv7s, @@ -101,6 +99,8 @@ static const CoreDefinition g_core_definitions[] = {       ArchSpec::eCore_arm_arm64, "arm64"},      {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,       ArchSpec::eCore_arm_armv8, "armv8"}, +    {eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, +      ArchSpec::eCore_arm_armv8l, "armv8l"},      {eByteOrderLittle, 4, 4, 4, llvm::Triple::aarch64_32,        ArchSpec::eCore_arm_arm64_32, "arm64_32"},      {eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64, @@ -444,7 +444,7 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {      {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,       LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON      {ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE, -     0xFFFFFFFFu, 0xFFFFFFFFu }, // ARC +     0xFFFFFFFFu, 0xFFFFFFFFu}, // ARC  };  static const ArchDefinition g_elf_arch_def = { @@ -564,20 +564,6 @@ ArchSpec::ArchSpec(ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) {  ArchSpec::~ArchSpec() = default; -//===----------------------------------------------------------------------===// -// Assignment and initialization. - -const ArchSpec &ArchSpec::operator=(const ArchSpec &rhs) { -  if (this != &rhs) { -    m_triple = rhs.m_triple; -    m_core = rhs.m_core; -    m_byte_order = rhs.m_byte_order; -    m_distribution_id = rhs.m_distribution_id; -    m_flags = rhs.m_flags; -  } -  return *this; -} -  void ArchSpec::Clear() {    m_triple = llvm::Triple();    m_core = kCore_invalid; @@ -878,7 +864,7 @@ void ArchSpec::MergeFrom(const ArchSpec &other) {        IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic &&        other.GetCore() != ArchSpec::eCore_arm_generic) {      m_core = other.GetCore(); -    CoreUpdated(true); +    CoreUpdated(false);    }    if (GetFlags() == 0) {      SetFlags(other.GetFlags()); @@ -1202,6 +1188,8 @@ static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2,    case ArchSpec::eCore_arm_armv7f:    case ArchSpec::eCore_arm_armv7k:    case ArchSpec::eCore_arm_armv7s: +  case ArchSpec::eCore_arm_armv7l: +  case ArchSpec::eCore_arm_armv8l:      if (!enforce_exact_match) {        if (core2 == ArchSpec::eCore_arm_generic)          return true; @@ -1451,21 +1439,24 @@ bool ArchSpec::IsAlwaysThumbInstructions() const {          GetCore() == ArchSpec::Core::eCore_thumbv6m) {        return true;      } +    // Windows on ARM is always thumb. +    if (GetTriple().isOSWindows()) +      return true;    }    return false;  } -void ArchSpec::DumpTriple(Stream &s) const { +void ArchSpec::DumpTriple(llvm::raw_ostream &s) const {    const llvm::Triple &triple = GetTriple();    llvm::StringRef arch_str = triple.getArchName();    llvm::StringRef vendor_str = triple.getVendorName();    llvm::StringRef os_str = triple.getOSName();    llvm::StringRef environ_str = triple.getEnvironmentName(); -  s.Printf("%s-%s-%s", arch_str.empty() ? "*" : arch_str.str().c_str(), -           vendor_str.empty() ? "*" : vendor_str.str().c_str(), -           os_str.empty() ? "*" : os_str.str().c_str()); +  s << llvm::formatv("{0}-{1}-{2}", arch_str.empty() ? "*" : arch_str, +                     vendor_str.empty() ? "*" : vendor_str, +                     os_str.empty() ? "*" : os_str);    if (!environ_str.empty()) -    s.Printf("-%s", environ_str.str().c_str()); +    s << "-" << environ_str;  } diff --git a/lldb/source/Utility/Baton.cpp b/lldb/source/Utility/Baton.cpp index 84e295e24686..7bba10dcec96 100644 --- a/lldb/source/Utility/Baton.cpp +++ b/lldb/source/Utility/Baton.cpp @@ -8,5 +8,6 @@  #include "lldb/Utility/Baton.h" -void lldb_private::UntypedBaton::GetDescription( -    Stream *s, lldb::DescriptionLevel level) const {} +void lldb_private::UntypedBaton::GetDescription(llvm::raw_ostream &s, +                                                lldb::DescriptionLevel level, +                                                unsigned indentation) const {} diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp index 148fdf7ba5b1..ee0c39f8fd42 100644 --- a/lldb/source/Utility/Broadcaster.cpp +++ b/lldb/source/Utility/Broadcaster.cpp @@ -17,7 +17,6 @@  #include <algorithm>  #include <memory> -#include <type_traits>  #include <utility>  #include <assert.h> @@ -318,9 +317,6 @@ bool BroadcastEventSpec::operator<(const BroadcastEventSpec &rhs) const {    return GetBroadcasterClass() < rhs.GetBroadcasterClass();  } -BroadcastEventSpec &BroadcastEventSpec:: -operator=(const BroadcastEventSpec &rhs) = default; -  BroadcasterManager::BroadcasterManager() : m_manager_mutex() {}  lldb::BroadcasterManagerSP BroadcasterManager::MakeBroadcasterManager() { diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index 2516ecf6a989..e90bb929bb81 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -18,7 +18,6 @@  #include "llvm/Support/RWMutex.h"  #include "llvm/Support/Threading.h" -#include <algorithm>  #include <array>  #include <utility> diff --git a/lldb/source/Utility/DataBufferLLVM.cpp b/lldb/source/Utility/DataBufferLLVM.cpp index 4227e9b39960..c20e1b06f52e 100644 --- a/lldb/source/Utility/DataBufferLLVM.cpp +++ b/lldb/source/Utility/DataBufferLLVM.cpp @@ -8,12 +8,9 @@  #include "lldb/Utility/DataBufferLLVM.h" -#include "llvm/ADT/Twine.h" -#include "llvm/Support/FileSystem.h"  #include "llvm/Support/MemoryBuffer.h"  #include <assert.h> -#include <type_traits>  using namespace lldb_private; diff --git a/lldb/source/Utility/DataEncoder.cpp b/lldb/source/Utility/DataEncoder.cpp index 13c505e34e82..8a1036e26dce 100644 --- a/lldb/source/Utility/DataEncoder.cpp +++ b/lldb/source/Utility/DataEncoder.cpp @@ -13,9 +13,7 @@  #include "llvm/Support/Endian.h"  #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MathExtras.h" -#include <cassert>  #include <cstddef>  #include <string.h> @@ -61,42 +59,6 @@ void DataEncoder::Clear() {    m_data_sp.reset();  } -// If this object contains shared data, this function returns the offset into -// that shared data. Else zero is returned. -size_t DataEncoder::GetSharedDataOffset() const { -  if (m_start != nullptr) { -    const DataBuffer *data = m_data_sp.get(); -    if (data != nullptr) { -      const uint8_t *data_bytes = data->GetBytes(); -      if (data_bytes != nullptr) { -        assert(m_start >= data_bytes); -        return m_start - data_bytes; -      } -    } -  } -  return 0; -} - -// Set the data with which this object will extract from to data starting at -// BYTES and set the length of the data to LENGTH bytes long. The data is -// externally owned must be around at least as long as this object points to -// the data. No copy of the data is made, this object just refers to this data -// and can extract from it. If this object refers to any shared data upon -// entry, the reference to that data will be released. Is SWAP is set to true, -// any data extracted will be endian swapped. -uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) { -  m_byte_order = endian; -  m_data_sp.reset(); -  if (bytes == nullptr || length == 0) { -    m_start = nullptr; -    m_end = nullptr; -  } else { -    m_start = static_cast<uint8_t *>(bytes); -    m_end = m_start + length; -  } -  return GetByteSize(); -} -  // Assign the data for this object to be a subrange of the shared data in  // "data_sp" starting "data_offset" bytes into "data_sp" and ending  // "data_length" bytes later. If "data_offset" is not a valid offset into @@ -187,16 +149,8 @@ uint32_t DataEncoder::PutU64(uint32_t offset, uint64_t value) {    return UINT32_MAX;  } -// Extract a single integer value from the data and update the offset pointed -// to by "offset_ptr". The size of the extracted integer is specified by the -// "byte_size" argument. "byte_size" should have a value >= 1 and <= 8 since -// the return value is only 64 bits wide. Any "byte_size" values less than 1 or -// greater than 8 will result in nothing being extracted, and zero being -// returned. -// -// RETURNS the integer value that was extracted, or zero on failure. -uint32_t DataEncoder::PutMaxU64(uint32_t offset, uint32_t byte_size, -                                uint64_t value) { +uint32_t DataEncoder::PutUnsigned(uint32_t offset, uint32_t byte_size, +                                  uint64_t value) {    switch (byte_size) {    case 1:      return PutU8(offset, value); @@ -225,7 +179,7 @@ uint32_t DataEncoder::PutData(uint32_t offset, const void *src,  }  uint32_t DataEncoder::PutAddress(uint32_t offset, lldb::addr_t addr) { -  return PutMaxU64(offset, GetAddressByteSize(), addr); +  return PutUnsigned(offset, m_addr_size, addr);  }  uint32_t DataEncoder::PutCString(uint32_t offset, const char *cstr) { diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index f642a8fc7639..fed2a1326b86 100644 --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -129,9 +129,8 @@ DataExtractor::DataExtractor()  DataExtractor::DataExtractor(const void *data, offset_t length,                               ByteOrder endian, uint32_t addr_size,                               uint32_t target_byte_size /*=1*/) -    : m_start(const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(data))), -      m_end(const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(data)) + -            length), +    : m_start(const_cast<uint8_t *>(static_cast<const uint8_t *>(data))), +      m_end(const_cast<uint8_t *>(static_cast<const uint8_t *>(data)) + length),        m_byte_order(endian), m_addr_size(addr_size), m_data_sp(),        m_target_byte_size(target_byte_size) {    assert(addr_size == 4 || addr_size == 8); @@ -232,7 +231,7 @@ lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length,      m_start = nullptr;      m_end = nullptr;    } else { -    m_start = const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(bytes)); +    m_start = const_cast<uint8_t *>(static_cast<const uint8_t *>(bytes));      m_end = m_start + length;    }    return GetByteSize(); @@ -577,18 +576,28 @@ int64_t DataExtractor::GetMaxS64(offset_t *offset_ptr, size_t byte_size) const {  uint64_t DataExtractor::GetMaxU64Bitfield(offset_t *offset_ptr, size_t size,                                            uint32_t bitfield_bit_size,                                            uint32_t bitfield_bit_offset) const { +  assert(bitfield_bit_size <= 64);    uint64_t uval64 = GetMaxU64(offset_ptr, size); -  if (bitfield_bit_size > 0) { -    int32_t lsbcount = bitfield_bit_offset; -    if (m_byte_order == eByteOrderBig) -      lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size; -    if (lsbcount > 0) -      uval64 >>= lsbcount; -    uint64_t bitfield_mask = ((1ul << bitfield_bit_size) - 1); -    if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64) -      return uval64; -    uval64 &= bitfield_mask; -  } + +  if (bitfield_bit_size == 0) +    return uval64; + +  int32_t lsbcount = bitfield_bit_offset; +  if (m_byte_order == eByteOrderBig) +    lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size; + +  if (lsbcount > 0) +    uval64 >>= lsbcount; + +  uint64_t bitfield_mask = +      (bitfield_bit_size == 64 +           ? std::numeric_limits<uint64_t>::max() +           : ((static_cast<uint64_t>(1) << bitfield_bit_size) - 1)); +  if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64) +    return uval64; + +  uval64 &= bitfield_mask; +    return uval64;  } @@ -975,8 +984,7 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {  lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,                                         offset_t length, uint64_t base_addr,                                         uint32_t num_per_line, -                                       DataExtractor::Type type, -                                       const char *format) const { +                                       DataExtractor::Type type) const {    if (log == nullptr)      return start_offset; @@ -1000,29 +1008,29 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,      switch (type) {      case TypeUInt8: -      sstr.Printf(format ? format : " %2.2x", GetU8(&offset)); +      sstr.Printf(" %2.2x", GetU8(&offset));        break;      case TypeChar: {        char ch = GetU8(&offset); -      sstr.Printf(format ? format : " %c", isprint(ch) ? ch : ' '); +      sstr.Printf(" %c", isprint(ch) ? ch : ' ');      } break;      case TypeUInt16: -      sstr.Printf(format ? format : " %4.4x", GetU16(&offset)); +      sstr.Printf(" %4.4x", GetU16(&offset));        break;      case TypeUInt32: -      sstr.Printf(format ? format : " %8.8x", GetU32(&offset)); +      sstr.Printf(" %8.8x", GetU32(&offset));        break;      case TypeUInt64: -      sstr.Printf(format ? format : " %16.16" PRIx64, GetU64(&offset)); +      sstr.Printf(" %16.16" PRIx64, GetU64(&offset));        break;      case TypePointer: -      sstr.Printf(format ? format : " 0x%" PRIx64, GetAddress(&offset)); +      sstr.Printf(" 0x%" PRIx64, GetAddress(&offset));        break;      case TypeULEB128: -      sstr.Printf(format ? format : " 0x%" PRIx64, GetULEB128(&offset)); +      sstr.Printf(" 0x%" PRIx64, GetULEB128(&offset));        break;      case TypeSLEB128: -      sstr.Printf(format ? format : " %" PRId64, GetSLEB128(&offset)); +      sstr.Printf(" %" PRId64, GetSLEB128(&offset));        break;      }    } diff --git a/lldb/source/Utility/Environment.cpp b/lldb/source/Utility/Environment.cpp index 140533600712..8cafd3024618 100644 --- a/lldb/source/Utility/Environment.cpp +++ b/lldb/source/Utility/Environment.cpp @@ -13,7 +13,7 @@ using namespace lldb_private;  char *Environment::Envp::make_entry(llvm::StringRef Key,                                      llvm::StringRef Value) {    const size_t size = Key.size() + 1 /*=*/ + Value.size() + 1 /*\0*/; -  char *Result = reinterpret_cast<char *>( +  char *Result = static_cast<char *>(        Allocator.Allocate(sizeof(char) * size, alignof(char)));    char *Next = Result; @@ -26,7 +26,7 @@ char *Environment::Envp::make_entry(llvm::StringRef Key,  }  Environment::Envp::Envp(const Environment &Env) { -  Data = reinterpret_cast<char **>( +  Data = static_cast<char **>(        Allocator.Allocate(sizeof(char *) * (Env.size() + 1), alignof(char *)));    char **Next = Data;    for (const auto &KV : Env) diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index f22ab4d84e40..5c216d947f75 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -75,15 +75,6 @@ FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {  FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple)      : FileSpec{path, triple.isOSWindows() ? Style::windows : Style::posix} {} -// Copy constructor -FileSpec::FileSpec(const FileSpec *rhs) : m_directory(), m_filename() { -  if (rhs) -    *this = *rhs; -} - -// Virtual destructor in case anyone inherits from this class. -FileSpec::~FileSpec() {} -  namespace {  /// Safely get a character at the specified index.  /// @@ -174,16 +165,6 @@ bool needsNormalization(const llvm::StringRef &path) {  } -// Assignment operator. -const FileSpec &FileSpec::operator=(const FileSpec &rhs) { -  if (this != &rhs) { -    m_directory = rhs.m_directory; -    m_filename = rhs.m_filename; -    m_is_resolved = rhs.m_is_resolved; -    m_style = rhs.m_style; -  } -  return *this; -}  void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); } @@ -271,7 +252,7 @@ bool FileSpec::operator<(const FileSpec &rhs) const {  // Dump a FileSpec object to a stream  Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) { -  f.Dump(&s); +  f.Dump(s.AsRawOstream());    return s;  } @@ -312,20 +293,18 @@ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) {  }  bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) { -  // case sensitivity of equality test -  const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive(); - -  const bool filenames_equal = ConstString::Equals(a.m_filename, -                                                   b.m_filename, -                                                   case_sensitive); - -  if (!filenames_equal) -    return false; +  if (full || (a.GetDirectory() && b.GetDirectory())) +    return a == b; -  if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty())) -    return filenames_equal; +  return a.FileEquals(b); +} -  return a == b; +bool FileSpec::Match(const FileSpec &pattern, const FileSpec &file) { +  if (pattern.GetDirectory()) +    return pattern == file; +  if (pattern.GetFilename()) +    return pattern.FileEquals(file); +  return true;  }  llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolute_path) { @@ -342,14 +321,12 @@ llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolut  // Dump the object to the supplied stream. If the object contains a valid  // directory name, it will be displayed followed by a directory delimiter, and  // the filename. -void FileSpec::Dump(Stream *s) const { -  if (s) { -    std::string path{GetPath(true)}; -    s->PutCString(path); -    char path_separator = GetPreferredPathSeparator(m_style); -    if (!m_filename && !path.empty() && path.back() != path_separator) -      s->PutChar(path_separator); -  } +void FileSpec::Dump(llvm::raw_ostream &s) const { +  std::string path{GetPath(true)}; +  s << path; +  char path_separator = GetPreferredPathSeparator(m_style); +  if (!m_filename && !path.empty() && path.back() != path_separator) +    s << path_separator;  }  FileSpec::Style FileSpec::GetPathStyle() const { return m_style; } diff --git a/lldb/source/Utility/GDBRemote.cpp b/lldb/source/Utility/GDBRemote.cpp index 85c4bc69a8d1..f267d00fc97e 100644 --- a/lldb/source/Utility/GDBRemote.cpp +++ b/lldb/source/Utility/GDBRemote.cpp @@ -14,6 +14,7 @@  #include <stdio.h>  using namespace lldb; +using namespace lldb_private::repro;  using namespace lldb_private;  using namespace llvm; @@ -45,12 +46,6 @@ int StreamGDBRemote::PutEscapedBytes(const void *s, size_t src_len) {    return bytes_written;  } -void GDBRemotePacket::Serialize(raw_ostream &strm) const { -  yaml::Output yout(strm); -  yout << const_cast<GDBRemotePacket &>(*this); -  strm.flush(); -} -  llvm::StringRef GDBRemotePacket::GetTypeStr() const {    switch (type) {    case GDBRemotePacket::ePacketTypeSend: @@ -98,8 +93,68 @@ void yaml::MappingTraits<GDBRemotePacket>::mapping(IO &io,  StringRef  yaml::MappingTraits<GDBRemotePacket>::validate(IO &io,                                                 GDBRemotePacket &Packet) { -  if (Packet.bytes_transmitted != Packet.packet.data.size()) -    return "BinaryData size doesn't match bytes transmitted"; -    return {};  } + +void GDBRemoteProvider::Keep() { +  std::vector<std::string> files; +  for (auto &recorder : m_packet_recorders) { +    files.push_back(recorder->GetFilename().GetPath()); +  } + +  FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file); +  std::error_code ec; +  llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text); +  if (ec) +    return; +  yaml::Output yout(os); +  yout << files; +} + +void GDBRemoteProvider::Discard() { m_packet_recorders.clear(); } + +llvm::Expected<std::unique_ptr<PacketRecorder>> +PacketRecorder::Create(const FileSpec &filename) { +  std::error_code ec; +  auto recorder = std::make_unique<PacketRecorder>(std::move(filename), ec); +  if (ec) +    return llvm::errorCodeToError(ec); +  return std::move(recorder); +} + +PacketRecorder *GDBRemoteProvider::GetNewPacketRecorder() { +  std::size_t i = m_packet_recorders.size() + 1; +  std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") + +                          llvm::Twine(i) + llvm::Twine(".yaml")) +                             .str(); +  auto recorder_or_error = +      PacketRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename)); +  if (!recorder_or_error) { +    llvm::consumeError(recorder_or_error.takeError()); +    return nullptr; +  } + +  m_packet_recorders.push_back(std::move(*recorder_or_error)); +  return m_packet_recorders.back().get(); +} + +void PacketRecorder::Record(const GDBRemotePacket &packet) { +  if (!m_record) +    return; +  yaml::Output yout(m_os); +  yout << const_cast<GDBRemotePacket &>(packet); +  m_os.flush(); +} + +llvm::raw_ostream *GDBRemoteProvider::GetHistoryStream() { +  FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file); + +  std::error_code EC; +  m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC, +                                                 sys::fs::OpenFlags::OF_Text); +  return m_stream_up.get(); +} + +char GDBRemoteProvider::ID = 0; +const char *GDBRemoteProvider::Info::file = "gdb-remote.yaml"; +const char *GDBRemoteProvider::Info::name = "gdb-remote"; diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp index 75530d806310..361d6d04a28f 100644 --- a/lldb/source/Utility/LLDBAssert.cpp +++ b/lldb/source/Utility/LLDBAssert.cpp @@ -21,10 +21,10 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text,    if (LLVM_LIKELY(expression))      return; -  // In a Debug configuration lldb_assert() behaves like assert(0). -  llvm_unreachable("lldb_assert failed"); +  // If asserts are enabled abort here. +  assert(false && "lldb_assert failed"); -  // In a Release configuration it will print a warning and encourage the user +  // In a release configuration it will print a warning and encourage the user    // to file a bug report, similar to LLVM’s crash handler, and then return    // execution.    errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", diff --git a/lldb/source/Utility/PPC64LE_ehframe_Registers.h b/lldb/source/Utility/PPC64LE_ehframe_Registers.h deleted file mode 100644 index 77cb3e5924e7..000000000000 --- a/lldb/source/Utility/PPC64LE_ehframe_Registers.h +++ /dev/null @@ -1,193 +0,0 @@ -//===-- PPC64LE_ehframe_Registers.h -----------------------------*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#ifndef utility_PPC64LE_ehframe_Registers_h_ -#define utility_PPC64LE_ehframe_Registers_h_ - -// The register numbers used in the eh_frame unwind information. -// Should be the same as DWARF register numbers. - -namespace ppc64le_ehframe { - -enum { -  r0 = 0, -  r1, -  r2, -  r3, -  r4, -  r5, -  r6, -  r7, -  r8, -  r9, -  r10, -  r11, -  r12, -  r13, -  r14, -  r15, -  r16, -  r17, -  r18, -  r19, -  r20, -  r21, -  r22, -  r23, -  r24, -  r25, -  r26, -  r27, -  r28, -  r29, -  r30, -  r31, -  f0, -  f1, -  f2, -  f3, -  f4, -  f5, -  f6, -  f7, -  f8, -  f9, -  f10, -  f11, -  f12, -  f13, -  f14, -  f15, -  f16, -  f17, -  f18, -  f19, -  f20, -  f21, -  f22, -  f23, -  f24, -  f25, -  f26, -  f27, -  f28, -  f29, -  f30, -  f31, -  lr = 65, -  ctr, -  cr = 68, -  xer = 76, -  vr0, -  vr1, -  vr2, -  vr3, -  vr4, -  vr5, -  vr6, -  vr7, -  vr8, -  vr9, -  vr10, -  vr11, -  vr12, -  vr13, -  vr14, -  vr15, -  vr16, -  vr17, -  vr18, -  vr19, -  vr20, -  vr21, -  vr22, -  vr23, -  vr24, -  vr25, -  vr26, -  vr27, -  vr28, -  vr29, -  vr30, -  vr31, -  vscr = 110, -  vrsave = 117, -  pc, -  softe, -  trap, -  origr3, -  fpscr, -  msr, -  vs0, -  vs1, -  vs2, -  vs3, -  vs4, -  vs5, -  vs6, -  vs7, -  vs8, -  vs9, -  vs10, -  vs11, -  vs12, -  vs13, -  vs14, -  vs15, -  vs16, -  vs17, -  vs18, -  vs19, -  vs20, -  vs21, -  vs22, -  vs23, -  vs24, -  vs25, -  vs26, -  vs27, -  vs28, -  vs29, -  vs30, -  vs31, -  vs32, -  vs33, -  vs34, -  vs35, -  vs36, -  vs37, -  vs38, -  vs39, -  vs40, -  vs41, -  vs42, -  vs43, -  vs44, -  vs45, -  vs46, -  vs47, -  vs48, -  vs49, -  vs50, -  vs51, -  vs52, -  vs53, -  vs54, -  vs55, -  vs56, -  vs57, -  vs58, -  vs59, -  vs60, -  vs61, -  vs62, -  vs63, -}; -} - -#endif // utility_PPC64LE_ehframe_Registers_h_ diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp index 5743d223be4f..b159e2641973 100644 --- a/lldb/source/Utility/ProcessInfo.cpp +++ b/lldb/source/Utility/ProcessInfo.cpp @@ -49,7 +49,7 @@ llvm::StringRef ProcessInfo::GetNameAsStringRef() const {  void ProcessInfo::Dump(Stream &s, Platform *platform) const {    s << "Executable: " << GetName() << "\n";    s << "Triple: "; -  m_arch.DumpTriple(s); +  m_arch.DumpTriple(s.AsRawOstream());    s << "\n";    s << "Arguments:\n"; @@ -119,7 +119,7 @@ void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {    if (m_executable) {      s.Printf("   name = %s\n", m_executable.GetFilename().GetCString());      s.PutCString("   file = "); -    m_executable.Dump(&s); +    m_executable.Dump(s.AsRawOstream());      s.EOL();    }    const uint32_t argc = m_arguments.GetArgumentCount(); @@ -137,7 +137,7 @@ void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {    if (m_arch.IsValid()) {      s.Printf("   arch = "); -    m_arch.DumpTriple(s); +    m_arch.DumpTriple(s.AsRawOstream());      s.EOL();    } @@ -189,7 +189,7 @@ void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,      StreamString arch_strm;      if (m_arch.IsValid()) -      m_arch.DumpTriple(arch_strm); +      m_arch.DumpTriple(arch_strm.AsRawOstream());      auto print = [&](bool (ProcessInstanceInfo::*isValid)() const,                       uint32_t (ProcessInstanceInfo::*getID)() const, diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp index a01c35a2818e..36790f5d8efa 100644 --- a/lldb/source/Utility/RegisterValue.cpp +++ b/lldb/source/Utility/RegisterValue.cpp @@ -8,7 +8,6 @@  #include "lldb/Utility/RegisterValue.h" -#include "lldb/Utility/Args.h"  #include "lldb/Utility/DataExtractor.h"  #include "lldb/Utility/Scalar.h"  #include "lldb/Utility/Status.h" @@ -330,6 +329,35 @@ static bool ParseVectorEncoding(const RegisterInfo *reg_info,    return true;  } +static bool UInt64ValueIsValidForByteSize(uint64_t uval64, +                                          size_t total_byte_size) { +  if (total_byte_size > 8) +    return false; + +  if (total_byte_size == 8) +    return true; + +  const uint64_t max = +      (static_cast<uint64_t>(1) << static_cast<uint64_t>(total_byte_size * 8)) - +      1; +  return uval64 <= max; +} + +static bool SInt64ValueIsValidForByteSize(int64_t sval64, +                                          size_t total_byte_size) { +  if (total_byte_size > 8) +    return false; + +  if (total_byte_size == 8) +    return true; + +  const int64_t max = (static_cast<int64_t>(1) +                       << static_cast<uint64_t>(total_byte_size * 8 - 1)) - +                      1; +  const int64_t min = ~(max); +  return min <= sval64 && sval64 <= max; +} +  Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,                                           llvm::StringRef value_str) {    Status error; @@ -368,7 +396,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,        break;      } -    if (!Args::UInt64ValueIsValidForByteSize(uval64, byte_size)) { +    if (!UInt64ValueIsValidForByteSize(uval64, byte_size)) {        error.SetErrorStringWithFormat(            "value 0x%" PRIx64            " is too large to fit in a %u byte unsigned integer value", @@ -397,7 +425,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,        break;      } -    if (!Args::SInt64ValueIsValidForByteSize(ival64, byte_size)) { +    if (!SInt64ValueIsValidForByteSize(ival64, byte_size)) {        error.SetErrorStringWithFormat(            "value 0x%" PRIx64            " is too large to fit in a %u byte signed integer value", diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index 4777d7576a32..b11e1a577ed2 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -25,6 +25,16 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,    lldbassert(!InstanceImpl() && "Already initialized.");    InstanceImpl().emplace(); +  // The environment can override the capture mode. +  if (mode != ReproducerMode::Replay) { +    std::string env = +        llvm::StringRef(getenv("LLDB_CAPTURE_REPRODUCER")).lower(); +    if (env == "0" || env == "off") +      mode = ReproducerMode::Off; +    else if (env == "1" || env == "on") +      mode = ReproducerMode::Capture; +  } +    switch (mode) {    case ReproducerMode::Capture: {      if (!root) { @@ -143,12 +153,14 @@ static FileSpec MakeAbsolute(FileSpec file_spec) {    return FileSpec(path, file_spec.GetPathStyle());  } -Generator::Generator(FileSpec root) -    : m_root(MakeAbsolute(std::move(root))), m_done(false) { +Generator::Generator(FileSpec root) : m_root(MakeAbsolute(std::move(root))) {    GetOrCreate<repro::WorkingDirectoryProvider>();  } -Generator::~Generator() {} +Generator::~Generator() { +  if (!m_done) +    Discard(); +}  ProviderBase *Generator::Register(std::unique_ptr<ProviderBase> provider) {    std::lock_guard<std::mutex> lock(m_providers_mutex); @@ -243,7 +255,7 @@ DataRecorder::Create(const FileSpec &filename) {  DataRecorder *CommandProvider::GetNewDataRecorder() {    std::size_t i = m_data_recorders.size() + 1;    std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") + -                          llvm::Twine(i) + llvm::Twine(".txt")) +                          llvm::Twine(i) + llvm::Twine(".yaml"))                               .str();    auto recorder_or_error =        DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename)); @@ -292,53 +304,9 @@ void WorkingDirectoryProvider::Keep() {    os << m_cwd << "\n";  } -llvm::raw_ostream *ProcessGDBRemoteProvider::GetHistoryStream() { -  FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file); - -  std::error_code EC; -  m_stream_up = std::make_unique<raw_fd_ostream>(history_file.GetPath(), EC, -                                                 sys::fs::OpenFlags::OF_Text); -  return m_stream_up.get(); -} - -std::unique_ptr<CommandLoader> CommandLoader::Create(Loader *loader) { -  if (!loader) -    return {}; - -  FileSpec file = loader->GetFile<repro::CommandProvider::Info>(); -  if (!file) -    return {}; - -  auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); -  if (auto err = error_or_file.getError()) -    return {}; - -  std::vector<std::string> files; -  llvm::yaml::Input yin((*error_or_file)->getBuffer()); -  yin >> files; - -  if (auto err = yin.error()) -    return {}; - -  for (auto &file : files) { -    FileSpec absolute_path = -        loader->GetRoot().CopyByAppendingPathComponent(file); -    file = absolute_path.GetPath(); -  } - -  return std::make_unique<CommandLoader>(std::move(files)); -} - -llvm::Optional<std::string> CommandLoader::GetNextFile() { -  if (m_index >= m_files.size()) -    return {}; -  return m_files[m_index++]; -} -  void ProviderBase::anchor() {}  char CommandProvider::ID = 0;  char FileProvider::ID = 0; -char ProcessGDBRemoteProvider::ID = 0;  char ProviderBase::ID = 0;  char VersionProvider::ID = 0;  char WorkingDirectoryProvider::ID = 0; @@ -346,8 +314,6 @@ const char *CommandProvider::Info::file = "command-interpreter.yaml";  const char *CommandProvider::Info::name = "command-interpreter";  const char *FileProvider::Info::file = "files.yaml";  const char *FileProvider::Info::name = "files"; -const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml"; -const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";  const char *VersionProvider::Info::file = "version.txt";  const char *VersionProvider::Info::name = "version";  const char *WorkingDirectoryProvider::Info::file = "cwd.txt"; diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index e9aec17b6650..a9293e87220b 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -74,7 +74,7 @@ Scalar::Scalar() : m_type(e_void), m_float(static_cast<float>(0)) {}  bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {    size_t byte_size = GetByteSize();    if (byte_size > 0) { -    const uint8_t *bytes = reinterpret_cast<const uint8_t *>(GetBytes()); +    const uint8_t *bytes = static_cast<const uint8_t *>(GetBytes());      if (limit_byte_size < byte_size) {        if (endian::InlHostByteOrder() == eByteOrderLittle) { @@ -132,7 +132,7 @@ const void *Scalar::GetBytes() const {        swapped_words[1] = apint_words[0];        apint_words = swapped_words;      } -    return reinterpret_cast<const void *>(apint_words); +    return static_cast<const void *>(apint_words);    case e_sint256:    case e_uint256:      apint_words = m_integer.getRawData(); @@ -143,7 +143,7 @@ const void *Scalar::GetBytes() const {        swapped_words[3] = apint_words[0];        apint_words = swapped_words;      } -    return reinterpret_cast<const void *>(apint_words); +    return static_cast<const void *>(apint_words);    case e_sint512:    case e_uint512:      apint_words = m_integer.getRawData(); @@ -158,13 +158,13 @@ const void *Scalar::GetBytes() const {        swapped_words[7] = apint_words[0];        apint_words = swapped_words;      } -    return reinterpret_cast<const void *>(apint_words); +    return static_cast<const void *>(apint_words);    case e_float:      flt_val = m_float.convertToFloat(); -    return reinterpret_cast<const void *>(&flt_val); +    return static_cast<const void *>(&flt_val);    case e_double:      dbl_val = m_float.convertToDouble(); -    return reinterpret_cast<const void *>(&dbl_val); +    return static_cast<const void *>(&dbl_val);    case e_long_double:      llvm::APInt ldbl_val = m_float.bitcastToAPInt();      apint_words = ldbl_val.getRawData(); @@ -176,7 +176,7 @@ const void *Scalar::GetBytes() const {        swapped_words[1] = apint_words[0];        apint_words = swapped_words;      } -    return reinterpret_cast<const void *>(apint_words); +    return static_cast<const void *>(apint_words);    }    return nullptr;  } @@ -305,15 +305,6 @@ const char *Scalar::GetTypeAsCString() const {    return "<invalid Scalar type>";  } -Scalar &Scalar::operator=(const Scalar &rhs) { -  if (this != &rhs) { -    m_type = rhs.m_type; -    m_integer = llvm::APInt(rhs.m_integer); -    m_float = rhs.m_float; -  } -  return *this; -} -  Scalar &Scalar::operator=(const int v) {    m_type = e_sint;    m_integer = llvm::APInt(sizeof(int) * 8, v, true); diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp index 3d64fb810abf..b74db72773dd 100644 --- a/lldb/source/Utility/Status.cpp +++ b/lldb/source/Utility/Status.cpp @@ -93,16 +93,6 @@ llvm::Error Status::ToError() const {                                               llvm::inconvertibleErrorCode());  } -// Assignment operator -const Status &Status::operator=(const Status &rhs) { -  if (this != &rhs) { -    m_code = rhs.m_code; -    m_type = rhs.m_type; -    m_string = rhs.m_string; -  } -  return *this; -} -  Status::~Status() = default;  #ifdef _WIN32 @@ -110,14 +100,23 @@ static std::string RetrieveWin32ErrorString(uint32_t error_code) {    char *buffer = nullptr;    std::string message;    // Retrieve win32 system error. +  // First, attempt to load a en-US message    if (::FormatMessageA(            FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |                FORMAT_MESSAGE_MAX_WIDTH_MASK, -          NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), +          NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),            (LPSTR)&buffer, 0, NULL)) {      message.assign(buffer);      ::LocalFree(buffer);    } +  // If the previous didn't work, use the default OS language +  else if (::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | +                                FORMAT_MESSAGE_FROM_SYSTEM | +                                FORMAT_MESSAGE_MAX_WIDTH_MASK, +                            NULL, error_code, 0, (LPSTR)&buffer, 0, NULL)) { +    message.assign(buffer); +    ::LocalFree(buffer); +  }    return message;  }  #endif diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index c48a12acd906..b336cb6b5185 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -11,6 +11,7 @@  #include "lldb/Utility/Endian.h"  #include "lldb/Utility/VASPrintf.h"  #include "llvm/ADT/SmallString.h" +#include "llvm/Support/Format.h"  #include "llvm/Support/LEB128.h"  #include <string> @@ -76,28 +77,27 @@ void Stream::QuotedCString(const char *cstr, const char *format) {  // Put an address "addr" out to the stream with optional prefix and suffix  // strings. -void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix, -                     const char *suffix) { +void lldb_private::DumpAddress(llvm::raw_ostream &s, uint64_t addr, +                               uint32_t addr_size, const char *prefix, +                               const char *suffix) {    if (prefix == nullptr)      prefix = "";    if (suffix == nullptr)      suffix = ""; -  //    int addr_width = m_addr_size << 1; -  //    Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix); -  Printf("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, addr, suffix); +  s << prefix << llvm::format_hex(addr, 2 + 2 * addr_size) << suffix;  }  // Put an address range out to the stream with optional prefix and suffix  // strings. -void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, -                          uint32_t addr_size, const char *prefix, -                          const char *suffix) { +void lldb_private::DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, +                                    uint64_t hi_addr, uint32_t addr_size, +                                    const char *prefix, const char *suffix) {    if (prefix && prefix[0]) -    PutCString(prefix); -  Address(lo_addr, addr_size, "["); -  Address(hi_addr, addr_size, "-", ")"); +    s << prefix; +  DumpAddress(s, lo_addr, addr_size, "["); +  DumpAddress(s, hi_addr, addr_size, "-", ")");    if (suffix && suffix[0]) -    PutCString(suffix); +    s << suffix;  }  size_t Stream::PutChar(char ch) { return Write(&ch, 1); } @@ -160,65 +160,19 @@ Stream &Stream::operator<<(const void *p) {    return *this;  } -// Stream a uint8_t "uval" out to this stream. -Stream &Stream::operator<<(uint8_t uval) { -  PutHex8(uval); -  return *this; -} - -// Stream a uint16_t "uval" out to this stream. -Stream &Stream::operator<<(uint16_t uval) { -  PutHex16(uval, m_byte_order); -  return *this; -} - -// Stream a uint32_t "uval" out to this stream. -Stream &Stream::operator<<(uint32_t uval) { -  PutHex32(uval, m_byte_order); -  return *this; -} - -// Stream a uint64_t "uval" out to this stream. -Stream &Stream::operator<<(uint64_t uval) { -  PutHex64(uval, m_byte_order); -  return *this; -} - -// Stream a int8_t "sval" out to this stream. -Stream &Stream::operator<<(int8_t sval) { -  Printf("%i", static_cast<int>(sval)); -  return *this; -} - -// Stream a int16_t "sval" out to this stream. -Stream &Stream::operator<<(int16_t sval) { -  Printf("%i", static_cast<int>(sval)); -  return *this; -} - -// Stream a int32_t "sval" out to this stream. -Stream &Stream::operator<<(int32_t sval) { -  Printf("%i", static_cast<int>(sval)); -  return *this; -} - -// Stream a int64_t "sval" out to this stream. -Stream &Stream::operator<<(int64_t sval) { -  Printf("%" PRIi64, sval); -  return *this; -} -  // Get the current indentation level -int Stream::GetIndentLevel() const { return m_indent_level; } +unsigned Stream::GetIndentLevel() const { return m_indent_level; }  // Set the current indentation level -void Stream::SetIndentLevel(int indent_level) { m_indent_level = indent_level; } +void Stream::SetIndentLevel(unsigned indent_level) { +  m_indent_level = indent_level; +}  // Increment the current indentation level -void Stream::IndentMore(int amount) { m_indent_level += amount; } +void Stream::IndentMore(unsigned amount) { m_indent_level += amount; }  // Decrement the current indentation level -void Stream::IndentLess(int amount) { +void Stream::IndentLess(unsigned amount) {    if (m_indent_level >= amount)      m_indent_level -= amount;    else diff --git a/lldb/source/Utility/StreamString.cpp b/lldb/source/Utility/StreamString.cpp index bf9814d6c305..6b5b7d337fcc 100644 --- a/lldb/source/Utility/StreamString.cpp +++ b/lldb/source/Utility/StreamString.cpp @@ -24,7 +24,7 @@ void StreamString::Flush() {  }  size_t StreamString::WriteImpl(const void *s, size_t length) { -  m_packet.append(reinterpret_cast<const char *>(s), length); +  m_packet.append(static_cast<const char *>(s), length);    return length;  } diff --git a/lldb/source/Utility/StructuredData.cpp b/lldb/source/Utility/StructuredData.cpp index 783a08082174..d5d7a7ec99a0 100644 --- a/lldb/source/Utility/StructuredData.cpp +++ b/lldb/source/Utility/StructuredData.cpp @@ -7,16 +7,12 @@  //===----------------------------------------------------------------------===//  #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/DataBuffer.h"  #include "lldb/Utility/FileSpec.h"  #include "lldb/Utility/Status.h" -#include "lldb/Utility/StreamString.h" -#include "llvm/ADT/STLExtras.h"  #include "llvm/Support/MemoryBuffer.h"  #include <cerrno>  #include <cstdlib>  #include <inttypes.h> -#include <limits>  using namespace lldb_private;  using namespace llvm; @@ -82,7 +78,7 @@ static StructuredData::ObjectSP ParseJSONObject(json::Object *object) {      if (StructuredData::ObjectSP value_sp = ParseJSONValue(value))        dict_up->AddItem(key, value_sp);    } -  return dict_up; +  return std::move(dict_up);  }  static StructuredData::ObjectSP ParseJSONArray(json::Array *array) { @@ -91,7 +87,7 @@ static StructuredData::ObjectSP ParseJSONArray(json::Array *array) {      if (StructuredData::ObjectSP value_sp = ParseJSONValue(value))        array_up->AddItem(value_sp);    } -  return array_up; +  return std::move(array_up);  }  StructuredData::ObjectSP diff --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp index f3f4ae7efc3c..c8c3334138d3 100644 --- a/lldb/source/Utility/VMRange.cpp +++ b/lldb/source/Utility/VMRange.cpp @@ -35,9 +35,10 @@ bool VMRange::ContainsRange(const VMRange::collection &coll,           }) != coll.end();  } -void VMRange::Dump(Stream *s, lldb::addr_t offset, uint32_t addr_width) const { -  s->AddressRange(offset + GetBaseAddress(), offset + GetEndAddress(), -                  addr_width); +void VMRange::Dump(llvm::raw_ostream &s, lldb::addr_t offset, +                   uint32_t addr_width) const { +  DumpAddressRange(s, offset + GetBaseAddress(), offset + GetEndAddress(), +                   addr_width);  }  bool lldb_private::operator==(const VMRange &lhs, const VMRange &rhs) {  | 
