Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/AddressResolverFileLine.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- AddressResolverFileLine.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/AddressResolverFileLine.h"
10
11
#include "lldb/Core/Address.h"
12
#include "lldb/Core/AddressRange.h"
13
#include "lldb/Symbol/CompileUnit.h"
14
#include "lldb/Symbol/LineEntry.h"
15
#include "lldb/Symbol/SymbolContext.h"
16
#include "lldb/Utility/ConstString.h"
17
#include "lldb/Utility/Log.h"
18
#include "lldb/Utility/Logging.h"
19
#include "lldb/Utility/Stream.h"
20
#include "lldb/Utility/StreamString.h"
21
#include "lldb/lldb-enumerations.h"
22
#include "lldb/lldb-types.h"
23
24
#include <cinttypes>
25
#include <vector>
26
27
using namespace lldb;
28
using namespace lldb_private;
29
30
// AddressResolverFileLine:
31
AddressResolverFileLine::AddressResolverFileLine(
32
    SourceLocationSpec location_spec)
33
1.29k
    : AddressResolver(), m_src_location_spec(location_spec) {}
34
35
1.29k
AddressResolverFileLine::~AddressResolverFileLine() = default;
36
37
Searcher::CallbackReturn
38
AddressResolverFileLine::SearchCallback(SearchFilter &filter,
39
204
                                        SymbolContext &context, Address *addr) {
40
204
  SymbolContextList sc_list;
41
204
  CompileUnit *cu = context.comp_unit;
42
43
204
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
44
45
  // TODO: Handle SourceLocationSpec column information
46
204
  cu->ResolveSymbolContext(m_src_location_spec, eSymbolContextEverything,
47
204
                           sc_list);
48
204
  uint32_t sc_list_size = sc_list.GetSize();
49
315
  for (uint32_t i = 0; i < sc_list_size; 
i++111
) {
50
111
    SymbolContext sc;
51
111
    if (sc_list.GetContextAtIndex(i, sc)) {
52
111
      Address line_start = sc.line_entry.range.GetBaseAddress();
53
111
      addr_t byte_size = sc.line_entry.range.GetByteSize();
54
111
      if (line_start.IsValid()) {
55
111
        AddressRange new_range(line_start, byte_size);
56
111
        m_address_ranges.push_back(new_range);
57
111
      } else {
58
0
        LLDB_LOGF(log,
59
0
                  "error: Unable to resolve address at file address 0x%" PRIx64
60
0
                  " for %s:%d\n",
61
0
                  line_start.GetFileAddress(),
62
0
                  m_src_location_spec.GetFileSpec().GetFilename().AsCString(
63
0
                      "<Unknown>"),
64
0
                  m_src_location_spec.GetLine().getValueOr(0));
65
0
      }
66
111
    }
67
111
  }
68
204
  return Searcher::eCallbackReturnContinue;
69
204
}
70
71
4.18k
lldb::SearchDepth AddressResolverFileLine::GetDepth() {
72
4.18k
  return lldb::eSearchDepthCompUnit;
73
4.18k
}
74
75
0
void AddressResolverFileLine::GetDescription(Stream *s) {
76
0
  s->Printf(
77
0
      "File and line address - file: \"%s\" line: %u",
78
0
      m_src_location_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"),
79
0
      m_src_location_spec.GetLine().getValueOr(0));
80
0
}