DebugClients/Python/DebugClientBase.py

branch
6_0_x
changeset 4373
54d6d7c772ea
parent 4120
6f0d4d279aeb
equal deleted inserted replaced
4372:5ca53a23d584 4373:54d6d7c772ea
576 execfile(sys.argv[0], self.debugMod.__dict__) 576 execfile(sys.argv[0], self.debugMod.__dict__)
577 except SystemExit as exc: 577 except SystemExit as exc:
578 res = exc.code 578 res = exc.code
579 atexit._run_exitfuncs() 579 atexit._run_exitfuncs()
580 self.writestream.flush() 580 self.writestream.flush()
581 self.progTerminated(res) 581 self.progTerminated(res, exit=True)
582 return 582 return
583 583
584 if cmd == DebugProtocol.RequestCoverage: 584 if cmd == DebugProtocol.RequestCoverage:
585 from coverage import coverage 585 from coverage import coverage
586 sys.argv = [] 586 sys.argv = []
617 res = exc.code 617 res = exc.code
618 atexit._run_exitfuncs() 618 atexit._run_exitfuncs()
619 self.cover.stop() 619 self.cover.stop()
620 self.cover.save() 620 self.cover.save()
621 self.writestream.flush() 621 self.writestream.flush()
622 self.progTerminated(res) 622 self.progTerminated(res, exit=True)
623 return 623 return
624 624
625 if cmd == DebugProtocol.RequestProfile: 625 if cmd == DebugProtocol.RequestProfile:
626 sys.setprofile(None) 626 sys.setprofile(None)
627 import PyProfile 627 import PyProfile
654 except SystemExit as exc: 654 except SystemExit as exc:
655 res = exc.code 655 res = exc.code
656 atexit._run_exitfuncs() 656 atexit._run_exitfuncs()
657 self.prof.save() 657 self.prof.save()
658 self.writestream.flush() 658 self.writestream.flush()
659 self.progTerminated(res) 659 self.progTerminated(res, exit=True)
660 return 660 return
661 661
662 if cmd == DebugProtocol.RequestShutdown: 662 if cmd == DebugProtocol.RequestShutdown:
663 self.sessionClose() 663 self.sessionClose()
664 return 664 return
1241 1241
1242 @return flag indicating a running debug session (boolean) 1242 @return flag indicating a running debug session (boolean)
1243 """ 1243 """
1244 return self.running 1244 return self.running
1245 1245
1246 def progTerminated(self, status): 1246 def progTerminated(self, status, exit=False):
1247 """ 1247 """
1248 Public method to tell the debugger that the program has terminated. 1248 Public method to tell the debugger that the program has terminated.
1249 1249
1250 @param status the return status 1250 @param status return status
1251 @param exit flag indicating to perform a sys.exit()
1252 @type bool
1251 """ 1253 """
1252 if status is None: 1254 if status is None:
1253 status = 0 1255 status = 0
1254 else: 1256 else:
1255 try: 1257 try:
1259 1261
1260 if self.running: 1262 if self.running:
1261 self.set_quit() 1263 self.set_quit()
1262 self.running = None 1264 self.running = None
1263 self.write('%s%d\n' % (DebugProtocol.ResponseExit, status)) 1265 self.write('%s%d\n' % (DebugProtocol.ResponseExit, status))
1266 if exit:
1267 sys.exit(status)
1264 1268
1265 # reset coding 1269 # reset coding
1266 self.__coding = self.defaultCoding 1270 self.__coding = self.defaultCoding
1267 1271
1268 def __dumpVariables(self, frmnr, scope, filter): 1272 def __dumpVariables(self, frmnr, scope, filter):

eric ide

mercurial