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);
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)) {
302std::vector<std::string>
305 std::vector<std::string> events;
309 for (
const auto &KV :
Live_)
310 events.emplace_back(llvm::formatv(
"{0} = <undef>", KV.second.name).str());
318 const auto mask = eSymbolContextFunction | eSymbolContextBlock;
319 if (!module_sp->ResolveSymbolContextForAddress(iaddr, mask, sc) ||
322 for (
const auto &KV :
Live_)
323 events.emplace_back(llvm::formatv(
"{0} = <undef>", KV.second.name).str());
332 auto filter = [](
Variable *v) ->
bool {
return v && !v->IsArtificial(); };
333 B->AppendVariables(
true,
345 ABI *abi = abi_sp.get();
347 llvm::DIDumpOptions opts;
348 opts.ShowAddresses =
false;
350 opts.PrintRegisterOnly =
static_cast<bool>(abi_sp);
352 llvm::DenseMap<lldb::user_id_t, VarState>
Current;
354 for (
size_t i = 0, e = var_list.
GetSize(); i != e; ++i) {
356 if (!v || v->IsArtificial())
359 const char *nm = v->GetName().AsCString();
360 llvm::StringRef name = nm ? nm :
"<anon>";
370 auto entry = *entry_or_err;
375 llvm::StringRef loc = llvm::StringRef(loc_ss.
GetString()).trim();
379 Current.try_emplace(v->GetID(),
380 VarState{std::string(name), std::string(loc)});
386 for (
const auto &KV :
Current) {
387 auto it =
Live_.find(KV.first);
388 if (it ==
Live_.end()) {
391 llvm::formatv(
"{0} = {1}", KV.second.name, KV.second.last_loc).str());
392 }
else if (it->second.last_loc != KV.second.last_loc) {
395 llvm::formatv(
"{0} = {1}", KV.second.name, KV.second.last_loc).str());
400 for (
const auto &KV :
Live_) {
402 events.emplace_back(llvm::formatv(
"{0} = <undef>", KV.second.name).str());
412 bool mixed_source_and_assembly,
413 uint32_t num_mixed_context_lines,
414 uint32_t options,
Stream &strm) {
418 const uint32_t max_opcode_byte_size =
423 const Address *pc_addr_ptr =
nullptr;
433 const uint32_t scope =
434 eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
435 const bool use_inline_block_range =
false;
441 disassembly_format = &format;
444 disassembly_format = &format;
455 std::map<FileSpec, std::set<uint32_t>> source_lines_seen;
456 Symbol *previous_symbol =
nullptr;
458 size_t address_text_size = 0;
459 for (
size_t i = 0; i < num_instructions_found; ++i) {
465 const SymbolContextItem resolve_mask = eSymbolContextFunction |
466 eSymbolContextSymbol |
467 eSymbolContextLineEntry;
468 uint32_t resolved_mask =
469 module_sp->ResolveSymbolContextForAddress(addr, resolve_mask, sc);
473 &exe_ctx, &addr, strmstr);
475 if (cur_line > address_text_size)
476 address_text_size = cur_line;
486 if (sc.
symbol != previous_symbol) {
507 previous_symbol =
nullptr;
509 for (
size_t i = 0; i < num_instructions_found; ++i) {
514 const bool inst_is_at_pc = pc_addr_ptr && addr == *pc_addr_ptr;
521 uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(
522 addr, eSymbolContextEverything, sc);
524 if (mixed_source_and_assembly) {
529 if (previous_symbol != sc.
symbol) {
534 if (previous_symbol !=
nullptr)
537 previous_symbol = sc.
symbol;
541 prologue_end_line)) {
543 uint32_t func_decl_line;
546 if (func_decl_file_sp &&
547 (func_decl_file_sp->Equal(
550 func_decl_file_sp->Equal(
556 for (uint32_t lineno = func_decl_line;
557 lineno <= prologue_end_line.
line; lineno++) {
559 this_line.
file = func_decl_file_sp->GetSpecOnly();
560 this_line.
line = lineno;
561 source_lines_to_display.
lines.push_back(this_line);
565 if (source_lines_to_display.
lines.size() > 0)
567 source_lines_to_display.
lines.size() - 1;
572 current_source_line_range);
579 current_source_line_range);
593 if (this_line != previous_line) {
595 std::vector<uint32_t> previous_lines;
597 i < num_mixed_context_lines &&
598 (this_line.
line - num_mixed_context_lines) > 0;
601 this_line.
line - num_mixed_context_lines + i;
602 auto pos = source_lines_seen.find(this_line.
file);
603 if (pos != source_lines_seen.end()) {
604 if (pos->second.count(line) == 1) {
605 previous_lines.clear();
607 previous_lines.push_back(line);
611 for (
size_t i = 0; i < previous_lines.size(); i++) {
613 previous_line.
file = this_line.
file;
614 previous_line.
line = previous_lines[i];
615 auto pos = source_lines_seen.find(previous_line.
file);
616 if (pos != source_lines_seen.end()) {
617 pos->second.insert(previous_line.
line);
619 source_lines_to_display.
lines.push_back(previous_line);
622 source_lines_to_display.
lines.push_back(this_line);
624 source_lines_to_display.
lines.size() - 1;
626 for (uint32_t i = 0; i < num_mixed_context_lines; i++) {
629 next_line.
line = this_line.
line + i + 1;
630 auto pos = source_lines_seen.find(next_line.
file);
631 if (pos != source_lines_seen.end()) {
632 if (pos->second.count(next_line.
line) == 1)
634 pos->second.insert(next_line.
line);
636 source_lines_to_display.
lines.push_back(next_line);
639 previous_line = this_line;
649 if (source_lines_to_display.
lines.size() > 0) {
651 for (
size_t idx = 0; idx < source_lines_to_display.
lines.size();
654 const char *line_highlight =
"";
656 line_highlight =
"->";
658 line_highlight =
"**";
662 line_highlight, &strm);
669 const bool show_control_flow_kind =
674 inst->
Dump(&inst_line, max_opcode_byte_size,
true, show_bytes,
675 show_control_flow_kind, &exe_ctx, &sc, &prev_sc,
nullptr,
679 auto annotations = annot.
annotate(*inst, *target_sp, module_sp);
680 if (!annotations.empty()) {
681 const size_t annotation_column = 100;
684 inst_line.
PutCString(llvm::join(annotations,
", "));
699 constexpr const char *plugin_name =
nullptr;
700 constexpr const char *flavor =
nullptr;
701 constexpr const char *cpu =
nullptr;
702 constexpr const char *features =
nullptr;
703 constexpr bool mixed_source_and_assembly =
false;
704 constexpr uint32_t num_mixed_context_lines = 0;
705 constexpr uint32_t options = 0;
713 disasm_sp->PrintInstructions(debugger, arch, frame,
714 mixed_source_and_assembly,
715 num_mixed_context_lines, options, strm);
733 if (limit.
value == 0)
736 return Disassemble(debugger, arch, plugin_name, flavor, cpu, features, frame,
738 num_mixed_context_lines, options, strm);
755 switch (instruction_control_flow_kind) {
775 llvm_unreachable(
"Fully covered switch above!");
779 bool show_address,
bool show_bytes,
780 bool show_control_flow_kind,
785 size_t max_address_text_size) {
786 size_t opcode_column_width = 7;
787 const size_t operand_column_width = 25;
804 if (max_opcode_byte_size > 0)
805 m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
811 if (max_opcode_byte_size > 0)
812 m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1);
818 if (show_control_flow_kind) {
822 instruction_control_flow_kind));
825 bool show_color =
false;
828 show_color = target_sp->GetDebugger().GetUseColor();
835 if (opcode_name.empty())
836 opcode_name =
"<unknown>";
853 opcode_pos + opcode_column_width + operand_column_width,
' ');
861 std::unique_ptr<EmulateInstruction> insn_emulator_up(
863 if (insn_emulator_up) {
865 return insn_emulator_up->EvaluateInstruction(0);
883 auto option_value_sp = std::make_shared<OptionValueArray>(1u << data_type);
887 if (!fgets(buffer, 1023, in_file)) {
889 "Instruction::ReadArray: Error reading file (fgets).\n");
890 option_value_sp.reset();
891 return option_value_sp;
894 std::string line(buffer);
896 size_t len = line.size();
897 if (line[len - 1] ==
'\n') {
898 line[len - 1] =
'\0';
899 line.resize(len - 1);
902 if ((line.size() == 1) && line[0] ==
']') {
910 llvm::StringRef(
"^[ \t]*([^ \t]+)[ \t]*$"));
911 llvm::SmallVector<llvm::StringRef, 2> matches;
912 if (g_reg_exp.
Execute(line, &matches))
913 value = matches[1].str();
920 data_value_sp = std::make_shared<OptionValueUInt64>(0, 0);
921 data_value_sp->SetValueFromString(value);
925 data_value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
929 option_value_sp->GetAsArray()->InsertValue(idx, data_value_sp);
934 return option_value_sp;
941 auto option_value_sp = std::make_shared<OptionValueDictionary>();
942 static constexpr llvm::StringLiteral encoding_key(
"data_encoding");
947 if (!fgets(buffer, 1023, in_file)) {
949 "Instruction::ReadDictionary: Error reading file (fgets).\n");
950 option_value_sp.reset();
951 return option_value_sp;
955 std::string line(buffer);
957 size_t len = line.size();
958 if (line[len - 1] ==
'\n') {
959 line[len - 1] =
'\0';
960 line.resize(len - 1);
963 if ((line.size() == 1) && (line[0] ==
'}')) {
972 "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"));
974 llvm::SmallVector<llvm::StringRef, 3> matches;
976 bool reg_exp_success = g_reg_exp.
Execute(line, &matches);
979 if (reg_exp_success) {
980 key = matches[1].str();
981 value = matches[2].str();
983 out_stream.
Printf(
"Instruction::ReadDictionary: Failure executing "
984 "regular expression.\n");
985 option_value_sp.reset();
986 return option_value_sp;
992 assert(value.empty() ==
false);
993 assert(key.empty() ==
false);
995 if (value[0] ==
'{') {
996 assert(value.size() == 1);
1000 option_value_sp.reset();
1001 return option_value_sp;
1003 }
else if (value[0] ==
'[') {
1004 assert(value.size() == 1);
1006 value_sp =
ReadArray(in_file, out_stream, data_type);
1008 option_value_sp.reset();
1009 return option_value_sp;
1014 }
else if ((value[0] ==
'0') && (value[1] ==
'x')) {
1015 value_sp = std::make_shared<OptionValueUInt64>(0, 0);
1016 value_sp->SetValueFromString(value);
1018 size_t len = value.size();
1019 if ((value[0] ==
'"') && (value[len - 1] ==
'"'))
1020 value = value.substr(1, len - 2);
1021 value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
1024 if (key == encoding_key) {
1028 if (llvm::StringRef(value) ==
"uint32_t")
1031 option_value_sp->GetAsDictionary()->SetValueForKey(key, value_sp,
1036 return option_value_sp;
1041 out_stream.
Printf(
"Instruction::TestEmulation: Missing file_name.");
1047 "Instruction::TestEmulation: Attempt to open test file failed.");
1052 if (!fgets(buffer, 255, test_file)) {
1054 "Instruction::TestEmulation: Error reading first line of test file.\n");
1059 if (strncmp(buffer,
"InstructionEmulationState={", 27) != 0) {
1060 out_stream.
Printf(
"Instructin::TestEmulation: Test file does not contain "
1061 "emulation state dictionary\n");
1070 if (!data_dictionary_sp) {
1072 "Instruction::TestEmulation: Error reading Dictionary Object.\n");
1081 static constexpr llvm::StringLiteral description_key(
"assembly_string");
1082 static constexpr llvm::StringLiteral triple_key(
"triple");
1087 out_stream.
Printf(
"Instruction::TestEmulation: Test file does not "
1088 "contain description string.\n");
1092 SetDescription(value_sp->GetValueAs<llvm::StringRef>().value_or(
""));
1097 "Instruction::TestEmulation: Test file does not contain triple.\n");
1103 llvm::Triple(value_sp->GetValueAs<llvm::StringRef>().value_or(
"")));
1105 bool success =
false;
1106 std::unique_ptr<EmulateInstruction> insn_emulator_up(
1108 if (insn_emulator_up)
1110 insn_emulator_up->TestEmulation(out_stream, arch, data_dictionary);
1113 out_stream.
Printf(
"Emulation test succeeded.");
1115 out_stream.
Printf(
"Emulation test failed.");
1121 const ArchSpec &arch, uint32_t evaluate_options,
void *baton,
1126 std::unique_ptr<EmulateInstruction> insn_emulator_up(
1128 if (insn_emulator_up) {
1129 insn_emulator_up->SetBaton(baton);
1130 insn_emulator_up->SetCallbacks(read_mem_callback, write_mem_callback,
1131 read_reg_callback, write_reg_callback);
1133 return insn_emulator_up->EvaluateInstruction(evaluate_options);
1150 uint32_t max_inst_size = 0;
1151 collection::const_iterator pos, end;
1154 uint32_t inst_size = (*pos)->GetOpcode().GetByteSize();
1155 if (max_inst_size < inst_size)
1156 max_inst_size = inst_size;
1158 return max_inst_size;
1162 size_t total_byte_size = 0;
1163 collection::const_iterator pos, end;
1166 total_byte_size += (*pos)->GetOpcode().GetByteSize();
1168 return total_byte_size;
1186 bool show_control_flow_kind,
1189 collection::const_iterator pos, begin, end;
1195 disassembly_format = &format;
1198 disassembly_format = &format;
1202 pos != end; ++pos) {
1205 (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes,
1206 show_control_flow_kind, exe_ctx,
nullptr,
nullptr,
1207 disassembly_format, 0);
1219 uint32_t start,
bool ignore_calls,
bool *found_calls)
const {
1225 *found_calls =
false;
1226 for (
size_t i = start; i < num_instructions; i++) {
1230 *found_calls =
true;
1245 for (
size_t i = 0; i < num_instructions; i++) {
1264 bool force_live_memory) {
1272 byte_size *=
m_arch.GetMaximumOpcodeByteSize();
1273 auto data_sp = std::make_shared<DataBufferHeap>(byte_size,
'\0');
1277 const size_t bytes_read =
1278 target.
ReadMemory(start, data_sp->GetBytes(), data_sp->GetByteSize(),
1279 error, force_live_memory, &load_addr);
1282 if (bytes_read == 0) {
1283 if (error_strm_ptr) {
1284 if (
const char *error_cstr =
error.AsCString())
1285 error_strm_ptr->
Printf(
"error: %s\n", error_cstr);
1290 if (bytes_read != data_sp->GetByteSize())
1291 data_sp->SetByteSize(bytes_read);
1293 m_arch.GetAddressByteSize());
1297 true, data_from_file);
1303 if (flavor ==
nullptr)
1311 std::string thumb_arch_name(arch.GetTriple().getArchName().str());
1313 if (thumb_arch_name.size() > 3) {
1314 thumb_arch_name.erase(0, 3);
1315 thumb_arch_name.insert(0,
"thumb");
1317 m_arch.SetTriple(thumb_arch_name.c_str());
1362 switch (opcode_size) {
1364 uint8_t value8 = *((uint8_t *)opcode_data);
1369 uint16_t value16 = *((uint16_t *)opcode_data);
1374 uint32_t value32 = *((uint32_t *)opcode_data);
1379 uint64_t value64 = *((uint64_t *)opcode_data);
1451 return (base(op) && op.m_children.size() == 2 &&
1452 ((left(op.m_children[0]) && right(op.m_children[1])) ||
1453 (left(op.m_children[1]) && right(op.m_children[0]))));
1462 return (base(op) && op.m_children.size() == 1 && child(op.m_children[0]));
1481 reg = op.m_register;
1490 ((op.m_negative && op.m_immediate == (uint64_t)-imm) ||
1491 (!op.m_negative && op.m_immediate == (uint64_t)imm)));
1501 if (op.m_negative) {
1502 imm = -((int64_t)op.m_immediate);
1504 imm = ((int64_t)op.m_immediate);
static llvm::raw_ostream & error(Stream &strm)
static Address ResolveAddress(Target &target, const Address &addr)
#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 * 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)
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)
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)
@ eOptionVariableAnnotations
@ eOptionMarkPCSourceLine
@ eOptionShowControlFlowKind
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.
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(lldb::SupportFileSP &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
OptionValueDictionary * GetAsDictionary()
OptionValueRegex * GetAsRegex()
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 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(lldb::SupportFileSP support_file_sp, 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.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
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.
const ArchSpec & GetArchitecture() const
Tracks live variable annotations across instructions and produces per-instruction "events" like name ...
llvm::DenseMap< lldb::user_id_t, VarState > Live_
std::vector< std::string > annotate(Instruction &inst, Target &target, const lldb::ModuleSP &module_sp)
Compute annotation strings for a single instruction and update Live_.
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.
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::SupportFile > SupportFileSP
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::@074264254305040353250152340202075156127302012033 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.
lldb::SupportFileSP original_file_sp
The original source file, from debug info.
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.
lldb::SupportFileSP file_sp
The source file, possibly mapped by the target.source-map setting.
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.