diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Core/FormatEntity.cpp | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'source/Core/FormatEntity.cpp')
-rw-r--r-- | source/Core/FormatEntity.cpp | 99 |
1 files changed, 47 insertions, 52 deletions
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp index 0cb74cc7658da..2257b7e273e84 100644 --- a/source/Core/FormatEntity.cpp +++ b/source/Core/FormatEntity.cpp @@ -12,6 +12,7 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" // for AddressRange #include "lldb/Core/Debugger.h" +#include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" #include "lldb/Core/RegisterValue.h" // for RegisterValue #include "lldb/Core/ValueObject.h" @@ -467,10 +468,9 @@ static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc, if (sc->function) { func_addr = sc->function->GetAddressRange().GetBaseAddress(); if (sc->block && !concrete_only) { - // Check to make sure we aren't in an inline - // function. If we are, use the inline block - // range that contains "format_addr" since - // blocks can be discontiguous. + // Check to make sure we aren't in an inline function. If we are, use + // the inline block range that contains "format_addr" since blocks + // can be discontiguous. Block *inline_block = sc->block->GetContainingInlinedBlock(); AddressRange inline_range; if (inline_block && @@ -622,7 +622,7 @@ static bool DumpRegister(Stream &s, StackFrame *frame, RegisterKind reg_kind, if (reg_info) { RegisterValue reg_value; if (reg_ctx->ReadRegister(reg_info, reg_value)) { - reg_value.Dump(&s, reg_info, false, false, format); + DumpRegisterValue(reg_value, &s, reg_info, false, false, format); return true; } } @@ -822,8 +822,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, if (do_deref_pointer && !is_array_range) { // I have not deref-ed yet, let's do it // this happens when we are not going through - // GetValueForVariableExpressionPath - // to get to the target ValueObject + // GetValueForVariableExpressionPath to get to the target ValueObject Status error; target = target->Dereference(error).get(); if (error.Fail()) { @@ -842,9 +841,9 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, return false; } - // we do not want to use the summary for a bitfield of type T:n - // if we were originally dealing with just a T - that would get - // us into an endless recursion + // we do not want to use the summary for a bitfield of type T:n if we were + // originally dealing with just a T - that would get us into an endless + // recursion if (target->IsBitfield() && was_var_indexed) { // TODO: check for a (T:n)-specific summary - we should still obey that StreamString bitfield_name; @@ -905,8 +904,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, } // if directly trying to print ${var}, and this is an aggregate, display a - // nice - // type @ location message + // nice type @ location message if (is_aggregate && was_plain_var) { s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); return true; @@ -1021,7 +1019,7 @@ static bool DumpRegister(Stream &s, StackFrame *frame, const char *reg_name, if (reg_info) { RegisterValue reg_value; if (reg_ctx->ReadRegister(reg_info, reg_value)) { - reg_value.Dump(&s, reg_info, false, false, format); + DumpRegisterValue(reg_value, &s, reg_info, false, false, format); return true; } } @@ -1142,8 +1140,8 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (!success) break; } - // Only if all items in a scope succeed, then do we - // print the output into the main stream + // Only if all items in a scope succeed, then do we print the output into + // the main stream if (success) s.Write(scope_stream.GetString().data(), scope_stream.GetString().size()); } @@ -1206,9 +1204,8 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, // Watch for the special "tid" format... if (entry.printf_format == "tid") { // TODO(zturner): Rather than hardcoding this to be platform - // specific, it should be controlled by a - // setting and the default value of the setting can be different - // depending on the platform. + // specific, it should be controlled by a setting and the default + // value of the setting can be different depending on the platform. Target &target = thread->GetProcess()->GetTarget(); ArchSpec arch(target.GetArchitecture()); llvm::Triple::OSType ostype = arch.IsValid() @@ -1914,9 +1911,9 @@ static Status ParseEntry(const llvm::StringRef &format_str, error.SetErrorStringWithFormat("%s", error_strm.GetData()); } else if (sep_char == ':') { // Any value whose separator is a with a ':' means this value has a - // string argument - // that needs to be stored in the entry (like "${script.var:}"). - // In this case the string value is the empty string which is ok. + // string argument that needs to be stored in the entry (like + // "${script.var:}"). In this case the string value is the empty + // string which is ok. } else { error.SetErrorStringWithFormat("%s", "invalid entry definitions"); } @@ -1926,8 +1923,7 @@ static Status ParseEntry(const llvm::StringRef &format_str, error = ParseEntry(value, entry_def, entry); } else if (sep_char == ':') { // Any value whose separator is a with a ':' means this value has a - // string argument - // that needs to be stored in the entry (like + // string argument that needs to be stored in the entry (like // "${script.var:modulename.function}") entry.string = value.str(); } else { @@ -2065,17 +2061,17 @@ Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry, case '0': // 1 to 3 octal chars { - // Make a string that can hold onto the initial zero char, - // up to 3 octal digits, and a terminating NULL. + // Make a string that can hold onto the initial zero char, up to 3 + // octal digits, and a terminating NULL. char oct_str[5] = {0, 0, 0, 0, 0}; int i; for (i = 0; (format[i] >= '0' && format[i] <= '7') && i < 4; ++i) oct_str[i] = format[i]; - // We don't want to consume the last octal character since - // the main for loop will do this for us, so we advance p by - // one less than i (even if i is zero) + // We don't want to consume the last octal character since the main + // for loop will do this for us, so we advance p by one less than i + // (even if i is zero) format = format.drop_front(i); unsigned long octal_value = ::strtoul(oct_str, nullptr, 8); if (octal_value <= UINT8_MAX) { @@ -2115,8 +2111,8 @@ Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry, break; default: - // Just desensitize any other character by just printing what - // came after the '\' + // Just desensitize any other character by just printing what came + // after the '\' parent_entry.AppendChar(desens_char); break; } @@ -2142,10 +2138,9 @@ Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry, if (!variable_format.empty()) { entry.printf_format = variable_format.str(); - // If the format contains a '%' we are going to assume this is - // a printf style format. So if you want to format your thread ID - // using "0x%llx" you can use: - // ${thread.id%0x%llx} + // If the format contains a '%' we are going to assume this is a + // printf style format. So if you want to format your thread ID + // using "0x%llx" you can use: ${thread.id%0x%llx} // // If there is no '%' in the format, then it is assumed to be a // LLDB format name, or one of the extended formats specified in @@ -2264,9 +2259,9 @@ Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry, return error; } } - // Check if this entry just wants to insert a constant string - // value into the parent_entry, if so, insert the string with - // AppendText, else append the entry to the parent_entry. + // Check if this entry just wants to insert a constant string value + // into the parent_entry, if so, insert the string with AppendText, + // else append the entry to the parent_entry. if (entry.type == Entry::Type::InsertString) parent_entry.AppendText(entry.string.c_str()); else @@ -2350,12 +2345,12 @@ static void AddMatches(const FormatEntity::Entry::Definition *def, } } -size_t FormatEntity::AutoComplete(llvm::StringRef str, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches) { - word_complete = false; - str = str.drop_front(match_start_point); - matches.Clear(); +size_t FormatEntity::AutoComplete(CompletionRequest &request) { + llvm::StringRef str = request.GetCursorArgumentPrefix().str(); + + request.SetWordComplete(false); + str = str.drop_front(request.GetMatchStartPoint()); + request.GetMatches().Clear(); const size_t dollar_pos = str.rfind('$'); if (dollar_pos == llvm::StringRef::npos) @@ -2365,7 +2360,7 @@ size_t FormatEntity::AutoComplete(llvm::StringRef str, int match_start_point, if (dollar_pos == str.size() - 1) { std::string match = str.str(); match.append("{"); - matches.AppendString(match); + request.GetMatches().AppendString(match); return 1; } @@ -2383,8 +2378,8 @@ size_t FormatEntity::AutoComplete(llvm::StringRef str, int match_start_point, llvm::StringRef partial_variable(str.substr(dollar_pos + 2)); if (partial_variable.empty()) { // Suggest all top level entites as we are just past "${" - AddMatches(&g_root, str, llvm::StringRef(), matches); - return matches.GetSize(); + AddMatches(&g_root, str, llvm::StringRef(), request.GetMatches()); + return request.GetMatches().GetSize(); } // We have a partially specified variable, find it @@ -2400,19 +2395,19 @@ size_t FormatEntity::AutoComplete(llvm::StringRef str, int match_start_point, // Exact match if (n > 0) { // "${thread.info" <TAB> - matches.AppendString(MakeMatch(str, ".")); + request.GetMatches().AppendString(MakeMatch(str, ".")); } else { // "${thread.id" <TAB> - matches.AppendString(MakeMatch(str, "}")); - word_complete = true; + request.GetMatches().AppendString(MakeMatch(str, "}")); + request.SetWordComplete(true); } } else if (remainder.equals(".")) { // "${thread." <TAB> - AddMatches(entry_def, str, llvm::StringRef(), matches); + AddMatches(entry_def, str, llvm::StringRef(), request.GetMatches()); } else { // We have a partial match // "${thre" <TAB> - AddMatches(entry_def, str, remainder, matches); + AddMatches(entry_def, str, remainder, request.GetMatches()); } - return matches.GetSize(); + return request.GetMatches().GetSize(); } |