aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Core
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-04 19:20:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:02:26 +0000
commit81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch)
tree311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/lldb/source/Core
parent5fff09660e06a66bed6482da9c70df328e16bbb6 (diff)
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
downloadsrc-81ad626541db97eb356e2c1d4a20eb2a26a766ab.tar.gz
src-81ad626541db97eb356e2c1d4a20eb2a26a766ab.zip
Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-15-init-15358-g53dc0f10787. PR: 265425 MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/lldb/source/Core')
-rw-r--r--contrib/llvm-project/lldb/source/Core/Address.cpp61
-rw-r--r--contrib/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp8
-rw-r--r--contrib/llvm-project/lldb/source/Core/Communication.cpp64
-rw-r--r--contrib/llvm-project/lldb/source/Core/CoreProperties.td32
-rw-r--r--contrib/llvm-project/lldb/source/Core/DataFileCache.cpp64
-rw-r--r--contrib/llvm-project/lldb/source/Core/Debugger.cpp357
-rw-r--r--contrib/llvm-project/lldb/source/Core/DebuggerEvents.cpp81
-rw-r--r--contrib/llvm-project/lldb/source/Core/DumpDataExtractor.cpp4
-rw-r--r--contrib/llvm-project/lldb/source/Core/DynamicLoader.cpp70
-rw-r--r--contrib/llvm-project/lldb/source/Core/FileSpecList.cpp1
-rw-r--r--contrib/llvm-project/lldb/source/Core/FormatEntity.cpp13
-rw-r--r--contrib/llvm-project/lldb/source/Core/IOHandler.cpp51
-rw-r--r--contrib/llvm-project/lldb/source/Core/IOHandlerCursesGUI.cpp246
-rw-r--r--contrib/llvm-project/lldb/source/Core/Mangled.cpp12
-rw-r--r--contrib/llvm-project/lldb/source/Core/Module.cpp143
-rw-r--r--contrib/llvm-project/lldb/source/Core/ModuleList.cpp13
-rw-r--r--contrib/llvm-project/lldb/source/Core/PluginManager.cpp48
-rw-r--r--contrib/llvm-project/lldb/source/Core/RichManglingContext.cpp12
-rw-r--r--contrib/llvm-project/lldb/source/Core/Section.cpp24
-rw-r--r--contrib/llvm-project/lldb/source/Core/SourceLocationSpec.cpp2
-rw-r--r--contrib/llvm-project/lldb/source/Core/SourceManager.cpp23
-rw-r--r--contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp5
-rw-r--r--contrib/llvm-project/lldb/source/Core/StreamFile.cpp3
-rw-r--r--contrib/llvm-project/lldb/source/Core/Value.cpp14
-rw-r--r--contrib/llvm-project/lldb/source/Core/ValueObject.cpp34
-rw-r--r--contrib/llvm-project/lldb/source/Core/ValueObjectChild.cpp2
-rw-r--r--contrib/llvm-project/lldb/source/Core/ValueObjectDynamicValue.cpp4
-rw-r--r--contrib/llvm-project/lldb/source/Core/ValueObjectRegister.cpp38
-rw-r--r--contrib/llvm-project/lldb/source/Core/ValueObjectSyntheticFilter.cpp8
29 files changed, 878 insertions, 559 deletions
diff --git a/contrib/llvm-project/lldb/source/Core/Address.cpp b/contrib/llvm-project/lldb/source/Core/Address.cpp
index 122bed924b42..b84e1ac8e169 100644
--- a/contrib/llvm-project/lldb/source/Core/Address.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Address.cpp
@@ -22,6 +22,7 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/Process.h"
@@ -232,7 +233,7 @@ static size_t ReadCStringFromMemory(ExecutionContextScope *exe_scope,
Address::Address(lldb::addr_t abs_addr) : m_section_wp(), m_offset(abs_addr) {}
Address::Address(addr_t address, const SectionList *section_list)
- : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {
+ : m_section_wp() {
ResolveAddressUsingFileSections(address, section_list);
}
@@ -403,7 +404,8 @@ bool Address::GetDescription(Stream &s, Target &target,
}
bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
- DumpStyle fallback_style, uint32_t addr_size) const {
+ DumpStyle fallback_style, uint32_t addr_size,
+ bool all_ranges) const {
// If the section was nullptr, only load address is going to work unless we
// are trying to deref a pointer
SectionSP section_sp(GetSection());
@@ -720,27 +722,42 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
bool get_parent_variables = true;
bool stop_if_block_is_inlined_function = false;
VariableList variable_list;
- sc.block->AppendVariables(can_create, get_parent_variables,
- stop_if_block_is_inlined_function,
- [](Variable *) { return true; },
- &variable_list);
-
+ addr_t file_addr = GetFileAddress();
+ sc.block->AppendVariables(
+ can_create, get_parent_variables,
+ stop_if_block_is_inlined_function,
+ [&](Variable *var) {
+ return var && var->LocationIsValidForAddress(*this);
+ },
+ &variable_list);
+ ABISP abi =
+ ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
for (const VariableSP &var_sp : variable_list) {
- if (var_sp && var_sp->LocationIsValidForAddress(*this)) {
- s->Indent();
- s->Printf(" Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\"",
- var_sp->GetID(), var_sp->GetName().GetCString());
- Type *type = var_sp->GetType();
- if (type)
- s->Printf(", type = \"%s\"", type->GetName().GetCString());
- else
- s->PutCString(", type = <unknown>");
- s->PutCString(", location = ");
- var_sp->DumpLocationForAddress(s, *this);
- s->PutCString(", decl = ");
- var_sp->GetDeclaration().DumpStopContext(s, false);
- s->EOL();
- }
+ s->Indent();
+ s->Printf(" Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\"",
+ var_sp->GetID(), var_sp->GetName().GetCString());
+ Type *type = var_sp->GetType();
+ if (type)
+ s->Printf(", type = \"%s\"", type->GetName().GetCString());
+ else
+ s->PutCString(", type = <unknown>");
+ s->PutCString(", valid ranges = ");
+ if (var_sp->GetScopeRange().IsEmpty())
+ s->PutCString("<block>");
+ else if (all_ranges) {
+ for (auto range : var_sp->GetScopeRange())
+ DumpAddressRange(s->AsRawOstream(), range.GetRangeBase(),
+ range.GetRangeEnd(), addr_size);
+ } else if (auto *range =
+ var_sp->GetScopeRange().FindEntryThatContains(
+ file_addr))
+ DumpAddressRange(s->AsRawOstream(), range->GetRangeBase(),
+ range->GetRangeEnd(), addr_size);
+ s->PutCString(", location = ");
+ var_sp->DumpLocations(s, all_ranges ? LLDB_INVALID_ADDRESS : *this);
+ s->PutCString(", decl = ");
+ var_sp->GetDeclaration().DumpStopContext(s, false);
+ s->EOL();
}
}
}
diff --git a/contrib/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp b/contrib/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp
index fb61a6100b0e..8152a57644fa 100644
--- a/contrib/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp
+++ b/contrib/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp
@@ -14,8 +14,8 @@
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-enumerations.h"
@@ -40,7 +40,7 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter,
SymbolContextList sc_list;
CompileUnit *cu = context.comp_unit;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ Log *log = GetLog(LLDBLog::Breakpoints);
// TODO: Handle SourceLocationSpec column information
cu->ResolveSymbolContext(m_src_location_spec, eSymbolContextEverything,
@@ -61,7 +61,7 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter,
line_start.GetFileAddress(),
m_src_location_spec.GetFileSpec().GetFilename().AsCString(
"<Unknown>"),
- m_src_location_spec.GetLine().getValueOr(0));
+ m_src_location_spec.GetLine().value_or(0));
}
}
}
@@ -76,5 +76,5 @@ void AddressResolverFileLine::GetDescription(Stream *s) {
s->Printf(
"File and line address - file: \"%s\" line: %u",
m_src_location_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"),
- m_src_location_spec.GetLine().getValueOr(0));
+ m_src_location_spec.GetLine().value_or(0));
}
diff --git a/contrib/llvm-project/lldb/source/Core/Communication.cpp b/contrib/llvm-project/lldb/source/Core/Communication.cpp
index 0ad2751f24f0..f41ce46ede88 100644
--- a/contrib/llvm-project/lldb/source/Core/Communication.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Communication.cpp
@@ -13,9 +13,9 @@
#include "lldb/Utility/Connection.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Event.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Listener.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/None.h"
@@ -47,8 +47,7 @@ Communication::Communication(const char *name)
{
- LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
- LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Object | LLDBLog::Communication),
"{0} Communication::Communication (name = {1})", this, name);
SetEventName(eBroadcastBitDisconnected, "disconnected");
@@ -62,8 +61,7 @@ Communication::Communication(const char *name)
}
Communication::~Communication() {
- LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
- LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Object | LLDBLog::Communication),
"{0} Communication::~Communication (name = {1})", this,
GetBroadcasterName().AsCString());
Clear();
@@ -78,7 +76,7 @@ void Communication::Clear() {
ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
Clear();
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::Connect (url = {1})", this, url);
lldb::ConnectionSP connection_sp(m_connection_sp);
@@ -90,8 +88,8 @@ ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
}
ConnectionStatus Communication::Disconnect(Status *error_ptr) {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
- "{0} Communication::Disconnect ()", this);
+ LLDB_LOG(GetLog(LLDBLog::Communication), "{0} Communication::Disconnect ()",
+ this);
assert((!m_read_thread_enabled || m_read_thread_did_exit) &&
"Disconnecting while the read thread is running is racy!");
@@ -125,7 +123,7 @@ bool Communication::HasConnection() const {
size_t Communication::Read(void *dst, size_t dst_len,
const Timeout<std::micro> &timeout,
ConnectionStatus &status, Status *error_ptr) {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION);
+ Log *log = GetLog(LLDBLog::Communication);
LLDB_LOG(
log,
"this = {0}, dst = {1}, dst_len = {2}, timeout = {3}, connection = {4}",
@@ -175,7 +173,7 @@ size_t Communication::Write(const void *src, size_t src_len,
lldb::ConnectionSP connection_sp(m_connection_sp);
std::lock_guard<std::mutex> guard(m_write_mutex);
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::Write (src = {1}, src_len = {2}"
") connection = {3}",
this, src, (uint64_t)src_len, connection_sp.get());
@@ -206,7 +204,7 @@ bool Communication::StartReadThread(Status *error_ptr) {
if (m_read_thread.IsJoinable())
return true;
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::StartReadThread ()", this);
const std::string thread_name =
@@ -215,15 +213,14 @@ bool Communication::StartReadThread(Status *error_ptr) {
m_read_thread_enabled = true;
m_read_thread_did_exit = false;
auto maybe_thread = ThreadLauncher::LaunchThread(
- thread_name, Communication::ReadThread, this);
+ thread_name, [this] { return ReadThread(); });
if (maybe_thread) {
m_read_thread = *maybe_thread;
} else {
if (error_ptr)
*error_ptr = Status(maybe_thread.takeError());
else {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
- "failed to launch host thread: {}",
+ LLDB_LOG(GetLog(LLDBLog::Host), "failed to launch host thread: {}",
llvm::toString(maybe_thread.takeError()));
}
}
@@ -238,7 +235,7 @@ bool Communication::StopReadThread(Status *error_ptr) {
if (!m_read_thread.IsJoinable())
return true;
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::StopReadThread ()", this);
m_read_thread_enabled = false;
@@ -280,7 +277,7 @@ size_t Communication::GetCachedBytes(void *dst, size_t dst_len) {
void Communication::AppendBytesToCache(const uint8_t *bytes, size_t len,
bool broadcast,
ConnectionStatus status) {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::AppendBytesToCache (src = {1}, src_len = {2}, "
"broadcast = {3})",
this, bytes, (uint64_t)len, broadcast);
@@ -314,12 +311,10 @@ size_t Communication::ReadFromConnection(void *dst, size_t dst_len,
bool Communication::ReadThreadIsRunning() { return m_read_thread_enabled; }
-lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
- Communication *comm = (Communication *)p;
+lldb::thread_result_t Communication::ReadThread() {
+ Log *log = GetLog(LLDBLog::Communication);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
-
- LLDB_LOGF(log, "%p Communication::ReadThread () thread starting...", p);
+ LLDB_LOG(log, "Communication({0}) thread starting...", this);
uint8_t buf[1024];
@@ -327,11 +322,11 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
ConnectionStatus status = eConnectionStatusSuccess;
bool done = false;
bool disconnect = false;
- while (!done && comm->m_read_thread_enabled) {
- size_t bytes_read = comm->ReadFromConnection(
+ while (!done && m_read_thread_enabled) {
+ size_t bytes_read = ReadFromConnection(
buf, sizeof(buf), std::chrono::seconds(5), status, &error);
if (bytes_read > 0 || status == eConnectionStatusEndOfFile)
- comm->AppendBytesToCache(buf, bytes_read, true, status);
+ AppendBytesToCache(buf, bytes_read, true, status);
switch (status) {
case eConnectionStatusSuccess:
@@ -339,12 +334,12 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
case eConnectionStatusEndOfFile:
done = true;
- disconnect = comm->GetCloseOnEOF();
+ disconnect = GetCloseOnEOF();
break;
case eConnectionStatusError: // Check GetError() for details
if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO) {
// EIO on a pipe is usually caused by remote shutdown
- disconnect = comm->GetCloseOnEOF();
+ disconnect = GetCloseOnEOF();
done = true;
}
if (error.Fail())
@@ -355,7 +350,7 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
// SynchronizeWithReadThread()
// The connection returns eConnectionStatusInterrupted only when there is
// no input pending to be read, so we can signal that.
- comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
+ BroadcastEvent(eBroadcastBitNoMorePendingInput);
break;
case eConnectionStatusNoConnection: // No connection
case eConnectionStatusLostConnection: // Lost connection while connected to
@@ -369,27 +364,26 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
break;
}
}
- log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION);
- if (log)
- LLDB_LOGF(log, "%p Communication::ReadThread () thread exiting...", p);
+ log = GetLog(LLDBLog::Communication);
+ LLDB_LOG(log, "Communication({0}) thread exiting...", this);
// Handle threads wishing to synchronize with us.
{
// Prevent new ones from showing up.
- comm->m_read_thread_did_exit = true;
+ m_read_thread_did_exit = true;
// Unblock any existing thread waiting for the synchronization signal.
- comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
+ BroadcastEvent(eBroadcastBitNoMorePendingInput);
// Wait for the thread to finish...
- std::lock_guard<std::mutex> guard(comm->m_synchronize_mutex);
+ std::lock_guard<std::mutex> guard(m_synchronize_mutex);
// ... and disconnect.
if (disconnect)
- comm->Disconnect();
+ Disconnect();
}
// Let clients know that this thread is exiting
- comm->BroadcastEvent(eBroadcastBitReadThreadDidExit);
+ BroadcastEvent(eBroadcastBitReadThreadDidExit);
return {};
}
diff --git a/contrib/llvm-project/lldb/source/Core/CoreProperties.td b/contrib/llvm-project/lldb/source/Core/CoreProperties.td
index c965b51a1d6d..46eeb1b5ed70 100644
--- a/contrib/llvm-project/lldb/source/Core/CoreProperties.td
+++ b/contrib/llvm-project/lldb/source/Core/CoreProperties.td
@@ -33,6 +33,10 @@ let Definition = "modulelist" in {
Global,
DefaultUnsignedValue<7>,
Desc<"The expiration time in days for a file. When a file hasn't been accessed for the specified amount of days, it is removed from the cache. A value of 0 disables the expiration-based pruning.">;
+ def LoadSymbolOnDemand: Property<"load-on-demand", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info on demand for each module based on various conditions (e.g. matched breakpoint, resolved stack frame addresses and matched global variables/function symbols in symbol table) to improve performance. Please refer to docs/use/ondemand.rst for details.">;
}
let Definition = "debugger" in {
@@ -98,19 +102,19 @@ let Definition = "debugger" in {
def StopShowColumnAnsiPrefix: Property<"stop-show-column-ansi-prefix", "String">,
Global,
DefaultStringValue<"${ansi.underline}">,
- Desc<"When displaying the column marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format at the immediately before the column to be marked.">;
+ Desc<"When displaying the column marker in a color-enabled terminal, use the ANSI terminal code specified in this format at the immediately before the column to be marked.">;
def StopShowColumnAnsiSuffix: Property<"stop-show-column-ansi-suffix", "String">,
Global,
DefaultStringValue<"${ansi.normal}">,
- Desc<"When displaying the column marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the column to be marked.">;
+ Desc<"When displaying the column marker in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the column to be marked.">;
def StopShowLineMarkerAnsiPrefix: Property<"stop-show-line-ansi-prefix", "String">,
Global,
DefaultStringValue<"${ansi.fg.yellow}">,
- Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format at the immediately before the line to be marked.">;
+ Desc<"When displaying the line marker in a color-enabled terminal, use the ANSI terminal code specified in this format at the immediately before the line to be marked.">;
def StopShowLineMarkerAnsiSuffix: Property<"stop-show-line-ansi-suffix", "String">,
Global,
DefaultStringValue<"${ansi.normal}">,
- Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the line to be marked.">;
+ Desc<"When displaying the line marker in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the line to be marked.">;
def TerminalWidth: Property<"term-width", "SInt64">,
Global,
DefaultUnsignedValue<80>,
@@ -131,6 +135,18 @@ let Definition = "debugger" in {
Global,
DefaultTrue,
Desc<"Whether to use Ansi color codes or not.">;
+ def ShowProgress: Property<"show-progress", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Whether to show progress or not if the debugger's output is an interactive color-enabled terminal.">;
+ def ShowProgressAnsiPrefix: Property<"show-progress-ansi-prefix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.faint}">,
+ Desc<"When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the progress message.">;
+ def ShowProgressAnsiSuffix: Property<"show-progress-ansi-suffix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.normal}">,
+ Desc<"When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the progress message.">;
def UseSourceCache: Property<"use-source-cache", "Boolean">,
Global,
DefaultTrue,
@@ -163,4 +179,12 @@ let Definition = "debugger" in {
Global,
DefaultFalse,
Desc<"If true, LLDB will show suggestions to complete the command the user typed. Suggestions may be accepted using Ctrl-F.">;
+ def ShowAutosuggestionAnsiPrefix: Property<"show-autosuggestion-ansi-prefix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.faint}">,
+ Desc<"When displaying suggestion in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the suggestion.">;
+ def ShowAutosuggestionAnsiSuffix: Property<"show-autosuggestion-ansi-suffix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.normal}">,
+ Desc<"When displaying suggestion in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the suggestion.">;
}
diff --git a/contrib/llvm-project/lldb/source/Core/DataFileCache.cpp b/contrib/llvm-project/lldb/source/Core/DataFileCache.cpp
index 3f52b925ef46..b38adfda169a 100644
--- a/contrib/llvm-project/lldb/source/Core/DataFileCache.cpp
+++ b/contrib/llvm-project/lldb/source/Core/DataFileCache.cpp
@@ -12,22 +12,21 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/DataEncoder.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "llvm/Support/CachePruning.h"
#include "llvm/Support/MemoryBuffer.h"
-using namespace llvm;
using namespace lldb_private;
-DataFileCache::DataFileCache(StringRef path) {
+DataFileCache::DataFileCache(llvm::StringRef path) {
m_cache_dir.SetPath(path);
// Prune the cache based off of the LLDB settings each time we create a cache
// object.
ModuleListProperties &properties =
ModuleList::GetGlobalModuleListProperties();
- CachePruningPolicy policy;
+ llvm::CachePruningPolicy policy;
// Only scan once an hour. If we have lots of debug sessions we don't want
// to scan this directory too often. A timestamp file is written to the
// directory to ensure different processes don't scan the directory too often.
@@ -52,19 +51,19 @@ DataFileCache::DataFileCache(StringRef path) {
if (m_take_ownership)
m_mem_buff_up = std::move(m);
};
- Expected<FileCache> cache_or_err =
+ llvm::Expected<llvm::FileCache> cache_or_err =
llvm::localCache("LLDBModuleCache", "lldb-module", path, add_buffer);
if (cache_or_err)
m_cache_callback = std::move(*cache_or_err);
else {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
+ Log *log = GetLog(LLDBLog::Modules);
LLDB_LOG_ERROR(log, cache_or_err.takeError(),
"failed to create lldb index cache directory: {0}");
}
}
std::unique_ptr<llvm::MemoryBuffer>
-DataFileCache::GetCachedData(StringRef key) {
+DataFileCache::GetCachedData(llvm::StringRef key) {
std::lock_guard<std::mutex> guard(m_mutex);
const unsigned task = 1;
@@ -73,13 +72,14 @@ DataFileCache::GetCachedData(StringRef key) {
// call the "add_buffer" lambda function from the constructor which will in
// turn take ownership of the member buffer that is passed to the callback and
// put it into a member variable.
- Expected<AddStreamFn> add_stream_or_err = m_cache_callback(task, key);
+ llvm::Expected<llvm::AddStreamFn> add_stream_or_err =
+ m_cache_callback(task, key);
m_take_ownership = false;
// At this point we either already called the "add_buffer" lambda with
// the data or we haven't. We can tell if we got the cached data by checking
// the add_stream function pointer value below.
if (add_stream_or_err) {
- AddStreamFn &add_stream = *add_stream_or_err;
+ llvm::AddStreamFn &add_stream = *add_stream_or_err;
// If the "add_stream" is nullptr, then the data was cached and we already
// called the "add_buffer" lambda. If it is valid, then if we were to call
// the add_stream function it would cause a cache file to get generated
@@ -89,7 +89,7 @@ DataFileCache::GetCachedData(StringRef key) {
if (!add_stream)
return std::move(m_mem_buff_up);
} else {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
+ Log *log = GetLog(LLDBLog::Modules);
LLDB_LOG_ERROR(log, add_stream_or_err.takeError(),
"failed to get the cache add stream callback for key: {0}");
}
@@ -97,18 +97,20 @@ DataFileCache::GetCachedData(StringRef key) {
return std::unique_ptr<llvm::MemoryBuffer>();
}
-bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef<uint8_t> data) {
+bool DataFileCache::SetCachedData(llvm::StringRef key,
+ llvm::ArrayRef<uint8_t> data) {
std::lock_guard<std::mutex> guard(m_mutex);
const unsigned task = 2;
// If we call this function and the data is cached, it will call the
// add_buffer lambda function from the constructor which will ignore the
// data.
- Expected<AddStreamFn> add_stream_or_err = m_cache_callback(task, key);
+ llvm::Expected<llvm::AddStreamFn> add_stream_or_err =
+ m_cache_callback(task, key);
// If we reach this code then we either already called the callback with
// the data or we haven't. We can tell if we had the cached data by checking
// the CacheAddStream function pointer value below.
if (add_stream_or_err) {
- AddStreamFn &add_stream = *add_stream_or_err;
+ llvm::AddStreamFn &add_stream = *add_stream_or_err;
// If the "add_stream" is nullptr, then the data was cached. If it is
// valid, then if we call the add_stream function with a task it will
// cause the file to get generated, but we only want to check if the data
@@ -117,20 +119,20 @@ bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef<uint8_t> data) {
// provided, but we won't take ownership of the memory buffer as we just
// want to write the data.
if (add_stream) {
- Expected<std::unique_ptr<CachedFileStream>> file_or_err =
+ llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> file_or_err =
add_stream(task);
if (file_or_err) {
- CachedFileStream *cfs = file_or_err->get();
+ llvm::CachedFileStream *cfs = file_or_err->get();
cfs->OS->write((const char *)data.data(), data.size());
return true;
} else {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
+ Log *log = GetLog(LLDBLog::Modules);
LLDB_LOG_ERROR(log, file_or_err.takeError(),
"failed to get the cache file stream for key: {0}");
}
}
} else {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
+ Log *log = GetLog(LLDBLog::Modules);
LLDB_LOG_ERROR(log, add_stream_or_err.takeError(),
"failed to get the cache add stream callback for key: {0}");
}
@@ -197,21 +199,21 @@ enum SignatureEncoding {
eSignatureEnd = 255u,
};
-bool CacheSignature::Encode(DataEncoder &encoder) {
+bool CacheSignature::Encode(DataEncoder &encoder) const {
if (!IsValid())
return false; // Invalid signature, return false!
- if (m_uuid.hasValue()) {
+ if (m_uuid) {
llvm::ArrayRef<uint8_t> uuid_bytes = m_uuid->GetBytes();
encoder.AppendU8(eSignatureUUID);
encoder.AppendU8(uuid_bytes.size());
encoder.AppendData(uuid_bytes);
}
- if (m_mod_time.hasValue()) {
+ if (m_mod_time) {
encoder.AppendU8(eSignatureModTime);
encoder.AppendU32(*m_mod_time);
}
- if (m_obj_mod_time.hasValue()) {
+ if (m_obj_mod_time) {
encoder.AppendU8(eSignatureObjectModTime);
encoder.AppendU32(*m_obj_mod_time);
}
@@ -219,7 +221,7 @@ bool CacheSignature::Encode(DataEncoder &encoder) {
return true;
}
-bool CacheSignature::Decode(const DataExtractor &data,
+bool CacheSignature::Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr) {
Clear();
while (uint8_t sig_encoding = data.GetU8(offset_ptr)) {
@@ -238,10 +240,14 @@ bool CacheSignature::Decode(const DataExtractor &data,
case eSignatureObjectModTime: {
uint32_t mod_time = data.GetU32(offset_ptr);
if (mod_time > 0)
- m_mod_time = mod_time;
+ m_obj_mod_time = mod_time;
} break;
case eSignatureEnd:
- return true;
+ // The definition of is valid changed to only be valid if the UUID is
+ // valid so make sure that if we attempt to decode an old cache file
+ // that we will fail to decode the cache file if the signature isn't
+ // considered valid.
+ return IsValid();
default:
break;
}
@@ -284,7 +290,7 @@ bool ConstStringTable::Encode(DataEncoder &encoder) {
return true;
}
-bool StringTableReader::Decode(const DataExtractor &data,
+bool StringTableReader::Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr) {
llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);
if (identifier != kStringTableIdentifier)
@@ -296,12 +302,12 @@ bool StringTableReader::Decode(const DataExtractor &data,
const char *bytes = (const char *)data.GetData(offset_ptr, length);
if (bytes == nullptr)
return false;
- m_data = StringRef(bytes, length);
+ m_data = llvm::StringRef(bytes, length);
return true;
}
-StringRef StringTableReader::Get(uint32_t offset) const {
+llvm::StringRef StringTableReader::Get(uint32_t offset) const {
if (offset >= m_data.size())
- return StringRef();
- return StringRef(m_data.data() + offset);
+ return llvm::StringRef();
+ return llvm::StringRef(m_data.data() + offset);
}
diff --git a/contrib/llvm-project/lldb/source/Core/Debugger.cpp b/contrib/llvm-project/lldb/source/Core/Debugger.cpp
index 49cc21b65951..f17cd8856a6d 100644
--- a/contrib/llvm-project/lldb/source/Core/Debugger.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Debugger.cpp
@@ -9,6 +9,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Core/DebuggerEvents.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/ModuleList.h"
@@ -43,13 +44,13 @@
#include "lldb/Target/ThreadList.h"
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Event.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Listener.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/ReproducerProvider.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
-#include "lldb/Utility/StreamCallback.h"
#include "lldb/Utility/StreamString.h"
#if defined(_WIN32)
@@ -64,6 +65,7 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
+#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
@@ -377,12 +379,44 @@ bool Debugger::SetUseColor(bool b) {
return ret;
}
+bool Debugger::GetShowProgress() const {
+ const uint32_t idx = ePropertyShowProgress;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
+}
+
+bool Debugger::SetShowProgress(bool show_progress) {
+ const uint32_t idx = ePropertyShowProgress;
+ return m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx,
+ show_progress);
+}
+
+llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const {
+ const uint32_t idx = ePropertyShowProgressAnsiPrefix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
+llvm::StringRef Debugger::GetShowProgressAnsiSuffix() const {
+ const uint32_t idx = ePropertyShowProgressAnsiSuffix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
bool Debugger::GetUseAutosuggestion() const {
const uint32_t idx = ePropertyShowAutosuggestion;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
}
+llvm::StringRef Debugger::GetAutosuggestionAnsiPrefix() const {
+ const uint32_t idx = ePropertyShowAutosuggestionAnsiPrefix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
+llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const {
+ const uint32_t idx = ePropertyShowAutosuggestionAnsiSuffix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
bool Debugger::GetUseSourceCache() const {
const uint32_t idx = ePropertyUseSourceCache;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -635,9 +669,9 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
CommandReturnObject result(debugger_sp->GetUseColor());
cmd_interpreter.SaveTranscript(result);
if (result.Succeeded())
- debugger_sp->GetOutputStream() << result.GetOutputData() << '\n';
+ (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n';
else
- debugger_sp->GetErrorStream() << result.GetErrorData() << '\n';
+ (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n';
}
debugger_sp->Clear();
@@ -723,8 +757,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_forward_listener_sp(), m_clear_once() {
m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
if (log_callback)
- m_log_callback_stream_sp =
- std::make_shared<StreamCallback>(log_callback, baton);
+ m_callback_handler_sp =
+ std::make_shared<CallbackLogHandler>(log_callback, baton);
m_command_interpreter_up->Initialize();
// Always add our default platform to the platform list
PlatformSP default_platform_sp(Platform::GetHostPlatform());
@@ -865,7 +899,8 @@ Status Debugger::SetInputString(const char *data) {
return result;
}
- write(fds[WRITE], data, size);
+ int r = write(fds[WRITE], data, size);
+ (void)r;
// Close the write end of the pipe, so that the command interpreter will exit
// when it consumes all the data.
llvm::sys::Process::SafelyCloseFileDescriptor(fds[WRITE]);
@@ -1041,9 +1076,12 @@ bool Debugger::CheckTopIOHandlerTypes(IOHandler::Type top_type,
}
void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) {
- lldb_private::StreamFile &stream =
- is_stdout ? GetOutputStream() : GetErrorStream();
- m_io_handler_stack.PrintAsync(&stream, s, len);
+ bool printed = m_io_handler_stack.PrintAsync(s, len, is_stdout);
+ if (!printed) {
+ lldb::StreamFileSP stream =
+ is_stdout ? m_output_stream_sp : m_error_stream_sp;
+ stream->Write(s, len);
+ }
}
ConstString Debugger::GetTopIOHandlerControlSequence(char ch) {
@@ -1163,11 +1201,11 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
}
StreamSP Debugger::GetAsyncOutputStream() {
- return std::make_shared<StreamAsynchronousIO>(*this, true);
+ return std::make_shared<StreamAsynchronousIO>(*this, true, GetUseColor());
}
StreamSP Debugger::GetAsyncErrorStream() {
- return std::make_shared<StreamAsynchronousIO>(*this, false);
+ return std::make_shared<StreamAsynchronousIO>(*this, false, GetUseColor());
}
size_t Debugger::GetNumDebuggers() {
@@ -1253,38 +1291,8 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
// For simplicity's sake, I am not going to deal with how to close down any
// open logging streams, I just redirect everything from here on out to the
// callback.
- m_log_callback_stream_sp =
- std::make_shared<StreamCallback>(log_callback, baton);
-}
-
-ConstString Debugger::ProgressEventData::GetFlavorString() {
- static ConstString g_flavor("Debugger::ProgressEventData");
- return g_flavor;
-}
-
-ConstString Debugger::ProgressEventData::GetFlavor() const {
- return Debugger::ProgressEventData::GetFlavorString();
-}
-
-void Debugger::ProgressEventData::Dump(Stream *s) const {
- s->Printf(" id = %" PRIu64 ", message = \"%s\"", m_id, m_message.c_str());
- if (m_completed == 0 || m_completed == m_total)
- s->Printf(", type = %s", m_completed == 0 ? "start" : "end");
- else
- s->PutCString(", type = update");
- // If m_total is UINT64_MAX, there is no progress to report, just "start"
- // and "end". If it isn't we will show the completed and total amounts.
- if (m_total != UINT64_MAX)
- s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total);
-}
-
-const Debugger::ProgressEventData *
-Debugger::ProgressEventData::GetEventDataFromEvent(const Event *event_ptr) {
- if (event_ptr)
- if (const EventData *event_data = event_ptr->GetData())
- if (event_data->GetFlavor() == ProgressEventData::GetFlavorString())
- return static_cast<const ProgressEventData *>(event_ptr->GetData());
- return nullptr;
+ m_callback_handler_sp =
+ std::make_shared<CallbackLogHandler>(log_callback, baton);
}
static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
@@ -1295,9 +1303,9 @@ static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
const uint32_t event_type = Debugger::eBroadcastBitProgress;
if (!debugger.GetBroadcaster().EventTypeHasListeners(event_type))
return;
- EventSP event_sp(new Event(event_type, new Debugger::ProgressEventData(
- progress_id, message, completed,
- total, is_debugger_specific)));
+ EventSP event_sp(new Event(
+ event_type, new ProgressEventData(progress_id, message, completed, total,
+ is_debugger_specific)));
debugger.GetBroadcaster().BroadcastEvent(event_sp);
}
@@ -1305,7 +1313,7 @@ void Debugger::ReportProgress(uint64_t progress_id, const std::string &message,
uint64_t completed, uint64_t total,
llvm::Optional<lldb::user_id_t> debugger_id) {
// Check if this progress is for a specific debugger.
- if (debugger_id.hasValue()) {
+ if (debugger_id) {
// It is debugger specific, grab it and deliver the event if the debugger
// still exists.
DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id);
@@ -1325,27 +1333,116 @@ void Debugger::ReportProgress(uint64_t progress_id, const std::string &message,
}
}
+static void PrivateReportDiagnostic(Debugger &debugger,
+ DiagnosticEventData::Type type,
+ std::string message,
+ bool debugger_specific) {
+ uint32_t event_type = 0;
+ switch (type) {
+ case DiagnosticEventData::Type::Warning:
+ event_type = Debugger::eBroadcastBitWarning;
+ break;
+ case DiagnosticEventData::Type::Error:
+ event_type = Debugger::eBroadcastBitError;
+ break;
+ }
+
+ Broadcaster &broadcaster = debugger.GetBroadcaster();
+ if (!broadcaster.EventTypeHasListeners(event_type)) {
+ // Diagnostics are too important to drop. If nobody is listening, print the
+ // diagnostic directly to the debugger's error stream.
+ DiagnosticEventData event_data(type, std::move(message), debugger_specific);
+ StreamSP stream = debugger.GetAsyncErrorStream();
+ event_data.Dump(stream.get());
+ return;
+ }
+ EventSP event_sp = std::make_shared<Event>(
+ event_type,
+ new DiagnosticEventData(type, std::move(message), debugger_specific));
+ broadcaster.BroadcastEvent(event_sp);
+}
+
+void Debugger::ReportDiagnosticImpl(DiagnosticEventData::Type type,
+ std::string message,
+ llvm::Optional<lldb::user_id_t> debugger_id,
+ std::once_flag *once) {
+ auto ReportDiagnosticLambda = [&]() {
+ // Check if this progress is for a specific debugger.
+ if (debugger_id) {
+ // It is debugger specific, grab it and deliver the event if the debugger
+ // still exists.
+ DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id);
+ if (debugger_sp)
+ PrivateReportDiagnostic(*debugger_sp, type, std::move(message), true);
+ return;
+ }
+ // The progress event is not debugger specific, iterate over all debuggers
+ // and deliver a progress event to each one.
+ if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
+ std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr);
+ for (const auto &debugger : *g_debugger_list_ptr)
+ PrivateReportDiagnostic(*debugger, type, message, false);
+ }
+ };
+
+ if (once)
+ std::call_once(*once, ReportDiagnosticLambda);
+ else
+ ReportDiagnosticLambda();
+}
+
+void Debugger::ReportWarning(std::string message,
+ llvm::Optional<lldb::user_id_t> debugger_id,
+ std::once_flag *once) {
+ ReportDiagnosticImpl(DiagnosticEventData::Type::Warning, std::move(message),
+ debugger_id, once);
+}
+
+void Debugger::ReportError(std::string message,
+ llvm::Optional<lldb::user_id_t> debugger_id,
+ std::once_flag *once) {
+
+ ReportDiagnosticImpl(DiagnosticEventData::Type::Error, std::move(message),
+ debugger_id, once);
+}
+
+static std::shared_ptr<LogHandler>
+CreateLogHandler(LogHandlerKind log_handler_kind, int fd, bool should_close,
+ size_t buffer_size) {
+ switch (log_handler_kind) {
+ case eLogHandlerStream:
+ return std::make_shared<StreamLogHandler>(fd, should_close, buffer_size);
+ case eLogHandlerCircular:
+ return std::make_shared<RotatingLogHandler>(buffer_size);
+ case eLogHandlerSystem:
+ return std::make_shared<SystemLogHandler>();
+ case eLogHandlerCallback:
+ return {};
+ }
+ return {};
+}
+
bool Debugger::EnableLog(llvm::StringRef channel,
llvm::ArrayRef<const char *> categories,
llvm::StringRef log_file, uint32_t log_options,
+ size_t buffer_size, LogHandlerKind log_handler_kind,
llvm::raw_ostream &error_stream) {
- const bool should_close = true;
- const bool unbuffered = true;
- std::shared_ptr<llvm::raw_ostream> log_stream_sp;
- if (m_log_callback_stream_sp) {
- log_stream_sp = m_log_callback_stream_sp;
+ std::shared_ptr<LogHandler> log_handler_sp;
+ if (m_callback_handler_sp) {
+ log_handler_sp = m_callback_handler_sp;
// For now when using the callback mode you always get thread & timestamp.
log_options |=
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
} else if (log_file.empty()) {
- log_stream_sp = std::make_shared<llvm::raw_fd_ostream>(
- GetOutputFile().GetDescriptor(), !should_close, unbuffered);
+ log_handler_sp =
+ CreateLogHandler(log_handler_kind, GetOutputFile().GetDescriptor(),
+ /*should_close=*/false, buffer_size);
} else {
- auto pos = m_log_streams.find(log_file);
- if (pos != m_log_streams.end())
- log_stream_sp = pos->second.lock();
- if (!log_stream_sp) {
+ auto pos = m_stream_handlers.find(log_file);
+ if (pos != m_stream_handlers.end())
+ log_handler_sp = pos->second.lock();
+ if (!log_handler_sp) {
File::OpenOptions flags =
File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate;
if (log_options & LLDB_LOG_OPTION_APPEND)
@@ -1360,18 +1457,18 @@ bool Debugger::EnableLog(llvm::StringRef channel,
return false;
}
- log_stream_sp = std::make_shared<llvm::raw_fd_ostream>(
- (*file)->GetDescriptor(), should_close, unbuffered);
- m_log_streams[log_file] = log_stream_sp;
+ log_handler_sp =
+ CreateLogHandler(log_handler_kind, (*file)->GetDescriptor(),
+ /*should_close=*/true, buffer_size);
+ m_stream_handlers[log_file] = log_handler_sp;
}
}
- assert(log_stream_sp);
+ assert(log_handler_sp);
if (log_options == 0)
- log_options =
- LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE;
+ log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
- return Log::EnableLogChannel(log_stream_sp, log_options, channel, categories,
+ return Log::EnableLogChannel(log_handler_sp, log_options, channel, categories,
error_stream);
}
@@ -1575,7 +1672,7 @@ void Debugger::CancelForwardEvents(const ListenerSP &listener_sp) {
m_forward_listener_sp.reset();
}
-void Debugger::DefaultEventHandler() {
+lldb::thread_result_t Debugger::DefaultEventHandler() {
ListenerSP listener_sp(GetListener());
ConstString broadcaster_class_target(Target::GetStaticBroadcasterClass());
ConstString broadcaster_class_process(Process::GetStaticBroadcasterClass());
@@ -1604,6 +1701,10 @@ void Debugger::DefaultEventHandler() {
CommandInterpreter::eBroadcastBitAsynchronousOutputData |
CommandInterpreter::eBroadcastBitAsynchronousErrorData);
+ listener_sp->StartListeningForEvents(
+ &m_broadcaster,
+ eBroadcastBitProgress | eBroadcastBitWarning | eBroadcastBitError);
+
// Let the thread that spawned us know that we have started up and that we
// are now listening to all required events so no events get missed
m_sync_broadcaster.BroadcastEvent(eBroadcastBitEventThreadIsListening);
@@ -1653,6 +1754,13 @@ void Debugger::DefaultEventHandler() {
}
}
}
+ } else if (broadcaster == &m_broadcaster) {
+ if (event_type & Debugger::eBroadcastBitProgress)
+ HandleProgressEvent(event_sp);
+ else if (event_type & Debugger::eBroadcastBitWarning)
+ HandleDiagnosticEvent(event_sp);
+ else if (event_type & Debugger::eBroadcastBitError)
+ HandleDiagnosticEvent(event_sp);
}
}
@@ -1661,10 +1769,6 @@ void Debugger::DefaultEventHandler() {
}
}
}
-}
-
-lldb::thread_result_t Debugger::EventHandlerThread(lldb::thread_arg_t arg) {
- ((Debugger *)arg)->DefaultEventHandler();
return {};
}
@@ -1686,14 +1790,14 @@ bool Debugger::StartEventHandlerThread() {
// Use larger 8MB stack for this thread
llvm::Expected<HostThread> event_handler_thread =
- ThreadLauncher::LaunchThread(thread_name, EventHandlerThread, this,
- g_debugger_event_thread_stack_bytes);
+ ThreadLauncher::LaunchThread(
+ thread_name, [this] { return DefaultEventHandler(); },
+ g_debugger_event_thread_stack_bytes);
if (event_handler_thread) {
m_event_handler_thread = *event_handler_thread;
} else {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
- "failed to launch host thread: {}",
+ LLDB_LOG(GetLog(LLDBLog::Host), "failed to launch host thread: {}",
llvm::toString(event_handler_thread.takeError()));
}
@@ -1716,25 +1820,106 @@ void Debugger::StopEventHandlerThread() {
}
}
-lldb::thread_result_t Debugger::IOHandlerThread(lldb::thread_arg_t arg) {
- Debugger *debugger = (Debugger *)arg;
- debugger->RunIOHandlers();
- debugger->StopEventHandlerThread();
+lldb::thread_result_t Debugger::IOHandlerThread() {
+ RunIOHandlers();
+ StopEventHandlerThread();
return {};
}
+void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
+ auto *data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ if (!data)
+ return;
+
+ // Do some bookkeeping for the current event, regardless of whether we're
+ // going to show the progress.
+ const uint64_t id = data->GetID();
+ if (m_current_event_id) {
+ if (id != *m_current_event_id)
+ return;
+ if (data->GetCompleted())
+ m_current_event_id.reset();
+ } else {
+ m_current_event_id = id;
+ }
+
+ // Decide whether we actually are going to show the progress. This decision
+ // can change between iterations so check it inside the loop.
+ if (!GetShowProgress())
+ return;
+
+ // Determine whether the current output file is an interactive terminal with
+ // color support. We assume that if we support ANSI escape codes we support
+ // vt100 escape codes.
+ File &file = GetOutputFile();
+ if (!file.GetIsInteractive() || !file.GetIsTerminalWithColors())
+ return;
+
+ StreamSP output = GetAsyncOutputStream();
+
+ // Print over previous line, if any.
+ output->Printf("\r");
+
+ if (data->GetCompleted()) {
+ // Clear the current line.
+ output->Printf("\x1B[2K");
+ output->Flush();
+ return;
+ }
+
+ // Trim the progress message if it exceeds the window's width and print it.
+ std::string message = data->GetMessage();
+ if (data->IsFinite())
+ message = llvm::formatv("[{0}/{1}] {2}", data->GetCompleted(),
+ data->GetTotal(), message)
+ .str();
+
+ // Trim the progress message if it exceeds the window's width and print it.
+ const uint32_t term_width = GetTerminalWidth();
+ const uint32_t ellipsis = 3;
+ if (message.size() + ellipsis >= term_width)
+ message = message.substr(0, term_width - ellipsis);
+
+ const bool use_color = GetUseColor();
+ llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix();
+ if (!ansi_prefix.empty())
+ output->Printf(
+ "%s", ansi::FormatAnsiTerminalCodes(ansi_prefix, use_color).c_str());
+
+ output->Printf("%s...", message.c_str());
+
+ llvm::StringRef ansi_suffix = GetShowProgressAnsiSuffix();
+ if (!ansi_suffix.empty())
+ output->Printf(
+ "%s", ansi::FormatAnsiTerminalCodes(ansi_suffix, use_color).c_str());
+
+ // Clear until the end of the line.
+ output->Printf("\x1B[K\r");
+
+ // Flush the output.
+ output->Flush();
+}
+
+void Debugger::HandleDiagnosticEvent(const lldb::EventSP &event_sp) {
+ auto *data = DiagnosticEventData::GetEventDataFromEvent(event_sp.get());
+ if (!data)
+ return;
+
+ StreamSP stream = GetAsyncErrorStream();
+ data->Dump(stream.get());
+}
+
bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); }
bool Debugger::StartIOHandlerThread() {
if (!m_io_handler_thread.IsJoinable()) {
llvm::Expected<HostThread> io_handler_thread = ThreadLauncher::LaunchThread(
- "lldb.debugger.io-handler", IOHandlerThread, this,
+ "lldb.debugger.io-handler", [this] { return IOHandlerThread(); },
8 * 1024 * 1024); // Use larger 8MB stack for this thread
if (io_handler_thread) {
m_io_handler_thread = *io_handler_thread;
} else {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
- "failed to launch host thread: {}",
+ LLDB_LOG(GetLog(LLDBLog::Host), "failed to launch host thread: {}",
llvm::toString(io_handler_thread.takeError()));
}
}
@@ -1807,3 +1992,13 @@ Status Debugger::RunREPL(LanguageType language, const char *repl_options) {
return err;
}
+
+llvm::ThreadPool &Debugger::GetThreadPool() {
+ // NOTE: intentional leak to avoid issues with C++ destructor chain
+ static llvm::ThreadPool *g_thread_pool = nullptr;
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
+ g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency());
+ });
+ return *g_thread_pool;
+}
diff --git a/contrib/llvm-project/lldb/source/Core/DebuggerEvents.cpp b/contrib/llvm-project/lldb/source/Core/DebuggerEvents.cpp
new file mode 100644
index 000000000000..19693e91ab23
--- /dev/null
+++ b/contrib/llvm-project/lldb/source/Core/DebuggerEvents.cpp
@@ -0,0 +1,81 @@
+//===-- DebuggerEvents.cpp ------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/DebuggerEvents.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace lldb_private;
+
+template <typename T>
+static const T *GetEventDataFromEventImpl(const Event *event_ptr) {
+ if (event_ptr)
+ if (const EventData *event_data = event_ptr->GetData())
+ if (event_data->GetFlavor() == T::GetFlavorString())
+ return static_cast<const T *>(event_ptr->GetData());
+ return nullptr;
+}
+
+ConstString ProgressEventData::GetFlavorString() {
+ static ConstString g_flavor("ProgressEventData");
+ return g_flavor;
+}
+
+ConstString ProgressEventData::GetFlavor() const {
+ return ProgressEventData::GetFlavorString();
+}
+
+void ProgressEventData::Dump(Stream *s) const {
+ s->Printf(" id = %" PRIu64 ", message = \"%s\"", m_id, m_message.c_str());
+ if (m_completed == 0 || m_completed == m_total)
+ s->Printf(", type = %s", m_completed == 0 ? "start" : "end");
+ else
+ s->PutCString(", type = update");
+ // If m_total is UINT64_MAX, there is no progress to report, just "start"
+ // and "end". If it isn't we will show the completed and total amounts.
+ if (m_total != UINT64_MAX)
+ s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total);
+}
+
+const ProgressEventData *
+ProgressEventData::GetEventDataFromEvent(const Event *event_ptr) {
+ return GetEventDataFromEventImpl<ProgressEventData>(event_ptr);
+}
+
+llvm::StringRef DiagnosticEventData::GetPrefix() const {
+ switch (m_type) {
+ case Type::Warning:
+ return "warning";
+ case Type::Error:
+ return "error";
+ }
+ llvm_unreachable("Fully covered switch above!");
+}
+
+void DiagnosticEventData::Dump(Stream *s) const {
+ llvm::HighlightColor color = m_type == Type::Warning
+ ? llvm::HighlightColor::Warning
+ : llvm::HighlightColor::Error;
+ llvm::WithColor(s->AsRawOstream(), color, llvm::ColorMode::Enable)
+ << GetPrefix();
+ *s << ": " << GetMessage() << '\n';
+ s->Flush();
+}
+
+ConstString DiagnosticEventData::GetFlavorString() {
+ static ConstString g_flavor("DiagnosticEventData");
+ return g_flavor;
+}
+
+ConstString DiagnosticEventData::GetFlavor() const {
+ return DiagnosticEventData::GetFlavorString();
+}
+
+const DiagnosticEventData *
+DiagnosticEventData::GetEventDataFromEvent(const Event *event_ptr) {
+ return GetEventDataFromEventImpl<DiagnosticEventData>(event_ptr);
+}
diff --git a/contrib/llvm-project/lldb/source/Core/DumpDataExtractor.cpp b/contrib/llvm-project/lldb/source/Core/DumpDataExtractor.cpp
index 211e16a2e033..4ef1df1aeb0f 100644
--- a/contrib/llvm-project/lldb/source/Core/DumpDataExtractor.cpp
+++ b/contrib/llvm-project/lldb/source/Core/DumpDataExtractor.cpp
@@ -118,7 +118,7 @@ static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data,
lldb::offset_t offset, lldb::offset_t byte_size,
bool is_signed, unsigned radix) {
llvm::Optional<llvm::APInt> apint = GetAPInt(data, &offset, byte_size);
- if (apint.hasValue()) {
+ if (apint) {
std::string apint_str = toString(apint.getValue(), radix, is_signed);
switch (radix) {
case 2:
@@ -670,7 +670,7 @@ lldb::offset_t lldb_private::DumpDataExtractor(
(llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
llvm::Optional<llvm::APInt> apint =
GetAPInt(DE, &offset, semantics_byte_size);
- if (apint.hasValue()) {
+ if (apint) {
llvm::APFloat apfloat(semantics, apint.getValue());
apfloat.toString(sv, format_precision, format_max_padding);
if (!sv.empty()) {
diff --git a/contrib/llvm-project/lldb/source/Core/DynamicLoader.cpp b/contrib/llvm-project/lldb/source/Core/DynamicLoader.cpp
index 1c7b9125e4d1..96e0d4ec6555 100644
--- a/contrib/llvm-project/lldb/source/Core/DynamicLoader.cpp
+++ b/contrib/llvm-project/lldb/source/Core/DynamicLoader.cpp
@@ -145,72 +145,30 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const {
return sections;
}
-ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
- addr_t link_map_addr,
- addr_t base_addr,
- bool base_addr_is_offset) {
+ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) {
Target &target = m_process->GetTarget();
- ModuleList &modules = target.GetImages();
ModuleSpec module_spec(file, target.GetArchitecture());
- ModuleSP module_sp;
- if ((module_sp = modules.FindFirstModule(module_spec))) {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr,
- base_addr_is_offset);
+ if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec))
return module_sp;
- }
- if ((module_sp = target.GetOrCreateModule(module_spec,
- true /* notify */))) {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr,
- base_addr_is_offset);
+ if (ModuleSP module_sp = target.GetOrCreateModule(module_spec, false))
return module_sp;
- }
-
- bool check_alternative_file_name = true;
- if (base_addr_is_offset) {
- // Try to fetch the load address of the file from the process as we need
- // absolute load address to read the file out of the memory instead of a
- // load bias.
- bool is_loaded = false;
- lldb::addr_t load_addr;
- Status error = m_process->GetFileLoadAddress(file, is_loaded, load_addr);
- if (error.Success() && is_loaded) {
- check_alternative_file_name = false;
- base_addr = load_addr;
- }
- }
-
- // We failed to find the module based on its name. Lets try to check if we
- // can find a different name based on the memory region info.
- if (check_alternative_file_name) {
- MemoryRegionInfo memory_info;
- Status error = m_process->GetMemoryRegionInfo(base_addr, memory_info);
- if (error.Success() && memory_info.GetMapped() &&
- memory_info.GetRange().GetRangeBase() == base_addr &&
- !(memory_info.GetName().IsEmpty())) {
- ModuleSpec new_module_spec(FileSpec(memory_info.GetName().GetStringRef()),
- target.GetArchitecture());
-
- if ((module_sp = modules.FindFirstModule(new_module_spec))) {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
- return module_sp;
- }
- if ((module_sp = target.GetOrCreateModule(new_module_spec,
- true /* notify */))) {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
- return module_sp;
- }
- }
- }
+ return nullptr;
+}
- if ((module_sp = m_process->ReadModuleFromMemory(file, base_addr))) {
- UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
- target.GetImages().AppendIfNeeded(module_sp);
+ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
+ addr_t link_map_addr,
+ addr_t base_addr,
+ bool base_addr_is_offset) {
+ if (ModuleSP module_sp = FindModuleViaTarget(file)) {
+ UpdateLoadedSections(module_sp, link_map_addr, base_addr,
+ base_addr_is_offset);
+ return module_sp;
}
- return module_sp;
+ return nullptr;
}
int64_t DynamicLoader::ReadUnsignedIntWithSizeInBytes(addr_t addr,
diff --git a/contrib/llvm-project/lldb/source/Core/FileSpecList.cpp b/contrib/llvm-project/lldb/source/Core/FileSpecList.cpp
index 1a1cf284ea07..8eec8f499352 100644
--- a/contrib/llvm-project/lldb/source/Core/FileSpecList.cpp
+++ b/contrib/llvm-project/lldb/source/Core/FileSpecList.cpp
@@ -16,7 +16,6 @@
#include <cstdint>
using namespace lldb_private;
-using namespace std;
FileSpecList::FileSpecList() : m_files() {}
diff --git a/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp b/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp
index 6e6255b903bb..6e7f44e461fa 100644
--- a/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp
+++ b/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp
@@ -44,8 +44,8 @@
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
@@ -263,11 +263,10 @@ constexpr Definition g_root = Entry::DefinitionWithChildren(
FormatEntity::Entry::Entry(llvm::StringRef s)
: string(s.data(), s.size()), printf_format(), children(),
- type(Type::String), fmt(lldb::eFormatDefault), number(0), deref(false) {}
+ type(Type::String) {}
FormatEntity::Entry::Entry(char ch)
- : string(1, ch), printf_format(), children(), type(Type::String),
- fmt(lldb::eFormatDefault), number(0), deref(false) {}
+ : string(1, ch), printf_format(), children(), type(Type::String) {}
void FormatEntity::Entry::AppendChar(char ch) {
if (children.empty() || children.back().type != Entry::Type::String)
@@ -509,7 +508,7 @@ static bool ScanBracketedRange(llvm::StringRef subpath,
size_t &close_bracket_index,
const char *&var_name_final_if_array_range,
int64_t &index_lower, int64_t &index_higher) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+ Log *log = GetLog(LLDBLog::DataFormatters);
close_bracket_index = llvm::StringRef::npos;
const size_t open_bracket_index = subpath.find('[');
if (open_bracket_index == llvm::StringRef::npos) {
@@ -618,7 +617,7 @@ static bool DumpRegister(Stream &s, StackFrame *frame, RegisterKind reg_kind,
static ValueObjectSP ExpandIndexedExpression(ValueObject *valobj, size_t index,
bool deref_pointer) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+ Log *log = GetLog(LLDBLog::DataFormatters);
const char *ptr_deref_format = "[%d]";
std::string ptr_deref_buffer(10, 0);
::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
@@ -676,7 +675,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
if (valobj == nullptr)
return false;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+ Log *log = GetLog(LLDBLog::DataFormatters);
Format custom_format = eFormatInvalid;
ValueObject::ValueObjectRepresentationStyle val_obj_display =
entry.string.empty()
diff --git a/contrib/llvm-project/lldb/source/Core/IOHandler.cpp b/contrib/llvm-project/lldb/source/Core/IOHandler.cpp
index c35b17990842..db388ab48275 100644
--- a/contrib/llvm-project/lldb/source/Core/IOHandler.cpp
+++ b/contrib/llvm-project/lldb/source/Core/IOHandler.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/File.h"
+#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/ReproducerProvider.h"
#include "lldb/Utility/Status.h"
@@ -121,14 +122,19 @@ void IOHandler::SetPopped(bool b) { m_popped.SetValue(b, eBroadcastOnChange); }
void IOHandler::WaitForPop() { m_popped.WaitForValueEqualTo(true); }
-void IOHandlerStack::PrintAsync(Stream *stream, const char *s, size_t len) {
- if (stream) {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (m_top)
- m_top->PrintAsync(stream, s, len);
- else
- stream->Write(s, len);
- }
+void IOHandler::PrintAsync(const char *s, size_t len, bool is_stdout) {
+ std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
+ lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
+ stream->Write(s, len);
+ stream->Flush();
+}
+
+bool IOHandlerStack::PrintAsync(const char *s, size_t len, bool is_stdout) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_top)
+ return false;
+ m_top->PrintAsync(s, len, is_stdout);
+ return true;
}
IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
@@ -261,9 +267,9 @@ IOHandlerEditline::IOHandlerEditline(
m_input_sp && m_input_sp->GetIsRealTerminal();
if (use_editline) {
- m_editline_up = std::make_unique<Editline>(editline_name, GetInputFILE(),
- GetOutputFILE(), GetErrorFILE(),
- m_color_prompts);
+ m_editline_up = std::make_unique<Editline>(
+ editline_name, GetInputFILE(), GetOutputFILE(), GetErrorFILE(),
+ GetOutputMutex(), m_color_prompts);
m_editline_up->SetIsInputCompleteCallback(
[this](Editline *editline, StringList &lines) {
return this->IsInputCompleteCallback(editline, lines);
@@ -273,10 +279,14 @@ IOHandlerEditline::IOHandlerEditline(
this->AutoCompleteCallback(request);
});
- if (debugger.GetUseAutosuggestion() && debugger.GetUseColor()) {
+ if (debugger.GetUseAutosuggestion()) {
m_editline_up->SetSuggestionCallback([this](llvm::StringRef line) {
return this->SuggestionCallback(line);
});
+ m_editline_up->SetSuggestionAnsiPrefix(ansi::FormatAnsiTerminalCodes(
+ debugger.GetAutosuggestionAnsiPrefix()));
+ m_editline_up->SetSuggestionAnsiSuffix(ansi::FormatAnsiTerminalCodes(
+ debugger.GetAutosuggestionAnsiSuffix()));
}
// See if the delegate supports fixing indentation
const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters();
@@ -426,7 +436,7 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
}
if (got_line) {
- line = got_line.getValue();
+ line = *got_line;
if (m_data_recorder)
m_data_recorder->Record(line, true);
}
@@ -607,11 +617,13 @@ void IOHandlerEditline::GotEOF() {
#endif
}
-void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
+void IOHandlerEditline::PrintAsync(const char *s, size_t len, bool is_stdout) {
#if LLDB_ENABLE_LIBEDIT
- if (m_editline_up)
- m_editline_up->PrintAsync(stream, s, len);
- else
+ if (m_editline_up) {
+ std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
+ lldb::StreamFileSP stream = is_stdout ? m_output_sp : m_error_sp;
+ m_editline_up->PrintAsync(stream.get(), s, len);
+ } else
#endif
{
#ifdef _WIN32
@@ -628,11 +640,10 @@ void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
SetConsoleCursorPosition(console_handle, coord);
}
#endif
- IOHandler::PrintAsync(stream, s, len);
+ IOHandler::PrintAsync(s, len, is_stdout);
#ifdef _WIN32
if (prompt)
- IOHandler::PrintAsync(GetOutputStreamFileSP().get(), prompt,
- strlen(prompt));
+ IOHandler::PrintAsync(prompt, strlen(prompt), is_stdout);
#endif
}
}
diff --git a/contrib/llvm-project/lldb/source/Core/IOHandlerCursesGUI.cpp b/contrib/llvm-project/lldb/source/Core/IOHandlerCursesGUI.cpp
index b37e84a13c5e..0151255631bf 100644
--- a/contrib/llvm-project/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/contrib/llvm-project/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -28,6 +28,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectUpdater.h"
#include "lldb/Host/File.h"
+#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
@@ -341,7 +342,7 @@ public:
protected:
StringList m_text;
- int m_first_visible_line;
+ int m_first_visible_line = 0;
};
// A surface is an abstraction for something than can be drawn on. The surface
@@ -352,7 +353,7 @@ class Surface {
public:
enum class Type { Window, Pad };
- Surface(Surface::Type type) : m_type(type), m_window(nullptr) {}
+ Surface(Surface::Type type) : m_type(type) {}
WINDOW *get() { return m_window; }
@@ -495,7 +496,7 @@ public:
if (use_blue_background)
::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
while (!string.empty()) {
- size_t esc_pos = string.find('\x1b');
+ size_t esc_pos = string.find(ANSI_ESC_START);
if (esc_pos == StringRef::npos) {
string = string.substr(skip_first_count);
if (!string.empty()) {
@@ -517,36 +518,36 @@ public:
string = string.drop_front(esc_pos);
}
}
- bool consumed = string.consume_front("\x1b");
+ bool consumed = string.consume_front(ANSI_ESC_START);
assert(consumed);
UNUSED_IF_ASSERT_DISABLED(consumed);
// This is written to match our Highlighter classes, which seem to
// generate only foreground color escape sequences. If necessary, this
// will need to be extended.
- if (!string.consume_front("[")) {
- llvm::errs() << "Missing '[' in color escape sequence.\n";
- continue;
- }
- // Only 8 basic foreground colors and reset, our Highlighter doesn't use
- // anything else.
+ // Only 8 basic foreground colors, underline and reset, our Highlighter
+ // doesn't use anything else.
int value;
if (!!string.consumeInteger(10, value) || // Returns false on success.
- !(value == 0 || (value >= 30 && value <= 37))) {
+ !(value == 0 || value == ANSI_CTRL_UNDERLINE ||
+ (value >= ANSI_FG_COLOR_BLACK && value <= ANSI_FG_COLOR_WHITE))) {
llvm::errs() << "No valid color code in color escape sequence.\n";
continue;
}
- if (!string.consume_front("m")) {
- llvm::errs() << "Missing 'm' in color escape sequence.\n";
+ if (!string.consume_front(ANSI_ESC_END)) {
+ llvm::errs() << "Missing '" << ANSI_ESC_END
+ << "' in color escape sequence.\n";
continue;
}
if (value == 0) { // Reset.
wattr_set(m_window, saved_attr, saved_pair, nullptr);
if (use_blue_background)
::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
+ } else if (value == ANSI_CTRL_UNDERLINE) {
+ ::wattron(m_window, A_UNDERLINE);
} else {
// Mapped directly to first 16 color pairs (black/blue background).
- ::wattron(m_window,
- COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
+ ::wattron(m_window, COLOR_PAIR(value - ANSI_FG_COLOR_BLACK + 1 +
+ (use_blue_background ? 8 : 0)));
}
}
wattr_set(m_window, saved_attr, saved_pair, nullptr);
@@ -555,7 +556,7 @@ public:
protected:
Type m_type;
- WINDOW *m_window;
+ WINDOW *m_window = nullptr;
};
class Pad : public Surface {
@@ -1076,8 +1077,7 @@ typedef std::unique_ptr<FieldDelegate> FieldDelegateUP;
class TextFieldDelegate : public FieldDelegate {
public:
TextFieldDelegate(const char *label, const char *content, bool required)
- : m_label(label), m_required(required), m_cursor_position(0),
- m_first_visibile_char(0) {
+ : m_label(label), m_required(required) {
if (content)
m_content = content;
}
@@ -1325,9 +1325,9 @@ protected:
std::string m_content;
// The cursor position in the content string itself. Can be in the range
// [0, GetContentLength()].
- int m_cursor_position;
+ int m_cursor_position = 0;
// The index of the first visible character in the content.
- int m_first_visibile_char;
+ int m_first_visibile_char = 0;
// Optional error message. If empty, field is considered to have no error.
std::string m_error;
};
@@ -1515,7 +1515,7 @@ public:
ChoicesFieldDelegate(const char *label, int number_of_visible_choices,
std::vector<std::string> choices)
: m_label(label), m_number_of_visible_choices(number_of_visible_choices),
- m_choices(choices), m_choice(0), m_first_visibile_choice(0) {}
+ m_choices(choices) {}
// Choices fields are drawn as titles boxses of a number of visible choices.
// The rest of the choices become visible as the user scroll. The selected
@@ -1609,7 +1609,7 @@ public:
// Returns the index of the choice.
int GetChoice() { return m_choice; }
- void SetChoice(const std::string &choice) {
+ void SetChoice(llvm::StringRef choice) {
for (int i = 0; i < GetNumberOfChoices(); i++) {
if (choice == m_choices[i]) {
m_choice = i;
@@ -1623,9 +1623,9 @@ protected:
int m_number_of_visible_choices;
std::vector<std::string> m_choices;
// The index of the selected choice.
- int m_choice;
+ int m_choice = 0;
// The index of the first visible choice in the field.
- int m_first_visibile_choice;
+ int m_first_visibile_choice = 0;
};
class PlatformPluginFieldDelegate : public ChoicesFieldDelegate {
@@ -1634,7 +1634,7 @@ public:
: ChoicesFieldDelegate("Platform Plugin", 3, GetPossiblePluginNames()) {
PlatformSP platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
if (platform_sp)
- SetChoice(platform_sp->GetName().AsCString());
+ SetChoice(platform_sp->GetPluginName());
}
std::vector<std::string> GetPossiblePluginNames() {
@@ -1707,7 +1707,7 @@ public:
template <class T> class ListFieldDelegate : public FieldDelegate {
public:
ListFieldDelegate(const char *label, T default_field)
- : m_label(label), m_default_field(default_field), m_selection_index(0),
+ : m_label(label), m_default_field(default_field),
m_selection_type(SelectionType::NewButton) {}
// Signify which element is selected. If a field or a remove button is
@@ -2011,7 +2011,7 @@ protected:
// created though a copy.
T m_default_field;
std::vector<T> m_fields;
- int m_selection_index;
+ int m_selection_index = 0;
// See SelectionType class enum.
SelectionType m_selection_type;
};
@@ -2283,7 +2283,7 @@ protected:
class FormDelegate {
public:
- FormDelegate() {}
+ FormDelegate() = default;
virtual ~FormDelegate() = default;
@@ -2465,9 +2465,7 @@ typedef std::shared_ptr<FormDelegate> FormDelegateSP;
class FormWindowDelegate : public WindowDelegate {
public:
- FormWindowDelegate(FormDelegateSP &delegate_sp)
- : m_delegate_sp(delegate_sp), m_selection_index(0),
- m_first_visible_line(0) {
+ FormWindowDelegate(FormDelegateSP &delegate_sp) : m_delegate_sp(delegate_sp) {
assert(m_delegate_sp->GetNumberOfActions() > 0);
if (m_delegate_sp->GetNumberOfFields() > 0)
m_selection_type = SelectionType::Field;
@@ -2856,11 +2854,11 @@ public:
protected:
FormDelegateSP m_delegate_sp;
// The index of the currently selected SelectionType.
- int m_selection_index;
+ int m_selection_index = 0;
// See SelectionType class enum.
SelectionType m_selection_type;
// The first visible line from the pad.
- int m_first_visible_line;
+ int m_first_visible_line = 0;
};
///////////////////////////
@@ -3647,7 +3645,7 @@ protected:
class SearcherDelegate {
public:
- SearcherDelegate() {}
+ SearcherDelegate() = default;
virtual ~SearcherDelegate() = default;
@@ -3670,8 +3668,7 @@ typedef std::shared_ptr<SearcherDelegate> SearcherDelegateSP;
class SearcherWindowDelegate : public WindowDelegate {
public:
SearcherWindowDelegate(SearcherDelegateSP &delegate_sp)
- : m_delegate_sp(delegate_sp), m_text_field("Search", "", false),
- m_selected_match(0), m_first_visible_match(0) {
+ : m_delegate_sp(delegate_sp), m_text_field("Search", "", false) {
;
}
@@ -3811,9 +3808,9 @@ protected:
SearcherDelegateSP m_delegate_sp;
TextFieldDelegate m_text_field;
// The index of the currently selected match.
- int m_selected_match;
+ int m_selected_match = 0;
// The index of the first visible match.
- int m_first_visible_match;
+ int m_first_visible_match = 0;
};
//////////////////////////////
@@ -4266,8 +4263,7 @@ HandleCharResult Menu::WindowDelegateHandleChar(Window &window, int key) {
class Application {
public:
- Application(FILE *in, FILE *out)
- : m_window_sp(), m_screen(nullptr), m_in(in), m_out(out) {}
+ Application(FILE *in, FILE *out) : m_window_sp(), m_in(in), m_out(out) {}
~Application() {
m_window_delegates.clear();
@@ -4475,7 +4471,7 @@ public:
protected:
WindowSP m_window_sp;
WindowDelegates m_window_delegates;
- SCREEN *m_screen;
+ SCREEN *m_screen = nullptr;
FILE *m_in;
FILE *m_out;
bool m_update_screen = false;
@@ -4541,7 +4537,8 @@ struct Row {
if (parent)
parent->DrawTreeForChild(window, this, 0);
- if (might_have_children) {
+ if (might_have_children &&
+ (!calculated_children || !GetChildren().empty())) {
// It we can get UTF8 characters to work we should try to use the
// "symbol" UTF8 string below
// const char *symbol = "";
@@ -4619,9 +4616,8 @@ typedef std::shared_ptr<TreeDelegate> TreeDelegateSP;
class TreeItem {
public:
TreeItem(TreeItem *parent, TreeDelegate &delegate, bool might_have_children)
- : m_parent(parent), m_delegate(delegate), m_user_data(nullptr),
- m_identifier(0), m_row_idx(-1), m_children(),
- m_might_have_children(might_have_children), m_is_expanded(false) {
+ : m_parent(parent), m_delegate(delegate), m_children(),
+ m_might_have_children(might_have_children) {
if (m_parent == nullptr)
m_is_expanded = m_delegate.TreeDelegateExpandRootByDefault();
}
@@ -4816,23 +4812,21 @@ public:
protected:
TreeItem *m_parent;
TreeDelegate &m_delegate;
- void *m_user_data;
- uint64_t m_identifier;
+ void *m_user_data = nullptr;
+ uint64_t m_identifier = 0;
std::string m_text;
- int m_row_idx; // Zero based visible row index, -1 if not visible or for the
- // root item
+ int m_row_idx = -1; // Zero based visible row index, -1 if not visible or for
+ // the root item
std::vector<TreeItem> m_children;
bool m_might_have_children;
- bool m_is_expanded;
+ bool m_is_expanded = false;
};
class TreeWindowDelegate : public WindowDelegate {
public:
TreeWindowDelegate(Debugger &debugger, const TreeDelegateSP &delegate_sp)
: m_debugger(debugger), m_delegate_sp(delegate_sp),
- m_root(nullptr, *delegate_sp, true), m_selected_item(nullptr),
- m_num_rows(0), m_selected_row_idx(0), m_first_visible_row(0),
- m_min_x(0), m_min_y(0), m_max_x(0), m_max_y(0) {}
+ m_root(nullptr, *delegate_sp, true) {}
int NumVisibleRows() const { return m_max_y - m_min_y; }
@@ -4992,14 +4986,14 @@ protected:
Debugger &m_debugger;
TreeDelegateSP m_delegate_sp;
TreeItem m_root;
- TreeItem *m_selected_item;
- int m_num_rows;
- int m_selected_row_idx;
- int m_first_visible_row;
- int m_min_x;
- int m_min_y;
- int m_max_x;
- int m_max_y;
+ TreeItem *m_selected_item = nullptr;
+ int m_num_rows = 0;
+ int m_selected_row_idx = 0;
+ int m_first_visible_row = 0;
+ int m_min_x = 0;
+ int m_min_y = 0;
+ int m_max_x = 0;
+ int m_max_y = 0;
};
// A tree delegate that just draws the text member of the tree item, it doesn't
@@ -5023,8 +5017,7 @@ class FrameTreeDelegate : public TreeDelegate {
public:
FrameTreeDelegate() : TreeDelegate() {
FormatEntity::Parse(
- "frame #${frame.index}: {${function.name}${function.pc-offset}}}",
- m_format);
+ "#${frame.index}: {${function.name}${function.pc-offset}}}", m_format);
}
~FrameTreeDelegate() override = default;
@@ -5071,8 +5064,7 @@ protected:
class ThreadTreeDelegate : public TreeDelegate {
public:
ThreadTreeDelegate(Debugger &debugger)
- : TreeDelegate(), m_debugger(debugger), m_tid(LLDB_INVALID_THREAD_ID),
- m_stop_id(UINT32_MAX) {
+ : TreeDelegate(), m_debugger(debugger) {
FormatEntity::Parse("thread #${thread.index}: tid = ${thread.id}{, stop "
"reason = ${thread.stop-reason}}",
m_format);
@@ -5161,16 +5153,15 @@ public:
protected:
Debugger &m_debugger;
std::shared_ptr<FrameTreeDelegate> m_frame_delegate_sp;
- lldb::user_id_t m_tid;
- uint32_t m_stop_id;
+ lldb::user_id_t m_tid = LLDB_INVALID_THREAD_ID;
+ uint32_t m_stop_id = UINT32_MAX;
FormatEntity::Entry m_format;
};
class ThreadsTreeDelegate : public TreeDelegate {
public:
ThreadsTreeDelegate(Debugger &debugger)
- : TreeDelegate(), m_thread_delegate_sp(), m_debugger(debugger),
- m_stop_id(UINT32_MAX), m_update_selection(false) {
+ : TreeDelegate(), m_thread_delegate_sp(), m_debugger(debugger) {
FormatEntity::Parse("process ${process.id}{, name = ${process.name}}",
m_format);
}
@@ -5280,8 +5271,8 @@ public:
protected:
std::shared_ptr<ThreadTreeDelegate> m_thread_delegate_sp;
Debugger &m_debugger;
- uint32_t m_stop_id;
- bool m_update_selection;
+ uint32_t m_stop_id = UINT32_MAX;
+ bool m_update_selection = false;
FormatEntity::Entry m_format;
};
@@ -5523,9 +5514,7 @@ class ValueObjectListDelegate : public WindowDelegate {
public:
ValueObjectListDelegate() : m_rows() {}
- ValueObjectListDelegate(ValueObjectList &valobj_list)
- : m_rows(), m_selected_row(nullptr), m_selected_row_idx(0),
- m_first_visible_row(0), m_num_rows(0), m_max_x(0), m_max_y(0) {
+ ValueObjectListDelegate(ValueObjectList &valobj_list) : m_rows() {
SetValues(valobj_list);
}
@@ -5836,9 +5825,11 @@ protected:
++m_num_rows;
}
- auto &children = row.GetChildren();
- if (row.expanded && !children.empty()) {
- DisplayRows(window, children, options);
+ if (row.expanded) {
+ auto &children = row.GetChildren();
+ if (!children.empty()) {
+ DisplayRows(window, children, options);
+ }
}
}
}
@@ -5859,11 +5850,13 @@ protected:
return &row;
else {
--row_index;
- auto &children = row.GetChildren();
- if (row.expanded && !children.empty()) {
- Row *result = GetRowForRowIndexImpl(children, row_index);
- if (result)
- return result;
+ if (row.expanded) {
+ auto &children = row.GetChildren();
+ if (!children.empty()) {
+ Row *result = GetRowForRowIndexImpl(children, row_index);
+ if (result)
+ return result;
+ }
}
}
}
@@ -5882,8 +5875,7 @@ protected:
class FrameVariablesWindowDelegate : public ValueObjectListDelegate {
public:
FrameVariablesWindowDelegate(Debugger &debugger)
- : ValueObjectListDelegate(), m_debugger(debugger),
- m_frame_block(nullptr) {}
+ : ValueObjectListDelegate(), m_debugger(debugger) {}
~FrameVariablesWindowDelegate() override = default;
@@ -5944,7 +5936,7 @@ public:
protected:
Debugger &m_debugger;
- Block *m_frame_block;
+ Block *m_frame_block = nullptr;
};
class RegistersWindowDelegate : public ValueObjectListDelegate {
@@ -6198,7 +6190,7 @@ static const char *CursesKeyToCString(int ch) {
HelpDialogDelegate::HelpDialogDelegate(const char *text,
KeyHelp *key_help_array)
- : m_text(), m_first_visible_line(0) {
+ : m_text() {
if (text && text[0]) {
m_text.SplitIntoLines(text);
m_text.AppendString("");
@@ -6415,8 +6407,11 @@ public:
if (exe_ctx.HasThreadScope()) {
Process *process = exe_ctx.GetProcessPtr();
if (process && process->IsAlive() &&
- StateIsStoppedState(process->GetState(), true))
- exe_ctx.GetThreadRef().StepOut();
+ StateIsStoppedState(process->GetState(), true)) {
+ Thread *thread = exe_ctx.GetThreadPtr();
+ uint32_t frame_idx = thread->GetSelectedFrameIndex();
+ exe_ctx.GetThreadRef().StepOut(frame_idx);
+ }
}
}
return MenuActionResult::Handled;
@@ -6762,11 +6757,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
public:
SourceFileWindowDelegate(Debugger &debugger)
: WindowDelegate(), m_debugger(debugger), m_sc(), m_file_sp(),
- m_disassembly_scope(nullptr), m_disassembly_sp(), m_disassembly_range(),
- m_title(), m_tid(LLDB_INVALID_THREAD_ID), m_line_width(4),
- m_selected_line(0), m_pc_line(0), m_stop_id(0), m_frame_idx(UINT32_MAX),
- m_first_visible_line(0), m_first_visible_column(0), m_min_x(0),
- m_min_y(0), m_max_x(0), m_max_y(0) {}
+ m_disassembly_sp(), m_disassembly_range(), m_title() {}
~SourceFileWindowDelegate() override = default;
@@ -6994,9 +6985,6 @@ public:
}
}
- const attr_t selected_highlight_attr = A_REVERSE;
- const attr_t pc_highlight_attr = COLOR_PAIR(BlackOnBlue);
-
for (size_t i = 0; i < num_visible_lines; ++i) {
const uint32_t curr_line = m_first_visible_line + i;
if (curr_line < num_source_lines) {
@@ -7004,14 +6992,13 @@ public:
window.MoveCursor(1, line_y);
const bool is_pc_line = curr_line == m_pc_line;
const bool line_is_selected = m_selected_line == curr_line;
- // Highlight the line as the PC line first, then if the selected
- // line isn't the same as the PC line, highlight it differently
+ // Highlight the line as the PC line first (done by passing
+ // argument to OutputColoredStringTruncated()), then if the selected
+ // line isn't the same as the PC line, highlight it differently.
attr_t highlight_attr = 0;
attr_t bp_attr = 0;
- if (is_pc_line)
- highlight_attr = pc_highlight_attr;
- else if (line_is_selected)
- highlight_attr = selected_highlight_attr;
+ if (line_is_selected && !is_pc_line)
+ highlight_attr = A_REVERSE;
if (bp_lines.find(curr_line + 1) != bp_lines.end())
bp_attr = COLOR_PAIR(BlackOnWhite);
@@ -7035,14 +7022,19 @@ public:
window.AttributeOn(highlight_attr);
StreamString lineStream;
- m_file_sp->DisplaySourceLines(curr_line + 1, {}, 0, 0, &lineStream);
+
+ llvm::Optional<size_t> column;
+ if (is_pc_line && m_sc.line_entry.IsValid() && m_sc.line_entry.column)
+ column = m_sc.line_entry.column - 1;
+ m_file_sp->DisplaySourceLines(curr_line + 1, column, 0, 0,
+ &lineStream);
StringRef line = lineStream.GetString();
if (line.endswith("\n"))
line = line.drop_back();
bool wasWritten = window.OutputColoredStringTruncated(
- 1, line, m_first_visible_column, line_is_selected);
- if (line_is_selected && !wasWritten) {
- // Draw an empty space to show the selected line if empty,
+ 1, line, m_first_visible_column, is_pc_line);
+ if (!wasWritten && (line_is_selected || is_pc_line)) {
+ // Draw an empty space to show the selected/PC line if empty,
// or draw '<' if nothing is visible because of scrolling too much
// to the right.
window.PutCStringTruncated(
@@ -7377,7 +7369,9 @@ public:
m_debugger.GetCommandInterpreter().GetExecutionContext();
if (exe_ctx.HasThreadScope() &&
StateIsStoppedState(exe_ctx.GetProcessRef().GetState(), true)) {
- exe_ctx.GetThreadRef().StepOut();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ uint32_t frame_idx = thread->GetSelectedFrameIndex();
+ exe_ctx.GetThreadRef().StepOut(frame_idx);
}
}
return eKeyHandled;
@@ -7524,22 +7518,22 @@ protected:
Debugger &m_debugger;
SymbolContext m_sc;
SourceManager::FileSP m_file_sp;
- SymbolContextScope *m_disassembly_scope;
+ SymbolContextScope *m_disassembly_scope = nullptr;
lldb::DisassemblerSP m_disassembly_sp;
AddressRange m_disassembly_range;
StreamString m_title;
- lldb::user_id_t m_tid;
- int m_line_width;
- uint32_t m_selected_line; // The selected line
- uint32_t m_pc_line; // The line with the PC
- uint32_t m_stop_id;
- uint32_t m_frame_idx;
- int m_first_visible_line;
- int m_first_visible_column;
- int m_min_x;
- int m_min_y;
- int m_max_x;
- int m_max_y;
+ lldb::user_id_t m_tid = LLDB_INVALID_THREAD_ID;
+ int m_line_width = 4;
+ uint32_t m_selected_line = 0; // The selected line
+ uint32_t m_pc_line = 0; // The line with the PC
+ uint32_t m_stop_id = 0;
+ uint32_t m_frame_idx = UINT32_MAX;
+ int m_first_visible_line = 0;
+ int m_first_visible_column = 0;
+ int m_min_x = 0;
+ int m_min_y = 0;
+ int m_max_x = 0;
+ int m_max_y = 0;
};
DisplayOptions ValueObjectListDelegate::g_options = {true};
@@ -7682,14 +7676,6 @@ void IOHandlerCursesGUI::Activate() {
status_window_sp->SetDelegate(
WindowDelegateSP(new StatusBarWindowDelegate(m_debugger)));
- // Show the main help window once the first time the curses GUI is
- // launched
- static bool g_showed_help = false;
- if (!g_showed_help) {
- g_showed_help = true;
- main_window_sp->CreateHelpSubwindow();
- }
-
// All colors with black background.
init_pair(1, COLOR_BLACK, COLOR_BLACK);
init_pair(2, COLOR_RED, COLOR_BLACK);
@@ -7729,7 +7715,9 @@ IOHandlerCursesGUI::~IOHandlerCursesGUI() = default;
void IOHandlerCursesGUI::Cancel() {}
-bool IOHandlerCursesGUI::Interrupt() { return false; }
+bool IOHandlerCursesGUI::Interrupt() {
+ return m_debugger.GetCommandInterpreter().IOHandlerInterrupt(*this);
+}
void IOHandlerCursesGUI::GotEOF() {}
diff --git a/contrib/llvm-project/lldb/source/Core/Mangled.cpp b/contrib/llvm-project/lldb/source/Core/Mangled.cpp
index b8e405544b33..0c4d9f78c440 100644
--- a/contrib/llvm-project/lldb/source/Core/Mangled.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Mangled.cpp
@@ -13,8 +13,8 @@
#include "lldb/Target/Language.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataEncoder.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-enumerations.h"
@@ -130,7 +130,7 @@ static char *GetMSVCDemangledStr(const char *M) {
llvm::MSDF_NoAccessSpecifier | llvm::MSDF_NoCallingConvention |
llvm::MSDF_NoMemberType | llvm::MSDF_NoVariableType));
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
+ if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
else
@@ -157,7 +157,7 @@ static char *GetItaniumDemangledStr(const char *M) {
"Expected demangled_size to return length including trailing null");
}
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
+ if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr)
LLDB_LOGF(log, "demangled itanium: %s -> \"%s\"", M, demangled_cstr);
else
@@ -168,9 +168,9 @@ static char *GetItaniumDemangledStr(const char *M) {
}
static char *GetRustV0DemangledStr(const char *M) {
- char *demangled_cstr = llvm::rustDemangle(M, nullptr, nullptr, nullptr);
+ char *demangled_cstr = llvm::rustDemangle(M);
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
+ if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOG(log, "demangled rustv0: {0} -> \"{1}\"", M, demangled_cstr);
else
@@ -183,7 +183,7 @@ static char *GetRustV0DemangledStr(const char *M) {
static char *GetDLangDemangledStr(const char *M) {
char *demangled_cstr = llvm::dlangDemangle(M);
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
+ if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOG(log, "demangled dlang: {0} -> \"{1}\"", M, demangled_cstr);
else
diff --git a/contrib/llvm-project/lldb/source/Core/Module.cpp b/contrib/llvm-project/lldb/source/Core/Module.cpp
index feecf984f7bf..41c21e1dc326 100644
--- a/contrib/llvm-project/lldb/source/Core/Module.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Module.cpp
@@ -39,8 +39,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
@@ -129,8 +129,7 @@ Module *Module::GetAllocatedModuleAtIndex(size_t idx) {
}
Module::Module(const ModuleSpec &module_spec)
- : m_object_offset(0), m_file_has_changed(false),
- m_first_file_changed_log(false) {
+ : m_file_has_changed(false), m_first_file_changed_log(false) {
// Scope for locker below...
{
std::lock_guard<std::recursive_mutex> guard(
@@ -138,8 +137,7 @@ Module::Module(const ModuleSpec &module_spec)
GetModuleCollection().push_back(this);
}
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
- LIBLLDB_LOG_MODULES));
+ Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules));
if (log != nullptr)
LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
static_cast<void *>(this),
@@ -251,8 +249,7 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch,
if (object_name)
m_object_name = *object_name;
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
- LIBLLDB_LOG_MODULES));
+ Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules));
if (log != nullptr)
LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
static_cast<void *>(this), m_arch.GetArchitectureName(),
@@ -281,8 +278,7 @@ Module::~Module() {
assert(pos != end);
modules.erase(pos);
}
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
- LIBLLDB_LOG_MODULES));
+ Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules));
if (log != nullptr)
LLDB_LOGF(log, "%p Module::~Module((%s) '%s%s%s%s')",
static_cast<void *>(this), m_arch.GetArchitectureName(),
@@ -308,15 +304,15 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (process_sp) {
m_did_load_objfile = true;
- auto data_up = std::make_unique<DataBufferHeap>(size_to_read, 0);
+ std::shared_ptr<DataBufferHeap> data_sp =
+ std::make_shared<DataBufferHeap>(size_to_read, 0);
Status readmem_error;
const size_t bytes_read =
- process_sp->ReadMemory(header_addr, data_up->GetBytes(),
- data_up->GetByteSize(), readmem_error);
+ process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
+ data_sp->GetByteSize(), readmem_error);
if (bytes_read < size_to_read)
- data_up->SetByteSize(bytes_read);
- if (data_up->GetByteSize() > 0) {
- DataBufferSP data_sp(data_up.release());
+ data_sp->SetByteSize(bytes_read);
+ if (data_sp->GetByteSize() > 0) {
m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
header_addr, data_sp);
if (m_objfile_sp) {
@@ -479,6 +475,7 @@ uint32_t Module::ResolveSymbolContextForAddress(
resolve_scope & eSymbolContextBlock ||
resolve_scope & eSymbolContextLineEntry ||
resolve_scope & eSymbolContextVariable) {
+ symfile->SetLoadDebugInfoEnabled();
resolved_flags |=
symfile->ResolveSymbolContext(so_addr, resolve_scope, sc);
}
@@ -639,9 +636,7 @@ void Module::FindCompileUnits(const FileSpec &path,
Module::LookupInfo::LookupInfo(ConstString name,
FunctionNameType name_type_mask,
LanguageType language)
- : m_name(name), m_lookup_name(), m_language(language),
- m_name_type_mask(eFunctionNameTypeNone),
- m_match_name_after_lookup(false) {
+ : m_name(name), m_lookup_name(), m_language(language) {
const char *name_cstr = name.GetCString();
llvm::StringRef basename;
llvm::StringRef context;
@@ -744,13 +739,25 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
while (i < sc_list.GetSize()) {
if (!sc_list.GetContextAtIndex(i, sc))
break;
- ConstString full_name(sc.GetFunctionName());
- if (full_name &&
- ::strstr(full_name.GetCString(), m_name.GetCString()) == nullptr) {
- sc_list.RemoveContextAtIndex(i);
- } else {
- ++i;
+
+ llvm::StringRef user_name = m_name.GetStringRef();
+ bool keep_it = true;
+ Language *language = Language::FindPlugin(sc.GetLanguage());
+ // If the symbol has a language, then let the language make the match.
+ // Otherwise just check that the demangled name contains the user name.
+ if (language)
+ keep_it = language->DemangledNameContainsPath(m_name.GetStringRef(),
+ sc.GetFunctionName());
+ else {
+ llvm::StringRef full_name = sc.GetFunctionName().GetStringRef();
+ // We always keep unnamed symbols:
+ if (!full_name.empty())
+ keep_it = full_name.contains(user_name);
}
+ if (keep_it)
+ ++i;
+ else
+ sc_list.RemoveContextAtIndex(i);
}
}
@@ -1028,7 +1035,9 @@ void Module::FindTypes(
llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
- LLDB_SCOPED_TIMER();
+ // If a scoped timer is needed, place it in a SymbolFile::FindTypes override.
+ // A timer here is too high volume for some cases, for example when calling
+ // FindTypes on each object file.
if (SymbolFile *symbols = GetSymbolFile())
symbols->FindTypes(pattern, languages, searched_symbol_files, types);
}
@@ -1098,27 +1107,6 @@ void Module::GetDescription(llvm::raw_ostream &s,
s << llvm::formatv("({0})", object_name);
}
-void Module::ReportError(const char *format, ...) {
- if (format && format[0]) {
- StreamString strm;
- strm.PutCString("error: ");
- GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
- strm.PutChar(' ');
- va_list args;
- va_start(args, format);
- strm.PrintfVarArg(format, args);
- va_end(args);
-
- const int format_len = strlen(format);
- if (format_len > 0) {
- const char last_char = format[format_len - 1];
- if (last_char != '\n' && last_char != '\r')
- strm.EOL();
- }
- Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData());
- }
-}
-
bool Module::FileHasChanged() const {
// We have provided the DataBuffer for this module to avoid accessing the
// filesystem. We never want to reload those files.
@@ -1130,13 +1118,38 @@ bool Module::FileHasChanged() const {
return m_file_has_changed;
}
+void Module::ReportWarningOptimization(
+ llvm::Optional<lldb::user_id_t> debugger_id) {
+ ConstString file_name = GetFileSpec().GetFilename();
+ if (file_name.IsEmpty())
+ return;
+
+ StreamString ss;
+ ss << file_name.GetStringRef()
+ << " was compiled with optimization - stepping may behave "
+ "oddly; variables may not be available.";
+ Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
+ &m_optimization_warning);
+}
+
+void Module::ReportWarningUnsupportedLanguage(
+ LanguageType language, llvm::Optional<lldb::user_id_t> debugger_id) {
+ StreamString ss;
+ ss << "This version of LLDB has no plugin for the language \""
+ << Language::GetNameForLanguageType(language)
+ << "\". "
+ "Inspection of frame variables will be limited.";
+ Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
+ &m_language_warning);
+}
+
void Module::ReportErrorIfModifyDetected(const char *format, ...) {
if (!m_first_file_changed_log) {
if (FileHasChanged()) {
m_first_file_changed_log = true;
if (format) {
StreamString strm;
- strm.PutCString("error: the object file ");
+ strm.PutCString("the object file ");
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
strm.PutCString(" has been modified\n");
@@ -1152,17 +1165,31 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) {
strm.EOL();
}
strm.PutCString("The debug session should be aborted as the original "
- "debug information has been overwritten.\n");
- Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData());
+ "debug information has been overwritten.");
+ Debugger::ReportError(std::string(strm.GetString()));
}
}
}
}
+void Module::ReportError(const char *format, ...) {
+ if (format && format[0]) {
+ StreamString strm;
+ GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
+ strm.PutChar(' ');
+
+ va_list args;
+ va_start(args, format);
+ strm.PrintfVarArg(format, args);
+ va_end(args);
+
+ Debugger::ReportError(std::string(strm.GetString()));
+ }
+}
+
void Module::ReportWarning(const char *format, ...) {
if (format && format[0]) {
StreamString strm;
- strm.PutCString("warning: ");
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
strm.PutChar(' ');
@@ -1171,13 +1198,7 @@ void Module::ReportWarning(const char *format, ...) {
strm.PrintfVarArg(format, args);
va_end(args);
- const int format_len = strlen(format);
- if (format_len > 0) {
- const char last_char = format[format_len - 1];
- if (last_char != '\n' && last_char != '\r')
- strm.EOL();
- }
- Host::SystemLog(Host::eSystemLogWarning, "%s", strm.GetData());
+ Debugger::ReportWarning(std::string(strm.GetString()));
}
}
@@ -1384,7 +1405,6 @@ void Module::PreloadSymbols() {
// Now let the symbol file preload its data and the symbol table will be
// available without needing to take the module lock.
sym_file->PreloadSymbols();
-
}
void Module::SetSymbolFileFileSpec(const FileSpec &file) {
@@ -1629,7 +1649,7 @@ void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
bool Module::MergeArchitecture(const ArchSpec &arch_spec) {
if (!arch_spec.IsValid())
return false;
- LLDB_LOGF(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES),
+ LLDB_LOGF(GetLog(LLDBLog::Object | LLDBLog::Modules),
"module has arch %s, merging/replacing with arch %s",
m_arch.GetTriple().getTriple().c_str(),
arch_spec.GetTriple().getTriple().c_str());
@@ -1690,6 +1710,9 @@ DataFileCache *Module::GetIndexCache() {
return nullptr;
// NOTE: intentional leak so we don't crash if global destructor chain gets
// called as other threads still use the result of this function
- static DataFileCache *g_data_file_cache = new DataFileCache(ModuleList::GetGlobalModuleListProperties().GetLLDBIndexCachePath().GetPath());
+ static DataFileCache *g_data_file_cache =
+ new DataFileCache(ModuleList::GetGlobalModuleListProperties()
+ .GetLLDBIndexCachePath()
+ .GetPath());
return g_data_file_cache;
}
diff --git a/contrib/llvm-project/lldb/source/Core/ModuleList.cpp b/contrib/llvm-project/lldb/source/Core/ModuleList.cpp
index 48412137546d..1692a3710a3d 100644
--- a/contrib/llvm-project/lldb/source/Core/ModuleList.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ModuleList.cpp
@@ -22,8 +22,8 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/UUID.h"
#include "lldb/lldb-defines.h"
@@ -180,10 +180,15 @@ PathMappingList ModuleListProperties::GetSymlinkMappings() const {
return m_symlink_paths;
}
+bool ModuleListProperties::GetLoadSymbolOnDemand() {
+ const uint32_t idx = ePropertyLoadSymbolOnDemand;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
+}
+
ModuleList::ModuleList() : m_modules(), m_modules_mutex() {}
-ModuleList::ModuleList(const ModuleList &rhs)
- : m_modules(), m_modules_mutex(), m_notifier(nullptr) {
+ModuleList::ModuleList(const ModuleList &rhs) : m_modules(), m_modules_mutex() {
std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
@@ -807,7 +812,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
if (old_modules)
old_modules->push_back(module_sp);
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
+ Log *log = GetLog(LLDBLog::Modules);
if (log != nullptr)
LLDB_LOGF(
log, "%p '%s' module changed: removing from global module list",
diff --git a/contrib/llvm-project/lldb/source/Core/PluginManager.cpp b/contrib/llvm-project/lldb/source/Core/PluginManager.cpp
index 37050494aa2e..38a9573411f4 100644
--- a/contrib/llvm-project/lldb/source/Core/PluginManager.cpp
+++ b/contrib/llvm-project/lldb/source/Core/PluginManager.cpp
@@ -621,9 +621,10 @@ struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> {
CallbackType create_callback,
ObjectFileCreateMemoryInstance create_memory_callback,
ObjectFileGetModuleSpecifications get_module_specifications,
- ObjectFileSaveCore save_core)
- : PluginInstance<ObjectFileCreateInstance>(name, description,
- create_callback),
+ ObjectFileSaveCore save_core,
+ DebuggerInitializeCallback debugger_init_callback)
+ : PluginInstance<ObjectFileCreateInstance>(
+ name, description, create_callback, debugger_init_callback),
create_memory_callback(create_memory_callback),
get_module_specifications(get_module_specifications),
save_core(save_core) {}
@@ -644,10 +645,11 @@ bool PluginManager::RegisterPlugin(
ObjectFileCreateInstance create_callback,
ObjectFileCreateMemoryInstance create_memory_callback,
ObjectFileGetModuleSpecifications get_module_specifications,
- ObjectFileSaveCore save_core) {
+ ObjectFileSaveCore save_core,
+ DebuggerInitializeCallback debugger_init_callback) {
return GetObjectFileInstances().RegisterPlugin(
name, description, create_callback, create_memory_callback,
- get_module_specifications, save_core);
+ get_module_specifications, save_core, debugger_init_callback);
}
bool PluginManager::UnregisterPlugin(ObjectFileCreateInstance create_callback) {
@@ -1031,14 +1033,14 @@ PluginManager::GetSymbolVendorCreateCallbackAtIndex(uint32_t idx) {
#pragma mark Trace
struct TraceInstance
- : public PluginInstance<TraceCreateInstanceForSessionFile> {
+ : public PluginInstance<TraceCreateInstanceFromBundle> {
TraceInstance(
llvm::StringRef name, llvm::StringRef description,
- CallbackType create_callback_for_session_file,
+ CallbackType create_callback_from_bundle,
TraceCreateInstanceForLiveProcess create_callback_for_live_process,
llvm::StringRef schema)
- : PluginInstance<TraceCreateInstanceForSessionFile>(
- name, description, create_callback_for_session_file),
+ : PluginInstance<TraceCreateInstanceFromBundle>(
+ name, description, create_callback_from_bundle),
schema(schema),
create_callback_for_live_process(create_callback_for_live_process) {}
@@ -1055,21 +1057,21 @@ static TraceInstances &GetTracePluginInstances() {
bool PluginManager::RegisterPlugin(
llvm::StringRef name, llvm::StringRef description,
- TraceCreateInstanceForSessionFile create_callback_for_session_file,
+ TraceCreateInstanceFromBundle create_callback_from_bundle,
TraceCreateInstanceForLiveProcess create_callback_for_live_process,
llvm::StringRef schema) {
return GetTracePluginInstances().RegisterPlugin(
- name, description, create_callback_for_session_file,
+ name, description, create_callback_from_bundle,
create_callback_for_live_process, schema);
}
bool PluginManager::UnregisterPlugin(
- TraceCreateInstanceForSessionFile create_callback_for_session_file) {
+ TraceCreateInstanceFromBundle create_callback_from_bundle) {
return GetTracePluginInstances().UnregisterPlugin(
- create_callback_for_session_file);
+ create_callback_from_bundle);
}
-TraceCreateInstanceForSessionFile
+TraceCreateInstanceFromBundle
PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
return GetTracePluginInstances().GetCallbackForName(plugin_name);
}
@@ -1364,6 +1366,7 @@ LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
void PluginManager::DebuggerInitialize(Debugger &debugger) {
GetDynamicLoaderInstances().PerformDebuggerCallback(debugger);
GetJITLoaderInstances().PerformDebuggerCallback(debugger);
+ GetObjectFileInstances().PerformDebuggerCallback(debugger);
GetPlatformInstances().PerformDebuggerCallback(debugger);
GetProcessInstances().PerformDebuggerCallback(debugger);
GetSymbolFileInstances().PerformDebuggerCallback(debugger);
@@ -1490,6 +1493,7 @@ CreateSettingForPlugin(Debugger &debugger, ConstString plugin_type_name,
static const char *kDynamicLoaderPluginName("dynamic-loader");
static const char *kPlatformPluginName("platform");
static const char *kProcessPluginName("process");
+static const char *kObjectFilePluginName("object-file");
static const char *kSymbolFilePluginName("symbol-file");
static const char *kJITLoaderPluginName("jit-loader");
static const char *kStructuredDataPluginName("structured-data");
@@ -1543,6 +1547,22 @@ bool PluginManager::CreateSettingForProcessPlugin(
}
lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForObjectFilePlugin(Debugger &debugger,
+ ConstString setting_name) {
+ return GetSettingForPlugin(debugger, setting_name,
+ ConstString(kObjectFilePluginName));
+}
+
+bool PluginManager::CreateSettingForObjectFilePlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ ConstString description, bool is_global_property) {
+ return CreateSettingForPlugin(
+ debugger, ConstString(kObjectFilePluginName),
+ ConstString("Settings for object file plug-ins"), properties_sp,
+ description, is_global_property);
+}
+
+lldb::OptionValuePropertiesSP
PluginManager::GetSettingForSymbolFilePlugin(Debugger &debugger,
ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
diff --git a/contrib/llvm-project/lldb/source/Core/RichManglingContext.cpp b/contrib/llvm-project/lldb/source/Core/RichManglingContext.cpp
index cecb5c6a2e54..64b18b401f2d 100644
--- a/contrib/llvm-project/lldb/source/Core/RichManglingContext.cpp
+++ b/contrib/llvm-project/lldb/source/Core/RichManglingContext.cpp
@@ -7,11 +7,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/RichManglingContext.h"
-
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
-
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "lldb/Utility/LLDBLog.h"
#include "llvm/ADT/StringRef.h"
@@ -47,7 +44,7 @@ bool RichManglingContext::FromItaniumName(ConstString mangled) {
ResetProvider(ItaniumPartialDemangler);
}
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
+ if (Log *log = GetLog(LLDBLog::Demangle)) {
if (!err) {
ParseFullName();
LLDB_LOG(log, "demangled itanium: {0} -> \"{1}\"", mangled, m_ipd_buf);
@@ -103,7 +100,7 @@ llvm::StringRef RichManglingContext::processIPDStrResult(char *ipd_res,
m_ipd_buf = ipd_res; // std::realloc freed or reused the old buffer.
m_ipd_buf_size = res_size; // May actually be bigger, but we can't know.
- if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE))
+ if (Log *log = GetLog(LLDBLog::Demangle))
LLDB_LOG(log, "ItaniumPartialDemangler Realloc: new buffer size is {0}",
m_ipd_buf_size);
}
@@ -126,6 +123,7 @@ llvm::StringRef RichManglingContext::ParseFunctionBaseName() {
case None:
return {};
}
+ llvm_unreachable("Fully covered switch above!");
}
llvm::StringRef RichManglingContext::ParseFunctionDeclContextName() {
@@ -142,6 +140,7 @@ llvm::StringRef RichManglingContext::ParseFunctionDeclContextName() {
case None:
return {};
}
+ llvm_unreachable("Fully covered switch above!");
}
llvm::StringRef RichManglingContext::ParseFullName() {
@@ -159,4 +158,5 @@ llvm::StringRef RichManglingContext::ParseFullName() {
case None:
return {};
}
+ llvm_unreachable("Fully covered switch above!");
}
diff --git a/contrib/llvm-project/lldb/source/Core/Section.cpp b/contrib/llvm-project/lldb/source/Core/Section.cpp
index 1660e3c92f2c..50c1562f7561 100644
--- a/contrib/llvm-project/lldb/source/Core/Section.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Section.cpp
@@ -164,12 +164,6 @@ Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
m_thread_specific(false), m_readable(false), m_writable(false),
m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
- // 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",
- // this, module_sp.get(), sect_id, file_addr, file_addr +
- // byte_size, file_offset, file_offset + file_size, flags,
- // name.GetCString());
}
Section::Section(const lldb::SectionSP &parent_section_sp,
@@ -186,19 +180,11 @@ Section::Section(const lldb::SectionSP &parent_section_sp,
m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
m_thread_specific(false), m_readable(false), m_writable(false),
m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
- // 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",
- // 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;
}
-Section::~Section() {
- // printf ("Section::~Section(%p)\n", this);
-}
+Section::~Section() = default;
addr_t Section::GetFileAddress() const {
SectionSP parent_sp(GetParent());
@@ -423,9 +409,15 @@ bool Section::ContainsOnlyDebugInfo() const {
case eSectionTypeGoSymtab:
case eSectionTypeAbsoluteAddress:
case eSectionTypeOther:
+ // Used for "__dof_cache" in mach-o or ".debug" for COFF which isn't debug
+ // information that we parse at all. This was causing system files with no
+ // debug info to show debug info byte sizes in the "statistics dump" output
+ // for each module. New "eSectionType" enums should be created for dedicated
+ // debug info that has a predefined format if we wish for these sections to
+ // show up as debug info.
+ case eSectionTypeDebug:
return false;
- case eSectionTypeDebug:
case eSectionTypeDWARFDebugAbbrev:
case eSectionTypeDWARFDebugAbbrevDwo:
case eSectionTypeDWARFDebugAddr:
diff --git a/contrib/llvm-project/lldb/source/Core/SourceLocationSpec.cpp b/contrib/llvm-project/lldb/source/Core/SourceLocationSpec.cpp
index 610754bb187c..c83d2d89370d 100644
--- a/contrib/llvm-project/lldb/source/Core/SourceLocationSpec.cpp
+++ b/contrib/llvm-project/lldb/source/Core/SourceLocationSpec.cpp
@@ -16,7 +16,7 @@ SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line,
llvm::Optional<uint16_t> column,
bool check_inlines, bool exact_match)
: m_declaration(file_spec, line,
- column.getValueOr(LLDB_INVALID_COLUMN_NUMBER)),
+ column.value_or(LLDB_INVALID_COLUMN_NUMBER)),
m_check_inlines(check_inlines), m_exact_match(exact_match) {}
SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
diff --git a/contrib/llvm-project/lldb/source/Core/SourceManager.cpp b/contrib/llvm-project/lldb/source/Core/SourceManager.cpp
index effba485f026..0e2157f377e0 100644
--- a/contrib/llvm-project/lldb/source/Core/SourceManager.cpp
+++ b/contrib/llvm-project/lldb/source/Core/SourceManager.cpp
@@ -25,7 +25,6 @@
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBuffer.h"
-#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-enumerations.h"
@@ -50,6 +49,14 @@ using namespace lldb_private;
static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
+static void resolve_tilde(FileSpec &file_spec) {
+ if (!FileSystem::Instance().Exists(file_spec) &&
+ file_spec.GetDirectory() &&
+ file_spec.GetDirectory().GetCString()[0] == '~') {
+ FileSystem::Instance().Resolve(file_spec);
+ }
+}
+
// SourceManager constructor
SourceManager::SourceManager(const TargetSP &target_sp)
: m_last_line(0), m_last_count(0), m_default_set(false),
@@ -67,10 +74,13 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
if (!file_spec)
return nullptr;
+ FileSpec resolved_fspec = file_spec;
+ resolve_tilde(resolved_fspec);
+
DebuggerSP debugger_sp(m_debugger_wp.lock());
FileSP file_sp;
if (debugger_sp && debugger_sp->GetUseSourceCache())
- file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
+ file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(resolved_fspec);
TargetSP target_sp(m_target_wp.lock());
@@ -88,9 +98,9 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
// If file_sp is no good or it points to a non-existent file, reset it.
if (!file_sp || !FileSystem::Instance().Exists(file_sp->GetFileSpec())) {
if (target_sp)
- file_sp = std::make_shared<File>(file_spec, target_sp.get());
+ file_sp = std::make_shared<File>(resolved_fspec, target_sp.get());
else
- file_sp = std::make_shared<File>(file_spec, debugger_sp);
+ file_sp = std::make_shared<File>(resolved_fspec, debugger_sp);
if (debugger_sp && debugger_sp->GetUseSourceCache())
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
@@ -442,6 +452,7 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
}
}
}
+ resolve_tilde(m_file_spec);
// Try remapping if m_file_spec does not correspond to an existing file.
if (!FileSystem::Instance().Exists(m_file_spec)) {
// Check target specific source remappings (i.e., the
@@ -645,7 +656,7 @@ bool SourceManager::File::CalculateLineOffsets(uint32_t line) {
if (m_data_sp.get() == nullptr)
return false;
- const char *start = (char *)m_data_sp->GetBytes();
+ const char *start = (const char *)m_data_sp->GetBytes();
if (start) {
const char *end = start + m_data_sp->GetByteSize();
@@ -695,7 +706,7 @@ bool SourceManager::File::GetLine(uint32_t line_no, std::string &buffer) {
if (end_offset == UINT32_MAX) {
end_offset = m_data_sp->GetByteSize();
}
- buffer.assign((char *)m_data_sp->GetBytes() + start_offset,
+ buffer.assign((const char *)m_data_sp->GetBytes() + start_offset,
end_offset - start_offset);
return true;
diff --git a/contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp b/contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp
index 04195a6d13ea..c2c64b61ab72 100644
--- a/contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp
+++ b/contrib/llvm-project/lldb/source/Core/StreamAsynchronousIO.cpp
@@ -14,8 +14,9 @@
using namespace lldb;
using namespace lldb_private;
-StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout)
- : Stream(0, 4, eByteOrderBig), m_debugger(debugger), m_data(),
+StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout,
+ bool colors)
+ : Stream(0, 4, eByteOrderBig, colors), m_debugger(debugger), m_data(),
m_for_stdout(for_stdout) {}
StreamAsynchronousIO::~StreamAsynchronousIO() {
diff --git a/contrib/llvm-project/lldb/source/Core/StreamFile.cpp b/contrib/llvm-project/lldb/source/Core/StreamFile.cpp
index 7753397ae0f1..8aac0b6d6306 100644
--- a/contrib/llvm-project/lldb/source/Core/StreamFile.cpp
+++ b/contrib/llvm-project/lldb/source/Core/StreamFile.cpp
@@ -8,6 +8,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include <cstdio>
@@ -37,7 +38,7 @@ StreamFile::StreamFile(const char *path, File::OpenOptions options,
m_file_sp = std::move(file.get());
else {
// TODO refactor this so the error gets popagated up instead of logged here.
- LLDB_LOG_ERROR(GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), file.takeError(),
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Host), file.takeError(),
"Cannot open {1}: {0}", path);
m_file_sp = std::make_shared<File>();
}
diff --git a/contrib/llvm-project/lldb/source/Core/Value.cpp b/contrib/llvm-project/lldb/source/Core/Value.cpp
index fb57c0fedf04..2b60dd6f00fa 100644
--- a/contrib/llvm-project/lldb/source/Core/Value.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Value.cpp
@@ -41,13 +41,10 @@ using namespace lldb_private;
Value::Value() : m_value(), m_compiler_type(), m_data_buffer() {}
Value::Value(const Scalar &scalar)
- : m_value(scalar), m_compiler_type(), m_context(nullptr),
- m_value_type(ValueType::Scalar), m_context_type(ContextType::Invalid),
- m_data_buffer() {}
+ : m_value(scalar), m_compiler_type(), m_data_buffer() {}
Value::Value(const void *bytes, int len)
- : m_value(), m_compiler_type(), m_context(nullptr),
- m_value_type(ValueType::HostAddress), m_context_type(ContextType::Invalid),
+ : m_value(), m_compiler_type(), m_value_type(ValueType::HostAddress),
m_data_buffer() {
SetBytes(bytes, len);
}
@@ -665,13 +662,6 @@ void Value::ConvertToLoadAddress(Module *module, Target *target) {
GetScalar() = load_addr;
}
-ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
-
-const ValueList &ValueList::operator=(const ValueList &rhs) {
- m_values = rhs.m_values;
- return *this;
-}
-
void ValueList::PushValue(const Value &value) { m_values.push_back(value); }
size_t ValueList::GetSize() { return m_values.size(); }
diff --git a/contrib/llvm-project/lldb/source/Core/ValueObject.cpp b/contrib/llvm-project/lldb/source/Core/ValueObject.cpp
index 6794d0c7331d..d80139ab1840 100644
--- a/contrib/llvm-project/lldb/source/Core/ValueObject.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ValueObject.cpp
@@ -42,8 +42,8 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
@@ -200,7 +200,7 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {
}
bool ValueObject::UpdateFormatsIfNeeded() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
+ Log *log = GetLog(LLDBLog::DataFormatters);
LLDB_LOGF(log,
"[%s %p] checking for FormatManager revisions. ValueObject "
"rev: %d - Global rev: %d",
@@ -265,7 +265,7 @@ CompilerType ValueObject::MaybeCalculateCompleteType() {
process_sp->GetLanguageRuntime(GetObjectRuntimeLanguage())) {
if (llvm::Optional<CompilerType> complete_type =
runtime->GetRuntimeType(compiler_type)) {
- m_override_type = complete_type.getValue();
+ m_override_type = *complete_type;
if (m_override_type.IsValid())
return m_override_type;
}
@@ -792,7 +792,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
uint64_t count = 0;
const Encoding encoding = GetCompilerType().GetEncoding(count);
- const size_t byte_size = GetByteSize().getValueOr(0);
+ const size_t byte_size = GetByteSize().value_or(0);
Value::ValueType value_type = m_value.GetValueType();
@@ -848,18 +848,18 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
}
static bool CopyStringDataToBufferSP(const StreamString &source,
- lldb::DataBufferSP &destination) {
+ lldb::WritableDataBufferSP &destination) {
llvm::StringRef src = source.GetString();
- src.consume_back(llvm::StringRef("\0", 1));
+ src = src.rtrim('\0');
destination = std::make_shared<DataBufferHeap>(src.size(), 0);
memcpy(destination->GetBytes(), src.data(), src.size());
return true;
}
std::pair<size_t, bool>
-ValueObject::ReadPointedString(lldb::DataBufferSP &buffer_sp, Status &error,
- uint32_t max_length, bool honor_array,
- Format item_format) {
+ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp,
+ Status &error, uint32_t max_length,
+ bool honor_array, Format item_format) {
bool was_capped = false;
StreamString s;
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -1184,7 +1184,7 @@ bool ValueObject::DumpPrintableRepresentation(
eFormatVectorOfChar)) // print char[] & char* directly
{
Status error;
- lldb::DataBufferSP buffer_sp;
+ lldb::WritableDataBufferSP buffer_sp;
std::pair<size_t, bool> read_string = ReadPointedString(
buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) ||
(custom_format == eFormatCharArray));
@@ -1474,7 +1474,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
uint64_t count = 0;
const Encoding encoding = GetCompilerType().GetEncoding(count);
- const size_t byte_size = GetByteSize().getValueOr(0);
+ const size_t byte_size = GetByteSize().value_or(0);
Value::ValueType value_type = m_value.GetValueType();
@@ -1656,13 +1656,13 @@ ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
uint32_t bit_field_offset = from;
if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
bit_field_offset =
- GetByteSize().getValueOr(0) * 8 - bit_field_size - bit_field_offset;
+ GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
// We haven't made a synthetic array member for INDEX yet, so lets make
// one and cache it for any future reference.
ValueObjectChild *synthetic_child = new ValueObjectChild(
- *this, GetCompilerType(), index_const_str,
- GetByteSize().getValueOr(0), 0, bit_field_size, bit_field_offset,
- false, false, eAddressTypeInvalid, 0);
+ *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
+ 0, bit_field_size, bit_field_offset, false, false,
+ eAddressTypeInvalid, 0);
// Cache the value if we got one back...
if (synthetic_child) {
@@ -2803,7 +2803,7 @@ ValueObject::EvaluationPoint::EvaluationPoint() : m_mod_id(), m_exe_ctx_ref() {}
ValueObject::EvaluationPoint::EvaluationPoint(ExecutionContextScope *exe_scope,
bool use_selected)
- : m_mod_id(), m_exe_ctx_ref(), m_needs_update(true) {
+ : m_mod_id(), m_exe_ctx_ref() {
ExecutionContext exe_ctx(exe_scope);
TargetSP target_sp(exe_ctx.GetTargetSP());
if (target_sp) {
@@ -2840,7 +2840,7 @@ ValueObject::EvaluationPoint::EvaluationPoint(ExecutionContextScope *exe_scope,
ValueObject::EvaluationPoint::EvaluationPoint(
const ValueObject::EvaluationPoint &rhs)
- : m_mod_id(), m_exe_ctx_ref(rhs.m_exe_ctx_ref), m_needs_update(true) {}
+ : m_mod_id(), m_exe_ctx_ref(rhs.m_exe_ctx_ref) {}
ValueObject::EvaluationPoint::~EvaluationPoint() = default;
diff --git a/contrib/llvm-project/lldb/source/Core/ValueObjectChild.cpp b/contrib/llvm-project/lldb/source/Core/ValueObjectChild.cpp
index a2beeb0bcdeb..d61d2021c318 100644
--- a/contrib/llvm-project/lldb/source/Core/ValueObjectChild.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ValueObjectChild.cpp
@@ -82,7 +82,7 @@ ConstString ValueObjectChild::GetDisplayTypeName() {
}
LazyBool ValueObjectChild::CanUpdateWithInvalidExecutionContext() {
- if (m_can_update_with_invalid_exe_ctx.hasValue())
+ if (m_can_update_with_invalid_exe_ctx)
return m_can_update_with_invalid_exe_ctx.getValue();
if (m_parent) {
ValueObject *opinionated_parent =
diff --git a/contrib/llvm-project/lldb/source/Core/ValueObjectDynamicValue.cpp b/contrib/llvm-project/lldb/source/Core/ValueObjectDynamicValue.cpp
index bf087f33c0e9..cc5c481cdbb5 100644
--- a/contrib/llvm-project/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -16,8 +16,8 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-types.h"
@@ -201,7 +201,7 @@ bool ValueObjectDynamicValue::UpdateValue() {
Value old_value(m_value);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES));
+ Log *log = GetLog(LLDBLog::Types);
bool has_changed_type = false;
diff --git a/contrib/llvm-project/lldb/source/Core/ValueObjectRegister.cpp b/contrib/llvm-project/lldb/source/Core/ValueObjectRegister.cpp
index 743083a2d1ed..2aa0c68ba40f 100644
--- a/contrib/llvm-project/lldb/source/Core/ValueObjectRegister.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ValueObjectRegister.cpp
@@ -18,6 +18,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
@@ -202,9 +203,8 @@ CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
auto type_system_or_err =
exe_module->GetTypeSystemForLanguage(eLanguageTypeC);
if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(
- lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TYPES),
- std::move(err), "Unable to get CompilerType from TypeSystem");
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Types), std::move(err),
+ "Unable to get CompilerType from TypeSystem");
} else {
m_compiler_type =
type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
@@ -269,26 +269,30 @@ bool ValueObjectRegister::SetValueFromCString(const char *value_str,
// The new value will be in the m_data. Copy that into our register value.
error =
m_reg_value.SetValueFromString(&m_reg_info, llvm::StringRef(value_str));
- if (error.Success()) {
- if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
- SetNeedsUpdate();
- return true;
- } else
- return false;
- } else
+ if (!error.Success())
return false;
+
+ if (!m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
+ error.SetErrorString("unable to write back to register");
+ return false;
+ }
+
+ SetNeedsUpdate();
+ return true;
}
bool ValueObjectRegister::SetData(DataExtractor &data, Status &error) {
error = m_reg_value.SetValueFromData(&m_reg_info, data, 0, false);
- if (error.Success()) {
- if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
- SetNeedsUpdate();
- return true;
- } else
- return false;
- } else
+ if (!error.Success())
return false;
+
+ if (!m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) {
+ error.SetErrorString("unable to write back to register");
+ return false;
+ }
+
+ SetNeedsUpdate();
+ return true;
}
bool ValueObjectRegister::ResolveValue(Scalar &scalar) {
diff --git a/contrib/llvm-project/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/contrib/llvm-project/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index aa55e3965706..a1001b396912 100644
--- a/contrib/llvm-project/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/contrib/llvm-project/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -12,8 +12,8 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/STLExtras.h"
@@ -81,7 +81,7 @@ ConstString ValueObjectSynthetic::GetDisplayTypeName() {
}
size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
+ Log *log = GetLog(LLDBLog::DataFormatters);
UpdateValueIfNeeded();
if (m_synthetic_children_count < UINT32_MAX)
@@ -148,7 +148,7 @@ void ValueObjectSynthetic::CreateSynthFilter() {
}
bool ValueObjectSynthetic::UpdateValue() {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
+ Log *log = GetLog(LLDBLog::DataFormatters);
SetValueIsValid(false);
m_error.Clear();
@@ -234,7 +234,7 @@ bool ValueObjectSynthetic::UpdateValue() {
lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
bool can_create) {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
+ Log *log = GetLog(LLDBLog::DataFormatters);
LLDB_LOGF(log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving "