aboutsummaryrefslogtreecommitdiffstats
path: root/source/Core
diff options
context:
space:
mode:
Diffstat (limited to 'source/Core')
-rw-r--r--source/Core/Address.cpp55
-rw-r--r--source/Core/AddressResolverFileLine.cpp17
-rw-r--r--source/Core/AddressResolverName.cpp15
-rw-r--r--source/Core/Communication.cpp55
-rw-r--r--source/Core/CoreProperties.td118
-rw-r--r--source/Core/Debugger.cpp488
-rw-r--r--source/Core/Disassembler.cpp239
-rw-r--r--source/Core/DumpDataExtractor.cpp96
-rw-r--r--source/Core/FileLineResolver.cpp2
-rw-r--r--source/Core/FormatEntity.cpp143
-rw-r--r--source/Core/Highlighter.cpp5
-rw-r--r--source/Core/IOHandler.cpp332
-rw-r--r--source/Core/Mangled.cpp72
-rw-r--r--source/Core/Module.cpp349
-rw-r--r--source/Core/ModuleList.cpp207
-rw-r--r--source/Core/PluginManager.cpp96
-rw-r--r--source/Core/SearchFilter.cpp37
-rw-r--r--source/Core/Section.cpp6
-rw-r--r--source/Core/SourceManager.cpp8
-rw-r--r--source/Core/StreamFile.cpp55
-rw-r--r--source/Core/Value.cpp11
-rw-r--r--source/Core/ValueObject.cpp44
-rw-r--r--source/Core/ValueObjectCast.cpp2
-rw-r--r--source/Core/ValueObjectChild.cpp26
-rw-r--r--source/Core/ValueObjectConstResult.cpp2
-rw-r--r--source/Core/ValueObjectDynamicValue.cpp8
-rw-r--r--source/Core/ValueObjectMemory.cpp4
-rw-r--r--source/Core/ValueObjectRegister.cpp21
-rw-r--r--source/Core/ValueObjectSyntheticFilter.cpp118
-rw-r--r--source/Core/ValueObjectVariable.cpp4
30 files changed, 1208 insertions, 1427 deletions
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 0da83eb98edb..a3912bef5a6e 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -261,6 +261,24 @@ bool Address::ResolveAddressUsingFileSections(addr_t file_addr,
return false; // Failed to resolve this address to a section offset value
}
+/// if "addr_range_ptr" is not NULL, then fill in with the address range of the function.
+bool Address::ResolveFunctionScope(SymbolContext &sym_ctx,
+ AddressRange *addr_range_ptr) {
+ constexpr SymbolContextItem resolve_scope =
+ eSymbolContextFunction | eSymbolContextSymbol;
+
+ if (!(CalculateSymbolContext(&sym_ctx, resolve_scope) & resolve_scope)) {
+ if (addr_range_ptr)
+ addr_range_ptr->Clear();
+ return false;
+ }
+
+ if (!addr_range_ptr)
+ return true;
+
+ return sym_ctx.GetAddressRange(resolve_scope, 0, false, *addr_range_ptr);
+}
+
ModuleSP Address::GetModule() const {
lldb::ModuleSP module_sp;
SectionSP section_sp(GetSection());
@@ -475,23 +493,19 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
switch (sect_type) {
case eSectionTypeData:
if (module_sp) {
- SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
- if (sym_vendor) {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab) {
- const addr_t file_Addr = GetFileAddress();
- Symbol *symbol =
- symtab->FindSymbolContainingFileAddress(file_Addr);
- if (symbol) {
- const char *symbol_name = symbol->GetName().AsCString();
- if (symbol_name) {
- s->PutCString(symbol_name);
- addr_t delta =
- file_Addr - symbol->GetAddressRef().GetFileAddress();
- if (delta)
- s->Printf(" + %" PRIu64, delta);
- showed_info = true;
- }
+ if (Symtab *symtab = module_sp->GetSymtab()) {
+ const addr_t file_Addr = GetFileAddress();
+ Symbol *symbol =
+ symtab->FindSymbolContainingFileAddress(file_Addr);
+ if (symbol) {
+ const char *symbol_name = symbol->GetName().AsCString();
+ if (symbol_name) {
+ s->PutCString(symbol_name);
+ addr_t delta =
+ file_Addr - symbol->GetAddressRef().GetFileAddress();
+ if (delta)
+ s->Printf(" + %" PRIu64, delta);
+ showed_info = true;
}
}
}
@@ -985,10 +999,9 @@ AddressClass Address::GetAddressClass() const {
if (module_sp) {
ObjectFile *obj_file = module_sp->GetObjectFile();
if (obj_file) {
- // Give the symbol vendor a chance to add to the unified section list
- // and to symtab from symbol file
- if (SymbolVendor *vendor = module_sp->GetSymbolVendor())
- vendor->GetSymtab();
+ // Give the symbol file a chance to add to the unified section list
+ // and to the symtab.
+ module_sp->GetSymtab();
return obj_file->GetAddressClass(GetFileAddress());
}
}
diff --git a/source/Core/AddressResolverFileLine.cpp b/source/Core/AddressResolverFileLine.cpp
index 24c0222d6ec2..4a14260c6c72 100644
--- a/source/Core/AddressResolverFileLine.cpp
+++ b/source/Core/AddressResolverFileLine.cpp
@@ -38,8 +38,7 @@ AddressResolverFileLine::~AddressResolverFileLine() {}
Searcher::CallbackReturn
AddressResolverFileLine::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) {
+ SymbolContext &context, Address *addr) {
SymbolContextList sc_list;
uint32_t sc_list_size;
CompileUnit *cu = context.comp_unit;
@@ -60,15 +59,15 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter,
if (log) {
StreamString s;
// new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose);
- // log->Printf ("Added address: %s\n", s.GetData());
+ // LLDB_LOGF(log, "Added address: %s\n", s.GetData());
}
} else {
- if (log)
- log->Printf(
- "error: Unable to resolve address at file address 0x%" PRIx64
- " for %s:%d\n",
- line_start.GetFileAddress(),
- m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number);
+ LLDB_LOGF(log,
+ "error: Unable to resolve address at file address 0x%" PRIx64
+ " for %s:%d\n",
+ line_start.GetFileAddress(),
+ m_file_spec.GetFilename().AsCString("<Unknown>"),
+ m_line_number);
}
}
}
diff --git a/source/Core/AddressResolverName.cpp b/source/Core/AddressResolverName.cpp
index e861368c0a25..6b9b7b2de723 100644
--- a/source/Core/AddressResolverName.cpp
+++ b/source/Core/AddressResolverName.cpp
@@ -36,7 +36,8 @@ AddressResolverName::AddressResolverName(const char *func_name,
: AddressResolver(), m_func_name(func_name), m_class_name(nullptr),
m_regex(), m_match_type(type) {
if (m_match_type == AddressResolver::Regexp) {
- if (!m_regex.Compile(m_func_name.GetStringRef())) {
+ m_regex = RegularExpression(m_func_name.GetStringRef());
+ if (!m_regex.IsValid()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
@@ -46,9 +47,9 @@ AddressResolverName::AddressResolverName(const char *func_name,
}
}
-AddressResolverName::AddressResolverName(RegularExpression &func_regex)
+AddressResolverName::AddressResolverName(RegularExpression func_regex)
: AddressResolver(), m_func_name(nullptr), m_class_name(nullptr),
- m_regex(func_regex), m_match_type(AddressResolver::Regexp) {}
+ m_regex(std::move(func_regex)), m_match_type(AddressResolver::Regexp) {}
AddressResolverName::AddressResolverName(const char *class_name,
const char *method,
@@ -66,8 +67,7 @@ AddressResolverName::~AddressResolverName() = default;
Searcher::CallbackReturn
AddressResolverName::SearchCallback(SearchFilter &filter,
- SymbolContext &context, Address *addr,
- bool containing) {
+ SymbolContext &context, Address *addr) {
SymbolContextList func_list;
SymbolContextList sym_list;
@@ -86,7 +86,6 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
const bool include_symbols = false;
const bool include_inlines = true;
- const bool append = false;
switch (m_match_type) {
case AddressResolver::Exact:
if (context.module_sp) {
@@ -94,7 +93,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_func_name, nullptr,
eFunctionNameTypeAuto, include_symbols,
- include_inlines, append, func_list);
+ include_inlines, func_list);
}
break;
@@ -103,7 +102,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
context.module_sp->FindSymbolsMatchingRegExAndType(
m_regex, eSymbolTypeCode, sym_list);
context.module_sp->FindFunctions(m_regex, include_symbols,
- include_inlines, append, func_list);
+ include_inlines, func_list);
}
break;
diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp
index a67cb925d648..0afd897a2093 100644
--- a/source/Core/Communication.cpp
+++ b/source/Core/Communication.cpp
@@ -46,9 +46,10 @@ Communication::Communication(const char *name)
m_callback(nullptr), m_callback_baton(nullptr), m_close_on_eof(true)
{
- lldb_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Communication (name = %s)", this, name);
+
+ LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
+ LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::Communication (name = {1})", this, name);
SetEventName(eBroadcastBitDisconnected, "disconnected");
SetEventName(eBroadcastBitReadThreadGotBytes, "got bytes");
@@ -61,10 +62,10 @@ Communication::Communication(const char *name)
}
Communication::~Communication() {
- lldb_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::~Communication (name = %s)", this,
- GetBroadcasterName().AsCString());
+ LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
+ LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::~Communication (name = {1})", this,
+ GetBroadcasterName().AsCString());
Clear();
}
@@ -77,9 +78,8 @@ void Communication::Clear() {
ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
Clear();
- lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Connect (url = %s)",
- this, url);
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::Connect (url = {1})", this, url);
lldb::ConnectionSP connection_sp(m_connection_sp);
if (connection_sp)
@@ -90,8 +90,8 @@ ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
}
ConnectionStatus Communication::Disconnect(Status *error_ptr) {
- lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Disconnect ()", this);
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::Disconnect ()", this);
lldb::ConnectionSP connection_sp(m_connection_sp);
if (connection_sp) {
@@ -173,11 +173,10 @@ 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_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::Write (src = %p, src_len = %" PRIu64
- ") connection = %p",
- this, src, (uint64_t)src_len, connection_sp.get());
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::Write (src = {1}, src_len = %" PRIu64
+ ") connection = {2}",
+ this, src, (uint64_t)src_len, connection_sp.get());
if (connection_sp)
return connection_sp->Write(src, src_len, status, error_ptr);
@@ -195,8 +194,8 @@ bool Communication::StartReadThread(Status *error_ptr) {
if (m_read_thread.IsJoinable())
return true;
- lldb_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_COMMUNICATION, "%p Communication::StartReadThread ()", this);
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::StartReadThread ()", this);
char thread_name[1024];
snprintf(thread_name, sizeof(thread_name), "<lldb.comm.%s>",
@@ -228,8 +227,8 @@ bool Communication::StopReadThread(Status *error_ptr) {
if (!m_read_thread.IsJoinable())
return true;
- lldb_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_COMMUNICATION, "%p Communication::StopReadThread ()", this);
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::StopReadThread ()", this);
m_read_thread_enabled = false;
@@ -270,11 +269,10 @@ 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_private::LogIfAnyCategoriesSet(
- LIBLLDB_LOG_COMMUNICATION,
- "%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64
- ", broadcast = %i)",
- this, bytes, (uint64_t)len, broadcast);
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
+ "{0} Communication::AppendBytesToCache (src = {1}, src_len = {2}, "
+ "broadcast = {3})",
+ this, bytes, (uint64_t)len, broadcast);
if ((bytes == nullptr || len == 0) &&
(status != lldb::eConnectionStatusEndOfFile))
return;
@@ -310,8 +308,7 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
- if (log)
- log->Printf("%p Communication::ReadThread () thread starting...", p);
+ LLDB_LOGF(log, "%p Communication::ReadThread () thread starting...", p);
uint8_t buf[1024];
@@ -366,7 +363,7 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
}
log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION);
if (log)
- log->Printf("%p Communication::ReadThread () thread exiting...", p);
+ LLDB_LOGF(log, "%p Communication::ReadThread () thread exiting...", p);
comm->m_read_thread_did_exit = true;
// Let clients know that this thread is exiting
diff --git a/source/Core/CoreProperties.td b/source/Core/CoreProperties.td
new file mode 100644
index 000000000000..014927c65c6f
--- /dev/null
+++ b/source/Core/CoreProperties.td
@@ -0,0 +1,118 @@
+include "../../include/lldb/Core/PropertiesBase.td"
+
+let Definition = "modulelist" in {
+ def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">;
+ def ClangModulesCachePath: Property<"clang-modules-cache-path", "FileSpec">,
+ Global,
+ DefaultStringValue<"">,
+ Desc<"The path to the clang modules cache directory (-fmodules-cache-path).">;
+}
+
+let Definition = "debugger" in {
+ def AutoConfirm: Property<"auto-confirm", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"If true all confirmation prompts will receive their default reply.">;
+ def DisassemblyFormat: Property<"disassembly-format", "FormatEntity">,
+ Global,
+ DefaultStringValue<"{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${function.changed}\\\\n{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${current-pc-arrow} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: ">,
+ Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
+ def FrameFormat: Property<"frame-format", "FormatEntity">,
+ Global,
+ DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
+ Desc<"The default frame format string to use when displaying stack frame information for threads.">;
+ def NotiftVoid: Property<"notify-void", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"Notify the user explicitly if an expression returns void (default: false).">;
+ def Prompt: Property<"prompt", "String">,
+ Global,
+ DefaultEnumValue<"OptionValueString::eOptionEncodeCharacterEscapeSequences">,
+ DefaultStringValue<"(lldb) ">,
+ Desc<"The debugger command line prompt displayed for the user.">;
+ def ScriptLanguage: Property<"script-lang", "Enum">,
+ Global,
+ DefaultEnumValue<"eScriptLanguagePython">,
+ EnumValues<"OptionEnumValues(g_language_enumerators)">,
+ Desc<"The script language to be used for evaluating user-written scripts.">;
+ def StopDisassemblyCount: Property<"stop-disassembly-count", "SInt64">,
+ Global,
+ DefaultUnsignedValue<4>,
+ Desc<"The number of disassembly lines to show when displaying a stopped context.">;
+ def StopDisassemblyDisplay: Property<"stop-disassembly-display", "Enum">,
+ Global,
+ DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
+ EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
+ Desc<"Control when to display disassembly when displaying a stopped context.">;
+ def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
+ Global,
+ DefaultUnsignedValue<3>,
+ Desc<"The number of sources lines to display that come after the current source line when displaying a stopped context.">;
+ def StopLineCountBefore: Property<"stop-line-count-before", "SInt64">,
+ Global,
+ DefaultUnsignedValue<3>,
+ Desc<"The number of sources lines to display that come before the current source line when displaying a stopped context.">;
+ def HighlightSource: Property<"highlight-source", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will highlight the displayed source code.">;
+ def StopShowColumn: Property<"stop-show-column", "Enum">,
+ DefaultEnumValue<"eStopShowColumnAnsiOrCaret">,
+ EnumValues<"OptionEnumValues(s_stop_show_column_values)">,
+ Desc<"If true, LLDB will use the column information from the debug info to mark the current position when displaying a stopped context.">;
+ 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.">;
+ 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.">;
+ def TerminalWidth: Property<"term-width", "SInt64">,
+ Global,
+ DefaultUnsignedValue<80>,
+ Desc<"The maximum number of columns to use for displaying text.">;
+ def ThreadFormat: Property<"thread-format", "FormatEntity">,
+ Global,
+ DefaultStringValue<"thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\\\\nReturn value: ${thread.return-value}}{\\\\nCompleted expression: ${thread.completed-expression}}\\\\n">,
+ Desc<"The default thread format string to use when displaying thread information.">;
+ def ThreadStopFormat: Property<"thread-stop-format", "FormatEntity">,
+ Global,
+ DefaultStringValue<"thread #${thread.index}{, name = '${thread.name}'}{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}{, activity = ${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}{, ${thread.info.trace_messages} messages}{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}{\\\\nReturn value: ${thread.return-value}}{\\\\nCompleted expression: ${thread.completed-expression}}\\\\n">,
+ Desc<"The default thread format string to use when displaying thread information as part of the stop display.">;
+ def UseExternalEditor: Property<"use-external-editor", "Boolean">,
+ Global,
+ DefaultFalse,
+ Desc<"Whether to use an external editor or not.">;
+ def UseColor: Property<"use-color", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Whether to use Ansi color codes or not.">;
+ def AutoOneLineSummaries: Property<"auto-one-line-summaries", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will automatically display small structs in one-liner format (default: true).">;
+ def AutoIndent: Property<"auto-indent", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will auto indent/outdent code. Currently only supported in the REPL (default: true).">;
+ def PrintDecls: Property<"print-decls", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will print the values of variables declared in an expression. Currently only supported in the REPL (default: true).">;
+ def TabSize: Property<"tab-size", "UInt64">,
+ Global,
+ DefaultUnsignedValue<4>,
+ Desc<"The tab size to use when indenting code in multi-line input mode (default: 4).">;
+ def EscapeNonPrintables: Property<"escape-non-printables", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will automatically escape non-printable and escape characters when formatting strings.">;
+ def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
+ Global,
+ DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
+ Desc<"The default frame format string to use when displaying stack frameinformation for threads from thread backtrace unique.">;
+}
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 1a69fc582d0c..18397d00dcaa 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -93,22 +93,47 @@ static DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
- {Debugger::eStopDisassemblyTypeNever, "never",
- "Never show disassembly when displaying a stop context."},
- {Debugger::eStopDisassemblyTypeNoDebugInfo, "no-debuginfo",
- "Show disassembly when there is no debug information."},
- {Debugger::eStopDisassemblyTypeNoSource, "no-source",
- "Show disassembly when there is no source information, or the source file "
- "is missing when displaying a stop context."},
- {Debugger::eStopDisassemblyTypeAlways, "always",
- "Always show disassembly when displaying a stop context."} };
+ {
+ Debugger::eStopDisassemblyTypeNever,
+ "never",
+ "Never show disassembly when displaying a stop context.",
+ },
+ {
+ Debugger::eStopDisassemblyTypeNoDebugInfo,
+ "no-debuginfo",
+ "Show disassembly when there is no debug information.",
+ },
+ {
+ Debugger::eStopDisassemblyTypeNoSource,
+ "no-source",
+ "Show disassembly when there is no source information, or the source "
+ "file "
+ "is missing when displaying a stop context.",
+ },
+ {
+ Debugger::eStopDisassemblyTypeAlways,
+ "always",
+ "Always show disassembly when displaying a stop context.",
+ },
+};
static constexpr OptionEnumValueElement g_language_enumerators[] = {
- {eScriptLanguageNone, "none", "Disable scripting languages."},
- {eScriptLanguagePython, "python",
- "Select python as the default scripting language."},
- {eScriptLanguageDefault, "default",
- "Select the lldb default as the default scripting language."} };
+ {
+ eScriptLanguageNone,
+ "none",
+ "Disable scripting languages.",
+ },
+ {
+ eScriptLanguagePython,
+ "python",
+ "Select python as the default scripting language.",
+ },
+ {
+ eScriptLanguageDefault,
+ "default",
+ "Select the lldb default as the default scripting language.",
+ },
+};
#define MODULE_WITH_FUNC \
"{ " \
@@ -189,133 +214,39 @@ static constexpr OptionEnumValueElement g_language_enumerators[] = {
// without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}:
static constexpr OptionEnumValueElement s_stop_show_column_values[] = {
- {eStopShowColumnAnsiOrCaret, "ansi-or-caret",
- "Highlight the stop column with ANSI terminal codes when color/ANSI mode "
- "is enabled; otherwise, fall back to using a text-only caret (^) as if "
- "\"caret-only\" mode was selected."},
- {eStopShowColumnAnsi, "ansi", "Highlight the stop column with ANSI "
- "terminal codes when running LLDB with "
- "color/ANSI enabled."},
- {eStopShowColumnCaret, "caret",
- "Highlight the stop column with a caret character (^) underneath the stop "
- "column. This method introduces a new line in source listings that "
- "display thread stop locations."},
- {eStopShowColumnNone, "none", "Do not highlight the stop column."}};
-
-static constexpr PropertyDefinition g_properties[] = {
- {"auto-confirm", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "If true all confirmation prompts will receive their default reply."},
- {"disassembly-format", OptionValue::eTypeFormatEntity, true, 0,
- DEFAULT_DISASSEMBLY_FORMAT, {},
- "The default disassembly format "
- "string to use when disassembling "
- "instruction sequences."},
- {"frame-format", OptionValue::eTypeFormatEntity, true, 0,
- DEFAULT_FRAME_FORMAT, {},
- "The default frame format string to use "
- "when displaying stack frame information "
- "for threads."},
- {"notify-void", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "Notify the user explicitly if an expression returns void (default: "
- "false)."},
- {"prompt", OptionValue::eTypeString, true,
- OptionValueString::eOptionEncodeCharacterEscapeSequences, "(lldb) ", {},
- "The debugger command line prompt displayed for the user."},
- {"script-lang", OptionValue::eTypeEnum, true, eScriptLanguagePython,
- nullptr, OptionEnumValues(g_language_enumerators),
- "The script language to be used for evaluating user-written scripts."},
- {"stop-disassembly-count", OptionValue::eTypeSInt64, true, 4, nullptr, {},
- "The number of disassembly lines to show when displaying a "
- "stopped context."},
- {"stop-disassembly-display", OptionValue::eTypeEnum, true,
- Debugger::eStopDisassemblyTypeNoDebugInfo, nullptr,
- OptionEnumValues(g_show_disassembly_enum_values),
- "Control when to display disassembly when displaying a stopped context."},
- {"stop-line-count-after", OptionValue::eTypeSInt64, true, 3, nullptr, {},
- "The number of sources lines to display that come after the "
- "current source line when displaying a stopped context."},
- {"stop-line-count-before", OptionValue::eTypeSInt64, true, 3, nullptr, {},
- "The number of sources lines to display that come before the "
- "current source line when displaying a stopped context."},
- {"highlight-source", OptionValue::eTypeBoolean, true, true, nullptr, {},
- "If true, LLDB will highlight the displayed source code."},
- {"stop-show-column", OptionValue::eTypeEnum, false,
- eStopShowColumnAnsiOrCaret, nullptr, OptionEnumValues(s_stop_show_column_values),
- "If true, LLDB will use the column information from the debug info to "
- "mark the current position when displaying a stopped context."},
- {"stop-show-column-ansi-prefix", OptionValue::eTypeString, true, 0,
- "${ansi.underline}", {},
- "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."},
- {"stop-show-column-ansi-suffix", OptionValue::eTypeString, true, 0,
- "${ansi.normal}", {},
- "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."},
- {"term-width", OptionValue::eTypeSInt64, true, 80, nullptr, {},
- "The maximum number of columns to use for displaying text."},
- {"thread-format", OptionValue::eTypeFormatEntity, true, 0,
- DEFAULT_THREAD_FORMAT, {},
- "The default thread format string to use "
- "when displaying thread information."},
- {"thread-stop-format", OptionValue::eTypeFormatEntity, true, 0,
- DEFAULT_THREAD_STOP_FORMAT, {},
- "The default thread format "
- "string to use when displaying thread "
- "information as part of the stop display."},
- {"use-external-editor", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "Whether to use an external editor or not."},
- {"use-color", OptionValue::eTypeBoolean, true, true, nullptr, {},
- "Whether to use Ansi color codes or not."},
- {"auto-one-line-summaries", OptionValue::eTypeBoolean, true, true, nullptr,
- {},
- "If true, LLDB will automatically display small structs in "
- "one-liner format (default: true)."},
- {"auto-indent", OptionValue::eTypeBoolean, true, true, nullptr, {},
- "If true, LLDB will auto indent/outdent code. Currently only supported in "
- "the REPL (default: true)."},
- {"print-decls", OptionValue::eTypeBoolean, true, true, nullptr, {},
- "If true, LLDB will print the values of variables declared in an "
- "expression. Currently only supported in the REPL (default: true)."},
- {"tab-size", OptionValue::eTypeUInt64, true, 4, nullptr, {},
- "The tab size to use when indenting code in multi-line input mode "
- "(default: 4)."},
- {"escape-non-printables", OptionValue::eTypeBoolean, true, true, nullptr,
- {},
- "If true, LLDB will automatically escape non-printable and "
- "escape characters when formatting strings."},
- {"frame-format-unique", OptionValue::eTypeFormatEntity, true, 0,
- DEFAULT_FRAME_FORMAT_NO_ARGS, {},
- "The default frame format string to use when displaying stack frame"
- "information for threads from thread backtrace unique."}};
+ {
+ eStopShowColumnAnsiOrCaret,
+ "ansi-or-caret",
+ "Highlight the stop column with ANSI terminal codes when color/ANSI "
+ "mode is enabled; otherwise, fall back to using a text-only caret (^) "
+ "as if \"caret-only\" mode was selected.",
+ },
+ {
+ eStopShowColumnAnsi,
+ "ansi",
+ "Highlight the stop column with ANSI terminal codes when running LLDB "
+ "with color/ANSI enabled.",
+ },
+ {
+ eStopShowColumnCaret,
+ "caret",
+ "Highlight the stop column with a caret character (^) underneath the "
+ "stop column. This method introduces a new line in source listings "
+ "that display thread stop locations.",
+ },
+ {
+ eStopShowColumnNone,
+ "none",
+ "Do not highlight the stop column.",
+ },
+};
+
+#define LLDB_PROPERTIES_debugger
+#include "CoreProperties.inc"
enum {
- ePropertyAutoConfirm = 0,
- ePropertyDisassemblyFormat,
- ePropertyFrameFormat,
- ePropertyNotiftVoid,
- ePropertyPrompt,
- ePropertyScriptLanguage,
- ePropertyStopDisassemblyCount,
- ePropertyStopDisassemblyDisplay,
- ePropertyStopLineCountAfter,
- ePropertyStopLineCountBefore,
- ePropertyHighlightSource,
- ePropertyStopShowColumn,
- ePropertyStopShowColumnAnsiPrefix,
- ePropertyStopShowColumnAnsiSuffix,
- ePropertyTerminalWidth,
- ePropertyThreadFormat,
- ePropertyThreadStopFormat,
- ePropertyUseExternalEditor,
- ePropertyUseColor,
- ePropertyAutoOneLineSummaries,
- ePropertyAutoIndent,
- ePropertyPrintDecls,
- ePropertyTabSize,
- ePropertyEscapeNonPrintables,
- ePropertyFrameFormatUnique,
+#define LLDB_PROPERTIES_debugger
+#include "CorePropertiesEnum.inc"
};
LoadPluginCallbackType Debugger::g_load_plugin_callback = nullptr;
@@ -324,8 +255,16 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
VarSetOperationType op,
llvm::StringRef property_path,
llvm::StringRef value) {
- bool is_load_script = (property_path == "target.load-script-from-symbol-file");
- bool is_escape_non_printables = (property_path == "escape-non-printables");
+ bool is_load_script =
+ (property_path == "target.load-script-from-symbol-file");
+ // These properties might change how we visualize data.
+ bool invalidate_data_vis = (property_path == "escape-non-printables");
+ invalidate_data_vis |=
+ (property_path == "target.max-zero-padding-in-float-format");
+ if (invalidate_data_vis) {
+ DataVisualization::ForceUpdate();
+ }
+
TargetSP target_sp;
LoadScriptFromSymFile load_script_old_value;
if (is_load_script && exe_ctx->GetTargetSP()) {
@@ -336,18 +275,18 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
Status error(Properties::SetPropertyValue(exe_ctx, op, property_path, value));
if (error.Success()) {
// FIXME it would be nice to have "on-change" callbacks for properties
- if (property_path == g_properties[ePropertyPrompt].name) {
+ if (property_path == g_debugger_properties[ePropertyPrompt].name) {
llvm::StringRef new_prompt = GetPrompt();
- std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes(
+ std::string str = lldb_private::ansi::FormatAnsiTerminalCodes(
new_prompt, GetUseColor());
if (str.length())
new_prompt = str;
GetCommandInterpreter().UpdatePrompt(new_prompt);
- auto bytes = llvm::make_unique<EventDataBytes>(new_prompt);
+ auto bytes = std::make_unique<EventDataBytes>(new_prompt);
auto prompt_change_event_sp = std::make_shared<Event>(
CommandInterpreter::eBroadcastBitResetPrompt, bytes.release());
GetCommandInterpreter().BroadcastEvent(prompt_change_event_sp);
- } else if (property_path == g_properties[ePropertyUseColor].name) {
+ } else if (property_path == g_debugger_properties[ePropertyUseColor].name) {
// use-color changed. Ping the prompt so it can reset the ansi terminal
// codes.
SetPrompt(GetPrompt());
@@ -358,18 +297,14 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
std::list<Status> errors;
StreamString feedback_stream;
if (!target_sp->LoadScriptingResources(errors, &feedback_stream)) {
- StreamFileSP stream_sp(GetErrorFile());
- if (stream_sp) {
- for (auto error : errors) {
- stream_sp->Printf("%s\n", error.AsCString());
- }
- if (feedback_stream.GetSize())
- stream_sp->PutCString(feedback_stream.GetString());
+ Stream &s = GetErrorStream();
+ for (auto error : errors) {
+ s.Printf("%s\n", error.AsCString());
}
+ if (feedback_stream.GetSize())
+ s.PutCString(feedback_stream.GetString());
}
}
- } else if (is_escape_non_printables) {
- DataVisualization::ForceUpdate();
}
}
return error;
@@ -378,7 +313,7 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
bool Debugger::GetAutoConfirm() const {
const uint32_t idx = ePropertyAutoConfirm;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
}
const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const {
@@ -399,13 +334,13 @@ const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const {
bool Debugger::GetNotifyVoid() const {
const uint32_t idx = ePropertyNotiftVoid;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
}
llvm::StringRef Debugger::GetPrompt() const {
const uint32_t idx = ePropertyPrompt;
return m_collection_sp->GetPropertyAtIndexAsString(
- nullptr, idx, g_properties[idx].default_cstr_value);
+ nullptr, idx, g_debugger_properties[idx].default_cstr_value);
}
void Debugger::SetPrompt(llvm::StringRef p) {
@@ -413,7 +348,7 @@ void Debugger::SetPrompt(llvm::StringRef p) {
m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, p);
llvm::StringRef new_prompt = GetPrompt();
std::string str =
- lldb_utility::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor());
+ lldb_private::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor());
if (str.length())
new_prompt = str;
GetCommandInterpreter().UpdatePrompt(new_prompt);
@@ -437,7 +372,7 @@ const FormatEntity::Entry *Debugger::GetThreadStopFormat() const {
lldb::ScriptLanguage Debugger::GetScriptLanguage() const {
const uint32_t idx = ePropertyScriptLanguage;
return (lldb::ScriptLanguage)m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) {
@@ -449,7 +384,7 @@ bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) {
uint32_t Debugger::GetTerminalWidth() const {
const uint32_t idx = ePropertyTerminalWidth;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
bool Debugger::SetTerminalWidth(uint32_t term_width) {
@@ -460,7 +395,7 @@ bool Debugger::SetTerminalWidth(uint32_t term_width) {
bool Debugger::GetUseExternalEditor() const {
const uint32_t idx = ePropertyUseExternalEditor;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
}
bool Debugger::SetUseExternalEditor(bool b) {
@@ -471,7 +406,7 @@ bool Debugger::SetUseExternalEditor(bool b) {
bool Debugger::GetUseColor() const {
const uint32_t idx = ePropertyUseColor;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
}
bool Debugger::SetUseColor(bool b) {
@@ -484,13 +419,13 @@ bool Debugger::SetUseColor(bool b) {
bool Debugger::GetHighlightSource() const {
const uint32_t idx = ePropertyHighlightSource;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
StopShowColumn Debugger::GetStopShowColumn() const {
const uint32_t idx = ePropertyStopShowColumn;
return (lldb::StopShowColumn)m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
llvm::StringRef Debugger::GetStopShowColumnAnsiPrefix() const {
@@ -507,20 +442,20 @@ uint32_t Debugger::GetStopSourceLineCount(bool before) const {
const uint32_t idx =
before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
Debugger::StopDisassemblyType Debugger::GetStopDisassemblyDisplay() const {
const uint32_t idx = ePropertyStopDisassemblyDisplay;
return (Debugger::StopDisassemblyType)
m_collection_sp->GetPropertyAtIndexAsEnumeration(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
uint32_t Debugger::GetDisassemblyLineCount() const {
const uint32_t idx = ePropertyStopDisassemblyCount;
return m_collection_sp->GetPropertyAtIndexAsSInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
bool Debugger::GetAutoOneLineSummaries() const {
@@ -556,7 +491,7 @@ bool Debugger::SetPrintDecls(bool b) {
uint32_t Debugger::GetTabSize() const {
const uint32_t idx = ePropertyTabSize;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
- nullptr, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_debugger_properties[idx].default_uint_value);
}
bool Debugger::SetTabSize(uint32_t tab_size) {
@@ -717,8 +652,7 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
}
}
-DebuggerSP
-Debugger::FindDebuggerWithInstanceName(ConstString instance_name) {
+DebuggerSP Debugger::FindDebuggerWithInstanceName(ConstString instance_name) {
DebuggerSP debugger_sp;
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr);
@@ -764,16 +698,16 @@ TargetSP Debugger::FindTargetWithProcess(Process *process) {
Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
: UserID(g_unique_id++),
Properties(std::make_shared<OptionValueProperties>()),
- m_input_file_sp(std::make_shared<StreamFile>(stdin, false)),
- m_output_file_sp(std::make_shared<StreamFile>(stdout, false)),
- m_error_file_sp(std::make_shared<StreamFile>(stderr, false)),
+ m_input_file_sp(std::make_shared<NativeFile>(stdin, false)),
+ m_output_stream_sp(std::make_shared<StreamFile>(stdout, false)),
+ m_error_stream_sp(std::make_shared<StreamFile>(stderr, false)),
m_input_recorder(nullptr),
m_broadcaster_manager_sp(BroadcasterManager::MakeBroadcasterManager()),
m_terminal_state(), m_target_list(*this), m_platform_list(),
m_listener_sp(Listener::MakeListener("lldb.Debugger")),
m_source_manager_up(), m_source_file_cache(),
m_command_interpreter_up(
- llvm::make_unique<CommandInterpreter>(*this, false)),
+ std::make_unique<CommandInterpreter>(*this, false)),
m_script_interpreter_sp(), m_input_reader_stack(), m_instance_name(),
m_loaded_plugins(), m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
@@ -790,7 +724,10 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
assert(default_platform_sp);
m_platform_list.Append(default_platform_sp, true);
- m_collection_sp->Initialize(g_properties);
+ m_dummy_target_sp = m_target_list.GetDummyTarget(*this);
+ assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?");
+
+ m_collection_sp->Initialize(g_debugger_properties);
m_collection_sp->AppendProperty(
ConstString("target"),
ConstString("Settings specify to debugging targets."), true,
@@ -818,7 +755,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
if (term && !strcmp(term, "dumb"))
SetUseColor(false);
// Turn off use-color if we don't write to a terminal with color support.
- if (!m_output_file_sp->GetFile().GetIsTerminalWithColors())
+ if (!GetOutputFile().GetIsTerminalWithColors())
SetUseColor(false);
#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
@@ -859,8 +796,7 @@ void Debugger::Clear() {
// Close the input file _before_ we close the input read communications
// class as it does NOT own the input file, our m_input_file does.
m_terminal_state.Clear();
- if (m_input_file_sp)
- m_input_file_sp->GetFile().Close();
+ GetInputFile().Close();
m_command_interpreter_up->Clear();
});
@@ -885,57 +821,29 @@ void Debugger::SetAsyncExecution(bool async_execution) {
repro::DataRecorder *Debugger::GetInputRecorder() { return m_input_recorder; }
-void Debugger::SetInputFileHandle(FILE *fh, bool tranfer_ownership,
- repro::DataRecorder *recorder) {
+void Debugger::SetInputFile(FileSP file_sp, repro::DataRecorder *recorder) {
+ assert(file_sp && file_sp->IsValid());
m_input_recorder = recorder;
- if (m_input_file_sp)
- m_input_file_sp->GetFile().SetStream(fh, tranfer_ownership);
- else
- m_input_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
-
- File &in_file = m_input_file_sp->GetFile();
- if (!in_file.IsValid())
- in_file.SetStream(stdin, true);
-
+ m_input_file_sp = file_sp;
// Save away the terminal state if that is relevant, so that we can restore
// it in RestoreInputState.
SaveInputTerminalState();
}
-void Debugger::SetOutputFileHandle(FILE *fh, bool tranfer_ownership) {
- if (m_output_file_sp)
- m_output_file_sp->GetFile().SetStream(fh, tranfer_ownership);
- else
- m_output_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
-
- File &out_file = m_output_file_sp->GetFile();
- if (!out_file.IsValid())
- out_file.SetStream(stdout, false);
-
- // Do not create the ScriptInterpreter just for setting the output file
- // handle as the constructor will know how to do the right thing on its own.
- if (ScriptInterpreter *script_interpreter =
- GetScriptInterpreter(/*can_create=*/false))
- script_interpreter->ResetOutputFileHandle(fh);
+void Debugger::SetOutputFile(FileSP file_sp) {
+ assert(file_sp && file_sp->IsValid());
+ m_output_stream_sp = std::make_shared<StreamFile>(file_sp);
}
-void Debugger::SetErrorFileHandle(FILE *fh, bool tranfer_ownership) {
- if (m_error_file_sp)
- m_error_file_sp->GetFile().SetStream(fh, tranfer_ownership);
- else
- m_error_file_sp = std::make_shared<StreamFile>(fh, tranfer_ownership);
-
- File &err_file = m_error_file_sp->GetFile();
- if (!err_file.IsValid())
- err_file.SetStream(stderr, false);
+void Debugger::SetErrorFile(FileSP file_sp) {
+ assert(file_sp && file_sp->IsValid());
+ m_error_stream_sp = std::make_shared<StreamFile>(file_sp);
}
void Debugger::SaveInputTerminalState() {
- if (m_input_file_sp) {
- File &in_file = m_input_file_sp->GetFile();
- if (in_file.GetDescriptor() != File::kInvalidDescriptor)
- m_terminal_state.Save(in_file.GetDescriptor(), true);
- }
+ int fd = GetInputFile().GetDescriptor();
+ if (fd != File::kInvalidDescriptor)
+ m_terminal_state.Save(fd, true);
}
void Debugger::RestoreInputTerminalState() { m_terminal_state.Restore(); }
@@ -1016,8 +924,9 @@ bool Debugger::CheckTopIOHandlerTypes(IOHandler::Type top_type,
}
void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) {
- lldb::StreamFileSP stream = is_stdout ? GetOutputFile() : GetErrorFile();
- m_input_reader_stack.PrintAsync(stream.get(), s, len);
+ lldb_private::StreamFile &stream =
+ is_stdout ? GetOutputStream() : GetErrorStream();
+ m_input_reader_stack.PrintAsync(&stream, s, len);
}
ConstString Debugger::GetTopIOHandlerControlSequence(char ch) {
@@ -1054,8 +963,7 @@ void Debugger::RunIOHandler(const IOHandlerSP &reader_sp) {
}
}
-void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in,
- StreamFileSP &out,
+void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
StreamFileSP &err) {
// Before an IOHandler runs, it must have in/out/err streams. This function
// is called when one ore more of the streams are nullptr. We use the top
@@ -1065,37 +973,34 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in,
std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
// If no STDIN has been set, then set it appropriately
- if (!in) {
+ if (!in || !in->IsValid()) {
if (top_reader_sp)
- in = top_reader_sp->GetInputStreamFile();
+ in = top_reader_sp->GetInputFileSP();
else
- in = GetInputFile();
-
+ in = GetInputFileSP();
// If there is nothing, use stdin
if (!in)
- in = std::make_shared<StreamFile>(stdin, false);
+ in = std::make_shared<NativeFile>(stdin, false);
}
// If no STDOUT has been set, then set it appropriately
- if (!out) {
+ if (!out || !out->GetFile().IsValid()) {
if (top_reader_sp)
- out = top_reader_sp->GetOutputStreamFile();
+ out = top_reader_sp->GetOutputStreamFileSP();
else
- out = GetOutputFile();
-
+ out = GetOutputStreamSP();
// If there is nothing, use stdout
if (!out)
out = std::make_shared<StreamFile>(stdout, false);
}
// If no STDERR has been set, then set it appropriately
- if (!err) {
+ if (!err || !err->GetFile().IsValid()) {
if (top_reader_sp)
- err = top_reader_sp->GetErrorStreamFile();
+ err = top_reader_sp->GetErrorStreamFileSP();
else
- err = GetErrorFile();
-
+ err = GetErrorStreamSP();
// If there is nothing, use stderr
if (!err)
- err = std::make_shared<StreamFile>(stdout, false);
+ err = std::make_shared<StreamFile>(stderr, false);
}
}
@@ -1263,15 +1168,15 @@ bool Debugger::EnableLog(llvm::StringRef channel,
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()->GetFile().GetDescriptor(), !should_close, unbuffered);
+ GetOutputFile().GetDescriptor(), !should_close, unbuffered);
} 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) {
- llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_Text;
+ llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text;
if (log_options & LLDB_LOG_OPTION_APPEND)
- flags |= llvm::sys::fs::F_Append;
+ flags |= llvm::sys::fs::OF_Append;
int FD;
if (std::error_code ec = llvm::sys::fs::openFileForWrite(
log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
@@ -1308,7 +1213,7 @@ ScriptInterpreter *Debugger::GetScriptInterpreter(bool can_create) {
SourceManager &Debugger::GetSourceManager() {
if (!m_source_manager_up)
- m_source_manager_up = llvm::make_unique<SourceManager>(shared_from_this());
+ m_source_manager_up = std::make_unique<SourceManager>(shared_from_this());
return *m_source_manager_up;
}
@@ -1360,60 +1265,23 @@ void Debugger::HandleBreakpointEvent(const EventSP &event_sp) {
// }
}
-size_t Debugger::GetProcessSTDOUT(Process *process, Stream *stream) {
- size_t total_bytes = 0;
- if (stream == nullptr)
- stream = GetOutputFile().get();
+void Debugger::FlushProcessOutput(Process &process, bool flush_stdout,
+ bool flush_stderr) {
+ const auto &flush = [&](Stream &stream,
+ size_t (Process::*get)(char *, size_t, Status &)) {
+ Status error;
+ size_t len;
+ char buffer[1024];
+ while ((len = (process.*get)(buffer, sizeof(buffer), error)) > 0)
+ stream.Write(buffer, len);
+ stream.Flush();
+ };
- if (stream) {
- // The process has stuff waiting for stdout; get it and write it out to the
- // appropriate place.
- if (process == nullptr) {
- TargetSP target_sp = GetTargetList().GetSelectedTarget();
- if (target_sp)
- process = target_sp->GetProcessSP().get();
- }
- if (process) {
- Status error;
- size_t len;
- char stdio_buffer[1024];
- while ((len = process->GetSTDOUT(stdio_buffer, sizeof(stdio_buffer),
- error)) > 0) {
- stream->Write(stdio_buffer, len);
- total_bytes += len;
- }
- }
- stream->Flush();
- }
- return total_bytes;
-}
-
-size_t Debugger::GetProcessSTDERR(Process *process, Stream *stream) {
- size_t total_bytes = 0;
- if (stream == nullptr)
- stream = GetOutputFile().get();
-
- if (stream) {
- // The process has stuff waiting for stderr; get it and write it out to the
- // appropriate place.
- if (process == nullptr) {
- TargetSP target_sp = GetTargetList().GetSelectedTarget();
- if (target_sp)
- process = target_sp->GetProcessSP().get();
- }
- if (process) {
- Status error;
- size_t len;
- char stdio_buffer[1024];
- while ((len = process->GetSTDERR(stdio_buffer, sizeof(stdio_buffer),
- error)) > 0) {
- stream->Write(stdio_buffer, len);
- total_bytes += len;
- }
- }
- stream->Flush();
- }
- return total_bytes;
+ std::lock_guard<std::mutex> guard(m_output_flush_mutex);
+ if (flush_stdout)
+ flush(*GetAsyncOutputStream(), &Process::GetSTDOUT);
+ if (flush_stderr)
+ flush(*GetAsyncErrorStream(), &Process::GetSTDERR);
}
// This function handles events that were broadcast by the process.
@@ -1453,15 +1321,9 @@ void Debugger::HandleProcessEvent(const EventSP &event_sp) {
pop_process_io_handler);
}
- // Now display and STDOUT
- if (got_stdout || got_state_changed) {
- GetProcessSTDOUT(process_sp.get(), output_stream_sp.get());
- }
-
- // Now display and STDERR
- if (got_stderr || got_state_changed) {
- GetProcessSTDERR(process_sp.get(), error_stream_sp.get());
- }
+ // Now display STDOUT and STDERR
+ FlushProcessOutput(*process_sp, got_stdout || got_state_changed,
+ got_stderr || got_state_changed);
// Give structured data events an opportunity to display.
if (got_structured_data) {
@@ -1638,8 +1500,9 @@ bool Debugger::StartEventHandlerThread() {
eBroadcastBitEventThreadIsListening);
auto thread_name =
- full_name.GetLength() < llvm::get_max_thread_name_length() ?
- full_name.AsCString() : "dbg.evt-handler";
+ full_name.GetLength() < llvm::get_max_thread_name_length()
+ ? full_name.AsCString()
+ : "dbg.evt-handler";
// Use larger 8MB stack for this thread
llvm::Expected<HostThread> event_handler_thread =
@@ -1700,8 +1563,7 @@ bool Debugger::StartIOHandlerThread() {
void Debugger::StopIOHandlerThread() {
if (m_io_handler_thread.IsJoinable()) {
- if (m_input_file_sp)
- m_input_file_sp->GetFile().Close();
+ GetInputFile().Close();
m_io_handler_thread.Join(nullptr);
}
}
@@ -1714,10 +1576,6 @@ void Debugger::JoinIOHandlerThread() {
}
}
-Target *Debugger::GetDummyTarget() {
- return m_target_list.GetDummyTarget(*this).get();
-}
-
Target *Debugger::GetSelectedOrDummyTarget(bool prefer_dummy) {
Target *target = nullptr;
if (!prefer_dummy) {
@@ -1734,13 +1592,11 @@ Status Debugger::RunREPL(LanguageType language, const char *repl_options) {
FileSpec repl_executable;
if (language == eLanguageTypeUnknown) {
- std::set<LanguageType> repl_languages;
-
- Language::GetLanguagesSupportingREPLs(repl_languages);
+ LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
- if (repl_languages.size() == 1) {
- language = *repl_languages.begin();
- } else if (repl_languages.empty()) {
+ if (auto single_lang = repl_languages.GetSingularLanguage()) {
+ language = *single_lang;
+ } else if (repl_languages.Empty()) {
err.SetErrorStringWithFormat(
"LLDB isn't configured with REPL support for any languages.");
return err;
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index af7cf82d470a..89ae25cbad64 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -158,52 +158,58 @@ size_t Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
return success_count;
}
-bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
- const char *plugin_name, const char *flavor,
- const ExecutionContext &exe_ctx,
- ConstString name, Module *module,
- uint32_t num_instructions,
- bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines,
- uint32_t options, Stream &strm) {
+bool Disassembler::Disassemble(
+ Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+ const char *flavor, const ExecutionContext &exe_ctx, ConstString name,
+ Module *module, uint32_t num_instructions, bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options, Stream &strm) {
+ // If no name is given there's nothing to disassemble.
+ if (!name)
+ return false;
+
+ const bool include_symbols = true;
+ const bool include_inlines = true;
+
+ // Find functions matching the given name.
SymbolContextList sc_list;
- if (name) {
- const bool include_symbols = true;
- const bool include_inlines = true;
- if (module) {
- module->FindFunctions(name, nullptr, eFunctionNameTypeAuto,
- include_symbols, include_inlines, true, sc_list);
- } else if (exe_ctx.GetTargetPtr()) {
- exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
- name, eFunctionNameTypeAuto, include_symbols, include_inlines, false,
- sc_list);
- }
+ if (module) {
+ module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, include_symbols,
+ include_inlines, sc_list);
+ } else if (exe_ctx.GetTargetPtr()) {
+ exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
+ name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);
}
- if (sc_list.GetSize()) {
- return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, sc_list,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
- }
- return false;
+ // If no functions were found there's nothing to disassemble.
+ if (sc_list.IsEmpty())
+ return false;
+
+ return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, sc_list,
+ num_instructions, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
}
lldb::DisassemblerSP Disassembler::DisassembleRange(
const ArchSpec &arch, const char *plugin_name, const char *flavor,
const ExecutionContext &exe_ctx, const AddressRange &range,
bool prefer_file_cache) {
- lldb::DisassemblerSP disasm_sp;
- if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid()) {
- disasm_sp = Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch,
- flavor, plugin_name);
-
- if (disasm_sp) {
- size_t bytes_disassembled = disasm_sp->ParseInstructions(
- &exe_ctx, range, nullptr, prefer_file_cache);
- if (bytes_disassembled == 0)
- disasm_sp.reset();
- }
- }
+ if (range.GetByteSize() <= 0)
+ return {};
+
+ if (!range.GetBaseAddress().IsValid())
+ return {};
+
+ lldb::DisassemblerSP disasm_sp = Disassembler::FindPluginForTarget(
+ exe_ctx.GetTargetSP(), arch, flavor, plugin_name);
+
+ if (!disasm_sp)
+ return {};
+
+ const size_t bytes_disassembled =
+ disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
+ if (bytes_disassembled == 0)
+ return {};
+
return disasm_sp;
}
@@ -212,20 +218,20 @@ Disassembler::DisassembleBytes(const ArchSpec &arch, const char *plugin_name,
const char *flavor, const Address &start,
const void *src, size_t src_len,
uint32_t num_instructions, bool data_from_file) {
- lldb::DisassemblerSP disasm_sp;
+ if (!src)
+ return {};
- if (src) {
- disasm_sp = Disassembler::FindPlugin(arch, flavor, plugin_name);
+ lldb::DisassemblerSP disasm_sp =
+ Disassembler::FindPlugin(arch, flavor, plugin_name);
- if (disasm_sp) {
- DataExtractor data(src, src_len, arch.GetByteOrder(),
- arch.GetAddressByteSize());
+ if (!disasm_sp)
+ return {};
- (void)disasm_sp->DecodeInstructions(start, data, 0, num_instructions,
- false, data_from_file);
- }
- }
+ DataExtractor data(src, src_len, arch.GetByteOrder(),
+ arch.GetAddressByteSize());
+ (void)disasm_sp->DecodeInstructions(start, data, 0, num_instructions, false,
+ data_from_file);
return disasm_sp;
}
@@ -237,27 +243,28 @@ bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
- if (disasm_range.GetByteSize()) {
- lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
- exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
-
- if (disasm_sp) {
- AddressRange range;
- ResolveAddress(exe_ctx, disasm_range.GetBaseAddress(),
- range.GetBaseAddress());
- range.SetByteSize(disasm_range.GetByteSize());
- const bool prefer_file_cache = false;
- size_t bytes_disassembled = disasm_sp->ParseInstructions(
- &exe_ctx, range, &strm, prefer_file_cache);
- if (bytes_disassembled == 0)
- return false;
-
- return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
- }
- }
- return false;
+ if (!disasm_range.GetByteSize())
+ return false;
+
+ lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
+ exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
+
+ if (!disasm_sp)
+ return false;
+
+ AddressRange range;
+ ResolveAddress(exe_ctx, disasm_range.GetBaseAddress(),
+ range.GetBaseAddress());
+ range.SetByteSize(disasm_range.GetByteSize());
+ const bool prefer_file_cache = false;
+ size_t bytes_disassembled =
+ disasm_sp->ParseInstructions(&exe_ctx, range, &strm, prefer_file_cache);
+ if (bytes_disassembled == 0)
+ return false;
+
+ return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
+ num_instructions, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
}
bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
@@ -268,42 +275,51 @@ bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
- if (num_instructions > 0) {
- lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
- exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
- if (disasm_sp) {
- Address addr;
- ResolveAddress(exe_ctx, start_address, addr);
- const bool prefer_file_cache = false;
- size_t bytes_disassembled = disasm_sp->ParseInstructions(
- &exe_ctx, addr, num_instructions, prefer_file_cache);
- if (bytes_disassembled == 0)
- return false;
- return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
- }
- }
- return false;
+ if (num_instructions == 0)
+ return false;
+
+ lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
+ exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
+ if (!disasm_sp)
+ return false;
+
+ Address addr;
+ ResolveAddress(exe_ctx, start_address, addr);
+
+ const bool prefer_file_cache = false;
+ size_t bytes_disassembled = disasm_sp->ParseInstructions(
+ &exe_ctx, addr, num_instructions, prefer_file_cache);
+ if (bytes_disassembled == 0)
+ return false;
+
+ return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
+ num_instructions, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
}
Disassembler::SourceLine
Disassembler::GetFunctionDeclLineEntry(const SymbolContext &sc) {
+ if (!sc.function)
+ return {};
+
+ if (!sc.line_entry.IsValid())
+ return {};
+
+ LineEntry prologue_end_line = sc.line_entry;
+ FileSpec func_decl_file;
+ uint32_t func_decl_line;
+ sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line);
+
+ if (func_decl_file != prologue_end_line.file &&
+ func_decl_file != prologue_end_line.original_file)
+ return {};
+
SourceLine decl_line;
- if (sc.function && sc.line_entry.IsValid()) {
- LineEntry prologue_end_line = sc.line_entry;
- FileSpec func_decl_file;
- uint32_t func_decl_line;
- sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line);
- if (func_decl_file == prologue_end_line.file ||
- func_decl_file == prologue_end_line.original_file) {
- decl_line.file = func_decl_file;
- decl_line.line = func_decl_line;
- // TODO do we care about column on these entries? If so, we need to
- // plumb that through GetStartLineSourceInfo.
- decl_line.column = 0;
- }
- }
+ decl_line.file = func_decl_file;
+ decl_line.line = func_decl_line;
+ // TODO: Do we care about column on these entries? If so, we need to plumb
+ // that through GetStartLineSourceInfo.
+ decl_line.column = 0;
return decl_line;
}
@@ -355,12 +371,9 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
const char *function_name =
sc.GetFunctionName(Mangled::ePreferDemangledWithoutArguments)
.GetCString();
- if (function_name) {
- RegularExpression::Match regex_match(1);
- if (avoid_regex->Execute(function_name, &regex_match)) {
- // skip this source line
- return true;
- }
+ if (function_name && avoid_regex->Execute(function_name)) {
+ // skip this source line
+ return true;
}
}
// don't skip this source line
@@ -793,10 +806,9 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
std::string value;
static RegularExpression g_reg_exp(
llvm::StringRef("^[ \t]*([^ \t]+)[ \t]*$"));
- RegularExpression::Match regex_match(1);
- bool reg_exp_success = g_reg_exp.Execute(line, &regex_match);
- if (reg_exp_success)
- regex_match.GetMatchAtIndex(line.c_str(), 1, value);
+ llvm::SmallVector<llvm::StringRef, 2> matches;
+ if (g_reg_exp.Execute(line, &matches))
+ value = matches[1].str();
else
value = line;
@@ -856,14 +868,15 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
if (!line.empty()) {
static RegularExpression g_reg_exp(llvm::StringRef(
"^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"));
- RegularExpression::Match regex_match(2);
- bool reg_exp_success = g_reg_exp.Execute(line, &regex_match);
+ llvm::SmallVector<llvm::StringRef, 3> matches;
+
+ bool reg_exp_success = g_reg_exp.Execute(line, &matches);
std::string key;
std::string value;
if (reg_exp_success) {
- regex_match.GetMatchAtIndex(line.c_str(), 1, key);
- regex_match.GetMatchAtIndex(line.c_str(), 2, value);
+ key = matches[1].str();
+ value = matches[2].str();
} else {
out_stream->Printf("Instruction::ReadDictionary: Failure executing "
"regular expression.\n");
diff --git a/source/Core/DumpDataExtractor.cpp b/source/Core/DumpDataExtractor.cpp
index aa84370e223a..12e98de2675c 100644
--- a/source/Core/DumpDataExtractor.cpp
+++ b/source/Core/DumpDataExtractor.cpp
@@ -14,20 +14,18 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/ModuleList.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/CanonicalType.h"
-
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include <limits>
@@ -64,8 +62,12 @@ static float half2float(uint16_t half) {
return u.f * ldexpf(1, -112);
}
-static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
- lldb::offset_t byte_size, llvm::APInt &result) {
+static llvm::Optional<llvm::APInt> GetAPInt(const DataExtractor &data,
+ lldb::offset_t *offset_ptr,
+ lldb::offset_t byte_size) {
+ if (byte_size == 0)
+ return llvm::None;
+
llvm::SmallVector<uint64_t, 2> uint64_array;
lldb::offset_t bytes_left = byte_size;
uint64_t u64;
@@ -81,8 +83,7 @@ static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
}
uint64_array.push_back(u64);
}
- result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
- return true;
+ return llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
} else if (byte_order == lldb::eByteOrderBig) {
lldb::offset_t be_offset = *offset_ptr + byte_size;
lldb::offset_t temp_offset;
@@ -101,18 +102,17 @@ static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
uint64_array.push_back(u64);
}
*offset_ptr += byte_size;
- result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
- return true;
+ return llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
}
- return false;
+ return llvm::None;
}
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::APInt apint;
- if (GetAPInt(data, &offset, byte_size, apint)) {
- std::string apint_str(apint.toString(radix, is_signed));
+ llvm::Optional<llvm::APInt> apint = GetAPInt(data, &offset, byte_size);
+ if (apint.hasValue()) {
+ std::string apint_str(apint.getValue().toString(radix, is_signed));
switch (radix) {
case 2:
s->Write("0b", 2);
@@ -555,49 +555,31 @@ lldb::offset_t lldb_private::DumpDataExtractor(
if (exe_scope)
target_sp = exe_scope->CalculateTarget();
if (target_sp) {
- ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
- if (clang_ast) {
- clang::ASTContext *ast = clang_ast->getASTContext();
- if (ast) {
- llvm::SmallVector<char, 256> sv;
- // Show full precision when printing float values
- const unsigned format_precision = 0;
- const unsigned format_max_padding = 100;
- size_t item_bit_size = item_byte_size * 8;
-
- if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
- llvm::APInt apint(item_bit_size,
- DE.GetMaxU64(&offset, item_byte_size));
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- } else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
- llvm::APInt apint;
- if (GetAPInt(DE, &offset, item_byte_size, apint)) {
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
- } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
- const auto &semantics =
- ast->getFloatTypeSemantics(ast->LongDoubleTy);
-
- offset_t byte_size = item_byte_size;
- if (&semantics == &llvm::APFloatBase::x87DoubleExtended())
- byte_size = (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
-
- llvm::APInt apint;
- if (GetAPInt(DE, &offset, byte_size, apint)) {
- llvm::APFloat apfloat(semantics, apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
- } else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
- llvm::APInt apint(item_bit_size, DE.GetU16(&offset));
- llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
- apint);
- apfloat.toString(sv, format_precision, format_max_padding);
- }
-
+ auto type_system_or_err =
+ target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
+ if (!type_system_or_err) {
+ llvm::consumeError(type_system_or_err.takeError());
+ } else {
+ auto &type_system = *type_system_or_err;
+ llvm::SmallVector<char, 256> sv;
+ // Show full precision when printing float values
+ const unsigned format_precision = 0;
+ const unsigned format_max_padding =
+ target_sp->GetMaxZeroPaddingInFloatFormat();
+
+ const auto &semantics =
+ type_system.GetFloatTypeSemantics(item_byte_size);
+
+ // Recalculate the byte size in case of a difference. This is possible
+ // when item_byte_size is 16 (128-bit), because you could get back the
+ // x87DoubleExtended semantics which has a byte size of 10 (80-bit).
+ const size_t semantics_byte_size =
+ (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
+ llvm::Optional<llvm::APInt> apint =
+ GetAPInt(DE, &offset, semantics_byte_size);
+ if (apint.hasValue()) {
+ llvm::APFloat apfloat(semantics, apint.getValue());
+ apfloat.toString(sv, format_precision, format_max_padding);
if (!sv.empty()) {
s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data());
used_upfloat = true;
diff --git a/source/Core/FileLineResolver.cpp b/source/Core/FileLineResolver.cpp
index 3cba1c7e8143..01df295398a8 100644
--- a/source/Core/FileLineResolver.cpp
+++ b/source/Core/FileLineResolver.cpp
@@ -33,7 +33,7 @@ FileLineResolver::~FileLineResolver() {}
Searcher::CallbackReturn
FileLineResolver::SearchCallback(SearchFilter &filter, SymbolContext &context,
- Address *addr, bool containing) {
+ Address *addr) {
CompileUnit *cu = context.comp_unit;
if (m_inlines ||
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp
index 1ffbed2cd64e..c90828f40989 100644
--- a/source/Core/FormatEntity.cpp
+++ b/source/Core/FormatEntity.cpp
@@ -514,24 +514,24 @@ static bool ScanBracketedRange(llvm::StringRef subpath,
close_bracket_index = llvm::StringRef::npos;
const size_t open_bracket_index = subpath.find('[');
if (open_bracket_index == llvm::StringRef::npos) {
- if (log)
- log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely");
+ LLDB_LOGF(log,
+ "[ScanBracketedRange] no bracketed range, skipping entirely");
return false;
}
close_bracket_index = subpath.find(']', open_bracket_index + 1);
if (close_bracket_index == llvm::StringRef::npos) {
- if (log)
- log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely");
+ LLDB_LOGF(log,
+ "[ScanBracketedRange] no bracketed range, skipping entirely");
return false;
} else {
var_name_final_if_array_range = subpath.data() + open_bracket_index;
if (close_bracket_index - open_bracket_index == 1) {
- if (log)
- log->Printf(
- "[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
+ LLDB_LOGF(
+ log,
+ "[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
index_lower = 0;
} else {
const size_t separator_index = subpath.find('-', open_bracket_index + 1);
@@ -540,22 +540,21 @@ static bool ScanBracketedRange(llvm::StringRef subpath,
const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
index_higher = index_lower;
- if (log)
- log->Printf("[ScanBracketedRange] [%" PRId64
- "] detected, high index is same",
- index_lower);
+ LLDB_LOGF(log,
+ "[ScanBracketedRange] [%" PRId64
+ "] detected, high index is same",
+ index_lower);
} else {
const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
const char *index_higher_cstr = subpath.data() + separator_index + 1;
index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
index_higher = ::strtoul(index_higher_cstr, nullptr, 0);
- if (log)
- log->Printf("[ScanBracketedRange] [%" PRId64 "-%" PRId64 "] detected",
- index_lower, index_higher);
+ LLDB_LOGF(log,
+ "[ScanBracketedRange] [%" PRId64 "-%" PRId64 "] detected",
+ index_lower, index_higher);
}
if (index_lower > index_higher && index_higher > 0) {
- if (log)
- log->Printf("[ScanBracketedRange] swapping indices");
+ LLDB_LOGF(log, "[ScanBracketedRange] swapping indices");
const int64_t temp = index_lower;
index_lower = index_higher;
index_higher = temp;
@@ -627,9 +626,8 @@ static ValueObjectSP ExpandIndexedExpression(ValueObject *valobj, size_t index,
const char *ptr_deref_format = "[%d]";
std::string ptr_deref_buffer(10, 0);
::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
- if (log)
- log->Printf("[ExpandIndexedExpression] name to deref: %s",
- ptr_deref_buffer.c_str());
+ LLDB_LOGF(log, "[ExpandIndexedExpression] name to deref: %s",
+ ptr_deref_buffer.c_str());
ValueObject::GetValueForExpressionPathOptions options;
ValueObject::ExpressionPathEndResultType final_value_type;
ValueObject::ExpressionPathScanEndReason reason_to_stop;
@@ -640,15 +638,15 @@ static ValueObjectSP ExpandIndexedExpression(ValueObject *valobj, size_t index,
ptr_deref_buffer.c_str(), &reason_to_stop, &final_value_type, options,
&what_next);
if (!item) {
- if (log)
- log->Printf("[ExpandIndexedExpression] ERROR: why stopping = %d,"
- " final_value_type %d",
- reason_to_stop, final_value_type);
+ LLDB_LOGF(log,
+ "[ExpandIndexedExpression] ERROR: why stopping = %d,"
+ " final_value_type %d",
+ reason_to_stop, final_value_type);
} else {
- if (log)
- log->Printf("[ExpandIndexedExpression] ALL RIGHT: why stopping = %d,"
- " final_value_type %d",
- reason_to_stop, final_value_type);
+ LLDB_LOGF(log,
+ "[ExpandIndexedExpression] ALL RIGHT: why stopping = %d,"
+ " final_value_type %d",
+ reason_to_stop, final_value_type);
}
return item;
}
@@ -770,9 +768,8 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
const std::string &expr_path = entry.string;
- if (log)
- log->Printf("[Debugger::FormatPrompt] symbol to expand: %s",
- expr_path.c_str());
+ LLDB_LOGF(log, "[Debugger::FormatPrompt] symbol to expand: %s",
+ expr_path.c_str());
target =
valobj
@@ -781,16 +778,16 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
.get();
if (!target) {
- if (log)
- log->Printf("[Debugger::FormatPrompt] ERROR: why stopping = %d,"
- " final_value_type %d",
- reason_to_stop, final_value_type);
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] ERROR: why stopping = %d,"
+ " final_value_type %d",
+ reason_to_stop, final_value_type);
return false;
} else {
- if (log)
- log->Printf("[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d,"
- " final_value_type %d",
- reason_to_stop, final_value_type);
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d,"
+ " final_value_type %d",
+ reason_to_stop, final_value_type);
target = target
->GetQualifiedRepresentationIfAvailable(
target->GetDynamicValueType(), true)
@@ -814,18 +811,16 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
Status error;
target = target->Dereference(error).get();
if (error.Fail()) {
- if (log)
- log->Printf("[Debugger::FormatPrompt] ERROR: %s\n",
- error.AsCString("unknown"));
+ LLDB_LOGF(log, "[Debugger::FormatPrompt] ERROR: %s\n",
+ error.AsCString("unknown"));
return false;
}
do_deref_pointer = false;
}
if (!target) {
- if (log)
- log->Printf("[Debugger::FormatPrompt] could not calculate target for "
- "prompt expression");
+ LLDB_LOGF(log, "[Debugger::FormatPrompt] could not calculate target for "
+ "prompt expression");
return false;
}
@@ -860,18 +855,16 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
// exceptions
{
StreamString str_temp;
- if (log)
- log->Printf(
- "[Debugger::FormatPrompt] I am into array || pointer && !range");
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] I am into array || pointer && !range");
if (target->HasSpecialPrintableRepresentation(val_obj_display,
custom_format)) {
// try to use the special cases
bool success = target->DumpPrintableRepresentation(
str_temp, val_obj_display, custom_format);
- if (log)
- log->Printf("[Debugger::FormatPrompt] special cases did%s match",
- success ? "" : "n't");
+ LLDB_LOGF(log, "[Debugger::FormatPrompt] special cases did%s match",
+ success ? "" : "n't");
// should not happen
if (success)
@@ -909,17 +902,16 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
}
if (!is_array_range) {
- if (log)
- log->Printf("[Debugger::FormatPrompt] dumping ordinary printable output");
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] dumping ordinary printable output");
return target->DumpPrintableRepresentation(s, val_obj_display,
custom_format);
} else {
- if (log)
- log->Printf("[Debugger::FormatPrompt] checking if I can handle as array");
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] checking if I can handle as array");
if (!is_array && !is_pointer)
return false;
- if (log)
- log->Printf("[Debugger::FormatPrompt] handle as array");
+ LLDB_LOGF(log, "[Debugger::FormatPrompt] handle as array");
StreamString special_directions_stream;
llvm::StringRef special_directions;
if (close_bracket_index != llvm::StringRef::npos &&
@@ -965,15 +957,15 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
.get();
if (!item) {
- if (log)
- log->Printf("[Debugger::FormatPrompt] ERROR in getting child item at "
- "index %" PRId64,
- index);
+ LLDB_LOGF(log,
+ "[Debugger::FormatPrompt] ERROR in getting child item at "
+ "index %" PRId64,
+ index);
} else {
- if (log)
- log->Printf(
- "[Debugger::FormatPrompt] special_directions for child item: %s",
- special_directions.data() ? special_directions.data() : "");
+ LLDB_LOGF(
+ log,
+ "[Debugger::FormatPrompt] special_directions for child item: %s",
+ special_directions.data() ? special_directions.data() : "");
}
if (special_directions.empty()) {
@@ -2354,34 +2346,31 @@ static void AddMatches(const FormatEntity::Entry::Definition *def,
}
}
-size_t FormatEntity::AutoComplete(CompletionRequest &request) {
- llvm::StringRef str = request.GetCursorArgumentPrefix().str();
-
- request.SetWordComplete(false);
- str = str.drop_front(request.GetMatchStartPoint());
+void FormatEntity::AutoComplete(CompletionRequest &request) {
+ llvm::StringRef str = request.GetCursorArgumentPrefix();
const size_t dollar_pos = str.rfind('$');
if (dollar_pos == llvm::StringRef::npos)
- return 0;
+ return;
// Hitting TAB after $ at the end of the string add a "{"
if (dollar_pos == str.size() - 1) {
std::string match = str.str();
match.append("{");
request.AddCompletion(match);
- return 1;
+ return;
}
if (str[dollar_pos + 1] != '{')
- return 0;
+ return;
const size_t close_pos = str.find('}', dollar_pos + 2);
if (close_pos != llvm::StringRef::npos)
- return 0;
+ return;
const size_t format_pos = str.find('%', dollar_pos + 2);
if (format_pos != llvm::StringRef::npos)
- return 0;
+ return;
llvm::StringRef partial_variable(str.substr(dollar_pos + 2));
if (partial_variable.empty()) {
@@ -2389,7 +2378,7 @@ size_t FormatEntity::AutoComplete(CompletionRequest &request) {
StringList new_matches;
AddMatches(&g_root, str, llvm::StringRef(), new_matches);
request.AddCompletions(new_matches);
- return request.GetNumberOfMatches();
+ return;
}
// We have a partially specified variable, find it
@@ -2397,7 +2386,7 @@ size_t FormatEntity::AutoComplete(CompletionRequest &request) {
const FormatEntity::Entry::Definition *entry_def =
FindEntry(partial_variable, &g_root, remainder);
if (!entry_def)
- return 0;
+ return;
const size_t n = entry_def->num_children;
@@ -2409,7 +2398,6 @@ size_t FormatEntity::AutoComplete(CompletionRequest &request) {
} else {
// "${thread.id" <TAB>
request.AddCompletion(MakeMatch(str, "}"));
- request.SetWordComplete(true);
}
} else if (remainder.equals(".")) {
// "${thread." <TAB>
@@ -2423,5 +2411,4 @@ size_t FormatEntity::AutoComplete(CompletionRequest &request) {
AddMatches(entry_def, str, remainder, new_matches);
request.AddCompletions(new_matches);
}
- return request.GetNumberOfMatches();
}
diff --git a/source/Core/Highlighter.cpp b/source/Core/Highlighter.cpp
index 0b0aa969bf65..c3c614aac210 100644
--- a/source/Core/Highlighter.cpp
+++ b/source/Core/Highlighter.cpp
@@ -13,6 +13,7 @@
#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
+using namespace lldb_private::ansi;
void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const {
s << m_prefix << value << m_suffix;
@@ -20,8 +21,8 @@ void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const {
void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix,
llvm::StringRef suffix) {
- m_prefix = lldb_utility::ansi::FormatAnsiTerminalCodes(prefix);
- m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix);
+ m_prefix = FormatAnsiTerminalCodes(prefix);
+ m_suffix = FormatAnsiTerminalCodes(suffix);
}
void DefaultHighlighter::Highlight(const HighlightStyle &options,
diff --git a/source/Core/IOHandler.cpp b/source/Core/IOHandler.cpp
index b30308490cca..46be29f6fbf9 100644
--- a/source/Core/IOHandler.cpp
+++ b/source/Core/IOHandler.cpp
@@ -52,7 +52,7 @@
#include "llvm/ADT/StringRef.h"
-#ifdef _MSC_VER
+#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
#endif
@@ -70,10 +70,14 @@
using namespace lldb;
using namespace lldb_private;
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
: IOHandler(debugger, type,
- StreamFileSP(), // Adopt STDIN from top input reader
+ FileSP(), // Adopt STDIN from top input reader
StreamFileSP(), // Adopt STDOUT from top input reader
StreamFileSP(), // Adopt STDERR from top input reader
0, // Flags
@@ -81,7 +85,7 @@ IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
) {}
IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type,
- const lldb::StreamFileSP &input_sp,
+ const lldb::FileSP &input_sp,
const lldb::StreamFileSP &output_sp,
const lldb::StreamFileSP &error_sp, uint32_t flags,
repro::DataRecorder *data_recorder)
@@ -98,7 +102,7 @@ IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type,
IOHandler::~IOHandler() = default;
int IOHandler::GetInputFD() {
- return (m_input_sp ? m_input_sp->GetFile().GetDescriptor() : -1);
+ return (m_input_sp ? m_input_sp->GetDescriptor() : -1);
}
int IOHandler::GetOutputFD() {
@@ -110,7 +114,7 @@ int IOHandler::GetErrorFD() {
}
FILE *IOHandler::GetInputFILE() {
- return (m_input_sp ? m_input_sp->GetFile().GetStream() : nullptr);
+ return (m_input_sp ? m_input_sp->GetStream() : nullptr);
}
FILE *IOHandler::GetOutputFILE() {
@@ -121,18 +125,18 @@ FILE *IOHandler::GetErrorFILE() {
return (m_error_sp ? m_error_sp->GetFile().GetStream() : nullptr);
}
-StreamFileSP &IOHandler::GetInputStreamFile() { return m_input_sp; }
+FileSP &IOHandler::GetInputFileSP() { return m_input_sp; }
-StreamFileSP &IOHandler::GetOutputStreamFile() { return m_output_sp; }
+StreamFileSP &IOHandler::GetOutputStreamFileSP() { return m_output_sp; }
-StreamFileSP &IOHandler::GetErrorStreamFile() { return m_error_sp; }
+StreamFileSP &IOHandler::GetErrorStreamFileSP() { return m_error_sp; }
bool IOHandler::GetIsInteractive() {
- return GetInputStreamFile()->GetFile().GetIsInteractive();
+ return GetInputFileSP() ? GetInputFileSP()->GetIsInteractive() : false;
}
bool IOHandler::GetIsRealTerminal() {
- return GetInputStreamFile()->GetFile().GetIsRealTerminal();
+ return GetInputFileSP() ? GetInputFileSP()->GetIsRealTerminal() : false;
}
void IOHandler::SetPopped(bool b) { m_popped.SetValue(b, eBroadcastOnChange); }
@@ -170,18 +174,11 @@ IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
IOHandlerConfirm::~IOHandlerConfirm() = default;
-int IOHandlerConfirm::IOHandlerComplete(
- IOHandler &io_handler, const char *current_line, const char *cursor,
- const char *last_char, int skip_first_n_matches, int max_matches,
- StringList &matches, StringList &descriptions) {
- if (current_line == cursor) {
- if (m_default_response) {
- matches.AppendString("y");
- } else {
- matches.AppendString("n");
- }
- }
- return matches.GetSize();
+void IOHandlerConfirm::IOHandlerComplete(IOHandler &io_handler,
+ CompletionRequest &request) {
+ if (request.GetRawCursorPos() != 0)
+ return;
+ request.AddCompletion(m_default_response ? "y" : "n");
}
void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
@@ -219,47 +216,20 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
}
}
-int IOHandlerDelegate::IOHandlerComplete(
- IOHandler &io_handler, const char *current_line, const char *cursor,
- const char *last_char, int skip_first_n_matches, int max_matches,
- StringList &matches, StringList &descriptions) {
+void IOHandlerDelegate::IOHandlerComplete(IOHandler &io_handler,
+ CompletionRequest &request) {
switch (m_completion) {
case Completion::None:
break;
-
case Completion::LLDBCommand:
- return io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(
- current_line, cursor, last_char, skip_first_n_matches, max_matches,
- matches, descriptions);
- case Completion::Expression: {
- CompletionResult result;
- CompletionRequest request(current_line, current_line - cursor,
- skip_first_n_matches, max_matches, result);
+ io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(request);
+ break;
+ case Completion::Expression:
CommandCompletions::InvokeCommonCompletionCallbacks(
io_handler.GetDebugger().GetCommandInterpreter(),
CommandCompletions::eVariablePathCompletion, request, nullptr);
- result.GetMatches(matches);
- result.GetDescriptions(descriptions);
-
- size_t num_matches = request.GetNumberOfMatches();
- if (num_matches > 0) {
- std::string common_prefix;
- matches.LongestCommonPrefix(common_prefix);
- const size_t partial_name_len = request.GetCursorArgumentPrefix().size();
-
- // If we matched a unique single command, add a space... Only do this if
- // the completer told us this was a complete word, however...
- if (num_matches == 1 && request.GetWordComplete()) {
- common_prefix.push_back(' ');
- }
- common_prefix.erase(0, partial_name_len);
- matches.InsertStringAtIndex(0, std::move(common_prefix));
- }
- return num_matches;
- } break;
+ break;
}
-
- return 0;
}
IOHandlerEditline::IOHandlerEditline(
@@ -269,7 +239,7 @@ IOHandlerEditline::IOHandlerEditline(
bool multi_line, bool color_prompts, uint32_t line_number_start,
IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
: IOHandlerEditline(debugger, type,
- StreamFileSP(), // Inherit input from top input reader
+ FileSP(), // Inherit input from top input reader
StreamFileSP(), // Inherit output from top input reader
StreamFileSP(), // Inherit error from top input reader
0, // Flags
@@ -278,9 +248,9 @@ IOHandlerEditline::IOHandlerEditline(
line_number_start, delegate, data_recorder) {}
IOHandlerEditline::IOHandlerEditline(
- Debugger &debugger, IOHandler::Type type,
- const lldb::StreamFileSP &input_sp, const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp, uint32_t flags,
+ Debugger &debugger, IOHandler::Type type, const lldb::FileSP &input_sp,
+ const lldb::StreamFileSP &output_sp, const lldb::StreamFileSP &error_sp,
+ uint32_t flags,
const char *editline_name, // Used for saving history files
llvm::StringRef prompt, llvm::StringRef continuation_prompt,
bool multi_line, bool color_prompts, uint32_t line_number_start,
@@ -300,7 +270,8 @@ IOHandlerEditline::IOHandlerEditline(
#ifndef LLDB_DISABLE_LIBEDIT
bool use_editline = false;
- use_editline = m_input_sp->GetFile().GetIsRealTerminal();
+ use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
if (use_editline) {
m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
@@ -339,92 +310,119 @@ void IOHandlerEditline::Deactivate() {
m_delegate.IOHandlerDeactivated(*this);
}
+// Split out a line from the buffer, if there is a full one to get.
+static Optional<std::string> SplitLine(std::string &line_buffer) {
+ size_t pos = line_buffer.find('\n');
+ if (pos == std::string::npos)
+ return None;
+ std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+ line_buffer = line_buffer.substr(pos + 1);
+ return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional<std::string> SplitLineEOF(std::string &line_buffer) {
+ if (llvm::all_of(line_buffer, isspace))
+ return None;
+ std::string line = std::move(line_buffer);
+ line_buffer.clear();
+ return line;
+}
+
bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_up) {
bool b = m_editline_up->GetLine(line, interrupted);
- if (m_data_recorder)
+ if (b && m_data_recorder)
m_data_recorder->Record(line, true);
return b;
- } else {
+ }
#endif
- line.clear();
- FILE *in = GetInputFILE();
- if (in) {
- if (GetIsInteractive()) {
- const char *prompt = nullptr;
+ line.clear();
- if (m_multi_line && m_curr_line_idx > 0)
- prompt = GetContinuationPrompt();
+ if (GetIsInteractive()) {
+ const char *prompt = nullptr;
- if (prompt == nullptr)
- prompt = GetPrompt();
+ if (m_multi_line && m_curr_line_idx > 0)
+ prompt = GetContinuationPrompt();
- if (prompt && prompt[0]) {
- FILE *out = GetOutputFILE();
- if (out) {
- ::fprintf(out, "%s", prompt);
- ::fflush(out);
- }
- }
+ if (prompt == nullptr)
+ prompt = GetPrompt();
+
+ if (prompt && prompt[0]) {
+ if (m_output_sp) {
+ m_output_sp->Printf("%s", prompt);
+ m_output_sp->Flush();
}
- char buffer[256];
- bool done = false;
- bool got_line = false;
- m_editing = true;
- while (!done) {
+ }
+ }
+
+ Optional<std::string> got_line = SplitLine(m_line_buffer);
+
+ if (!got_line && !m_input_sp) {
+ // No more input file, we are done...
+ SetIsDone(true);
+ return false;
+ }
+
+ FILE *in = GetInputFILE();
+ char buffer[256];
+
+ if (!got_line && !in && m_input_sp) {
+ // there is no FILE*, fall back on just reading bytes from the stream.
+ while (!got_line) {
+ size_t bytes_read = sizeof(buffer);
+ Status error = m_input_sp->Read((void *)buffer, bytes_read);
+ if (error.Success() && !bytes_read) {
+ got_line = SplitLineEOF(m_line_buffer);
+ break;
+ }
+ if (error.Fail())
+ break;
+ m_line_buffer += StringRef(buffer, bytes_read);
+ got_line = SplitLine(m_line_buffer);
+ }
+ }
+
+ if (!got_line && in) {
+ m_editing = true;
+ while (!got_line) {
+ char *r = fgets(buffer, sizeof(buffer), in);
#ifdef _WIN32
- // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
- // according to the docs on MSDN. However, this has evidently been a
- // known bug since Windows 8. Therefore, we can't detect if a signal
- // interrupted in the fgets. So pressing ctrl-c causes the repl to end
- // and the process to exit. A temporary workaround is just to attempt to
- // fgets twice until this bug is fixed.
- if (fgets(buffer, sizeof(buffer), in) == nullptr &&
- fgets(buffer, sizeof(buffer), in) == nullptr) {
-#else
- if (fgets(buffer, sizeof(buffer), in) == nullptr) {
+ // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
+ // according to the docs on MSDN. However, this has evidently been a
+ // known bug since Windows 8. Therefore, we can't detect if a signal
+ // interrupted in the fgets. So pressing ctrl-c causes the repl to end
+ // and the process to exit. A temporary workaround is just to attempt to
+ // fgets twice until this bug is fixed.
+ if (r == nullptr)
+ r = fgets(buffer, sizeof(buffer), in);
+ // this is the equivalent of EINTR for Windows
+ if (r == nullptr && GetLastError() == ERROR_OPERATION_ABORTED)
+ continue;
#endif
- const int saved_errno = errno;
- if (feof(in))
- done = true;
- else if (ferror(in)) {
- if (saved_errno != EINTR)
- done = true;
- }
- } else {
- got_line = true;
- size_t buffer_len = strlen(buffer);
- assert(buffer[buffer_len] == '\0');
- char last_char = buffer[buffer_len - 1];
- if (last_char == '\r' || last_char == '\n') {
- done = true;
- // Strip trailing newlines
- while (last_char == '\r' || last_char == '\n') {
- --buffer_len;
- if (buffer_len == 0)
- break;
- last_char = buffer[buffer_len - 1];
- }
- }
- line.append(buffer, buffer_len);
- }
+ if (r == nullptr) {
+ if (ferror(in) && errno == EINTR)
+ continue;
+ if (feof(in))
+ got_line = SplitLineEOF(m_line_buffer);
+ break;
}
- m_editing = false;
- if (m_data_recorder && got_line)
- m_data_recorder->Record(line, true);
- // We might have gotten a newline on a line by itself make sure to return
- // true in this case.
- return got_line;
- } else {
- // No more input file, we are done...
- SetIsDone(true);
+ m_line_buffer += buffer;
+ got_line = SplitLine(m_line_buffer);
}
- return false;
-#ifndef LLDB_DISABLE_LIBEDIT
+ m_editing = false;
}
-#endif
+
+ if (got_line) {
+ line = got_line.getValue();
+ if (m_data_recorder)
+ m_data_recorder->Record(line, true);
+ }
+
+ return (bool)got_line;
}
#ifndef LLDB_DISABLE_LIBEDIT
@@ -445,16 +443,11 @@ int IOHandlerEditline::FixIndentationCallback(Editline *editline,
*editline_reader, lines, cursor_position);
}
-int IOHandlerEditline::AutoCompleteCallback(
- const char *current_line, const char *cursor, const char *last_char,
- int skip_first_n_matches, int max_matches, StringList &matches,
- StringList &descriptions, void *baton) {
+void IOHandlerEditline::AutoCompleteCallback(CompletionRequest &request,
+ void *baton) {
IOHandlerEditline *editline_reader = (IOHandlerEditline *)baton;
if (editline_reader)
- return editline_reader->m_delegate.IOHandlerComplete(
- *editline_reader, current_line, cursor, last_char, skip_first_n_matches,
- max_matches, matches, descriptions);
- return 0;
+ editline_reader->m_delegate.IOHandlerComplete(*editline_reader, request);
}
#endif
@@ -526,10 +519,11 @@ bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
// Show line numbers if we are asked to
std::string line;
if (m_base_line_number > 0 && GetIsInteractive()) {
- FILE *out = GetOutputFILE();
- if (out)
- ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(),
- GetPrompt() == nullptr ? " " : "");
+ if (m_output_sp) {
+ m_output_sp->Printf("%u%s",
+ m_base_line_number + (uint32_t)lines.GetSize(),
+ GetPrompt() == nullptr ? " " : "");
+ }
}
m_curr_line_idx = lines.GetSize();
@@ -615,7 +609,7 @@ void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
else
#endif
{
-#ifdef _MSC_VER
+#ifdef _WIN32
const char *prompt = GetPrompt();
if (prompt) {
// Back up over previous prompt using Windows API
@@ -630,9 +624,9 @@ void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
}
#endif
IOHandler::PrintAsync(stream, s, len);
-#ifdef _MSC_VER
+#ifdef _WIN32
if (prompt)
- IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
+ IOHandler::PrintAsync(GetOutputStreamFileSP().get(), prompt,
strlen(prompt));
#endif
}
@@ -952,16 +946,9 @@ public:
}
void PutChar(int ch) { ::waddch(m_window, ch); }
void PutCString(const char *s, int len = -1) { ::waddnstr(m_window, s, len); }
- void Refresh() { ::wrefresh(m_window); }
- void DeferredRefresh() {
- // We are using panels, so we don't need to call this...
- //::wnoutrefresh(m_window);
- }
void SetBackground(int color_pair_idx) {
::wbkgd(m_window, COLOR_PAIR(color_pair_idx));
}
- void UnderlineOn() { AttributeOn(A_UNDERLINE); }
- void UnderlineOff() { AttributeOff(A_UNDERLINE); }
void PutCStringTruncated(const char *s, int right_pad) {
int bytes_left = GetWidth() - GetCursorX();
@@ -1213,19 +1200,6 @@ public:
return eKeyNotHandled;
}
- bool SetActiveWindow(Window *window) {
- const size_t num_subwindows = m_subwindows.size();
- for (size_t i = 0; i < num_subwindows; ++i) {
- if (m_subwindows[i].get() == window) {
- m_prev_active_window_idx = m_curr_active_window_idx;
- ::top_panel(window->m_panel);
- m_curr_active_window_idx = i;
- return true;
- }
- }
- return false;
- }
-
WindowSP GetActiveWindow() {
if (!m_subwindows.empty()) {
if (m_curr_active_window_idx >= m_subwindows.size()) {
@@ -1257,8 +1231,6 @@ public:
void SetCanBeActive(bool b) { m_can_activate = b; }
- const WindowDelegateSP &GetDelegate() const { return m_delegate_sp; }
-
void SetDelegate(const WindowDelegateSP &delegate_sp) {
m_delegate_sp = delegate_sp;
}
@@ -1410,12 +1382,8 @@ public:
int GetKeyValue() const { return m_key_value; }
- void SetKeyValue(int key_value) { m_key_value = key_value; }
-
std::string &GetName() { return m_name; }
- std::string &GetKeyName() { return m_key_name; }
-
int GetDrawWidth() const {
return m_max_submenu_name_length + m_max_submenu_key_name_length + 8;
}
@@ -1569,7 +1537,6 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) {
menu->DrawMenuTitle(window, false);
}
window.PutCString(" |");
- window.DeferredRefresh();
} break;
case Menu::Type::Item: {
@@ -1592,7 +1559,6 @@ bool Menu::WindowDelegateDraw(Window &window, bool force) {
submenus[i]->DrawMenuTitle(window, is_selected);
}
window.MoveCursor(cursor_x, cursor_y);
- window.DeferredRefresh();
} break;
default:
@@ -1898,8 +1864,6 @@ public:
return m_window_sp;
}
- WindowDelegates &GetWindowDelegates() { return m_window_delegates; }
-
protected:
WindowSP m_window_sp;
WindowDelegates m_window_delegates;
@@ -1936,9 +1900,7 @@ struct Row {
return 0;
}
- void Expand() {
- expanded = true;
- }
+ void Expand() { expanded = true; }
std::vector<Row> &GetChildren() {
ProcessSP process_sp = value.GetProcessSP();
@@ -2293,8 +2255,6 @@ public:
m_selected_item = nullptr;
}
- window.DeferredRefresh();
-
return true; // Drawing handled
}
@@ -2644,14 +2604,12 @@ protected:
class ValueObjectListDelegate : public WindowDelegate {
public:
ValueObjectListDelegate()
- : 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) {}
+ : 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(), 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) {
+ : 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) {
SetValues(valobj_list);
}
@@ -2694,8 +2652,6 @@ public:
DisplayRows(window, m_rows, g_options);
- window.DeferredRefresh();
-
// Get the selected row
m_selected_row = GetRowForRowIndex(m_selected_row_idx);
// Keep the cursor on the selected row so the highlight and the cursor are
@@ -3800,7 +3756,6 @@ public:
window.Printf(" with status = %i", exit_status);
}
}
- window.DeferredRefresh();
return true;
}
@@ -4258,7 +4213,6 @@ public:
}
}
}
- window.DeferredRefresh();
return true; // Drawing handled
}
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index c6759cc944ca..b06656aa3fb7 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
#include "lldb/Core/Mangled.h"
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include <dbghelp.h>
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
#include "lldb/Core/RichManglingContext.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
#include <string.h>
using namespace lldb_private;
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
- DWORD DemangledLength) {
- static std::mutex M;
- std::lock_guard<std::mutex> Lock(M);
- return ::UnDecorateSymbolName(
- Mangled, Demangled, DemangledLength,
- UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
- // keywords
- UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
- // etc keywords
- UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
- UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
- // specifiers
- UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords
- );
-}
-#endif
-
static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
if (s) {
if (s[0] == '?')
@@ -124,21 +98,6 @@ get_demangled_name_without_arguments(ConstString mangled,
}
#pragma mark Mangled
-// Default constructor
-Mangled::Mangled() : m_mangled(), m_demangled() {}
-
-// Constructor with an optional string and a boolean indicating if it is the
-// mangled version.
-Mangled::Mangled(ConstString s, bool mangled)
- : m_mangled(), m_demangled() {
- if (s)
- SetValue(s, mangled);
-}
-
-Mangled::Mangled(llvm::StringRef name, bool is_mangled) {
- if (!name.empty())
- SetValue(ConstString(name), is_mangled);
-}
Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
if (s)
@@ -150,9 +109,6 @@ Mangled::Mangled(llvm::StringRef name) {
SetValue(ConstString(name));
}
-// Destructor
-Mangled::~Mangled() {}
-
// Convert to pointer operator. This allows code to check any Mangled objects
// to see if they contain anything valid using code such as:
//
@@ -218,28 +174,20 @@ void Mangled::SetValue(ConstString name) {
// Local helpers for different demangling implementations.
static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
- const size_t demangled_length = 2048;
- char *demangled_cstr = static_cast<char *>(::malloc(demangled_length));
- ::ZeroMemory(demangled_cstr, demangled_length);
- DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+ char *demangled_cstr = llvm::microsoftDemangle(
+ M, nullptr, nullptr, nullptr,
+ llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
+ llvm::MSDF_NoCallingConvention |
+ llvm::MSDF_NoMemberType));
if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
if (demangled_cstr && demangled_cstr[0])
- log->Printf("demangled msvc: %s -> \"%s\"", M, demangled_cstr);
+ LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
else
- log->Printf("demangled msvc: %s -> error: 0x%lu", M, result);
+ LLDB_LOGF(log, "demangled msvc: %s -> error", M);
}
- if (result != 0) {
- return demangled_cstr;
- } else {
- ::free(demangled_cstr);
- return nullptr;
- }
-#else
- return nullptr;
-#endif
+ return demangled_cstr;
}
static char *GetItaniumDemangledStr(const char *M) {
@@ -261,9 +209,9 @@ static char *GetItaniumDemangledStr(const char *M) {
if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
if (demangled_cstr)
- log->Printf("demangled itanium: %s -> \"%s\"", M, demangled_cstr);
+ LLDB_LOGF(log, "demangled itanium: %s -> \"%s\"", M, demangled_cstr);
else
- log->Printf("demangled itanium: %s -> error: failed to demangle", M);
+ LLDB_LOGF(log, "demangled itanium: %s -> error: failed to demangle", M);
}
return demangled_cstr;
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 153d5a740936..aef3f3e3b4b0 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -137,14 +137,15 @@ Module::Module(const ModuleSpec &module_spec)
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
LIBLLDB_LOG_MODULES));
if (log != nullptr)
- log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this),
- module_spec.GetArchitecture().GetArchitectureName(),
- module_spec.GetFileSpec().GetPath().c_str(),
- module_spec.GetObjectName().IsEmpty() ? "" : "(",
- module_spec.GetObjectName().IsEmpty()
- ? ""
- : module_spec.GetObjectName().AsCString(""),
- module_spec.GetObjectName().IsEmpty() ? "" : ")");
+ LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
+ static_cast<void *>(this),
+ module_spec.GetArchitecture().GetArchitectureName(),
+ module_spec.GetFileSpec().GetPath().c_str(),
+ module_spec.GetObjectName().IsEmpty() ? "" : "(",
+ module_spec.GetObjectName().IsEmpty()
+ ? ""
+ : module_spec.GetObjectName().AsCString(""),
+ module_spec.GetObjectName().IsEmpty() ? "" : ")");
// First extract all module specifications from the file using the local file
// path. If there are no specifications, then don't fill anything in
@@ -164,7 +165,7 @@ Module::Module(const ModuleSpec &module_spec)
if (!modules_specs.FindMatchingModuleSpec(module_spec,
matching_module_spec)) {
if (log) {
- log->Printf("Found local object file but the specs didn't match");
+ LLDB_LOGF(log, "Found local object file but the specs didn't match");
}
return;
}
@@ -235,11 +236,11 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
LIBLLDB_LOG_MODULES));
if (log != nullptr)
- log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this),
- m_arch.GetArchitectureName(), m_file.GetPath().c_str(),
- m_object_name.IsEmpty() ? "" : "(",
- m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
- m_object_name.IsEmpty() ? "" : ")");
+ LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",
+ static_cast<void *>(this), m_arch.GetArchitectureName(),
+ m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
+ m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
+ m_object_name.IsEmpty() ? "" : ")");
}
Module::Module()
@@ -267,11 +268,11 @@ Module::~Module() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT |
LIBLLDB_LOG_MODULES));
if (log != nullptr)
- log->Printf("%p Module::~Module((%s) '%s%s%s%s')",
- static_cast<void *>(this), m_arch.GetArchitectureName(),
- m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
- m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
- m_object_name.IsEmpty() ? "" : ")");
+ LLDB_LOGF(log, "%p Module::~Module((%s) '%s%s%s%s')",
+ static_cast<void *>(this), m_arch.GetArchitectureName(),
+ m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
+ m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
+ m_object_name.IsEmpty() ? "" : ")");
// Release any auto pointers before we start tearing down our member
// variables since the object file and symbol files might need to make
// function calls back into this module object. The ordering is important
@@ -291,7 +292,7 @@ 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 = llvm::make_unique<DataBufferHeap>(size_to_read, 0);
+ auto data_up = std::make_unique<DataBufferHeap>(size_to_read, 0);
Status readmem_error;
const size_t bytes_read =
process_sp->ReadMemory(header_addr, data_up->GetBytes(),
@@ -352,7 +353,8 @@ void Module::SetUUID(const lldb_private::UUID &uuid) {
}
}
-TypeSystem *Module::GetTypeSystemForLanguage(LanguageType language) {
+llvm::Expected<TypeSystem &>
+Module::GetTypeSystemForLanguage(LanguageType language) {
return m_type_system_map.GetTypeSystemForLanguage(language, this, true);
}
@@ -364,7 +366,7 @@ void Module::ParseAllDebugSymbols() {
SymbolContext sc;
sc.module_sp = shared_from_this();
- SymbolVendor *symbols = GetSymbolVendor();
+ SymbolFile *symbols = GetSymbolFile();
for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
@@ -404,8 +406,7 @@ size_t Module::GetNumCompileUnits() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "Module::GetNumCompileUnits (module = %p)",
static_cast<void *>(this));
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
+ if (SymbolFile *symbols = GetSymbolFile())
return symbols->GetNumCompileUnits();
return 0;
}
@@ -416,8 +417,7 @@ CompUnitSP Module::GetCompileUnitAtIndex(size_t index) {
CompUnitSP cu_sp;
if (index < num_comp_units) {
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
+ if (SymbolFile *symbols = GetSymbolFile())
cu_sp = symbols->GetCompileUnitAtIndex(index);
}
return cu_sp;
@@ -455,8 +455,8 @@ uint32_t Module::ResolveSymbolContextForAddress(
sc.module_sp = shared_from_this();
resolved_flags |= eSymbolContextModule;
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (!sym_vendor)
+ SymbolFile *symfile = GetSymbolFile();
+ if (!symfile)
return resolved_flags;
// Resolve the compile unit, function, block, line table or line entry if
@@ -467,14 +467,14 @@ uint32_t Module::ResolveSymbolContextForAddress(
resolve_scope & eSymbolContextLineEntry ||
resolve_scope & eSymbolContextVariable) {
resolved_flags |=
- sym_vendor->ResolveSymbolContext(so_addr, resolve_scope, sc);
+ symfile->ResolveSymbolContext(so_addr, resolve_scope, sc);
}
// Resolve the symbol if requested, but don't re-look it up if we've
// already found it.
if (resolve_scope & eSymbolContextSymbol &&
!(resolved_flags & eSymbolContextSymbol)) {
- Symtab *symtab = sym_vendor->GetSymtab();
+ Symtab *symtab = symfile->GetSymtab();
if (symtab && so_addr.IsSectionOffset()) {
Symbol *matching_symbol = nullptr;
@@ -507,18 +507,15 @@ uint32_t Module::ResolveSymbolContextForAddress(
// files on MacOSX have an unstripped symbol table inside of them.
ObjectFile *symtab_objfile = symtab->GetObjectFile();
if (symtab_objfile && symtab_objfile->IsStripped()) {
- SymbolFile *symfile = sym_vendor->GetSymbolFile();
- if (symfile) {
- ObjectFile *symfile_objfile = symfile->GetObjectFile();
- if (symfile_objfile != symtab_objfile) {
- Symtab *symfile_symtab = symfile_objfile->GetSymtab();
- if (symfile_symtab) {
- Symbol *symbol =
- symfile_symtab->FindSymbolContainingFileAddress(
- so_addr.GetFileAddress());
- if (symbol && !symbol->IsSynthetic()) {
- sc.symbol = symbol;
- }
+ ObjectFile *symfile_objfile = symfile->GetObjectFile();
+ if (symfile_objfile != symtab_objfile) {
+ Symtab *symfile_symtab = symfile_objfile->GetSymtab();
+ if (symfile_symtab) {
+ Symbol *symbol =
+ symfile_symtab->FindSymbolContainingFileAddress(
+ so_addr.GetFileAddress());
+ if (symbol && !symbol->IsSynthetic()) {
+ sc.symbol = symbol;
}
}
}
@@ -590,40 +587,29 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
const uint32_t initial_count = sc_list.GetSize();
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
+ if (SymbolFile *symbols = GetSymbolFile())
symbols->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope,
sc_list);
return sc_list.GetSize() - initial_count;
}
-size_t Module::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches,
- VariableList &variables) {
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
- return symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches,
- variables);
- return 0;
+void Module::FindGlobalVariables(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, VariableList &variables) {
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
}
-size_t Module::FindGlobalVariables(const RegularExpression &regex,
- size_t max_matches,
- VariableList &variables) {
- SymbolVendor *symbols = GetSymbolVendor();
+void Module::FindGlobalVariables(const RegularExpression &regex,
+ size_t max_matches, VariableList &variables) {
+ SymbolFile *symbols = GetSymbolFile();
if (symbols)
- return symbols->FindGlobalVariables(regex, max_matches, variables);
- return 0;
+ symbols->FindGlobalVariables(regex, max_matches, variables);
}
-size_t Module::FindCompileUnits(const FileSpec &path, bool append,
- SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
- const size_t start_size = sc_list.GetSize();
+void Module::FindCompileUnits(const FileSpec &path,
+ SymbolContextList &sc_list) {
const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
@@ -635,7 +621,6 @@ size_t Module::FindCompileUnits(const FileSpec &path, bool append,
sc_list.Append(sc);
}
}
- return sc_list.GetSize() - start_size;
}
Module::LookupInfo::LookupInfo(ConstString name,
@@ -798,18 +783,15 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
}
-size_t Module::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- FunctionNameType name_type_mask,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
+void Module::FindFunctions(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ FunctionNameType name_type_mask,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
// Find all the functions (not symbols, but debug information functions...
- SymbolVendor *symbols = GetSymbolVendor();
+ SymbolFile *symbols = GetSymbolFile();
if (name_type_mask & eFunctionNameTypeAuto) {
LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
@@ -817,7 +799,7 @@ size_t Module::FindFunctions(ConstString name,
if (symbols) {
symbols->FindFunctions(lookup_info.GetLookupName(), parent_decl_ctx,
lookup_info.GetNameTypeMask(), include_inlines,
- append, sc_list);
+ sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -836,7 +818,7 @@ size_t Module::FindFunctions(ConstString name,
} else {
if (symbols) {
symbols->FindFunctions(name, parent_decl_ctx, name_type_mask,
- include_inlines, append, sc_list);
+ include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -847,21 +829,15 @@ size_t Module::FindFunctions(ConstString name,
}
}
}
-
- return sc_list.GetSize() - old_size;
}
-size_t Module::FindFunctions(const RegularExpression &regex,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
-
+void Module::FindFunctions(const RegularExpression &regex, bool include_symbols,
+ bool include_inlines,
+ SymbolContextList &sc_list) {
const size_t start_size = sc_list.GetSize();
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols) {
- symbols->FindFunctions(regex, include_inlines, append, sc_list);
+ if (SymbolFile *symbols = GetSymbolFile()) {
+ symbols->FindFunctions(regex, include_inlines, sc_list);
// Now check our symbol table for symbols that are code symbols if
// requested
@@ -923,7 +899,6 @@ size_t Module::FindFunctions(const RegularExpression &regex,
}
}
}
- return sc_list.GetSize() - start_size;
}
void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
@@ -945,57 +920,49 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
}
}
-size_t Module::FindTypes_Impl(
+void Module::FindTypes_Impl(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
- bool append, size_t max_matches,
+ size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
- return symbols->FindTypes(name, parent_decl_ctx, append, max_matches,
- searched_symbol_files, types);
- return 0;
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->FindTypes(name, parent_decl_ctx, max_matches,
+ searched_symbol_files, types);
}
-size_t Module::FindTypesInNamespace(ConstString type_name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches, TypeList &type_list) {
- const bool append = true;
+void Module::FindTypesInNamespace(ConstString type_name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, TypeList &type_list) {
TypeMap types_map;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- size_t num_types =
- FindTypes_Impl(type_name, parent_decl_ctx, append, max_matches,
- searched_symbol_files, types_map);
- if (num_types > 0) {
+ FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
+ types_map);
+ if (types_map.GetSize()) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(types_map, type_list);
}
- return num_types;
}
lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
ConstString name, bool exact_match) {
TypeList type_list;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- const size_t num_matches =
- FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
- if (num_matches)
+ FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
+ if (type_list.GetSize())
return type_list.GetTypeAtIndex(0);
return TypeSP();
}
-size_t Module::FindTypes(
+void Module::FindTypes(
ConstString name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types) {
- size_t num_matches = 0;
const char *type_name_cstr = name.GetCString();
llvm::StringRef type_scope;
llvm::StringRef type_basename;
- const bool append = true;
TypeClass type_class = eTypeClassAny;
TypeMap typesmap;
@@ -1008,58 +975,66 @@ size_t Module::FindTypes(
exact_match = type_scope.consume_front("::");
ConstString type_basename_const_str(type_basename);
- if (FindTypes_Impl(type_basename_const_str, nullptr, append, max_matches,
- searched_symbol_files, typesmap)) {
+ FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
+ searched_symbol_files, typesmap);
+ if (typesmap.GetSize())
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
- num_matches = typesmap.GetSize();
- }
} else {
// The type is not in a namespace/class scope, just search for it by
// basename
if (type_class != eTypeClassAny && !type_basename.empty()) {
// The "type_name_cstr" will have been modified if we have a valid type
// class prefix (like "struct", "class", "union", "typedef" etc).
- FindTypes_Impl(ConstString(type_basename), nullptr, append, UINT_MAX,
+ FindTypes_Impl(ConstString(type_basename), nullptr, UINT_MAX,
searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
- num_matches = typesmap.GetSize();
} else {
- num_matches = FindTypes_Impl(name, nullptr, append, UINT_MAX,
- searched_symbol_files, typesmap);
+ FindTypes_Impl(name, nullptr, UINT_MAX, searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
typesmap.RemoveMismatchedTypes(type_scope, name_str, type_class,
exact_match);
- num_matches = typesmap.GetSize();
}
}
}
- if (num_matches > 0) {
+ if (typesmap.GetSize()) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(typesmap, types);
}
- return num_matches;
}
-SymbolVendor *Module::GetSymbolVendor(bool can_create,
- lldb_private::Stream *feedback_strm) {
- if (!m_did_load_symbol_vendor.load()) {
+void Module::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->FindTypes(pattern, languages, types);
+}
+
+SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
+ if (!m_did_load_symfile.load()) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_did_load_symbol_vendor.load() && can_create) {
+ if (!m_did_load_symfile.load() && can_create) {
ObjectFile *obj_file = GetObjectFile();
if (obj_file != nullptr) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
m_symfile_up.reset(
SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
- m_did_load_symbol_vendor = true;
+ m_did_load_symfile = true;
}
}
}
- return m_symfile_up.get();
+ return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
+}
+
+Symtab *Module::GetSymtab() {
+ if (SymbolFile *symbols = GetSymbolFile())
+ return symbols->GetSymtab();
+ return nullptr;
}
void Module::SetFileSpecAndObjectName(const FileSpec &file,
@@ -1232,20 +1207,12 @@ void Module::Dump(Stream *s) {
if (objfile)
objfile->Dump(s);
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
- symbols->Dump(s);
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->Dump(*s);
s->IndentLess();
}
-TypeList *Module::GetTypeList() {
- SymbolVendor *symbols = GetSymbolVendor();
- if (symbols)
- return &symbols->GetTypeList();
- return nullptr;
-}
-
ConstString Module::GetObjectName() const { return m_object_name; }
ObjectFile *Module::GetObjectFile() {
@@ -1295,9 +1262,8 @@ void Module::SectionFileAddressesChanged() {
ObjectFile *obj_file = GetObjectFile();
if (obj_file)
obj_file->SectionFileAddressesChanged();
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (sym_vendor != nullptr)
- sym_vendor->SectionFileAddressesChanged();
+ if (SymbolFile *symbols = GetSymbolFile())
+ symbols->SectionFileAddressesChanged();
}
UnwindTable &Module::GetUnwindTable() {
@@ -1308,7 +1274,7 @@ UnwindTable &Module::GetUnwindTable() {
SectionList *Module::GetUnifiedSectionList() {
if (!m_sections_up)
- m_sections_up = llvm::make_unique<SectionList>();
+ m_sections_up = std::make_unique<SectionList>();
return m_sections_up.get();
}
@@ -1318,13 +1284,9 @@ const Symbol *Module::FindFirstSymbolWithNameAndType(ConstString name,
Timer scoped_timer(
func_cat, "Module::FindFirstSymbolWithNameAndType (name = %s, type = %i)",
name.AsCString(), symbol_type);
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (sym_vendor) {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab)
- return symtab->FindFirstSymbolWithNameAndType(
- name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
- }
+ if (Symtab *symtab = GetSymtab())
+ return symtab->FindFirstSymbolWithNameAndType(
+ name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
return nullptr;
}
void Module::SymbolIndicesToSymbolContextList(
@@ -1345,23 +1307,18 @@ void Module::SymbolIndicesToSymbolContextList(
}
}
-size_t Module::FindFunctionSymbols(ConstString name,
+void Module::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat,
"Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
name.AsCString(), name_type_mask);
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (sym_vendor) {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab)
- return symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
- }
- return 0;
+ if (Symtab *symtab = GetSymtab())
+ symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
}
-size_t Module::FindSymbolsWithNameAndType(ConstString name,
+void Module::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
@@ -1371,22 +1328,16 @@ size_t Module::FindSymbolsWithNameAndType(ConstString name,
Timer scoped_timer(
func_cat, "Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
name.AsCString(), symbol_type);
- const size_t initial_size = sc_list.GetSize();
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (sym_vendor) {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab) {
- std::vector<uint32_t> symbol_indexes;
- symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
- SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
- }
+ if (Symtab *symtab = GetSymtab()) {
+ std::vector<uint32_t> symbol_indexes;
+ symtab->FindAllSymbolsWithNameAndType(name, symbol_type, symbol_indexes);
+ SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
- return sc_list.GetSize() - initial_size;
}
-size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
- SymbolType symbol_type,
- SymbolContextList &sc_list) {
+void Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
+ SymbolType symbol_type,
+ SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
// already thread safe.
@@ -1395,35 +1346,27 @@ size_t Module::FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
func_cat,
"Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
regex.GetText().str().c_str(), symbol_type);
- const size_t initial_size = sc_list.GetSize();
- SymbolVendor *sym_vendor = GetSymbolVendor();
- if (sym_vendor) {
- Symtab *symtab = sym_vendor->GetSymtab();
- if (symtab) {
- std::vector<uint32_t> symbol_indexes;
- symtab->FindAllSymbolsMatchingRexExAndType(
- regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny,
- symbol_indexes);
- SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
- }
+ if (Symtab *symtab = GetSymtab()) {
+ std::vector<uint32_t> symbol_indexes;
+ symtab->FindAllSymbolsMatchingRexExAndType(
+ regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny,
+ symbol_indexes);
+ SymbolIndicesToSymbolContextList(symtab, symbol_indexes, sc_list);
}
- return sc_list.GetSize() - initial_size;
}
void Module::PreloadSymbols() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- SymbolVendor * sym_vendor = GetSymbolVendor();
- if (!sym_vendor) {
+ SymbolFile *sym_file = GetSymbolFile();
+ if (!sym_file)
return;
- }
+
// Prime the symbol file first, since it adds symbols to the symbol table.
- if (SymbolFile *symbol_file = sym_vendor->GetSymbolFile()) {
- symbol_file->PreloadSymbols();
- }
+ sym_file->PreloadSymbols();
+
// Now we can prime the symbol table.
- if (Symtab * symtab = sym_vendor->GetSymtab()) {
+ if (Symtab *symtab = sym_file->GetSymtab())
symtab->PreloadSymbols();
- }
}
void Module::SetSymbolFileFileSpec(const FileSpec &file) {
@@ -1433,7 +1376,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// Remove any sections in the unified section list that come from the
// current symbol vendor.
SectionList *section_list = GetSectionList();
- SymbolFile *symbol_file = m_symfile_up->GetSymbolFile();
+ SymbolFile *symbol_file = GetSymbolFile();
if (section_list && symbol_file) {
ObjectFile *obj_file = symbol_file->GetObjectFile();
// Make sure we have an object file and that the symbol vendor's objfile
@@ -1489,7 +1432,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
}
m_symfile_spec = file;
m_symfile_up.reset();
- m_did_load_symbol_vendor = false;
+ m_did_load_symfile = false;
}
bool Module::IsExecutable() {
@@ -1654,6 +1597,26 @@ bool Module::RemapSourceFile(llvm::StringRef path,
return m_source_mappings.RemapPath(path, new_path);
}
+bool Module::MergeArchitecture(const ArchSpec &arch_spec) {
+ if (!arch_spec.IsValid())
+ return false;
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES),
+ "module has arch %s, merging/replacing with arch %s",
+ m_arch.GetTriple().getTriple().c_str(),
+ arch_spec.GetTriple().getTriple().c_str());
+ if (!m_arch.IsCompatibleMatch(arch_spec)) {
+ // The new architecture is different, we just need to replace it.
+ return SetArchitecture(arch_spec);
+ }
+
+ // Merge bits from arch_spec into "merged_arch" and set our architecture.
+ ArchSpec merged_arch(m_arch);
+ merged_arch.MergeFrom(arch_spec);
+ // SetArchitecture() is a no-op if m_arch is already valid.
+ m_arch = ArchSpec();
+ return SetArchitecture(merged_arch);
+}
+
llvm::VersionTuple Module::GetVersion() {
if (ObjectFile *obj_file = GetObjectFile())
return obj_file->GetVersion();
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index 9d795f9e5586..b0567a902fd7 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -17,6 +17,7 @@
#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
@@ -56,40 +57,26 @@ class SymbolFile;
namespace lldb_private {
class Target;
}
-namespace lldb_private {
-class TypeList;
-}
using namespace lldb;
using namespace lldb_private;
namespace {
-static constexpr PropertyDefinition g_properties[] = {
- {"enable-external-lookup", OptionValue::eTypeBoolean, true, true, nullptr,
- {},
- "Control the use of external tools and repositories to locate symbol "
- "files. Directories listed in target.debug-file-search-paths and "
- "directory of the executable are always checked first for separate debug "
- "info files. Then depending on this setting: "
- "On macOS, Spotlight would be also used to locate a matching .dSYM "
- "bundle based on the UUID of the executable. "
- "On NetBSD, directory /usr/libdata/debug would be also searched. "
- "On platforms other than NetBSD directory /usr/lib/debug would be "
- "also searched."
- },
- {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr,
- {},
- "The path to the clang modules cache directory (-fmodules-cache-path)."}};
-
-enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath };
+#define LLDB_PROPERTIES_modulelist
+#include "CoreProperties.inc"
+
+enum {
+#define LLDB_PROPERTIES_modulelist
+#include "CorePropertiesEnum.inc"
+};
} // namespace
ModuleListProperties::ModuleListProperties() {
m_collection_sp =
std::make_shared<OptionValueProperties>(ConstString("symbols"));
- m_collection_sp->Initialize(g_properties);
+ m_collection_sp->Initialize(g_modulelist_properties);
llvm::SmallString<128> path;
clang::driver::Driver::getDefaultModuleCachePath(path);
@@ -99,7 +86,7 @@ ModuleListProperties::ModuleListProperties() {
bool ModuleListProperties::GetEnableExternalLookup() const {
const uint32_t idx = ePropertyEnableExternalLookup;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_properties[idx].default_uint_value != 0);
+ nullptr, idx, g_modulelist_properties[idx].default_uint_value != 0);
}
bool ModuleListProperties::SetEnableExternalLookup(bool new_value) {
@@ -135,9 +122,9 @@ ModuleList::ModuleList(ModuleList::Notifier *notifier)
const ModuleList &ModuleList::operator=(const ModuleList &rhs) {
if (this != &rhs) {
std::lock(m_modules_mutex, rhs.m_modules_mutex);
- std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex,
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex,
std::adopt_lock);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex,
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex,
std::adopt_lock);
m_modules = rhs.m_modules;
}
@@ -155,8 +142,8 @@ void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) {
}
}
-void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
- AppendImpl(module_sp, notify);
+void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
+ AppendImpl(module_sp, notify);
}
void ModuleList::ReplaceEquivalent(const ModuleSP &module_sp) {
@@ -339,14 +326,10 @@ ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const {
return module_sp;
}
-size_t ModuleList::FindFunctions(ConstString name,
- FunctionNameType name_type_mask,
- bool include_symbols, bool include_inlines,
- bool append,
- SymbolContextList &sc_list) const {
- if (!append)
- sc_list.Clear();
-
+void ModuleList::FindFunctions(ConstString name,
+ FunctionNameType name_type_mask,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) const {
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto) {
@@ -357,7 +340,7 @@ size_t ModuleList::FindFunctions(ConstString name,
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(lookup_info.GetLookupName(), nullptr,
lookup_info.GetNameTypeMask(), include_symbols,
- include_inlines, true, sc_list);
+ include_inlines, sc_list);
}
const size_t new_size = sc_list.GetSize();
@@ -369,15 +352,14 @@ size_t ModuleList::FindFunctions(ConstString name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols,
- include_inlines, true, sc_list);
+ include_inlines, sc_list);
}
}
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindFunctionSymbols(ConstString name,
- lldb::FunctionNameType name_type_mask,
- SymbolContextList &sc_list) {
+void ModuleList::FindFunctionSymbols(ConstString name,
+ lldb::FunctionNameType name_type_mask,
+ SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto) {
@@ -401,96 +383,66 @@ size_t ModuleList::FindFunctionSymbols(ConstString name,
(*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
}
}
-
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindFunctions(const RegularExpression &name,
- bool include_symbols, bool include_inlines,
- bool append, SymbolContextList &sc_list) {
- const size_t old_size = sc_list.GetSize();
-
+void ModuleList::FindFunctions(const RegularExpression &name,
+ bool include_symbols, bool include_inlines,
+ SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(name, include_symbols, include_inlines, append,
- sc_list);
+ (*pos)->FindFunctions(name, include_symbols, include_inlines, sc_list);
}
-
- return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
- SymbolContextList &sc_list) const {
- if (!append)
- sc_list.Clear();
-
+void ModuleList::FindCompileUnits(const FileSpec &path,
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindCompileUnits(path, true, sc_list);
+ (*pos)->FindCompileUnits(path, sc_list);
}
-
- return sc_list.GetSize();
}
-size_t ModuleList::FindGlobalVariables(ConstString name,
- size_t max_matches,
- VariableList &variable_list) const {
- size_t initial_size = variable_list.GetSize();
+void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
+ VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
}
- return variable_list.GetSize() - initial_size;
}
-size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
- size_t max_matches,
- VariableList &variable_list) const {
- size_t initial_size = variable_list.GetSize();
+void ModuleList::FindGlobalVariables(const RegularExpression &regex,
+ size_t max_matches,
+ VariableList &variable_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
}
- return variable_list.GetSize() - initial_size;
}
-size_t ModuleList::FindSymbolsWithNameAndType(ConstString name,
- SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append) const {
+void ModuleList::FindSymbolsWithNameAndType(ConstString name,
+ SymbolType symbol_type,
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- if (!append)
- sc_list.Clear();
- size_t initial_size = sc_list.GetSize();
-
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
- return sc_list.GetSize() - initial_size;
}
-size_t ModuleList::FindSymbolsMatchingRegExAndType(
+void ModuleList::FindSymbolsMatchingRegExAndType(
const RegularExpression &regex, lldb::SymbolType symbol_type,
- SymbolContextList &sc_list, bool append) const {
+ SymbolContextList &sc_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- if (!append)
- sc_list.Clear();
- size_t initial_size = sc_list.GetSize();
-
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
(*pos)->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
- return sc_list.GetSize() - initial_size;
}
-size_t ModuleList::FindModules(const ModuleSpec &module_spec,
- ModuleList &matching_module_list) const {
- size_t existing_matches = matching_module_list.GetSize();
-
+void ModuleList::FindModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
@@ -498,7 +450,6 @@ size_t ModuleList::FindModules(const ModuleSpec &module_spec,
if (module_sp->MatchesModuleSpec(module_spec))
matching_module_list.Append(module_sp);
}
- return matching_module_list.GetSize() - existing_matches;
}
ModuleSP ModuleList::FindModule(const Module *module_ptr) const {
@@ -536,44 +487,36 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const {
return module_sp;
}
-size_t
-ModuleList::FindTypes(Module *search_first, ConstString name,
- bool name_is_fully_qualified, size_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeList &types) const {
+void ModuleList::FindTypes(Module *search_first, ConstString name,
+ bool name_is_fully_qualified, size_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeList &types) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- size_t total_matches = 0;
collection::const_iterator pos, end = m_modules.end();
if (search_first) {
for (pos = m_modules.begin(); pos != end; ++pos) {
if (search_first == pos->get()) {
- total_matches +=
- search_first->FindTypes(name, name_is_fully_qualified, max_matches,
- searched_symbol_files, types);
+ search_first->FindTypes(name, name_is_fully_qualified, max_matches,
+ searched_symbol_files, types);
- if (total_matches >= max_matches)
- break;
+ if (types.GetSize() >= max_matches)
+ return;
}
}
}
- if (total_matches < max_matches) {
- for (pos = m_modules.begin(); pos != end; ++pos) {
- // Search the module if the module is not equal to the one in the symbol
- // context "sc". If "sc" contains a empty module shared pointer, then the
- // comparison will always be true (valid_module_ptr != nullptr).
- if (search_first != pos->get())
- total_matches +=
- (*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
- searched_symbol_files, types);
-
- if (total_matches >= max_matches)
- break;
- }
- }
+ for (pos = m_modules.begin(); pos != end; ++pos) {
+ // Search the module if the module is not equal to the one in the symbol
+ // context "sc". If "sc" contains a empty module shared pointer, then the
+ // comparison will always be true (valid_module_ptr != nullptr).
+ if (search_first != pos->get())
+ (*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
+ searched_symbol_files, types);
- return total_matches;
+ if (types.GetSize() >= max_matches)
+ return;
+ }
}
bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
@@ -641,11 +584,11 @@ void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
for (pos = begin; pos != end; ++pos) {
Module *module = pos->get();
const FileSpec &module_file_spec = module->GetFileSpec();
- log->Printf("%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr : "",
- (uint32_t)std::distance(begin, pos),
- module->GetUUID().GetAsString().c_str(),
- module->GetArchitecture().GetArchitectureName(),
- module_file_spec.GetPath().c_str());
+ LLDB_LOGF(log, "%s[%u] %s (%s) \"%s\"", prefix_cstr ? prefix_cstr : "",
+ (uint32_t)std::distance(begin, pos),
+ module->GetUUID().GetAsString().c_str(),
+ module->GetArchitecture().GetArchitectureName(),
+ module_file_spec.GetPath().c_str());
}
}
}
@@ -757,9 +700,9 @@ bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
return false;
}
-size_t ModuleList::FindSharedModules(const ModuleSpec &module_spec,
- ModuleList &matching_module_list) {
- return GetSharedModuleList().FindModules(module_spec, matching_module_list);
+void ModuleList::FindSharedModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) {
+ GetSharedModuleList().FindModules(module_spec, matching_module_list);
}
size_t ModuleList::RemoveOrphanSharedModules(bool mandatory) {
@@ -794,8 +737,9 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
// mutex list.
if (!always_create) {
ModuleList matching_module_list;
- const size_t num_matching_modules =
- shared_module_list.FindModules(module_spec, matching_module_list);
+ shared_module_list.FindModules(module_spec, matching_module_list);
+ const size_t num_matching_modules = matching_module_list.GetSize();
+
if (num_matching_modules > 0) {
for (size_t module_idx = 0; module_idx < num_matching_modules;
++module_idx) {
@@ -808,8 +752,9 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
if (log != nullptr)
- log->Printf("module changed: %p, removing from global module list",
- static_cast<void *>(module_sp.get()));
+ LLDB_LOGF(log,
+ "module changed: %p, removing from global module list",
+ static_cast<void *>(module_sp.get()));
shared_module_list.Remove(module_sp);
module_sp.reset();
@@ -945,8 +890,8 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
platform_module_spec.GetSymbolFileSpec() =
located_binary_modulespec.GetSymbolFileSpec();
ModuleList matching_module_list;
- if (shared_module_list.FindModules(platform_module_spec,
- matching_module_list) > 0) {
+ shared_module_list.FindModules(platform_module_spec, matching_module_list);
+ if (!matching_module_list.IsEmpty()) {
module_sp = matching_module_list.GetModuleAtIndex(0);
// If we didn't have a UUID in mind when looking for the object file,
diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp
index 24cadcd85bf5..80b64fb832fa 100644
--- a/source/Core/PluginManager.cpp
+++ b/source/Core/PluginManager.cpp
@@ -1341,10 +1341,10 @@ PluginManager::GetPlatformCreateCallbackForPluginName(ConstString name) {
return nullptr;
}
-size_t PluginManager::AutoCompletePlatformName(llvm::StringRef name,
- StringList &matches) {
+void PluginManager::AutoCompletePlatformName(llvm::StringRef name,
+ CompletionRequest &request) {
if (name.empty())
- return matches.GetSize();
+ return;
std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
PlatformInstances &instances = GetPlatformInstances();
@@ -1354,9 +1354,8 @@ size_t PluginManager::AutoCompletePlatformName(llvm::StringRef name,
for (pos = instances.begin(); pos != end; ++pos) {
llvm::StringRef plugin_name(pos->name.GetCString());
if (plugin_name.startswith(name_sref))
- matches.AppendString(plugin_name.data());
+ request.AddCompletion(plugin_name.data());
}
- return matches.GetSize();
}
#pragma mark Process
@@ -2084,12 +2083,11 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName(
#pragma mark TypeSystem
struct TypeSystemInstance {
- TypeSystemInstance() : name(), description(), create_callback(nullptr) {}
-
ConstString name;
std::string description;
TypeSystemCreateInstance create_callback;
- TypeSystemEnumerateSupportedLanguages enumerate_callback;
+ LanguageSet supported_languages_for_types;
+ LanguageSet supported_languages_for_expressions;
};
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
@@ -2104,11 +2102,11 @@ static TypeSystemInstances &GetTypeSystemInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name,
- const char *description,
- TypeSystemCreateInstance create_callback,
- TypeSystemEnumerateSupportedLanguages
- enumerate_supported_languages_callback) {
+bool PluginManager::RegisterPlugin(
+ ConstString name, const char *description,
+ TypeSystemCreateInstance create_callback,
+ LanguageSet supported_languages_for_types,
+ LanguageSet supported_languages_for_expressions) {
if (create_callback) {
TypeSystemInstance instance;
assert((bool)name);
@@ -2116,7 +2114,8 @@ bool PluginManager::RegisterPlugin(ConstString name,
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
- instance.enumerate_callback = enumerate_supported_languages_callback;
+ instance.supported_languages_for_types = supported_languages_for_types;
+ instance.supported_languages_for_expressions = supported_languages_for_expressions;
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
GetTypeSystemInstances().push_back(instance);
}
@@ -2164,30 +2163,22 @@ PluginManager::GetTypeSystemCreateCallbackForPluginName(
return nullptr;
}
-TypeSystemEnumerateSupportedLanguages
-PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(
- uint32_t idx) {
+LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() {
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
+ LanguageSet all;
TypeSystemInstances &instances = GetTypeSystemInstances();
- if (idx < instances.size())
- return instances[idx].enumerate_callback;
- return nullptr;
+ for (unsigned i = 0; i < instances.size(); ++i)
+ all.bitvector |= instances[i].supported_languages_for_types.bitvector;
+ return all;
}
-TypeSystemEnumerateSupportedLanguages
-PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
- TypeSystemInstances &instances = GetTypeSystemInstances();
-
- TypeSystemInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->enumerate_callback;
- }
- }
- return nullptr;
+LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
+ std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
+ LanguageSet all;
+ TypeSystemInstances &instances = GetTypeSystemInstances();
+ for (unsigned i = 0; i < instances.size(); ++i)
+ all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
+ return all;
}
#pragma mark REPL
@@ -2198,7 +2189,7 @@ struct REPLInstance {
ConstString name;
std::string description;
REPLCreateInstance create_callback;
- REPLEnumerateSupportedLanguages enumerate_languages_callback;
+ LanguageSet supported_languages;
};
typedef std::vector<REPLInstance> REPLInstances;
@@ -2213,10 +2204,9 @@ static REPLInstances &GetREPLInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(
- ConstString name, const char *description,
- REPLCreateInstance create_callback,
- REPLEnumerateSupportedLanguages enumerate_languages_callback) {
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
+ REPLCreateInstance create_callback,
+ LanguageSet supported_languages) {
if (create_callback) {
REPLInstance instance;
assert((bool)name);
@@ -2224,7 +2214,7 @@ bool PluginManager::RegisterPlugin(
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
- instance.enumerate_languages_callback = enumerate_languages_callback;
+ instance.supported_languages = supported_languages;
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
GetREPLInstances().push_back(instance);
}
@@ -2270,29 +2260,13 @@ PluginManager::GetREPLCreateCallbackForPluginName(ConstString name) {
return nullptr;
}
-REPLEnumerateSupportedLanguages
-PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx) {
+LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
+ LanguageSet all;
REPLInstances &instances = GetREPLInstances();
- if (idx < instances.size())
- return instances[idx].enumerate_languages_callback;
- return nullptr;
-}
-
-REPLEnumerateSupportedLanguages
-PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
- REPLInstances &instances = GetREPLInstances();
-
- REPLInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->enumerate_languages_callback;
- }
- }
- return nullptr;
+ for (unsigned i = 0; i < instances.size(); ++i)
+ all.bitvector |= instances[i].supported_languages.bitvector;
+ return all;
}
#pragma mark PluginManager
diff --git a/source/Core/SearchFilter.cpp b/source/Core/SearchFilter.cpp
index 531fa078de29..e02b4f66b58c 100644
--- a/source/Core/SearchFilter.cpp
+++ b/source/Core/SearchFilter.cpp
@@ -13,7 +13,7 @@
#include "lldb/Core/ModuleList.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Status.h"
@@ -209,7 +209,7 @@ void SearchFilter::Search(Searcher &searcher) {
empty_sc.target_sp = m_target_sp;
if (searcher.GetDepth() == lldb::eSearchDepthTarget)
- searcher.SearchCallback(*this, empty_sc, nullptr, false);
+ searcher.SearchCallback(*this, empty_sc, nullptr);
else
DoModuleIteration(empty_sc, searcher);
}
@@ -222,7 +222,7 @@ void SearchFilter::SearchInModuleList(Searcher &searcher, ModuleList &modules) {
empty_sc.target_sp = m_target_sp;
if (searcher.GetDepth() == lldb::eSearchDepthTarget)
- searcher.SearchCallback(*this, empty_sc, nullptr, false);
+ searcher.SearchCallback(*this, empty_sc, nullptr);
else {
std::lock_guard<std::recursive_mutex> guard(modules.GetMutex());
const size_t numModules = modules.GetSize();
@@ -252,7 +252,7 @@ SearchFilter::DoModuleIteration(const SymbolContext &context,
if (context.module_sp) {
if (searcher.GetDepth() == lldb::eSearchDepthModule) {
SymbolContext matchingContext(context.module_sp.get());
- searcher.SearchCallback(*this, matchingContext, nullptr, false);
+ searcher.SearchCallback(*this, matchingContext, nullptr);
} else {
return DoCUIteration(context.module_sp, context, searcher);
}
@@ -272,7 +272,7 @@ SearchFilter::DoModuleIteration(const SymbolContext &context,
SymbolContext matchingContext(m_target_sp, module_sp);
Searcher::CallbackReturn shouldContinue =
- searcher.SearchCallback(*this, matchingContext, nullptr, false);
+ searcher.SearchCallback(*this, matchingContext, nullptr);
if (shouldContinue == Searcher::eCallbackReturnStop ||
shouldContinue == Searcher::eCallbackReturnPop)
return shouldContinue;
@@ -306,7 +306,7 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp,
SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get());
shouldContinue =
- searcher.SearchCallback(*this, matchingContext, nullptr, false);
+ searcher.SearchCallback(*this, matchingContext, nullptr);
if (shouldContinue == Searcher::eCallbackReturnPop)
return Searcher::eCallbackReturnContinue;
@@ -316,10 +316,10 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp,
// First make sure this compile unit's functions are parsed
// since CompUnit::ForeachFunction only iterates over already
// parsed functions.
- SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
- if (!sym_vendor)
+ SymbolFile *sym_file = module_sp->GetSymbolFile();
+ if (!sym_file)
continue;
- if (!sym_vendor->ParseFunctions(*cu_sp))
+ if (!sym_file->ParseFunctions(*cu_sp))
continue;
// If we got any functions, use ForeachFunction to do the iteration.
cu_sp->ForeachFunction([&](const FunctionSP &func_sp) {
@@ -328,9 +328,8 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp,
if (searcher.GetDepth() == lldb::eSearchDepthFunction) {
SymbolContext matchingContext(m_target_sp, module_sp,
cu_sp.get(), func_sp.get());
- shouldContinue = searcher.SearchCallback(*this,
- matchingContext,
- nullptr, false);
+ shouldContinue =
+ searcher.SearchCallback(*this, matchingContext, nullptr);
} else {
shouldContinue = DoFunctionIteration(func_sp.get(), context,
searcher);
@@ -343,7 +342,7 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp,
} else {
if (CompUnitPasses(*context.comp_unit)) {
SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit);
- return searcher.SearchCallback(*this, matchingContext, nullptr, false);
+ return searcher.SearchCallback(*this, matchingContext, nullptr);
}
}
return Searcher::eCallbackReturnContinue;
@@ -431,7 +430,7 @@ void SearchFilterByModule::Search(Searcher &searcher) {
if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
SymbolContext empty_sc;
empty_sc.target_sp = m_target_sp;
- searcher.SearchCallback(*this, empty_sc, nullptr, false);
+ searcher.SearchCallback(*this, empty_sc, nullptr);
}
// If the module file spec is a full path, then we can just find the one
@@ -568,7 +567,7 @@ void SearchFilterByModuleList::Search(Searcher &searcher) {
if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
SymbolContext empty_sc;
empty_sc.target_sp = m_target_sp;
- searcher.SearchCallback(*this, empty_sc, nullptr, false);
+ searcher.SearchCallback(*this, empty_sc, nullptr);
}
// If the module file spec is a full path, then we can just find the one
@@ -640,7 +639,7 @@ SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
"SFBM::CFSD: filter module item %zu not a string.", i);
return nullptr;
}
- modules.Append(FileSpec(module));
+ modules.EmplaceBack(module);
}
}
@@ -703,7 +702,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
"SFBM::CFSD: filter module item %zu not a string.", i);
return result_sp;
}
- modules.Append(FileSpec(module));
+ modules.EmplaceBack(module);
}
}
@@ -725,7 +724,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
"SFBM::CFSD: filter cu item %zu not a string.", i);
return nullptr;
}
- cus.Append(FileSpec(cu));
+ cus.EmplaceBack(cu);
}
return std::make_shared<SearchFilterByModuleListAndCU>(
@@ -777,7 +776,7 @@ void SearchFilterByModuleListAndCU::Search(Searcher &searcher) {
if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
SymbolContext empty_sc;
empty_sc.target_sp = m_target_sp;
- searcher.SearchCallback(*this, empty_sc, nullptr, false);
+ searcher.SearchCallback(*this, empty_sc, nullptr);
}
// If the module file spec is a full path, then we can just find the one
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index f30ddd2c18c3..7615dc1d65c7 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -269,7 +269,7 @@ bool Section::ResolveContainedAddress(addr_t offset, Address &so_addr,
bool Section::ContainsFileAddress(addr_t vm_addr) const {
const addr_t file_addr = GetFileAddress();
- if (file_addr != LLDB_INVALID_ADDRESS) {
+ if (file_addr != LLDB_INVALID_ADDRESS && !IsThreadSpecific()) {
if (file_addr <= vm_addr) {
const addr_t offset = (vm_addr - file_addr) * m_target_byte_size;
return offset < GetByteSize();
@@ -417,10 +417,6 @@ lldb::offset_t Section::GetSectionData(DataExtractor &section_data) {
#pragma mark SectionList
-SectionList::SectionList() : m_sections() {}
-
-SectionList::~SectionList() {}
-
SectionList &SectionList::operator=(const SectionList &rhs) {
if (this != &rhs)
m_sections = rhs.m_sections;
diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp
index 87065ab62425..42741e4ba4fe 100644
--- a/source/Core/SourceManager.cpp
+++ b/source/Core/SourceManager.cpp
@@ -324,10 +324,10 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
ConstString main_name("main");
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
- bool append = false;
- size_t num_matches = executable_ptr->FindFunctions(
- main_name, nullptr, lldb::eFunctionNameTypeBase, inlines_okay,
- symbols_okay, append, sc_list);
+ executable_ptr->FindFunctions(main_name, nullptr,
+ lldb::eFunctionNameTypeBase, inlines_okay,
+ symbols_okay, sc_list);
+ size_t num_matches = sc_list.GetSize();
for (size_t idx = 0; idx < num_matches; idx++) {
SymbolContext sc;
sc_list.GetContextAtIndex(idx, sc);
diff --git a/source/Core/StreamFile.cpp b/source/Core/StreamFile.cpp
index ce6e1ea2c18f..2ddb39659d66 100644
--- a/source/Core/StreamFile.cpp
+++ b/source/Core/StreamFile.cpp
@@ -8,6 +8,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/Log.h"
#include <stdio.h>
@@ -15,35 +16,55 @@ using namespace lldb;
using namespace lldb_private;
// StreamFile constructor
-StreamFile::StreamFile() : Stream(), m_file() {}
+StreamFile::StreamFile() : Stream() { m_file_sp = std::make_shared<File>(); }
StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
- : Stream(flags, addr_size, byte_order), m_file() {}
-
-StreamFile::StreamFile(int fd, bool transfer_ownership)
- : Stream(), m_file(fd, transfer_ownership) {}
+ : Stream(flags, addr_size, byte_order) {
+ m_file_sp = std::make_shared<File>();
+}
-StreamFile::StreamFile(FILE *fh, bool transfer_ownership)
- : Stream(), m_file(fh, transfer_ownership) {}
+StreamFile::StreamFile(int fd, bool transfer_ownership) : Stream() {
+ m_file_sp =
+ std::make_shared<NativeFile>(fd, File::eOpenOptionWrite, transfer_ownership);
+}
-StreamFile::StreamFile(const char *path) : Stream(), m_file() {
- FileSystem::Instance().Open(m_file, FileSpec(path),
- File::eOpenOptionWrite |
- File::eOpenOptionCanCreate |
- File::eOpenOptionCloseOnExec);
+StreamFile::StreamFile(FILE *fh, bool transfer_ownership) : Stream() {
+ m_file_sp = std::make_shared<NativeFile>(fh, transfer_ownership);
}
-StreamFile::StreamFile(const char *path, uint32_t options, uint32_t permissions)
- : Stream(), m_file() {
+StreamFile::StreamFile(const char *path) : Stream() {
+ auto file = FileSystem::Instance().Open(
+ FileSpec(path), File::eOpenOptionWrite | File::eOpenOptionCanCreate |
+ File::eOpenOptionCloseOnExec);
+ if (file)
+ 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(),
+ "Cannot open {1}: {0}", path);
+ m_file_sp = std::make_shared<File>();
+ }
+}
- FileSystem::Instance().Open(m_file, FileSpec(path), options, permissions);
+StreamFile::StreamFile(const char *path, File::OpenOptions options,
+ uint32_t permissions)
+ : Stream() {
+ auto file = FileSystem::Instance().Open(FileSpec(path), options, permissions);
+ if (file)
+ 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(),
+ "Cannot open {1}: {0}", path);
+ m_file_sp = std::make_shared<File>();
+ }
}
StreamFile::~StreamFile() {}
-void StreamFile::Flush() { m_file.Flush(); }
+void StreamFile::Flush() { m_file_sp->Flush(); }
size_t StreamFile::WriteImpl(const void *s, size_t length) {
- m_file.Write(s, length);
+ m_file_sp->Write(s, length);
return length;
}
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index fdb4adb5f431..3124b9338b36 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -314,7 +314,7 @@ bool Value::GetData(DataExtractor &data) {
}
Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
- uint32_t data_offset, Module *module) {
+ Module *module) {
data.Clear();
Status error;
@@ -520,13 +520,12 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
// Make sure we have enough room within "data", and if we don't make
// something large enough that does
- if (!data.ValidOffsetForDataOfSize(data_offset, byte_size)) {
- auto data_sp =
- std::make_shared<DataBufferHeap>(data_offset + byte_size, '\0');
+ if (!data.ValidOffsetForDataOfSize(0, byte_size)) {
+ auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
data.SetData(data_sp);
}
- uint8_t *dst = const_cast<uint8_t *>(data.PeekData(data_offset, byte_size));
+ uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
if (dst != nullptr) {
if (address_type == eAddressTypeHost) {
// The address is an address in this process, so just copy it.
@@ -597,7 +596,7 @@ Scalar &Value::ResolveValue(ExecutionContext *exe_ctx) {
{
DataExtractor data;
lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
- Status error(GetValueAsData(exe_ctx, data, 0, nullptr));
+ Status error(GetValueAsData(exe_ctx, data, nullptr));
if (error.Success()) {
Scalar scalar;
if (compiler_type.GetValueAsScalar(data, 0, data.GetByteSize(),
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 297365b4ecbd..74176eeace3a 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -73,7 +73,6 @@ class SymbolContextScope;
using namespace lldb;
using namespace lldb_private;
-using namespace lldb_utility;
static user_id_t g_value_obj_uid = 0;
@@ -226,12 +225,12 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {
bool ValueObject::UpdateFormatsIfNeeded() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
- if (log)
- log->Printf("[%s %p] checking for FormatManager revisions. ValueObject "
- "rev: %d - Global rev: %d",
- GetName().GetCString(), static_cast<void *>(this),
- m_last_format_mgr_revision,
- DataVisualization::GetCurrentRevision());
+ LLDB_LOGF(log,
+ "[%s %p] checking for FormatManager revisions. ValueObject "
+ "rev: %d - Global rev: %d",
+ GetName().GetCString(), static_cast<void *>(this),
+ m_last_format_mgr_revision,
+ DataVisualization::GetCurrentRevision());
bool any_change = false;
@@ -811,7 +810,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
UpdateValueIfNeeded(false);
ExecutionContext exe_ctx(GetExecutionContextRef());
- error = m_value.GetValueAsData(&exe_ctx, data, 0, GetModule().get());
+ error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
if (error.Fail()) {
if (m_data.GetByteSize()) {
data = m_data;
@@ -1672,16 +1671,7 @@ bool ValueObject::IsRuntimeSupportValue() {
if (!GetVariable() || !GetVariable()->IsArtificial())
return false;
- LanguageType lang = eLanguageTypeUnknown;
- if (auto *sym_ctx_scope = GetSymbolContextScope()) {
- if (auto *func = sym_ctx_scope->CalculateSymbolContextFunction())
- lang = func->GetLanguage();
- else if (auto *comp_unit =
- sym_ctx_scope->CalculateSymbolContextCompileUnit())
- lang = comp_unit->GetLanguage();
- }
-
- if (auto *runtime = process->GetLanguageRuntime(lang))
+ if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
if (runtime->IsWhitelistedRuntimeValue(GetName()))
return false;
@@ -2726,9 +2716,9 @@ ValueObjectSP ValueObject::CreateConstantValue(ConstString name) {
if (IsBitfield()) {
Value v(Scalar(GetValueAsUnsigned(UINT64_MAX)));
- m_error = v.GetValueAsData(&exe_ctx, data, 0, GetModule().get());
+ m_error = v.GetValueAsData(&exe_ctx, data, GetModule().get());
} else
- m_error = m_value.GetValueAsData(&exe_ctx, data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
valobj_sp = ValueObjectConstResult::Create(
exe_ctx.GetBestExecutionContextScope(), GetCompilerType(), name, data,
@@ -3310,32 +3300,32 @@ lldb::ValueObjectSP ValueObjectManager::GetSP() {
lldb::ProcessSP process_sp = GetProcessSP();
if (!process_sp)
return lldb::ValueObjectSP();
-
+
const uint32_t current_stop_id = process_sp->GetLastNaturalStopID();
if (current_stop_id == m_stop_id)
return m_user_valobj_sp;
-
+
m_stop_id = current_stop_id;
-
+
if (!m_root_valobj_sp) {
m_user_valobj_sp.reset();
return m_root_valobj_sp;
}
-
+
m_user_valobj_sp = m_root_valobj_sp;
-
+
if (m_use_dynamic != lldb::eNoDynamicValues) {
lldb::ValueObjectSP dynamic_sp = m_user_valobj_sp->GetDynamicValue(m_use_dynamic);
if (dynamic_sp)
m_user_valobj_sp = dynamic_sp;
}
-
+
if (m_use_synthetic) {
lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue(m_use_synthetic);
if (synthetic_sp)
m_user_valobj_sp = synthetic_sp;
}
-
+
return m_user_valobj_sp;
}
diff --git a/source/Core/ValueObjectCast.cpp b/source/Core/ValueObjectCast.cpp
index 6ccda8c32915..3a74b6a7fe18 100644
--- a/source/Core/ValueObjectCast.cpp
+++ b/source/Core/ValueObjectCast.cpp
@@ -79,7 +79,7 @@ bool ValueObjectCast::UpdateValue() {
m_value.GetScalar() != old_value.GetScalar());
}
ExecutionContext exe_ctx(GetExecutionContextRef());
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
SetValueDidChange(m_parent->GetValueDidChange());
return true;
}
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index 01f2e20dd0bc..6b4ada154d68 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -175,6 +175,30 @@ bool ValueObjectChild::UpdateValue() {
// Set this object's scalar value to the address of its value by
// adding its byte offset to the parent address
m_value.GetScalar() += GetByteOffset();
+
+ // If a bitfield doesn't fit into the child_byte_size'd
+ // window at child_byte_offset, move the window forward
+ // until it fits. The problem here is that Value has no
+ // notion of bitfields and thus the Value's DataExtractor
+ // is sized like the bitfields CompilerType; a sequence of
+ // bitfields, however, can be larger than their underlying
+ // type.
+ if (m_bitfield_bit_offset) {
+ const bool thread_and_frame_only_if_stopped = true;
+ ExecutionContext exe_ctx(GetExecutionContextRef().Lock(
+ thread_and_frame_only_if_stopped));
+ if (auto type_bit_size = GetCompilerType().GetBitSize(
+ exe_ctx.GetBestExecutionContextScope())) {
+ uint64_t bitfield_end =
+ m_bitfield_bit_size + m_bitfield_bit_offset;
+ if (bitfield_end > *type_bit_size) {
+ uint64_t overhang_bytes =
+ (bitfield_end - *type_bit_size + 7) / 8;
+ m_value.GetScalar() += overhang_bytes;
+ m_bitfield_bit_offset -= overhang_bytes * 8;
+ }
+ }
+ }
}
} break;
@@ -203,7 +227,7 @@ bool ValueObjectChild::UpdateValue() {
if (GetCompilerType().GetTypeInfo() & lldb::eTypeHasValue) {
Value &value = is_instance_ptr_base ? m_parent->GetValue() : m_value;
m_error =
- value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
} else {
m_error.Clear(); // No value so nothing to read...
}
diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp
index a1b2cac96874..71620698da2a 100644
--- a/source/Core/ValueObjectConstResult.cpp
+++ b/source/Core/ValueObjectConstResult.cpp
@@ -182,7 +182,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
m_name = name;
ExecutionContext exe_ctx;
exe_scope->CalculateExecutionContext(exe_ctx);
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, module);
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, module);
}
ValueObjectConstResult::~ValueObjectConstResult() {}
diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp
index 90b46d1f170d..59037e2b6b25 100644
--- a/source/Core/ValueObjectDynamicValue.cpp
+++ b/source/Core/ValueObjectDynamicValue.cpp
@@ -199,7 +199,7 @@ bool ValueObjectDynamicValue::UpdateValue() {
ClearDynamicTypeInformation();
m_dynamic_type_info.Clear();
m_value = m_parent->GetValue();
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
return m_error.Success();
}
@@ -243,13 +243,13 @@ bool ValueObjectDynamicValue::UpdateValue() {
m_value.SetValueType(value_type);
if (has_changed_type && log)
- log->Printf("[%s %p] has a new dynamic type %s", GetName().GetCString(),
- static_cast<void *>(this), GetTypeName().GetCString());
+ LLDB_LOGF(log, "[%s %p] has a new dynamic type %s", GetName().GetCString(),
+ static_cast<void *>(this), GetTypeName().GetCString());
if (m_address.IsValid() && m_dynamic_type_info) {
// The variable value is in the Scalar value inside the m_value. We can
// point our m_data right to it.
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
if (m_error.Success()) {
if (!CanProvideValue()) {
// this value object represents an aggregate type whose children have
diff --git a/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp
index 95d4330ee0c6..1a316bf3e7b0 100644
--- a/source/Core/ValueObjectMemory.cpp
+++ b/source/Core/ValueObjectMemory.cpp
@@ -168,7 +168,7 @@ bool ValueObjectMemory::UpdateValue() {
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value. We can
// point our m_data right to it.
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
break;
case Value::eValueTypeFileAddress:
@@ -209,7 +209,7 @@ bool ValueObjectMemory::UpdateValue() {
value.SetCompilerType(m_compiler_type);
}
- m_error = value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
}
break;
}
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 75a254fbbc21..7e97df6d2a34 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/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/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
@@ -256,15 +257,19 @@ ValueObjectRegister::~ValueObjectRegister() {}
CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
if (!m_compiler_type.IsValid()) {
ExecutionContext exe_ctx(GetExecutionContextRef());
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- Module *exe_module = target->GetExecutableModulePointer();
- if (exe_module) {
- TypeSystem *type_system =
+ if (auto *target = exe_ctx.GetTargetPtr()) {
+ if (auto *exe_module = target->GetExecutableModulePointer()) {
+ auto type_system_or_err =
exe_module->GetTypeSystemForLanguage(eLanguageTypeC);
- if (type_system)
- m_compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize(
- m_reg_info.encoding, m_reg_info.byte_size * 8);
+ 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");
+ } else {
+ m_compiler_type =
+ type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
+ m_reg_info.encoding, m_reg_info.byte_size * 8);
+ }
}
}
}
diff --git a/source/Core/ValueObjectSyntheticFilter.cpp b/source/Core/ValueObjectSyntheticFilter.cpp
index 400473235759..a6bf35eac70a 100644
--- a/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/source/Core/ValueObjectSyntheticFilter.cpp
@@ -87,20 +87,18 @@ size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
if (max < UINT32_MAX) {
size_t num_children = m_synth_filter_up->CalculateNumChildren(max);
- if (log)
- log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
- "%s and type %s, the filter returned %zu child values",
- GetName().AsCString(), GetTypeName().AsCString(),
- num_children);
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
+ "%s and type %s, the filter returned %zu child values",
+ GetName().AsCString(), GetTypeName().AsCString(), num_children);
return num_children;
} else {
size_t num_children = (m_synthetic_children_count =
m_synth_filter_up->CalculateNumChildren(max));
- if (log)
- log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
- "%s and type %s, the filter returned %zu child values",
- GetName().AsCString(), GetTypeName().AsCString(),
- num_children);
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
+ "%s and type %s, the filter returned %zu child values",
+ GetName().AsCString(), GetTypeName().AsCString(), num_children);
return num_children;
}
}
@@ -142,7 +140,7 @@ void ValueObjectSynthetic::CreateSynthFilter() {
}
m_synth_filter_up = (m_synth_sp->GetFrontEnd(*valobj_for_frontend));
if (!m_synth_filter_up)
- m_synth_filter_up = llvm::make_unique<DummySyntheticFrontEnd>(*m_parent);
+ m_synth_filter_up = std::make_unique<DummySyntheticFrontEnd>(*m_parent);
}
bool ValueObjectSynthetic::UpdateValue() {
@@ -163,21 +161,21 @@ bool ValueObjectSynthetic::UpdateValue() {
// <rdar://problem/12424824>
ConstString new_parent_type_name = m_parent->GetTypeName();
if (new_parent_type_name != m_parent_type_name) {
- if (log)
- log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, type changed "
- "from %s to %s, recomputing synthetic filter",
- GetName().AsCString(), m_parent_type_name.AsCString(),
- new_parent_type_name.AsCString());
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::UpdateValue] name=%s, type changed "
+ "from %s to %s, recomputing synthetic filter",
+ GetName().AsCString(), m_parent_type_name.AsCString(),
+ new_parent_type_name.AsCString());
m_parent_type_name = new_parent_type_name;
CreateSynthFilter();
}
// let our backend do its update
if (!m_synth_filter_up->Update()) {
- if (log)
- log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
- "filter said caches are stale - clearing",
- GetName().AsCString());
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
+ "filter said caches are stale - clearing",
+ GetName().AsCString());
// filter said that cached values are stale
m_children_byindex.Clear();
m_name_toindex.Clear();
@@ -190,10 +188,10 @@ bool ValueObjectSynthetic::UpdateValue() {
m_synthetic_children_count = UINT32_MAX;
m_might_have_children = eLazyBoolCalculate;
} else {
- if (log)
- log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
- "filter said caches are still valid",
- GetName().AsCString());
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
+ "filter said caches are still valid",
+ GetName().AsCString());
}
m_provides_value = eLazyBoolCalculate;
@@ -201,18 +199,18 @@ bool ValueObjectSynthetic::UpdateValue() {
lldb::ValueObjectSP synth_val(m_synth_filter_up->GetSyntheticValue());
if (synth_val && synth_val->CanProvideValue()) {
- if (log)
- log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
- "filter said it can provide a value",
- GetName().AsCString());
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
+ "filter said it can provide a value",
+ GetName().AsCString());
m_provides_value = eLazyBoolYes;
CopyValueData(synth_val.get());
} else {
- if (log)
- log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
- "filter said it will not provide a value",
- GetName().AsCString());
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
+ "filter said it will not provide a value",
+ GetName().AsCString());
m_provides_value = eLazyBoolNo;
CopyValueData(m_parent);
@@ -226,32 +224,32 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
bool can_create) {
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
- if (log)
- log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving "
- "child at index %zu",
- GetName().AsCString(), idx);
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving "
+ "child at index %zu",
+ GetName().AsCString(), idx);
UpdateValueIfNeeded();
ValueObject *valobj;
if (!m_children_byindex.GetValueForKey(idx, valobj)) {
if (can_create && m_synth_filter_up != nullptr) {
- if (log)
- log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
- "index %zu not cached and will be created",
- GetName().AsCString(), idx);
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
+ "index %zu not cached and will be created",
+ GetName().AsCString(), idx);
lldb::ValueObjectSP synth_guy = m_synth_filter_up->GetChildAtIndex(idx);
- if (log)
- log->Printf(
- "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index "
- "%zu created as %p (is "
- "synthetic: %s)",
- GetName().AsCString(), idx, static_cast<void *>(synth_guy.get()),
- synth_guy.get()
- ? (synth_guy->IsSyntheticChildrenGenerated() ? "yes" : "no")
- : "no");
+ LLDB_LOGF(
+ log,
+ "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index "
+ "%zu created as %p (is "
+ "synthetic: %s)",
+ GetName().AsCString(), idx, static_cast<void *>(synth_guy.get()),
+ synth_guy.get()
+ ? (synth_guy->IsSyntheticChildrenGenerated() ? "yes" : "no")
+ : "no");
if (!synth_guy)
return synth_guy;
@@ -263,20 +261,20 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
GetPreferredDisplayLanguage());
return synth_guy;
} else {
- if (log)
- log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
- "index %zu not cached and cannot "
- "be created (can_create = %s, synth_filter = %p)",
- GetName().AsCString(), idx, can_create ? "yes" : "no",
- static_cast<void *>(m_synth_filter_up.get()));
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
+ "index %zu not cached and cannot "
+ "be created (can_create = %s, synth_filter = %p)",
+ GetName().AsCString(), idx, can_create ? "yes" : "no",
+ static_cast<void *>(m_synth_filter_up.get()));
return lldb::ValueObjectSP();
}
} else {
- if (log)
- log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
- "index %zu cached as %p",
- GetName().AsCString(), idx, static_cast<void *>(valobj));
+ LLDB_LOGF(log,
+ "[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
+ "index %zu cached as %p",
+ GetName().AsCString(), idx, static_cast<void *>(valobj));
return valobj->GetSP();
}
@@ -322,7 +320,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetNonSyntheticValue() {
void ValueObjectSynthetic::CopyValueData(ValueObject *source) {
m_value = (source->UpdateValueIfNeeded(), source->GetValue());
ExecutionContext exe_ctx(GetExecutionContextRef());
- m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_error = m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
}
bool ValueObjectSynthetic::CanProvideValue() {
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index 5aee82493b28..33f9d5410843 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -221,7 +221,7 @@ bool ValueObjectVariable::UpdateValue() {
// The variable value is in the Scalar value inside the m_value. We can
// point our m_data right to it.
m_error =
- m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ m_value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
break;
case Value::eValueTypeFileAddress:
@@ -250,7 +250,7 @@ bool ValueObjectVariable::UpdateValue() {
Value value(m_value);
value.SetContext(Value::eContextTypeVariable, variable);
m_error =
- value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get());
+ value.GetValueAsData(&exe_ctx, m_data, GetModule().get());
SetValueDidChange(value_type != old_value.GetValueType() ||
m_value.GetScalar() != old_value.GetScalar());