summaryrefslogtreecommitdiffstats
path: root/quanta/components/debugger/gubed/quantadebuggergubed.h
blob: 62acac0b7e7b79983fb03e3dfa65ddef0b8ed370 (plain)
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
/***************************************************************************
                          phpdebuggubed.cpp
                             -------------------
    begin                : 2004-03-12
    copyright            : (C) 2004 Linus McCabe <linus@mccabe.nu>
 ***************************************************************************/

/****************************************************************************
 *                                                                          *
 *   This program is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 2 of the License, or      *
 *   (at your option) any later version.                                    *
 *                                                                          *
 ***************************************************************************/

#ifndef QUANTADEBUGGERGUBED_H
#define QUANTADEBUGGERGUBED_H

#include <kserversocket.h>
#include <kstreamsocket.h>
#include <qptrlist.h>
#include <kurl.h>
#include <qdom.h>

#include "debuggerclient.h"

typedef QValueList<QString> WatchList;
typedef QMap<QString, QString> StringMap;

class QuantaDebuggerGubed : public DebuggerClient
{
    Q_OBJECT

  public:
    QuantaDebuggerGubed(QObject *parent, const char* name, const QStringList&);
    ~QuantaDebuggerGubed();

    // Execution states
    enum State
    {
      Pause = 0,
      Trace,
      Run
    };
    // Error codes
    enum Errors
    {
      Warning = 2,
      Notice = 8,
      User_Error = 256,
      User_Warning = 512,
      User_Notice = 1024
    };

    // Protocol version
    static const char protocolversion[];

    // Manager interaction
    const uint supports(DebuggerClientCapabilities::Capabilities);

    // Execution control
    void request();
    void trace();
    void run();
    void skip();
    void stepInto();
    void stepOver();
    void stepOut();
    void pause();
    void kill();
    void setExecutionState(State newstate);

    // Connection
    void startSession();
    void endSession();

    // Return name of debugger
    QString getName();

    // New file opened in quanta
    void fileOpened(const QString& file);

    // Settings
    void readConfig(QDomNode node);
    void showConfig(QDomNode node);

    // Breakpoints
    void addBreakpoint(DebuggerBreakpoint* breakpoint);
    void removeBreakpoint(DebuggerBreakpoint* breakpoint);
    void showCondition(const StringMap &args);

    // Variables
    void addWatch(const QString &variable);
    void removeWatch(DebuggerVariable *var);
    void variableSetValue(const DebuggerVariable &variable);

  private:
    KNetwork::KStreamSocket *m_socket;
    KNetwork::KServerSocket *m_server;
    QString m_command, m_buffer;
    long    m_datalen;

    QString m_serverBasedir;
    QString m_localBasedir;
    QString m_serverPort;
    QString m_serverHost;
    QString m_startsession;
    QString m_listenPort;
    bool    m_useproxy;
    State   m_executionState, m_defaultExecutionState;
    long    m_errormask;
    long    m_displaydelay;

    WatchList m_watchlist;

//     bool sendCommand(const QString&, const QString&);
    bool sendCommand(const QString& command, StringMap args);
    bool sendCommand(const QString& command, char * firstarg, ...);

    void processCommand(const QString&);
    void sendWatches();
    void sendBreakpoints();
    void debuggingState(bool enable);
    void connected();

    QString mapServerPathToLocal(const QString& serverpath);
    QString mapLocalPathToServer(const QString& localpath);
    QString bpToGubed(DebuggerBreakpoint* breakpoint);

    // Communication helpers
    QString phpSerialize(StringMap args);
    StringMap parseArgs(const QString &args);

    // Variables
    DebuggerVariable* parsePHPVariables(const QString &varstring);
    DebuggerVariable* parsePHPVariables(QString &str);
    void showWatch(const QString& data);

    
  public slots:
    // Socket slots
    void slotConnected(const KNetwork::KResolverEntry &);
    void slotConnectionClosed();
    void slotError(int error);
    void slotReadyRead();
    void slotReadyAccept();

  signals:
    void updateStatus(DebuggerUI::DebuggerStatus);
};

#endif