Debugger/DebugUI.py

changeset 3032
927a2f8b3669
parent 3021
801289962f4e
child 3060
5883ce99ee12
child 3156
86a6528fea9f
equal deleted inserted replaced
3031:ed2eaa573ca5 3032:927a2f8b3669
970 self.debugProjectAct.setEnabled(self.projectOpen) 970 self.debugProjectAct.setEnabled(self.projectOpen)
971 self.runProjectAct.setEnabled(self.projectOpen) 971 self.runProjectAct.setEnabled(self.projectOpen)
972 self.profileProjectAct.setEnabled(self.projectOpen) 972 self.profileProjectAct.setEnabled(self.projectOpen)
973 self.coverageProjectAct.setEnabled(self.projectOpen) 973 self.coverageProjectAct.setEnabled(self.projectOpen)
974 if self.lastDebuggedFile is not None and \ 974 if self.lastDebuggedFile is not None and \
975 (self.editorOpen or self.projectOpen): 975 (self.editorOpen or self.projectOpen):
976 self.restartAct.setEnabled(True) 976 self.restartAct.setEnabled(True)
977 else: 977 else:
978 self.restartAct.setEnabled(False) 978 self.restartAct.setEnabled(False)
979 self.stopAct.setEnabled(False) 979 self.stopAct.setEnabled(False)
980 self.resetUI.emit() 980 self.resetUI.emit()
1025 msg = self.trUtf8('The program has terminated with an exit' 1025 msg = self.trUtf8('The program has terminated with an exit'
1026 ' status of {0}.').format(status) 1026 ' status of {0}.').format(status)
1027 else: 1027 else:
1028 msg = self.trUtf8('"{0}" has terminated with an exit' 1028 msg = self.trUtf8('"{0}" has terminated with an exit'
1029 ' status of {1}.')\ 1029 ' status of {1}.')\
1030 .format(os.path.basename(self.ui.currentProg), 1030 .format(os.path.basename(self.ui.currentProg),
1031 status) 1031 status)
1032 self.ui.showNotification( 1032 self.ui.showNotification(
1033 UI.PixmapCache.getPixmap("debug48.png"), 1033 UI.PixmapCache.getPixmap("debug48.png"),
1034 self.trUtf8("Program terminated"), msg) 1034 self.trUtf8("Program terminated"), msg)
1035 else: 1035 else:
1036 if self.ui.currentProg is None: 1036 if self.ui.currentProg is None:
1101 self.ui, Program, 1101 self.ui, Program,
1102 self.trUtf8('An unhandled exception occured.' 1102 self.trUtf8('An unhandled exception occured.'
1103 ' See the shell window for details.')) 1103 ' See the shell window for details.'))
1104 return 1104 return
1105 1105
1106 if (self.exceptions and \ 1106 if (self.exceptions and
1107 exceptionType not in self.excIgnoreList and \ 1107 exceptionType not in self.excIgnoreList and
1108 (not len(self.excList) or \ 1108 (not len(self.excList) or
1109 (len(self.excList) and exceptionType in self.excList)))\ 1109 (len(self.excList) and exceptionType in self.excList)))\
1110 or exceptionType.startswith('unhandled'): 1110 or exceptionType.startswith('unhandled'):
1111 res = None 1111 res = None
1112 if stackTrace: 1112 if stackTrace:
1113 try: 1113 try:
1128 res = E5MessageBox.Yes 1128 res = E5MessageBox.Yes
1129 else: 1129 else:
1130 if stackTrace: 1130 if stackTrace:
1131 if exceptionType.startswith('unhandled'): 1131 if exceptionType.startswith('unhandled'):
1132 buttons = E5MessageBox.StandardButtons( 1132 buttons = E5MessageBox.StandardButtons(
1133 E5MessageBox.No | \ 1133 E5MessageBox.No |
1134 E5MessageBox.Yes) 1134 E5MessageBox.Yes)
1135 else: 1135 else:
1136 buttons = E5MessageBox.StandardButtons( 1136 buttons = E5MessageBox.StandardButtons(
1137 E5MessageBox.No | \ 1137 E5MessageBox.No |
1138 E5MessageBox.Yes | \ 1138 E5MessageBox.Yes |
1139 E5MessageBox.Ignore) 1139 E5MessageBox.Ignore)
1140 res = E5MessageBox.critical( 1140 res = E5MessageBox.critical(
1141 self.ui, Program, 1141 self.ui, Program,
1142 self.trUtf8( 1142 self.trUtf8(
1143 '<p>The debugged program raised the exception' 1143 '<p>The debugged program raised the exception'
1144 ' <b>{0}</b><br>"<b>{1}</b>"<br>' 1144 ' <b>{0}</b><br>"<b>{1}</b>"<br>'
1145 'File: <b>{2}</b>, Line: <b>{3}</b></p>' 1145 'File: <b>{2}</b>, Line: <b>{3}</b></p>'
1146 '<p>Break here?</p>') 1146 '<p>Break here?</p>')
1147 .format( 1147 .format(
1148 exceptionType, 1148 exceptionType,
1149 Utilities.html_encode(exceptionMessage), 1149 Utilities.html_encode(exceptionMessage),
1150 stackTrace[0][0], 1150 stackTrace[0][0],
1151 stackTrace[0][1]), 1151 stackTrace[0][1]),
1152 buttons, 1152 buttons,
1153 E5MessageBox.No) 1153 E5MessageBox.No)
1154 else: 1154 else:
1155 res = E5MessageBox.critical( 1155 res = E5MessageBox.critical(
1156 self.ui, Program, 1156 self.ui, Program,
1157 self.trUtf8( 1157 self.trUtf8(
1158 '<p>The debugged program raised the exception' 1158 '<p>The debugged program raised the exception'
1159 ' <b>{0}</b><br>"<b>{1}</b>"</p>') 1159 ' <b>{0}</b><br>"<b>{1}</b>"</p>')
1160 .format( 1160 .format(
1161 exceptionType, 1161 exceptionType,
1162 Utilities.html_encode(exceptionMessage))) 1162 Utilities.html_encode(exceptionMessage)))
1163 if res == E5MessageBox.Yes: 1163 if res == E5MessageBox.Yes:
1164 self.exceptionInterrupt.emit() 1164 self.exceptionInterrupt.emit()
1165 stack = [] 1165 stack = []
1166 for fn, ln, func, args in stackTrace: 1166 for fn, ln, func, args in stackTrace:
1167 stack.append((fn, ln, func, args)) 1167 stack.append((fn, ln, func, args))
1265 E5MessageBox.critical( 1265 E5MessageBox.critical(
1266 self.ui, 1266 self.ui,
1267 self.trUtf8("Breakpoint Condition Error"), 1267 self.trUtf8("Breakpoint Condition Error"),
1268 self.trUtf8( 1268 self.trUtf8(
1269 """<p>The condition of the breakpoint <b>{0}, {1}</b>""" 1269 """<p>The condition of the breakpoint <b>{0}, {1}</b>"""
1270 """ contains a syntax error.</p>""")\ 1270 """ contains a syntax error.</p>""")
1271 .format(filename, lineno)) 1271 .format(filename, lineno))
1272 1272
1273 model = self.debugServer.getBreakPointModel() 1273 model = self.debugServer.getBreakPointModel()
1274 index = model.getBreakPointIndex(filename, lineno) 1274 index = model.getBreakPointIndex(filename, lineno)
1275 if not index.isValid(): 1275 if not index.isValid():
1276 return 1276 return
1300 """ 1300 """
1301 E5MessageBox.critical( 1301 E5MessageBox.critical(
1302 self.ui, 1302 self.ui,
1303 self.trUtf8("Watch Expression Error"), 1303 self.trUtf8("Watch Expression Error"),
1304 self.trUtf8("""<p>The watch expression <b>{0}</b>""" 1304 self.trUtf8("""<p>The watch expression <b>{0}</b>"""
1305 """ contains a syntax error.</p>""")\ 1305 """ contains a syntax error.</p>""")
1306 .format(cond)) 1306 .format(cond))
1307 1307
1308 model = self.debugServer.getWatchPointModel() 1308 model = self.debugServer.getWatchPointModel()
1309 index = model.getWatchPointIndex(cond) 1309 index = model.getWatchPointIndex(cond)
1310 if not index.isValid(): 1310 if not index.isValid():
1311 return 1311 return
1328 idx.internalPointer() != index.internalPointer() 1328 idx.internalPointer() != index.internalPointer()
1329 if duplicate: 1329 if duplicate:
1330 if not special: 1330 if not special:
1331 msg = self.trUtf8("""<p>A watch expression '<b>{0}</b>'""" 1331 msg = self.trUtf8("""<p>A watch expression '<b>{0}</b>'"""
1332 """ already exists.</p>""")\ 1332 """ already exists.</p>""")\
1333 .format(Utilities.html_encode(cond)) 1333 .format(Utilities.html_encode(cond))
1334 else: 1334 else:
1335 msg = self.trUtf8( 1335 msg = self.trUtf8(
1336 """<p>A watch expression '<b>{0}</b>'""" 1336 """<p>A watch expression '<b>{0}</b>'"""
1337 """ for the variable <b>{1}</b> already""" 1337 """ for the variable <b>{1}</b> already"""
1338 """ exists.</p>""")\ 1338 """ exists.</p>""")\
1343 self.trUtf8("Watch expression already exists"), 1343 self.trUtf8("Watch expression already exists"),
1344 msg) 1344 msg)
1345 model.deleteWatchPointByIndex(index) 1345 model.deleteWatchPointByIndex(index)
1346 else: 1346 else:
1347 model.setWatchPointByIndex(index, cond, special, 1347 model.setWatchPointByIndex(index, cond, special,
1348 (temp, enabled, count)) 1348 (temp, enabled, count))
1349 1349
1350 def __configureVariablesFilters(self): 1350 def __configureVariablesFilters(self):
1351 """ 1351 """
1352 Private slot for displaying the variables filter configuration dialog. 1352 Private slot for displaying the variables filter configuration dialog.
1353 """ 1353 """
1524 else: 1524 else:
1525 editor = self.viewmanager.activeWindow() 1525 editor = self.viewmanager.activeWindow()
1526 if editor is None: 1526 if editor is None:
1527 return 1527 return
1528 1528
1529 if not self.viewmanager.checkDirty(editor, 1529 if not self.viewmanager.checkDirty(
1530 Preferences.getDebugger("Autosave")) or \ 1530 editor,
1531 editor.getFileName() is None: 1531 Preferences.getDebugger("Autosave")) or \
1532 editor.getFileName() is None:
1532 return 1533 return
1533 1534
1534 fn = editor.getFileName() 1535 fn = editor.getFileName()
1535 self.lastStartAction = 5 1536 self.lastStartAction = 5
1536 self.clientType = editor.determineFileType() 1537 self.clientType = editor.determineFileType()
1641 else: 1642 else:
1642 editor = self.viewmanager.activeWindow() 1643 editor = self.viewmanager.activeWindow()
1643 if editor is None: 1644 if editor is None:
1644 return 1645 return
1645 1646
1646 if not self.viewmanager.checkDirty(editor, 1647 if not self.viewmanager.checkDirty(
1647 Preferences.getDebugger("Autosave")) or \ 1648 editor,
1648 editor.getFileName() is None: 1649 Preferences.getDebugger("Autosave")) or \
1650 editor.getFileName() is None:
1649 return 1651 return
1650 1652
1651 fn = editor.getFileName() 1653 fn = editor.getFileName()
1652 self.lastStartAction = 7 1654 self.lastStartAction = 7
1653 self.clientType = editor.determineFileType() 1655 self.clientType = editor.determineFileType()
1760 else: 1762 else:
1761 editor = self.viewmanager.activeWindow() 1763 editor = self.viewmanager.activeWindow()
1762 if editor is None: 1764 if editor is None:
1763 return 1765 return
1764 1766
1765 if not self.viewmanager.checkDirty(editor, 1767 if not self.viewmanager.checkDirty(
1766 Preferences.getDebugger("Autosave")) or \ 1768 editor,
1767 editor.getFileName() is None: 1769 Preferences.getDebugger("Autosave")) or \
1770 editor.getFileName() is None:
1768 return 1771 return
1769 1772
1770 fn = editor.getFileName() 1773 fn = editor.getFileName()
1771 self.lastStartAction = 3 1774 self.lastStartAction = 3
1772 self.clientType = editor.determineFileType() 1775 self.clientType = editor.determineFileType()
1881 else: 1884 else:
1882 editor = self.viewmanager.activeWindow() 1885 editor = self.viewmanager.activeWindow()
1883 if editor is None: 1886 if editor is None:
1884 return 1887 return
1885 1888
1886 if not self.viewmanager.checkDirty(editor, 1889 if not self.viewmanager.checkDirty(
1887 Preferences.getDebugger("Autosave")) or \ 1890 editor,
1888 editor.getFileName() is None: 1891 Preferences.getDebugger("Autosave")) or \
1892 editor.getFileName() is None:
1889 return 1893 return
1890 1894
1891 fn = editor.getFileName() 1895 fn = editor.getFileName()
1892 self.lastStartAction = 1 1896 self.lastStartAction = 1
1893 self.clientType = editor.determineFileType() 1897 self.clientType = editor.determineFileType()
2147 curr = 0 2151 curr = 0
2148 else: 2152 else:
2149 curr = -1 2153 curr = -1
2150 2154
2151 arg, ok = QInputDialog.getItem( 2155 arg, ok = QInputDialog.getItem(
2152 self.ui, 2156 self.ui,
2153 self.trUtf8("Evaluate"), 2157 self.trUtf8("Evaluate"),
2154 self.trUtf8("Enter the statement to evaluate"), 2158 self.trUtf8("Enter the statement to evaluate"),
2155 self.evalHistory, 2159 self.evalHistory,
2156 curr, True) 2160 curr, True)
2157 2161
2158 if ok: 2162 if ok:
2159 if not arg: 2163 if not arg:
2160 return 2164 return
2161 2165
2176 curr = 0 2180 curr = 0
2177 else: 2181 else:
2178 curr = -1 2182 curr = -1
2179 2183
2180 stmt, ok = QInputDialog.getItem( 2184 stmt, ok = QInputDialog.getItem(
2181 self.ui, 2185 self.ui,
2182 self.trUtf8("Execute"), 2186 self.trUtf8("Execute"),
2183 self.trUtf8("Enter the statement to execute"), 2187 self.trUtf8("Enter the statement to execute"),
2184 self.execHistory, 2188 self.execHistory,
2185 curr, True) 2189 curr, True)
2186 2190
2187 if ok: 2191 if ok:
2188 if not stmt: 2192 if not stmt:
2189 return 2193 return
2190 2194

eric ide

mercurial