3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
8 #include <klocale.h> /* i18n */
12 #include <kiconloader.h>
13 #include <kstdaccel.h>
14 #include <kfiledialog.h>
17 #include <qfileinfo.h>
18 #include "dbgmainwnd.h"
21 #include "commandids.h"
24 #include "threadlist.h"
25 #include "memwindow.h"
30 DebuggerMainWnd::DebuggerMainWnd(const char* name
) :
34 setDockManager(new DockManager( this, QString(name
)+"_DockManager"));
38 DockWidget
* dw0
= createDockWidget("Source", p
);
39 dw0
->setCaption(i18n("Source"));
40 m_filesWindow
= new WinStack(dw0
, "files");
43 DockWidget
* dw1
= createDockWidget("Stack", p
);
44 dw1
->setCaption(i18n("Stack"));
45 m_btWindow
= new QListBox(dw1
, "backtrace");
46 DockWidget
* dw2
= createDockWidget("Locals", p
);
47 dw2
->setCaption(i18n("Locals"));
48 m_localVariables
= new ExprWnd(dw2
, "locals");
49 DockWidget
* dw3
= createDockWidget("Watches", p
);
50 dw3
->setCaption(i18n("Watches"));
51 m_watches
= new WatchWindow(dw3
, "watches");
52 DockWidget
* dw4
= createDockWidget("Registers", p
);
53 dw4
->setCaption(i18n("Registers"));
54 m_registers
= new RegisterView(dw4
, "registers");
55 DockWidget
* dw5
= createDockWidget("Breakpoints", p
);
56 dw5
->setCaption(i18n("Breakpoints"));
57 m_bpTable
= new BreakpointTable(dw5
, "breakpoints");
58 DockWidget
* dw6
= createDockWidget("Output", p
);
59 dw6
->setCaption(i18n("Output"));
60 m_ttyWindow
= new TTYWindow(dw6
, "output");
61 DockWidget
* dw7
= createDockWidget("Threads", p
);
62 dw7
->setCaption(i18n("Threads"));
63 m_threads
= new ThreadList(dw7
, "threads");
64 DockWidget
* dw8
= createDockWidget("Memory", p
);
65 dw8
->setCaption(i18n("Memory"));
66 m_memoryWindow
= new MemoryWindow(dw8
, "memory");
68 m_menuRecentExecutables
= new QPopupMenu();
73 setupDebugger(m_localVariables
, m_watches
->watchVariables(), m_btWindow
);
74 m_bpTable
->setDebugger(m_debugger
);
75 m_memoryWindow
->setDebugger(m_debugger
);
77 connect(m_watches
, SIGNAL(addWatch()), SLOT(slotAddWatch()));
78 connect(m_watches
, SIGNAL(deleteWatch()), m_debugger
, SLOT(slotDeleteWatch()));
80 m_filesWindow
->setWindowMenu(m_menuWindow
);
81 connect(&m_filesWindow
->m_findDlg
, SIGNAL(closed()), SLOT(updateUI()));
82 connect(m_filesWindow
, SIGNAL(newFileLoaded()),
83 SLOT(slotNewFileLoaded()));
84 connect(m_filesWindow
, SIGNAL(toggleBreak(const QString
&,int,const DbgAddr
&,bool)),
85 this, SLOT(slotToggleBreak(const QString
&,int,const DbgAddr
&,bool)));
86 connect(m_filesWindow
, SIGNAL(enadisBreak(const QString
&,int,const DbgAddr
&)),
87 this, SLOT(slotEnaDisBreak(const QString
&,int,const DbgAddr
&)));
88 connect(m_debugger
, SIGNAL(activateFileLine(const QString
&,int,const DbgAddr
&)),
89 m_filesWindow
, SLOT(activate(const QString
&,int,const DbgAddr
&)));
90 connect(m_debugger
, SIGNAL(executableUpdated()),
91 m_filesWindow
, SLOT(reloadAllFiles()));
92 connect(m_debugger
, SIGNAL(updatePC(const QString
&,int,const DbgAddr
&,int)),
93 m_filesWindow
, SLOT(updatePC(const QString
&,int,const DbgAddr
&,int)));
94 // value popup communication
95 connect(m_filesWindow
, SIGNAL(initiateValuePopup(const QString
&)),
96 m_debugger
, SLOT(slotValuePopup(const QString
&)));
97 connect(m_debugger
, SIGNAL(valuePopup(const QString
&)),
98 m_filesWindow
, SLOT(slotShowValueTip(const QString
&)));
100 connect(m_filesWindow
, SIGNAL(disassemble(const QString
&, int)),
101 m_debugger
, SLOT(slotDisassemble(const QString
&, int)));
102 connect(m_debugger
, SIGNAL(disassembled(const QString
&,int,const QList
<DisassembledCode
>&)),
103 m_filesWindow
, SLOT(slotDisassembled(const QString
&,int,const QList
<DisassembledCode
>&)));
105 connect(m_debugger
, SIGNAL(programStopped()), SLOT(slotProgramStopped()));
106 connect(&m_backTimer
, SIGNAL(timeout()), SLOT(slotBackTimer()));
108 connect(this, SIGNAL(setTabWidth(int)), m_filesWindow
, SIGNAL(setTabWidth(int)));
110 // Establish communication when right clicked on file window.
111 connect(&m_filesWindow
->m_menuFloat
, SIGNAL(activated(int)),
112 SLOT(menuCallback(int)));
114 // Connection when right clicked on file window before any file is
116 connect(&m_filesWindow
->m_menuFileFloat
, SIGNAL(activated(int)),
117 SLOT(menuCallback(int)));
119 // route unhandled menu items to winstack
120 connect(this, SIGNAL(forwardMenuCallback(int)), m_filesWindow
, SLOT(menuCallback(int)));
122 connect(m_filesWindow
, SIGNAL(fileChanged()), SLOT(slotFileChanged()));
123 connect(m_filesWindow
, SIGNAL(lineChanged()), SLOT(slotLineChanged()));
125 // connect breakpoint table
126 connect(m_bpTable
, SIGNAL(activateFileLine(const QString
&,int,const DbgAddr
&)),
127 m_filesWindow
, SLOT(activate(const QString
&,int,const DbgAddr
&)));
128 connect(m_debugger
, SIGNAL(updateUI()), m_bpTable
, SLOT(updateUI()));
129 connect(m_debugger
, SIGNAL(breakpointsChanged()), m_bpTable
, SLOT(updateBreakList()));
131 connect(m_debugger
, SIGNAL(registersChanged(QList
<RegisterInfo
>&)),
132 m_registers
, SLOT(updateRegisters(QList
<RegisterInfo
>&)));
134 connect(m_debugger
, SIGNAL(memoryDumpChanged(const QString
&, QList
<MemoryDump
>&)),
135 m_memoryWindow
, SLOT(slotNewMemoryDump(const QString
&, QList
<MemoryDump
>&)));
136 connect(m_debugger
, SIGNAL(saveProgramSpecific(KSimpleConfig
*)),
137 m_memoryWindow
, SLOT(saveProgramSpecific(KSimpleConfig
*)));
138 connect(m_debugger
, SIGNAL(restoreProgramSpecific(KSimpleConfig
*)),
139 m_memoryWindow
, SLOT(restoreProgramSpecific(KSimpleConfig
*)));
142 connect(m_debugger
, SIGNAL(threadsChanged(QList
<ThreadInfo
>&)),
143 m_threads
, SLOT(updateThreads(QList
<ThreadInfo
>&)));
144 connect(m_threads
, SIGNAL(setThread(int)),
145 m_debugger
, SLOT(setThread(int)));
147 // view menu changes when docking state changes
148 connect(dockManager
, SIGNAL(change()), SLOT(updateUI()));
150 // popup menu of the local variables window
151 m_popupLocals
= new QPopupMenu
;
152 m_popupLocals
->insertItem(i18n("Watch Expression"),
153 this, SLOT(slotLocalsToWatch()));
154 connect(m_localVariables
, SIGNAL(rightPressed(int, const QPoint
&)),
155 this, SLOT(slotLocalsPopup(int, const QPoint
&)));
157 restoreSettings(kapp
->getConfig());
159 connect(m_menuRecentExecutables
, SIGNAL(activated(int)), SLOT(slotRecentExec(int)));
160 fillRecentExecMenu();
163 m_bpTable
->updateUI();
167 DebuggerMainWnd::~DebuggerMainWnd()
169 saveSettings(kapp
->getConfig());
170 // must delete m_debugger early since it references our windows
173 // must disconnect from dockManager since it keeps emitting signals
174 dockManager
->disconnect(this);
176 delete m_memoryWindow
;
182 delete m_localVariables
;
184 delete m_filesWindow
;
188 delete m_menuProgram
;
193 void DebuggerMainWnd::initMenu()
195 m_menuFile
= new QPopupMenu
;
196 m_menuFile
->insertItem(i18n("&Open Source..."), ID_FILE_OPEN
);
197 m_menuFile
->insertItem(i18n("&Reload Source"), ID_FILE_RELOAD
);
198 m_menuFile
->insertSeparator();
199 m_menuFile
->insertItem(i18n("&Executable..."), ID_FILE_EXECUTABLE
);
200 m_menuFile
->insertItem(i18n("Recent E&xecutables"), m_menuRecentExecutables
);
201 m_menuFile
->insertItem(i18n("&Settings..."), ID_FILE_PROG_SETTINGS
);
202 m_menuFile
->insertItem(i18n("&Core dump..."), ID_FILE_COREFILE
);
203 m_menuFile
->insertSeparator();
204 m_menuFile
->insertItem(i18n("&Global Options..."), ID_FILE_GLOBAL_OPTIONS
);
205 m_menuFile
->insertSeparator();
206 m_menuFile
->insertItem(i18n("&Quit"), ID_FILE_QUIT
);
207 m_menuFile
->setAccel(keys
->open(), ID_FILE_OPEN
);
208 m_menuFile
->setAccel(keys
->quit(), ID_FILE_QUIT
);
210 m_menuView
= new QPopupMenu
;
211 m_menuView
->setCheckable(true);
212 m_menuView
->insertItem(i18n("&Find..."), ID_VIEW_FINDDLG
);
213 m_menuView
->insertSeparator();
214 i18n("Source &code");
215 m_menuView
->insertItem(i18n("Stac&k"), ID_VIEW_STACK
);
216 m_menuView
->insertItem(i18n("&Locals"), ID_VIEW_LOCALS
);
217 m_menuView
->insertItem(i18n("&Watched expressions"), ID_VIEW_WATCHES
);
218 m_menuView
->insertItem(i18n("&Registers"), ID_VIEW_REGISTERS
);
219 m_menuView
->insertItem(i18n("&Breakpoints"), ID_BRKPT_LIST
);
220 m_menuView
->insertItem(i18n("T&hreads"), ID_VIEW_THREADS
);
221 m_menuView
->insertItem(i18n("&Output"), ID_VIEW_OUTPUT
);
222 m_menuView
->insertItem(i18n("&Memory"), ID_VIEW_MEMORY
);
223 m_menuView
->insertSeparator();
224 m_menuView
->insertItem(i18n("Toggle &Toolbar"), ID_VIEW_TOOLBAR
);
225 m_menuView
->insertItem(i18n("Toggle &Statusbar"), ID_VIEW_STATUSBAR
);
226 m_menuView
->setAccel(keys
->find(), ID_VIEW_FINDDLG
);
228 m_menuProgram
= new QPopupMenu
;
229 m_menuProgram
->insertItem(i18n("&Run"), ID_PROGRAM_RUN
);
230 m_menuProgram
->insertItem(i18n("Step &into"), ID_PROGRAM_STEP
);
231 m_menuProgram
->insertItem(i18n("Step &over"), ID_PROGRAM_NEXT
);
232 m_menuProgram
->insertItem(i18n("Step o&ut"), ID_PROGRAM_FINISH
);
233 m_menuProgram
->insertItem(i18n("Run to &cursor"), ID_PROGRAM_UNTIL
);
234 m_menuProgram
->insertItem(i18n("Step i&nto by instruction"), ID_PROGRAM_STEPI
);
235 m_menuProgram
->insertItem(i18n("Step o&ver by instruction"), ID_PROGRAM_NEXTI
);
236 m_menuProgram
->insertSeparator();
237 m_menuProgram
->insertItem(i18n("&Break"), ID_PROGRAM_BREAK
);
238 m_menuProgram
->insertItem(i18n("&Kill"), ID_PROGRAM_KILL
);
239 m_menuProgram
->insertItem(i18n("Re&start"), ID_PROGRAM_RUN_AGAIN
);
240 m_menuProgram
->insertItem(i18n("A&ttach..."), ID_PROGRAM_ATTACH
);
241 m_menuProgram
->insertSeparator();
242 m_menuProgram
->insertItem(i18n("&Arguments..."), ID_PROGRAM_ARGS
);
243 m_menuProgram
->setAccel(Key_F5
, ID_PROGRAM_RUN
);
244 m_menuProgram
->setAccel(Key_F8
, ID_PROGRAM_STEP
);
245 m_menuProgram
->setAccel(SHIFT
+Key_F8
, ID_PROGRAM_STEPI
);
246 m_menuProgram
->setAccel(Key_F10
, ID_PROGRAM_NEXT
);
247 m_menuProgram
->setAccel(SHIFT
+Key_F10
, ID_PROGRAM_NEXTI
);
248 m_menuProgram
->setAccel(Key_F6
, ID_PROGRAM_FINISH
);
249 m_menuProgram
->setAccel(Key_F7
, ID_PROGRAM_UNTIL
);
251 m_menuBrkpt
= new QPopupMenu
;
252 m_menuBrkpt
->insertItem(i18n("Set/Clear &breakpoint"), ID_BRKPT_SET
);
253 m_menuBrkpt
->insertItem(i18n("Set &temporary breakpoint"), ID_BRKPT_TEMP
);
254 m_menuBrkpt
->insertItem(i18n("&Enable/Disable breakpoint"), ID_BRKPT_ENABLE
);
255 m_menuBrkpt
->setAccel(Key_F9
, ID_BRKPT_SET
);
256 m_menuBrkpt
->setAccel(SHIFT
+Key_F9
, ID_BRKPT_TEMP
);
257 m_menuBrkpt
->setAccel(CTRL
+Key_F9
, ID_BRKPT_ENABLE
);
259 m_menuWindow
= new QPopupMenu
;
260 m_menuWindow
->insertItem(i18n("&More..."), ID_WINDOW_MORE
);
262 connect(m_menuFile
, SIGNAL(activated(int)), SLOT(menuCallback(int)));
263 connect(m_menuView
, SIGNAL(activated(int)), SLOT(menuCallback(int)));
264 connect(m_menuProgram
, SIGNAL(activated(int)), SLOT(menuCallback(int)));
265 connect(m_menuBrkpt
, SIGNAL(activated(int)), SLOT(menuCallback(int)));
266 connect(m_menuWindow
, SIGNAL(activated(int)), SLOT(menuCallback(int)));
268 KMenuBar
* menu
= menuBar();
269 menu
->insertItem(i18n("&File"), m_menuFile
);
270 menu
->insertItem(i18n("&View"), m_menuView
);
271 menu
->insertItem(i18n("E&xecution"), m_menuProgram
);
272 menu
->insertItem(i18n("&Breakpoint"), m_menuBrkpt
);
273 menu
->insertItem(i18n("&Window"), m_menuWindow
);
277 static QPixmap
BarIcon(const char* name
)
279 return kapp
->getIconLoader()->loadIcon(name
);
283 void DebuggerMainWnd::initToolbar()
285 KToolBar
* toolbar
= toolBar();
286 toolbar
->insertButton(BarIcon("execopen.xpm"),ID_FILE_EXECUTABLE
, true,
288 toolbar
->insertButton(BarIcon("fileopen.xpm"),ID_FILE_OPEN
, true,
289 i18n("Open a source file"));
290 toolbar
->insertButton(BarIcon("reload.xpm"),ID_FILE_RELOAD
, true,
291 i18n("Reload source file"));
292 toolbar
->insertSeparator();
293 toolbar
->insertButton(BarIcon("pgmrun.xpm"),ID_PROGRAM_RUN
, true,
294 i18n("Run/Continue"));
295 toolbar
->insertButton(BarIcon("pgmstep.xpm"),ID_PROGRAM_STEP
, true,
297 toolbar
->insertButton(BarIcon("pgmnext.xpm"),ID_PROGRAM_NEXT
, true,
299 toolbar
->insertButton(BarIcon("pgmfinish.xpm"),ID_PROGRAM_FINISH
, true,
301 toolbar
->insertButton(BarIcon("pgmstepi.xpm"),ID_PROGRAM_STEPI
, true,
302 i18n("Step into by instruction"));
303 toolbar
->insertButton(BarIcon("pgmnexti.xpm"),ID_PROGRAM_NEXTI
, true,
304 i18n("Step over by instruction"));
305 toolbar
->insertSeparator();
306 toolbar
->insertButton(BarIcon("brkpt.xpm"),ID_BRKPT_SET
, true,
308 toolbar
->insertSeparator();
309 toolbar
->insertButton(BarIcon("search.xpm"),ID_VIEW_FINDDLG
, true,
312 connect(toolbar
, SIGNAL(clicked(int)), SLOT(menuCallback(int)));
313 toolbar
->setBarPos(KToolBar::Top
);
317 KStatusBar
* statusbar
= statusBar();
318 statusbar
->insertItem(m_statusActive
, ID_STATUS_ACTIVE
);
319 m_lastActiveStatusText
= m_statusActive
;
320 statusbar
->insertItem(i18n("Line 00000"), ID_STATUS_LINENO
);
321 statusbar
->insertItem("", ID_STATUS_MSG
); /* message pane */
323 // reserve some translations
329 * We must override KTMainWindow's handling of close events since we have
330 * only one toplevel window, which lives on the stack (which KTMainWindow
331 * can't live with :-( )
333 void DebuggerMainWnd::closeEvent(QCloseEvent
* e
)
335 #if QT_VERSION >= 200
336 clearWFlags(WDestructiveClose
);
339 if (m_debugger
!= 0) {
340 m_debugger
->shutdown();
348 // instance properties
349 void DebuggerMainWnd::saveProperties(KConfig
* config
)
351 // session management
352 QString executable
= "";
353 if (m_debugger
!= 0) {
354 executable
= m_debugger
->executable();
356 config
->writeEntry("executable", executable
);
359 void DebuggerMainWnd::readProperties(KConfig
* config
)
361 // session management
362 QString execName
= config
->readEntry("executable");
364 TRACE("readProperties: executable=" + execName
);
365 if (!execName
.isEmpty()) {
366 debugProgram(execName
);
370 const char WindowGroup
[] = "Windows";
372 void DebuggerMainWnd::saveSettings(KConfig
* config
)
374 KConfigGroupSaver
g(config
, WindowGroup
);
376 writeDockConfig(config
);
378 DebuggerMainWndBase::saveSettings(config
);
381 void DebuggerMainWnd::restoreSettings(KConfig
* config
)
383 KConfigGroupSaver
g(config
, WindowGroup
);
385 readDockConfig(config
);
387 DebuggerMainWndBase::restoreSettings(config
);
389 emit
setTabWidth(m_tabWidth
);
392 void DebuggerMainWnd::menuCallback(int item
)
397 QString fileName
= myGetFileName(i18n("Open"),
399 makeSourceFilter(), this);
401 if (!fileName
.isEmpty())
403 QFileInfo
fi(fileName
);
404 m_lastDirectory
= fi
.dirPath();
405 m_filesWindow
->setExtraDirectory(m_lastDirectory
);
406 m_filesWindow
->activateFile(fileName
);
411 if (m_debugger
!= 0) {
412 m_debugger
->shutdown();
416 case ID_VIEW_TOOLBAR
:
419 case ID_VIEW_STATUSBAR
:
422 case ID_PROGRAM_UNTIL
:
427 if (m_filesWindow
->activeLine(file
, lineNo
))
428 m_debugger
->runUntil(file
, lineNo
);
432 showhideWindow(m_bpTable
);
435 showhideWindow(m_filesWindow
);
438 showhideWindow(m_btWindow
);
441 showhideWindow(m_localVariables
);
443 case ID_VIEW_WATCHES
:
444 showhideWindow(m_watches
);
446 case ID_VIEW_REGISTERS
:
447 showhideWindow(m_registers
);
449 case ID_VIEW_THREADS
:
450 showhideWindow(m_threads
);
453 showhideWindow(m_memoryWindow
);
456 showhideWindow(m_ttyWindow
);
459 // forward all others
460 if (!handleCommand(item
))
461 emit
forwardMenuCallback(item
);
462 else if (item
== ID_FILE_EXECUTABLE
) {
463 // special: this may have changed m_lastDirectory
464 m_filesWindow
->setExtraDirectory(m_lastDirectory
);
465 fillRecentExecMenu();
467 // start timer to move window into background
469 case ID_PROGRAM_STEP
:
470 case ID_PROGRAM_STEPI
:
471 case ID_PROGRAM_NEXT
:
472 case ID_PROGRAM_NEXTI
:
473 case ID_PROGRAM_FINISH
:
474 case ID_PROGRAM_UNTIL
:
485 void DebuggerMainWnd::updateUI()
487 // enumerate all menus
489 UpdateMenuUI
updateMenu(m_menuFile
, this, SLOT(updateUIItem(UpdateUI
*)));
490 updateMenu
.iterateMenu();
493 UpdateMenuUI
updateMenu(m_menuView
, this, SLOT(updateUIItem(UpdateUI
*)));
494 updateMenu
.iterateMenu();
497 UpdateMenuUI
updateMenu(m_menuProgram
, this, SLOT(updateUIItem(UpdateUI
*)));
498 updateMenu
.iterateMenu();
501 UpdateMenuUI
updateMenu(m_menuBrkpt
, this, SLOT(updateUIItem(UpdateUI
*)));
502 updateMenu
.iterateMenu();
505 // Update winstack float popup items
507 UpdateMenuUI
updateMenu(&m_filesWindow
->m_menuFloat
, this,
508 SLOT(updateUIItem(UpdateUI
*)));
509 updateMenu
.iterateMenu();
512 // Update winstack float file popup items
514 UpdateMenuUI
updateMenu(&m_filesWindow
->m_menuFileFloat
, this,
515 SLOT(updateUIItem(UpdateUI
*)));
516 updateMenu
.iterateMenu();
520 static const int toolIds
[] = {
521 ID_PROGRAM_RUN
, ID_PROGRAM_STEP
, ID_PROGRAM_NEXT
, ID_PROGRAM_FINISH
,
522 ID_PROGRAM_STEPI
, ID_PROGRAM_NEXTI
,
525 UpdateToolbarUI
updateToolbar(toolBar(), this, SLOT(updateUIItem(UpdateUI
*)),
526 toolIds
, sizeof(toolIds
)/sizeof(toolIds
[0]));
527 updateToolbar
.iterateToolbar();
531 if (m_debugger
->isProgramActive())
532 newStatus
= m_statusActive
;
533 if (newStatus
!= m_lastActiveStatusText
) {
534 statusBar()->changeItem(newStatus
, ID_STATUS_ACTIVE
);
535 m_lastActiveStatusText
= newStatus
;
537 // line number is updated in slotLineChanged
540 void DebuggerMainWnd::dockUpdateHelper(UpdateUI
* item
, QWidget
* w
)
542 if (canChangeDockVisibility(w
)) {
544 item
->setCheck(isDockVisible(w
));
547 item
->setCheck(false);
551 void DebuggerMainWnd::updateUIItem(UpdateUI
* item
)
554 case ID_VIEW_FINDDLG
:
555 item
->setCheck(m_filesWindow
->m_findDlg
.isVisible());
559 item
->enable(m_debugger
->canChangeBreakpoints());
561 case ID_BRKPT_ENABLE
:
562 item
->enable(m_debugger
->canChangeBreakpoints());
565 dockUpdateHelper(item
, m_bpTable
);
568 dockUpdateHelper(item
, m_filesWindow
);
571 dockUpdateHelper(item
, m_btWindow
);
574 dockUpdateHelper(item
, m_localVariables
);
576 case ID_VIEW_WATCHES
:
577 dockUpdateHelper(item
, m_watches
);
579 case ID_VIEW_REGISTERS
:
580 dockUpdateHelper(item
, m_registers
);
582 case ID_VIEW_THREADS
:
583 dockUpdateHelper(item
, m_threads
);
586 dockUpdateHelper(item
, m_memoryWindow
);
589 dockUpdateHelper(item
, m_ttyWindow
);
592 DebuggerMainWndBase::updateUIItem(item
);
597 void DebuggerMainWnd::updateLineItems()
599 m_filesWindow
->updateLineItems(m_debugger
);
602 void DebuggerMainWnd::slotAddWatch()
604 if (m_debugger
!= 0) {
605 QString t
= m_watches
->watchText();
606 m_debugger
->addWatch(t
);
610 void DebuggerMainWnd::slotFileChanged()
614 QString caption
= kapp
->getCaption();
618 if (m_debugger
->haveExecutable()) {
619 // basename part of executable
620 QString executable
= m_debugger
->executable();
621 const char* execBase
= executable
.data();
622 int lastSlash
= executable
.findRev('/');
624 execBase
+= lastSlash
+ 1;
632 bool anyWindows
= m_filesWindow
->activeLine(file
, line
);
633 updateLineStatus(anyWindows
? line
: -1);
642 void DebuggerMainWnd::slotLineChanged()
646 bool anyWindows
= m_filesWindow
->activeLine(file
, line
);
647 updateLineStatus(anyWindows
? line
: -1);
650 void DebuggerMainWnd::slotNewFileLoaded()
652 // updates program counter in the new file
654 m_filesWindow
->updateLineItems(m_debugger
);
657 void DebuggerMainWnd::updateLineStatus(int lineNo
)
660 statusBar()->changeItem("", ID_STATUS_LINENO
);
663 strLine
.sprintf(i18n("Line %d"), lineNo
+ 1);
664 statusBar()->changeItem(strLine
, ID_STATUS_LINENO
);
668 DockWidget
* DebuggerMainWnd::dockParent(QWidget
* w
)
670 while ((w
= w
->parentWidget()) != 0) {
671 if (w
->isA("DockWidget"))
672 return static_cast<DockWidget
*>(w
);
677 bool DebuggerMainWnd::isDockVisible(QWidget
* w
)
679 DockWidget
* d
= dockParent(w
);
680 return d
!= 0 && d
->mayBeHide();
683 bool DebuggerMainWnd::canChangeDockVisibility(QWidget
* w
)
685 DockWidget
* d
= dockParent(w
);
686 return d
!= 0 && (d
->mayBeHide() || d
->mayBeShow());
689 void DebuggerMainWnd::showhideWindow(QWidget
* w
)
691 DockWidget
* d
= dockParent(w
);
693 TRACE(QString("no dockParent found: ") + d
->name());
696 d
->changeHideShowState();
700 KToolBar
* DebuggerMainWnd::dbgToolBar()
705 KStatusBar
* DebuggerMainWnd::dbgStatusBar()
710 QWidget
* DebuggerMainWnd::dbgMainWnd()
715 TTYWindow
* DebuggerMainWnd::ttyWindow()
720 void DebuggerMainWnd::slotNewStatusMsg()
722 DebuggerMainWndBase::slotNewStatusMsg();
725 void DebuggerMainWnd::slotAnimationTimeout()
727 DebuggerMainWndBase::slotAnimationTimeout();
730 void DebuggerMainWnd::doGlobalOptions()
732 int oldTabWidth
= m_tabWidth
;
734 DebuggerMainWndBase::doGlobalOptions();
736 if (m_tabWidth
!= oldTabWidth
) {
737 emit
setTabWidth(m_tabWidth
);
741 void DebuggerMainWnd::slotDebuggerStarting()
743 DebuggerMainWndBase::slotDebuggerStarting();
746 void DebuggerMainWnd::slotToggleBreak(const QString
& fileName
, int lineNo
,
747 const DbgAddr
& address
, bool temp
)
749 // lineNo is zero-based
750 if (m_debugger
!= 0) {
751 m_debugger
->setBreakpoint(fileName
, lineNo
, address
, temp
);
755 void DebuggerMainWnd::slotEnaDisBreak(const QString
& fileName
, int lineNo
,
756 const DbgAddr
& address
)
758 // lineNo is zero-based
759 if (m_debugger
!= 0) {
760 m_debugger
->enableDisableBreakpoint(fileName
, lineNo
, address
);
764 QString
DebuggerMainWnd::createOutputWindow()
766 QString tty
= DebuggerMainWndBase::createOutputWindow();
767 if (!tty
.isEmpty()) {
768 connect(m_outputTermProc
, SIGNAL(processExited(KProcess
*)),
769 SLOT(slotTermEmuExited()));
774 void DebuggerMainWnd::slotTermEmuExited()
776 shutdownTermWindow();
779 #include <X11/Xlib.h> /* XRaiseWindow, XLowerWindow */
781 void DebuggerMainWnd::slotProgramStopped()
783 // when the program stopped, move the window to the foreground
784 if (m_popForeground
) {
785 ::XRaiseWindow(x11Display(), winId());
790 void DebuggerMainWnd::intoBackground()
792 m_backTimer
.start(m_backTimeout
, true); /* single-shot */
795 void DebuggerMainWnd::slotBackTimer()
797 ::XLowerWindow(x11Display(), winId());
800 void DebuggerMainWnd::slotRecentExec(int item
)
802 if (item
>= 0 && item
< int(m_recentExecList
.count())) {
803 QString exe
= m_recentExecList
.at(item
);
804 if (debugProgramInteractive(exe
)) {
807 removeRecentExec(exe
);
809 fillRecentExecMenu();
813 void DebuggerMainWnd::fillRecentExecMenu()
815 m_menuRecentExecutables
->clear();
816 for (uint i
= 0; i
< m_recentExecList
.count(); i
++) {
817 m_menuRecentExecutables
->insertItem(m_recentExecList
.at(i
), i
);
821 QString
DebuggerMainWnd::makeSourceFilter()
824 f
= m_sourceFilter
+ " " + m_headerFilter
+ i18n("|All source files\n");
825 f
+= m_sourceFilter
+ i18n("|Source files\n");
826 f
+= m_headerFilter
+ i18n("|Header files\n");
827 f
+= i18n("*|All files");
832 * Pop up the context menu in the locals window
834 void DebuggerMainWnd::slotLocalsPopup(int, const QPoint
& pt
)
836 if (m_popupLocals
->isVisible()) {
837 m_popupLocals
->hide();
839 m_popupLocals
->popup(m_localVariables
->mapToGlobal(pt
));
844 * Copies the currently selected item to the watch window.
846 void DebuggerMainWnd::slotLocalsToWatch()
848 int idx
= m_localVariables
->currentItem();
850 if (idx
>= 0 && m_debugger
!= 0) {
851 QString text
= m_localVariables
->exprStringAt(idx
);
852 m_debugger
->addWatch(text
);
857 #include "dbgmainwnd.moc"