Added a framework to specify different debugger drivers on the command line.
[kdbg.git] / kdbg / mainwndbase.h
blobca08710156b2de1ea308bc4c6f74679f71165feb
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #ifndef MAINWNDBASE_H
7 #define MAINWNDBASE_H
9 #include <qlineedit.h>
10 #include <qlayout.h>
11 #include <qpushbutton.h>
12 #include <qcstring.h>
13 #include "exprwnd.h"
14 #include "sys/types.h" /* pid_t */
16 // forward declarations
17 class KDebugger;
18 class TTYWindow;
19 class UpdateUI;
20 class KToolBar;
21 class KStatusBar;
22 class KProcess;
23 class DebuggerDriver;
25 class WatchWindow : public QWidget
27 Q_OBJECT
28 public:
29 WatchWindow(QWidget* parent, const char* name, WFlags f = 0);
30 ~WatchWindow();
31 ExprWnd* watchVariables() { return &m_watchVariables; }
32 QString watchText() const { return m_watchEdit.text(); }
34 protected:
35 QLineEdit m_watchEdit;
36 QPushButton m_watchAdd;
37 QPushButton m_watchDelete;
38 ExprWnd m_watchVariables;
39 QVBoxLayout m_watchV;
40 QHBoxLayout m_watchH;
42 virtual bool eventFilter(QObject* ob, QEvent* ev);
44 signals:
45 void addWatch();
46 void deleteWatch();
48 protected slots:
49 void slotWatchHighlighted(int);
53 class DebuggerMainWndBase
55 public:
56 DebuggerMainWndBase();
57 virtual ~DebuggerMainWndBase();
59 /**
60 * Sets the command to invoke the terminal that displays the program
61 * output. If cmd is the empty string, the default is substituted.
63 void setTerminalCmd(const QString& cmd);
64 /**
65 * Sets the command to invoke the debugger.
67 void setDebuggerCmdStr(const QString& cmd);
68 /**
69 * Specifies the file where to write the transcript.
71 void setTranscript(const char* name);
73 // the following are needed to handle program arguments
74 bool debugProgram(const QString& executable, QWidget* parent);
75 void setCoreFile(const QString& corefile);
76 void setRemoteDevice(const QString &remoteDevice);
77 void setLanguage(const QCString& lang);
78 /** helper around KFileDialog */
79 static QString myGetFileName(QString caption,
80 QString dir, QString filter,
81 QWidget* parent);
82 /** invokes the global options dialog */
83 virtual void doGlobalOptions(QWidget* parent);
84 /** add recent executable; moves it to top of list if present */
85 void addRecentExec(const QString& executable);
86 /** remove recent executable */
87 void removeRecentExec(const QString& executable);
88 /** start a new session; error popups appear on errors */
89 bool debugProgramInteractive(const QString& executable, QWidget* parent);
91 protected:
92 // settings
93 virtual void saveSettings(KConfig*);
94 virtual void restoreSettings(KConfig*);
96 // override must return the toolbar containing the animation and
97 // buttons to update
98 virtual KToolBar* dbgToolBar() = 0;
99 // override must return the statusbar
100 virtual KStatusBar* dbgStatusBar() = 0;
101 // override must return the integrated output window
102 virtual TTYWindow* ttyWindow() = 0;
104 // statusbar texts
105 QString m_statusActive;
107 // animated button
108 QList<QPixmap> m_animation;
109 uint m_animationCounter;
110 void initAnimation();
112 // output window
113 QString m_outputTermCmdStr;
114 QString m_outputTermKeepScript;
115 KProcess* m_outputTermProc;
116 int m_ttyLevel;
117 virtual QString createOutputWindow(); /* returns terminal name */
118 void shutdownTermWindow();
120 QString m_lastDirectory; /* the dir of the most recently opened file */
122 QString m_transcriptFile; /* where gdb dialog is logged */
124 bool m_popForeground; /* whether main wnd raises when prog stops */
125 int m_backTimeout; /* when wnd goes back */
126 int m_tabWidth; /* tab width in characters (can be 0) */
127 QString m_sourceFilter;
128 QString m_headerFilter;
130 // recent execs in File menu
131 QStrList m_recentExecList;
133 // the debugger proper
134 QString m_debuggerCmdStr;
135 KDebugger* m_debugger;
136 void setupDebugger(QWidget* parent,
137 ExprWnd* localVars,
138 ExprWnd* watchVars,
139 QListBox* backtrace);
140 // which language are we debugging?
141 QCString m_language;
142 static DebuggerDriver* driverFromLang(const QCString& lang);
144 public:
146 * Important! The following functions must be overridden in derived
147 * classes and be declared as slots! Note: These must not be declared
148 * virtual here since Qt signal mechanism fails miserably (because this
149 * class will not be the left-most base class!).
151 void updateUIItem(UpdateUI* item);
152 void updateLineItems();
153 void slotNewStatusMsg();
154 void slotAnimationTimeout();
155 void slotDebuggerStarting();
158 #endif // MAINWNDBASE_H