Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/DumpRegisterValue.cpp
Line
Count
Source (jump to first uncovered line)
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
9
#include "lldb/Core/DumpRegisterValue.h"
10
#include "lldb/Core/DumpDataExtractor.h"
11
#include "lldb/Utility/DataExtractor.h"
12
#include "lldb/Utility/RegisterValue.h"
13
#include "lldb/Utility/StreamString.h"
14
#include "lldb/lldb-private-types.h"
15
16
using namespace lldb;
17
18
bool lldb_private::DumpRegisterValue(const RegisterValue &reg_val, Stream *s,
19
                                     const RegisterInfo *reg_info,
20
                                     bool prefix_with_name,
21
                                     bool prefix_with_alt_name, Format format,
22
6.11k
                                     uint32_t reg_name_right_align_at) {
23
6.11k
  DataExtractor data;
24
6.11k
  if (reg_val.GetData(data)) {
25
6.11k
    bool name_printed = false;
26
    // For simplicity, alignment of the register name printing applies only in
27
    // the most common case where:
28
    //
29
    //     prefix_with_name^prefix_with_alt_name is true
30
    //
31
6.11k
    StreamString format_string;
32
6.11k
    if (reg_name_right_align_at && (prefix_with_name ^ prefix_with_alt_name))
33
6.11k
      format_string.Printf("%%%us", reg_name_right_align_at);
34
0
    else
35
0
      format_string.Printf("%%s");
36
6.11k
    std::string fmt = std::string(format_string.GetString());
37
6.11k
    if (prefix_with_name) {
38
6.11k
      if (reg_info->name) {
39
6.11k
        s->Printf(fmt.c_str(), reg_info->name);
40
6.11k
        name_printed = true;
41
6.11k
      } else 
if (0
reg_info->alt_name0
) {
42
0
        s->Printf(fmt.c_str(), reg_info->alt_name);
43
0
        prefix_with_alt_name = false;
44
0
        name_printed = true;
45
0
      }
46
6.11k
    }
47
6.11k
    if (prefix_with_alt_name) {
48
0
      if (name_printed)
49
0
        s->PutChar('/');
50
0
      if (reg_info->alt_name) {
51
0
        s->Printf(fmt.c_str(), reg_info->alt_name);
52
0
        name_printed = true;
53
0
      } else if (!name_printed) {
54
        // No alternate name but we were asked to display a name, so show the
55
        // main name
56
0
        s->Printf(fmt.c_str(), reg_info->name);
57
0
        name_printed = true;
58
0
      }
59
0
    }
60
6.11k
    if (name_printed)
61
6.11k
      s->PutCString(" = ");
62
63
6.11k
    if (format == eFormatDefault)
64
6.11k
      format = reg_info->format;
65
66
6.11k
    DumpDataExtractor(data, s,
67
6.11k
                      0,                    // Offset in "data"
68
6.11k
                      format,               // Format to use when dumping
69
6.11k
                      reg_info->byte_size,  // item_byte_size
70
6.11k
                      1,                    // item_count
71
6.11k
                      UINT32_MAX,           // num_per_line
72
6.11k
                      LLDB_INVALID_ADDRESS, // base_addr
73
6.11k
                      0,                    // item_bit_size
74
6.11k
                      0);                   // item_bit_offset
75
6.11k
    return true;
76
6.11k
  }
77
0
  return false;
78
6.11k
}