DebugClients/Python/eric6dbgstub.py

branch
debugger speed
changeset 5178
878ce843ca9f
parent 4631
5c1a96925da4
child 5179
5f56410e7624
equal deleted inserted replaced
5174:8c48f5e0cd92 5178:878ce843ca9f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2009 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a debugger stub for remote debugging.
8 """
9
10 import os
11 import sys
12 import distutils.sysconfig
13
14 from eric6config import getConfig
15
16 debugger = None
17 __scriptname = None
18
19 modDir = distutils.sysconfig.get_python_lib(True)
20 ericpath = os.getenv('ERICDIR', getConfig('ericDir'))
21
22 if ericpath not in sys.path:
23 sys.path.insert(-1, ericpath)
24
25
26 def initDebugger(kind="standard"):
27 """
28 Module function to initialize a debugger for remote debugging.
29
30 @param kind type of debugger ("standard" or "threads")
31 @return flag indicating success (boolean)
32 @exception ValueError raised to indicate a wrong debugger kind
33 """
34 global debugger
35 res = True
36 try:
37 if kind == "standard":
38 import DebugClient
39 debugger = DebugClient.DebugClient()
40 elif kind == "threads":
41 import DebugClientThreads
42 debugger = DebugClientThreads.DebugClientThreads()
43 else:
44 raise ValueError
45 except ImportError:
46 debugger = None
47 res = False
48
49 return res
50
51
52 def runcall(func, *args):
53 """
54 Module function mimicing the Pdb interface.
55
56 @param func function to be called (function object)
57 @param *args arguments being passed to func
58 @return the function result
59 """
60 global debugger, __scriptname
61 return debugger.run_call(__scriptname, func, *args)
62
63
64 def setScriptname(name):
65 """
66 Module function to set the scriptname to be reported back to the IDE.
67
68 @param name absolute pathname of the script (string)
69 """
70 global __scriptname
71 __scriptname = name
72
73
74 def startDebugger(enableTrace=True, exceptions=True,
75 tracePython=False, redirect=True):
76 """
77 Module function used to start the remote debugger.
78
79 @keyparam enableTrace flag to enable the tracing function (boolean)
80 @keyparam exceptions flag to enable exception reporting of the IDE
81 (boolean)
82 @keyparam tracePython flag to enable tracing into the Python library
83 (boolean)
84 @keyparam redirect flag indicating redirection of stdin, stdout and
85 stderr (boolean)
86 """
87 global debugger
88 if debugger:
89 debugger.startDebugger(enableTrace=enableTrace, exceptions=exceptions,
90 tracePython=tracePython, redirect=redirect)
91
92 #
93 # eflag: noqa = M702

eric ide

mercurial