~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to debuggers/gdb/gdb.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Low level GDB interface.
 
3
 *
 
4
 * Copyright 2007 Vladimir Prus <ghost@cs.msu.su>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as
 
8
 * published by the Free Software Foundation; either version 2 of the
 
9
 * License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public
 
17
 * License along with this program; if not, write to the
 
18
 * Free Software Foundation, Inc.,
 
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef GDB_H_d5c9cb274cbad688fe7a507a84f6633b
 
23
#define GDB_H_d5c9cb274cbad688fe7a507a84f6633b
 
24
 
 
25
#include "mi/gdbmi.h"
 
26
#include "mi/miparser.h"
 
27
#include "gdbcommand.h"
 
28
 
 
29
#include <KProcess>
 
30
 
 
31
#include <QObject>
 
32
#include <QByteArray>
 
33
 
 
34
class KConfigGroup;
 
35
 
 
36
namespace GDBDebugger
 
37
{
 
38
 
 
39
class GDB : public QObject
 
40
{
 
41
    Q_OBJECT
 
42
public:
 
43
    GDB();
 
44
 
 
45
    /** Starts GDB.  This should be done after connecting to all
 
46
        signals the client is interested in.  */
 
47
    void start(KConfigGroup& config);
 
48
 
 
49
    /** Executes a command.  This method may be called at
 
50
        most once each time 'ready' is emitted.  When the
 
51
        GDB instance is just constructed, one should wait
 
52
        for 'ready' as well.  
 
53
 
 
54
        The ownership of 'command' is transferred to GDB.  */
 
55
    void execute(GDBCommand* command);
 
56
 
 
57
    /** Returns true if 'execute' can be called immediately.  */
 
58
    bool isReady() const;
 
59
 
 
60
    /** FIXME: temporary, to be eliminated.  */
 
61
    GDBCommand* currentCommand() const;
 
62
    
 
63
    /** Arrange to gdb to stop doing whatever it's doing,
 
64
        and start waiting for a command.  
 
65
        FIXME: probably should make sure that 'ready' is
 
66
        emitted, or something.  */
 
67
    void interrupt();
 
68
 
 
69
    /** Kills GDB.  */
 
70
    void kill();
 
71
 
 
72
Q_SIGNALS:
 
73
    /** Emitted when debugger becomes ready -- i.e. when
 
74
        isReady call will return true.  */
 
75
    void ready();
 
76
 
 
77
    /** Emitted when GDB itself exits.  This could happen because
 
78
        it just crashed due to internal bug, or we killed it
 
79
        explicitly.  */
 
80
    void gdbExited();
 
81
 
 
82
    /** Emitted when GDB reports stop, with 'r' being the
 
83
        data provided by GDB. */
 
84
    void programStopped(const GDBMI::ResultRecord& r);
 
85
    
 
86
    /** Emitted when GDB believes that the program is running.  */
 
87
    void programRunning();
 
88
 
 
89
    /** Emitted for each MI stream record found.  Presently only
 
90
     used to recognize some CLI messages that mean that the program
 
91
    has died. 
 
92
    FIXME: connect to parseCliLine
 
93
    */
 
94
    void streamRecord(const GDBMI::StreamRecord& s);
 
95
 
 
96
    /** FIXME: temporary, to be eliminated.  */
 
97
    void resultRecord(const GDBMI::ResultRecord& s);
 
98
    
 
99
    /** Reports a general MI notification.  */
 
100
    void notification(const GDBMI::ResultRecord& n);
 
101
    
 
102
    /** Emitted for error that is not handled by the
 
103
        command being executed. */
 
104
    void error(const GDBMI::ResultRecord& s);
 
105
 
 
106
    /** Reports output from the running application.
 
107
        Generally output will only be available when
 
108
        using remote GDB targets. When running locally,
 
109
        the output will either appear on GDB stdout, and
 
110
        ignored, or routed via pty.  */
 
111
    void applicationOutput(const QString& s);
 
112
 
 
113
    /** Reports output of a command explicitly typed by
 
114
        the user, or output from .gdbinit commands.  */
 
115
    void userCommandOutput(const QString& s);
 
116
 
 
117
    /** Reports output of a command issued internally
 
118
        by KDevelop.  At the moment, stderr output from
 
119
        GDB and the 'log' MI channel will be also routed here.  */
 
120
    void internalCommandOutput(const QString& s);
 
121
 
 
122
private Q_SLOTS:
 
123
    void readyReadStandardOutput();
 
124
    void readyReadStandardError();
 
125
    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
 
126
    void processErrored(QProcess::ProcessError);
 
127
 
 
128
private:
 
129
    void processLine(const QByteArray& line);
 
130
 
 
131
private:
 
132
    QString gdbBinary_;
 
133
    KProcess* process_;
 
134
    bool sawPrompt_;
 
135
 
 
136
    GDBCommand* currentCmd_;
 
137
 
 
138
    MIParser mi_parser_;
 
139
 
 
140
    /** The unprocessed output from gdb. Output is
 
141
        processed as soon as we see newline. */
 
142
    QByteArray buffer_;
 
143
};
 
144
}
 
145
 
 
146
#endif