~ubuntu-branches/ubuntu/karmic/kdevelop/karmic

« back to all changes in this revision

Viewing changes to debuggers/gdb/gdb.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-05-25 19:34:26 UTC
  • mfrom: (1.1.11 upstream) (2.3.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090525193426-hdntv90rvflyew8g
Tags: 4:3.9.93-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - Conflict/replace -kde4 packages

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
namespace GDBDebugger
 
35
{
 
36
 
 
37
class GDB : public QObject
 
38
{
 
39
    Q_OBJECT
 
40
public:
 
41
    GDB();
 
42
 
 
43
    /** Starts GDB.  This should be done after connecting to all
 
44
        signals the client is interested in.  */
 
45
    void start();
 
46
 
 
47
    /** Executes a command.  This method may be called at
 
48
        most once each time 'ready' is emitted.  When the
 
49
        GDB instance is just constructed, one should wait
 
50
        for 'ready' as well.  
 
51
 
 
52
        The ownership of 'command' is transferred to GDB.  */
 
53
    void execute(GDBCommand* command);
 
54
 
 
55
    /** Returns true if 'execute' can be called immediately.  */
 
56
    bool isReady() const;
 
57
 
 
58
    /** FIXME: temporary, to be eliminated.  */
 
59
    GDBCommand* currentCommand() const;
 
60
    
 
61
    /** Arrange to gdb to stop doing whatever it's doing,
 
62
        and start waiting for a command.  
 
63
        FIXME: probably should make sure that 'ready' is
 
64
        emitted, or something.  */
 
65
    void interrupt();
 
66
 
 
67
    /** Kills GDB.  */
 
68
    void kill();
 
69
 
 
70
Q_SIGNALS:
 
71
    /** Emitted when debugger becomes ready -- i.e. when
 
72
        isReady call will return true.  */
 
73
    void ready();
 
74
 
 
75
    /** Emitted when GDB itself exits.  This could happen because
 
76
        it just crashed due to internal bug, or we killed it
 
77
        explicitly.  */
 
78
    void gdbExited();
 
79
 
 
80
    /** Emitted when GDB reports stop, with 'r' being the
 
81
        data provided by GDB. */
 
82
    void programStopped(const GDBMI::ResultRecord& r);
 
83
    
 
84
    /** Emitted when GDB believes that the program is running.  */
 
85
    void programRunning();
 
86
 
 
87
    /** Emitted for each MI stream record found.  Presently only
 
88
     used to recognize some CLI messages that mean that the program
 
89
    has died. 
 
90
    FIXME: connect to parseCliLine
 
91
    */
 
92
    void streamRecord(const GDBMI::StreamRecord& s);
 
93
 
 
94
    /** FIXME: temporary, to be eliminated.  */
 
95
    void resultRecord(const GDBMI::ResultRecord& s);
 
96
    
 
97
    /** Emitted for error that is not handled by the
 
98
        command being executed. */
 
99
    void error(const GDBMI::ResultRecord& s);
 
100
 
 
101
    /** Reports output from the running application.
 
102
        Generally output will only be available when
 
103
        using remote GDB targets. When running locally,
 
104
        the output will either appear on GDB stdout, and
 
105
        ignored, or routed via pty.  */
 
106
    void applicationOutput(const QString& s);
 
107
 
 
108
    /** Reports output of a command explicitly typed by
 
109
        the user, or output from .gdbinit commands.  */
 
110
    void userCommandOutput(const QString& s);
 
111
 
 
112
    /** Reports output of a command issued internally
 
113
        by KDevelop.  At the moment, stderr output from
 
114
        GDB and the 'log' MI channel will be also routed here.  */
 
115
    void internalCommandOutput(const QString& s);
 
116
 
 
117
private Q_SLOTS:
 
118
    void readyReadStandardOutput();
 
119
    void readyReadStandardError();
 
120
    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
 
121
    void processErrored(QProcess::ProcessError);
 
122
 
 
123
private:
 
124
    void processLine(const QByteArray& line);
 
125
 
 
126
private:
 
127
    QString gdbBinary_;
 
128
    KProcess* process_;
 
129
    bool sawPrompt_;
 
130
 
 
131
    GDBCommand* currentCmd_;
 
132
 
 
133
    MIParser mi_parser_;
 
134
 
 
135
    /** The unprocessed output from gdb. Output is
 
136
        processed as soon as we see newline. */
 
137
    QByteArray buffer_;
 
138
};
 
139
}
 
140
 
 
141
#endif