diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-01-27 22:06:42 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-01-27 22:06:42 +0000 |
| commit | 6f8fc217eaa12bf657be1c6468ed9938d10168b3 (patch) | |
| tree | a1fd89b864d9b93e2ad68fe1dcf7afee2e3c8d76 /lldb/source/Utility | |
| parent | 77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (diff) | |
Vendor import of llvm-project main llvmorg-14-init-17616-g024a1fab5c35.vendor/llvm-project/llvmorg-14-init-17616-g024a1fab5c35
Diffstat (limited to 'lldb/source/Utility')
| -rw-r--r-- | lldb/source/Utility/ConstString.cpp | 18 | ||||
| -rw-r--r-- | lldb/source/Utility/Instrumentation.cpp | 43 | ||||
| -rw-r--r-- | lldb/source/Utility/Log.cpp | 16 | ||||
| -rw-r--r-- | lldb/source/Utility/Logging.cpp | 97 | ||||
| -rw-r--r-- | lldb/source/Utility/Reproducer.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Utility/ReproducerInstrumentation.cpp | 262 | ||||
| -rw-r--r-- | lldb/source/Utility/StringList.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Utility/Timer.cpp | 4 |
8 files changed, 126 insertions, 328 deletions
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index e5e1b2387e64..142c335ddbbe 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -159,16 +159,15 @@ public: return nullptr; } - // Return the size in bytes that this object and any items in its collection - // of uniqued strings + data count values takes in memory. - size_t MemorySize() const { - size_t mem_size = sizeof(Pool); + ConstString::MemoryStats GetMemoryStats() const { + ConstString::MemoryStats stats; for (const auto &pool : m_string_pools) { llvm::sys::SmartScopedReader<false> rlock(pool.m_mutex); - for (const auto &entry : pool.m_string_map) - mem_size += sizeof(StringPoolEntryType) + entry.getKey().size(); + const Allocator &alloc = pool.m_string_map.getAllocator(); + stats.bytes_total += alloc.getTotalMemory(); + stats.bytes_used += alloc.getBytesAllocated(); } - return mem_size; + return stats; } protected: @@ -327,9 +326,8 @@ void ConstString::SetTrimmedCStringWithLength(const char *cstr, m_string = StringPool().GetConstTrimmedCStringWithLength(cstr, cstr_len); } -size_t ConstString::StaticMemorySize() { - // Get the size of the static string pool - return StringPool().MemorySize(); +ConstString::MemoryStats ConstString::GetMemoryStats() { + return StringPool().GetMemoryStats(); } void llvm::format_provider<ConstString>::format(const ConstString &CS, diff --git a/lldb/source/Utility/Instrumentation.cpp b/lldb/source/Utility/Instrumentation.cpp new file mode 100644 index 000000000000..861789810e1a --- /dev/null +++ b/lldb/source/Utility/Instrumentation.cpp @@ -0,0 +1,43 @@ +//===-- Instrumentation.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/Utility/Instrumentation.h" +#include "llvm/Support/Signposts.h" + +#include <cstdio> +#include <cstdlib> +#include <limits> +#include <thread> + +using namespace lldb_private; +using namespace lldb_private::instrumentation; + +// Whether we're currently across the API boundary. +static thread_local bool g_global_boundary = false; + +// Instrument SB API calls with singposts when supported. +static llvm::ManagedStatic<llvm::SignpostEmitter> g_api_signposts; + +Instrumenter::Instrumenter(llvm::StringRef pretty_func, + std::string &&pretty_args) + : m_pretty_func(pretty_func), m_local_boundary(false) { + if (!g_global_boundary) { + g_global_boundary = true; + m_local_boundary = true; + g_api_signposts->startInterval(this, m_pretty_func); + } + LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "[{0}] {1} ({2})", + m_local_boundary ? "external" : "internal", m_pretty_func, + pretty_args); +} + +Instrumenter::~Instrumenter() { + if (m_local_boundary) { + g_global_boundary = false; + g_api_signposts->endInterval(this, m_pretty_func); + } +} diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp index ff654ec93e78..d229538073d1 100644 --- a/lldb/source/Utility/Log.cpp +++ b/lldb/source/Utility/Log.cpp @@ -30,7 +30,6 @@ #include <process.h> #else #include <unistd.h> -#include <pthread.h> #endif using namespace lldb_private; @@ -89,7 +88,7 @@ void Log::Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp, uint32_t options, uint32_t flags) { llvm::sys::ScopedWriter lock(m_mutex); - uint32_t mask = m_mask.fetch_or(flags, std::memory_order_relaxed); + MaskType mask = m_mask.fetch_or(flags, std::memory_order_relaxed); if (mask | flags) { m_options.store(options, std::memory_order_relaxed); m_stream_sp = stream_sp; @@ -100,7 +99,7 @@ void Log::Enable(const std::shared_ptr<llvm::raw_ostream> &stream_sp, void Log::Disable(uint32_t flags) { llvm::sys::ScopedWriter lock(m_mutex); - uint32_t mask = m_mask.fetch_and(~flags, std::memory_order_relaxed); + MaskType mask = m_mask.fetch_and(~flags, std::memory_order_relaxed); if (!(mask & ~flags)) { m_stream_sp.reset(); m_channel.log_ptr.store(nullptr, std::memory_order_relaxed); @@ -180,9 +179,6 @@ void Log::Warning(const char *format, ...) { } void Log::Initialize() { -#ifdef LLVM_ON_UNIX - pthread_atfork(nullptr, nullptr, &Log::DisableLoggingChild); -#endif InitializeLldbChannel(); } @@ -346,11 +342,3 @@ void Log::Format(llvm::StringRef file, llvm::StringRef function, message << payload << "\n"; WriteMessage(message.str()); } - -void Log::DisableLoggingChild() { - // Disable logging by clearing out the atomic variable after forking -- if we - // forked while another thread held the channel mutex, we would deadlock when - // trying to write to the log. - for (auto &c: *g_channel_map) - c.second.m_channel.log_ptr.store(nullptr, std::memory_order_relaxed); -} diff --git a/lldb/source/Utility/Logging.cpp b/lldb/source/Utility/Logging.cpp index 4648bec502c5..67d5d3af2640 100644 --- a/lldb/source/Utility/Logging.cpp +++ b/lldb/source/Utility/Logging.cpp @@ -16,49 +16,74 @@ using namespace lldb_private; static constexpr Log::Category g_categories[] = { - {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API}, - {{"ast"}, {"log AST"}, LIBLLDB_LOG_AST}, - {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS}, - {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS}, - {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION}, - {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION}, - {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE}, - {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER}, - {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS}, - {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS}, - {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS}, - {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST}, - {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER}, - {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE}, - {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP}, - {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES}, - {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT}, - {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS}, - {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM}, - {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS}, - {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT}, - {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE}, - {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP}, - {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS}, - {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME}, - {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET}, - {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY}, - {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD}, - {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES}, - {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND}, - {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS}, + {{"api"}, {"log API calls and return values"}, LLDBLog::API}, + {{"ast"}, {"log AST"}, LLDBLog::AST}, + {{"break"}, {"log breakpoints"}, LLDBLog::Breakpoints}, + {{"commands"}, {"log command argument parsing"}, LLDBLog::Commands}, + {{"comm"}, {"log communication activities"}, LLDBLog::Communication}, + {{"conn"}, {"log connection details"}, LLDBLog::Connection}, + {{"demangle"}, + {"log mangled names to catch demangler crashes"}, + LLDBLog::Demangle}, + {{"dyld"}, + {"log shared library related activities"}, + LLDBLog::DynamicLoader}, + {{"event"}, + {"log broadcaster, listener and event queue activities"}, + LLDBLog::Events}, + {{"expr"}, {"log expressions"}, LLDBLog::Expressions}, + {{"formatters"}, + {"log data formatters related activities"}, + LLDBLog::DataFormatters}, + {{"host"}, {"log host activities"}, LLDBLog::Host}, + {{"jit"}, {"log JIT events in the target"}, LLDBLog::JITLoader}, + {{"language"}, {"log language runtime events"}, LLDBLog::Language}, + {{"mmap"}, {"log mmap related activities"}, LLDBLog::MMap}, + {{"module"}, + {"log module activities such as when modules are created, destroyed, " + "replaced, and more"}, + LLDBLog::Modules}, + {{"object"}, + {"log object construction/destruction for important objects"}, + LLDBLog::Object}, + {{"os"}, {"log OperatingSystem plugin related activities"}, LLDBLog::OS}, + {{"platform"}, {"log platform events and activities"}, LLDBLog::Platform}, + {{"process"}, {"log process events and activities"}, LLDBLog::Process}, + {{"script"}, {"log events about the script interpreter"}, LLDBLog::Script}, + {{"state"}, + {"log private and public process state changes"}, + LLDBLog::State}, + {{"step"}, {"log step related activities"}, LLDBLog::Step}, + {{"symbol"}, {"log symbol related issues and warnings"}, LLDBLog::Symbols}, + {{"system-runtime"}, {"log system runtime events"}, LLDBLog::SystemRuntime}, + {{"target"}, {"log target events and activities"}, LLDBLog::Target}, + {{"temp"}, {"log internal temporary debug messages"}, LLDBLog::Temporary}, + {{"thread"}, {"log thread events and activities"}, LLDBLog::Thread}, + {{"types"}, {"log type system related activities"}, LLDBLog::Types}, + {{"unwind"}, {"log stack unwind activities"}, LLDBLog::Unwind}, + {{"watch"}, {"log watchpoint related activities"}, LLDBLog::Watchpoints}, }; -static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT); +static Log::Channel g_log_channel(g_categories, + LLDBLog::Process | LLDBLog::Thread | + LLDBLog::DynamicLoader | + LLDBLog::Breakpoints | + LLDBLog::Watchpoints | LLDBLog::Step | + LLDBLog::State | LLDBLog::Symbols | + LLDBLog::Target | LLDBLog::Commands); + +template <> Log::Channel &lldb_private::LogChannelFor<LLDBLog>() { + return g_log_channel; +} void lldb_private::InitializeLldbChannel() { Log::Register("lldb", g_log_channel); } -Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) { - return g_log_channel.GetLogIfAll(mask); +Log *lldb_private::GetLogIfAllCategoriesSet(LLDBLog mask) { + return GetLog(mask); } -Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) { - return g_log_channel.GetLogIfAny(mask); +Log *lldb_private::GetLogIfAnyCategoriesSet(LLDBLog mask) { + return GetLog(mask); } diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp index a306d6c1ef25..1e71dba472ed 100644 --- a/lldb/source/Utility/Reproducer.cpp +++ b/lldb/source/Utility/Reproducer.cpp @@ -362,7 +362,7 @@ llvm::Error repro::Finalize(Loader *loader) { FileSpec mapping = reproducer_root.CopyByAppendingPathComponent(FileProvider::Info::file); - if (auto ec = collector.copyFiles(/*stop_on_error=*/false)) + if (auto ec = collector.copyFiles(/*StopOnError=*/false)) return errorCodeToError(ec); collector.writeMapping(mapping.GetPath()); diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp deleted file mode 100644 index b3285f4b3776..000000000000 --- a/lldb/source/Utility/ReproducerInstrumentation.cpp +++ /dev/null @@ -1,262 +0,0 @@ -//===-- ReproducerInstrumentation.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/Utility/ReproducerInstrumentation.h" -#include "lldb/Utility/Reproducer.h" -#include <cstdio> -#include <cstdlib> -#include <limits> -#include <thread> - -using namespace lldb_private; -using namespace lldb_private::repro; - -// Whether we're currently across the API boundary. -static thread_local bool g_global_boundary = false; - -void *IndexToObject::GetObjectForIndexImpl(unsigned idx) { - return m_mapping.lookup(idx); -} - -void IndexToObject::AddObjectForIndexImpl(unsigned idx, void *object) { - assert(idx != 0 && "Cannot add object for sentinel"); - m_mapping[idx] = object; -} - -std::vector<void *> IndexToObject::GetAllObjects() const { - std::vector<std::pair<unsigned, void *>> pairs; - for (auto &e : m_mapping) { - pairs.emplace_back(e.first, e.second); - } - - // Sort based on index. - std::sort(pairs.begin(), pairs.end(), - [](auto &lhs, auto &rhs) { return lhs.first < rhs.first; }); - - std::vector<void *> objects; - objects.reserve(pairs.size()); - for (auto &p : pairs) { - objects.push_back(p.second); - } - - return objects; -} - -template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>() { - return Deserialize<uint8_t *>(); -} - -template <> void *Deserializer::Deserialize<void *>() { - return const_cast<void *>(Deserialize<const void *>()); -} - -template <> const void *Deserializer::Deserialize<const void *>() { - return nullptr; -} - -template <> char *Deserializer::Deserialize<char *>() { - return const_cast<char *>(Deserialize<const char *>()); -} - -template <> const char *Deserializer::Deserialize<const char *>() { - const size_t size = Deserialize<size_t>(); - if (size == std::numeric_limits<size_t>::max()) - return nullptr; - assert(HasData(size + 1)); - const char *str = m_buffer.data(); - m_buffer = m_buffer.drop_front(size + 1); -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> \"" - << str << "\"\n"; -#endif - return str; -} - -template <> const char **Deserializer::Deserialize<const char **>() { - const size_t size = Deserialize<size_t>(); - if (size == 0) - return nullptr; - const char **r = - reinterpret_cast<const char **>(calloc(size + 1, sizeof(char *))); - for (size_t i = 0; i < size; ++i) - r[i] = Deserialize<const char *>(); - return r; -} - -void Deserializer::CheckSequence(unsigned sequence) { - if (m_expected_sequence && *m_expected_sequence != sequence) - llvm::report_fatal_error( - "The result does not match the preceding " - "function. This is probably the result of concurrent " - "use of the SB API during capture, which is currently not " - "supported."); - m_expected_sequence.reset(); -} - -bool Registry::Replay(const FileSpec &file) { - auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); - if (auto err = error_or_file.getError()) - return false; - - return Replay((*error_or_file)->getBuffer()); -} - -bool Registry::Replay(llvm::StringRef buffer) { - Deserializer deserializer(buffer); - return Replay(deserializer); -} - -bool Registry::Replay(Deserializer &deserializer) { -#ifndef LLDB_REPRO_INSTR_TRACE - Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API); -#endif - - // Disable buffering stdout so that we approximate the way things get flushed - // during an interactive session. - setvbuf(stdout, nullptr, _IONBF, 0); - - while (deserializer.HasData(1)) { - unsigned sequence = deserializer.Deserialize<unsigned>(); - unsigned id = deserializer.Deserialize<unsigned>(); - -#ifndef LLDB_REPRO_INSTR_TRACE - LLDB_LOG(log, "Replaying {0}: {1}", id, GetSignature(id)); -#else - llvm::errs() << "Replaying " << id << ": " << GetSignature(id) << "\n"; -#endif - - deserializer.SetExpectedSequence(sequence); - GetReplayer(id)->operator()(deserializer); - } - - // Add a small artificial delay to ensure that all asynchronous events have - // completed before we exit. - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - return true; -} - -void Registry::DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer, - SignatureStr signature) { - const unsigned id = m_replayers.size() + 1; - assert(m_replayers.find(RunID) == m_replayers.end()); - m_replayers[RunID] = std::make_pair(std::move(replayer), id); - m_ids[id] = - std::make_pair(m_replayers[RunID].first.get(), std::move(signature)); -} - -unsigned Registry::GetID(uintptr_t addr) { - unsigned id = m_replayers[addr].second; - assert(id != 0 && "Forgot to add function to registry?"); - return id; -} - -std::string Registry::GetSignature(unsigned id) { - assert(m_ids.count(id) != 0 && "ID not in registry"); - return m_ids[id].second.ToString(); -} - -void Registry::CheckID(unsigned expected, unsigned actual) { - if (expected != actual) { - llvm::errs() << "Reproducer expected signature " << expected << ": '" - << GetSignature(expected) << "'\n"; - llvm::errs() << "Reproducer actual signature " << actual << ": '" - << GetSignature(actual) << "'\n"; - llvm::report_fatal_error( - "Detected reproducer replay divergence. Refusing to continue."); - } - -#ifdef LLDB_REPRO_INSTR_TRACE - llvm::errs() << "Replaying " << actual << ": " << GetSignature(actual) - << "\n"; -#endif -} - -Replayer *Registry::GetReplayer(unsigned id) { - assert(m_ids.count(id) != 0 && "ID not in registry"); - return m_ids[id].first; -} - -std::string Registry::SignatureStr::ToString() const { - return (result + (result.empty() ? "" : " ") + scope + "::" + name + args) - .str(); -} - -unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) { - unsigned index = m_mapping.size() + 1; - auto it = m_mapping.find(object); - if (it == m_mapping.end()) - m_mapping[object] = index; - return m_mapping[object]; -} - -Recorder::Recorder() - : m_pretty_func(), m_pretty_args(), - - m_sequence(std::numeric_limits<unsigned>::max()) { - if (!g_global_boundary) { - g_global_boundary = true; - m_local_boundary = true; - m_sequence = GetNextSequenceNumber(); - } -} - -Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args) - : m_serializer(nullptr), m_pretty_func(pretty_func), - m_pretty_args(pretty_args), m_local_boundary(false), - m_result_recorded(true), - m_sequence(std::numeric_limits<unsigned>::max()) { - if (!g_global_boundary) { - g_global_boundary = true; - m_local_boundary = true; - m_sequence = GetNextSequenceNumber(); - LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})", - m_pretty_func, m_pretty_args); - } -} - -Recorder::~Recorder() { - assert(m_result_recorded && "Did you forget LLDB_RECORD_RESULT?"); - UpdateBoundary(); -} - -unsigned Recorder::GetSequenceNumber() const { - assert(m_sequence != std::numeric_limits<unsigned>::max()); - return m_sequence; -} - -void Recorder::PrivateThread() { g_global_boundary = true; } - -void Recorder::UpdateBoundary() { - if (m_local_boundary) - g_global_boundary = false; -} - -void InstrumentationData::Initialize(Serializer &serializer, - Registry ®istry) { - InstanceImpl().emplace(serializer, registry); -} - -void InstrumentationData::Initialize(Deserializer &deserializer, - Registry ®istry) { - InstanceImpl().emplace(deserializer, registry); -} - -InstrumentationData &InstrumentationData::Instance() { - if (!InstanceImpl()) - InstanceImpl().emplace(); - return *InstanceImpl(); -} - -llvm::Optional<InstrumentationData> &InstrumentationData::InstanceImpl() { - static llvm::Optional<InstrumentationData> g_instrumentation_data; - return g_instrumentation_data; -} - -std::atomic<unsigned> lldb_private::repro::Recorder::g_sequence; -std::mutex lldb_private::repro::Recorder::g_mutex; diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp index baff34ae3a5e..ee1f157f16f1 100644 --- a/lldb/source/Utility/StringList.cpp +++ b/lldb/source/Utility/StringList.cpp @@ -42,7 +42,9 @@ void StringList::AppendString(const char *str) { void StringList::AppendString(const std::string &s) { m_strings.push_back(s); } -void StringList::AppendString(std::string &&s) { m_strings.push_back(s); } +void StringList::AppendString(std::string &&s) { + m_strings.push_back(std::move(s)); +} void StringList::AppendString(const char *str, size_t str_len) { if (str) @@ -53,6 +55,10 @@ void StringList::AppendString(llvm::StringRef str) { m_strings.push_back(str.str()); } +void StringList::AppendString(const llvm::Twine &str) { + m_strings.push_back(str.str()); +} + void StringList::AppendList(const char **strv, int strc) { for (int i = 0; i < strc; ++i) { if (strv[i]) @@ -133,9 +139,9 @@ void StringList::InsertStringAtIndex(size_t idx, const std::string &str) { void StringList::InsertStringAtIndex(size_t idx, std::string &&str) { if (idx < m_strings.size()) - m_strings.insert(m_strings.begin() + idx, str); + m_strings.insert(m_strings.begin() + idx, std::move(str)); else - m_strings.push_back(str); + m_strings.push_back(std::move(str)); } void StringList::DeleteStringAtIndex(size_t idx) { diff --git a/lldb/source/Utility/Timer.cpp b/lldb/source/Utility/Timer.cpp index 2f3afe4c8703..b190f35007d5 100644 --- a/lldb/source/Utility/Timer.cpp +++ b/lldb/source/Utility/Timer.cpp @@ -63,7 +63,7 @@ Timer::Timer(Timer::Category &category, const char *format, ...) TimerStack &stack = GetTimerStackForCurrentThread(); stack.push_back(this); - if (g_quiet && stack.size() <= g_display_depth) { + if (!g_quiet && stack.size() <= g_display_depth) { std::lock_guard<std::mutex> lock(GetFileMutex()); // Indent @@ -89,7 +89,7 @@ Timer::~Timer() { Signposts->endInterval(this, m_category.GetName()); TimerStack &stack = GetTimerStackForCurrentThread(); - if (g_quiet && stack.size() <= g_display_depth) { + if (!g_quiet && stack.size() <= g_display_depth) { std::lock_guard<std::mutex> lock(GetFileMutex()); ::fprintf(stdout, "%*s%.9f sec (%.9f sec)\n", int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "", |
