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

daisytuner / sdfglib / 17316805645

29 Aug 2025 06:46AM UTC coverage: 60.01% (+0.2%) from 59.781%
17316805645

Pull #210

github

web-flow
Merge cd9cb386d into 18d34db1e
Pull Request #210: New debug info

351 of 562 new or added lines in 37 files covered. (62.46%)

15 existing lines in 8 files now uncovered.

9574 of 15954 relevant lines covered (60.01%)

115.01 hits per line

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

85.34
/src/debug_info.cpp
1
#include "sdfg/debug_info.h"
2

3
#include <cstddef>
4
#include <string>
5
#include <vector>
6
#include "sdfg/exceptions.h"
7

8
namespace sdfg {
9

10
/***** DebugInfoElement *****/
11

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

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

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

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

35
const std::vector<DebugLoc>& DebugInfoElement::locations() const { return this->locations_; }
121✔
36

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

39
std::string DebugInfoElement::filename() const { return this->locations_.front().filename_; };
1✔
40

41
std::string DebugInfoElement::function() const { return this->locations_.front().function_; };
1✔
42

43
size_t DebugInfoElement::line() const { return this->locations_.front().line_; };
1✔
44

45
size_t DebugInfoElement::column() const { return this->locations_.front().column_; };
1✔
46

47

48
/***** DebugInfoRegion *****/
49

50
DebugInfoRegion::DebugInfoRegion()
2,900✔
51
    : indices_(), filename_(""), function_(""), start_line_(0), start_column_(0), end_line_(0), end_column_(0) {
2,900✔
52
    this->has_ = false;
2,900✔
53
};
2,900✔
54

55
DebugInfoRegion::DebugInfoRegion(std::unordered_set<size_t> indices, const std::vector<DebugInfoElement>& all_instructions)
342✔
56
    : indices_(indices) {
171✔
57
    if (this->indices_.empty()) {
171✔
58
        this->has_ = false;
136✔
59
        return;
136✔
60
    }
61

62
    if (all_instructions.empty()) {
35✔
NEW
63
        this->has_ = false;
×
NEW
64
        return;
×
65
    }
66

67
    // filter instructions
68
    std::vector<DebugInfoElement> instructions;
35✔
69
    for (auto index : this->indices_) {
81✔
70
        if (index < all_instructions.size()) {
46✔
71
            auto instruction = all_instructions[index];
46✔
72
            if (instruction.has()) {
46✔
73
                instructions.push_back(instruction);
46✔
74
            }
46✔
75
        }
46✔
76
    }
77

78
    if (instructions.empty()) {
35✔
NEW
79
        this->has_ = false;
×
NEW
80
        return;
×
81
    }
82

83
    // find locations
84
    std::string filename;
35✔
85
    std::string function;
35✔
86
    size_t start_line;
87
    size_t start_column;
88
    size_t end_line;
89
    size_t end_column;
90

91

92
    bool found = false;
35✔
93
    for (auto& loc : instructions.front().locations()) {
37✔
94
        filename = loc.filename_;
37✔
95
        function = loc.function_;
37✔
96
        start_line = loc.line_;
37✔
97
        start_column = loc.column_;
37✔
98
        end_line = loc.line_;
37✔
99
        end_column = loc.column_;
37✔
100
        int fitting = 0;
37✔
101
        for (const auto& instruction : instructions) {
85✔
102
            found = false;
50✔
103
            for (const auto& inlined_loc : instruction.locations()) {
55✔
104
                if (fuse_ranges(inlined_loc, filename, function, start_line, start_column, end_line, end_column)) {
53✔
105
                    found = true;
48✔
106
                    break;
48✔
107
                }
108
            }
109
            if (!found) {
50✔
110
                // If no ranges were fused, we can break early
111
                break;
2✔
112
            }
113
            fitting++;
48✔
114
        }
115
        if (fitting == instructions.size()) {
37✔
116
            found = true;
35✔
117
            break; // All instructions fit the same file and function
35✔
118
        }
119
    }
120
    if (!found) {
35✔
NEW
121
        throw InvalidSDFGException("No valid debug locations found in DebugInfo");
×
122
    }
123

124
    this->filename_ = filename;
35✔
125
    this->function_ = function;
35✔
126
    this->start_line_ = start_line;
35✔
127
    this->start_column_ = start_column;
35✔
128
    this->end_line_ = end_line;
35✔
129
    this->end_column_ = end_column;
35✔
130
    this->has_ = true;
35✔
131
};
171✔
132

133
bool DebugInfoRegion::fuse_ranges(
53✔
134
    const DebugLoc& loc,
135
    std::string& filename,
136
    std::string& function,
137
    size_t& line_start,
138
    size_t& col_start,
139
    size_t& line_end,
140
    size_t& col_end
141
) {
142
    if (loc.filename_ == filename && loc.function_ == function) {
53✔
143
        if (line_start == loc.line_) {
48✔
144
            col_start = std::min(col_start, loc.column_);
40✔
145
        } else if (line_start > loc.line_) {
48✔
146
            col_start = loc.column_;
4✔
147
        }
4✔
148
        line_start = std::min(line_start, loc.line_);
48✔
149

150
        if (line_end == loc.line_) {
48✔
151
            col_end = std::max(col_end, loc.column_);
40✔
152
        } else if (line_end < loc.line_) {
48✔
153
            col_end = loc.column_;
4✔
154
        }
4✔
155
        line_end = std::max(line_end, loc.line_);
48✔
156
        return true; // Same file and function, ranges fused
48✔
157
    }
158
    return false; // Different file or function, ranges not fused
5✔
159
}
53✔
160

161
std::unordered_set<size_t> DebugInfoRegion::indices() const { return this->indices_; }
117✔
162

163
DebugInfoRegion DebugInfoRegion::merge(
26✔
164
    const DebugInfoRegion& first, const DebugInfoRegion& second, const std::vector<DebugInfoElement>& all_instructions
165
) {
166
    // Merge the two regions by combining their indices
167
    std::unordered_set<size_t> merged_indices = first.indices_;
26✔
168
    merged_indices.insert(second.indices_.begin(), second.indices_.end());
26✔
169

170
    // Create a new region with the merged indices
171
    return DebugInfoRegion(merged_indices, all_instructions);
26✔
172
}
26✔
173

174
bool DebugInfoRegion::has() const { return this->has_; }
127✔
175

176
std::string DebugInfoRegion::filename() const { return this->filename_; }
129✔
177

178
std::string DebugInfoRegion::function() const { return this->function_; }
128✔
179

180
size_t DebugInfoRegion::start_line() const { return this->start_line_; }
129✔
181
size_t DebugInfoRegion::start_column() const { return this->start_column_; }
129✔
182
size_t DebugInfoRegion::end_line() const { return this->end_line_; }
129✔
183
size_t DebugInfoRegion::end_column() const { return this->end_column_; }
129✔
184

185
/***** DebugInfo *****/
186

187
const std::vector<DebugInfoElement>& DebugInfo::instructions() const { return this->instructions_; };
200✔
188

189
size_t DebugInfo::add_element(DebugInfoElement loc) {
22✔
190
    this->instructions_.push_back(loc);
22✔
191
    return this->instructions_.size() - 1;
22✔
192
};
193

NEW
194
DebugInfoRegion DebugInfo::get_region(std::unordered_set<size_t> indices) const {
×
NEW
195
    return DebugInfoRegion(indices, this->instructions_);
×
NEW
196
};
×
197

198
} // 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