• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 17264921398

27 Aug 2025 11:05AM UTC coverage: 60.053% (+0.3%) from 59.755%
17264921398

Pull #210

github

web-flow
Merge ff8271e01 into 12d242c5d
Pull Request #210: New debug info

174 of 212 new or added lines in 3 files covered. (82.08%)

1 existing line in 1 file now uncovered.

9501 of 15821 relevant lines covered (60.05%)

115.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.86
/src/element.cpp
1
#include "sdfg/element.h"
2
#include <string>
3
#include <vector>
4
#include "sdfg/exceptions.h"
5

6
namespace sdfg {
7

NEW
8
DebugInfoElement::DebugInfoElement() { this->locations_ = {DebugLoc("", "", 0, 0, false)}; };
×
9

10
DebugInfoElement::DebugInfoElement(DebugLoc loc) : locations_({loc}) {};
14✔
11

NEW
12
DebugInfoElement::DebugInfoElement(DebugLoc loc, std::vector<DebugLoc> inlined_at) : locations_({loc}) {
×
NEW
13
    for (auto& debug_loc : inlined_at) {
×
NEW
14
        if (debug_loc.has_) {
×
NEW
15
            this->locations_.push_back(debug_loc);
×
NEW
16
        }
×
17
    }
NEW
18
};
×
19

20
DebugInfoElement::DebugInfoElement(std::vector<DebugLoc> inlined_at) {
10✔
21
    for (auto& loc : inlined_at) {
29✔
22
        if (loc.has_) {
19✔
23
            this->locations_.push_back(loc);
19✔
24
        }
19✔
25
    }
26
    if (this->locations_.empty()) {
10✔
NEW
27
        this->locations_.push_back(DebugLoc("", "", 0, 0, false));
×
NEW
28
    }
×
29
}
10✔
30

31
const std::vector<DebugLoc>& DebugInfoElement::locations() const { return this->locations_; }
96✔
32

33
bool DebugInfoElement::has() const { return this->locations_.front().has_; };
53✔
34

35
std::string DebugInfoElement::filename() const { return this->locations_.front().filename_; };
15✔
36

37
std::string DebugInfoElement::function() const { return this->locations_.front().function_; };
15✔
38

39
size_t DebugInfoElement::line() const { return this->locations_.front().line_; };
29✔
40

41
size_t DebugInfoElement::column() const { return this->locations_.front().column_; };
29✔
42

43
DebugInfo::DebugInfo()
3,021✔
44
    : instructions_(), filename_(""), function_(""), start_line_(0), start_column_(0), end_line_(0), end_column_(0),
3,021✔
45
      has_(false) {};
3,021✔
46

47
DebugInfo::DebugInfo(DebugInfoElement loc) {
14✔
48
    if (loc.has()) {
14✔
49
        this->instructions_.push_back(loc);
14✔
50
        this->filename_ = loc.filename();
14✔
51
        this->function_ = loc.function();
14✔
52
        this->start_line_ = loc.line();
14✔
53
        this->start_column_ = loc.column();
14✔
54
        this->end_line_ = loc.line();
14✔
55
        this->end_column_ = loc.column();
14✔
56
        this->has_ = true;
14✔
57
        instructions_.push_back(std::move(loc));
14✔
58
    } else {
14✔
NEW
59
        this->has_ = false;
×
60
    }
61
};
14✔
62

63
bool DebugInfo::has() const { return has_; }
198✔
64

65
std::string DebugInfo::filename() const { return filename_; }
129✔
66

67
std::string DebugInfo::function() const { return function_; }
128✔
68

69
size_t DebugInfo::start_line() const { return start_line_; }
129✔
70

71
size_t DebugInfo::start_column() const { return start_column_; }
129✔
72

73
size_t DebugInfo::end_line() const { return end_line_; }
129✔
74

75
size_t DebugInfo::end_column() const { return end_column_; }
129✔
76

77
const std::vector<DebugInfoElement>& DebugInfo::instructions() const { return this->instructions_; };
198✔
78

79
bool fuse_ranges(
36✔
80
    const DebugLoc& loc,
81
    std::string& filename,
82
    std::string& function,
83
    size_t& line_start,
84
    size_t& col_start,
85
    size_t& line_end,
86
    size_t& col_end
87
) {
88
    if (loc.filename_ == filename && loc.function_ == function) {
36✔
89
        if (line_start == loc.line_) {
30✔
90
            col_start = std::min(col_start, loc.column_);
22✔
91
        } else if (line_start > loc.line_) {
30✔
92
            col_start = loc.column_;
2✔
93
        }
2✔
94
        line_start = std::min(line_start, loc.line_);
30✔
95

96
        if (line_end == loc.line_) {
30✔
97
            col_end = std::max(col_end, loc.column_);
22✔
98
        } else if (line_end < loc.line_) {
30✔
99
            col_end = loc.column_;
4✔
100
        }
4✔
101
        line_end = std::max(line_end, loc.line_);
30✔
102
        return true; // Same file and function, ranges fused
30✔
103
    }
104
    return false; // Different file or function, ranges not fused
6✔
105
}
36✔
106

107
DebugInfo::DebugInfo(std::vector<DebugInfoElement> instructions) {
18✔
108
    if (instructions.empty()) {
18✔
109
        this->has_ = false;
9✔
110
        return;
9✔
111
    }
112

113
    this->has_ = false;
9✔
114
    for (const auto& instruction : instructions) {
37✔
115
        if (instruction.has()) {
28✔
116
            this->has_ = true;
28✔
117
            this->instructions_.push_back(instruction);
28✔
118
        }
28✔
119
    }
120

121
    if (!this->has_) {
9✔
NEW
122
        return; // No valid instructions found
×
123
    }
124

125
    // find locations
126
    std::string filename;
9✔
127
    std::string function;
9✔
128
    size_t start_line;
129
    size_t start_column;
130
    size_t end_line;
131
    size_t end_column;
132

133

134
    bool found = false;
9✔
135
    for (auto& loc : this->instructions_.front().locations()) {
11✔
136
        filename = loc.filename_;
11✔
137
        function = loc.function_;
11✔
138
        start_line = loc.line_;
11✔
139
        start_column = loc.column_;
11✔
140
        end_line = loc.line_;
11✔
141
        end_column = loc.column_;
11✔
142
        int fitting = 0;
11✔
143
        for (const auto& instruction : this->instructions_) {
41✔
144
            found = false;
32✔
145
            for (const auto& inlined_loc : instruction.locations()) {
38✔
146
                if (fuse_ranges(inlined_loc, filename, function, start_line, start_column, end_line, end_column)) {
36✔
147
                    found = true;
30✔
148
                    break;
30✔
149
                }
150
            }
151
            if (!found) {
32✔
152
                // If no ranges were fused, we can break early
153
                break;
2✔
154
            }
155
            fitting++;
30✔
156
        }
157
        if (fitting == this->instructions_.size()) {
11✔
158
            found = true;
9✔
159
            break; // All instructions fit the same file and function
9✔
160
        }
161
    }
162
    if (!found) {
9✔
NEW
163
        throw InvalidSDFGException("No valid debug locations found in DebugInfo");
×
164
    }
165

166
    this->filename_ = filename;
9✔
167
    this->function_ = function;
9✔
168
    this->start_line_ = start_line;
9✔
169
    this->start_column_ = start_column;
9✔
170
    this->end_line_ = end_line;
9✔
171
    this->end_column_ = end_column;
9✔
172
};
18✔
173

174
DebugInfo DebugInfo::merge(const DebugInfo& left, const DebugInfo& right) {
26✔
175
    if (left.has() && !right.has()) {
26✔
176
        return left; // If left has debug info, return it
7✔
177
    }
178
    if (!left.has() && right.has()) {
19✔
179
        return right; // If right has debug info, return it
5✔
180
    }
181

182
    auto list = left.instructions();
14✔
183
    list.insert(list.end(), right.instructions().begin(), right.instructions().end());
14✔
184
    return DebugInfo(list);
14✔
185
};
26✔
186

NEW
187
void DebugInfo::append(DebugInfoElement& other) {
×
NEW
188
    if (!other.has()) {
×
NEW
189
        return;
×
190
    }
191

NEW
192
    if (!this->has_) {
×
NEW
193
        this->instructions_.push_back(other);
×
NEW
194
        this->filename_ = other.filename();
×
NEW
195
        this->function_ = other.function();
×
NEW
196
        this->start_line_ = other.line();
×
NEW
197
        this->start_column_ = other.column();
×
NEW
198
        this->end_line_ = other.line();
×
NEW
199
        this->end_column_ = other.column();
×
NEW
200
        this->has_ = true;
×
NEW
201
        return;
×
202
    }
203

NEW
204
    this->instructions_.push_back(other);
×
205

NEW
206
    DebugInfo debug_info(this->instructions_);
×
207

NEW
208
    this->filename_ = debug_info.filename();
×
NEW
209
    this->function_ = debug_info.function();
×
NEW
210
    this->start_line_ = debug_info.start_line();
×
NEW
211
    this->start_column_ = debug_info.start_column();
×
NEW
212
    this->end_line_ = debug_info.end_line();
×
NEW
213
    this->end_column_ = debug_info.end_column();
×
NEW
214
    this->has_ = true;
×
UNCOV
215
};
×
216

217
Element::Element(size_t element_id, const DebugInfo& debug_info) : element_id_(element_id), debug_info_(debug_info) {};
4,378✔
218

219
size_t Element::element_id() const { return this->element_id_; };
2,077✔
220

221
const DebugInfo& Element::debug_info() const { return this->debug_info_; };
369✔
222

223
void Element::set_debug_info(const DebugInfo& debug_info) { this->debug_info_ = debug_info; }
4✔
224

225
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc