59#include "llvm/ADT/STLExtras.h"
60#include "llvm/ADT/StringRef.h"
61#include "llvm/Support/Compiler.h"
62#include "llvm/Support/Regex.h"
63#include "llvm/TargetParser/Triple.h"
108 Definition(
"flags", EntryType::FrameRegisterTypeFlags),
109 Definition(
"no-debug", EntryType::FrameNoDebug),
112 Definition(
"is-artificial", EntryType::FrameIsArtificial),
114 Definition(
"borrowed-info", EntryType::FrameBorrowedInfo),
120 Definition(
"name-without-args", EntryType::FunctionNameNoArgs),
121 Definition(
"name-with-args", EntryType::FunctionNameWithArgs),
122 Definition(
"mangled-name", EntryType::FunctionMangledName),
123 Definition(
"addr-offset", EntryType::FunctionAddrOffset),
124 Definition(
"concrete-only-addr-offset-no-padding",
125 EntryType::FunctionAddrOffsetConcrete),
126 Definition(
"line-offset", EntryType::FunctionLineOffset),
127 Definition(
"pc-offset", EntryType::FunctionPCOffset),
128 Definition(
"initial-function", EntryType::FunctionInitial),
129 Definition(
"changed", EntryType::FunctionChanged),
130 Definition(
"is-optimized", EntryType::FunctionIsOptimized),
131 Definition(
"is-inlined", EntryType::FunctionIsInlined),
132 Definition(
"prefix", EntryType::FunctionPrefix),
133 Definition(
"scope", EntryType::FunctionScope),
134 Definition(
"basename", EntryType::FunctionBasename),
135 Definition(
"name-qualifiers", EntryType::FunctionNameQualifiers),
136 Definition(
"template-arguments", EntryType::FunctionTemplateArguments),
137 Definition(
"formatted-arguments", EntryType::FunctionFormattedArguments),
138 Definition(
"return-left", EntryType::FunctionReturnLeft),
139 Definition(
"return-right", EntryType::FunctionReturnRight),
140 Definition(
"qualifiers", EntryType::FunctionQualifiers),
141 Definition(
"suffix", EntryType::FunctionSuffix),
147 Definition(
"number", EntryType::LineEntryLineNumber),
148 Definition(
"column", EntryType::LineEntryColumn),
149 Definition(
"start-addr", EntryType::LineEntryStartAddress),
150 Definition(
"end-addr", EntryType::LineEntryEndAddress),
170 Definition(
"protocol_id", EntryType::ThreadProtocolID),
171 Definition(
"index", EntryType::ThreadIndexID),
176 Definition(
"stop-reason", EntryType::ThreadStopReason),
177 Definition(
"stop-reason-raw", EntryType::ThreadStopReasonRaw),
178 Definition(
"return-value", EntryType::ThreadReturnValue),
179 Definition(
"completed-expression", EntryType::ThreadCompletedExpression)};
187 Definition(
"count", EntryType::ProgressCount),
188 Definition(
"message", EntryType::ProgressMessage)};
190#define _TO_STR2(_val) #_val
191#define _TO_STR(_val) _TO_STR2(_val)
248 Definition(
"process", EntryType::ScriptProcess),
249 Definition(
"target", EntryType::ScriptTarget),
250 Definition(
"thread", EntryType::ScriptThread),
252 Definition(
"svar", EntryType::ScriptVariableSynthetic),
253 Definition(
"thread", EntryType::ScriptThread)};
258 Definition(
"addr-file-or-load", EntryType::AddressLoadOrFile),
260 Definition(
"current-pc-arrow", EntryType::CurrentPCArrow),
286 Definition(
"separator", EntryType::Separator),
311 entries.push_back(
Entry(ch));
313 entries.back().string.append(1, ch);
319 entries.push_back(
Entry(s));
321 entries.back().string.append(s.data(), s.size());
330 entries.push_back(entry);
339#define ENUM_TO_CSTR(eee) \
340 case FormatEntity::Entry::Type::eee: \
435 s.
Printf(
"string = \"%s\"",
string.c_str());
444 for (
const auto &child : children)
445 child.Dump(s, depth + 1);
452 const char *script_function_name) {
458 if (script_interpreter) {
460 std::string script_output;
463 script_output,
error) &&
478 bool print_file_addr_or_load_addr) {
493 if (print_file_addr_or_load_addr) {
499 s.
Printf(
"0x%*.*" PRIx64, addr_width, addr_width, vaddr);
508 bool concrete_only,
bool no_padding,
509 bool print_zero_offsets) {
516 if (sc->
block && !concrete_only) {
523 format_addr, inline_range))
531 const char *addr_offset_padding = no_padding ?
"" :
" ";
536 if (addr_file_addr > func_file_addr ||
537 (addr_file_addr == func_file_addr && print_zero_offsets)) {
538 s.
Printf(
"%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding,
539 addr_file_addr - func_file_addr);
540 }
else if (addr_file_addr < func_file_addr) {
541 s.
Printf(
"%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding,
542 func_file_addr - addr_file_addr);
550 if (addr_load_addr > func_load_addr ||
551 (addr_load_addr == func_load_addr && print_zero_offsets)) {
552 s.
Printf(
"%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding,
553 addr_load_addr - func_load_addr);
554 }
else if (addr_load_addr < func_load_addr) {
555 s.
Printf(
"%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding,
556 func_load_addr - addr_load_addr);
567 size_t &close_bracket_index,
568 const char *&var_name_final_if_array_range,
569 int64_t &index_lower, int64_t &index_higher) {
571 close_bracket_index = llvm::StringRef::npos;
572 const size_t open_bracket_index = subpath.find(
'[');
573 if (open_bracket_index == llvm::StringRef::npos) {
575 "[ScanBracketedRange] no bracketed range, skipping entirely");
579 close_bracket_index = subpath.find(
']', open_bracket_index + 1);
581 if (close_bracket_index == llvm::StringRef::npos) {
583 "[ScanBracketedRange] no bracketed range, skipping entirely");
586 var_name_final_if_array_range = subpath.data() + open_bracket_index;
588 if (close_bracket_index - open_bracket_index == 1) {
591 "[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
594 const size_t separator_index = subpath.find(
'-', open_bracket_index + 1);
596 if (separator_index == llvm::StringRef::npos) {
597 const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
598 index_lower = ::strtoul(index_lower_cstr,
nullptr, 0);
599 index_higher = index_lower;
601 "[ScanBracketedRange] [%" PRId64
602 "] detected, high index is same",
605 const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
606 const char *index_higher_cstr = subpath.data() + separator_index + 1;
607 index_lower = ::strtoul(index_lower_cstr,
nullptr, 0);
608 index_higher = ::strtoul(index_higher_cstr,
nullptr, 0);
610 "[ScanBracketedRange] [%" PRId64
"-%" PRId64
"] detected",
611 index_lower, index_higher);
613 if (index_lower > index_higher && index_higher > 0) {
614 LLDB_LOGF(log,
"[ScanBracketedRange] swapping indices");
615 const int64_t temp = index_lower;
616 index_lower = index_higher;
634 formatters::StringPrinter::StringElementType::UTF8>(options);
667 uint32_t reg_num,
Format format) {
672 const uint32_t lldb_reg_num =
691 bool deref_pointer) {
693 std::string name_to_deref = llvm::formatv(
"[{0}]", index);
694 LLDB_LOG(log,
"[ExpandIndexedExpression] name to deref: {0}", name_to_deref);
702 name_to_deref, &reason_to_stop, &final_value_type, options, &what_next);
705 "[ExpandIndexedExpression] ERROR: why stopping = %d,"
706 " final_value_type %d",
707 reason_to_stop, final_value_type);
710 "[ExpandIndexedExpression] ALL RIGHT: why stopping = %d,"
711 " final_value_type %d",
712 reason_to_stop, final_value_type);
746 std::string formatted;
747 std::string llvm_format = (
"{0:" + options +
"}").str();
751 if (type_info & eTypeIsSigned) {
752 bool success =
false;
755 formatted = llvm::formatv(llvm_format.data(),
integer);
757 bool success =
false;
760 formatted = llvm::formatv(llvm_format.data(),
integer);
764 if (formatted.empty())
767 s.
Write(formatted.data(), formatted.size());
774 if (valobj ==
nullptr)
784 bool do_deref_pointer = entry.
deref;
785 bool is_script =
false;
786 switch (entry.
type) {
792 custom_format = entry.
fmt;
800 custom_format = entry.
fmt;
804 if (valobj ==
nullptr)
822 SyntheticChildrenTraversal::Both);
824 const char *var_name_final_if_array_range =
nullptr;
825 size_t close_bracket_index = llvm::StringRef::npos;
826 int64_t index_lower = -1;
827 int64_t index_higher = -1;
828 bool is_array_range =
false;
829 bool was_plain_var =
false;
830 bool was_var_format =
false;
831 bool was_var_indexed =
false;
842 auto split = llvm::StringRef(entry.
string).split(
':');
843 auto subpath = split.first;
844 auto llvm_format = split.second;
847 if (subpath.empty()) {
850 was_plain_var =
true;
852 was_var_format =
true;
856 if (subpath[0] ==
'[')
857 was_var_indexed =
true;
859 var_name_final_if_array_range, index_lower,
864 LLDB_LOG(log,
"[Debugger::FormatPrompt] symbol to expand: {0}", subpath);
869 &final_value_type, options, &what_next)
874 "[Debugger::FormatPrompt] ERROR: why stopping = %d,"
875 " final_value_type %d",
876 reason_to_stop, final_value_type);
880 "[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d,"
881 " final_value_type %d",
882 reason_to_stop, final_value_type);
899 if (do_deref_pointer && !is_array_range) {
906 LLDB_LOGF(log,
"[Debugger::FormatPrompt] ERROR: %s\n",
907 error.AsCString(
"unknown"));
910 do_deref_pointer =
false;
914 LLDB_LOGF(log,
"[Debugger::FormatPrompt] could not calculate target for "
915 "prompt expression");
922 if (target->
IsBitfield() && was_var_indexed) {
927 auto type_sp = std::make_shared<TypeNameSpecifierImpl>(
929 if (val_obj_display ==
936 const uint32_t type_info_flags =
938 bool is_array = (type_info_flags & eTypeIsArray) != 0;
939 bool is_pointer = (type_info_flags & eTypeIsPointer) != 0;
942 if ((is_array || is_pointer) && (!is_array_range) &&
951 "[Debugger::FormatPrompt] I am into array || pointer && !range");
957 str_temp, val_obj_display, custom_format);
958 LLDB_LOGF(log,
"[Debugger::FormatPrompt] special cases did%s match",
959 success ?
"" :
"n't");
969 }
else if (is_pointer)
972 s, val_obj_display, custom_format,
981 if (is_aggregate && was_plain_var) {
992 s <<
"<invalid use of aggregate type>";
996 if (!is_array_range) {
997 if (!llvm_format.empty()) {
999 LLDB_LOGF(log,
"dumping using llvm format");
1004 "empty output using llvm format '{0}' - with type info flags {1}",
1008 LLDB_LOGF(log,
"dumping ordinary printable output");
1013 "[Debugger::FormatPrompt] checking if I can handle as array");
1014 if (!is_array && !is_pointer)
1016 LLDB_LOGF(log,
"[Debugger::FormatPrompt] handle as array");
1018 llvm::StringRef special_directions;
1019 if (close_bracket_index != llvm::StringRef::npos &&
1020 subpath.size() > close_bracket_index) {
1021 llvm::StringRef additional_data(
1022 subpath.drop_front(close_bracket_index + 1));
1023 special_directions_stream
1025 << llvm::formatv(
"{0}var{1}", do_deref_pointer ?
"*" :
"",
1029 const char format_char =
1031 if (format_char !=
'\0')
1032 special_directions_stream.
Printf(
"%%%c", format_char);
1034 const char *format_cstr =
1036 special_directions_stream.
Printf(
"%%%s", format_cstr);
1038 }
else if (entry.
number != 0) {
1042 special_directions_stream.
Printf(
"%%%c", style_char);
1044 special_directions_stream.
PutChar(
'}');
1045 special_directions =
1046 llvm::StringRef(special_directions_stream.
GetString());
1052 if (index_higher < 0)
1055 uint32_t max_num_children =
1056 target->
GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
1058 bool success =
true;
1059 for (int64_t index = index_lower; index <= index_higher; ++index) {
1064 "[Debugger::FormatPrompt] ERROR in getting child item at "
1070 "[Debugger::FormatPrompt] special_directions for child item: %s",
1071 special_directions.data() ? special_directions.data() :
"");
1074 if (special_directions.empty()) {
1081 if (--max_num_children == 0) {
1086 if (index < index_higher)
1117 llvm::StringRef path(entry.
string);
1120 thread_info_dictionary->GetObjectForDotSeparatedPath(path);
1124 const char *token_format =
"0x%4.4" PRIx64;
1127 s.
Printf(token_format, value->GetUnsignedIntegerValue());
1130 s.
Printf(
"%f", value->GetAsFloat()->GetValue());
1133 s.
Format(
"{0}", value->GetAsString()->GetValue());
1136 if (value->GetAsArray()->GetSize() > 0) {
1137 s.
Printf(
"%zu", value->GetAsArray()->GetSize());
1142 value->GetAsDictionary()->GetKeys()->GetAsArray()->GetSize());
1150static inline bool IsToken(
const char *var_name_begin,
const char *var) {
1151 return (::strncmp(var_name_begin, var, strlen(var)) == 0);
1161static std::pair<char const *, char const *>
1163 const char *open_paren = strchr(full_name,
'(');
1164 const char *close_paren =
nullptr;
1165 const char *
generic = strchr(full_name,
'<');
1169 if (generic && open_paren && generic < open_paren) {
1170 int generic_depth = 1;
1172 for (; *
generic && generic_depth > 0;
generic++) {
1173 if (*generic ==
'<')
1175 if (*generic ==
'>')
1179 open_paren = strchr(generic,
'(');
1181 open_paren =
nullptr;
1185 if (
IsToken(open_paren,
"(anonymous namespace)")) {
1186 open_paren = strchr(open_paren + strlen(
"(anonymous namespace)"),
'(');
1188 close_paren = strchr(open_paren,
')');
1190 close_paren = strchr(open_paren,
')');
1193 return {open_paren, close_paren};
1200 char const *full_name,
1205 out_stream.
Write(full_name, open_paren - full_name + 1);
1224 return inline_block->GetBlockVariableList(
true);
1260 Language *language_plugin =
nullptr;
1261 bool language_plugin_handled =
false;
1268 if (language_plugin)
1272 if (language_plugin_handled) {
1295 Language *language_plugin =
nullptr;
1298 else if (
m_sc->symbol)
1301 if (!language_plugin)
1311 const bool success =
Format(format, name_stream,
nullptr);
1320 if (!format_str.empty()) {
1323 if (
error.Success()) {
1324 return Format(root, s, valobj);
1334 "Error: detected recursive format entity: {0}",
1341 switch (entry.
type) {
1350 Debugger &debugger = target->GetDebugger();
1360 if (!
Format(child, s, valobj)) {
1372 auto format_children = [&](
const std::vector<Entry> &children) {
1373 scope_stream.
Clear();
1374 for (
const auto &child : children) {
1375 if (!
Format(child, scope_stream, valobj))
1382 if (format_children(children)) {
1410 const char *format =
"%" PRIu64;
1445 const char *format =
"0x%4.4" PRIx64;
1452 Target &target = thread->GetProcess()->GetTarget();
1454 llvm::Triple::OSType ostype = arch.
IsValid()
1456 : llvm::Triple::UnknownOS;
1457 if (ostype == llvm::Triple::FreeBSD ||
1458 ostype == llvm::Triple::Linux ||
1459 ostype == llvm::Triple::NetBSD ||
1460 ostype == llvm::Triple::OpenBSD) {
1461 format =
"%" PRIu64;
1467 s.
Printf(format, thread->GetID());
1477 const char *format =
"0x%4.4" PRIx64;
1480 s.
Printf(format, thread->GetProtocolID());
1490 const char *format =
"%" PRIu32;
1493 s.
Printf(format, thread->GetIndexID());
1503 const char *cstr = thread->GetName();
1504 if (cstr && cstr[0]) {
1516 const char *cstr = thread->GetQueueName();
1517 if (cstr && cstr[0]) {
1528 std::string stop_description = thread->GetStopDescription();
1529 if (!stop_description.empty()) {
1540 std::string stop_description = thread->GetStopDescriptionRaw();
1541 if (!stop_description.empty()) {
1553 StopInfoSP stop_info_sp = thread->GetStopInfo();
1554 if (stop_info_sp && stop_info_sp->IsValid()) {
1558 if (
auto *returned = std::get_if<ReturnedValue>(&return_value))
1559 return_valobj_sp = returned->valobj_sp;
1560 else if (
auto *thrown = std::get_if<ThrownError>(&return_value))
1561 return_valobj_sp = thrown->valobj_sp;
1562 if (return_valobj_sp) {
1564 if (return_valobj_sp->IsDynamic())
1566 if (return_valobj_sp->DoesProvideSyntheticValue())
1568 if (llvm::Error
error = return_valobj_sp->Dump(s, options)) {
1583 StopInfoSP stop_info_sp = thread->GetStopInfo();
1584 if (stop_info_sp && stop_info_sp->IsValid()) {
1587 if (expression_var_sp && expression_var_sp->GetValueObject()) {
1588 if (llvm::Error
error =
1589 expression_var_sp->GetValueObject()->Dump(s)) {
1640 if (
Module *exe_module = target->GetExecutableModulePointer()) {
1681 const char *lang_name =
1695 const char *format =
"%" PRIu32;
1772 return frame->IsArtificial();
1779 if (frame->IsSynthetic())
1781 else if (frame->IsHistorical())
1792 llvm::dyn_cast<BorrowedStackFrame>(frame)) {
1794 borrowed_frame->GetBorrowedFrame()) {
1795 s.
Printf(
" [borrowed from frame #%u]",
1796 borrowed_from_sp->GetFrameIndex());
1815 if (
m_sc->function) {
1816 s.
Printf(
"function{0x%8.8" PRIx64
"}",
m_sc->function->GetID());
1818 }
else if (
m_sc->symbol) {
1819 s.
Printf(
"symbol[%u]",
m_sc->symbol->GetID());
1833 Language *language_plugin =
nullptr;
1834 bool language_plugin_handled =
false;
1839 else if (
m_sc->symbol)
1842 if (language_plugin)
1846 if (language_plugin_handled) {
1851 const char *name =
m_sc->GetPossiblyInlinedFunctionName()
1853 .AsCString(
nullptr);
1876 Language *language_plugin =
nullptr;
1877 bool language_plugin_handled =
false;
1881 else if (
m_sc->symbol)
1884 if (language_plugin)
1889 if (language_plugin_handled) {
1895 m_sc->GetPossiblyInlinedFunctionName()
1898 .AsCString(
nullptr);
1929 Language *language_plugin =
nullptr;
1932 else if (
m_sc->symbol)
1935 if (!language_plugin)
1968 const char *name =
m_sc->GetPossiblyInlinedFunctionName()
1970 .AsCString(
nullptr);
2016 bool is_optimized =
false;
2017 if (
m_sc &&
m_sc->function &&
m_sc->function->GetIsOptimized()) {
2018 is_optimized =
true;
2020 return is_optimized;
2024 return m_sc &&
m_sc->block &&
m_sc->block->GetInlinedFunctionInfo();
2031 if (
m_sc &&
m_sc->line_entry.IsValid()) {
2038 if (
m_sc &&
m_sc->line_entry.IsValid()) {
2039 const char *format =
"%" PRIu32;
2048 if (
m_sc &&
m_sc->line_entry.IsValid() &&
m_sc->line_entry.column) {
2049 const char *format =
"%" PRIu32;
2059 if (
m_sc &&
m_sc->line_entry.range.GetBaseAddress().IsValid()) {
2060 Address addr =
m_sc->line_entry.range.GetBaseAddress();
2063 addr.
Slide(
m_sc->line_entry.range.GetByteSize());
2072 m_exe_ctx->GetFramePtr()->GetRegisterContextSP();
2074 addr_t pc_loadaddr = reg_ctx->GetPC();
2077 pc.SetLoadAddress(pc_loadaddr,
m_exe_ctx->GetTargetPtr());
2091 if (
auto progress = target->GetDebugger().GetCurrentProgressReport()) {
2093 s.
Format(
"[{0:N}/{1:N}]", progress->completed, progress->total);
2102 if (
auto progress = target->GetDebugger().GetCurrentProgressReport()) {
2111 s << target->GetDebugger().GetSeparator();
2124 for (
size_t i = 0; i < n; ++i) {
2138 const size_t sep_pos = format_str.find_first_of(
".[:");
2139 const char sep_char =
2140 (sep_pos == llvm::StringRef::npos) ?
'\0' : format_str[sep_pos];
2141 llvm::StringRef key = format_str.substr(0, sep_pos);
2144 for (
size_t i = 0; i < n; ++i) {
2146 if (key == entry_def->
name || entry_def->
name[0] ==
'*') {
2147 llvm::StringRef value;
2150 format_str.substr(sep_pos + (entry_def->
keep_separator ? 0 : 1));
2151 switch (entry_def->
type) {
2153 entry.
string = format_str.str();
2170 if (value.empty()) {
2174 error_strm.
Printf(
"'%s' can't be specified on its own, you must "
2175 "access one of its children: ",
2180 }
else if (sep_char ==
':') {
2187 "%s",
"invalid entry definitions");
2193 }
else if (sep_char ==
':') {
2197 entry.
string = value.str();
2200 "'%s' followed by '%s' but it has no children", key.str().c_str(),
2201 value.str().c_str());
2210 "invalid top level item '%s'. Valid top level items are: ",
2213 error_strm.
Printf(
"invalid member '%s' in '%s'. Valid members are: ",
2214 key.str().c_str(), parent->
name);
2222 llvm::StringRef &remainder) {
2225 std::pair<llvm::StringRef, llvm::StringRef> p = format_str.split(
'.');
2227 for (
size_t i = 0; i < n; ++i) {
2229 if (p.first == entry_def->
name || entry_def->
name[0] ==
'*') {
2230 if (p.second.empty()) {
2231 if (format_str.back() ==
'.')
2232 remainder = format_str.drop_front(format_str.size() - 1);
2234 remainder = llvm::StringRef();
2238 return FindEntry(p.second, entry_def, remainder);
2240 remainder = p.second;
2246 remainder = format_str;
2253 while (!format.empty() &&
error.Success()) {
2254 const size_t non_special_chars = format.find_first_of(
"${}\\|");
2256 if (non_special_chars == llvm::StringRef::npos) {
2262 if (non_special_chars > 0) {
2265 parent_entry.
AppendText(format.substr(0, non_special_chars));
2266 format = format.drop_front(non_special_chars);
2269 switch (format[0]) {
2274 format = format.drop_front();
2292 format = format.drop_front();
2300 format = format.drop_front();
2301 if (format.empty()) {
2303 "'\\' character was not followed by another character");
2307 const char desens_char = format[0];
2308 format = format.drop_front();
2309 switch (desens_char) {
2342 char oct_str[5] = {0, 0, 0, 0, 0};
2345 for (i = 0; (format[i] >=
'0' && format[i] <=
'7') && i < 4; ++i)
2346 oct_str[i] = format[i];
2351 format = format.drop_front(i);
2352 unsigned long octal_value = ::strtoul(oct_str,
nullptr, 8);
2353 if (octal_value <= UINT8_MAX) {
2357 "octal number is larger than a single byte");
2365 if (isxdigit(format[0])) {
2368 char hex_str[3] = {0, 0, 0};
2369 hex_str[0] = format[0];
2371 format = format.drop_front();
2373 if (isxdigit(format[0])) {
2374 hex_str[1] = format[0];
2375 format = format.drop_front();
2378 unsigned long hex_value = strtoul(hex_str,
nullptr, 16);
2379 if (hex_value <= UINT8_MAX) {
2383 "hex number is larger than a single byte");
2400 format = format.drop_front();
2401 if (format.empty() || format.front() !=
'{') {
2405 format = format.drop_front();
2407 llvm::StringRef variable, variable_format;
2412 bool verify_is_thread_id =
false;
2414 if (!variable_format.empty()) {
2426 bool clear_printf =
false;
2431 entry.
number = ValueObject::
2432 eValueObjectRepresentationStyleLanguageSpecific;
2433 clear_printf =
true;
2439 clear_printf =
true;
2444 clear_printf =
true;
2449 clear_printf =
true;
2454 clear_printf =
true;
2458 clear_printf =
true;
2462 clear_printf =
true;
2467 clear_printf =
true;
2475 clear_printf =
true;
2477 verify_is_thread_id =
true;
2493 if (variable[0] ==
'*') {
2495 variable = variable.drop_front();
2502 llvm::StringRef entry_string(entry.
string);
2503 if (entry_string.contains(
':')) {
2504 auto [_, llvm_format] = entry_string.split(
':');
2507 "invalid llvm format: '%s'", llvm_format.data());
2512 if (verify_is_thread_id) {
2516 "the 'tid' format can only be used on "
2517 "${thread.id} and ${thread.protocol_id}");
2521 switch (entry.
type) {
2525 if (entry.
string.empty())
2537 "${%s} can't be dereferenced, only ${var} and ${svar} can.",
2538 variable.str().c_str());
2551 llvm::StringRef &variable_name,
2552 llvm::StringRef &variable_format) {
2554 variable_name = llvm::StringRef();
2555 variable_format = llvm::StringRef();
2557 const size_t paren_pos = format_str.find(
'}');
2558 if (paren_pos != llvm::StringRef::npos) {
2559 const size_t percent_pos = format_str.find(
'%');
2560 if (percent_pos < paren_pos) {
2561 if (percent_pos > 0) {
2562 if (percent_pos > 1)
2563 variable_name = format_str.substr(0, percent_pos);
2565 format_str.substr(percent_pos + 1, paren_pos - (percent_pos + 1));
2568 variable_name = format_str.substr(0, paren_pos);
2571 format_str = format_str.substr(paren_pos + 1);
2574 "missing terminating '}' character for '${%s'",
2575 format_str.str().c_str());
2581 llvm::StringRef variable_name,
2582 llvm::StringRef variable_format) {
2583 if (variable_name.empty() || variable_name ==
".fullpath") {
2586 }
else if (variable_name ==
".basename") {
2589 }
else if (variable_name ==
".dirname") {
2597 const char *suffix) {
2598 std::string match(prefix.str());
2599 match.append(suffix);
2604 const llvm::StringRef &match_prefix,
2608 for (
size_t i = 0; i < n; ++i) {
2609 if (match_prefix.empty())
2611 else if (strncmp(def->
children[i].
name, match_prefix.data(),
2612 match_prefix.size()) == 0)
2622 const size_t dollar_pos = str.rfind(
'$');
2623 if (dollar_pos == llvm::StringRef::npos)
2627 if (dollar_pos == str.size() - 1) {
2628 std::string match = str.str();
2634 if (str[dollar_pos + 1] !=
'{')
2637 const size_t close_pos = str.find(
'}', dollar_pos + 2);
2638 if (close_pos != llvm::StringRef::npos)
2641 const size_t format_pos = str.find(
'%', dollar_pos + 2);
2642 if (format_pos != llvm::StringRef::npos)
2645 llvm::StringRef partial_variable(str.substr(dollar_pos + 2));
2646 if (partial_variable.empty()) {
2655 llvm::StringRef remainder;
2662 if (remainder.empty()) {
2671 }
else if (remainder ==
".") {
2674 AddMatches(entry_def, str, llvm::StringRef(), new_matches);
2680 AddMatches(entry_def, str, remainder, new_matches);
2688 const size_t num_args = args.
GetSize();
2689 for (
size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
2695 llvm::StringRef var_representation;
2696 const char *var_name = var_value_sp->GetName().GetCString();
2697 if (var_value_sp->GetCompilerType().IsValid()) {
2699 var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(
2701 ->TargetProperties::GetPreferDynamicValue(),
2703 ->TargetProperties::GetEnableSyntheticValue());
2704 if (var_value_sp->GetCompilerType().IsAggregateType() &&
2707 .SetHideItemNames(
false)
2708 .SetShowMembersOneLiner(
true),
2711 var_representation = buffer;
2713 var_value_sp->DumpPrintableRepresentation(
2716 eValueObjectRepresentationStyleSummary,
2725 if (var_value_sp->GetError().Success()) {
2726 if (!var_representation.empty())
2727 out_stream.
Printf(
"%s=%s", var_name, var_representation.str().c_str());
2729 out_stream.
Printf(
"%s=%s at %s", var_name,
2730 var_value_sp->GetTypeName().GetCString(),
2731 var_value_sp->GetLocationAsCString());
2733 out_stream.
Printf(
"%s=<unavailable>", var_name);
2740 llvm::StringRef modifiable_format(format_str);
2751 static constexpr std::array s_permitted_recursive_entities = {
2754 if (llvm::is_contained(s_permitted_recursive_entities, type))
#define ANSI_BG_COLOR_PURPLE
#define ANSI_CTRL_UNDERLINE
#define ANSI_BG_COLOR_RED
#define ANSI_FG_COLOR_BLACK
#define ANSI_BG_COLOR_YELLOW
#define ANSI_BG_COLOR_BLACK
#define ANSI_FG_COLOR_YELLOW
#define ANSI_FG_COLOR_PURPLE
#define ANSI_BG_COLOR_CYAN
#define ANSI_BG_COLOR_GREEN
#define ANSI_CTRL_SLOW_BLINK
#define ANSI_FG_COLOR_RED
#define ANSI_BG_COLOR_BLUE
#define ANSI_FG_COLOR_CYAN
#define ANSI_CTRL_FAST_BLINK
#define ANSI_CTRL_CROSSED_OUT
#define ANSI_CTRL_IMAGE_NEGATIVE
#define ANSI_BG_COLOR_WHITE
#define ANSI_CTRL_CONCEAL
#define ANSI_FG_COLOR_GREEN
#define ANSI_FG_COLOR_BLUE
#define ANSI_FG_COLOR_WHITE
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
@ DumpStyleLoadAddress
Display as the load address (if resolved).
bool Slide(int64_t offset)
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump a description of this object to a Stream.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A class that describes a single lexical block.
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
"lldb/Target/BorrowedStackFrame.h"
A class that describes a compilation unit.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
lldb::LanguageType GetLanguage()
bool IsAggregateType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
void AddCompletions(const StringList &completions)
Adds multiple possible completion strings.
llvm::StringRef GetCursorArgumentPrefix() const
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
static bool ShouldPrintAsOneLiner(ValueObject &valobj)
static lldb::TypeSummaryImplSP GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp)
A class to manage flag bits.
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
DumpValueObjectOptions & SetUseSyntheticValue(bool use_synthetic=true)
DumpValueObjectOptions & SetUseDynamicType(lldb::DynamicValueType dyn=lldb::eNoDynamicValues)
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual lldb::TargetSP CalculateTarget()=0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
llvm::StringRef GetFilename() const
Filename string const get accessor.
llvm::StringRef GetDirectory() const
Directory string const get accessor.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
const Address & GetAddress() const
Return the address of the function (its entry point).
lldb::LanguageType GetLanguage() const
Block & GetBlock(bool can_create)
Get accessor for the block list.
virtual bool HandleFrameFormatVariable(const SymbolContext &sc, const ExecutionContext *exe_ctx, FormatEntity::Entry::Type type, Stream &s)
static Language * FindPlugin(lldb::LanguageType language)
static const char * GetNameForLanguageType(lldb::LanguageType language)
Returns the internal LLDB name for the specified language.
virtual bool GetFunctionDisplayName(const SymbolContext &sc, const ExecutionContext *exe_ctx, FunctionNameRepresentation representation, Stream &s)
virtual FormatEntity::Entry GetFunctionNameFormat() const
@ ePreferDemangledWithoutArguments
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
A class that describes an executable image and its associated object and symbol files.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
A plug-in interface definition class for debugging a process.
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Target & GetTarget()
Get the target object pointer for this module.
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
Convert from a given register numbering scheme to the lldb register numbering scheme.
virtual const RegisterInfo * GetRegisterInfoAtIndex(size_t reg)=0
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)=0
virtual bool RunScriptFormatKeyword(const char *impl_function, Process *process, std::string &output, Status &error)
This base class provides an interface to stack frames.
virtual const char * GetFunctionName()
Get the frame's demangled name.
virtual lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
virtual const char * GetDisplayFunctionName()
Get the frame's demangled display name.
virtual uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
virtual bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
virtual const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static ThreadPlanReturnValue GetReturnValue(lldb::StopInfoSP &stop_info_sp)
static lldb::ExpressionVariableSP GetExpressionVariable(lldb::StopInfoSP &stop_info_sp)
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
void AppendString(const std::string &s)
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
Symbol * symbol
The Symbol for a given query.
Mangled GetPossiblyInlinedFunctionName() const
If available, will return the function name according to the specified mangling preference.
bool ValueIsAddress() const
lldb::LanguageType GetLanguage() const
Address & GetAddressRef()
ConstString GetName() const
Module * GetExecutableModulePointer()
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Debugger & GetDebugger() const
const ArchSpec & GetArchitecture() const
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
virtual uint32_t GetBitfieldBitSize()
bool DumpPrintableRepresentation(Stream &s, ValueObjectRepresentationStyle val_obj_display=eValueObjectRepresentationStyleSummary, lldb::Format custom_format=lldb::eFormatInvalid, PrintableRepresentationSpecialCases special=PrintableRepresentationSpecialCases::eAllow, bool do_dump_error=true)
lldb::ValueObjectSP GetSyntheticValue()
ExpressionPathScanEndReason
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
@ eExpressionPathAftermathNothing
Just return it.
@ eExpressionPathAftermathDereference
Dereference the target.
lldb::ValueObjectSP GetValueForExpressionPath(llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop=nullptr, ExpressionPathEndResultType *final_value_type=nullptr, const GetValueForExpressionPathOptions &options=GetValueForExpressionPathOptions::DefaultOptions(), ExpressionPathAftermath *final_task_on_target=nullptr)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
virtual ConstString GetTypeName()
lldb::DynamicValueType GetDynamicValueType()
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr)
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
lldb::TargetSP GetTargetSP() const
ExpressionPathEndResultType
@ eExpressionPathEndResultTypePlain
Anything but...
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
virtual lldb::ValueObjectSP Dereference(Status &error)
CompilerType GetCompilerType()
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
virtual const char * GetLocationAsCString()
virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success=nullptr)
ValueObjectRepresentationStyle
@ eValueObjectRepresentationStyleLocation
@ eValueObjectRepresentationStyleSummary
@ eValueObjectRepresentationStyleName
@ eValueObjectRepresentationStyleType
@ eValueObjectRepresentationStyleChildrenCount
@ eValueObjectRepresentationStyleExpressionPath
@ eValueObjectRepresentationStyleValue
@ eValueObjectRepresentationStyleLanguageSpecific
virtual bool IsSynthetic()
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
lldb::VariableSP GetVariableAtIndex(size_t idx) const
size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list, bool if_unique=true)
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_FP
lldb::ByteOrder InlHostByteOrder()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
void DumpRegisterValue(const RegisterValue ®_val, Stream &s, const RegisterInfo ®_info, bool prefix_with_name, bool prefix_with_alt_name, lldb::Format format, uint32_t reg_name_right_align_at=0, ExecutionContextScope *exe_scope=nullptr, bool print_type=false, lldb::TargetSP target_sp=nullptr)
std::variant< std::monostate, ReturnedValue, ThrownError > ThreadPlanReturnValue
What a completed thread plan computed for the function it stepped out of or called: nothing,...
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
Format
Display format definitions.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
@ eValueTypeVariableArgument
function argument variables
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
@ eStructuredDataTypeFloat
@ eStructuredDataTypeDictionary
@ eStructuredDataTypeInteger
@ eStructuredDataTypeArray
@ eStructuredDataTypeString
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
RegisterKind
Register numbering types.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
const char * name
The name/string placeholder that corresponds to this definition.
const Definition * children
An array of "num_children" Definition entries.
const bool keep_separator
Whether the separator is kept during parsing or not.
const char * string
Insert this exact string into the output.
const uint64_t data
Data that is returned as the value of the format string.
const uint32_t num_children
The number of children of this node in the tree of format strings.
const Entry::Type type
Entry::Type corresponding to this definition.
void Dump(Stream &s, int depth=0) const
Entry(Type t=Type::Invalid, const char *s=nullptr, const char *f=nullptr)
void AppendText(const llvm::StringRef &s)
static constexpr Definition DefinitionWithChildren(const char *name, const FormatEntity::Entry::Type t, const Definition(&children)[N], bool keep_separator=false)
std::string printf_format
llvm::SmallVector< std::vector< Entry >, 1 > children_stack
A stack of children entries, used by Scope entries to provide alterantive children.
std::vector< Entry > & GetChildren()
static const char * TypeToCString(Type t)
void AppendEntry(const Entry &&entry)
@ FunctionAddrOffsetConcrete
@ FunctionInitialFunction
@ FunctionTemplateArguments
@ FunctionFormattedArguments
@ ThreadCompletedExpression
@ ScriptVariableSynthetic
Every register is described in detail including its name, alternate name (optional),...
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
GetValueForExpressionPathOptions & DoAllowFragileIVar()
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()
GetValueForExpressionPathOptions & DoAllowBitfieldSyntax()