15#include "llvm/Support/Casting.h"
20using SetInfo = std::pair<const char *, uint32_t>;
24 uint32_t terminal_width) {
25 std::vector<const char *> invalidates;
33 "Register invalidate list refers to a register that does not exist.");
34 invalidates.push_back(inv_info->
name);
39 std::vector<SetInfo> in_sets;
42 assert(set &&
"Register set should be valid.");
43 for (uint32_t reg_idx = 0; reg_idx < set->
num_registers; ++reg_idx) {
46 assert(set_reg_info &&
"Register info should be valid.");
48 if (set_reg_info == &info) {
49 in_sets.push_back({set->
name, set_idx});
55 std::vector<const char *> read_from;
61 assert(read_info &&
"Register value registers list refers to a register "
62 "that does not exist.");
63 read_from.push_back(read_info->
name);
72template <
typename ElementType>
74 const std::vector<ElementType> &list,
75 std::function<
void(
Stream &, ElementType)> emitter) {
82 for (ElementType elem : list) {
91 Stream &strm,
const char *name,
const char *alt_name, uint32_t byte_size,
92 const std::vector<const char *> &invalidates,
93 const std::vector<const char *> &read_from,
94 const std::vector<SetInfo> &in_sets,
const RegisterType *register_type,
95 uint32_t terminal_width) {
96 strm <<
" Name: " << name;
98 strm <<
" (" << alt_name <<
")";
104 strm.
Printf(
" Size: %d bytes (%d bits)", byte_size, byte_size * 8);
106 std::function<void(
Stream &,
const char *)> emit_str =
107 [](
Stream &strm,
const char *s) { strm << s; };
108 DumpList(strm,
"Invalidates: ", invalidates, emit_str);
109 DumpList(strm,
" Read from: ", read_from, emit_str);
113 strm.
Printf(
"%s (index %d)", info.first, info.second);
115 DumpList(strm,
" In sets: ", in_sets, emit_set);
117 if (
auto flags_type =
118 llvm::dyn_cast_if_present<RegisterTypeFlags>(register_type)) {
119 strm.
Printf(
"\n\n%s", flags_type->AsTable(terminal_width).c_str());
121 std::string enumerators = flags_type->DumpEnums(terminal_width);
122 if (enumerators.size())
123 strm <<
"\n\n" << enumerators;
124 }
else if (
auto *vector_type =
125 llvm::dyn_cast_if_present<RegisterTypeVector>(register_type)) {
126 strm.
Printf(
"\n\n Vector elements: %u", vector_type->GetCount());
std::pair< const char *, uint32_t > SetInfo
static void DumpList(Stream &strm, const char *title, const std::vector< ElementType > &list, std::function< void(Stream &, ElementType)> emitter)
virtual const RegisterSet * GetRegisterSet(size_t reg_set)=0
virtual const RegisterInfo * GetRegisterInfoAtIndex(size_t reg)=0
const RegisterInfo * GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num)
virtual size_t GetRegisterSetCount()=0
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 EOL()
Output and End of Line character to the stream.
#define LLDB_INVALID_REGNUM
A class that represents a running process on the host machine.
void DoDumpRegisterInfo(Stream &strm, const char *name, const char *alt_name, uint32_t byte_size, const std::vector< const char * > &invalidates, const std::vector< const char * > &read_from, const std::vector< std::pair< const char *, uint32_t > > &in_sets, const RegisterType *register_type, uint32_t terminal_width)
void DumpRegisterInfo(Stream &strm, RegisterContext &ctx, const RegisterInfo &info, uint32_t terminal_width)
@ eRegisterKindLLDB
lldb's internal register numbers
Every register is described in detail including its name, alternate name (optional),...
const char * alt_name
Alternate name of this register, can be NULL.
uint32_t * value_regs
List of registers (terminated with LLDB_INVALID_REGNUM).
uint32_t byte_size
Size in bytes of the register.
const RegisterType * register_type
If not nullptr, a type defined by XML descriptions.
const char * name
Name of this register, can't be NULL.
uint32_t * invalidate_regs
List of registers (terminated with LLDB_INVALID_REGNUM).
Registers are grouped into register sets.
size_t num_registers
The number of registers in REGISTERS array below.
const uint32_t * registers
An array of register indicies in this set.
const char * name
Name of this register set.