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

ArkScript-lang / Ark / 21043080682

15 Jan 2026 07:07PM UTC coverage: 91.835% (-0.9%) from 92.743%
21043080682

Pull #628

github

web-flow
Merge 453e86f68 into ada0e0686
Pull Request #628: Feat/debugger

131 of 242 new or added lines in 10 files covered. (54.13%)

2 existing lines in 1 file now uncovered.

8571 of 9333 relevant lines covered (91.84%)

276580.72 hits per line

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

0.0
/include/Ark/VM/Debugger.hpp
1
/**
2
 * @file Debugger.hpp
3
 * @author Lexy Plateau (lexplt.dev@gmail.com)
4
 * @brief Debugger used by the VM when an error or a breakpoint is reached
5
 * @date 2026-01-12
6
 *
7
 * @copyright Copyright (c) 2026-01-12
8
 *
9
 */
10

11
#ifndef ARK_VM_DEBUGGER_HPP
12
#define ARK_VM_DEBUGGER_HPP
13

14
#include <vector>
15
#include <memory>
16
#include <string>
17
#include <optional>
18
#include <filesystem>
19

20
#include <Ark/VM/Value/Value.hpp>
21
#include <Ark/VM/ExecutionContext.hpp>
22

23
namespace Ark
24
{
25
    class VM;
26
}
27

28
namespace Ark::internal
29
{
NEW
30
    struct SavedState
×
31
    {
32
        std::size_t ip;
33
        std::size_t pp;
34
        uint16_t sp;
35
        uint16_t fc;
36
        std::vector<ScopeView> locals;
37
        std::vector<std::shared_ptr<ClosureScope>> closure_scopes;
38
    };
39

NEW
40
    class Debugger
×
41
    {
42
    public:
43
        /**
44
         * @brief Create a new Debugger object
45
         *
46
         * @param context context from the VM before displaying a backtrace
47
         * @param libenv
48
         * @param symbols symbols table of the VM
49
         * @param constants constants table of the VM
50
         */
51
        explicit Debugger(const ExecutionContext& context, const std::vector<std::filesystem::path>& libenv, const std::vector<std::string>& symbols, const std::vector<Value>& constants);
52

53
        /**
54
         * @brief Save the current VM state, to get back to it once the debugger is done running
55
         *
56
         * @param context
57
         */
58
        void saveState(const ExecutionContext& context);
59

60
        /**
61
         * @brief Reset a VM context to the last state saved by the debugger
62
         *
63
         * @param context context to reset
64
         */
65
        void resetContextToErrorState(ExecutionContext& context);
66

67
        /**
68
         * @brief Start the debugger shell
69
         *
70
         * @param vm
71
         * @param context
72
         */
73
        void run(VM& vm, ExecutionContext& context);
74

NEW
75
        inline bool isRunning() const noexcept
×
NEW
76
        {
×
NEW
77
            return m_running;
×
78
        }
79

80
    private:
81
        std::vector<std::unique_ptr<SavedState>> m_states;
82
        std::vector<std::filesystem::path> m_libenv;
83
        std::vector<std::string> m_symbols;
84
        std::vector<Value> m_constants;
85
        bool m_running;
86

87
        std::string m_code;  ///< Code added while inside the debugger
88

89
        /**
90
         * @brief Take care of compiling new code using the existing data tables
91
         *
92
         * @param code
93
         * @param start_page_at_offset offset to start the new pages at
94
         * @return std::optional<std::vector<bytecode_t>> optional set of bytecode pages if compilation succeeded
95
         */
96
        std::optional<std::vector<bytecode_t>> compile(const std::string& code, std::size_t start_page_at_offset);
97
    };
98
}
99

100
#endif  // ARK_VM_DEBUGGER_HPP
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