diff options
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.cpp (renamed from lldb/source/Target/VerboseTrapFrameRecognizer.cpp) | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.h | 47 | ||||
| -rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 10 | ||||
| -rw-r--r-- | lldb/source/Target/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | lldb/source/Target/InstrumentationRuntime.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Target/Target.cpp | 19 | ||||
| -rw-r--r-- | lldb/source/Utility/Stream.cpp | 8 | 
11 files changed, 76 insertions, 25 deletions
diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index ff37b48..a5547a4 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -798,6 +798,8 @@ bool ABISysV_riscv::RegisterIsCalleeSaved(const RegisterInfo *reg_info) {            .Cases({"f8", "f9", "f18", "f19", "f20", "f21", "f22", "f23"},                   is_hw_fp)            .Cases({"f24", "f25", "f26", "f27"}, is_hw_fp) +          // vlenb is constant and needed for vector unwinding. +          .Case("vlenb", true)            .Default(false);    return is_callee_saved; diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt index 1717b0a..a27bcef 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt @@ -1,5 +1,6 @@  add_lldb_library(lldbPluginCPPRuntime    CPPLanguageRuntime.cpp +  VerboseTrapFrameRecognizer.cpp    LINK_LIBS      lldbCore diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index 21a5ebe..913678b 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -12,6 +12,7 @@  #include <memory>  #include "CPPLanguageRuntime.h" +#include "VerboseTrapFrameRecognizer.h"  #include "llvm/ADT/StringRef.h" @@ -107,12 +108,15 @@ public:  CPPLanguageRuntime::CPPLanguageRuntime(Process *process)      : LanguageRuntime(process) { -  if (process) +  if (process) {      process->GetTarget().GetFrameRecognizerManager().AddRecognizer(          StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},          std::make_shared<RegularExpression>("^std::__[^:]*::"),          /*mangling_preference=*/Mangled::ePreferDemangledWithoutArguments,          /*first_instruction_only=*/false); + +    RegisterVerboseTrapFrameRecognizer(*process); +  }  }  bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) { diff --git a/lldb/source/Target/VerboseTrapFrameRecognizer.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.cpp index 03ab58b..730aba5 100644 --- a/lldb/source/Target/VerboseTrapFrameRecognizer.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.cpp @@ -1,4 +1,4 @@ -#include "lldb/Target/VerboseTrapFrameRecognizer.h" +#include "VerboseTrapFrameRecognizer.h"  #include "lldb/Core/Module.h"  #include "lldb/Symbol/Function.h" diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.h new file mode 100644 index 0000000..7d7020f --- /dev/null +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.h @@ -0,0 +1,47 @@ +//===-- VerboseTrapFrameRecognizer.h --------------------------------------===// +// +// 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 LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H +#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H + +#include "lldb/Target/StackFrameRecognizer.h" + +namespace lldb_private { + +void RegisterVerboseTrapFrameRecognizer(Process &process); + +/// Holds the stack frame that caused the Verbose trap and the inlined stop +/// reason message. +class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame { +public: +  VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp, +                                  std::string stop_desc); + +  lldb::StackFrameSP GetMostRelevantFrame() override; + +private: +  lldb::StackFrameSP m_most_relevant_frame; +}; + +/// When a thread stops, it checks the current frame contains a +/// Verbose Trap diagnostic. If so, it returns a \a +/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason +/// description with and the parent frame as the most relavant frame. +class VerboseTrapFrameRecognizer : public StackFrameRecognizer { +public: +  std::string GetName() override { +    return "Verbose Trap StackFrame Recognizer"; +  } + +  lldb::RecognizedStackFrameSP +  RecognizeFrame(lldb::StackFrameSP frame) override; +}; + +} // namespace lldb_private + +#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 49841e7..e06e69f 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2735,9 +2735,8 @@ static void ApplyELF64ABS64Relocation(Symtab *symtab, ELFRelocation &rel,      // ObjectFileELF creates a WritableDataBuffer in CreateInstance.      WritableDataBuffer *data_buffer =          llvm::cast<WritableDataBuffer>(data_buffer_sp.get()); -    uint64_t *dst = reinterpret_cast<uint64_t *>( -        data_buffer->GetBytes() + rel_section->GetFileOffset() + -        ELFRelocation::RelocOffset64(rel)); +    void *const dst = data_buffer->GetBytes() + rel_section->GetFileOffset() + +                      ELFRelocation::RelocOffset64(rel);      uint64_t val_offset = value + ELFRelocation::RelocAddend64(rel);      memcpy(dst, &val_offset, sizeof(uint64_t));    } @@ -2762,9 +2761,8 @@ static void ApplyELF64ABS32Relocation(Symtab *symtab, ELFRelocation &rel,      // ObjectFileELF creates a WritableDataBuffer in CreateInstance.      WritableDataBuffer *data_buffer =          llvm::cast<WritableDataBuffer>(data_buffer_sp.get()); -    uint32_t *dst = reinterpret_cast<uint32_t *>( -        data_buffer->GetBytes() + rel_section->GetFileOffset() + -        ELFRelocation::RelocOffset32(rel)); +    void *const dst = data_buffer->GetBytes() + rel_section->GetFileOffset() + +                      ELFRelocation::RelocOffset32(rel);      memcpy(dst, &truncated_addr, sizeof(uint32_t));    }  } diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt index b7788e8..8e6d51e 100644 --- a/lldb/source/Target/CMakeLists.txt +++ b/lldb/source/Target/CMakeLists.txt @@ -80,7 +80,6 @@ add_lldb_library(lldbTarget    UnixSignals.cpp    UnwindAssembly.cpp    UnwindLLDB.cpp -  VerboseTrapFrameRecognizer.cpp    ADDITIONAL_HEADER_DIRS      ${LLDB_INCLUDE_DIR}/lldb/Target diff --git a/lldb/source/Target/InstrumentationRuntime.cpp b/lldb/source/Target/InstrumentationRuntime.cpp index 7e58e8b..d9800a8 100644 --- a/lldb/source/Target/InstrumentationRuntime.cpp +++ b/lldb/source/Target/InstrumentationRuntime.cpp @@ -55,7 +55,8 @@ void InstrumentationRuntime::ModulesDidLoad(        return IterationAction::Continue;      const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary(); -    if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) || +    if (MatchAllModules() || +        runtime_regex.Execute(file_spec.GetFilename().GetCString()) ||          module_sp->IsExecutable()) {        if (CheckIfRuntimeIsValid(module_sp)) {          SetRuntimeModuleSP(module_sp); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index fb9e7eb..42ce198 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -65,7 +65,6 @@  #include "lldb/Target/ThreadPlanCallFunction.h"  #include "lldb/Target/ThreadPlanStack.h"  #include "lldb/Target/UnixSignals.h" -#include "lldb/Target/VerboseTrapFrameRecognizer.h"  #include "lldb/Utility/AddressableBits.h"  #include "lldb/Utility/Event.h"  #include "lldb/Utility/LLDBLog.h" @@ -513,7 +512,6 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,    // We should have a plugin do the registration instead, for example, a    // common C LanguageRuntime plugin.    RegisterAssertFrameRecognizer(this); -  RegisterVerboseTrapFrameRecognizer(*this);  }  Process::~Process() { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 1e43094..a23091a 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3962,9 +3962,7 @@ void Target::StopHook::GetDescription(Stream &s,      return;    } -  unsigned indent_level = s.GetIndentLevel(); - -  s.SetIndentLevel(indent_level + 2); +  auto indent_scope = s.MakeIndentScope();    s.Printf("Hook: %" PRIu64 "\n", GetID());    if (m_active) @@ -3978,19 +3976,17 @@ void Target::StopHook::GetDescription(Stream &s,    if (m_specifier_sp) {      s.Indent();      s.PutCString("Specifier:\n"); -    s.SetIndentLevel(indent_level + 4); +    auto indent_scope = s.MakeIndentScope();      m_specifier_sp->GetDescription(&s, level); -    s.SetIndentLevel(indent_level + 2);    }    if (m_thread_spec_up) {      StreamString tmp;      s.Indent("Thread:\n");      m_thread_spec_up->GetDescription(&tmp, level); -    s.SetIndentLevel(indent_level + 4); +    auto indent_scope = s.MakeIndentScope();      s.Indent(tmp.GetString());      s.PutCString("\n"); -    s.SetIndentLevel(indent_level + 2);    }    GetSubclassDescription(s, level);  } @@ -4003,14 +3999,13 @@ void Target::StopHookCommandLine::GetSubclassDescription(        s.PutCString(m_commands.GetStringAtIndex(0));      return;    } -  s.Indent("Commands: \n"); -  s.SetIndentLevel(s.GetIndentLevel() + 4); +  s.Indent("Commands:\n"); +  auto indent_scope = s.MakeIndentScope(4);    uint32_t num_commands = m_commands.GetSize();    for (uint32_t i = 0; i < num_commands; i++) {      s.Indent(m_commands.GetStringAtIndex(i));      s.PutCString("\n");    } -  s.SetIndentLevel(s.GetIndentLevel() - 4);  }  // Target::StopHookCommandLine @@ -4145,7 +4140,7 @@ void Target::StopHookScripted::GetSubclassDescription(      return;    s.Indent("Args:\n"); -  s.SetIndentLevel(s.GetIndentLevel() + 4); +  auto indent_scope = s.MakeIndentScope(4);    auto print_one_element = [&s](llvm::StringRef key,                                  StructuredData::Object *object) { @@ -4155,8 +4150,6 @@ void Target::StopHookScripted::GetSubclassDescription(    };    as_dict->ForEach(print_one_element); - -  s.SetIndentLevel(s.GetIndentLevel() - 4);  }  static constexpr OptionEnumValueElement g_dynamic_value_types[] = { diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index 89dce9f..e9632c3 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -202,6 +202,14 @@ void Stream::IndentLess(unsigned amount) {      m_indent_level = 0;  } +// Create an indentation scope that restores the original indent level when the +// object goes out of scope (RAII). +Stream::IndentScope Stream::MakeIndentScope(unsigned indent_amount) { +  IndentScope indent_scope(*this); +  IndentMore(indent_amount); +  return indent_scope; +} +  // Get the address size in bytes  uint32_t Stream::GetAddressByteSize() const { return m_addr_size; }  | 
