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

Alan-Jowett / ebpf-verifier / 15194704016

22 May 2025 08:53AM UTC coverage: 88.11% (-0.07%) from 88.177%
15194704016

push

github

elazarg
uniform class names and explicit constructors for adapt_sgraph.hpp

Signed-off-by: Elazar Gershuni <elazarg@gmail.com>

27 of 30 new or added lines in 1 file covered. (90.0%)

481 existing lines in 33 files now uncovered.

8552 of 9706 relevant lines covered (88.11%)

9089054.61 hits per line

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

81.25
/src/program.hpp
1
// Copyright (c) Prevail Verifier contributors.
2
// SPDX-License-Identifier: MIT
3
#pragma once
4

5
#include <map>
6
#include <vector>
7

8
#include "asm_syntax.hpp"
9
#include "cfg/cfg.hpp"
10
#include "cfg/label.hpp"
11
#include "config.hpp"
12
#include "crab_utils/debug.hpp"
13

14
namespace prevail {
15
class Program {
16
    friend struct CfgBuilder;
17

18
    std::map<Label, Instruction> m_instructions{{Label::entry, Undefined{}}, {Label::exit, Undefined{}}};
19

20
    // This is a cache. The assertions can also be computed on the fly.
21
    std::map<Label, std::vector<Assertion>> m_assertions{{Label::entry, {}}, {Label::exit, {}}};
22
    Cfg m_cfg;
23

24
    // TODO: add ProgramInfo field
25

26
  public:
27
    const Cfg& cfg() const { return m_cfg; }
322,096✔
28

29
    //! return a view of the labels, including entry and exit
30
    [[nodiscard]]
31
    auto labels() const {
2,502✔
32
        return m_cfg.labels();
2,502✔
33
    }
34

35
    const Instruction& instruction_at(const Label& label) const {
346,518✔
36
        if (!m_instructions.contains(label)) {
346,518✔
UNCOV
37
            CRAB_ERROR("Label ", to_string(label), " not found in the CFG: ");
×
38
        }
39
        return m_instructions.at(label);
346,518✔
40
    }
41

42
    Instruction& instruction_at(const Label& label) {
342,254✔
43
        if (!m_instructions.contains(label)) {
342,254✔
UNCOV
44
            CRAB_ERROR("Label ", to_string(label), " not found in the CFG: ");
×
45
        }
46
        return m_instructions.at(label);
342,254✔
47
    }
48

49
    std::vector<Assertion> assertions_at(const Label& label) const {
174,240✔
50
        if (!m_assertions.contains(label)) {
174,240✔
UNCOV
51
            CRAB_ERROR("Label ", to_string(label), " not found in the CFG: ");
×
52
        }
53
        return m_assertions.at(label);
174,240✔
54
    }
55

56
    static Program from_sequence(const InstructionSeq& inst_seq, const ProgramInfo& info,
57
                                 const ebpf_verifier_options_t& options);
58
};
59

60
class InvalidControlFlow final : public std::runtime_error {
61
  public:
62
    explicit InvalidControlFlow(const std::string& what) : std::runtime_error(what) {}
8✔
63
};
64

65
std::vector<Assertion> get_assertions(Instruction ins, const ProgramInfo& info, const std::optional<Label>& label);
66

67
std::vector<std::string> stats_headers();
68
std::map<std::string, int> collect_stats(const Program& prog);
69

70
using printfunc = std::function<void(std::ostream&, const Label& label)>;
71
void print_program(const Program& prog, std::ostream& os, bool simplify, const printfunc& prefunc,
72
                   const printfunc& postfunc);
73
void print_program(const Program& prog, std::ostream& os, bool simplify);
74
void print_dot(const Program& prog, const std::string& outfile);
75
} // namespace prevail
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