44#include "llvm/Support/Compiler.h"
45#include "llvm/TargetParser/Triple.h"
53#define DEFAULT_DISASM_BYTE_SIZE 32
59 const char *flavor,
const char *cpu,
61 const char *plugin_name) {
70 if (create_callback) {
71 if (
auto disasm_sp = create_callback(arch, flavor, cpu, features))
75 for (uint32_t idx = 0;
79 if (
auto disasm_sp = create_callback(arch, flavor, cpu, features))
88 const char *cpu,
const char *features,
const char *plugin_name) {
93 if (arch.
GetTriple().getArch() == llvm::Triple::x86 ||
94 arch.
GetTriple().getArch() == llvm::Triple::x86_64)
102 return FindPlugin(arch, flavor, cpu, features, plugin_name);
117 if (is_resolved && resolved_addr.
IsValid())
118 return resolved_addr;
124 const ArchSpec &arch,
const char *plugin_name,
const char *flavor,
125 const char *cpu,
const char *features,
Target &target,
126 llvm::ArrayRef<AddressRange> disasm_ranges,
bool force_live_memory) {
128 target, arch, flavor, cpu, features, plugin_name);
133 size_t bytes_disassembled = 0;
135 bytes_disassembled += disasm_sp->AppendInstructions(
136 target, range.GetBaseAddress(), {Limit::Bytes, range.GetByteSize()},
137 nullptr, force_live_memory);
139 if (bytes_disassembled == 0)
147 const char *flavor,
const char *cpu,
148 const char *features,
const Address &start,
149 const void *src,
size_t src_len,
150 uint32_t num_instructions,
bool data_from_file) {
163 (void)disasm_sp->DecodeInstructions(start, data, 0, num_instructions,
false,
169 const char *plugin_name,
const char *flavor,
170 const char *cpu,
const char *features,
173 bool mixed_source_and_assembly,
174 uint32_t num_mixed_context_lines,
175 uint32_t options,
Stream &strm) {
180 exe_ctx.
GetTargetRef(), arch, flavor, cpu, features, plugin_name));
184 const bool force_live_memory =
true;
185 size_t bytes_disassembled = disasm_sp->ParseInstructions(
186 exe_ctx.
GetTargetRef(), address, limit, &strm, force_live_memory);
187 if (bytes_disassembled == 0)
190 disasm_sp->PrintInstructions(debugger, arch, exe_ctx,
191 mixed_source_and_assembly,
192 num_mixed_context_lines, options, strm);
206 uint32_t func_decl_line;
209 if (!func_decl_file_sp)
211 if (!func_decl_file_sp->Equal(*prologue_end_line.
file_sp,
218 decl_line.
file = func_decl_file_sp->GetSpecOnly();
219 decl_line.
line = func_decl_line;
228 std::map<
FileSpec, std::set<uint32_t>> &source_lines_seen) {
230 auto source_lines_seen_pos = source_lines_seen.find(line.
file);
231 if (source_lines_seen_pos == source_lines_seen.end()) {
232 std::set<uint32_t> lines;
233 lines.insert(line.
line);
234 source_lines_seen.emplace(line.
file, lines);
236 source_lines_seen_pos->second.insert(line.
line);
255 avoid_regex = thread_sp->GetSymbolsToAvoidRegexp();
260 OptionValueSP value_sp = target_sp->GetDebugger().GetPropertyValue(
261 &exe_ctx,
"target.process.thread.step-avoid-regexp",
error);
270 if (avoid_regex && sc.
symbol !=
nullptr) {
271 const char *function_name =
274 if (function_name && avoid_regex->
Execute(function_name)) {
285 bool mixed_source_and_assembly,
286 uint32_t num_mixed_context_lines,
287 uint32_t options,
Stream &strm) {
291 const uint32_t max_opcode_byte_size =
296 const Address *pc_addr_ptr =
nullptr;
306 const uint32_t scope =
307 eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
308 const bool use_inline_block_range =
false;
317 disassembly_format = &format;
328 std::map<FileSpec, std::set<uint32_t>> source_lines_seen;
329 Symbol *previous_symbol =
nullptr;
331 size_t address_text_size = 0;
332 for (
size_t i = 0; i < num_instructions_found; ++i) {
338 const SymbolContextItem resolve_mask = eSymbolContextFunction |
339 eSymbolContextSymbol |
340 eSymbolContextLineEntry;
341 uint32_t resolved_mask =
342 module_sp->ResolveSymbolContextForAddress(addr, resolve_mask, sc);
346 &exe_ctx, &addr, strmstr);
348 if (cur_line > address_text_size)
349 address_text_size = cur_line;
359 if (sc.
symbol != previous_symbol) {
379 previous_symbol =
nullptr;
381 for (
size_t i = 0; i < num_instructions_found; ++i) {
386 const bool inst_is_at_pc = pc_addr_ptr && addr == *pc_addr_ptr;
393 uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(
394 addr, eSymbolContextEverything, sc);
396 if (mixed_source_and_assembly) {
401 if (previous_symbol != sc.
symbol) {
406 if (previous_symbol !=
nullptr)
409 previous_symbol = sc.
symbol;
413 prologue_end_line)) {
415 uint32_t func_decl_line;
418 if (func_decl_file_sp &&
419 (func_decl_file_sp->Equal(
422 func_decl_file_sp->Equal(
428 for (uint32_t lineno = func_decl_line;
429 lineno <= prologue_end_line.
line; lineno++) {
431 this_line.
file = func_decl_file_sp->GetSpecOnly();
432 this_line.
line = lineno;
433 source_lines_to_display.
lines.push_back(this_line);
437 if (source_lines_to_display.
lines.size() > 0)
439 source_lines_to_display.
lines.size() - 1;
444 current_source_line_range);
451 current_source_line_range);
465 if (this_line != previous_line) {
467 std::vector<uint32_t> previous_lines;
469 i < num_mixed_context_lines &&
470 (this_line.
line - num_mixed_context_lines) > 0;
473 this_line.
line - num_mixed_context_lines + i;
474 auto pos = source_lines_seen.find(this_line.
file);
475 if (pos != source_lines_seen.end()) {
476 if (pos->second.count(line) == 1) {
477 previous_lines.clear();
479 previous_lines.push_back(line);
483 for (
size_t i = 0; i < previous_lines.size(); i++) {
485 previous_line.
file = this_line.
file;
486 previous_line.
line = previous_lines[i];
487 auto pos = source_lines_seen.find(previous_line.
file);
488 if (pos != source_lines_seen.end()) {
489 pos->second.insert(previous_line.
line);
491 source_lines_to_display.
lines.push_back(previous_line);
494 source_lines_to_display.
lines.push_back(this_line);
496 source_lines_to_display.
lines.size() - 1;
498 for (uint32_t i = 0; i < num_mixed_context_lines; i++) {
501 next_line.
line = this_line.
line + i + 1;
502 auto pos = source_lines_seen.find(next_line.
file);
503 if (pos != source_lines_seen.end()) {
504 if (pos->second.count(next_line.
line) == 1)
506 pos->second.insert(next_line.
line);
508 source_lines_to_display.
lines.push_back(next_line);
511 previous_line = this_line;
521 if (source_lines_to_display.
lines.size() > 0) {
523 for (
size_t idx = 0; idx < source_lines_to_display.
lines.size();
526 const char *line_highlight =
"";
528 line_highlight =
"->";
530 line_highlight =
"**";
534 line_highlight, &strm);
541 const bool show_control_flow_kind =
543 inst->
Dump(&strm, max_opcode_byte_size,
true, show_bytes,
544 show_control_flow_kind, &exe_ctx, &sc, &prev_sc,
nullptr,
572 if (limit.
value == 0)
575 return Disassemble(debugger, arch,
nullptr,
nullptr,
nullptr,
nullptr,
580 : m_address(address), m_address_class(addr_class), m_opcode(),
581 m_calculated_strings(false) {}
593 switch (instruction_control_flow_kind) {
613 llvm_unreachable(
"Fully covered switch above!");
617 bool show_address,
bool show_bytes,
618 bool show_control_flow_kind,
623 size_t max_address_text_size) {
624 size_t opcode_column_width = 7;
625 const size_t operand_column_width = 25;
642 if (max_opcode_byte_size > 0)
649 if (max_opcode_byte_size > 0)
656 if (show_control_flow_kind) {
660 instruction_control_flow_kind));
663 bool show_color =
false;
666 show_color = target_sp->GetDebugger().GetUseColor();
670 const std::string &opcode_name =
689 opcode_pos + opcode_column_width + operand_column_width,
' ');
697 std::unique_ptr<EmulateInstruction> insn_emulator_up(
699 if (insn_emulator_up) {
701 return insn_emulator_up->EvaluateInstruction(0);
721 auto option_value_sp = std::make_shared<OptionValueArray>(1u << data_type);
725 if (!fgets(buffer, 1023, in_file)) {
727 "Instruction::ReadArray: Error reading file (fgets).\n");
728 option_value_sp.reset();
729 return option_value_sp;
732 std::string line(buffer);
734 size_t len = line.size();
735 if (line[len - 1] ==
'\n') {
736 line[len - 1] =
'\0';
737 line.resize(len - 1);
740 if ((line.size() == 1) && line[0] ==
']') {
748 llvm::StringRef(
"^[ \t]*([^ \t]+)[ \t]*$"));
749 llvm::SmallVector<llvm::StringRef, 2> matches;
750 if (g_reg_exp.
Execute(line, &matches))
751 value = matches[1].str();
758 data_value_sp = std::make_shared<OptionValueUInt64>(0, 0);
759 data_value_sp->SetValueFromString(value);
763 data_value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
767 option_value_sp->GetAsArray()->InsertValue(idx, data_value_sp);
772 return option_value_sp;
779 auto option_value_sp = std::make_shared<OptionValueDictionary>();
780 static constexpr llvm::StringLiteral encoding_key(
"data_encoding");
785 if (!fgets(buffer, 1023, in_file)) {
787 "Instruction::ReadDictionary: Error reading file (fgets).\n");
788 option_value_sp.reset();
789 return option_value_sp;
793 std::string line(buffer);
795 size_t len = line.size();
796 if (line[len - 1] ==
'\n') {
797 line[len - 1] =
'\0';
798 line.resize(len - 1);
801 if ((line.size() == 1) && (line[0] ==
'}')) {
810 "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"));
812 llvm::SmallVector<llvm::StringRef, 3> matches;
814 bool reg_exp_success = g_reg_exp.
Execute(line, &matches);
817 if (reg_exp_success) {
818 key = matches[1].str();
819 value = matches[2].str();
821 out_stream.
Printf(
"Instruction::ReadDictionary: Failure executing "
822 "regular expression.\n");
823 option_value_sp.reset();
824 return option_value_sp;
830 assert(value.empty() ==
false);
831 assert(key.empty() ==
false);
833 if (value[0] ==
'{') {
834 assert(value.size() == 1);
838 option_value_sp.reset();
839 return option_value_sp;
841 }
else if (value[0] ==
'[') {
842 assert(value.size() == 1);
844 value_sp =
ReadArray(in_file, out_stream, data_type);
846 option_value_sp.reset();
847 return option_value_sp;
852 }
else if ((value[0] ==
'0') && (value[1] ==
'x')) {
853 value_sp = std::make_shared<OptionValueUInt64>(0, 0);
854 value_sp->SetValueFromString(value);
856 size_t len = value.size();
857 if ((value[0] ==
'"') && (value[len - 1] ==
'"'))
858 value = value.substr(1, len - 2);
859 value_sp = std::make_shared<OptionValueString>(value.c_str(),
"");
862 if (key == encoding_key) {
866 if (llvm::StringRef(value) ==
"uint32_t")
869 option_value_sp->GetAsDictionary()->SetValueForKey(key, value_sp,
874 return option_value_sp;
879 out_stream.
Printf(
"Instruction::TestEmulation: Missing file_name.");
885 "Instruction::TestEmulation: Attempt to open test file failed.");
890 if (!fgets(buffer, 255, test_file)) {
892 "Instruction::TestEmulation: Error reading first line of test file.\n");
897 if (strncmp(buffer,
"InstructionEmulationState={", 27) != 0) {
898 out_stream.
Printf(
"Instructin::TestEmulation: Test file does not contain "
899 "emulation state dictionary\n");
908 if (!data_dictionary_sp) {
910 "Instruction::TestEmulation: Error reading Dictionary Object.\n");
919 static constexpr llvm::StringLiteral description_key(
"assembly_string");
920 static constexpr llvm::StringLiteral triple_key(
"triple");
925 out_stream.
Printf(
"Instruction::TestEmulation: Test file does not "
926 "contain description string.\n");
930 SetDescription(value_sp->GetValueAs<llvm::StringRef>().value_or(
""));
935 "Instruction::TestEmulation: Test file does not contain triple.\n");
941 llvm::Triple(value_sp->GetValueAs<llvm::StringRef>().value_or(
"")));
943 bool success =
false;
944 std::unique_ptr<EmulateInstruction> insn_emulator_up(
946 if (insn_emulator_up)
948 insn_emulator_up->TestEmulation(out_stream, arch, data_dictionary);
951 out_stream.
Printf(
"Emulation test succeeded.");
953 out_stream.
Printf(
"Emulation test failed.");
959 const ArchSpec &arch, uint32_t evaluate_options,
void *baton,
964 std::unique_ptr<EmulateInstruction> insn_emulator_up(
966 if (insn_emulator_up) {
967 insn_emulator_up->SetBaton(baton);
968 insn_emulator_up->SetCallbacks(read_mem_callback, write_mem_callback,
969 read_reg_callback, write_reg_callback);
971 return insn_emulator_up->EvaluateInstruction(evaluate_options);
988 uint32_t max_inst_size = 0;
989 collection::const_iterator pos, end;
992 uint32_t inst_size = (*pos)->GetOpcode().GetByteSize();
993 if (max_inst_size < inst_size)
994 max_inst_size = inst_size;
996 return max_inst_size;
1014 bool show_control_flow_kind,
1017 collection::const_iterator pos, begin, end;
1022 disassembly_format =
1026 disassembly_format = &format;
1030 pos != end; ++pos) {
1033 (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes,
1034 show_control_flow_kind, exe_ctx,
nullptr,
nullptr,
1035 disassembly_format, 0);
1049 bool *found_calls)
const {
1055 *found_calls =
false;
1056 for (
size_t i = start; i < num_instructions; i++) {
1060 *found_calls =
true;
1075 for (
size_t i = 0; i < num_instructions; i++) {
1094 bool force_live_memory) {
1103 auto data_sp = std::make_shared<DataBufferHeap>(byte_size,
'\0');
1107 const size_t bytes_read =
1108 target.
ReadMemory(start, data_sp->GetBytes(), data_sp->GetByteSize(),
1109 error, force_live_memory, &load_addr);
1112 if (bytes_read == 0) {
1113 if (error_strm_ptr) {
1114 if (
const char *error_cstr =
error.AsCString())
1115 error_strm_ptr->
Printf(
"error: %s\n", error_cstr);
1120 if (bytes_read != data_sp->GetByteSize())
1121 data_sp->SetByteSize(bytes_read);
1127 true, data_from_file);
1132 : m_arch(arch), m_instruction_list(), m_flavor() {
1133 if (flavor ==
nullptr)
1141 std::string thumb_arch_name(arch.
GetTriple().getArchName().str());
1143 if (thumb_arch_name.size() > 3) {
1144 thumb_arch_name.erase(0, 3);
1145 thumb_arch_name.insert(0,
"thumb");
1192 switch (opcode_size) {
1194 uint8_t value8 = *((uint8_t *)opcode_data);
1199 uint16_t value16 = *((uint16_t *)opcode_data);
1204 uint32_t value32 = *((uint32_t *)opcode_data);
1209 uint64_t value64 = *((uint64_t *)opcode_data);
1232 ret.
m_type = Type::Immediate;
1240 ret.
m_type = Type::Immediate;
1254 ret.
m_type = Type::Dereference;
1270 ret.
m_type = Type::Product;
1281 return (base(op) && op.m_children.size() == 2 &&
1282 ((left(op.m_children[0]) && right(op.m_children[1])) ||
1283 (left(op.m_children[1]) && right(op.m_children[0]))));
1292 return (base(op) && op.m_children.size() == 1 && child(op.m_children[0]));
1311 reg = op.m_register;
1320 ((op.m_negative && op.m_immediate == (uint64_t)-imm) ||
1321 (!op.m_negative && op.m_immediate == (uint64_t)imm)));
1331 if (op.m_negative) {
1332 imm = -((int64_t)op.m_immediate);
1334 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(...)
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 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.
AddressClass GetAddressClass() const
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.
uint32_t GetMaximumOpcodeByteSize() const
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
A class to manage flag bits.
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)
const FormatEntity::Entry * GetDisassemblyFormat() const
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)
@ 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.
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.
const AddressRange & GetAddressRange()
DEPRECATED: Use GetAddressRanges instead.
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)
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)
@ ePreferDemangledWithoutArguments
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const
void SetOpcode16(uint16_t inst, lldb::ByteOrder order)
int Dump(Stream *s, uint32_t min_byte_width)
uint32_t GetByteSize() const
void SetOpcode64(uint64_t inst, lldb::ByteOrder order)
Opcode::Type GetType() const
void SetOpcode8(uint8_t inst, lldb::ByteOrder order)
uint32_t GetData(DataExtractor &data) const
void SetOpcode32(uint32_t inst, lldb::ByteOrder order)
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.
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.
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
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 ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
const ModuleList & GetImages() const
Get accessor for the images for this process.
#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::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::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
enum lldb_private::Disassembler::Limit::@5 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.