eric6/Debugger/DebugViewer.py

branch
multi_processing
changeset 7379
72a72fd56494
parent 7377
cc920e534ac0
child 7389
770ffcb88be5
equal deleted inserted replaced
7377:cc920e534ac0 7379:72a72fd56494
60 super(DebugViewer, self).__init__(parent) 60 super(DebugViewer, self).__init__(parent)
61 61
62 self.debugServer = debugServer 62 self.debugServer = debugServer
63 self.debugUI = None 63 self.debugUI = None
64 64
65 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) 65 self.setWindowIcon(UI.PixmapCache.getIcon("eric"))
66 66
67 self.__mainLayout = QVBoxLayout() 67 self.__mainLayout = QVBoxLayout()
68 self.__mainLayout.setContentsMargins(0, 0, 0, 0) 68 self.__mainLayout.setContentsMargins(0, 0, 0, 0)
69 self.setLayout(self.__mainLayout) 69 self.setLayout(self.__mainLayout)
70 70
122 self.glvWidgetHLayout.addWidget(self.setGlobalsFilterButton) 122 self.glvWidgetHLayout.addWidget(self.setGlobalsFilterButton)
123 self.glvWidgetVLayout.addLayout(self.glvWidgetHLayout) 123 self.glvWidgetVLayout.addLayout(self.glvWidgetHLayout)
124 124
125 index = self.__tabWidget.addTab( 125 index = self.__tabWidget.addTab(
126 self.glvWidget, 126 self.glvWidget,
127 UI.PixmapCache.getIcon("globalVariables.png"), '') 127 UI.PixmapCache.getIcon("globalVariables"), '')
128 self.__tabWidget.setTabToolTip(index, self.globalsViewer.windowTitle()) 128 self.__tabWidget.setTabToolTip(index, self.globalsViewer.windowTitle())
129 129
130 self.setGlobalsFilterButton.clicked.connect( 130 self.setGlobalsFilterButton.clicked.connect(
131 self.setGlobalsFilter) 131 self.setGlobalsFilter)
132 self.globalsFilterEdit.returnPressed.connect(self.setGlobalsFilter) 132 self.globalsFilterEdit.returnPressed.connect(self.setGlobalsFilter)
176 self.lvWidgetHLayout2.addWidget(self.setLocalsFilterButton) 176 self.lvWidgetHLayout2.addWidget(self.setLocalsFilterButton)
177 self.lvWidgetVLayout.addLayout(self.lvWidgetHLayout2) 177 self.lvWidgetVLayout.addLayout(self.lvWidgetHLayout2)
178 178
179 index = self.__tabWidget.addTab( 179 index = self.__tabWidget.addTab(
180 self.lvWidget, 180 self.lvWidget,
181 UI.PixmapCache.getIcon("localVariables.png"), '') 181 UI.PixmapCache.getIcon("localVariables"), '')
182 self.__tabWidget.setTabToolTip(index, self.localsViewer.windowTitle()) 182 self.__tabWidget.setTabToolTip(index, self.localsViewer.windowTitle())
183 183
184 self.sourceButton.clicked.connect(self.__showSource) 184 self.sourceButton.clicked.connect(self.__showSource)
185 self.stackComboBox.currentIndexChanged[int].connect( 185 self.stackComboBox.currentIndexChanged[int].connect(
186 self.__frameSelected) 186 self.__frameSelected)
194 from .CallStackViewer import CallStackViewer 194 from .CallStackViewer import CallStackViewer
195 # add the call stack viewer 195 # add the call stack viewer
196 self.callStackViewer = CallStackViewer(self.debugServer) 196 self.callStackViewer = CallStackViewer(self.debugServer)
197 index = self.__tabWidget.addTab( 197 index = self.__tabWidget.addTab(
198 self.callStackViewer, 198 self.callStackViewer,
199 UI.PixmapCache.getIcon("step.png"), "") 199 UI.PixmapCache.getIcon("step"), "")
200 self.__tabWidget.setTabToolTip( 200 self.__tabWidget.setTabToolTip(
201 index, self.callStackViewer.windowTitle()) 201 index, self.callStackViewer.windowTitle())
202 self.callStackViewer.sourceFile.connect(self.sourceFile) 202 self.callStackViewer.sourceFile.connect(self.sourceFile)
203 self.callStackViewer.frameSelected.connect( 203 self.callStackViewer.frameSelected.connect(
204 self.__callStackFrameSelected) 204 self.__callStackFrameSelected)
205 205
206 from .CallTraceViewer import CallTraceViewer 206 from .CallTraceViewer import CallTraceViewer
207 # add the call trace viewer 207 # add the call trace viewer
208 self.callTraceViewer = CallTraceViewer(self.debugServer) 208 self.callTraceViewer = CallTraceViewer(self.debugServer, self)
209 index = self.__tabWidget.addTab( 209 index = self.__tabWidget.addTab(
210 self.callTraceViewer, 210 self.callTraceViewer,
211 UI.PixmapCache.getIcon("callTrace.png"), "") 211 UI.PixmapCache.getIcon("callTrace"), "")
212 self.__tabWidget.setTabToolTip( 212 self.__tabWidget.setTabToolTip(
213 index, self.callTraceViewer.windowTitle()) 213 index, self.callTraceViewer.windowTitle())
214 self.callTraceViewer.sourceFile.connect(self.sourceFile) 214 self.callTraceViewer.sourceFile.connect(self.sourceFile)
215 215
216 from .BreakPointViewer import BreakPointViewer 216 from .BreakPointViewer import BreakPointViewer
217 # add the breakpoint viewer 217 # add the breakpoint viewer
218 self.breakpointViewer = BreakPointViewer() 218 self.breakpointViewer = BreakPointViewer()
219 self.breakpointViewer.setModel(self.debugServer.getBreakPointModel()) 219 self.breakpointViewer.setModel(self.debugServer.getBreakPointModel())
220 index = self.__tabWidget.addTab( 220 index = self.__tabWidget.addTab(
221 self.breakpointViewer, 221 self.breakpointViewer,
222 UI.PixmapCache.getIcon("breakpoints.png"), '') 222 UI.PixmapCache.getIcon("breakpoints"), '')
223 self.__tabWidget.setTabToolTip( 223 self.__tabWidget.setTabToolTip(
224 index, self.breakpointViewer.windowTitle()) 224 index, self.breakpointViewer.windowTitle())
225 self.breakpointViewer.sourceFile.connect(self.sourceFile) 225 self.breakpointViewer.sourceFile.connect(self.sourceFile)
226 226
227 from .WatchPointViewer import WatchPointViewer 227 from .WatchPointViewer import WatchPointViewer
228 # add the watch expression viewer 228 # add the watch expression viewer
229 self.watchpointViewer = WatchPointViewer() 229 self.watchpointViewer = WatchPointViewer()
230 self.watchpointViewer.setModel(self.debugServer.getWatchPointModel()) 230 self.watchpointViewer.setModel(self.debugServer.getWatchPointModel())
231 index = self.__tabWidget.addTab( 231 index = self.__tabWidget.addTab(
232 self.watchpointViewer, 232 self.watchpointViewer,
233 UI.PixmapCache.getIcon("watchpoints.png"), '') 233 UI.PixmapCache.getIcon("watchpoints"), '')
234 self.__tabWidget.setTabToolTip( 234 self.__tabWidget.setTabToolTip(
235 index, self.watchpointViewer.windowTitle()) 235 index, self.watchpointViewer.windowTitle())
236 236
237 from .ExceptionLogger import ExceptionLogger 237 from .ExceptionLogger import ExceptionLogger
238 # add the exception logger 238 # add the exception logger
239 self.exceptionLogger = ExceptionLogger() 239 self.exceptionLogger = ExceptionLogger()
240 index = self.__tabWidget.addTab( 240 index = self.__tabWidget.addTab(
241 self.exceptionLogger, 241 self.exceptionLogger,
242 UI.PixmapCache.getIcon("exceptions.png"), '') 242 UI.PixmapCache.getIcon("exceptions"), '')
243 self.__tabWidget.setTabToolTip( 243 self.__tabWidget.setTabToolTip(
244 index, self.exceptionLogger.windowTitle()) 244 index, self.exceptionLogger.windowTitle())
245 245
246 self.__tabWidget.setCurrentWidget(self.glvWidget) 246 self.__tabWidget.setCurrentWidget(self.glvWidget)
247 247
276 self.showDebuggersList) 276 self.showDebuggersList)
277 self.debugServer.passiveDebugStarted.connect( 277 self.debugServer.passiveDebugStarted.connect(
278 self.handleDebuggingStarted) 278 self.handleDebuggingStarted)
279 self.debugServer.clientLine.connect( 279 self.debugServer.clientLine.connect(
280 self.__clientLine) 280 self.__clientLine)
281 self.debugServer.clientSyntaxError.connect(
282 self.__clientSyntaxError)
283 self.debugServer.clientException.connect(
284 self.__clientException)
281 285
282 self.debugServer.clientException.connect( 286 self.debugServer.clientException.connect(
283 self.exceptionLogger.addException) 287 self.exceptionLogger.addException)
284 self.debugServer.passiveDebugStarted.connect( 288 self.debugServer.passiveDebugStarted.connect(
285 self.exceptionLogger.debuggingStarted) 289 self.exceptionLogger.debuggingStarted)
430 """ 434 """
431 if debuggerId: 435 if debuggerId:
432 index = self.__debuggersCombo.findText(debuggerId, Qt.MatchExactly) 436 index = self.__debuggersCombo.findText(debuggerId, Qt.MatchExactly)
433 if index >= 0: 437 if index >= 0:
434 self.__debuggersCombo.setItemIcon( 438 self.__debuggersCombo.setItemIcon(
435 index, UI.PixmapCache.getIcon("exceptions.png")) 439 index, UI.PixmapCache.getIcon("exceptions"))
440
441 # TODO: Refactor the icon setting code into a method
442 def __clientSyntaxError(self, message, filename, lineNo, characterNo,
443 debuggerId):
444 """
445 Private method to handle a syntax error in the debugged program.
446
447 @param message message of the syntax error
448 @type str
449 @param filename translated filename of the syntax error position
450 @type str
451 @param lineNo line number of the syntax error position
452 @type int
453 @param characterNo character number of the syntax error position
454 @type int
455 @param debuggerId ID of the debugger backend
456 @type str
457 """
458 if debuggerId:
459 index = self.__debuggersCombo.findText(debuggerId, Qt.MatchExactly)
460 if index >= 0:
461 self.__debuggersCombo.setItemIcon(
462 index, UI.PixmapCache.getIcon("syntaxError22"))
463
464 def __clientException(self, exceptionType, exceptionMessage, stackTrace,
465 debuggerId):
466 """
467 Private method to handle an exception of the debugged program.
468
469 @param exceptionType type of exception raised
470 @type str
471 @param exceptionMessage message given by the exception
472 @type (str
473 @param stackTrace list of stack entries
474 @type list of str
475 @param debuggerId ID of the debugger backend
476 @type str
477 """
478 if debuggerId:
479 index = self.__debuggersCombo.findText(debuggerId, Qt.MatchExactly)
480 if index >= 0:
481 self.__debuggersCombo.setItemIcon(
482 index, UI.PixmapCache.getIcon("exceptions"))
436 483
437 def setVariablesFilter(self, globalsFilter, localsFilter): 484 def setVariablesFilter(self, globalsFilter, localsFilter):
438 """ 485 """
439 Public slot to set the local variables filter. 486 Public slot to set the local variables filter.
440 487
463 """ 510 """
464 if frmnr >= 0: 511 if frmnr >= 0:
465 self.framenr = frmnr 512 self.framenr = frmnr
466 if self.debugServer.isDebugging(): 513 if self.debugServer.isDebugging():
467 self.debugServer.remoteClientVariables( 514 self.debugServer.remoteClientVariables(
468 0, self.localsFilter, frmnr) 515 self.getSelectedDebuggerId(), 0, self.localsFilter, frmnr)
469 516
470 if self.__autoViewSource: 517 if self.__autoViewSource:
471 self.__showSource() 518 self.__showSource()
472 519
473 def setGlobalsFilter(self): 520 def setGlobalsFilter(self):
475 Public slot to set the global variable filter. 522 Public slot to set the global variable filter.
476 """ 523 """
477 if self.debugServer.isDebugging(): 524 if self.debugServer.isDebugging():
478 filterStr = self.globalsFilterEdit.text() 525 filterStr = self.globalsFilterEdit.text()
479 self.debugServer.remoteClientSetFilter(1, filterStr) 526 self.debugServer.remoteClientSetFilter(1, filterStr)
480 self.debugServer.remoteClientVariables(2, self.globalsFilter) 527 self.debugServer.remoteClientVariables(
528 self.getSelectedDebuggerId(), 2, self.globalsFilter)
481 529
482 def setLocalsFilter(self): 530 def setLocalsFilter(self):
483 """ 531 """
484 Public slot to set the local variable filter. 532 Public slot to set the local variable filter.
485 """ 533 """
486 if self.debugServer.isDebugging(): 534 if self.debugServer.isDebugging():
487 filterStr = self.localsFilterEdit.text() 535 filterStr = self.localsFilterEdit.text()
488 self.debugServer.remoteClientSetFilter(0, filterStr) 536 self.debugServer.remoteClientSetFilter(0, filterStr)
489 if self.currentStack: 537 if self.currentStack:
490 self.debugServer.remoteClientVariables( 538 self.debugServer.remoteClientVariables(
491 0, self.localsFilter, self.framenr) 539 self.getSelectedDebuggerId(), 0, self.localsFilter,
540 self.framenr)
492 541
493 def handleDebuggingStarted(self): 542 def handleDebuggingStarted(self):
494 """ 543 """
495 Public slot to handle the start of a debugging session. 544 Public slot to handle the start of a debugging session.
496 545
534 583
535 self.__threadList.clear() 584 self.__threadList.clear()
536 for thread in threadList: 585 for thread in threadList:
537 if thread.get('except', False): 586 if thread.get('except', False):
538 state = self.tr("waiting at exception") 587 state = self.tr("waiting at exception")
539 icon = "exceptions.png" 588 icon = "exceptions"
540 debugStatus = 1 589 debugStatus = 1
541 elif thread['broken']: 590 elif thread['broken']:
542 state = self.tr("waiting at breakpoint") 591 state = self.tr("waiting at breakpoint")
543 icon = "mediaPlaybackPause.png" 592 icon = "mediaPlaybackPause"
544 if debugStatus < 1: 593 if debugStatus < 1:
545 debugStatus = 0 594 debugStatus = 0
546 else: 595 else:
547 state = self.tr("running") 596 state = self.tr("running")
548 icon = "mediaPlaybackStart.png" 597 icon = "mediaPlaybackStart"
549 itm = QTreeWidgetItem(self.__threadList, 598 itm = QTreeWidgetItem(self.__threadList,
550 ["{0:d}".format(thread['id']), 599 ["{0:d}".format(thread['id']),
551 thread['name'], state]) 600 thread['name'], state])
552 itm.setIcon(0, UI.PixmapCache.getIcon(icon)) 601 itm.setIcon(0, UI.PixmapCache.getIcon(icon))
553 if thread['id'] == currentID: 602 if thread['id'] == currentID:
568 elif thread['broken']: 617 elif thread['broken']:
569 if debugStatus < 1: 618 if debugStatus < 1:
570 debugStatus = 0 619 debugStatus = 0
571 620
572 if debugStatus == -1: 621 if debugStatus == -1:
573 icon = "mediaPlaybackStart.png" 622 icon = "mediaPlaybackStart"
574 elif debugStatus == 0: 623 elif debugStatus == 0:
575 icon = "mediaPlaybackPause.png" 624 icon = "mediaPlaybackPause"
576 else: 625 else:
577 icon = "exceptions.png" 626 icon = "exceptions"
578 self.__debuggersCombo.setItemIcon(self.__debuggersCombo.currentIndex(), 627 self.__debuggersCombo.setItemIcon(self.__debuggersCombo.currentIndex(),
579 UI.PixmapCache.getIcon(icon)) 628 UI.PixmapCache.getIcon(icon))
580 629
581 def __threadSelected(self, current, previous): 630 def __threadSelected(self, current, previous):
582 """ 631 """
586 @param previous reference to the previous current item 635 @param previous reference to the previous current item
587 (QTreeWidgetItem) 636 (QTreeWidgetItem)
588 """ 637 """
589 if current is not None and self.__doThreadListUpdate: 638 if current is not None and self.__doThreadListUpdate:
590 tid = int(current.text(0)) 639 tid = int(current.text(0))
591 self.debugServer.remoteSetThread(tid) 640 self.debugServer.remoteSetThread(self.getSelectedDebuggerId(), tid)
592 641
593 def __callStackFrameSelected(self, frameNo): 642 def __callStackFrameSelected(self, frameNo):
594 """ 643 """
595 Private slot to handle the selection of a call stack entry of the 644 Private slot to handle the selection of a call stack entry of the
596 call stack viewer. 645 call stack viewer.

eric ide

mercurial