LLDB  mainline
DumpRegisterValue.cpp
Go to the documentation of this file.
1 //===-- DumpRegisterValue.cpp ---------------------------------------------===//
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 
15 
16 using namespace lldb;
17 
19  const RegisterInfo *reg_info,
20  bool prefix_with_name,
21  bool prefix_with_alt_name, Format format,
22  uint32_t reg_name_right_align_at,
23  ExecutionContextScope *exe_scope) {
24  DataExtractor data;
25  if (reg_val.GetData(data)) {
26  bool name_printed = false;
27  // For simplicity, alignment of the register name printing applies only in
28  // the most common case where:
29  //
30  // prefix_with_name^prefix_with_alt_name is true
31  //
32  StreamString format_string;
33  if (reg_name_right_align_at && (prefix_with_name ^ prefix_with_alt_name))
34  format_string.Printf("%%%us", reg_name_right_align_at);
35  else
36  format_string.Printf("%%s");
37  std::string fmt = std::string(format_string.GetString());
38  if (prefix_with_name) {
39  if (reg_info->name) {
40  s->Printf(fmt.c_str(), reg_info->name);
41  name_printed = true;
42  } else if (reg_info->alt_name) {
43  s->Printf(fmt.c_str(), reg_info->alt_name);
44  prefix_with_alt_name = false;
45  name_printed = true;
46  }
47  }
48  if (prefix_with_alt_name) {
49  if (name_printed)
50  s->PutChar('/');
51  if (reg_info->alt_name) {
52  s->Printf(fmt.c_str(), reg_info->alt_name);
53  name_printed = true;
54  } else if (!name_printed) {
55  // No alternate name but we were asked to display a name, so show the
56  // main name
57  s->Printf(fmt.c_str(), reg_info->name);
58  name_printed = true;
59  }
60  }
61  if (name_printed)
62  s->PutCString(" = ");
63 
64  if (format == eFormatDefault)
65  format = reg_info->format;
66 
67  DumpDataExtractor(data, s,
68  0, // Offset in "data"
69  format, // Format to use when dumping
70  reg_info->byte_size, // item_byte_size
71  1, // item_count
72  UINT32_MAX, // num_per_line
73  LLDB_INVALID_ADDRESS, // base_addr
74  0, // item_bit_size
75  0, // item_bit_offset
76  exe_scope);
77  return true;
78  }
79  return false;
80 }
lldb-private-types.h
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
lldb_private::RegisterValue
Definition: RegisterValue.h:28
RegisterValue.h
lldb_private::Stream
Definition: Stream.h:28
lldb_private::DumpDataExtractor
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
Definition: DumpDataExtractor.cpp:341
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
DumpRegisterValue.h
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
StreamString.h
lldb_private::RegisterValue::GetData
bool GetData(DataExtractor &data) const
Definition: RegisterValue.cpp:34
lldb_private::StreamString
Definition: StreamString.h:23
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
DumpDataExtractor.h
uint32_t
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::DumpRegisterValue
bool DumpRegisterValue(const RegisterValue &reg_val, Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, bool prefix_with_alt_name, lldb::Format format, uint32_t reg_name_right_align_at=0, ExecutionContextScope *exe_scope=nullptr)
Definition: DumpRegisterValue.cpp:18
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
DataExtractor.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb
Definition: SBAddress.h:15
lldb::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:156