summaryrefslogtreecommitdiffstats
path: root/languages/ruby/debugger/rdbcontroller.h
blob: af72ddbc8a5ca5a48067957b361a1faa12b295c2 (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
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
187
188
189
190
191
192
193
/***************************************************************************
                          rdbcontroller.h  -  description
                             -------------------
    begin                : Sun Aug 8 1999
    copyright            : (C) 1999 by John Birch
    email                : jbb@kdevelop.org
	
                          Adapted for ruby debugging
                          --------------------------
	
    begin                : Mon Nov 1 2004
    copyright            : (C) 2004 by Richard Dale
    email                : Richard_Dale@tipitina.demon.co.uk
	
	
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 _RDBCONTROLLER_H_
#define _RDBCONTROLLER_H_

#include "dbgcontroller.h"

#include <tqcstring.h>
#include <tqdom.h>
#include <tqobject.h>
#include <tqptrlist.h>
#include <tqstring.h>
#include <tqsocketnotifier.h> 

class KProcess;

namespace RDBDebugger
{

class Breakpoint;
class DbgCommand;
class FramestackWidget;
class VarItem;
class VariableTree;
class STTY;

/**
 * A front end implementation to the ruby command line debugger
 * @author jbb
 */

class RDBController : public DbgController
{
    Q_OBJECT
  TQ_OBJECT

public:
    RDBController(VariableTree *varTree, FramestackWidget *frameStack, TQDomDocument &projectDom);
    ~RDBController();

protected:
    void queueCmd(DbgCommand *cmd, bool executeNext=false);

private:
    void parseProgramLocation (char *buf);
    void parseBacktraceList   (char *buf);
    void parseThreadList      (char* buf);
    void parseSwitchThread    (char* buf);
    void parseFrameMove       (char *buf);
    void parseBreakpointSet   (char *buf);
    void parseDisplay         (char *buf, char * expr);
    void parseUpdateDisplay   (char *buf);
    void parseGlobals         (char *buf);
    void parseLocals          (char type, char *buf);
    void parseRequestedData   (char *buf);
    void parseFrameSelected   (char *buf);

    void parse                (char *buf);

    void pauseApp();
    void executeCmd ();
    void destroyCmds();
    void removeInfoRequests();
    void actOnProgramPause(const TQString &msg);
    void programNoApp(const TQString &msg, bool msgBox);

    void setBreakpoint(const TQCString &BPSetCmd, int key);
    void clearBreakpoint(const TQCString &BPClearCmd);
    void modifyBreakpoint(const Breakpoint&);

    void setStateOn(int stateOn)    { state_ |= stateOn; }
    void setStateOff(int stateOff)  { state_ &= ~stateOff; }
    bool stateIsOn(int state)       { return state_  &state; }

public slots:
    void configure();

    void slotStart(	const TQString& shell, const TQString& characterCoding, 
					const TQString& run_directory, const TQString& debuggee_path, 
					const TQString &application, const TQString& run_arguments,
                    bool show_constants, bool trace_into_ruby );
    //void slotStart(const TQString& shell, const TQString &application);

    void slotStopDebugger();

    void slotRun();
    void slotRunUntil(const TQString &filename, int lineNum);
    void slotStepInto();
    void slotStepOver();
    void slotStepOutOff();

    void slotBreakInto();
    void slotBPState( const Breakpoint& );
    void slotClearAllBreakpoints();

    void slotExpandItem(VarItem *tqparent, const TQCString &userRequest);
    void slotRubyInspect(const TQString &inspectText);
    void slotSelectFrame(int frameNo, int threadNo, const TQString& frameName);
    void slotFetchGlobals(bool fetch);
    void slotAddWatchExpression(const TQString& expr, bool execute);
	void slotRemoveWatchExpression(int displayId);

    void slotUserRDBCmd(const TQString&);

protected slots:
    void slotDbgStdout(KProcess *proc, char *buf, int buflen);
    void slotDbgStderr(KProcess *proc, char *buf, int buflen);
    void slotDbgWroteStdin(KProcess *proc);
    void slotDbgProcessExited(KProcess *proc);
	
    void slotAcceptConnection(int masterSocket);
    void slotReadFromSocket(int socket);

signals:
    void acceptPendingBPs     ();
    void unableToSetBPNow     (int BPNo);
    void addWatchExpression     (const TQString&);

private:
    FramestackWidget* frameStack_;
    VariableTree*     varTree_;
    int               currentFrame_;
    int               viewedThread_;

    int               stdoutSizeofBuf_;      // size of the buffer for holding stdout piped
	                                         // from the ruby program
    int               stdoutOutputLen_;      // amount of data in the output buffer
    char*             stdoutOutput_;         // buffer for the output from kprocess
    TQCString          holdingZone_;
    
	int               rdbSizeofBuf_;         // size of the output buffer from rdb
    int               rdbOutputLen_;         // amount of data in the rdb buffer
    char*             rdbOutput_;            // buffer for the output from rdb via the Unix socket
	
	int               masterSocket_;         // The socket to accept connections
	TQSocketNotifier*  acceptNotifier_;
    static TQCString   unixSocketPath_;       // The name of the Unix Domain socket
	int               socket_;               // The socket to read and write to the debuggee
	TQSocketNotifier*  socketNotifier_;

    TQPtrList<DbgCommand> cmdList_;
    DbgCommand*       currentCmd_;
	TQString           currentPrompt_;

    STTY*             tty_;
	
	// Details for starting the ruby debugger process
	TQString          rubyInterpreter_;
	TQString          characterCoding_;
	TQString          runDirectory_;
	TQString          debuggeePath_;
	TQString          application_;
	TQString          runArguments_;
    bool             showConstants_;
    bool             traceIntoRuby_;

    // Some state variables
    int               state_;
    bool              programHasExited_;

    // Configuration values
    TQDomDocument &dom;
    bool    config_forceBPSet_;
    bool    config_dbgTerminal_;
};

}

#endif