File: mibreakpointcontroller.h

package info (click to toggle)
kdevelop 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 73,508 kB
  • sloc: cpp: 291,803; python: 4,322; javascript: 3,518; sh: 1,316; ansic: 703; xml: 414; php: 95; lisp: 66; makefile: 31; sed: 12
file content (106 lines) | stat: -rw-r--r-- 3,079 bytes parent folder | download | duplicates (2)
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
/*
    SPDX-FileCopyrightText: 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
    SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org>
    SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org>
    SPDX-FileCopyrightText: 2009 Niko Sams <niko.sams@gmail.com>

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

#ifndef MIBREAKPOINTCONTROLLER_H
#define MIBREAKPOINTCONTROLLER_H

#include "dbgglobal.h"

#include <debugger/interfaces/ibreakpointcontroller.h>
#include <debugger/interfaces/idebugsession.h>

namespace KDevMI {

namespace MI {
struct AsyncRecord;
struct ResultRecord;
struct Value;
}

struct BreakpointData {
    int debuggerId = -1;
    KDevelop::BreakpointModel::ColumnFlags dirty;
    KDevelop::BreakpointModel::ColumnFlags sent;
    KDevelop::BreakpointModel::ColumnFlags errors;
    bool pending = false;

    BreakpointData()
    {}
};

using BreakpointDataPtr = QSharedPointer<BreakpointData>;

class MIDebugSession;
/**
* Handles signals from the editor that relate to breakpoints and the execution
* point of the debugger.
* We may change, add or remove breakpoints in this class.
*/
class MIBreakpointController : public KDevelop::IBreakpointController
{
    Q_OBJECT
public:
    explicit MIBreakpointController(MIDebugSession* parent);

    using IBreakpointController::breakpointModel;

    /**
     * Controls whether when duplicate breakpoints are received via async notification from GDB,
     * one of the duplicates will be deleted.
     */
    void setDeleteDuplicateBreakpoints(bool enable);

    void breakpointAdded(int row) override;
    void breakpointModelChanged(int row, KDevelop::BreakpointModel::ColumnFlags columns) override;
    void breakpointAboutToBeDeleted(int row) override;
    void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState) override;

    void notifyBreakpointCreated(const MI::AsyncRecord& r);
    void notifyBreakpointModified(const MI::AsyncRecord& r);
    void notifyBreakpointDeleted(const MI::AsyncRecord& r);

public Q_SLOTS:
    void initSendBreakpoints();

private Q_SLOTS:
    void programStopped(const MI::AsyncRecord &r);

private:
    virtual QLatin1String pendingBreakpointAddress() const = 0;

    MIDebugSession* debugSession() const;

    int breakpointRow(const BreakpointDataPtr& breakpoint);
    void createBreakpoint(int row);
    void sendUpdates(int row);
    void recalculateState(int row);

    void sendMaybe(KDevelop::Breakpoint *breakpoint) override;

    void createFromDebugger(const MI::Value& miBkpt);
    void updateFromDebugger(int row, const MI::Value& miBkpt,
                            KDevelop::BreakpointModel::ColumnFlags lockedColumns = {});

    int rowFromDebuggerId(int gdbId) const;

    struct Handler;
    struct InsertedHandler;
    struct UpdateHandler;
    struct DeleteHandler;
    struct IgnoreChanges;

    QList<BreakpointDataPtr> m_breakpoints;
    QList<BreakpointDataPtr> m_pendingDeleted;
    int m_ignoreChanges = 0;
    bool m_deleteDuplicateBreakpoints = false;
};

} // end of namespace KDevMI

#endif // MIBREAKPOINTCONTROLLER_H