aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/MemoryTagMap.cpp64
-rw-r--r--lldb/source/Target/Platform.cpp7
-rw-r--r--lldb/source/Target/RegisterContextUnwind.cpp2
-rw-r--r--lldb/source/Target/StackFrame.cpp6
-rw-r--r--lldb/source/Target/Statistics.cpp55
-rw-r--r--lldb/source/Target/Target.cpp7
-rw-r--r--lldb/source/Target/Thread.cpp4
-rw-r--r--lldb/source/Target/TraceInstructionDumper.cpp6
8 files changed, 135 insertions, 16 deletions
diff --git a/lldb/source/Target/MemoryTagMap.cpp b/lldb/source/Target/MemoryTagMap.cpp
new file mode 100644
index 000000000000..846eef9209da
--- /dev/null
+++ b/lldb/source/Target/MemoryTagMap.cpp
@@ -0,0 +1,64 @@
+//===-- MemoryTagMap.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/Target/MemoryTagMap.h"
+
+using namespace lldb_private;
+
+MemoryTagMap::MemoryTagMap(const MemoryTagManager *manager)
+ : m_manager(manager) {
+ assert(m_manager && "valid tag manager required to construct a MemoryTagMap");
+}
+
+void MemoryTagMap::InsertTags(lldb::addr_t addr,
+ const std::vector<lldb::addr_t> tags) {
+ // We're assuming that addr has no non address bits and is granule aligned.
+ size_t granule_size = m_manager->GetGranuleSize();
+ for (auto tag : tags) {
+ m_addr_to_tag[addr] = tag;
+ addr += granule_size;
+ }
+}
+
+bool MemoryTagMap::Empty() const { return m_addr_to_tag.empty(); }
+
+std::vector<llvm::Optional<lldb::addr_t>>
+MemoryTagMap::GetTags(lldb::addr_t addr, size_t len) const {
+ // Addr and len might be unaligned
+ addr = m_manager->RemoveTagBits(addr);
+ MemoryTagManager::TagRange range(addr, len);
+ range = m_manager->ExpandToGranule(range);
+
+ std::vector<llvm::Optional<lldb::addr_t>> tags;
+ lldb::addr_t end_addr = range.GetRangeEnd();
+ addr = range.GetRangeBase();
+ bool got_valid_tags = false;
+ size_t granule_size = m_manager->GetGranuleSize();
+
+ for (; addr < end_addr; addr += granule_size) {
+ llvm::Optional<lldb::addr_t> tag = GetTag(addr);
+ tags.push_back(tag);
+ if (tag)
+ got_valid_tags = true;
+ }
+
+ // To save the caller checking if every item is llvm::None,
+ // we return an empty vector if we got no tags at all.
+ if (got_valid_tags)
+ return tags;
+ return {};
+}
+
+llvm::Optional<lldb::addr_t> MemoryTagMap::GetTag(lldb::addr_t addr) const {
+ // Here we assume that addr is granule aligned, just like when the tags
+ // were inserted.
+ auto found = m_addr_to_tag.find(addr);
+ if (found == m_addr_to_tag.end())
+ return llvm::None;
+ return found->second;
+}
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index af5ca0225169..3c331c8760df 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -428,6 +428,9 @@ void Platform::GetStatus(Stream &strm) {
strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no");
}
+ if (GetSDKRootDirectory()) {
+ strm.Format(" Sysroot: {0}\n", GetSDKRootDirectory());
+ }
if (GetWorkingDirectory()) {
strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetCString());
}
@@ -2000,3 +2003,7 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
return 0;
}
+
+CompilerType Platform::GetSiginfoType(const llvm::Triple& triple) {
+ return CompilerType();
+}
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index 96b69640a3a3..315ccea65d1f 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1509,7 +1509,7 @@ RegisterContextUnwind::SavedLocationForRegister(
regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
return UnwindLLDB::RegisterSearchResult::eRegisterFound;
} else {
- std::string unwindplan_name("");
+ std::string unwindplan_name;
if (m_full_unwind_plan_sp) {
unwindplan_name += "via '";
unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString();
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 7b4295158425..58de26b23b65 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1433,13 +1433,13 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
/// Attempt to reconstruct the ValueObject for the address contained in a
/// given register plus an offset.
///
-/// \params [in] frame
+/// \param [in] frame
/// The current stack frame.
///
-/// \params [in] reg
+/// \param [in] reg
/// The register.
///
-/// \params [in] offset
+/// \param [in] offset
/// The offset from the register.
///
/// \param [in] disassembler
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 1b205c533519..ebddad837d14 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -34,7 +34,8 @@ json::Value StatsSuccessFail::ToJSON() const {
}
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end) {
- StatsDuration elapsed = end.time_since_epoch() - start.time_since_epoch();
+ StatsDuration::Duration elapsed =
+ end.time_since_epoch() - start.time_since_epoch();
return elapsed.count();
}
@@ -52,12 +53,26 @@ json::Value ModuleStats::ToJSON() const {
module.try_emplace("identifier", identifier);
module.try_emplace("symbolTableParseTime", symtab_parse_time);
module.try_emplace("symbolTableIndexTime", symtab_index_time);
+ module.try_emplace("symbolTableLoadedFromCache", symtab_loaded_from_cache);
+ module.try_emplace("symbolTableSavedToCache", symtab_saved_to_cache);
module.try_emplace("debugInfoParseTime", debug_parse_time);
module.try_emplace("debugInfoIndexTime", debug_index_time);
module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size);
+ module.try_emplace("debugInfoIndexLoadedFromCache",
+ debug_info_index_loaded_from_cache);
+ module.try_emplace("debugInfoIndexSavedToCache",
+ debug_info_index_saved_to_cache);
return module;
}
+llvm::json::Value ConstStringStats::ToJSON() const {
+ json::Object obj;
+ obj.try_emplace<int64_t>("bytesTotal", stats.GetBytesTotal());
+ obj.try_emplace<int64_t>("bytesUsed", stats.GetBytesUsed());
+ obj.try_emplace<int64_t>("bytesUnused", stats.GetBytesUnused());
+ return obj;
+}
+
json::Value TargetStats::ToJSON(Target &target) {
CollectStats(target);
@@ -80,7 +95,8 @@ json::Value TargetStats::ToJSON(Target &target) {
elapsed(*m_launch_or_attach_time, *m_first_public_stop_time);
target_metrics_json.try_emplace("firstStopTime", elapsed_time);
}
- target_metrics_json.try_emplace("targetCreateTime", m_create_time.count());
+ target_metrics_json.try_emplace("targetCreateTime",
+ m_create_time.get().count());
json::Array breakpoints_array;
double totalBreakpointResolveTime = 0.0;
@@ -144,6 +160,10 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
double symtab_index_time = 0.0;
double debug_parse_time = 0.0;
double debug_index_time = 0.0;
+ uint32_t symtabs_loaded = 0;
+ uint32_t symtabs_saved = 0;
+ uint32_t debug_index_loaded = 0;
+ uint32_t debug_index_saved = 0;
uint64_t debug_info_size = 0;
if (target) {
json_targets.emplace_back(target->ReportStatistics());
@@ -167,13 +187,30 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
}
module_stat.uuid = module->GetUUID().GetAsString();
module_stat.triple = module->GetArchitecture().GetTriple().str();
- module_stat.symtab_parse_time = module->GetSymtabParseTime().count();
- module_stat.symtab_index_time = module->GetSymtabIndexTime().count();
+ module_stat.symtab_parse_time = module->GetSymtabParseTime().get().count();
+ module_stat.symtab_index_time = module->GetSymtabIndexTime().get().count();
+ Symtab *symtab = module->GetSymtab();
+ if (symtab) {
+ module_stat.symtab_loaded_from_cache = symtab->GetWasLoadedFromCache();
+ if (module_stat.symtab_loaded_from_cache)
+ ++symtabs_loaded;
+ module_stat.symtab_saved_to_cache = symtab->GetWasSavedToCache();
+ if (module_stat.symtab_saved_to_cache)
+ ++symtabs_saved;
+ }
SymbolFile *sym_file = module->GetSymbolFile();
if (sym_file) {
module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
module_stat.debug_info_size = sym_file->GetDebugInfoSize();
+ module_stat.debug_info_index_loaded_from_cache =
+ sym_file->GetDebugInfoIndexWasLoadedFromCache();
+ if (module_stat.debug_info_index_loaded_from_cache)
+ ++debug_index_loaded;
+ module_stat.debug_info_index_saved_to_cache =
+ sym_file->GetDebugInfoIndexWasSavedToCache();
+ if (module_stat.debug_info_index_saved_to_cache)
+ ++debug_index_saved;
}
symtab_parse_time += module_stat.symtab_parse_time;
symtab_index_time += module_stat.symtab_index_time;
@@ -183,13 +220,23 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
json_modules.emplace_back(module_stat.ToJSON());
}
+ ConstStringStats const_string_stats;
+ json::Object json_memory{
+ {"strings", const_string_stats.ToJSON()},
+ };
+
json::Object global_stats{
{"targets", std::move(json_targets)},
{"modules", std::move(json_modules)},
+ {"memory", std::move(json_memory)},
{"totalSymbolTableParseTime", symtab_parse_time},
{"totalSymbolTableIndexTime", symtab_index_time},
+ {"totalSymbolTablesLoadedFromCache", symtabs_loaded},
+ {"totalSymbolTablesSavedToCache", symtabs_saved},
{"totalDebugInfoParseTime", debug_parse_time},
{"totalDebugInfoIndexTime", debug_index_time},
+ {"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
+ {"totalDebugInfoIndexSavedToCache", debug_index_saved},
{"totalDebugInfoByteSize", debug_info_size},
};
return std::move(global_stats);
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index fa860399aca7..01e51c0577aa 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -212,17 +212,20 @@ const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; }
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
const char *repl_options, bool can_create) {
+ if (language == eLanguageTypeUnknown)
+ language = m_debugger.GetREPLLanguage();
+
if (language == eLanguageTypeUnknown) {
LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
if (auto single_lang = repl_languages.GetSingularLanguage()) {
language = *single_lang;
} else if (repl_languages.Empty()) {
- err.SetErrorStringWithFormat(
+ err.SetErrorString(
"LLDB isn't configured with REPL support for any languages.");
return REPLSP();
} else {
- err.SetErrorStringWithFormat(
+ err.SetErrorString(
"Multiple possible REPL languages. Please specify a language.");
return REPLSP();
}
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 481a39a576e9..c5f16b4e6c1d 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -471,9 +471,7 @@ void Thread::SetStopInfoToNothing() {
StopInfo::CreateStopReasonWithSignal(*this, LLDB_INVALID_SIGNAL_NUMBER));
}
-bool Thread::ThreadStoppedForAReason(void) {
- return (bool)GetPrivateStopInfo();
-}
+bool Thread::ThreadStoppedForAReason() { return (bool)GetPrivateStopInfo(); }
bool Thread::CheckpointThreadState(ThreadStateCheckpoint &saved_state) {
saved_state.register_backup_sp.reset();
diff --git a/lldb/source/Target/TraceInstructionDumper.cpp b/lldb/source/Target/TraceInstructionDumper.cpp
index dc1e86481c36..d58d2dff7383 100644
--- a/lldb/source/Target/TraceInstructionDumper.cpp
+++ b/lldb/source/Target/TraceInstructionDumper.cpp
@@ -137,7 +137,7 @@ DumpInstructionSymbolContext(Stream &s,
insn.sc.module_sp->GetFileSpec().GetFilename().AsCString());
else
insn.sc.DumpStopContext(&s, insn.exe_ctx.GetTargetPtr(), insn.address,
- /*show_fullpath=*/false,
+ /*show_fullpaths=*/false,
/*show_module=*/true, /*show_inlined_frames=*/false,
/*show_function_arguments=*/true,
/*show_function_name=*/true);
@@ -148,8 +148,8 @@ static void DumpInstructionDisassembly(Stream &s, InstructionSymbolInfo &insn) {
if (!insn.instruction)
return;
s.Printf(" ");
- insn.instruction->Dump(&s, /*show_address=*/false, /*show_bytes=*/false,
- /*max_opcode_byte_size=*/0, &insn.exe_ctx, &insn.sc,
+ insn.instruction->Dump(&s, /*max_opcode_byte_size=*/0, /*show_address=*/false,
+ /*show_bytes=*/false, &insn.exe_ctx, &insn.sc,
/*prev_sym_ctx=*/nullptr,
/*disassembly_addr_format=*/nullptr,
/*max_address_text_size=*/0);