src/eric7/DebugClients/Python/DebugClientBase.py

branch
eric7
changeset 10321
4a017fdf316f
parent 10289
490388ca210c
child 10331
c1a2ff7e3575
equal deleted inserted replaced
10320:ff28050f5dec 10321:4a017fdf316f
177 self.passive = False # used to indicate the passive mode 177 self.passive = False # used to indicate the passive mode
178 self.running = None 178 self.running = None
179 self.test = None 179 self.test = None
180 self.debugging = False 180 self.debugging = False
181 self.multiprocessSupport = False 181 self.multiprocessSupport = False
182 self.reportAllExceptions = False
182 self.noDebugList = [] 183 self.noDebugList = []
183 184
184 self.readstream = None 185 self.readstream = None
185 self.writestream = None 186 self.writestream = None
186 self.errorstream = None 187 self.errorstream = None
266 with contextlib.suppress(Exception): # secok 267 with contextlib.suppress(Exception): # secok
267 self.set_quit() 268 self.set_quit()
268 269
269 self.debugging = False 270 self.debugging = False
270 self.multiprocessSupport = False 271 self.multiprocessSupport = False
272 self.reportAllExceptions = False
271 self.noDebugList = [] 273 self.noDebugList = []
272 274
273 # make sure we close down our end of the socket 275 # make sure we close down our end of the socket
274 # might be overkill as normally stdin, stdout and stderr 276 # might be overkill as normally stdin, stdout and stderr
275 # SHOULD be closed on exit, but it does not hurt to do it here 277 # SHOULD be closed on exit, but it does not hurt to do it here
468 os.chdir(params["workdir"]) 470 os.chdir(params["workdir"])
469 471
470 self.running = sys.argv[0] 472 self.running = sys.argv[0]
471 self.debugging = True 473 self.debugging = True
472 self.multiprocessSupport = params["multiprocess"] 474 self.multiprocessSupport = params["multiprocess"]
475 self.reportAllExceptions = params["reportAllExceptions"]
473 476
474 self.threads.clear() 477 self.threads.clear()
475 self.attachThread(mainThread=True) 478 self.attachThread(mainThread=True)
476 479
477 # set the system exception handling function to ensure, that 480 # set the system exception handling function to ensure, that
995 "characternumber": charno, 998 "characternumber": charno,
996 "threadName": threadName, 999 "threadName": threadName,
997 }, 1000 },
998 ) 1001 )
999 1002
1000 def sendPassiveStartup(self, filename, exceptions): 1003 def sendPassiveStartup(self, filename, reportAllExceptions):
1001 """ 1004 """
1002 Public method to send the passive start information. 1005 Public method to send the passive start information.
1003 1006
1004 @param filename name of the script 1007 @param filename name of the script
1005 @type str 1008 @type str
1006 @param exceptions flag to enable exception reporting of the IDE 1009 @param reportAllExceptions flag to enable reporting of all exceptions
1007 @type bool 1010 @type bool
1008 """ 1011 """
1009 self.sendJsonCommand( 1012 self.sendJsonCommand(
1010 "PassiveStartup", 1013 "PassiveStartup",
1011 { 1014 {
1012 "filename": filename, 1015 "filename": filename,
1013 "exceptions": exceptions, 1016 "reportAllExceptions": reportAllExceptions,
1014 }, 1017 },
1015 ) 1018 )
1016 1019
1017 def sendDebuggerId(self): 1020 def sendDebuggerId(self):
1018 """ 1021 """
1763 self, 1766 self,
1764 filename=None, 1767 filename=None,
1765 host=None, 1768 host=None,
1766 port=None, 1769 port=None,
1767 enableTrace=True, 1770 enableTrace=True,
1768 exceptions=True, # noqa: U100 1771 reportAllExceptions=False,
1769 tracePython=False, 1772 tracePython=False,
1770 redirect=True, 1773 redirect=True,
1771 passive=True, 1774 passive=True,
1772 multiprocessSupport=False, # noqa: U100 1775 multiprocessSupport=False, # noqa: U100
1773 ): 1776 ):
1780 @type str 1783 @type str
1781 @param port portnumber of the debug server 1784 @param port portnumber of the debug server
1782 @type int 1785 @type int
1783 @param enableTrace flag to enable the tracing function 1786 @param enableTrace flag to enable the tracing function
1784 @type bool 1787 @type bool
1785 @param exceptions flag to enable exception reporting of the IDE 1788 @param reportAllExceptions flag indicating to report all exceptions
1789 instead of unhandled exceptions only
1786 @type bool 1790 @type bool
1787 @param tracePython flag to enable tracing into the Python library 1791 @param tracePython flag to enable tracing into the Python library
1788 @type bool 1792 @type bool
1789 @param redirect flag indicating redirection of stdin, stdout and 1793 @param redirect flag indicating redirection of stdin, stdout and
1790 stderr 1794 stderr
1818 # setup the debugger variables 1822 # setup the debugger variables
1819 self._fncache = {} 1823 self._fncache = {}
1820 self.dircache = [] 1824 self.dircache = []
1821 self.debugging = True 1825 self.debugging = True
1822 1826
1827 # all exceptions reporting
1828 self.reportAllExceptions = reportAllExceptions
1829
1823 self.attachThread(mainThread=True) 1830 self.attachThread(mainThread=True)
1824 self.mainThread.tracePythonLibs(tracePython) 1831 self.mainThread.tracePythonLibs(tracePython)
1825 1832
1826 # set the system exception handling function to ensure, that 1833 # set the system exception handling function to ensure, that
1827 # we report on all unhandled exceptions 1834 # we report on all unhandled exceptions
1836 self, 1843 self,
1837 progargs, 1844 progargs,
1838 wd="", 1845 wd="",
1839 host=None, 1846 host=None,
1840 port=None, 1847 port=None,
1841 exceptions=True,
1842 tracePython=False, 1848 tracePython=False,
1843 redirect=True, 1849 redirect=True,
1844 passive=True, 1850 passive=True,
1845 multiprocessSupport=False, 1851 multiprocessSupport=False,
1852 reportAllExceptions=False,
1846 callTraceOptimization=False, 1853 callTraceOptimization=False,
1847 codeStr="", 1854 codeStr="",
1848 scriptModule="", 1855 scriptModule="",
1849 ): 1856 ):
1850 """ 1857 """
1856 @type str 1863 @type str
1857 @param host hostname of the debug server 1864 @param host hostname of the debug server
1858 @type str 1865 @type str
1859 @param port portnumber of the debug server 1866 @param port portnumber of the debug server
1860 @type int 1867 @type int
1861 @param exceptions flag to enable exception reporting of the IDE
1862 @type bool
1863 @param tracePython flag to enable tracing into the Python library 1868 @param tracePython flag to enable tracing into the Python library
1864 @type bool 1869 @type bool
1865 @param redirect flag indicating redirection of stdin, stdout and 1870 @param redirect flag indicating redirection of stdin, stdout and
1866 stderr 1871 stderr
1867 @type bool 1872 @type bool
1868 @param passive flag indicating a passive debugging session 1873 @param passive flag indicating a passive debugging session
1869 @type bool 1874 @type bool
1870 @param multiprocessSupport flag indicating to enable multiprocess 1875 @param multiprocessSupport flag indicating to enable multiprocess
1871 debugging support 1876 debugging support
1877 @type bool
1878 @param reportAllExceptions flag indicating to report all exceptions instead
1879 of unhandled exceptions only
1872 @type bool 1880 @type bool
1873 @param callTraceOptimization flag indicating to speed up function/method 1881 @param callTraceOptimization flag indicating to speed up function/method
1874 call tracing 1882 call tracing
1875 @type bool 1883 @type bool
1876 @param codeStr string containing Python code to execute 1884 @param codeStr string containing Python code to execute
1912 os.chdir(wd) 1920 os.chdir(wd)
1913 self.running = sys.argv[0] 1921 self.running = sys.argv[0]
1914 self.__setCoding(self.running) 1922 self.__setCoding(self.running)
1915 self.debugging = True 1923 self.debugging = True
1916 self.multiprocessSupport = multiprocessSupport 1924 self.multiprocessSupport = multiprocessSupport
1925 self.reportAllExceptions = reportAllExceptions
1917 self.callTraceOptimization = callTraceOptimization 1926 self.callTraceOptimization = callTraceOptimization
1918 1927
1919 self.passive = passive 1928 self.passive = passive
1920 if passive: 1929 if passive:
1921 self.sendPassiveStartup(self.running, exceptions) 1930 self.sendPassiveStartup(self.running, reportAllExceptions)
1922 1931
1923 self.attachThread(mainThread=True) 1932 self.attachThread(mainThread=True)
1924 self.mainThread.tracePythonLibs(tracePython) 1933 self.mainThread.tracePythonLibs(tracePython)
1925 1934
1926 # set the system exception handling function to ensure, that 1935 # set the system exception handling function to ensure, that
2002 args = sys.argv[1:] 2011 args = sys.argv[1:]
2003 host = None 2012 host = None
2004 port = None 2013 port = None
2005 wd = "" 2014 wd = ""
2006 tracePython = False 2015 tracePython = False
2007 exceptions = True
2008 redirect = True 2016 redirect = True
2009 passive = True 2017 passive = True
2010 multiprocess = False 2018 multiprocess = False
2019 reportAllExceptions = False
2011 callTraceOptimization = False 2020 callTraceOptimization = False
2012 codeStr = "" 2021 codeStr = ""
2013 scriptModule = "" 2022 scriptModule = ""
2014 while args[0]: 2023 while args[0]:
2015 if args[0] == "-h": 2024 if args[0] == "-h":
2025 del args[0] 2034 del args[0]
2026 del args[0] 2035 del args[0]
2027 elif args[0] == "-t": 2036 elif args[0] == "-t":
2028 tracePython = True 2037 tracePython = True
2029 del args[0] 2038 del args[0]
2030 elif args[0] == "-e":
2031 exceptions = False
2032 del args[0]
2033 elif args[0] == "-n": 2039 elif args[0] == "-n":
2034 redirect = False 2040 redirect = False
2035 del args[0] 2041 del args[0]
2036 elif args[0] == "--no-encoding": 2042 elif args[0] == "--no-encoding":
2037 self.noencoding = True 2043 self.noencoding = True
2039 elif args[0] == "--no-passive": 2045 elif args[0] == "--no-passive":
2040 passive = False 2046 passive = False
2041 del args[0] 2047 del args[0]
2042 elif args[0] == "--multiprocess": 2048 elif args[0] == "--multiprocess":
2043 multiprocess = True 2049 multiprocess = True
2050 del args[0]
2051 elif args[0] == "--report-exceptions":
2052 reportAllExceptions = True
2044 del args[0] 2053 del args[0]
2045 elif args[0] == "--call-trace-optimization": 2054 elif args[0] == "--call-trace-optimization":
2046 callTraceOptimization = True 2055 callTraceOptimization = True
2047 del args[0] 2056 del args[0]
2048 elif args[0] in ("-c", "--code"): 2057 elif args[0] in ("-c", "--code"):
2068 # Store options in case a new Python process is created 2077 # Store options in case a new Python process is created
2069 self.startOptions = ( 2078 self.startOptions = (
2070 wd, 2079 wd,
2071 host, 2080 host,
2072 port, 2081 port,
2073 exceptions, 2082 reportAllExceptions,
2074 tracePython, 2083 tracePython,
2075 redirect, 2084 redirect,
2076 self.noencoding, 2085 self.noencoding,
2077 ) 2086 )
2078 if not self.noencoding: 2087 if not self.noencoding:
2081 res = self.startProgInDebugger( 2090 res = self.startProgInDebugger(
2082 args, 2091 args,
2083 wd, 2092 wd,
2084 host, 2093 host,
2085 port, 2094 port,
2086 exceptions=exceptions,
2087 tracePython=tracePython, 2095 tracePython=tracePython,
2088 redirect=redirect, 2096 redirect=redirect,
2089 passive=passive, 2097 passive=passive,
2090 multiprocessSupport=multiprocess, 2098 multiprocessSupport=multiprocess,
2099 reportAllExceptions=reportAllExceptions,
2091 callTraceOptimization=callTraceOptimization, 2100 callTraceOptimization=callTraceOptimization,
2092 codeStr=codeStr, 2101 codeStr=codeStr,
2093 scriptModule=scriptModule, 2102 scriptModule=scriptModule,
2094 ) 2103 )
2095 sys.exit(res) 2104 sys.exit(res)
2139 # Store options in case a new Python process is created 2148 # Store options in case a new Python process is created
2140 self.startOptions = ( 2149 self.startOptions = (
2141 "", 2150 "",
2142 remoteAddress, 2151 remoteAddress,
2143 port, 2152 port,
2144 True, 2153 False,
2145 False, 2154 False,
2146 redirect, 2155 redirect,
2147 self.noencoding, 2156 self.noencoding,
2148 ) 2157 )
2149 if not self.noencoding: 2158 if not self.noencoding:

eric ide

mercurial