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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
|
// *************************************************************************
// rdbcontroller.cpp - description
// -------------------
// begin : Sun Aug 8 1999
// copyright : (C) 1999 by John Birch
// email : [email protected]
//
// Adapted for ruby debugging
// --------------------------
// begin : Mon Nov 1 2004
// copyright : (C) 2004 by Richard Dale
// email : [email protected]
// **************************************************************************
//
// **************************************************************************
// * *
// * 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. *
// * *
// **************************************************************************
#include "rdbcontroller.h"
#include <sys/types.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include "breakpoint.h"
#include "framestackwidget.h"
#include "rdbcommand.h"
#include "stty.h"
#include "variablewidget.h"
#include "domutil.h"
#include "settings.h"
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kprocess.h>
#include <tqdatetime.h>
#include <tqfileinfo.h>
#include <tqregexp.h>
#include <tqstring.h>
#include <tqtextstream.h>
#include <iostream>
#include <ctype.h>
#include <stdlib.h>
using namespace std;
// **************************************************************************
//
// Does all the communication between rdb and the kdevelop's debugger code.
// Significatant classes being used here are
//
// RDBParser - parses the "variable" data using the vartree and varitems
// VarTree - where the variable data will end up
// FrameStack - tracks the program frames and allows the user to switch between
// and therefore view the calling funtions and their data
// Breakpoint - Where and what to do with breakpoints.
// STTY - the tty that the _application_ will run on.
//
// Significant variables
// state_ - be very careful setting this. The controller is totally
// dependent on this reflecting the correct state. For instance,
// if the app is busy but we don't think so, then we lose control
// of the app. The only way to get out of these situations is to
// delete (stop) the controller.
// currentFrame_
// - Holds the frame number where and locals/variable information will
// go to
//
//
// **************************************************************************
namespace RDBDebugger
{
// This is here so we can check for startup /shutdown problems
int debug_controllerExists = false;
// At the moment a Unix domain socket is used. It might be better to
// change to tcp/ip and listen on a port instead
TQCString RDBController::unixSocketPath_;
RDBController::RDBController(VariableTree *varTree, FramestackWidget *frameStack, TQDomDocument &projectDom)
: DbgController(),
frameStack_(frameStack),
varTree_(varTree),
currentFrame_(1),
viewedThread_(-1),
stdoutOutputLen_(0),
stdoutOutput_(new char[4096]),
holdingZone_(),
rdbOutputLen_(0),
rdbOutput_(new char[49152]),
socketNotifier_(0),
currentCmd_(0),
currentPrompt_("(rdb:1) "),
tty_(0),
state_(s_dbgNotStarted|s_appNotStarted|s_silent),
programHasExited_(false),
dom(projectDom),
config_forceBPSet_(true),
config_dbgTerminal_(false)
{
struct sockaddr_un sockaddr;
unixSocketPath_.sprintf("/tmp/.rubydebugger%d", getpid());
QFileInfo unixSocket(unixSocketPath_);
stdoutSizeofBuf_ = sizeof(stdoutOutput_);
rdbSizeofBuf_ = sizeof(rdbOutput_);
if (unixSocket.exists()) {
unlink(unixSocketPath_);
}
masterSocket_ = socket(AF_UNIX, SOCK_STREAM, 0);
sockaddr.sun_family = AF_UNIX;
strcpy(sockaddr.sun_path, unixSocketPath_);
bind(masterSocket_, (const struct sockaddr*) &sockaddr, sizeof(sockaddr));
listen(masterSocket_, 1);
acceptNotifier_ = new TQSocketNotifier(masterSocket_, TQSocketNotifier::Read, this);
TQObject::connect( acceptNotifier_, TQT_SIGNAL(activated(int)),
this, TQT_SLOT(slotAcceptConnection(int)) );
configure();
cmdList_.setAutoDelete(true);
Q_ASSERT(! debug_controllerExists);
debug_controllerExists = true;
}
// **************************************************************************
// Deleting the controller involves shutting down rdb nicely.
// When were attached to a process, we must first detach so that the process
// can continue running as it was before being attached. rdb is quite slow to
// detach from a process, so we must process events within here to get a "clean"
// shutdown.
RDBController::~RDBController()
{
delete[] stdoutOutput_;
delete[] rdbOutput_;
debug_controllerExists = false;
TQFileInfo unixSocket(unixSocketPath_);
if (unixSocket.exists()) {
unlink(unixSocketPath_);
}
}
// **************************************************************************
void RDBController::configure()
{
}
// **************************************************************************
// Fairly obvious that we'll add whatever command you give me to a queue
// If you tell me to, I'll put it at the head of the queue so it'll run ASAP
// Not quite so obvious though is that if we are going to run again. then any
// information requests become redundent and must be removed.
// We also try and run whatever command happens to be at the head of
// the queue.
void RDBController::queueCmd(DbgCommand *cmd, bool executeNext)
{
// We remove any info command or _run_ command if we are about to
// add a run command.
if (cmd->isARunCmd())
removeInfoRequests();
if (executeNext)
cmdList_.insert(0, cmd);
else
cmdList_.append (cmd);
}
// **************************************************************************
// If the appliction can accept a command and we've got one waiting
// then send it.
// Commands can be just request for data (or change rdbs state in someway)
// or they can be "run" commands. If a command is sent to rdb our internal
// state will get updated.
void RDBController::executeCmd()
{
if (stateIsOn(s_dbgNotStarted|s_waitForWrite|s_appBusy|s_shuttingDown) || !dbgProcess_)
return;
if (currentCmd_ == 0) {
if (cmdList_.isEmpty())
return;
currentCmd_ = cmdList_.take(0);
}
if (!currentCmd_->moreToSend()) {
delete currentCmd_;
if (cmdList_.isEmpty()) {
currentCmd_ = 0;
return;
}
currentCmd_ = cmdList_.take(0);
}
char * ptr = currentCmd_->cmdToSend().data();
int bytesToWrite = currentCmd_->cmdLength();
int bytesWritten = 0;
while (bytesToWrite > 0) {
bytesWritten = write(socket_, ptr, bytesToWrite);
bytesToWrite -= bytesWritten;
ptr += bytesWritten;
}
if (currentCmd_->isARunCmd()) {
setStateOn(s_appBusy);
kdDebug(9012) << "App is busy" << endl;
setStateOff(s_appNotStarted|s_programExited|s_silent);
}
TQString prettyCmd = currentCmd_->cmdToSend();
prettyCmd = currentPrompt_ + prettyCmd;
emit rdbStdout( prettyCmd.latin1() );
if (!stateIsOn(s_silent))
emit dbgStatus("", state_);
}
// **************************************************************************
void RDBController::destroyCmds()
{
if (currentCmd_)
{
delete currentCmd_;
currentCmd_ = 0;
}
while (!cmdList_.isEmpty())
delete cmdList_.take(0);
}
// **********************************************************************
void RDBController::removeInfoRequests()
{
int i = cmdList_.count();
while (i)
{
i--;
DbgCommand *cmd = cmdList_.at(i);
if (cmd->isAnInfoCmd() || cmd->isARunCmd())
delete cmdList_.take(i);
}
}
// **********************************************************************
// Pausing an app removes any pending run commands so that the app doesn't
// start again. If we want to be silent then we remove any pending info
// commands as well.
void RDBController::pauseApp()
{
int i = cmdList_.count();
while (i)
{
i--;
DbgCommand *cmd = cmdList_.at(i);
if ((stateIsOn(s_silent) && cmd->isAnInfoCmd()) || cmd->isARunCmd())
delete cmdList_.take(i);
}
if (dbgProcess_ && stateIsOn(s_appBusy))
dbgProcess_->kill(SIGINT);
}
// **********************************************************************
// Whenever the program pauses we need to refresh the data visible to
// the user. The reason we've stopped may be passed in to be emitted.
void RDBController::actOnProgramPause(const TQString &msg)
{
// We're only stopping if we were running, of course.
if (stateIsOn(s_appBusy))
{
kdDebug(9012) << "App is paused" << endl;
setStateOff(s_appBusy);
if (stateIsOn(s_silent))
return;
emit dbgStatus (msg, state_);
// We're always at frame one when the program stops
// and we must reset the active flag
currentFrame_ = 1;
varTree_->nextActivationId();
setStateOn(s_fetchLocals);
queueCmd(new RDBCommand("where", NOTRUNCMD, INFOCMD), true);
queueCmd(new RDBCommand("thread list", NOTRUNCMD, INFOCMD), true);
if (stateIsOn(s_fetchGlobals)) {
queueCmd(new RDBCommand("var global", NOTRUNCMD, INFOCMD));
}
emit acceptPendingBPs();
}
}
// **************************************************************************
// There is no app anymore. This can be caused by program exiting
// an invalid program specified or ...
// rdb is still running though, but only the run command (may) make sense
// all other commands are disabled.
void RDBController::programNoApp(const TQString &msg, bool msgBox)
{
state_ = (s_appNotStarted|s_programExited|(state_&(s_shuttingDown)));
destroyCmds();
// We're always at frame one when the program stops
// and we must reset the active flag
viewedThread_ = -1;
currentFrame_ = 1;
varTree_->nextActivationId();
// Now wipe the tree out
varTree_->viewport()->setUpdatesEnabled(false);
varTree_->prune();
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
frameStack_->clear();
if (msgBox)
KMessageBox::error(0, i18n("rdb message:\n")+msg);
emit dbgStatus (msg, state_);
}
// **************************************************************************
// The program location falls out of rdb. We treat
// it as a wrapped command.
// The data gets parsed here and emitted in its component parts.
void RDBController::parseProgramLocation(char *buf)
{
TQString buffer(buf);
TQString line;
TQTextStream input(&buffer, IO_ReadOnly);
TQString sourceFile;
int sourceLine = 0;
// "1: a = 1"
TQRegExp display_re("^(\\d+):\\s(.*)$");
// "/opt/qt/src/widgets/qlistview.rb:1558:puts 'hello world'"
TQRegExp sourcepos_re("^([^:]+):(\\d+):");
line = input.readLine();
while (! line.isNull()) {
if (sourcepos_re.search(line, 0) >= 0) {
sourceFile = sourcepos_re.cap(1);
sourceLine = sourcepos_re.cap(2).toInt();
} else if (display_re.search(line, 0) >= 0) {
varTree_->watchRoot()->updateWatchExpression(display_re.cap(1).toInt(), display_re.cap(2));
}
line = input.readLine();
}
if ( !sourceFile.isNull()
&& ( traceIntoRuby_
|| ( !sourceFile.endsWith("/qtruby.rb")
&& !sourceFile.endsWith("/korundum.rb") ) )
&& !sourceFile.endsWith("/debuggee.rb") )
{
actOnProgramPause(TQString());
emit showStepInSource(sourceFile, sourceLine, "");
return;
}
if (stateIsOn(s_appBusy))
actOnProgramPause(i18n("No source: %1").arg(sourceFile));
else
emit dbgStatus (i18n("No source: %1").arg(sourceFile), state_);
}
// **************************************************************************
// parsing the backtrace list will cause the vartree to be refreshed
void RDBController::parseBacktraceList(char *buf)
{
frameStack_->parseRDBBacktraceList(buf);
}
// **************************************************************************
void RDBController::parseThreadList(char *buf)
{
frameStack_->parseRDBThreadList(buf);
viewedThread_ = frameStack_->viewedThread();
varTree_->setCurrentThread(viewedThread_);
}
// **************************************************************************
void RDBController::parseSwitchThread(char *buf)
{
// Look for the thread number
// 2 #<Thread:0x30091998 sleep> /home/duke/play/testit/trykorundum/src/bar.rb:13
TQRegExp thread_re("(\\d+)");
if (thread_re.search(buf) != -1) {
viewedThread_ = thread_re.cap(1).toInt();
currentFrame_ = 1;
}
}
// **************************************************************************
// After an 'up nnn' or 'down nnn' command, get the new source file and line no.
void RDBController::parseFrameMove(char *buf)
{
TQString sourceFile;
int sourceLine = 0;
if (stateIsOn(s_fetchLocals)) {
return;
}
// "#2 /home/duke/play/testit/trykorundum/src/main.rb:11"
TQRegExp sourcepos_re("#\\d+\\s([^:]+):(\\d+)");
if (sourcepos_re.search(buf) != -1) {
sourceFile = sourcepos_re.cap(1);
sourceLine = sourcepos_re.cap(2).toInt();
if ( !sourceFile.isNull()
&& ( traceIntoRuby_
|| ( !sourceFile.endsWith("/qtruby.rb")
&& !sourceFile.endsWith("/korundum.rb") ) )
&& !sourceFile.endsWith("/debuggee.rb") )
{
emit showStepInSource(sourceFile, sourceLine, "");
return;
}
}
emit dbgStatus(i18n("No source: %1").arg(sourceFile), state_);
}
// **************************************************************************
// When a breakpoint has been set, rdb responds with some data about the
// new breakpoint. We just inform the breakpoint system about this.
void RDBController::parseBreakpointSet(char *buf)
{
if (RDBSetBreakpointCommand *BPCmd = dynamic_cast<RDBSetBreakpointCommand*>(currentCmd_))
{
// ... except in this case :-) A -1 key tells us that this is
// a special internal breakpoint, and we shouldn't do anything
// with it. Currently there are _no_ internal breakpoints.
if (BPCmd->getKey() != -1) {
emit rawRDBBreakpointSet(buf, BPCmd->getKey());
}
}
}
// **************************************************************************
// Extra data needed by an item was requested. Here's the result.
// If it's an ordinary 'p ' command then just echo the result on
// the RDB console and don't bother parsing.
void RDBController::parseRequestedData(char *buf)
{
if (RDBItemCommand *rdbItemCommand = dynamic_cast<RDBItemCommand*> (currentCmd_))
{
// Fish out the item from the command and let it deal with the data
VarItem *item = rdbItemCommand->getItem();
varTree_->viewport()->setUpdatesEnabled(false);
item->expandValue(buf);
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
}
}
// **************************************************************************
// Select a different frame to view. We need to get and (maybe) display
// where we are in the program source.
void RDBController::parseFrameSelected(char *buf)
{
if (!stateIsOn(s_silent)) {
emit showStepInSource("", -1, "");
emit dbgStatus (i18n("No source: %1").arg(TQString(buf)), state_);
}
}
// **************************************************************************
// Sets the id of the display in the VarTree and a current value.
void RDBController::parseDisplay(char *buf, char * expr)
{
varTree_->viewport()->setUpdatesEnabled(false);
varTree_->watchRoot()->setWatchExpression(buf, expr);
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
}
// **************************************************************************
// Updates the watch expressions with current values
void RDBController::parseUpdateDisplay(char *buf)
{
varTree_->viewport()->setUpdatesEnabled(false);
TQRegExp display_re("(\\d+):\\s([^\n]*)\n");
int pos = display_re.search(buf);
while (pos != -1) {
varTree_->watchRoot()->updateWatchExpression(display_re.cap(1).toInt(), display_re.cap(2));
pos += display_re.matchedLength();
pos = display_re.search(buf, pos);
}
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
}
// **************************************************************************
// This is called on program stop to process the globals.
void RDBController::parseGlobals(char *buf)
{
varTree_->viewport()->setUpdatesEnabled(false);
varTree_->globalRoot()->setGlobals(buf);
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
}
// **************************************************************************
// This is called on program stop to process the locals.
// Once the locals have been processed we prune the tree of items that are
// inactive.
void RDBController::parseLocals(char type, char *buf)
{
varTree_->viewport()->setUpdatesEnabled(false);
// The locals are always attached to the currentFrame
VarFrameRoot *frame = varTree_->findFrame(currentFrame_, viewedThread_);
if (!frame)
{
frame = new VarFrameRoot(varTree_, currentFrame_, viewedThread_);
frame->setFrameName(
frameStack_->findFrame(currentFrame_, viewedThread_)->frameName());
}
Q_ASSERT(frame);
if (type == (char) CONSTANTS) {
frame->addLocals(buf);
} else if (type == (char) CVARS) {
frame->addLocals(buf);
} else if (type == (char) IVARS) {
frame->addLocals(buf);
} else {
frame->addLocals(buf);
frame->setLocals();
}
varTree_->viewport()->setUpdatesEnabled(true);
varTree_->repaint();
}
// **************************************************************************
void RDBController::parse(char *buf)
{
if (currentCmd_ == 0) {
return;
}
if (currentCmd_->isARunCmd()) {
parseProgramLocation(buf);
} else if (currentCmd_->rawDbgCommand() == "break") {
emit rawRDBBreakpointList(buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "break ", strlen("break ")) == 0) {
parseBreakpointSet(buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "watch ", strlen("watch ")) == 0) {
parseBreakpointSet(buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "display ", strlen("display ")) == 0) {
parseDisplay(buf, currentCmd_->rawDbgCommand().data() + strlen("display "));
} else if (currentCmd_->rawDbgCommand() == "display") {
parseUpdateDisplay(buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "undisplay ", strlen("undisplay ")) == 0) {
;
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "method instance ", strlen("method instance ")) == 0) {
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "method ", strlen("method ")) == 0) {
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "pp ", strlen("pp ")) == 0) {
parseRequestedData(buf);
} else if (currentCmd_->rawDbgCommand() == "thread list") {
parseThreadList(buf);
} else if ( qstrncmp(currentCmd_->rawDbgCommand(), "up ", strlen("up ")) == 0
|| qstrncmp(currentCmd_->rawDbgCommand(), "down ", strlen("down ")) == 0 )
{
parseFrameMove(buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "thread switch ", strlen("thread switch ")) == 0) {
parseSwitchThread(buf);
} else if (currentCmd_->rawDbgCommand() == "thread current") {
parseThreadList(buf);
} else if (currentCmd_->rawDbgCommand() == "where") {
parseBacktraceList(buf);
} else if (currentCmd_->rawDbgCommand() == "var global") {
parseGlobals(buf);
} else if (currentCmd_->rawDbgCommand() == "var local") {
parseLocals(LOCALS, buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "var instance ", strlen("var instance ")) == 0) {
parseLocals(IVARS, buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "var class ", strlen("var class ")) == 0) {
parseLocals(CVARS, buf);
} else if (qstrncmp(currentCmd_->rawDbgCommand(), "var const ", strlen("var const ")) == 0) {
parseLocals(CONSTANTS, buf);
}
return;
}
// **************************************************************************
void RDBController::setBreakpoint(const TQCString &BPSetCmd, int key)
{
queueCmd(new RDBSetBreakpointCommand(BPSetCmd, key));
}
// **************************************************************************
void RDBController::clearBreakpoint(const TQCString &BPClearCmd)
{
queueCmd(new RDBCommand(BPClearCmd, NOTRUNCMD, NOTINFOCMD));
// Note: this is NOT an info command, because rdb doesn't explictly tell
// us that the breakpoint has been deleted, so if we don't have it the
// BP list doesn't get updated.
queueCmd(new RDBCommand("break", NOTRUNCMD, NOTINFOCMD));
}
// **************************************************************************
void RDBController::modifyBreakpoint( const Breakpoint& BP )
{
Q_ASSERT(BP.isActionModify());
if (BP.dbgId() > 0)
{
if (BP.changedEnable())
queueCmd(new RDBCommand(TQCString().sprintf("%s %d",
BP.isEnabled() ? "enable" : "disable",
BP.dbgId()), NOTRUNCMD, NOTINFOCMD));
// BP.setDbgProcessing(true);
// Note: this is NOT an info command, because rdb doesn't explictly tell
// us that the breakpoint has been deleted, so if we don't have it the
// BP list doesn't get updated.
queueCmd(new RDBCommand("break", NOTRUNCMD, NOTINFOCMD));
}
}
// **************************************************************************
// SLOTS
// *****
// For most of these slots data can only be sent to rdb when it
// isn't busy and it is running.
// **************************************************************************
void RDBController::slotStart(const TQString& ruby_interpreter, const TQString& character_coding, const TQString& run_directory, const TQString& debuggee_path, const TQString &application, const TQString& run_arguments, bool show_constants, bool trace_into_ruby)
{
Q_ASSERT (!dbgProcess_ && !tty_);
// tty_ = new STTY(config_dbgTerminal_, "konsole");
tty_ = new STTY(config_dbgTerminal_, Settings::terminalEmulatorName( *kapp->config() ));
if (!config_dbgTerminal_)
{
connect( tty_, TQT_SIGNAL(OutOutput(const char*)), TQT_SIGNAL(ttyStdout(const char*)) );
connect( tty_, TQT_SIGNAL(ErrOutput(const char*)), TQT_SIGNAL(ttyStderr(const char*)) );
}
TQString tty(tty_->getSlave());
if (tty.isEmpty())
{
KMessageBox::error(0, i18n("The ruby debugger cannot use the tty* or pty* devices.\n"
"Check the settings on /dev/tty* and /dev/pty*\n"
"As root you may need to \"chmod ug+rw\" tty* and pty* devices "
"and/or add the user to the tty group using "
"\"usermod -G tty username\"."));
delete tty_;
tty_ = 0;
return;
}
dbgProcess_ = new KProcess;
connect( dbgProcess_, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)),
this, TQT_SLOT(slotDbgStdout(KProcess *, char *, int)) );
connect( dbgProcess_, TQT_SIGNAL(receivedStderr(KProcess *, char *, int)),
this, TQT_SLOT(slotDbgStderr(KProcess *, char *, int)) );
connect( dbgProcess_, TQT_SIGNAL(wroteStdin(KProcess *)),
this, TQT_SLOT(slotDbgWroteStdin(KProcess *)) );
connect( dbgProcess_, TQT_SIGNAL(processExited(KProcess*)),
this, TQT_SLOT(slotDbgProcessExited(KProcess*)) );
rubyInterpreter_ = ruby_interpreter;
characterCoding_ = character_coding;
runDirectory_ = run_directory;
debuggeePath_ = debuggee_path;
application_ = application;
runArguments_ = run_arguments;
showConstants_ = show_constants;
traceIntoRuby_ = trace_into_ruby;
*dbgProcess_ << ruby_interpreter;
*dbgProcess_ << character_coding;
*dbgProcess_ << "-C" << TQString(TQFile::encodeName( run_directory ));
*dbgProcess_ << "-r" << debuggee_path;
*dbgProcess_ << application;
if (!run_arguments.isNull() && !run_arguments.isEmpty()) {
*dbgProcess_ << run_arguments;
}
emit rdbStdout(TQString( ruby_interpreter + " " + character_coding
+ " -C " + TQString(TQFile::encodeName( run_directory ))
+ " -r " + debuggee_path + " "
+ application + " " + run_arguments ).latin1() );
if (!dbgProcess_->start( KProcess::NotifyOnExit,
KProcess::Communication(KProcess::All)) )
{
kdDebug(9012) << "Couldn't start ruby debugger" << endl;
}
// Initialise rdb. At this stage rdb is sitting wondering what to do,
// and to whom. Organise a few things, then set up the tty for the application,
// and the application itself
// Now the ruby debugger has been started and the application has been loaded,
// BUT the app hasn't been started yet! A run command is about to be issued
// by whoever is controlling us.
if (!dbgProcess_->writeStdin(TQString("%1\n").arg(unixSocketPath_).latin1(), strlen(unixSocketPath_) + 1)) {
kdDebug(9012) << "failed to write Unix domain socket path to rdb "
<< TQString("%1\n").arg(unixSocketPath_).latin1() << endl;
}
setStateOff(s_programExited);
setStateOn(s_dbgNotStarted|s_appNotStarted|s_silent);
}
// **************************************************************************
void RDBController::slotStopDebugger()
{
if (stateIsOn(s_shuttingDown) || !dbgProcess_)
return;
setStateOn(s_shuttingDown|s_silent);
destroyCmds();
TQTime start;
TQTime now;
// Get rdb's attention if it's busy. We need rdb to be at the
// command line so we can stop it.
if (stateIsOn(s_appBusy))
{
kdDebug(9012) << "ruby debugger busy on shutdown - stopping rdb (SIGINT)" << endl;
dbgProcess_->kill(SIGINT);
start = TQTime::currentTime();
while (-1)
{
kapp->processEvents(20);
now = TQTime::currentTime();
if (!stateIsOn(s_appBusy) || start.msecsTo( now ) > 2000)
break;
}
}
// Now try to stop the ruby debugger running.
kdDebug(9012) << "App is busy" << endl;
setStateOn(s_appBusy);
const char *quit="quit\n";
if (!dbgProcess_->writeStdin(quit, strlen(quit)))
kdDebug(9012) << "failed to write 'quit' to ruby debugger" << endl;
emit rdbStdout("(rdb:1) quit");
start = TQTime::currentTime();
while (-1)
{
kapp->processEvents(20);
now = TQTime::currentTime();
if (stateIsOn(s_programExited) || start.msecsTo( now ) > 2000)
break;
}
// We cannot wait forever.
if (!stateIsOn(s_programExited))
{
kdDebug(9012) << "rdb not shutdown - killing" << endl;
dbgProcess_->kill(SIGKILL);
}
delete dbgProcess_; dbgProcess_ = 0;
delete tty_; tty_ = 0;
state_ = s_dbgNotStarted | s_appNotStarted | s_silent;
emit dbgStatus (i18n("Debugger stopped"), state_);
}
// **************************************************************************
void RDBController::slotRun()
{
if (stateIsOn(s_appBusy|s_dbgNotStarted|s_shuttingDown))
return;
if (stateIsOn(s_programExited)) {
slotStart(rubyInterpreter_, characterCoding_, runDirectory_, debuggeePath_, application_, runArguments_, showConstants_, traceIntoRuby_);
return;
}
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
void RDBController::slotRunUntil(const TQString &fileName, int lineNum)
{
if (stateIsOn(s_appBusy|s_dbgNotStarted|s_shuttingDown))
return;
if (fileName.isEmpty())
queueCmd(new RDBCommand( TQCString().sprintf("break %d", lineNum),
RUNCMD, NOTINFOCMD));
else
queueCmd(new RDBCommand(
TQCString().sprintf("break %s:%d", fileName.latin1(), lineNum),
RUNCMD, NOTINFOCMD));
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
void RDBController::slotStepInto()
{
if (stateIsOn(s_appBusy|s_appNotStarted|s_shuttingDown))
return;
queueCmd(new RDBCommand("step", RUNCMD, NOTINFOCMD));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
void RDBController::slotStepOver()
{
if (stateIsOn(s_appBusy|s_appNotStarted|s_shuttingDown))
return;
queueCmd(new RDBCommand("next", RUNCMD, NOTINFOCMD));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
void RDBController::slotStepOutOff()
{
if (stateIsOn(s_appBusy|s_appNotStarted|s_shuttingDown))
return;
queueCmd(new RDBCommand("finish", RUNCMD, NOTINFOCMD));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
// Only interrupt a running program.
void RDBController::slotBreakInto()
{
pauseApp();
}
// **************************************************************************
// See what, if anything needs doing to this breakpoint.
void RDBController::slotBPState( const Breakpoint& BP )
{
// Are we in a position to do anything to this breakpoint?
if (stateIsOn(s_dbgNotStarted|s_shuttingDown) || !BP.isPending() ||
BP.isActionDie())
return;
// We need this flag so that we can continue execution. I did use
// the s_silent state flag but it can be set prior to this method being
// called, hence is invalid.
bool restart = false;
if (stateIsOn(s_appBusy))
{
if (!config_forceBPSet_)
return;
// When forcing breakpoints to be set/unset, interrupt a running app
// and change the state.
setStateOn(s_silent);
pauseApp();
restart = true;
}
if (BP.isActionAdd())
{
setBreakpoint(BP.dbgSetCommand().latin1(), BP.key());
// BP.setDbgProcessing(true);
}
else
{
if (BP.isActionClear())
{
clearBreakpoint(BP.dbgRemoveCommand().latin1());
// BP.setDbgProcessing(true);
}
else
{
if (BP.isActionModify())
{
modifyBreakpoint(BP); // Note: DbgProcessing gets set in modify fn
}
}
}
if (restart)
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
}
// **************************************************************************
void RDBController::slotClearAllBreakpoints()
{
// Are we in a position to do anything to this breakpoint?
if (stateIsOn(s_dbgNotStarted|s_shuttingDown))
return;
bool restart = false;
if (stateIsOn(s_appBusy))
{
if (!config_forceBPSet_)
return;
// When forcing breakpoints to be set/unset, interrupt a running app
// and change the state.
setStateOn(s_silent);
pauseApp();
restart = true;
}
queueCmd(new RDBCommand("delete", NOTRUNCMD, NOTINFOCMD));
// Note: this is NOT an info command, because rdb doesn't explictly tell
// us that the breakpoint has been deleted, so if we don't have it the
// BP list doesn't get updated.
queueCmd(new RDBCommand("break", NOTRUNCMD, NOTINFOCMD));
if (restart)
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
executeCmd();
}
// **************************************************************************
void RDBController::slotSelectFrame(int frameNo, int threadNo, const TQString& frameName)
{
if (stateIsOn(s_appBusy|s_dbgNotStarted|s_shuttingDown)) {
kdDebug(9012) << "RDBController::slotSelectFrame wrong state" << endl;
return;
}
if (viewedThread_ != threadNo) {
// Note that 'thread switch nnn' is a run command
queueCmd(new RDBCommand(TQCString().sprintf("thread switch %d",
threadNo), RUNCMD, INFOCMD));
executeCmd();
return;
}
if (frameNo > currentFrame_) {
queueCmd(new RDBCommand(TQCString().sprintf("up %d", frameNo - currentFrame_), NOTRUNCMD, INFOCMD));
if (!stateIsOn(s_fetchLocals)) {
queueCmd(new RDBCommand("display", NOTRUNCMD, INFOCMD));
}
} else if (frameNo < currentFrame_) {
queueCmd(new RDBCommand(TQCString().sprintf("down %d", currentFrame_ - frameNo), NOTRUNCMD, INFOCMD));
if (!stateIsOn(s_fetchLocals)) {
queueCmd(new RDBCommand("display", NOTRUNCMD, INFOCMD));
}
}
// Hold on to this thread/frame so that we know where to put the local
// variables if generated.
viewedThread_ = threadNo;
currentFrame_ = frameNo;
VarFrameRoot *frame = varTree_->findFrame(frameNo, viewedThread_);
if (frame == 0) {
frame = new VarFrameRoot(varTree_, currentFrame_, viewedThread_);
}
frame->setFrameName(frameName);
varTree_->setSelected(frame, true);
// Have we already got these details?
if (frame->needsVariables()) {
// Ask for the locals
if (showConstants_) {
queueCmd(new RDBCommand("var const self.class", NOTRUNCMD, INFOCMD));
}
queueCmd(new RDBCommand("var instance self", NOTRUNCMD, INFOCMD));
queueCmd(new RDBCommand("var class self.class", NOTRUNCMD, INFOCMD));
queueCmd(new RDBCommand("var local", NOTRUNCMD, INFOCMD));
frame->startWaitingForData();
}
if (currentCmd_ == 0) {
executeCmd();
}
return;
}
// **************************************************************************
// This is called when an item needs special processing to show a value.
void RDBController::slotExpandItem(VarItem *item, const TQCString &userRequest)
{
if (stateIsOn(s_appBusy|s_dbgNotStarted|s_shuttingDown))
return;
Q_ASSERT(item != 0);
// Bad user data!!
if (userRequest.isEmpty())
return;
queueCmd(new RDBItemCommand(item, TQCString("pp ") + userRequest.data(), false));
if (currentCmd_ == 0) {
executeCmd();
}
}
// **************************************************************************
// This method evaluates text selected with the 'Inspect:' context menu
void RDBController::slotRubyInspect(const TQString &inspectText)
{
queueCmd(new RDBCommand( TQCString().sprintf("p %s", inspectText.latin1()),
NOTRUNCMD,
INFOCMD ), true );
executeCmd();
}
// **************************************************************************
// Add a new expression to be displayed in the Watch variable tree
void RDBController::slotAddWatchExpression(const TQString& expr, bool execute)
{
queueCmd(new RDBCommand( TQCString().sprintf("display %s", expr.latin1()),
NOTRUNCMD,
NOTINFOCMD ) );
if (execute) {
executeCmd();
}
}
// **************************************************************************
// Add a new expression to be displayed in the Watch variable tree
void RDBController::slotRemoveWatchExpression(int displayId)
{
queueCmd(new RDBCommand( TQCString().sprintf("undisplay %d", displayId),
NOTRUNCMD,
INFOCMD ) );
executeCmd();
}
// **************************************************************************
// The user will only get globals if the Global frame is open
void RDBController::slotFetchGlobals(bool fetch)
{
if (fetch) {
setStateOn(s_fetchGlobals);
queueCmd(new RDBCommand("var global", NOTRUNCMD, INFOCMD));
executeCmd();
} else {
setStateOff(s_fetchGlobals);
}
kdDebug(9012) << (fetch ? "<Globals ON>": "<Globals OFF>") << endl;
}
// **************************************************************************
// Data from the ruby program's stdout gets processed here.
void RDBController::slotDbgStdout(KProcess *, char *buf, int buflen)
{
TQCString msg(buf, buflen+1);
emit ttyStdout(msg);
}
// **************************************************************************
// Data from the ruby program's stderr gets processed here.
void RDBController::slotDbgStderr(KProcess *, char *buf, int buflen)
{
TQCString msg(buf, buflen+1);
emit ttyStderr(msg);
}
// **************************************************************************
void RDBController::slotDbgWroteStdin(KProcess *)
{
// setStateOff(s_waitForWrite);
// if (!stateIsOn(s_silent))
// emit dbgStatus ("", state_);
// executeCmd();
}
// **************************************************************************
void RDBController::slotAcceptConnection(int masterSocket)
{
Q_ASSERT(masterSocket == masterSocket_);
struct sockaddr sockaddr;
socklen_t fromlen;
if (socketNotifier_ != 0) {
close(socket_);
delete socketNotifier_;
}
socket_ = accept(masterSocket, &sockaddr, &fromlen);
if (fcntl(socket_, F_SETFL, O_NONBLOCK) == -1) {
kdDebug(9012) << "RDBController::slotAcceptConnection can't set nonblocking socket " << errno << endl;
}
socketNotifier_ = new TQSocketNotifier(socket_, TQSocketNotifier::Read, 0);
TQObject::connect( socketNotifier_, TQT_SIGNAL(activated(int)),
this, TQT_SLOT(slotReadFromSocket(int)) );
setStateOff(s_dbgNotStarted);
emit dbgStatus ("", state_);
cmdList_.clear();
rdbOutputLen_ = 0;
// Organise any breakpoints.
emit acceptPendingBPs();
if (traceIntoRuby_) {
queueCmd(new RDBCommand("trace_ruby on", NOTRUNCMD, NOTINFOCMD));
}
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
// Reset the display id for any watch expressions already in the variable tree
varTree_->resetWatchVars();
}
// **************************************************************************
// Output from rdb via the Unix socket gets processed here.
void RDBController::slotReadFromSocket(int socket)
{
Q_ASSERT(socket == socket_);
static bool parsing = false;
int bytesRead = read(socket, rdbOutput_ + rdbOutputLen_, rdbSizeofBuf_);
rdbOutputLen_ += bytesRead;
*(rdbOutput_ + rdbOutputLen_) = 0;
// Already parsing? then get out quick.
if (parsing)
{
kdDebug(9012) << "Already parsing" << endl;
return;
}
// kdDebug(9012) << "RDBController::slotReadFromSocket length: " << rdbOutputLen_ << " input: " << rdbOutput_ << endl;
TQRegExp prompt_re("(\\(rdb:(\\d+)\\) )$");
int promptPos = prompt_re.search(rdbOutput_, 0);
// Keep appending output to the rbdOutput_ buffer until the
// ruby debugger writes the next prompt
if (promptPos == -1) {
return;
}
// kdDebug(9012) << "RDBController::slotReadFromSocket length: " << rdbOutputLen_ << " input: " << rdbOutput_ << endl;
// Save the prompt, and remove it from the buffer
currentPrompt_ = prompt_re.cap(1).latin1();
rdbOutputLen_ -= prompt_re.matchedLength();
*(rdbOutput_ + rdbOutputLen_) = 0;
emit rdbStdout(rdbOutput_);
parsing = true;
parse(rdbOutput_);
parsing = false;
rdbOutputLen_ = 0;
executeCmd();
if (currentCmd_ == 0 && stateIsOn(s_fetchLocals)) {
if (!varTree_->schedule()) {
setStateOff(s_fetchLocals);
}
}
}
// **************************************************************************
void RDBController::slotDbgProcessExited(KProcess*)
{
destroyCmds();
state_ = s_appNotStarted|s_programExited|(state_&(s_shuttingDown));
emit dbgStatus (i18n("Process exited"), state_);
emit rdbStdout("(rdb:1) Process exited\n");
frameStack_->clear();
varTree_->clear();
if (socketNotifier_ != 0) {
delete socketNotifier_;
socketNotifier_ = 0;
close(socket_);
}
delete dbgProcess_; dbgProcess_ = 0;
delete tty_; tty_ = 0;
}
// **************************************************************************
// Takes abbreviated commands and expands them, before passing them on to rdb
//
void RDBController::slotUserRDBCmd(const TQString& cmd)
{
kdDebug(9012) << "Requested user cmd: " << cmd << endl;
TQRegExp break_re("^b(reak)?(\\s.*)?");
TQRegExp watch_re("^wat(ch)?\\s+(.*)");
TQRegExp delete_re("^del(ete)?(\\s.*)?");
TQRegExp display_re("^disp(lay)?(\\s.*)?");
TQRegExp undisplay_re("^undisp(lay)?(\\s.*)?");
TQRegExp step_re("^s(tep)?(\\s[\\d]+)?$");
TQRegExp next_re("^n(ext)?(\\s[\\d]+)?$");
TQRegExp varlocal_re("^v(ar)?\\s+l(ocal)?");
TQRegExp varglobal_re("^v(ar)?\\s+g(lobal)?");
TQRegExp varinstance_re("^v(ar)?\\s+i(nstance)?\\s(.*)");
TQRegExp varconst_re("^v(ar)?\\s+c(onst)?\\s(.*)");
TQRegExp threadlist_re("^th(read)?\\s+l(ist)?");
TQRegExp threadcurrent_re("^th(read)?(\\sc(ur(rent)?)?)?$");
TQRegExp threadswitch_re("^th(read)?(\\ssw(itch)?)?(\\s.*)");
TQRegExp thread_re("^th(read)?(\\s+.*)?");
TQRegExp methodinstance_re("^m(ethod)?\\s+i(nstance)?\\s+(.*)");
TQRegExp method_re("^m(ethod)?\\s+(.*)");
TQRegExp list_re("^l(ist)?(\\s+\\d+-\\d+)?$");
if ( break_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("break%s", break_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( watch_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("watch %s", watch_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( delete_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("delete%s", delete_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( display_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("display%s", display_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( undisplay_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("undisplay%s", undisplay_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( step_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("step%s", step_re.cap(2).latin1()),
RUNCMD,
INFOCMD ), true );
} else if ( next_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("next%s", next_re.cap(2).latin1()),
RUNCMD,
INFOCMD ), true );
} else if ( varlocal_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand("var local", NOTRUNCMD, INFOCMD));
} else if ( varglobal_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand("var global", NOTRUNCMD, INFOCMD));
} else if ( varinstance_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("var instance %s", varinstance_re.cap(3).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( varconst_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("var const %s", varconst_re.cap(3).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( methodinstance_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("method instance %s", methodinstance_re.cap(3).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( method_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("method %s", method_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if ( list_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("list%s", list_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if (cmd == "c" || cmd == "cont") {
queueCmd(new RDBCommand("cont", RUNCMD, NOTINFOCMD));
} else if (cmd == "fi" || cmd == "finish") {
queueCmd(new RDBCommand("finish", RUNCMD, NOTINFOCMD));
} else if ( threadlist_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand("thread list", NOTRUNCMD, INFOCMD), true);
} else if ( threadcurrent_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand("thread current", NOTRUNCMD, INFOCMD), true );
} else if ( threadswitch_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("thread switch%s", threadswitch_re.cap(4).latin1()),
RUNCMD,
INFOCMD ), true );
} else if ( thread_re.search(cmd) >= 0 ) {
queueCmd(new RDBCommand( TQCString().sprintf("thread%s", thread_re.cap(2).latin1()),
NOTRUNCMD,
INFOCMD ), true );
} else if (cmd == "frame" || cmd == "f" || cmd == "where" || cmd == "w") {
queueCmd(new RDBCommand("where", NOTRUNCMD, INFOCMD), true);
} else if (cmd == "q" || cmd == "quit") {
slotStopDebugger();
return;
} else {
kdDebug(9012) << "Passing directly to rdb: " << cmd << endl;
queueCmd(new RDBCommand(cmd.latin1(), NOTRUNCMD, INFOCMD));
}
executeCmd();
}
}
// **************************************************************************
// **************************************************************************
// **************************************************************************
#include "rdbcontroller.moc"
|