File: idebugsession.h

package info (click to toggle)
kdevelop 4%3A22.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 70,096 kB
  • sloc: cpp: 284,635; javascript: 3,558; python: 3,422; sh: 1,319; ansic: 685; xml: 331; php: 95; lisp: 66; makefile: 39; sed: 12
file content (186 lines) | stat: -rw-r--r-- 5,899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
    SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef KDEVPLATFORM_IDEBUGSESSION_H
#define KDEVPLATFORM_IDEBUGSESSION_H

#include <debugger/debuggerexport.h>

#include <QObject>
#include <QUrl>

namespace KDevelop {

class IVariableController;
class IBreakpointController;
class IFrameStackModel;
class Breakpoint;
class StackModel;
class IDebugSessionPrivate;

class KDEVPLATFORMDEBUGGER_EXPORT IDebugSession : public QObject
{
    Q_OBJECT
public:
    IDebugSession(QObject* parent = nullptr);
    ~IDebugSession() override;

    enum DebuggerState {
        NotStartedState,
        StartingState,
        ActiveState,
        PausedState,
        StoppingState,
        StoppedState,
        EndedState
    };
    Q_ENUM(DebuggerState)

    enum event_t {
        program_state_changed = 1,
        program_exited,
        debugger_exited,
        // Emitted when the thread or frame that is selected in UI
        // changes.
        thread_or_frame_changed,
        debugger_busy,
        debugger_ready,
        // Raised when debugger believe that program start running.
        // Can be used to hide current line indicator.
        // Don't count on this being raise in all cases where
        // program is running.
        program_running,
        // Raise when the debugger is in touch with the program,
        // and should have access to its debug symbols. The program
        // is not necessary running yet, or might already exited,
        // or be otherwise dead.
        connected_to_program
    };

public:
    /**
     * Current state of the debug session
     */
    virtual DebuggerState state() const = 0;

    /**
     * Should return if restart is currently available
     */
    virtual bool restartAvaliable() const = 0;

    /**
     * Returns if the debugee is currently running. This includes paused.
     */
    bool isRunning() const;
    
    /**
     * Returns the local Url for a source file used in the current debug session.
     *
     * The default implementation just returns the url and is sufficient for
     * local debuggers. Remote debuggers can implement a path mapping mechanism.
     */
    virtual QPair<QUrl, int> convertToLocalUrl(const QPair<QUrl, int> &remoteUrl) const;

    /**
     * Returns the remote Url for a source file used in the current debug session.
     *
     * The default implementation just returns the url and is sufficient for
     * local debuggers. Remote debuggers can implement a path mapping mechanism.
     */
    virtual QPair<QUrl, int> convertToRemoteUrl(const QPair<QUrl, int> &localUrl) const;

    /**
     * @return the breakpoint controller of this session
     *
     * @note Implementations must ensure that a breakpoint controller always exists (even if it
     * is a dummy stub implementation that does nothing), and that it does not change during
     * the lifetime of a session.
     */
    virtual IBreakpointController* breakpointController() const = 0;

    /**
     * @return the variable controller of this session
     *
     * @note Implementations must ensure that a variable controller always exists (even if it
     * is a dummy stub implementation that does nothing), and that it does not change during
     * the lifetime of a session.
     */
    virtual IVariableController* variableController() const = 0;

    /**
     * @return the frame stack model of this session
     *
     * @note Implementations must ensure that a frame stack model always exists (even if it
     * is a dummy stub implementation that does nothing), and that it does not change during
     * the lifetime of a session.
     */
    virtual IFrameStackModel* frameStackModel() const = 0;

public Q_SLOTS:
    virtual void restartDebugger() = 0;
    virtual void stopDebugger() = 0;
    /// @brief Kills the debugger process synchronously if it is still running.
    virtual void killDebuggerNow() = 0;
    virtual void interruptDebugger() = 0;
    virtual void run() = 0;
    virtual void runToCursor() = 0;
    virtual void jumpToCursor() = 0;
    virtual void stepOver() = 0;
    virtual void stepIntoInstruction() = 0;
    virtual void stepInto() = 0;
    virtual void stepOverInstruction() = 0;
    virtual void stepOut() = 0;

Q_SIGNALS:
    void stateChanged(KDevelop::IDebugSession::DebuggerState state);
    void showStepInSource(const QUrl& file, int line, const QString &addr);
    void showStepInDisassemble(const QString &addr);
    void clearExecutionPoint();
    void finished();

    void raiseFramestackViews();

    /** This signal is emitted whenever the given event in a program
        happens. See DESIGN.txt for expected handled of each event.

        NOTE: this signal should never be emitted directly. Instead,
        use raiseEvent.
    */
    void event(IDebugSession::event_t e);

public:
    using QObject::event; // prevent hiding of base method.

    QUrl currentUrl() const;
    int currentLine() const;
    QString currentAddr() const;
    
protected:

    // Clear the position before running code
    void clearCurrentPosition();
    /// Sets new position and emits showStepInSource or showStepInDisassemble (if source file is unavailable) signal
    void setCurrentPosition(const QUrl& url, int line, const QString& addr);

    /** Raises the specified event. Should be used instead of
        emitting 'event' directly, since this method can perform
        additional book-keeping for events.
        FIXME: it might make sense to automatically route
        events to all debugger components, as opposed to requiring
        that they connect to any signal.
    */
    virtual void raiseEvent(event_t e);
    friend class FrameStackModel;

private:
    friend class IDebugSessionPrivate;
    const QScopedPointer<class IDebugSessionPrivate> d_ptr;
    Q_DECLARE_PRIVATE(IDebugSession)
};

}

#endif