LLDB  mainline
Disassembler.h
Go to the documentation of this file.
1 //===-- Disassembler.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_DISASSEMBLER_H
10 #define LLDB_CORE_DISASSEMBLER_H
11 
12 #include "lldb/Core/Address.h"
14 #include "lldb/Core/FormatEntity.h"
15 #include "lldb/Core/Opcode.h"
18 #include "lldb/Symbol/LineEntry.h"
20 #include "lldb/Utility/ArchSpec.h"
22 #include "lldb/Utility/FileSpec.h"
23 #include "lldb/lldb-defines.h"
24 #include "lldb/lldb-forward.h"
26 #include "lldb/lldb-types.h"
27 
28 #include "llvm/ADT/StringRef.h"
29 
30 #include <functional>
31 #include <map>
32 #include <memory>
33 #include <set>
34 #include <string>
35 #include <vector>
36 
37 #include <cstddef>
38 #include <cstdint>
39 #include <cstdio>
40 
41 namespace llvm {
42 template <typename T> class SmallVectorImpl;
43 }
44 
45 namespace lldb_private {
46 class AddressRange;
47 class DataExtractor;
48 class Debugger;
49 class Disassembler;
50 class Module;
51 class StackFrame;
52 class Stream;
53 class SymbolContext;
54 class SymbolContextList;
55 class Target;
56 struct RegisterInfo;
57 
58 class Instruction {
59 public:
60  Instruction(const Address &address,
62 
63  virtual ~Instruction();
64 
65  const Address &GetAddress() const { return m_address; }
66 
67  const char *GetMnemonic(const ExecutionContext *exe_ctx) {
69  return m_opcode_name.c_str();
70  }
71 
72  const char *GetOperands(const ExecutionContext *exe_ctx) {
74  return m_mnemonics.c_str();
75  }
76 
77  const char *GetComment(const ExecutionContext *exe_ctx) {
79  return m_comment.c_str();
80  }
81 
82  /// \return
83  /// The control flow kind of this instruction, or
84  /// eInstructionControlFlowKindUnknown if the instruction
85  /// can't be classified.
89  }
90 
91  virtual void
93 
95 
96  void SetAddress(const Address &addr) {
97  // Invalidate the address class to lazily discover it if we need to.
99  m_address = addr;
100  }
101 
102  /// Dump the text representation of this Instruction to a Stream
103  ///
104  /// Print the (optional) address, (optional) bytes, opcode,
105  /// operands, and instruction comments to a stream.
106  ///
107  /// \param[in] s
108  /// The Stream to add the text to.
109  ///
110  /// \param[in] show_address
111  /// Whether the address (using disassembly_addr_format_spec formatting)
112  /// should be printed.
113  ///
114  /// \param[in] show_bytes
115  /// Whether the bytes of the assembly instruction should be printed.
116  ///
117  /// \param[in] show_control_flow_kind
118  /// Whether the control flow kind of the instruction should be printed.
119  ///
120  /// \param[in] max_opcode_byte_size
121  /// The size (in bytes) of the largest instruction in the list that
122  /// we are printing (for text justification/alignment purposes)
123  /// Only needed if show_bytes is true.
124  ///
125  /// \param[in] exe_ctx
126  /// The current execution context, if available. May be used in
127  /// the assembling of the operands+comments for this instruction.
128  /// Pass NULL if not applicable.
129  ///
130  /// \param[in] sym_ctx
131  /// The SymbolContext for this instruction.
132  /// Pass NULL if not available/computed.
133  /// Only needed if show_address is true.
134  ///
135  /// \param[in] prev_sym_ctx
136  /// The SymbolContext for the previous instruction. Depending on
137  /// the disassembly address format specification, a change in
138  /// Symbol / Function may mean that a line is printed with the new
139  /// symbol/function name.
140  /// Pass NULL if unavailable, or if this is the first instruction of
141  /// the InstructionList.
142  /// Only needed if show_address is true.
143  ///
144  /// \param[in] disassembly_addr_format
145  /// The format specification for how addresses are printed.
146  /// Only needed if show_address is true.
147  ///
148  /// \param[in] max_address_text_size
149  /// The length of the longest address string at the start of the
150  /// disassembly line that will be printed (the
151  /// Debugger::FormatDisassemblerAddress() string)
152  /// so this method can properly align the instruction opcodes.
153  /// May be 0 to indicate no indentation/alignment of the opcodes.
154  virtual void Dump(Stream *s, uint32_t max_opcode_byte_size, bool show_address,
155  bool show_bytes, bool show_control_flow_kind,
156  const ExecutionContext *exe_ctx,
157  const SymbolContext *sym_ctx,
158  const SymbolContext *prev_sym_ctx,
159  const FormatEntity::Entry *disassembly_addr_format,
160  size_t max_address_text_size);
161 
162  virtual bool DoesBranch() = 0;
163 
164  virtual bool HasDelaySlot();
165 
166  virtual bool IsLoad() = 0;
167 
168  virtual bool IsAuthenticated() = 0;
169 
170  bool CanSetBreakpoint ();
171 
172  virtual size_t Decode(const Disassembler &disassembler,
173  const DataExtractor &data,
174  lldb::offset_t data_offset) = 0;
175 
176  virtual void SetDescription(llvm::StringRef) {
177  } // May be overridden in sub-classes that have descriptions.
178 
179  lldb::OptionValueSP ReadArray(FILE *in_file, Stream *out_stream,
180  OptionValue::Type data_type);
181 
182  lldb::OptionValueSP ReadDictionary(FILE *in_file, Stream *out_stream);
183 
184  bool DumpEmulation(const ArchSpec &arch);
185 
186  virtual bool TestEmulation(Stream *stream, const char *test_file_name);
187 
188  bool Emulate(const ArchSpec &arch, uint32_t evaluate_options, void *baton,
189  EmulateInstruction::ReadMemoryCallback read_mem_callback,
190  EmulateInstruction::WriteMemoryCallback write_mem_calback,
192  EmulateInstruction::WriteRegisterCallback write_reg_callback);
193 
194  const Opcode &GetOpcode() const { return m_opcode; }
195 
197 
198  struct Operand {
199  enum class Type {
200  Invalid = 0,
201  Register,
202  Immediate,
203  Dereference,
204  Sum,
205  Product
206  } m_type = Type::Invalid;
207  std::vector<Operand> m_children;
210  bool m_negative = false;
211  bool m_clobbered = false;
212 
213  bool IsValid() { return m_type != Type::Invalid; }
214 
215  static Operand BuildRegister(ConstString &r);
216  static Operand BuildImmediate(lldb::addr_t imm, bool neg);
217  static Operand BuildImmediate(int64_t imm);
218  static Operand BuildDereference(const Operand &ref);
219  static Operand BuildSum(const Operand &lhs, const Operand &rhs);
220  static Operand BuildProduct(const Operand &lhs, const Operand &rhs);
221  };
222 
224  return false;
225  }
226 
227  virtual bool IsCall() { return false; }
228 
229  static const char *GetNameForInstructionControlFlowKind(
230  lldb::InstructionControlFlowKind instruction_control_flow_kind);
231 
232 protected:
233  Address m_address; // The section offset address of this instruction
234  // We include an address class in the Instruction class to
235  // allow the instruction specify the
236  // AddressClass::eCodeAlternateISA (currently used for
237  // thumb), and also to specify data (AddressClass::eData).
238  // The usual value will be AddressClass::eCode, but often
239  // when disassembling memory, you might run into data.
240  // This can help us to disassemble appropriately.
241 private:
242  AddressClass m_address_class; // Use GetAddressClass () accessor function!
243 
244 protected:
245  Opcode m_opcode; // The opcode for this instruction
250 
251  void
253  if (!m_calculated_strings) {
254  m_calculated_strings = true;
256  }
257  }
258 };
259 
260 namespace OperandMatchers {
261 std::function<bool(const Instruction::Operand &)>
262 MatchBinaryOp(std::function<bool(const Instruction::Operand &)> base,
263  std::function<bool(const Instruction::Operand &)> left,
264  std::function<bool(const Instruction::Operand &)> right);
265 
266 std::function<bool(const Instruction::Operand &)>
267 MatchUnaryOp(std::function<bool(const Instruction::Operand &)> base,
268  std::function<bool(const Instruction::Operand &)> child);
269 
270 std::function<bool(const Instruction::Operand &)>
271 MatchRegOp(const RegisterInfo &info);
272 
273 std::function<bool(const Instruction::Operand &)> FetchRegOp(ConstString &reg);
274 
275 std::function<bool(const Instruction::Operand &)> MatchImmOp(int64_t imm);
276 
277 std::function<bool(const Instruction::Operand &)> FetchImmOp(int64_t &imm);
278 
279 std::function<bool(const Instruction::Operand &)>
281 }
282 
284 public:
285  InstructionList();
287 
288  size_t GetSize() const;
289 
291 
292  lldb::InstructionSP GetInstructionAtIndex(size_t idx) const;
293 
294  /// Get the instruction at the given address.
295  ///
296  /// \return
297  /// A valid \a InstructionSP if the address could be found, or null
298  /// otherwise.
299  lldb::InstructionSP GetInstructionAtAddress(const Address &addr);
300 
301  //------------------------------------------------------------------
302  /// Get the index of the next branch instruction.
303  ///
304  /// Given a list of instructions, find the next branch instruction
305  /// in the list by returning an index.
306  ///
307  /// @param[in] start
308  /// The instruction index of the first instruction to check.
309  ///
310  /// @param[in] ignore_calls
311  /// It true, then fine the first branch instruction that isn't
312  /// a function call (a branch that calls and returns to the next
313  /// instruction). If false, find the instruction index of any
314  /// branch in the list.
315  ///
316  /// @param[out] found_calls
317  /// If non-null, this will be set to true if any calls were found in
318  /// extending the range.
319  ///
320  /// @return
321  /// The instruction index of the first branch that is at or past
322  /// \a start. Returns UINT32_MAX if no matching branches are
323  /// found.
324  //------------------------------------------------------------------
326  bool ignore_calls,
327  bool *found_calls) const;
328 
330  Target &target);
331 
333 
334  void Clear();
335 
336  void Append(lldb::InstructionSP &inst_sp);
337 
338  void Dump(Stream *s, bool show_address, bool show_bytes,
339  bool show_control_flow_kind, const ExecutionContext *exe_ctx);
340 
341 private:
342  typedef std::vector<lldb::InstructionSP> collection;
343  typedef collection::iterator iterator;
344  typedef collection::const_iterator const_iterator;
345 
347 };
348 
350 public:
352 
353  ~PseudoInstruction() override;
354 
355  bool DoesBranch() override;
356 
357  bool HasDelaySlot() override;
358 
359  bool IsLoad() override;
360 
361  bool IsAuthenticated() override;
362 
364  const ExecutionContext *exe_ctx) override {
365  // TODO: fill this in and put opcode name into Instruction::m_opcode_name,
366  // mnemonic into Instruction::m_mnemonics, and any comment into
367  // Instruction::m_comment
368  }
369 
370  size_t Decode(const Disassembler &disassembler, const DataExtractor &data,
371  lldb::offset_t data_offset) override;
372 
373  void SetOpcode(size_t opcode_size, void *opcode_data);
374 
375  void SetDescription(llvm::StringRef description) override;
376 
377 protected:
379 
380  PseudoInstruction(const PseudoInstruction &) = delete;
381  const PseudoInstruction &operator=(const PseudoInstruction &) = delete;
382 };
383 
384 class Disassembler : public std::enable_shared_from_this<Disassembler>,
385  public PluginInterface {
386 public:
387  enum {
389  eOptionShowBytes = (1u << 0),
390  eOptionRawOuput = (1u << 1),
391  eOptionMarkPCSourceLine = (1u << 2), // Mark the source line that contains
392  // the current PC (mixed mode only)
394  (1u << 3), // Mark the disassembly line the contains the PC
396  };
397 
401  };
402 
403  // FindPlugin should be lax about the flavor string (it is too annoying to
404  // have various internal uses of the disassembler fail because the global
405  // flavor string gets set wrong. Instead, if you get a flavor string you
406  // don't understand, use the default. Folks who care to check can use the
407  // FlavorValidForArchSpec method on the disassembler they got back.
408  static lldb::DisassemblerSP
409  FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name);
410 
411  // This version will use the value in the Target settings if flavor is NULL;
412  static lldb::DisassemblerSP FindPluginForTarget(const Target &target,
413  const ArchSpec &arch,
414  const char *flavor,
415  const char *plugin_name);
416 
417  struct Limit {
420  };
421 
422  static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch,
423  const char *plugin_name,
424  const char *flavor,
425  Target &target,
426  const AddressRange &disasm_range,
427  bool force_live_memory = false);
428 
429  static lldb::DisassemblerSP
430  DisassembleBytes(const ArchSpec &arch, const char *plugin_name,
431  const char *flavor, const Address &start, const void *bytes,
432  size_t length, uint32_t max_num_instructions,
433  bool data_from_file);
434 
435  static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
436  const char *plugin_name, const char *flavor,
437  const ExecutionContext &exe_ctx, const Address &start,
438  Limit limit, bool mixed_source_and_assembly,
439  uint32_t num_mixed_context_lines, uint32_t options,
440  Stream &strm);
441 
442  static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
443  StackFrame &frame, Stream &strm);
444 
445  // Constructors and Destructors
446  Disassembler(const ArchSpec &arch, const char *flavor);
447  ~Disassembler() override;
448 
449  void PrintInstructions(Debugger &debugger, const ArchSpec &arch,
450  const ExecutionContext &exe_ctx,
451  bool mixed_source_and_assembly,
452  uint32_t num_mixed_context_lines, uint32_t options,
453  Stream &strm);
454 
455  size_t ParseInstructions(Target &target, Address address, Limit limit,
456  Stream *error_strm_ptr,
457  bool force_live_memory = false);
458 
459  virtual size_t DecodeInstructions(const Address &base_addr,
460  const DataExtractor &data,
461  lldb::offset_t data_offset,
462  size_t num_instructions, bool append,
463  bool data_from_file) = 0;
464 
466 
467  const InstructionList &GetInstructionList() const;
468 
469  const ArchSpec &GetArchitecture() const { return m_arch; }
470 
471  const char *GetFlavor() const { return m_flavor.c_str(); }
472 
473  virtual bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch,
474  const char *flavor) = 0;
475 
476 protected:
477  // SourceLine and SourceLinesToDisplay structures are only used in the mixed
478  // source and assembly display methods internal to this class.
479 
480  struct SourceLine {
484 
485  SourceLine() = default;
486 
487  bool operator==(const SourceLine &rhs) const {
488  return file == rhs.file && line == rhs.line && rhs.column == column;
489  }
490 
491  bool operator!=(const SourceLine &rhs) const {
492  return file != rhs.file || line != rhs.line || column != rhs.column;
493  }
494 
495  bool IsValid() const { return line != LLDB_INVALID_LINE_NUMBER; }
496  };
497 
499  std::vector<SourceLine> lines;
500 
501  // index of the "current" source line, if we want to highlight that when
502  // displaying the source lines. (as opposed to the surrounding source
503  // lines provided to give context)
504  size_t current_source_line = -1;
505 
506  // Whether to print a blank line at the end of the source lines.
508 
509  SourceLinesToDisplay() = default;
510  };
511 
512  // Get the function's declaration line number, hopefully a line number
513  // earlier than the opening curly brace at the start of the function body.
515 
516  // Add the provided SourceLine to the map of filenames-to-source-lines-seen.
517  static void AddLineToSourceLineTables(
518  SourceLine &line,
519  std::map<FileSpec, std::set<uint32_t>> &source_lines_seen);
520 
521  // Given a source line, determine if we should print it when we're doing
522  // mixed source & assembly output. We're currently using the
523  // target.process.thread.step-avoid-regexp setting (which is used for
524  // stepping over inlined STL functions by default) to determine what source
525  // lines to avoid showing.
526  //
527  // Returns true if this source line should be elided (if the source line
528  // should not be displayed).
529  static bool
531  const SymbolContext &sc, SourceLine &line);
532 
533  static bool
535  const SymbolContext &sc, LineEntry &line) {
536  SourceLine sl;
537  sl.file = line.file;
538  sl.line = line.line;
539  sl.column = line.column;
540  return ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, sl);
541  };
542 
543  // Classes that inherit from Disassembler can see and modify these
548 
549 private:
550  // For Disassembler only
551  Disassembler(const Disassembler &) = delete;
552  const Disassembler &operator=(const Disassembler &) = delete;
553 };
554 
555 } // namespace lldb_private
556 
557 #endif // LLDB_CORE_DISASSEMBLER_H
lldb_private::Disassembler::SourceLinesToDisplay::current_source_line
size_t current_source_line
Definition: Disassembler.h:504
lldb_private::Disassembler::eOptionNone
@ eOptionNone
Definition: Disassembler.h:388
lldb_private::Disassembler::ElideMixedSourceAndDisassemblyLine
static bool ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx, const SymbolContext &sc, SourceLine &line)
Definition: Disassembler.cpp:236
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
llvm
Definition: Debugger.h:50
lldb_private::EmulateInstruction::ReadMemoryCallback
size_t(* ReadMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
Definition: EmulateInstruction.h:333
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
lldb_private::Instruction::IsCall
virtual bool IsCall()
Definition: Disassembler.h:227
lldb_private::EmulateInstruction::WriteRegisterCallback
bool(* WriteRegisterCallback)(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.h:348
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::Instruction::Operand::m_immediate
lldb::addr_t m_immediate
Definition: Disassembler.h:208
lldb_private::Disassembler::SourceLinesToDisplay::SourceLinesToDisplay
SourceLinesToDisplay()=default
lldb_private::Instruction::GetData
uint32_t GetData(DataExtractor &data)
Definition: Disassembler.cpp:959
lldb_private::Instruction::Operand::m_negative
bool m_negative
Definition: Disassembler.h:210
lldb_private::Instruction::Operand::m_register
ConstString m_register
Definition: Disassembler.h:209
lldb_private::Opcode
Definition: Opcode.h:29
lldb_private::OperandMatchers::FetchImmOp
std::function< bool(const Instruction::Operand &)> FetchImmOp(int64_t &imm)
Definition: Disassembler.h:277
lldb_private::Instruction::GetOperands
const char * GetOperands(const ExecutionContext *exe_ctx)
Definition: Disassembler.h:72
lldb_private::AddressClass
AddressClass
Definition: lldb-private-enumerations.h:48
Opcode.h
lldb_private::OperandMatchers::MatchOpType
std::function< bool(const Instruction::Operand &)> MatchOpType(Instruction::Operand::Type type)
Definition: Disassembler.h:280
lldb_private::Disassembler::~Disassembler
~Disassembler() override
lldb_private::Disassembler::m_base_addr
lldb::addr_t m_base_addr
Definition: Disassembler.h:546
lldb_private::Disassembler::SourceLine::file
FileSpec file
Definition: Disassembler.h:481
lldb_private::PluginInterface
Definition: PluginInterface.h:16
lldb-defines.h
lldb_private::Instruction::m_mnemonics
std::string m_mnemonics
Definition: Disassembler.h:247
lldb_private::Instruction::GetAddressClass
AddressClass GetAddressClass()
Definition: Disassembler.cpp:574
lldb_private::Disassembler::FindPlugin
static lldb::DisassemblerSP FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name)
Definition: Disassembler.cpp:58
lldb_private::PseudoInstruction::m_description
std::string m_description
Definition: Disassembler.h:378
lldb_private::PseudoInstruction
Definition: Disassembler.h:349
lldb_private::Instruction::Decode
virtual size_t Decode(const Disassembler &disassembler, const DataExtractor &data, lldb::offset_t data_offset)=0
lldb_private::Disassembler::Limit::Bytes
@ Bytes
Definition: Disassembler.h:418
lldb_private::InstructionList::GetIndexOfInstructionAtLoadAddress
uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr, Target &target)
Definition: Disassembler.cpp:1067
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::InstructionList::GetInstructionAtIndex
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const
Definition: Disassembler.cpp:981
lldb_private::Disassembler::Limit
Definition: Disassembler.h:417
lldb_private::Instruction
Definition: Disassembler.h:58
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Instruction::m_address_class
AddressClass m_address_class
Definition: Disassembler.h:242
lldb_private::Instruction::Operand::m_children
std::vector< Operand > m_children
Definition: Disassembler.h:207
lldb_private::Disassembler::Limit::kind
enum lldb_private::Disassembler::Limit::@6 kind
lldb-private-enumerations.h
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::Disassembler::eOptionShowBytes
@ eOptionShowBytes
Definition: Disassembler.h:389
lldb_private::Instruction::m_opcode_name
std::string m_opcode_name
Definition: Disassembler.h:246
lldb_private::AddressClass::eInvalid
@ eInvalid
lldb_private::Instruction::IsLoad
virtual bool IsLoad()=0
lldb_private::Instruction::CalculateMnemonicOperandsAndComment
virtual void CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx)=0
lldb_private::Disassembler::DisassembleBytes
static lldb::DisassemblerSP DisassembleBytes(const ArchSpec &arch, const char *plugin_name, const char *flavor, const Address &start, const void *bytes, size_t length, uint32_t max_num_instructions, bool data_from_file)
Definition: Disassembler.cpp:147
lldb_private::Instruction::GetOpcode
const Opcode & GetOpcode() const
Definition: Disassembler.h:194
lldb_private::Instruction::~Instruction
virtual ~Instruction()
lldb_private::Instruction::DumpEmulation
bool DumpEmulation(const ArchSpec &arch)
Definition: Disassembler.cpp:674
lldb_private::Instruction::Instruction
Instruction(const Address &address, AddressClass addr_class=AddressClass::eInvalid)
Definition: Disassembler.cpp:568
OptionValue.h
lldb_private::Instruction::Operand::Type::Sum
@ Sum
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::InstructionList::Dump
void Dump(Stream *s, bool show_address, bool show_bytes, bool show_control_flow_kind, const ExecutionContext *exe_ctx)
Definition: Disassembler.cpp:995
lldb_private::Instruction::Operand::Type
Type
Definition: Disassembler.h:199
lldb_private::Disassembler::m_flavor
std::string m_flavor
Definition: Disassembler.h:547
lldb_private::Disassembler::SourceLinesToDisplay::print_source_context_end_eol
bool print_source_context_end_eol
Definition: Disassembler.h:507
lldb_private::InstructionList
Definition: Disassembler.h:283
lldb_private::OperandMatchers::FetchRegOp
std::function< bool(const Instruction::Operand &)> FetchRegOp(ConstString &reg)
Definition: Disassembler.h:273
lldb_private::Disassembler::eHexStyleC
@ eHexStyleC
Definition: Disassembler.h:399
lldb_private::Disassembler::DisassembleRange
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, Target &target, const AddressRange &disasm_range, bool force_live_memory=false)
Definition: Disassembler.cpp:122
EmulateInstruction.h
lldb_private::OperandMatchers::MatchBinaryOp
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)
Definition: Disassembler.h:262
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::Instruction::ReadArray
lldb::OptionValueSP ReadArray(FILE *in_file, Stream *out_stream, OptionValue::Type data_type)
Definition: Disassembler.cpp:694
lldb_private::Disassembler::eHexStyleAsm
@ eHexStyleAsm
Definition: Disassembler.h:400
lldb_private::Disassembler::SourceLine::IsValid
bool IsValid() const
Definition: Disassembler.h:495
lldb_private::Instruction::Dump
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.
Definition: Disassembler.cpp:605
lldb_private::PseudoInstruction::Decode
size_t Decode(const Disassembler &disassembler, const DataExtractor &data, lldb::offset_t data_offset) override
Definition: Disassembler.cpp:1167
lldb_private::Disassembler::eOptionShowControlFlowKind
@ eOptionShowControlFlowKind
Definition: Disassembler.h:395
LineEntry.h
lldb_private::Disassembler::DecodeInstructions
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
lldb::InstructionControlFlowKind
InstructionControlFlowKind
Architecture-agnostic categorization of instructions for traversing the control flow of a trace.
Definition: lldb-enumerations.h:984
lldb_private::Instruction::m_opcode
Opcode m_opcode
Definition: Disassembler.h:245
lldb_private::Disassembler::PrintInstructions
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)
Definition: Disassembler.cpp:278
lldb_private::Instruction::GetAddress
const Address & GetAddress() const
Definition: Disassembler.h:65
lldb_private::Disassembler::Disassemble
static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, 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)
Definition: Disassembler.cpp:168
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::Instruction::HasDelaySlot
virtual bool HasDelaySlot()
Definition: Disassembler.cpp:689
lldb_private::Instruction::CalculateMnemonicOperandsAndCommentIfNeeded
void CalculateMnemonicOperandsAndCommentIfNeeded(const ExecutionContext *exe_ctx)
Definition: Disassembler.h:252
lldb_private::Disassembler::SourceLine::line
uint32_t line
Definition: Disassembler.h:482
lldb_private::Instruction::GetComment
const char * GetComment(const ExecutionContext *exe_ctx)
Definition: Disassembler.h:77
PluginInterface.h
lldb_private::Instruction::Operand::BuildDereference
static Operand BuildDereference(const Operand &ref)
Definition: Disassembler.cpp:1237
lldb_private::Disassembler::SourceLine::operator==
bool operator==(const SourceLine &rhs) const
Definition: Disassembler.h:487
lldb_private::OperandMatchers::MatchImmOp
std::function< bool(const Instruction::Operand &)> MatchImmOp(int64_t imm)
Definition: Disassembler.h:275
lldb_private::InstructionList::GetIndexOfNextBranchInstruction
uint32_t GetIndexOfNextBranchInstruction(uint32_t start, bool ignore_calls, bool *found_calls) const
Get the index of the next branch instruction.
Definition: Disassembler.cpp:1029
lldb_private::Instruction::Operand
Definition: Disassembler.h:198
lldb_private::PseudoInstruction::IsAuthenticated
bool IsAuthenticated() override
Definition: Disassembler.cpp:1165
lldb_private::Disassembler::m_instruction_list
InstructionList m_instruction_list
Definition: Disassembler.h:545
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::Instruction::Operand::BuildImmediate
static Operand BuildImmediate(lldb::addr_t imm, bool neg)
Definition: Disassembler.cpp:1214
lldb_private::InstructionList::GetMaxOpcocdeByteSize
uint32_t GetMaxOpcocdeByteSize() const
Definition: Disassembler.cpp:969
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::EmulateInstruction::WriteMemoryCallback
size_t(* WriteMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
Definition: EmulateInstruction.h:338
lldb_private::LineEntry::column
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:146
lldb_private::Instruction::Operand::BuildRegister
static Operand BuildRegister(ConstString &r)
Definition: Disassembler.cpp:1207
Address.h
lldb_private::Disassembler::SourceLine
Definition: Disassembler.h:480
lldb_private::Instruction::m_comment
std::string m_comment
Definition: Disassembler.h:248
lldb_private::Disassembler::operator=
const Disassembler & operator=(const Disassembler &)=delete
lldb_private::Disassembler::Limit::value
lldb::addr_t value
Definition: Disassembler.h:419
lldb_private::Disassembler::eOptionMarkPCAddress
@ eOptionMarkPCAddress
Definition: Disassembler.h:393
lldb_private::Instruction::Operand::Type::Register
@ Register
lldb_private::LineEntry::line
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
lldb_private::InstructionList::iterator
collection::iterator iterator
Definition: Disassembler.h:343
LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:86
lldb_private::Instruction::Operand::Type::Invalid
@ Invalid
lldb-types.h
lldb_private::Disassembler::GetFunctionDeclLineEntry
static SourceLine GetFunctionDeclLineEntry(const SymbolContext &sc)
Definition: Disassembler.cpp:196
lldb_private::Instruction::Operand::Type::Dereference
@ Dereference
lldb_private::OperandMatchers::MatchRegOp
std::function< bool(const Instruction::Operand &)> MatchRegOp(const RegisterInfo &info)
Definition: Disassembler.h:271
lldb_private::InstructionList::const_iterator
collection::const_iterator const_iterator
Definition: Disassembler.h:344
lldb_private::Disassembler::ElideMixedSourceAndDisassemblyLine
static bool ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx, const SymbolContext &sc, LineEntry &line)
Definition: Disassembler.h:534
lldb_private::Instruction::Operand::BuildProduct
static Operand BuildProduct(const Operand &lhs, const Operand &rhs)
Definition: Disassembler.cpp:1252
lldb_private::PseudoInstruction::DoesBranch
bool DoesBranch() override
Definition: Disassembler.cpp:1153
lldb_private::PseudoInstruction::IsLoad
bool IsLoad() override
Definition: Disassembler.cpp:1163
lldb_private::Instruction::Operand::BuildSum
static Operand BuildSum(const Operand &lhs, const Operand &rhs)
Definition: Disassembler.cpp:1244
lldb_private::PseudoInstruction::PseudoInstruction
PseudoInstruction()
Definition: Disassembler.cpp:1148
lldb_private::OptionValue::Type
Type
Definition: OptionValue.h:27
lldb_private::PseudoInstruction::CalculateMnemonicOperandsAndComment
void CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx) override
Definition: Disassembler.h:363
lldb_private::OperandMatchers::MatchUnaryOp
std::function< bool(const Instruction::Operand &)> MatchUnaryOp(std::function< bool(const Instruction::Operand &)> base, std::function< bool(const Instruction::Operand &)> child)
Definition: Disassembler.h:267
uint32_t
lldb_private::Instruction::GetControlFlowKind
virtual lldb::InstructionControlFlowKind GetControlFlowKind(const ExecutionContext *exe_ctx)
Definition: Disassembler.h:87
lldb_private::InstructionList::collection
std::vector< lldb::InstructionSP > collection
Definition: Disassembler.h:342
lldb_private::Address
Definition: Address.h:59
lldb_private::Instruction::GetMnemonic
const char * GetMnemonic(const ExecutionContext *exe_ctx)
Definition: Disassembler.h:67
lldb_private::Disassembler::Limit::Instructions
@ Instructions
Definition: Disassembler.h:418
lldb_private::Disassembler::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Disassembler.h:469
lldb_private::Instruction::m_address
Address m_address
Definition: Disassembler.h:233
lldb_private::Disassembler::HexImmediateStyle
HexImmediateStyle
Definition: Disassembler.h:398
lldb_private::InstructionList::m_instructions
collection m_instructions
Definition: Disassembler.h:346
ArchSpec.h
lldb_private::FormatEntity::Entry
Definition: FormatEntity.h:40
FormatEntity.h
lldb_private::Instruction::m_calculated_strings
bool m_calculated_strings
Definition: Disassembler.h:249
lldb_private::Disassembler::SourceLinesToDisplay
Definition: Disassembler.h:498
lldb_private::InstructionList::InstructionList
InstructionList()
Definition: Disassembler.cpp:963
lldb_private::Instruction::Operand::m_type
enum lldb_private::Instruction::Operand::Type m_type
lldb_private::InstructionList::Clear
void Clear()
Definition: Disassembler.cpp:1021
lldb_private::Instruction::SetDescription
virtual void SetDescription(llvm::StringRef)
Definition: Disassembler.h:176
lldb_private::InstructionList::GetSize
size_t GetSize() const
Definition: Disassembler.cpp:967
lldb-forward.h
lldb_private::Disassembler::SourceLine::column
uint32_t column
Definition: Disassembler.h:483
lldb_private::Disassembler::AddLineToSourceLineTables
static void AddLineToSourceLineTables(SourceLine &line, std::map< FileSpec, std::set< uint32_t >> &source_lines_seen)
Definition: Disassembler.cpp:221
lldb_private::InstructionList::GetInstructionAtAddress
lldb::InstructionSP GetInstructionAtAddress(const Address &addr)
Get the instruction at the given address.
Definition: Disassembler.cpp:988
lldb_private::Instruction::DoesBranch
virtual bool DoesBranch()=0
lldb_private::Disassembler
Definition: Disassembler.h:384
lldb::eInstructionControlFlowKindUnknown
@ eInstructionControlFlowKindUnknown
The instruction could not be classified.
Definition: lldb-enumerations.h:986
lldb_private::Disassembler::FlavorValidForArchSpec
virtual bool FlavorValidForArchSpec(const lldb_private::ArchSpec &arch, const char *flavor)=0
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Instruction::Operand::Type::Product
@ Product
lldb_private::PseudoInstruction::~PseudoInstruction
~PseudoInstruction() override
lldb_private::Disassembler::SourceLine::operator!=
bool operator!=(const SourceLine &rhs) const
Definition: Disassembler.h:491
lldb_private::Disassembler::GetInstructionList
InstructionList & GetInstructionList()
Definition: Disassembler.cpp:1138
lldb_private::Instruction::ReadDictionary
lldb::OptionValueSP ReadDictionary(FILE *in_file, Stream *out_stream)
Definition: Disassembler.cpp:753
lldb_private::Instruction::ParseOperands
virtual bool ParseOperands(llvm::SmallVectorImpl< Operand > &operands)
Definition: Disassembler.h:223
lldb_private::PseudoInstruction::SetOpcode
void SetOpcode(size_t opcode_size, void *opcode_data)
Definition: Disassembler.cpp:1173
FileSpec.h
lldb_private::Instruction::SetAddress
void SetAddress(const Address &addr)
Definition: Disassembler.h:96
ConstString.h
lldb_private::Disassembler::GetFlavor
const char * GetFlavor() const
Definition: Disassembler.h:471
lldb_private::Disassembler::FindPluginForTarget
static lldb::DisassemblerSP FindPluginForTarget(const Target &target, const ArchSpec &arch, const char *flavor, const char *plugin_name)
Definition: Disassembler.cpp:89
lldb_private::InstructionList::Append
void Append(lldb::InstructionSP &inst_sp)
Definition: Disassembler.cpp:1023
lldb_private::InstructionList::~InstructionList
~InstructionList()
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::PseudoInstruction::operator=
const PseudoInstruction & operator=(const PseudoInstruction &)=delete
lldb_private::Instruction::CanSetBreakpoint
bool CanSetBreakpoint()
Definition: Disassembler.cpp:685
lldb_private::InstructionList::GetIndexOfInstructionAtAddress
uint32_t GetIndexOfInstructionAtAddress(const Address &addr)
Definition: Disassembler.cpp:1054
lldb_private::Disassembler::m_arch
ArchSpec m_arch
Definition: Disassembler.h:541
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::PseudoInstruction::SetDescription
void SetDescription(llvm::StringRef description) override
Definition: Disassembler.cpp:1203
lldb_private::Instruction::Operand::IsValid
bool IsValid()
Definition: Disassembler.h:213
lldb_private::Disassembler::ParseInstructions
size_t ParseInstructions(Target &target, Address address, Limit limit, Stream *error_strm_ptr, bool force_live_memory=false)
Definition: Disassembler.cpp:1074
lldb_private::Instruction::Emulate
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)
Definition: Disassembler.cpp:940
lldb_private::Disassembler::SourceLine::SourceLine
SourceLine()=default
lldb_private::Instruction::IsAuthenticated
virtual bool IsAuthenticated()=0
lldb_private::Disassembler::eOptionMarkPCSourceLine
@ eOptionMarkPCSourceLine
Definition: Disassembler.h:391
lldb_private::LineEntry
Definition: LineEntry.h:20
lldb_private::Disassembler::Disassembler
Disassembler(const ArchSpec &arch, const char *flavor)
Definition: Disassembler.cpp:1115
ExecutionContext.h
lldb_private::Instruction::TestEmulation
virtual bool TestEmulation(Stream *stream, const char *test_file_name)
Definition: Disassembler.cpp:857
lldb_private::EmulateInstruction::ReadRegisterCallback
bool(* ReadRegisterCallback)(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.h:343
lldb_private::Instruction::Operand::m_clobbered
bool m_clobbered
Definition: Disassembler.h:211
lldb_private::Disassembler::eOptionRawOuput
@ eOptionRawOuput
Definition: Disassembler.h:390
lldb_private::Disassembler::SourceLinesToDisplay::lines
std::vector< SourceLine > lines
Definition: Disassembler.h:499
lldb_private::Instruction::GetNameForInstructionControlFlowKind
static const char * GetNameForInstructionControlFlowKind(lldb::InstructionControlFlowKind instruction_control_flow_kind)
Definition: Disassembler.cpp:580
lldb_private::Instruction::Operand::Type::Immediate
@ Immediate
lldb_private::PseudoInstruction::HasDelaySlot
bool HasDelaySlot() override
Definition: Disassembler.cpp:1158