1 //===-- DumpRegisterValue.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/DumpRegisterValue.h"
11 #include "lldb/Core/DumpDataExtractor.h"
12 #include "lldb/Core/RegisterValue.h"
13 #include "lldb/Utility/DataExtractor.h"
14 #include "lldb/Utility/StreamString.h"
15 #include "lldb/lldb-private-types.h"
19 bool lldb_private::DumpRegisterValue(const RegisterValue ®_val, Stream *s,
20 const RegisterInfo *reg_info,
21 bool prefix_with_name,
22 bool prefix_with_alt_name, Format format,
23 uint32_t reg_name_right_align_at) {
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:
30 // prefix_with_name^prefix_with_alt_name is true
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);
36 format_string.Printf("%%s");
37 std::string fmt = format_string.GetString();
38 if (prefix_with_name) {
40 s->Printf(fmt.c_str(), reg_info->name);
42 } else if (reg_info->alt_name) {
43 s->Printf(fmt.c_str(), reg_info->alt_name);
44 prefix_with_alt_name = false;
48 if (prefix_with_alt_name) {
51 if (reg_info->alt_name) {
52 s->Printf(fmt.c_str(), reg_info->alt_name);
54 } else if (!name_printed) {
55 // No alternate name but we were asked to display a name, so show the
57 s->Printf(fmt.c_str(), reg_info->name);
64 if (format == eFormatDefault)
65 format = reg_info->format;
67 DumpDataExtractor(data, s,
68 0, // Offset in "data"
69 format, // Format to use when dumping
70 reg_info->byte_size, // item_byte_size
72 UINT32_MAX, // num_per_line
73 LLDB_INVALID_ADDRESS, // base_addr
75 0); // item_bit_offset