48#include "llvm/ADT/DenseMap.h"
49#include "llvm/ADT/StringRef.h"
50#include "llvm/Support/Compiler.h"
51#include "llvm/TargetParser/Triple.h"
59#define DEFAULT_DISASM_BYTE_SIZE 32
65 const char *flavor,
const char *cpu,
67 const char *plugin_name) {
76 if (create_callback) {
77 if (
auto disasm_sp = create_callback(arch, flavor, cpu, features))
81 for (uint32_t idx = 0;
85 if (
auto disasm_sp = create_callback(arch, flavor, cpu, features))
94 const char *cpu,
const char *features,
const char *plugin_name) {
99 if (arch.
GetTriple().getArch() == llvm::Triple::x86 ||
100 arch.
GetTriple().getArch() == llvm::Triple::x86_64)
108 return FindPlugin(arch, flavor, cpu, features, plugin_name);
123 if (is_resolved && resolved_addr.
IsValid())
124 return resolved_addr;
130 const ArchSpec &arch,
const char *plugin_name,
const char *flavor,
131 const char *cpu,
const char *features,
Target &target,
132 llvm::ArrayRef<AddressRange> disasm_ranges,
bool force_live_memory) {
134 target, arch, flavor, cpu, features, plugin_name);
139 size_t bytes_disassembled = 0;
141 bytes_disassembled += disasm_sp->AppendInstructions(
142 target, range.GetBaseAddress(), {Limit::Bytes, range.GetByteSize()},
143 nullptr, force_live_memory);
145 if (bytes_disassembled == 0)
153 const char *flavor,
const char *cpu,
154 const char *features,
const Address &start,
155 const void *src,
size_t src_len,
156 uint32_t num_instructions,
bool data_from_file) {
169 (void)disasm_sp->DecodeInstructions(start, data, 0, num_instructions,
false,
175 const char *plugin_name,
const char *flavor,
176 const char *cpu,
const char *features,
179 bool mixed_source_and_assembly,
180 uint32_t num_mixed_context_lines,
181 uint32_t options,
Stream &strm) {
186 exe_ctx.
GetTargetRef(), arch, flavor, cpu, features, plugin_name));
190 const bool force_live_memory =
true;
191 size_t bytes_disassembled = disasm_sp->ParseInstructions(
192 exe_ctx.
GetTargetRef(), address, limit, &strm, force_live_memory);
193 if (bytes_disassembled == 0)
196 disasm_sp->PrintInstructions(debugger, arch, exe_ctx,
197 mixed_source_and_assembly,
198 num_mixed_context_lines, options, strm);
211 SupportFileNSP func_decl_file_sp = std::make_shared<SupportFile>();
212 uint32_t func_decl_line;
215 if (!func_decl_file_sp)
217 if (!func_decl_file_sp->Equal(*prologue_end_line.
file_sp,
224 decl_line.
file = func_decl_file_sp->GetSpecOnly();
225 decl_line.
line = func_decl_line;
234 std::map<
FileSpec, std::set<uint32_t>> &source_lines_seen) {
236 auto source_lines_seen_pos = source_lines_seen.find(line.
file);
237 if (source_lines_seen_pos == source_lines_seen.end()) {
238 std::set<uint32_t> lines;
239 lines.insert(line.
line);
240 source_lines_seen.emplace(line.
file, lines);
242 source_lines_seen_pos->second.insert(line.
line);
261 avoid_regex = thread_sp->GetSymbolsToAvoidRegexp();
266 OptionValueSP value_sp = target_sp->GetDebugger().GetPropertyValue(
267 &exe_ctx,
"target.process.thread.step-avoid-regexp",
error);
276 if (avoid_regex && sc.
symbol !=
nullptr) {
277 const char *function_name =
280 if (function_name && avoid_regex->
Execute(function_name)) {
294 const bool is_live) {
295 annotation_entity.
is_live = is_live;
298 annotations.push_back(std::move(annotation_entity));
315 std::vector<VariableAnnotation> structured_annotations =
318 std::vector<std::string> events;
319 events.reserve(structured_annotations.size());
322 const llvm::StringRef location =
325 : llvm::StringRef(annotation.location_description));
328 llvm::formatv(
"{0} = {1}", annotation.variable_name, location).str());
334std::vector<VariableAnnotation>
336 std::vector<VariableAnnotation> annotations;
351 const auto mask = eSymbolContextFunction | eSymbolContextBlock;
352 if (!module_sp->ResolveSymbolContextForAddress(iaddr, mask, sc) ||
365 auto filter = [](
Variable *v) ->
bool {
return v && !v->IsArtificial(); };
366 B->AppendVariables(
true,
378 ABI *abi = abi_sp.get();
380 llvm::DIDumpOptions opts;
381 opts.ShowAddresses =
false;
383 opts.PrintRegisterOnly =
static_cast<bool>(abi_sp);
385 llvm::DenseMap<lldb::user_id_t, VariableAnnotation> current_vars;
387 for (
size_t i = 0, e = var_list.
GetSize(); i != e; ++i) {
389 if (!v || v->IsArtificial())
392 const char *nm = v->GetName().AsCString();
393 llvm::StringRef name = nm ? nm :
"<anon>";
403 auto entry = *entry_or_err;
408 llvm::StringRef loc = llvm::StringRef(loc_ss.
GetString()).trim();
412 std::optional<std::string> decl_file;
413 std::optional<uint32_t> decl_line;
414 std::optional<std::string> type_name;
423 if (
Type *type = v->GetType())
424 if (
const char *type_str = type->GetName().AsCString())
425 type_name = type_str;
427 current_vars.try_emplace(
430 entry.expr->GetRegisterKind(), entry.file_range,
431 decl_file, decl_line, type_name});
437 for (
const auto &KV : current_vars) {
442 else if (it->second.location_description != KV.second.location_description)
450 if (!current_vars.count(KV.first))
460 bool mixed_source_and_assembly,
461 uint32_t num_mixed_context_lines,
462 uint32_t options,
Stream &strm) {
466 const uint32_t max_opcode_byte_size =
471 const Address *pc_addr_ptr =
nullptr;
481 const uint32_t scope =
482 eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
483 const bool use_inline_block_range =
false;
489 disassembly_format = &format;
492 disassembly_format = &format;
503 std::map<FileSpec, std::set<uint32_t>> source_lines_seen;
504 Symbol *previous_symbol =
nullptr;
506 size_t address_text_size = 0;
507 for (
size_t i = 0; i < num_instructions_found; ++i) {
513 const SymbolContextItem resolve_mask = eSymbolContextFunction |
514 eSymbolContextSymbol |
515 eSymbolContextLineEntry;
516 uint32_t resolved_mask =
517 module_sp->ResolveSymbolContextForAddress(addr, resolve_mask, sc);
521 &exe_ctx, &addr, strmstr);
523 if (cur_line > address_text_size)
524 address_text_size = cur_line;
534 if (sc.
symbol != previous_symbol) {
555 previous_symbol =
nullptr;
557 for (
size_t i = 0; i < num_instructions_found; ++i) {
562 const bool inst_is_at_pc = pc_addr_ptr && addr == *pc_addr_ptr;
569 uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(
570 addr, eSymbolContextEverything, sc);
572 if (mixed_source_and_assembly) {
577 if (previous_symbol != sc.
symbol) {
582 if (previous_symbol !=
nullptr)
585 previous_symbol = sc.
symbol;
589 prologue_end_line)) {
591 std::make_shared<SupportFile>();
592 uint32_t func_decl_line;
595 if (func_decl_file_sp &&
596 (func_decl_file_sp->Equal(
599 func_decl_file_sp->Equal(
605 for (uint32_t lineno = func_decl_line;
606 lineno <= prologue_end_line.
line; lineno++) {
608 this_line.
file = func_decl_file_sp->GetSpecOnly();
609 this_line.
line = lineno;
610 source_lines_to_display.
lines.push_back(this_line);
614 if (source_lines_to_display.
lines.size() > 0)
616 source_lines_to_display.
lines.size() - 1;
621 current_source_line_range);
628 current_source_line_range);
642 if (this_line != previous_line) {
644 std::vector<uint32_t> previous_lines;
646 i < num_mixed_context_lines &&
647 (this_line.
line - num_mixed_context_lines) > 0;
650 this_line.
line - num_mixed_context_lines + i;
651 auto pos = source_lines_seen.find(this_line.
file);
652 if (pos != source_lines_seen.end()) {
653 if (pos->second.count(line) == 1) {
654 previous_lines.clear();
656 previous_lines.push_back(line);
660 for (
size_t i = 0; i < previous_lines.size(); i++) {
662 previous_line.
file = this_line.
file;
663 previous_line.
line = previous_lines[i];
664 auto pos = source_lines_seen.find(previous_line.
file);
665 if (pos != source_lines_seen.end()) {
666 pos->second.insert(previous_line.
line);
668 source_lines_to_display.
lines.push_back(previous_line);
671 source_lines_to_display.
lines.push_back(this_line);
673 source_lines_to_display.
lines.size() - 1;
675 for (uint32_t i = 0; i < num_mixed_context_lines; i++) {
678 next_line.
line = this_line.
line + i + 1;
679 auto pos = source_lines_seen.find(next_line.
file);
680 if (pos != source_lines_seen.end()) {
681 if (pos->second.count(next_line.
line) == 1)
683 pos->second.insert(next_line.
line);
685 source_lines_to_display.
lines.push_back(next_line);
688 previous_line = this_line;
698 if (source_lines_to_display.
lines.size() > 0) {
700 for (
size_t idx = 0; idx < source_lines_to_display.
lines.size();
703 const char *line_highlight =
"";
705 line_highlight =
"->";
707 line_highlight =
"**";
711 line_highlight, &strm);
718 const bool show_control_flow_kind =
723 inst->
Dump(&inst_line, max_opcode_byte_size,
true, show_bytes,
724 show_control_flow_kind, &exe_ctx, &sc, &prev_sc,
nullptr,
728 auto annotations = annot.
Annotate(*inst);
729 if (!annotations.empty()) {
730 const size_t annotation_column = 100;
733 inst_line.
PutCString(llvm::join(annotations,
", "));
748 constexpr const char *plugin_name =
nullptr;
749 constexpr const char *flavor =
nullptr;
750 constexpr const char *cpu =
nullptr;
751 constexpr const char *features =
nullptr;
752 constexpr bool mixed_source_and_assembly =
false;
753 constexpr uint32_t num_mixed_context_lines = 0;
754 constexpr uint32_t options = 0;
762 disasm_sp->PrintInstructions(debugger, arch, frame,
763 mixed_source_and_assembly,
764 num_mixed_context_lines, options, strm);
782 if (limit.
value == 0)
785 return Disassemble(debugger, arch, plugin_name, flavor, cpu, features, frame,
787 num_mixed_context_lines, options, strm);
804 switch (instruction_control_flow_kind) {
824 llvm_unreachable(
"Fully covered switch above!");
828 bool show_address,
bool show_bytes,
829 bool show_control_flow_kind,
834 size_t max_address_text_size) {
835 size_t opcode_column_width = 7;
836 const size_t operand_column_width = 25;
853 if (max_opcode_byte_size > 0)
854 m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
860 if (max_opcode_byte_size > 0)
861 m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
867 if (show_control_flow_kind) {
871 instruction_control_flow_kind));
874 bool show_color =
false;
877 show_color = target_sp->GetDebugger().GetUseColor();
884 if (opcode_name.empty())
885 opcode_name =
"<unknown>";
902 opcode_pos + opcode_column_width + operand_column_width,
' ');
910 std::unique_ptr<EmulateInstruction> insn_emulator_up(
912 if (insn_emulator_up) {
914 return insn_emulator_up->EvaluateInstruction(0);
932 auto option_value_sp = std::make_shared<OptionValueArray>(1u << data_type);
936 if (!fgets(buffer, 1023, in_file)) {
938 "Instruction::ReadArray: Error reading file (fgets).\n");
939 option_value_sp.reset();
940 return option_value_sp;
943 std::string line(buffer);
945 size_t len = line.size();
946 if (line[len - 1] ==
'\n') {
947 line[len - 1] =
'\0';
948 line.resize(len - 1);
951 if ((line.size() == 1) && line[0] ==
']') {
959 llvm::StringRef(
"^[ \t]*([^ \t]+)[ \t]*$"));
960 llvm::SmallVector<llvm::StringRef, 2> matches;
961 if (g_reg_exp.
Execute(line, &matches))
962 value = matches[1].str();
969 data_value_sp = std::make_shared<OptionValueUInt64>(0, 0);
970 data_value_sp->SetValueFromString(value);
974 data_value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
978 option_value_sp->GetAsArray()->InsertValue(idx, data_value_sp);
983 return option_value_sp;
990 auto option_value_sp = std::make_shared<OptionValueDictionary>();
991 static constexpr llvm::StringLiteral encoding_key(
"data_encoding");
996 if (!fgets(buffer, 1023, in_file)) {
998 "Instruction::ReadDictionary: Error reading file (fgets).\n");
999 option_value_sp.reset();
1000 return option_value_sp;
1004 std::string line(buffer);
1006 size_t len = line.size();
1007 if (line[len - 1] ==
'\n') {
1008 line[len - 1] =
'\0';
1009 line.resize(len - 1);
1012 if ((line.size() == 1) && (line[0] ==
'}')) {
1019 if (!line.empty()) {
1021 "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"));
1023 llvm::SmallVector<llvm::StringRef, 3> matches;
1025 bool reg_exp_success = g_reg_exp.
Execute(line, &matches);
1028 if (reg_exp_success) {
1029 key = matches[1].str();
1030 value = matches[2].str();
1032 out_stream.
Printf(
"Instruction::ReadDictionary: Failure executing "
1033 "regular expression.\n");
1034 option_value_sp.reset();
1035 return option_value_sp;
1041 assert(value.empty() ==
false);
1042 assert(key.empty() ==
false);
1044 if (value[0] ==
'{') {
1045 assert(value.size() == 1);
1049 option_value_sp.reset();
1050 return option_value_sp;
1052 }
else if (value[0] ==
'[') {
1053 assert(value.size() == 1);
1055 value_sp =
ReadArray(in_file, out_stream, data_type);
1057 option_value_sp.reset();
1058 return option_value_sp;
1063 }
else if ((value[0] ==
'0') && (value[1] ==
'x')) {
1064 value_sp = std::make_shared<OptionValueUInt64>(0, 0);
1065 value_sp->SetValueFromString(value);
1067 size_t len = value.size();
1068 if ((value[0] ==
'"') && (value[len - 1] ==
'"'))
1069 value = value.substr(1, len - 2);
1070 value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
1073 if (key == encoding_key) {
1077 if (llvm::StringRef(value) ==
"uint32_t")
1080 option_value_sp->GetAsDictionary()->SetValueForKey(key, value_sp,
1085 return option_value_sp;
1090 out_stream.
Printf(
"Instruction::TestEmulation: Missing file_name.");
1096 "Instruction::TestEmulation: Attempt to open test file failed.");
1101 if (!fgets(buffer, 255, test_file)) {
1103 "Instruction::TestEmulation: Error reading first line of test file.\n");
1108 if (strncmp(buffer,
"InstructionEmulationState={", 27) != 0) {
1109 out_stream.
Printf(
"Instructin::TestEmulation: Test file does not contain "
1110 "emulation state dictionary\n");
1119 if (!data_dictionary_sp) {
1121 "Instruction::TestEmulation: Error reading Dictionary Object.\n");
1129 data_dictionary_sp->GetAsDictionary();
1130 static constexpr llvm::StringLiteral description_key(
"assembly_string");
1131 static constexpr llvm::StringLiteral triple_key(
"triple");
1136 out_stream.
Printf(
"Instruction::TestEmulation: Test file does not "
1137 "contain description string.\n");
1141 SetDescription(value_sp->GetValueAs<llvm::StringRef>().value_or(
""));
1146 "Instruction::TestEmulation: Test file does not contain triple.\n");
1152 llvm::Triple(value_sp->GetValueAs<llvm::StringRef>().value_or(
"")));
1154 bool success =
false;
1155 std::unique_ptr<EmulateInstruction> insn_emulator_up(
1157 if (insn_emulator_up)
1159 insn_emulator_up->TestEmulation(out_stream, arch, data_dictionary);
1162 out_stream.
Printf(
"Emulation test succeeded.");
1164 out_stream.
Printf(
"Emulation test failed.");
1170 const ArchSpec &arch, uint32_t evaluate_options,
void *baton,
1175 std::unique_ptr<EmulateInstruction> insn_emulator_up(
1177 if (insn_emulator_up) {
1178 insn_emulator_up->SetBaton(baton);
1179 insn_emulator_up->SetCallbacks(read_mem_callback, write_mem_callback,
1180 read_reg_callback, write_reg_callback);
1182 return insn_emulator_up->EvaluateInstruction(evaluate_options);
1199 uint32_t max_inst_size = 0;
1200 collection::const_iterator pos, end;
1203 uint32_t inst_size = (*pos)->GetOpcode().GetByteSize();
1204 if (max_inst_size < inst_size)
1205 max_inst_size = inst_size;
1207 return max_inst_size;
1211 size_t total_byte_size = 0;
1212 collection::const_iterator pos, end;
1215 total_byte_size += (*pos)->GetOpcode().GetByteSize();
1217 return total_byte_size;
1235 bool show_control_flow_kind,
1238 collection::const_iterator pos, begin, end;
1244 disassembly_format = &format;
1247 disassembly_format = &format;
1251 pos != end; ++pos) {
1254 (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes,
1255 show_control_flow_kind, exe_ctx,
nullptr,
nullptr,
1256 disassembly_format, 0);
1268 uint32_t start,
bool ignore_calls,
bool *found_calls)
const {
1274 *found_calls =
false;
1275 for (
size_t i = start; i < num_instructions; i++) {
1279 *found_calls =
true;
1294 for (
size_t i = 0; i < num_instructions; i++) {
1313 bool force_live_memory) {
1321 byte_size *=
m_arch.GetMaximumOpcodeByteSize();
1322 auto data_sp = std::make_shared<DataBufferHeap>(byte_size,
'\0');
1326 const size_t bytes_read =
1327 target.
ReadMemory(start, data_sp->GetBytes(), data_sp->GetByteSize(),
1328 error, force_live_memory, &load_addr);
1331 if (bytes_read == 0) {
1332 if (error_strm_ptr) {
1333 if (
const char *error_cstr =
error.AsCString())
1334 error_strm_ptr->
Printf(
"error: %s\n", error_cstr);
1339 if (bytes_read != data_sp->GetByteSize())
1340 data_sp->SetByteSize(bytes_read);
1342 m_arch.GetAddressByteSize());
1346 true, data_from_file);
1352 if (flavor ==
nullptr)
1360 std::string thumb_arch_name(arch.GetTriple().getArchName().str());
1362 if (thumb_arch_name.size() > 3) {
1363 thumb_arch_name.erase(0, 3);
1364 thumb_arch_name.insert(0,
"thumb");
1366 m_arch.SetTriple(thumb_arch_name.c_str());
1416 switch (opcode_size) {
1418 uint8_t value8 = *((uint8_t *)opcode_data);
1423 uint16_t value16 = *((uint16_t *)opcode_data);
1428 uint32_t value32 = *((uint32_t *)opcode_data);
1433 uint64_t value64 = *((uint64_t *)opcode_data);
1505 return (base(op) && op.m_children.size() == 2 &&
1506 ((left(op.m_children[0]) && right(op.m_children[1])) ||
1507 (left(op.m_children[1]) && right(op.m_children[0]))));
1516 return (base(op) && op.m_children.size() == 1 && child(op.m_children[0]));
1535 reg = op.m_register;
1544 ((op.m_negative && op.m_immediate == (uint64_t)-imm) ||
1545 (!op.m_negative && op.m_immediate == (uint64_t)imm)));
1555 if (op.m_negative) {
1556 imm = -((int64_t)op.m_immediate);
1558 imm = ((int64_t)op.m_immediate);
static llvm::raw_ostream & error(Stream &strm)
static Address ResolveAddress(Target &target, const Address &addr)
static constexpr const llvm::StringLiteral kUndefLocationFormatted
static constexpr const llvm::StringLiteral kUndefLocation
static void AddVariableAnnotationToVector(std::vector< VariableAnnotation > &annotations, VariableAnnotation annotation_entity, const bool is_live)
#define DEFAULT_DISASM_BYTE_SIZE
#define LLDB_SCOPED_TIMERF(...)
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this range.
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
A section + offset based address class.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsValid() const
Check if the object state is valid.
bool IsSectionOffset() const
Check if an address is section offset.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsAlwaysThumbInstructions() const
Detect whether this architecture uses thumb code exclusively.
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A class that describes a single lexical block.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
std::optional< DWARFExpressionEntry > GetExpressionEntryAtAddress(lldb::addr_t func_load_addr, lldb::addr_t load_addr) const
Returns a DWARFExpressionEntry whose file_range contains the given load‐address.
bool IsValid() const
Return true if the location expression contains data.
A class to manage flag bits.
FormatEntity::Entry GetDisassemblyFormat() const
SourceManager & GetSourceManager()
static bool FormatDisassemblerAddress(const FormatEntity::Entry *format, const SymbolContext *sc, const SymbolContext *prev_sc, const ExecutionContext *exe_ctx, const Address *addr, Stream &s)
A class that describes the declaration location of a lldb object.
uint32_t GetLine() const
Get accessor for the declaration line number.
FileSpec & GetFile()
Get accessor for file specification.
static lldb::DisassemblerSP FindPluginForTarget(const Target &target, const ArchSpec &arch, const char *flavor, const char *cpu, const char *features, const char *plugin_name)
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, const char *cpu, const char *features, Target &target, llvm::ArrayRef< AddressRange > disasm_ranges, bool force_live_memory=false)
static lldb::DisassemblerSP FindPlugin(const ArchSpec &arch, const char *flavor, const char *cpu, const char *features, const char *plugin_name)
InstructionList m_instruction_list
void PrintInstructions(Debugger &debugger, const ArchSpec &arch, const ExecutionContext &exe_ctx, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm)
static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, const char *cpu, const char *features, const ExecutionContext &exe_ctx, const Address &start, Limit limit, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm)
@ eOptionVariableAnnotations
@ eOptionMarkPCSourceLine
@ eOptionShowControlFlowKind
size_t AppendInstructions(Target &target, Address address, Limit limit, Stream *error_strm_ptr, bool force_live_memory)
static void AddLineToSourceLineTables(SourceLine &line, std::map< FileSpec, std::set< uint32_t > > &source_lines_seen)
static bool ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx, const SymbolContext &sc, SourceLine &line)
Disassembler(const ArchSpec &arch, const char *flavor)
static SourceLine GetFunctionDeclLineEntry(const SymbolContext &sc)
virtual size_t DecodeInstructions(const Address &base_addr, const DataExtractor &data, lldb::offset_t data_offset, size_t num_instructions, bool append, bool data_from_file)=0
InstructionList & GetInstructionList()
static lldb::DisassemblerSP DisassembleBytes(const ArchSpec &arch, const char *plugin_name, const char *flavor, const char *cpu, const char *features, const Address &start, const void *bytes, size_t length, uint32_t max_num_instructions, bool data_from_file)
bool(* WriteRegisterCallback)(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
size_t(* WriteMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
size_t(* ReadMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
bool(* ReadRegisterCallback)(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
static EmulateInstruction * FindPlugin(const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
Target & GetTargetRef() const
Returns a reference to the target object.
const ConstString & GetFilename() const
Filename string const get accessor.
static FileSystem & Instance()
FILE * Fopen(const char *path, const char *mode)
Wraps fopen in a platform-independent way.
const Address & GetAddress() const
Return the address of the function (its entry point).
void GetStartLineSourceInfo(SupportFileNSP &source_file_sp, uint32_t &line_no)
Find the file and line number of the source location of the start of the function.
AddressRanges GetAddressRanges()
void Append(lldb::InstructionSP &inst_sp)
uint32_t GetIndexOfInstructionAtAddress(const Address &addr)
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const
uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr, Target &target)
size_t GetTotalByteSize() const
collection m_instructions
lldb::InstructionSP GetInstructionAtAddress(const Address &addr)
Get the instruction at the given address.
void Dump(Stream *s, bool show_address, bool show_bytes, bool show_control_flow_kind, const ExecutionContext *exe_ctx)
uint32_t GetIndexOfNextBranchInstruction(uint32_t start, bool ignore_calls, bool *found_calls) const
Get the index of the next branch instruction.
uint32_t GetMaxOpcocdeByteSize() const
uint32_t GetData(DataExtractor &data)
Instruction(const Address &address, AddressClass addr_class=AddressClass::eInvalid)
virtual bool HasDelaySlot()
AddressClass m_address_class
static const char * GetNameForInstructionControlFlowKind(lldb::InstructionControlFlowKind instruction_control_flow_kind)
std::string m_markup_mnemonics
virtual bool TestEmulation(Stream &stream, const char *test_file_name)
virtual lldb::InstructionControlFlowKind GetControlFlowKind(const ExecutionContext *exe_ctx)
void CalculateMnemonicOperandsAndCommentIfNeeded(const ExecutionContext *exe_ctx)
lldb::OptionValueSP ReadArray(FILE *in_file, Stream &out_stream, OptionValue::Type data_type)
const Address & GetAddress() const
bool DumpEmulation(const ArchSpec &arch)
lldb::OptionValueSP ReadDictionary(FILE *in_file, Stream &out_stream)
virtual void SetDescription(llvm::StringRef)
const Opcode & GetOpcode() const
std::string m_opcode_name
std::string m_markup_opcode_name
AddressClass GetAddressClass()
virtual void Dump(Stream *s, uint32_t max_opcode_byte_size, bool show_address, bool show_bytes, bool show_control_flow_kind, const ExecutionContext *exe_ctx, const SymbolContext *sym_ctx, const SymbolContext *prev_sym_ctx, const FormatEntity::Entry *disassembly_addr_format, size_t max_address_text_size)
Dump the text representation of this Instruction to a Stream.
bool Emulate(const ArchSpec &arch, uint32_t evaluate_options, void *baton, EmulateInstruction::ReadMemoryCallback read_mem_callback, EmulateInstruction::WriteMemoryCallback write_mem_calback, EmulateInstruction::ReadRegisterCallback read_reg_callback, EmulateInstruction::WriteRegisterCallback write_reg_callback)
bool m_calculated_strings
@ ePreferDemangledWithoutArguments
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const
lldb::OptionValueSP GetValueForKey(llvm::StringRef key) const
const RegularExpression * GetCurrentValue() const
static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName(llvm::StringRef name)
static DisassemblerCreateInstance GetDisassemblerCreateCallbackAtIndex(uint32_t idx)
std::string m_description
void SetOpcode(size_t opcode_size, void *opcode_data)
void SetDescription(llvm::StringRef description) override
bool IsAuthenticated() override
bool IsBarrier() override
bool HasDelaySlot() override
size_t Decode(const Disassembler &disassembler, const DataExtractor &data, lldb::offset_t data_offset) override
~PseudoInstruction() override
bool DoesBranch() override
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
size_t DisplaySourceLinesWithLineNumbers(SupportFileNSP support_file_nsp, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, Stream *s, const SymbolContextList *bp_locs=nullptr)
This base class provides an interface to stack frames.
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
lldb::TargetSP CalculateTarget() override
size_t GetSizeOfLastLine() const
llvm::StringRef GetString() const
void FillLastLineToColumn(uint32_t column, char fill_char)
A stream class that can stream formatted output to a file.
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.
@ eEqualFileSpecAndChecksumIfSet
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
Block * block
The Block for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
void Clear(bool clear_target)
Clear the object's state.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool ValueIsAddress() const
Address & GetAddressRef()
lldb::addr_t GetByteSize() const
const char * GetDisassemblyFeatures() const
const char * GetDisassemblyFlavor() const
const char * GetDisassemblyCPU() const
Debugger & GetDebugger() const
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr, bool *did_read_live_memory=nullptr)
const ModuleList & GetImages() const
Get accessor for the images for this process.
Tracks live variable annotations across instructions and produces per-instruction "events" like name ...
std::vector< std::string > Annotate(Instruction &inst)
Compute annotation strings for a single instruction and update m_live_vars.
std::vector< VariableAnnotation > AnnotateStructured(Instruction &inst)
Returns structured data for all variables relevant at this instruction.
llvm::DenseMap< lldb::user_id_t, VariableAnnotation > m_live_vars
lldb::VariableSP GetVariableAtIndex(size_t idx) const
#define LLDB_INVALID_ADDRESS
std::function< bool(const Instruction::Operand &)> MatchRegOp(const RegisterInfo &info)
std::function< bool(const Instruction::Operand &)> FetchRegOp(ConstString ®)
std::function< bool(const Instruction::Operand &)> MatchImmOp(int64_t imm)
std::function< bool(const Instruction::Operand &)> FetchImmOp(int64_t &imm)
std::function< bool(const Instruction::Operand &)> MatchOpType(Instruction::Operand::Type type)
std::function< bool(const Instruction::Operand &)> MatchBinaryOp(std::function< bool(const Instruction::Operand &)> base, std::function< bool(const Instruction::Operand &)> left, std::function< bool(const Instruction::Operand &)> right)
std::function< bool(const Instruction::Operand &)> MatchUnaryOp(std::function< bool(const Instruction::Operand &)> base, std::function< bool(const Instruction::Operand &)> child)
A class that represents a running process on the host machine.
NonNullSharedPtr< lldb_private::SupportFile > SupportFileNSP
lldb::DisassemblerSP(* DisassemblerCreateInstance)(const ArchSpec &arch, const char *flavor, const char *cpu, const char *features)
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Instruction > InstructionSP
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
InstructionControlFlowKind
Architecture-agnostic categorization of instructions for traversing the control flow of a trace.
@ eInstructionControlFlowKindReturn
The instruction is a near (function) return.
@ eInstructionControlFlowKindFarJump
The instruction is a jump-like far transfer.
@ eInstructionControlFlowKindOther
The instruction is something not listed below, i.e.
@ eInstructionControlFlowKindFarCall
The instruction is a call-like far transfer.
@ eInstructionControlFlowKindFarReturn
The instruction is a return-like far transfer.
@ eInstructionControlFlowKindUnknown
The instruction could not be classified.
@ eInstructionControlFlowKindJump
The instruction is a near unconditional jump.
@ eInstructionControlFlowKindCall
The instruction is a near (function) call.
@ eInstructionControlFlowKindCondJump
The instruction is a near conditional jump.
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
enum lldb_private::Disassembler::Limit::@153225075164054222165007100131150321273323317332 kind
size_t current_source_line
std::vector< SourceLine > lines
bool print_source_context_end_eol
enum lldb_private::Instruction::Operand::Type m_type
static Operand BuildImmediate(lldb::addr_t imm, bool neg)
static Operand BuildDereference(const Operand &ref)
std::vector< Operand > m_children
static Operand BuildProduct(const Operand &lhs, const Operand &rhs)
static Operand BuildSum(const Operand &lhs, const Operand &rhs)
static Operand BuildRegister(ConstString &r)
A line table entry class.
uint16_t column
The column number of the source line, or zero if there is no column information.
bool IsValid() const
Check if a line entry object is valid.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
const FileSpec & GetFile() const
Helper to access the file.
SupportFileNSP file_sp
The source file, possibly mapped by the target.source-map setting.
SupportFileNSP original_file_sp
The original source file, from debug info.
Every register is described in detail including its name, alternate name (optional),...
const char * alt_name
Alternate name of this register, can be NULL.
const char * name
Name of this register, can't be NULL.
Structured data for a single variable annotation.
bool is_live
Whether variable is live at this instruction.
std::string location_description
Location description (e.g., "r15", "undef", "const_0").