repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
fabioz/PyDev.Debugger
pydev_coverage.py
is_valid_py_file
def is_valid_py_file(path): ''' Checks whether the file can be read by the coverage module. This is especially needed for .pyx files and .py files with syntax errors. ''' import os is_valid = False if os.path.isfile(path) and not os.path.splitext(path)[1] == '.pyx': try: with open(path, 'rb') as f: compile(f.read(), path, 'exec') is_valid = True except: pass return is_valid
python
def is_valid_py_file(path): ''' Checks whether the file can be read by the coverage module. This is especially needed for .pyx files and .py files with syntax errors. ''' import os is_valid = False if os.path.isfile(path) and not os.path.splitext(path)[1] == '.pyx': try: with open(path, 'rb') as f: compile(f.read(), path, 'exec') is_valid = True except: pass return is_valid
[ "def", "is_valid_py_file", "(", "path", ")", ":", "import", "os", "is_valid", "=", "False", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", "and", "not", "os", ".", "path", ".", "splitext", "(", "path", ")", "[", "1", "]", "==", "'.pyx'",...
Checks whether the file can be read by the coverage module. This is especially needed for .pyx files and .py files with syntax errors.
[ "Checks", "whether", "the", "file", "can", "be", "read", "by", "the", "coverage", "module", ".", "This", "is", "especially", "needed", "for", ".", "pyx", "files", "and", ".", "py", "files", "with", "syntax", "errors", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydev_coverage.py#L6-L21
train
209,300
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/event.py
EventHandler.__get_hooks_for_dll
def __get_hooks_for_dll(self, event): """ Get the requested API hooks for the current DLL. Used by L{__hook_dll} and L{__unhook_dll}. """ result = [] if self.__apiHooks: path = event.get_module().get_filename() if path: lib_name = PathOperations.pathname_to_filename(path).lower() for hook_lib, hook_api_list in compat.iteritems(self.__apiHooks): if hook_lib == lib_name: result.extend(hook_api_list) return result
python
def __get_hooks_for_dll(self, event): """ Get the requested API hooks for the current DLL. Used by L{__hook_dll} and L{__unhook_dll}. """ result = [] if self.__apiHooks: path = event.get_module().get_filename() if path: lib_name = PathOperations.pathname_to_filename(path).lower() for hook_lib, hook_api_list in compat.iteritems(self.__apiHooks): if hook_lib == lib_name: result.extend(hook_api_list) return result
[ "def", "__get_hooks_for_dll", "(", "self", ",", "event", ")", ":", "result", "=", "[", "]", "if", "self", ".", "__apiHooks", ":", "path", "=", "event", ".", "get_module", "(", ")", ".", "get_filename", "(", ")", "if", "path", ":", "lib_name", "=", "P...
Get the requested API hooks for the current DLL. Used by L{__hook_dll} and L{__unhook_dll}.
[ "Get", "the", "requested", "API", "hooks", "for", "the", "current", "DLL", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/event.py#L1413-L1427
train
209,301
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/event.py
EventSift.event
def event(self, event): """ Forwards events to the corresponding instance of your event handler for this process. If you subclass L{EventSift} and reimplement this method, no event will be forwarded at all unless you call the superclass implementation. If your filtering is based on the event type, there's a much easier way to do it: just implement a handler for it. """ eventCode = event.get_event_code() pid = event.get_pid() handler = self.forward.get(pid, None) if handler is None: handler = self.cls(*self.argv, **self.argd) if eventCode != win32.EXIT_PROCESS_DEBUG_EVENT: self.forward[pid] = handler elif eventCode == win32.EXIT_PROCESS_DEBUG_EVENT: del self.forward[pid] return handler(event)
python
def event(self, event): """ Forwards events to the corresponding instance of your event handler for this process. If you subclass L{EventSift} and reimplement this method, no event will be forwarded at all unless you call the superclass implementation. If your filtering is based on the event type, there's a much easier way to do it: just implement a handler for it. """ eventCode = event.get_event_code() pid = event.get_pid() handler = self.forward.get(pid, None) if handler is None: handler = self.cls(*self.argv, **self.argd) if eventCode != win32.EXIT_PROCESS_DEBUG_EVENT: self.forward[pid] = handler elif eventCode == win32.EXIT_PROCESS_DEBUG_EVENT: del self.forward[pid] return handler(event)
[ "def", "event", "(", "self", ",", "event", ")", ":", "eventCode", "=", "event", ".", "get_event_code", "(", ")", "pid", "=", "event", ".", "get_pid", "(", ")", "handler", "=", "self", ".", "forward", ".", "get", "(", "pid", ",", "None", ")", "if", ...
Forwards events to the corresponding instance of your event handler for this process. If you subclass L{EventSift} and reimplement this method, no event will be forwarded at all unless you call the superclass implementation. If your filtering is based on the event type, there's a much easier way to do it: just implement a handler for it.
[ "Forwards", "events", "to", "the", "corresponding", "instance", "of", "your", "event", "handler", "for", "this", "process", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/event.py#L1627-L1647
train
209,302
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/event.py
EventDispatcher.set_event_handler
def set_event_handler(self, eventHandler): """ Set the event handler. @warn: This is normally not needed. Use with care! @type eventHandler: L{EventHandler} @param eventHandler: New event handler object, or C{None}. @rtype: L{EventHandler} @return: Previous event handler object, or C{None}. @raise TypeError: The event handler is of an incorrect type. @note: The L{eventHandler} parameter may be any callable Python object (for example a function, or an instance method). However you'll probably find it more convenient to use an instance of a subclass of L{EventHandler} here. """ if eventHandler is not None and not callable(eventHandler): raise TypeError("Event handler must be a callable object") try: wrong_type = issubclass(eventHandler, EventHandler) except TypeError: wrong_type = False if wrong_type: classname = str(eventHandler) msg = "Event handler must be an instance of class %s" msg += "rather than the %s class itself. (Missing parens?)" msg = msg % (classname, classname) raise TypeError(msg) try: previous = self.__eventHandler except AttributeError: previous = None self.__eventHandler = eventHandler return previous
python
def set_event_handler(self, eventHandler): """ Set the event handler. @warn: This is normally not needed. Use with care! @type eventHandler: L{EventHandler} @param eventHandler: New event handler object, or C{None}. @rtype: L{EventHandler} @return: Previous event handler object, or C{None}. @raise TypeError: The event handler is of an incorrect type. @note: The L{eventHandler} parameter may be any callable Python object (for example a function, or an instance method). However you'll probably find it more convenient to use an instance of a subclass of L{EventHandler} here. """ if eventHandler is not None and not callable(eventHandler): raise TypeError("Event handler must be a callable object") try: wrong_type = issubclass(eventHandler, EventHandler) except TypeError: wrong_type = False if wrong_type: classname = str(eventHandler) msg = "Event handler must be an instance of class %s" msg += "rather than the %s class itself. (Missing parens?)" msg = msg % (classname, classname) raise TypeError(msg) try: previous = self.__eventHandler except AttributeError: previous = None self.__eventHandler = eventHandler return previous
[ "def", "set_event_handler", "(", "self", ",", "eventHandler", ")", ":", "if", "eventHandler", "is", "not", "None", "and", "not", "callable", "(", "eventHandler", ")", ":", "raise", "TypeError", "(", "\"Event handler must be a callable object\"", ")", "try", ":", ...
Set the event handler. @warn: This is normally not needed. Use with care! @type eventHandler: L{EventHandler} @param eventHandler: New event handler object, or C{None}. @rtype: L{EventHandler} @return: Previous event handler object, or C{None}. @raise TypeError: The event handler is of an incorrect type. @note: The L{eventHandler} parameter may be any callable Python object (for example a function, or an instance method). However you'll probably find it more convenient to use an instance of a subclass of L{EventHandler} here.
[ "Set", "the", "event", "handler", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/event.py#L1723-L1759
train
209,303
fabioz/PyDev.Debugger
third_party/isort_container/isort/settings.py
should_skip
def should_skip(filename, config, path='/'): """Returns True if the file should be skipped based on the passed in settings.""" for skip_path in config['skip']: if posixpath.abspath(posixpath.join(path, filename)) == posixpath.abspath(skip_path.replace('\\', '/')): return True position = os.path.split(filename) while position[1]: if position[1] in config['skip']: return True position = os.path.split(position[0]) for glob in config['skip_glob']: if fnmatch.fnmatch(filename, glob): return True return False
python
def should_skip(filename, config, path='/'): """Returns True if the file should be skipped based on the passed in settings.""" for skip_path in config['skip']: if posixpath.abspath(posixpath.join(path, filename)) == posixpath.abspath(skip_path.replace('\\', '/')): return True position = os.path.split(filename) while position[1]: if position[1] in config['skip']: return True position = os.path.split(position[0]) for glob in config['skip_glob']: if fnmatch.fnmatch(filename, glob): return True return False
[ "def", "should_skip", "(", "filename", ",", "config", ",", "path", "=", "'/'", ")", ":", "for", "skip_path", "in", "config", "[", "'skip'", "]", ":", "if", "posixpath", ".", "abspath", "(", "posixpath", ".", "join", "(", "path", ",", "filename", ")", ...
Returns True if the file should be skipped based on the passed in settings.
[ "Returns", "True", "if", "the", "file", "should", "be", "skipped", "based", "on", "the", "passed", "in", "settings", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/isort_container/isort/settings.py#L240-L256
train
209,304
fabioz/PyDev.Debugger
_pydev_bundle/_pydev_jy_imports_tipper.py
ismethod
def ismethod(func): '''this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from the function this is a list because when we have methods from java with the same name and different signatures, we actually have many methods, each with its own set of arguments ''' try: if isinstance(func, core.PyFunction): #ok, this is from python, created by jython #print_ ' PyFunction' def getargs(func_code): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is a list of argument names (possibly containing nested lists), and 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" nargs = func_code.co_argcount names = func_code.co_varnames args = list(names[:nargs]) step = 0 if not hasattr(func_code, 'CO_VARARGS'): from org.python.core import CodeFlag # @UnresolvedImport co_varargs_flag = CodeFlag.CO_VARARGS.flag co_varkeywords_flag = CodeFlag.CO_VARKEYWORDS.flag else: co_varargs_flag = func_code.CO_VARARGS co_varkeywords_flag = func_code.CO_VARKEYWORDS varargs = None if func_code.co_flags & co_varargs_flag: varargs = func_code.co_varnames[nargs] nargs = nargs + 1 varkw = None if func_code.co_flags & co_varkeywords_flag: varkw = func_code.co_varnames[nargs] return args, varargs, varkw args = getargs(func.func_code) return 1, [Info(func.func_name, args=args[0], varargs=args[1], kwargs=args[2], doc=func.func_doc)] if isinstance(func, core.PyMethod): #this is something from java itself, and jython just wrapped it... #things to play in func: #['__call__', '__class__', '__cmp__', '__delattr__', '__dir__', '__doc__', '__findattr__', '__name__', '_doget', 'im_class', #'im_func', 'im_self', 'toString'] #print_ ' PyMethod' #that's the PyReflectedFunction... keep going to get it func = func.im_func if isinstance(func, PyReflectedFunction): #this is something from java itself, and jython just wrapped it... #print_ ' PyReflectedFunction' infos = [] for i in xrange(len(func.argslist)): #things to play in func.argslist[i]: #'PyArgsCall', 'PyArgsKeywordsCall', 'REPLACE', 'StandardCall', 'args', 'compare', 'compareTo', 'data', 'declaringClass' #'flags', 'isStatic', 'matches', 'precedence'] #print_ ' ', func.argslist[i].data.__class__ #func.argslist[i].data.__class__ == java.lang.reflect.Method if func.argslist[i]: met = func.argslist[i].data name = met.getName() try: ret = met.getReturnType() except AttributeError: ret = '' parameterTypes = met.getParameterTypes() args = [] for j in xrange(len(parameterTypes)): paramTypesClass = parameterTypes[j] try: try: paramClassName = paramTypesClass.getName() except: paramClassName = paramTypesClass.getName(paramTypesClass) except AttributeError: try: paramClassName = repr(paramTypesClass) #should be something like <type 'object'> paramClassName = paramClassName.split('\'')[1] except: paramClassName = repr(paramTypesClass) #just in case something else happens... it will at least be visible #if the parameter equals [C, it means it it a char array, so, let's change it a = format_param_class_name(paramClassName) #a = a.replace('[]','Array') #a = a.replace('Object', 'obj') #a = a.replace('String', 's') #a = a.replace('Integer', 'i') #a = a.replace('Char', 'c') #a = a.replace('Double', 'd') args.append(a) #so we don't leave invalid code info = Info(name, args=args, ret=ret) #print_ info.basic_as_str() infos.append(info) return 1, infos except Exception: s = StringIO.StringIO() traceback.print_exc(file=s) return 1, [Info(str('ERROR'), doc=s.getvalue())] return 0, None
python
def ismethod(func): '''this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from the function this is a list because when we have methods from java with the same name and different signatures, we actually have many methods, each with its own set of arguments ''' try: if isinstance(func, core.PyFunction): #ok, this is from python, created by jython #print_ ' PyFunction' def getargs(func_code): """Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is a list of argument names (possibly containing nested lists), and 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" nargs = func_code.co_argcount names = func_code.co_varnames args = list(names[:nargs]) step = 0 if not hasattr(func_code, 'CO_VARARGS'): from org.python.core import CodeFlag # @UnresolvedImport co_varargs_flag = CodeFlag.CO_VARARGS.flag co_varkeywords_flag = CodeFlag.CO_VARKEYWORDS.flag else: co_varargs_flag = func_code.CO_VARARGS co_varkeywords_flag = func_code.CO_VARKEYWORDS varargs = None if func_code.co_flags & co_varargs_flag: varargs = func_code.co_varnames[nargs] nargs = nargs + 1 varkw = None if func_code.co_flags & co_varkeywords_flag: varkw = func_code.co_varnames[nargs] return args, varargs, varkw args = getargs(func.func_code) return 1, [Info(func.func_name, args=args[0], varargs=args[1], kwargs=args[2], doc=func.func_doc)] if isinstance(func, core.PyMethod): #this is something from java itself, and jython just wrapped it... #things to play in func: #['__call__', '__class__', '__cmp__', '__delattr__', '__dir__', '__doc__', '__findattr__', '__name__', '_doget', 'im_class', #'im_func', 'im_self', 'toString'] #print_ ' PyMethod' #that's the PyReflectedFunction... keep going to get it func = func.im_func if isinstance(func, PyReflectedFunction): #this is something from java itself, and jython just wrapped it... #print_ ' PyReflectedFunction' infos = [] for i in xrange(len(func.argslist)): #things to play in func.argslist[i]: #'PyArgsCall', 'PyArgsKeywordsCall', 'REPLACE', 'StandardCall', 'args', 'compare', 'compareTo', 'data', 'declaringClass' #'flags', 'isStatic', 'matches', 'precedence'] #print_ ' ', func.argslist[i].data.__class__ #func.argslist[i].data.__class__ == java.lang.reflect.Method if func.argslist[i]: met = func.argslist[i].data name = met.getName() try: ret = met.getReturnType() except AttributeError: ret = '' parameterTypes = met.getParameterTypes() args = [] for j in xrange(len(parameterTypes)): paramTypesClass = parameterTypes[j] try: try: paramClassName = paramTypesClass.getName() except: paramClassName = paramTypesClass.getName(paramTypesClass) except AttributeError: try: paramClassName = repr(paramTypesClass) #should be something like <type 'object'> paramClassName = paramClassName.split('\'')[1] except: paramClassName = repr(paramTypesClass) #just in case something else happens... it will at least be visible #if the parameter equals [C, it means it it a char array, so, let's change it a = format_param_class_name(paramClassName) #a = a.replace('[]','Array') #a = a.replace('Object', 'obj') #a = a.replace('String', 's') #a = a.replace('Integer', 'i') #a = a.replace('Char', 'c') #a = a.replace('Double', 'd') args.append(a) #so we don't leave invalid code info = Info(name, args=args, ret=ret) #print_ info.basic_as_str() infos.append(info) return 1, infos except Exception: s = StringIO.StringIO() traceback.print_exc(file=s) return 1, [Info(str('ERROR'), doc=s.getvalue())] return 0, None
[ "def", "ismethod", "(", "func", ")", ":", "try", ":", "if", "isinstance", "(", "func", ",", "core", ".", "PyFunction", ")", ":", "#ok, this is from python, created by jython", "#print_ ' PyFunction'", "def", "getargs", "(", "func_code", ")", ":", "\"\"\"Get inf...
this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from the function this is a list because when we have methods from java with the same name and different signatures, we actually have many methods, each with its own set of arguments
[ "this", "function", "should", "return", "the", "information", "gathered", "on", "a", "function" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/_pydev_jy_imports_tipper.py#L177-L295
train
209,305
fabioz/PyDev.Debugger
_pydev_bundle/_pydev_jy_imports_tipper.py
format_arg
def format_arg(arg): '''formats an argument to be shown ''' s = str(arg) dot = s.rfind('.') if dot >= 0: s = s[dot + 1:] s = s.replace(';', '') s = s.replace('[]', 'Array') if len(s) > 0: c = s[0].lower() s = c + s[1:] return s
python
def format_arg(arg): '''formats an argument to be shown ''' s = str(arg) dot = s.rfind('.') if dot >= 0: s = s[dot + 1:] s = s.replace(';', '') s = s.replace('[]', 'Array') if len(s) > 0: c = s[0].lower() s = c + s[1:] return s
[ "def", "format_arg", "(", "arg", ")", ":", "s", "=", "str", "(", "arg", ")", "dot", "=", "s", ".", "rfind", "(", "'.'", ")", "if", "dot", ">=", "0", ":", "s", "=", "s", "[", "dot", "+", "1", ":", "]", "s", "=", "s", ".", "replace", "(", ...
formats an argument to be shown
[ "formats", "an", "argument", "to", "be", "shown" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/_pydev_jy_imports_tipper.py#L376-L391
train
209,306
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
start_server
def start_server(port): ''' binds to a port, waits for the debugger to connect ''' s = socket(AF_INET, SOCK_STREAM) s.settimeout(None) try: from socket import SO_REUSEPORT s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1) except ImportError: s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) s.bind(('', port)) pydev_log.info("Bound to port :%s", port) try: s.listen(1) newSock, _addr = s.accept() pydev_log.info("Connection accepted") # closing server socket is not necessary but we don't need it s.shutdown(SHUT_RDWR) s.close() return newSock except: pydev_log.exception("Could not bind to port: %s\n", port)
python
def start_server(port): ''' binds to a port, waits for the debugger to connect ''' s = socket(AF_INET, SOCK_STREAM) s.settimeout(None) try: from socket import SO_REUSEPORT s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1) except ImportError: s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) s.bind(('', port)) pydev_log.info("Bound to port :%s", port) try: s.listen(1) newSock, _addr = s.accept() pydev_log.info("Connection accepted") # closing server socket is not necessary but we don't need it s.shutdown(SHUT_RDWR) s.close() return newSock except: pydev_log.exception("Could not bind to port: %s\n", port)
[ "def", "start_server", "(", "port", ")", ":", "s", "=", "socket", "(", "AF_INET", ",", "SOCK_STREAM", ")", "s", ".", "settimeout", "(", "None", ")", "try", ":", "from", "socket", "import", "SO_REUSEPORT", "s", ".", "setsockopt", "(", "SOL_SOCKET", ",", ...
binds to a port, waits for the debugger to connect
[ "binds", "to", "a", "port", "waits", "for", "the", "debugger", "to", "connect" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L381-L405
train
209,307
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
internal_change_variable
def internal_change_variable(dbg, seq, thread_id, frame_id, scope, attr, value): ''' Changes the value of a variable ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: result = pydevd_vars.change_attr_expression(frame, attr, value, dbg) else: result = None xml = "<xml>" xml += pydevd_xml.var_to_xml(result, "") xml += "</xml>" cmd = dbg.cmd_factory.make_variable_changed_message(seq, xml) dbg.writer.add_command(cmd) except Exception: cmd = dbg.cmd_factory.make_error_message(seq, "Error changing variable attr:%s expression:%s traceback:%s" % (attr, value, get_exception_traceback_str())) dbg.writer.add_command(cmd)
python
def internal_change_variable(dbg, seq, thread_id, frame_id, scope, attr, value): ''' Changes the value of a variable ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: result = pydevd_vars.change_attr_expression(frame, attr, value, dbg) else: result = None xml = "<xml>" xml += pydevd_xml.var_to_xml(result, "") xml += "</xml>" cmd = dbg.cmd_factory.make_variable_changed_message(seq, xml) dbg.writer.add_command(cmd) except Exception: cmd = dbg.cmd_factory.make_error_message(seq, "Error changing variable attr:%s expression:%s traceback:%s" % (attr, value, get_exception_traceback_str())) dbg.writer.add_command(cmd)
[ "def", "internal_change_variable", "(", "dbg", ",", "seq", ",", "thread_id", ",", "frame_id", ",", "scope", ",", "attr", ",", "value", ")", ":", "try", ":", "frame", "=", "dbg", ".", "find_frame", "(", "thread_id", ",", "frame_id", ")", "if", "frame", ...
Changes the value of a variable
[ "Changes", "the", "value", "of", "a", "variable" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L714-L729
train
209,308
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
internal_get_next_statement_targets
def internal_get_next_statement_targets(dbg, seq, thread_id, frame_id): ''' gets the valid line numbers for use with set next statement ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: code = frame.f_code xml = "<xml>" if hasattr(code, 'co_lnotab'): lineno = code.co_firstlineno lnotab = code.co_lnotab for i in itertools.islice(lnotab, 1, len(lnotab), 2): if isinstance(i, int): lineno = lineno + i else: # in python 2 elements in co_lnotab are of type str lineno = lineno + ord(i) xml += "<line>%d</line>" % (lineno,) else: xml += "<line>%d</line>" % (frame.f_lineno,) del frame xml += "</xml>" cmd = dbg.cmd_factory.make_get_next_statement_targets_message(seq, xml) dbg.writer.add_command(cmd) else: cmd = dbg.cmd_factory.make_error_message(seq, "Frame not found: %s from thread: %s" % (frame_id, thread_id)) dbg.writer.add_command(cmd) except: cmd = dbg.cmd_factory.make_error_message(seq, "Error resolving frame: %s from thread: %s" % (frame_id, thread_id)) dbg.writer.add_command(cmd)
python
def internal_get_next_statement_targets(dbg, seq, thread_id, frame_id): ''' gets the valid line numbers for use with set next statement ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: code = frame.f_code xml = "<xml>" if hasattr(code, 'co_lnotab'): lineno = code.co_firstlineno lnotab = code.co_lnotab for i in itertools.islice(lnotab, 1, len(lnotab), 2): if isinstance(i, int): lineno = lineno + i else: # in python 2 elements in co_lnotab are of type str lineno = lineno + ord(i) xml += "<line>%d</line>" % (lineno,) else: xml += "<line>%d</line>" % (frame.f_lineno,) del frame xml += "</xml>" cmd = dbg.cmd_factory.make_get_next_statement_targets_message(seq, xml) dbg.writer.add_command(cmd) else: cmd = dbg.cmd_factory.make_error_message(seq, "Frame not found: %s from thread: %s" % (frame_id, thread_id)) dbg.writer.add_command(cmd) except: cmd = dbg.cmd_factory.make_error_message(seq, "Error resolving frame: %s from thread: %s" % (frame_id, thread_id)) dbg.writer.add_command(cmd)
[ "def", "internal_get_next_statement_targets", "(", "dbg", ",", "seq", ",", "thread_id", ",", "frame_id", ")", ":", "try", ":", "frame", "=", "dbg", ".", "find_frame", "(", "thread_id", ",", "frame_id", ")", "if", "frame", "is", "not", "None", ":", "code", ...
gets the valid line numbers for use with set next statement
[ "gets", "the", "valid", "line", "numbers", "for", "use", "with", "set", "next", "statement" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L805-L833
train
209,309
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
internal_evaluate_expression
def internal_evaluate_expression(dbg, seq, thread_id, frame_id, expression, is_exec, trim_if_too_big, attr_to_set_result): ''' gets the value of a variable ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: result = pydevd_vars.evaluate_expression(dbg, frame, expression, is_exec) if attr_to_set_result != "": pydevd_vars.change_attr_expression(frame, attr_to_set_result, expression, dbg, result) else: result = None xml = "<xml>" xml += pydevd_xml.var_to_xml(result, expression, trim_if_too_big) xml += "</xml>" cmd = dbg.cmd_factory.make_evaluate_expression_message(seq, xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(seq, "Error evaluating expression " + exc) dbg.writer.add_command(cmd)
python
def internal_evaluate_expression(dbg, seq, thread_id, frame_id, expression, is_exec, trim_if_too_big, attr_to_set_result): ''' gets the value of a variable ''' try: frame = dbg.find_frame(thread_id, frame_id) if frame is not None: result = pydevd_vars.evaluate_expression(dbg, frame, expression, is_exec) if attr_to_set_result != "": pydevd_vars.change_attr_expression(frame, attr_to_set_result, expression, dbg, result) else: result = None xml = "<xml>" xml += pydevd_xml.var_to_xml(result, expression, trim_if_too_big) xml += "</xml>" cmd = dbg.cmd_factory.make_evaluate_expression_message(seq, xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(seq, "Error evaluating expression " + exc) dbg.writer.add_command(cmd)
[ "def", "internal_evaluate_expression", "(", "dbg", ",", "seq", ",", "thread_id", ",", "frame_id", ",", "expression", ",", "is_exec", ",", "trim_if_too_big", ",", "attr_to_set_result", ")", ":", "try", ":", "frame", "=", "dbg", ".", "find_frame", "(", "thread_i...
gets the value of a variable
[ "gets", "the", "value", "of", "a", "variable" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L914-L933
train
209,310
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
internal_get_description
def internal_get_description(dbg, seq, thread_id, frame_id, expression): ''' Fetch the variable description stub from the debug console ''' try: frame = dbg.find_frame(thread_id, frame_id) description = pydevd_console.get_description(frame, thread_id, frame_id, expression) description = pydevd_xml.make_valid_xml_value(quote(description, '/>_= \t')) description_xml = '<xml><var name="" type="" value="%s"/></xml>' % description cmd = dbg.cmd_factory.make_get_description_message(seq, description_xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(seq, "Error in fetching description" + exc) dbg.writer.add_command(cmd)
python
def internal_get_description(dbg, seq, thread_id, frame_id, expression): ''' Fetch the variable description stub from the debug console ''' try: frame = dbg.find_frame(thread_id, frame_id) description = pydevd_console.get_description(frame, thread_id, frame_id, expression) description = pydevd_xml.make_valid_xml_value(quote(description, '/>_= \t')) description_xml = '<xml><var name="" type="" value="%s"/></xml>' % description cmd = dbg.cmd_factory.make_get_description_message(seq, description_xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(seq, "Error in fetching description" + exc) dbg.writer.add_command(cmd)
[ "def", "internal_get_description", "(", "dbg", ",", "seq", ",", "thread_id", ",", "frame_id", ",", "expression", ")", ":", "try", ":", "frame", "=", "dbg", ".", "find_frame", "(", "thread_id", ",", "frame_id", ")", "description", "=", "pydevd_console", ".", ...
Fetch the variable description stub from the debug console
[ "Fetch", "the", "variable", "description", "stub", "from", "the", "debug", "console" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L1047-L1060
train
209,311
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
internal_get_exception_details_json
def internal_get_exception_details_json(dbg, request, thread_id, max_frames, set_additional_thread_info=None, iter_visible_frames_info=None): ''' Fetch exception details ''' try: response = build_exception_info_response(dbg, thread_id, request.seq, set_additional_thread_info, iter_visible_frames_info, max_frames) except: exc = get_exception_traceback_str() response = pydevd_base_schema.build_response(request, kwargs={ 'success': False, 'message': exc, 'body':{} }) dbg.writer.add_command(NetCommand(CMD_RETURN, 0, response, is_json=True))
python
def internal_get_exception_details_json(dbg, request, thread_id, max_frames, set_additional_thread_info=None, iter_visible_frames_info=None): ''' Fetch exception details ''' try: response = build_exception_info_response(dbg, thread_id, request.seq, set_additional_thread_info, iter_visible_frames_info, max_frames) except: exc = get_exception_traceback_str() response = pydevd_base_schema.build_response(request, kwargs={ 'success': False, 'message': exc, 'body':{} }) dbg.writer.add_command(NetCommand(CMD_RETURN, 0, response, is_json=True))
[ "def", "internal_get_exception_details_json", "(", "dbg", ",", "request", ",", "thread_id", ",", "max_frames", ",", "set_additional_thread_info", "=", "None", ",", "iter_visible_frames_info", "=", "None", ")", ":", "try", ":", "response", "=", "build_exception_info_re...
Fetch exception details
[ "Fetch", "exception", "details" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L1157-L1169
train
209,312
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
WriterThread._on_run
def _on_run(self): ''' just loop and write responses ''' try: while True: try: try: cmd = self.cmdQueue.get(1, 0.1) except _queue.Empty: if self.killReceived: try: self.sock.shutdown(SHUT_WR) self.sock.close() except: pass return # break if queue is empty and killReceived else: continue except: # pydev_log.info('Finishing debug communication...(1)') # when liberating the thread here, we could have errors because we were shutting down # but the thread was still not liberated return cmd.send(self.sock) if cmd.id == CMD_EXIT: break if time is None: break # interpreter shutdown time.sleep(self.timeout) except Exception: GlobalDebuggerHolder.global_dbg.finish_debugging_session() if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 0: pydev_log_exception()
python
def _on_run(self): ''' just loop and write responses ''' try: while True: try: try: cmd = self.cmdQueue.get(1, 0.1) except _queue.Empty: if self.killReceived: try: self.sock.shutdown(SHUT_WR) self.sock.close() except: pass return # break if queue is empty and killReceived else: continue except: # pydev_log.info('Finishing debug communication...(1)') # when liberating the thread here, we could have errors because we were shutting down # but the thread was still not liberated return cmd.send(self.sock) if cmd.id == CMD_EXIT: break if time is None: break # interpreter shutdown time.sleep(self.timeout) except Exception: GlobalDebuggerHolder.global_dbg.finish_debugging_session() if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 0: pydev_log_exception()
[ "def", "_on_run", "(", "self", ")", ":", "try", ":", "while", "True", ":", "try", ":", "try", ":", "cmd", "=", "self", ".", "cmdQueue", ".", "get", "(", "1", ",", "0.1", ")", "except", "_queue", ".", "Empty", ":", "if", "self", ".", "killReceived...
just loop and write responses
[ "just", "loop", "and", "write", "responses" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L341-L375
train
209,313
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
InternalThreadCommand.can_be_executed_by
def can_be_executed_by(self, thread_id): '''By default, it must be in the same thread to be executed ''' return self.thread_id == thread_id or self.thread_id.endswith('|' + thread_id)
python
def can_be_executed_by(self, thread_id): '''By default, it must be in the same thread to be executed ''' return self.thread_id == thread_id or self.thread_id.endswith('|' + thread_id)
[ "def", "can_be_executed_by", "(", "self", ",", "thread_id", ")", ":", "return", "self", ".", "thread_id", "==", "thread_id", "or", "self", ".", "thread_id", ".", "endswith", "(", "'|'", "+", "thread_id", ")" ]
By default, it must be in the same thread to be executed
[ "By", "default", "it", "must", "be", "in", "the", "same", "thread", "to", "be", "executed" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L458-L461
train
209,314
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
InternalConsoleGetCompletions.do_it
def do_it(self, dbg): ''' Get completions and write back to the client ''' try: frame = dbg.find_frame(self.thread_id, self.frame_id) completions_xml = pydevd_console.get_completions(frame, self.act_tok) cmd = dbg.cmd_factory.make_send_console_message(self.sequence, completions_xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error in fetching completions" + exc) dbg.writer.add_command(cmd)
python
def do_it(self, dbg): ''' Get completions and write back to the client ''' try: frame = dbg.find_frame(self.thread_id, self.frame_id) completions_xml = pydevd_console.get_completions(frame, self.act_tok) cmd = dbg.cmd_factory.make_send_console_message(self.sequence, completions_xml) dbg.writer.add_command(cmd) except: exc = get_exception_traceback_str() cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error in fetching completions" + exc) dbg.writer.add_command(cmd)
[ "def", "do_it", "(", "self", ",", "dbg", ")", ":", "try", ":", "frame", "=", "dbg", ".", "find_frame", "(", "self", ".", "thread_id", ",", "self", ".", "frame_id", ")", "completions_xml", "=", "pydevd_console", ".", "get_completions", "(", "frame", ",", ...
Get completions and write back to the client
[ "Get", "completions", "and", "write", "back", "to", "the", "client" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L1326-L1337
train
209,315
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
InternalLoadFullValue.do_it
def do_it(self, dbg): '''Starts a thread that will load values asynchronously''' try: var_objects = [] for variable in self.vars: variable = variable.strip() if len(variable) > 0: if '\t' in variable: # there are attributes beyond scope scope, attrs = variable.split('\t', 1) name = attrs[0] else: scope, attrs = (variable, None) name = scope var_obj = pydevd_vars.getVariable(dbg, self.thread_id, self.frame_id, scope, attrs) var_objects.append((var_obj, name)) t = GetValueAsyncThreadDebug(dbg, self.sequence, var_objects) t.start() except: exc = get_exception_traceback_str() sys.stderr.write('%s\n' % (exc,)) cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error evaluating variable %s " % exc) dbg.writer.add_command(cmd)
python
def do_it(self, dbg): '''Starts a thread that will load values asynchronously''' try: var_objects = [] for variable in self.vars: variable = variable.strip() if len(variable) > 0: if '\t' in variable: # there are attributes beyond scope scope, attrs = variable.split('\t', 1) name = attrs[0] else: scope, attrs = (variable, None) name = scope var_obj = pydevd_vars.getVariable(dbg, self.thread_id, self.frame_id, scope, attrs) var_objects.append((var_obj, name)) t = GetValueAsyncThreadDebug(dbg, self.sequence, var_objects) t.start() except: exc = get_exception_traceback_str() sys.stderr.write('%s\n' % (exc,)) cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error evaluating variable %s " % exc) dbg.writer.add_command(cmd)
[ "def", "do_it", "(", "self", ",", "dbg", ")", ":", "try", ":", "var_objects", "=", "[", "]", "for", "variable", "in", "self", ".", "vars", ":", "variable", "=", "variable", ".", "strip", "(", ")", "if", "len", "(", "variable", ")", ">", "0", ":",...
Starts a thread that will load values asynchronously
[ "Starts", "a", "thread", "that", "will", "load", "values", "asynchronously" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L1385-L1407
train
209,316
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/kernel32.py
RaiseIfLastError
def RaiseIfLastError(result, func = None, arguments = ()): """ Error checking for Win32 API calls with no error-specific return value. Regardless of the return value, the function calls GetLastError(). If the code is not C{ERROR_SUCCESS} then a C{WindowsError} exception is raised. For this to work, the user MUST call SetLastError(ERROR_SUCCESS) prior to calling the API. Otherwise an exception may be raised even on success, since most API calls don't clear the error status code. """ code = GetLastError() if code != ERROR_SUCCESS: raise ctypes.WinError(code) return result
python
def RaiseIfLastError(result, func = None, arguments = ()): """ Error checking for Win32 API calls with no error-specific return value. Regardless of the return value, the function calls GetLastError(). If the code is not C{ERROR_SUCCESS} then a C{WindowsError} exception is raised. For this to work, the user MUST call SetLastError(ERROR_SUCCESS) prior to calling the API. Otherwise an exception may be raised even on success, since most API calls don't clear the error status code. """ code = GetLastError() if code != ERROR_SUCCESS: raise ctypes.WinError(code) return result
[ "def", "RaiseIfLastError", "(", "result", ",", "func", "=", "None", ",", "arguments", "=", "(", ")", ")", ":", "code", "=", "GetLastError", "(", ")", "if", "code", "!=", "ERROR_SUCCESS", ":", "raise", "ctypes", ".", "WinError", "(", "code", ")", "retur...
Error checking for Win32 API calls with no error-specific return value. Regardless of the return value, the function calls GetLastError(). If the code is not C{ERROR_SUCCESS} then a C{WindowsError} exception is raised. For this to work, the user MUST call SetLastError(ERROR_SUCCESS) prior to calling the API. Otherwise an exception may be raised even on success, since most API calls don't clear the error status code.
[ "Error", "checking", "for", "Win32", "API", "calls", "with", "no", "error", "-", "specific", "return", "value", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/kernel32.py#L56-L70
train
209,317
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/kernel32.py
Handle.close
def close(self): """ Closes the Win32 handle. """ if self.bOwnership and self.value not in (None, INVALID_HANDLE_VALUE): if Handle.__bLeakDetection: # XXX DEBUG print("CLOSE HANDLE (%d) %r" % (self.value, self)) try: self._close() finally: self._value = None
python
def close(self): """ Closes the Win32 handle. """ if self.bOwnership and self.value not in (None, INVALID_HANDLE_VALUE): if Handle.__bLeakDetection: # XXX DEBUG print("CLOSE HANDLE (%d) %r" % (self.value, self)) try: self._close() finally: self._value = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "bOwnership", "and", "self", ".", "value", "not", "in", "(", "None", ",", "INVALID_HANDLE_VALUE", ")", ":", "if", "Handle", ".", "__bLeakDetection", ":", "# XXX DEBUG", "print", "(", "\"CLOSE HANDLE...
Closes the Win32 handle.
[ "Closes", "the", "Win32", "handle", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/kernel32.py#L683-L693
train
209,318
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/kernel32.py
Handle._normalize
def _normalize(value): """ Normalize handle values. """ if hasattr(value, 'value'): value = value.value if value is not None: value = long(value) return value
python
def _normalize(value): """ Normalize handle values. """ if hasattr(value, 'value'): value = value.value if value is not None: value = long(value) return value
[ "def", "_normalize", "(", "value", ")", ":", "if", "hasattr", "(", "value", ",", "'value'", ")", ":", "value", "=", "value", ".", "value", "if", "value", "is", "not", "None", ":", "value", "=", "long", "(", "value", ")", "return", "value" ]
Normalize handle values.
[ "Normalize", "handle", "values", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/kernel32.py#L716-L724
train
209,319
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/kernel32.py
Handle.wait
def wait(self, dwMilliseconds = None): """ Wait for the Win32 object to be signaled. @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout value in milliseconds. Use C{INFINITE} or C{None} for no timeout. """ if self.value is None: raise ValueError("Handle is already closed!") if dwMilliseconds is None: dwMilliseconds = INFINITE r = WaitForSingleObject(self.value, dwMilliseconds) if r != WAIT_OBJECT_0: raise ctypes.WinError(r)
python
def wait(self, dwMilliseconds = None): """ Wait for the Win32 object to be signaled. @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout value in milliseconds. Use C{INFINITE} or C{None} for no timeout. """ if self.value is None: raise ValueError("Handle is already closed!") if dwMilliseconds is None: dwMilliseconds = INFINITE r = WaitForSingleObject(self.value, dwMilliseconds) if r != WAIT_OBJECT_0: raise ctypes.WinError(r)
[ "def", "wait", "(", "self", ",", "dwMilliseconds", "=", "None", ")", ":", "if", "self", ".", "value", "is", "None", ":", "raise", "ValueError", "(", "\"Handle is already closed!\"", ")", "if", "dwMilliseconds", "is", "None", ":", "dwMilliseconds", "=", "INFI...
Wait for the Win32 object to be signaled. @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout value in milliseconds. Use C{INFINITE} or C{None} for no timeout.
[ "Wait", "for", "the", "Win32", "object", "to", "be", "signaled", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/kernel32.py#L726-L740
train
209,320
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/btm_matcher.py
BottomMatcher.add
def add(self, pattern, start): "Recursively adds a linear pattern to the AC automaton" #print("adding pattern", pattern, "to", start) if not pattern: #print("empty pattern") return [start] if isinstance(pattern[0], tuple): #alternatives #print("alternatives") match_nodes = [] for alternative in pattern[0]: #add all alternatives, and add the rest of the pattern #to each end node end_nodes = self.add(alternative, start=start) for end in end_nodes: match_nodes.extend(self.add(pattern[1:], end)) return match_nodes else: #single token #not last if pattern[0] not in start.transition_table: #transition did not exist, create new next_node = BMNode() start.transition_table[pattern[0]] = next_node else: #transition exists already, follow next_node = start.transition_table[pattern[0]] if pattern[1:]: end_nodes = self.add(pattern[1:], start=next_node) else: end_nodes = [next_node] return end_nodes
python
def add(self, pattern, start): "Recursively adds a linear pattern to the AC automaton" #print("adding pattern", pattern, "to", start) if not pattern: #print("empty pattern") return [start] if isinstance(pattern[0], tuple): #alternatives #print("alternatives") match_nodes = [] for alternative in pattern[0]: #add all alternatives, and add the rest of the pattern #to each end node end_nodes = self.add(alternative, start=start) for end in end_nodes: match_nodes.extend(self.add(pattern[1:], end)) return match_nodes else: #single token #not last if pattern[0] not in start.transition_table: #transition did not exist, create new next_node = BMNode() start.transition_table[pattern[0]] = next_node else: #transition exists already, follow next_node = start.transition_table[pattern[0]] if pattern[1:]: end_nodes = self.add(pattern[1:], start=next_node) else: end_nodes = [next_node] return end_nodes
[ "def", "add", "(", "self", ",", "pattern", ",", "start", ")", ":", "#print(\"adding pattern\", pattern, \"to\", start)", "if", "not", "pattern", ":", "#print(\"empty pattern\")", "return", "[", "start", "]", "if", "isinstance", "(", "pattern", "[", "0", "]", ","...
Recursively adds a linear pattern to the AC automaton
[ "Recursively", "adds", "a", "linear", "pattern", "to", "the", "AC", "automaton" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/btm_matcher.py#L49-L81
train
209,321
fabioz/PyDev.Debugger
_pydev_bundle/pydev_umd.py
_get_globals
def _get_globals(): """Return current Python interpreter globals namespace""" if _get_globals_callback is not None: return _get_globals_callback() else: try: from __main__ import __dict__ as namespace except ImportError: try: # The import fails on IronPython import __main__ namespace = __main__.__dict__ except: namespace shell = namespace.get('__ipythonshell__') if shell is not None and hasattr(shell, 'user_ns'): # IPython 0.12+ kernel return shell.user_ns else: # Python interpreter return namespace return namespace
python
def _get_globals(): """Return current Python interpreter globals namespace""" if _get_globals_callback is not None: return _get_globals_callback() else: try: from __main__ import __dict__ as namespace except ImportError: try: # The import fails on IronPython import __main__ namespace = __main__.__dict__ except: namespace shell = namespace.get('__ipythonshell__') if shell is not None and hasattr(shell, 'user_ns'): # IPython 0.12+ kernel return shell.user_ns else: # Python interpreter return namespace return namespace
[ "def", "_get_globals", "(", ")", ":", "if", "_get_globals_callback", "is", "not", "None", ":", "return", "_get_globals_callback", "(", ")", "else", ":", "try", ":", "from", "__main__", "import", "__dict__", "as", "namespace", "except", "ImportError", ":", "try...
Return current Python interpreter globals namespace
[ "Return", "current", "Python", "interpreter", "globals", "namespace" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_umd.py#L102-L123
train
209,322
fabioz/PyDev.Debugger
_pydev_bundle/pydev_umd.py
UserModuleDeleter.run
def run(self, verbose=False): """ Del user modules to force Python to deeply reload them Do not del modules which are considered as system modules, i.e. modules installed in subdirectories of Python interpreter's binary Do not del C modules """ log = [] modules_copy = dict(sys.modules) for modname, module in modules_copy.items(): if modname == 'aaaaa': print(modname, module) print(self.previous_modules) if modname not in self.previous_modules: modpath = getattr(module, '__file__', None) if modpath is None: # *module* is a C module that is statically linked into the # interpreter. There is no way to know its path, so we # choose to ignore it. continue if not self.is_module_blacklisted(modname, modpath): log.append(modname) del sys.modules[modname] if verbose and log: print("\x1b[4;33m%s\x1b[24m%s\x1b[0m" % ("UMD has deleted", ": " + ", ".join(log)))
python
def run(self, verbose=False): """ Del user modules to force Python to deeply reload them Do not del modules which are considered as system modules, i.e. modules installed in subdirectories of Python interpreter's binary Do not del C modules """ log = [] modules_copy = dict(sys.modules) for modname, module in modules_copy.items(): if modname == 'aaaaa': print(modname, module) print(self.previous_modules) if modname not in self.previous_modules: modpath = getattr(module, '__file__', None) if modpath is None: # *module* is a C module that is statically linked into the # interpreter. There is no way to know its path, so we # choose to ignore it. continue if not self.is_module_blacklisted(modname, modpath): log.append(modname) del sys.modules[modname] if verbose and log: print("\x1b[4;33m%s\x1b[24m%s\x1b[0m" % ("UMD has deleted", ": " + ", ".join(log)))
[ "def", "run", "(", "self", ",", "verbose", "=", "False", ")", ":", "log", "=", "[", "]", "modules_copy", "=", "dict", "(", "sys", ".", "modules", ")", "for", "modname", ",", "module", "in", "modules_copy", ".", "items", "(", ")", ":", "if", "modnam...
Del user modules to force Python to deeply reload them Do not del modules which are considered as system modules, i.e. modules installed in subdirectories of Python interpreter's binary Do not del C modules
[ "Del", "user", "modules", "to", "force", "Python", "to", "deeply", "reload", "them" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_umd.py#L68-L94
train
209,323
fabioz/PyDev.Debugger
third_party/isort_container/isort/isort.py
get_stdlib_path
def get_stdlib_path(): """Returns the path to the standard lib for the current path installation. This function can be dropped and "sysconfig.get_paths()" used directly once Python 2.6 support is dropped. """ if sys.version_info >= (2, 7): import sysconfig return sysconfig.get_paths()['stdlib'] else: return os.path.join(sys.prefix, 'lib')
python
def get_stdlib_path(): """Returns the path to the standard lib for the current path installation. This function can be dropped and "sysconfig.get_paths()" used directly once Python 2.6 support is dropped. """ if sys.version_info >= (2, 7): import sysconfig return sysconfig.get_paths()['stdlib'] else: return os.path.join(sys.prefix, 'lib')
[ "def", "get_stdlib_path", "(", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "2", ",", "7", ")", ":", "import", "sysconfig", "return", "sysconfig", ".", "get_paths", "(", ")", "[", "'stdlib'", "]", "else", ":", "return", "os", ".", "path", "...
Returns the path to the standard lib for the current path installation. This function can be dropped and "sysconfig.get_paths()" used directly once Python 2.6 support is dropped.
[ "Returns", "the", "path", "to", "the", "standard", "lib", "for", "the", "current", "path", "installation", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/isort_container/isort/isort.py#L945-L954
train
209,324
fabioz/PyDev.Debugger
third_party/isort_container/isort/isort.py
exists_case_sensitive
def exists_case_sensitive(path): """ Returns if the given path exists and also matches the case on Windows. When finding files that can be imported, it is important for the cases to match because while file os.path.exists("module.py") and os.path.exists("MODULE.py") both return True on Windows, Python can only import using the case of the real file. """ result = os.path.exists(path) if sys.platform.startswith('win') and result: directory, basename = os.path.split(path) result = basename in os.listdir(directory) return result
python
def exists_case_sensitive(path): """ Returns if the given path exists and also matches the case on Windows. When finding files that can be imported, it is important for the cases to match because while file os.path.exists("module.py") and os.path.exists("MODULE.py") both return True on Windows, Python can only import using the case of the real file. """ result = os.path.exists(path) if sys.platform.startswith('win') and result: directory, basename = os.path.split(path) result = basename in os.listdir(directory) return result
[ "def", "exists_case_sensitive", "(", "path", ")", ":", "result", "=", "os", ".", "path", ".", "exists", "(", "path", ")", "if", "sys", ".", "platform", ".", "startswith", "(", "'win'", ")", "and", "result", ":", "directory", ",", "basename", "=", "os",...
Returns if the given path exists and also matches the case on Windows. When finding files that can be imported, it is important for the cases to match because while file os.path.exists("module.py") and os.path.exists("MODULE.py") both return True on Windows, Python can only import using the case of the real file.
[ "Returns", "if", "the", "given", "path", "exists", "and", "also", "matches", "the", "case", "on", "Windows", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/isort_container/isort/isort.py#L957-L969
train
209,325
fabioz/PyDev.Debugger
third_party/isort_container/isort/isort.py
SortImports._add_comments
def _add_comments(self, comments, original_string=""): """ Returns a string with comments added """ return comments and "{0} # {1}".format(self._strip_comments(original_string)[0], "; ".join(comments)) or original_string
python
def _add_comments(self, comments, original_string=""): """ Returns a string with comments added """ return comments and "{0} # {1}".format(self._strip_comments(original_string)[0], "; ".join(comments)) or original_string
[ "def", "_add_comments", "(", "self", ",", "comments", ",", "original_string", "=", "\"\"", ")", ":", "return", "comments", "and", "\"{0} # {1}\"", ".", "format", "(", "self", ".", "_strip_comments", "(", "original_string", ")", "[", "0", "]", ",", "\"; \"",...
Returns a string with comments added
[ "Returns", "a", "string", "with", "comments", "added" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/isort_container/isort/isort.py#L322-L327
train
209,326
fabioz/PyDev.Debugger
pydevd.py
settrace
def settrace( host=None, stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=False, overwrite_prev_trace=False, patch_multiprocessing=False, stop_at_frame=None, ): '''Sets the tracing function with the pydev debug function and initializes needed facilities. @param host: the user may specify another host, if the debug server is not in the same machine (default is the local host) @param stdoutToServer: when this is true, the stdout is passed to the debug server @param stderrToServer: when this is true, the stderr is passed to the debug server so that they are printed in its console and not in this process console. @param port: specifies which port to use for communicating with the server (note that the server must be started in the same port). @note: currently it's hard-coded at 5678 in the client @param suspend: whether a breakpoint should be emulated as soon as this function is called. @param trace_only_current_thread: determines if only the current thread will be traced or all current and future threads will also have the tracing enabled. @param overwrite_prev_trace: deprecated @param patch_multiprocessing: if True we'll patch the functions which create new processes so that launched processes are debugged. @param stop_at_frame: if passed it'll stop at the given frame, otherwise it'll stop in the function which called this method. ''' _set_trace_lock.acquire() try: _locked_settrace( host, stdoutToServer, stderrToServer, port, suspend, trace_only_current_thread, patch_multiprocessing, stop_at_frame, ) finally: _set_trace_lock.release()
python
def settrace( host=None, stdoutToServer=False, stderrToServer=False, port=5678, suspend=True, trace_only_current_thread=False, overwrite_prev_trace=False, patch_multiprocessing=False, stop_at_frame=None, ): '''Sets the tracing function with the pydev debug function and initializes needed facilities. @param host: the user may specify another host, if the debug server is not in the same machine (default is the local host) @param stdoutToServer: when this is true, the stdout is passed to the debug server @param stderrToServer: when this is true, the stderr is passed to the debug server so that they are printed in its console and not in this process console. @param port: specifies which port to use for communicating with the server (note that the server must be started in the same port). @note: currently it's hard-coded at 5678 in the client @param suspend: whether a breakpoint should be emulated as soon as this function is called. @param trace_only_current_thread: determines if only the current thread will be traced or all current and future threads will also have the tracing enabled. @param overwrite_prev_trace: deprecated @param patch_multiprocessing: if True we'll patch the functions which create new processes so that launched processes are debugged. @param stop_at_frame: if passed it'll stop at the given frame, otherwise it'll stop in the function which called this method. ''' _set_trace_lock.acquire() try: _locked_settrace( host, stdoutToServer, stderrToServer, port, suspend, trace_only_current_thread, patch_multiprocessing, stop_at_frame, ) finally: _set_trace_lock.release()
[ "def", "settrace", "(", "host", "=", "None", ",", "stdoutToServer", "=", "False", ",", "stderrToServer", "=", "False", ",", "port", "=", "5678", ",", "suspend", "=", "True", ",", "trace_only_current_thread", "=", "False", ",", "overwrite_prev_trace", "=", "F...
Sets the tracing function with the pydev debug function and initializes needed facilities. @param host: the user may specify another host, if the debug server is not in the same machine (default is the local host) @param stdoutToServer: when this is true, the stdout is passed to the debug server @param stderrToServer: when this is true, the stderr is passed to the debug server so that they are printed in its console and not in this process console. @param port: specifies which port to use for communicating with the server (note that the server must be started in the same port). @note: currently it's hard-coded at 5678 in the client @param suspend: whether a breakpoint should be emulated as soon as this function is called. @param trace_only_current_thread: determines if only the current thread will be traced or all current and future threads will also have the tracing enabled. @param overwrite_prev_trace: deprecated @param patch_multiprocessing: if True we'll patch the functions which create new processes so that launched processes are debugged. @param stop_at_frame: if passed it'll stop at the given frame, otherwise it'll stop in the function which called this method.
[ "Sets", "the", "tracing", "function", "with", "the", "pydev", "debug", "function", "and", "initializes", "needed", "facilities", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1829-L1879
train
209,327
fabioz/PyDev.Debugger
pydevd.py
settrace_forked
def settrace_forked(): ''' When creating a fork from a process in the debugger, we need to reset the whole debugger environment! ''' from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder GlobalDebuggerHolder.global_dbg = None threading.current_thread().additional_info = None from _pydevd_frame_eval.pydevd_frame_eval_main import clear_thread_local_info host, port = dispatch() import pydevd_tracing pydevd_tracing.restore_sys_set_trace_func() if port is not None: global connected connected = False global forked forked = True custom_frames_container_init() if clear_thread_local_info is not None: clear_thread_local_info() settrace( host, port=port, suspend=False, trace_only_current_thread=False, overwrite_prev_trace=True, patch_multiprocessing=True, )
python
def settrace_forked(): ''' When creating a fork from a process in the debugger, we need to reset the whole debugger environment! ''' from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder GlobalDebuggerHolder.global_dbg = None threading.current_thread().additional_info = None from _pydevd_frame_eval.pydevd_frame_eval_main import clear_thread_local_info host, port = dispatch() import pydevd_tracing pydevd_tracing.restore_sys_set_trace_func() if port is not None: global connected connected = False global forked forked = True custom_frames_container_init() if clear_thread_local_info is not None: clear_thread_local_info() settrace( host, port=port, suspend=False, trace_only_current_thread=False, overwrite_prev_trace=True, patch_multiprocessing=True, )
[ "def", "settrace_forked", "(", ")", ":", "from", "_pydevd_bundle", ".", "pydevd_constants", "import", "GlobalDebuggerHolder", "GlobalDebuggerHolder", ".", "global_dbg", "=", "None", "threading", ".", "current_thread", "(", ")", ".", "additional_info", "=", "None", "...
When creating a fork from a process in the debugger, we need to reset the whole debugger environment!
[ "When", "creating", "a", "fork", "from", "a", "process", "in", "the", "debugger", "we", "need", "to", "reset", "the", "whole", "debugger", "environment!" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L2086-L2118
train
209,328
fabioz/PyDev.Debugger
pydevd.py
PyDB.enable_tracing
def enable_tracing(self, thread_trace_func=None): ''' Enables tracing. If in regular mode (tracing), will set the tracing function to the tracing function for this thread -- by default it's `PyDB.trace_dispatch`, but after `PyDB.enable_tracing` is called with a `thread_trace_func`, the given function will be the default for the given thread. ''' if self.frame_eval_func is not None: self.frame_eval_func() pydevd_tracing.SetTrace(self.dummy_trace_dispatch) return if thread_trace_func is None: thread_trace_func = self.get_thread_local_trace_func() else: self._local_thread_trace_func.thread_trace_func = thread_trace_func pydevd_tracing.SetTrace(thread_trace_func)
python
def enable_tracing(self, thread_trace_func=None): ''' Enables tracing. If in regular mode (tracing), will set the tracing function to the tracing function for this thread -- by default it's `PyDB.trace_dispatch`, but after `PyDB.enable_tracing` is called with a `thread_trace_func`, the given function will be the default for the given thread. ''' if self.frame_eval_func is not None: self.frame_eval_func() pydevd_tracing.SetTrace(self.dummy_trace_dispatch) return if thread_trace_func is None: thread_trace_func = self.get_thread_local_trace_func() else: self._local_thread_trace_func.thread_trace_func = thread_trace_func pydevd_tracing.SetTrace(thread_trace_func)
[ "def", "enable_tracing", "(", "self", ",", "thread_trace_func", "=", "None", ")", ":", "if", "self", ".", "frame_eval_func", "is", "not", "None", ":", "self", ".", "frame_eval_func", "(", ")", "pydevd_tracing", ".", "SetTrace", "(", "self", ".", "dummy_trace...
Enables tracing. If in regular mode (tracing), will set the tracing function to the tracing function for this thread -- by default it's `PyDB.trace_dispatch`, but after `PyDB.enable_tracing` is called with a `thread_trace_func`, the given function will be the default for the given thread.
[ "Enables", "tracing", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L622-L641
train
209,329
fabioz/PyDev.Debugger
pydevd.py
PyDB.on_breakpoints_changed
def on_breakpoints_changed(self, removed=False): ''' When breakpoints change, we have to re-evaluate all the assumptions we've made so far. ''' if not self.ready_to_run: # No need to do anything if we're still not running. return self.mtime += 1 if not removed: # When removing breakpoints we can leave tracing as was, but if a breakpoint was added # we have to reset the tracing for the existing functions to be re-evaluated. self.set_tracing_for_untraced_contexts()
python
def on_breakpoints_changed(self, removed=False): ''' When breakpoints change, we have to re-evaluate all the assumptions we've made so far. ''' if not self.ready_to_run: # No need to do anything if we're still not running. return self.mtime += 1 if not removed: # When removing breakpoints we can leave tracing as was, but if a breakpoint was added # we have to reset the tracing for the existing functions to be re-evaluated. self.set_tracing_for_untraced_contexts()
[ "def", "on_breakpoints_changed", "(", "self", ",", "removed", "=", "False", ")", ":", "if", "not", "self", ".", "ready_to_run", ":", "# No need to do anything if we're still not running.", "return", "self", ".", "mtime", "+=", "1", "if", "not", "removed", ":", "...
When breakpoints change, we have to re-evaluate all the assumptions we've made so far.
[ "When", "breakpoints", "change", "we", "have", "to", "re", "-", "evaluate", "all", "the", "assumptions", "we", "ve", "made", "so", "far", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L646-L658
train
209,330
fabioz/PyDev.Debugger
pydevd.py
PyDB.apply_files_filter
def apply_files_filter(self, frame, filename, force_check_project_scope): ''' Should only be called if `self.is_files_filter_enabled == True`. Note that it covers both the filter by specific paths includes/excludes as well as the check which filters out libraries if not in the project scope. :param force_check_project_scope: Check that the file is in the project scope even if the global setting is off. :return bool: True if it should be excluded when stepping and False if it should be included. ''' cache_key = (frame.f_code.co_firstlineno, frame.f_code.co_name, filename, force_check_project_scope) try: return self._apply_filter_cache[cache_key] except KeyError: if self.plugin is not None and (self.has_plugin_line_breaks or self.has_plugin_exception_breaks): # If it's explicitly needed by some plugin, we can't skip it. if not self.plugin.can_skip(self, frame): # print('include (include by plugins): %s' % filename) self._apply_filter_cache[cache_key] = False return False if self._exclude_filters_enabled: exclude_by_filter = self._exclude_by_filter(frame, filename) if exclude_by_filter is not None: if exclude_by_filter: # ignore files matching stepping filters # print('exclude (filtered out): %s' % filename) self._apply_filter_cache[cache_key] = True return True else: # print('include (explicitly included): %s' % filename) self._apply_filter_cache[cache_key] = False return False if (self._is_libraries_filter_enabled or force_check_project_scope) and not self.in_project_scope(filename): # print('exclude (not on project): %s' % filename) # ignore library files while stepping self._apply_filter_cache[cache_key] = True return True # print('include (on project): %s' % filename) self._apply_filter_cache[cache_key] = False return False
python
def apply_files_filter(self, frame, filename, force_check_project_scope): ''' Should only be called if `self.is_files_filter_enabled == True`. Note that it covers both the filter by specific paths includes/excludes as well as the check which filters out libraries if not in the project scope. :param force_check_project_scope: Check that the file is in the project scope even if the global setting is off. :return bool: True if it should be excluded when stepping and False if it should be included. ''' cache_key = (frame.f_code.co_firstlineno, frame.f_code.co_name, filename, force_check_project_scope) try: return self._apply_filter_cache[cache_key] except KeyError: if self.plugin is not None and (self.has_plugin_line_breaks or self.has_plugin_exception_breaks): # If it's explicitly needed by some plugin, we can't skip it. if not self.plugin.can_skip(self, frame): # print('include (include by plugins): %s' % filename) self._apply_filter_cache[cache_key] = False return False if self._exclude_filters_enabled: exclude_by_filter = self._exclude_by_filter(frame, filename) if exclude_by_filter is not None: if exclude_by_filter: # ignore files matching stepping filters # print('exclude (filtered out): %s' % filename) self._apply_filter_cache[cache_key] = True return True else: # print('include (explicitly included): %s' % filename) self._apply_filter_cache[cache_key] = False return False if (self._is_libraries_filter_enabled or force_check_project_scope) and not self.in_project_scope(filename): # print('exclude (not on project): %s' % filename) # ignore library files while stepping self._apply_filter_cache[cache_key] = True return True # print('include (on project): %s' % filename) self._apply_filter_cache[cache_key] = False return False
[ "def", "apply_files_filter", "(", "self", ",", "frame", ",", "filename", ",", "force_check_project_scope", ")", ":", "cache_key", "=", "(", "frame", ".", "f_code", ".", "co_firstlineno", ",", "frame", ".", "f_code", ".", "co_name", ",", "filename", ",", "for...
Should only be called if `self.is_files_filter_enabled == True`. Note that it covers both the filter by specific paths includes/excludes as well as the check which filters out libraries if not in the project scope. :param force_check_project_scope: Check that the file is in the project scope even if the global setting is off. :return bool: True if it should be excluded when stepping and False if it should be included.
[ "Should", "only", "be", "called", "if", "self", ".", "is_files_filter_enabled", "==", "True", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L754-L801
train
209,331
fabioz/PyDev.Debugger
pydevd.py
PyDB.get_internal_queue
def get_internal_queue(self, thread_id): """ returns internal command queue for a given thread. if new queue is created, notify the RDB about it """ if thread_id.startswith('__frame__'): thread_id = thread_id[thread_id.rfind('|') + 1:] return self._cmd_queue[thread_id]
python
def get_internal_queue(self, thread_id): """ returns internal command queue for a given thread. if new queue is created, notify the RDB about it """ if thread_id.startswith('__frame__'): thread_id = thread_id[thread_id.rfind('|') + 1:] return self._cmd_queue[thread_id]
[ "def", "get_internal_queue", "(", "self", ",", "thread_id", ")", ":", "if", "thread_id", ".", "startswith", "(", "'__frame__'", ")", ":", "thread_id", "=", "thread_id", "[", "thread_id", ".", "rfind", "(", "'|'", ")", "+", "1", ":", "]", "return", "self"...
returns internal command queue for a given thread. if new queue is created, notify the RDB about it
[ "returns", "internal", "command", "queue", "for", "a", "given", "thread", ".", "if", "new", "queue", "is", "created", "notify", "the", "RDB", "about", "it" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L877-L882
train
209,332
fabioz/PyDev.Debugger
pydevd.py
PyDB.notify_thread_not_alive
def notify_thread_not_alive(self, thread_id, use_lock=True): """ if thread is not alive, cancel trace_dispatch processing """ if self.writer is None: return with self._lock_running_thread_ids if use_lock else NULL: if not self._enable_thread_notifications: return thread = self._running_thread_ids.pop(thread_id, None) if thread is None: return was_notified = thread.additional_info.pydev_notify_kill if not was_notified: thread.additional_info.pydev_notify_kill = True self.writer.add_command(self.cmd_factory.make_thread_killed_message(thread_id))
python
def notify_thread_not_alive(self, thread_id, use_lock=True): """ if thread is not alive, cancel trace_dispatch processing """ if self.writer is None: return with self._lock_running_thread_ids if use_lock else NULL: if not self._enable_thread_notifications: return thread = self._running_thread_ids.pop(thread_id, None) if thread is None: return was_notified = thread.additional_info.pydev_notify_kill if not was_notified: thread.additional_info.pydev_notify_kill = True self.writer.add_command(self.cmd_factory.make_thread_killed_message(thread_id))
[ "def", "notify_thread_not_alive", "(", "self", ",", "thread_id", ",", "use_lock", "=", "True", ")", ":", "if", "self", ".", "writer", "is", "None", ":", "return", "with", "self", ".", "_lock_running_thread_ids", "if", "use_lock", "else", "NULL", ":", "if", ...
if thread is not alive, cancel trace_dispatch processing
[ "if", "thread", "is", "not", "alive", "cancel", "trace_dispatch", "processing" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L992-L1009
train
209,333
fabioz/PyDev.Debugger
pydevd.py
PyDB.process_internal_commands
def process_internal_commands(self): '''This function processes internal commands ''' with self._main_lock: self.check_output_redirect() program_threads_alive = {} all_threads = threadingEnumerate() program_threads_dead = [] with self._lock_running_thread_ids: reset_cache = not self._running_thread_ids for t in all_threads: if getattr(t, 'is_pydev_daemon_thread', False): pass # I.e.: skip the DummyThreads created from pydev daemon threads elif isinstance(t, PyDBDaemonThread): pydev_log.error_once('Error in debugger: Found PyDBDaemonThread not marked with is_pydev_daemon_thread=True.') elif is_thread_alive(t): if reset_cache: # Fix multiprocessing debug with breakpoints in both main and child processes # (https://youtrack.jetbrains.com/issue/PY-17092) When the new process is created, the main # thread in the new process already has the attribute 'pydevd_id', so the new thread doesn't # get new id with its process number and the debugger loses access to both threads. # Therefore we should update thread_id for every main thread in the new process. clear_cached_thread_id(t) thread_id = get_thread_id(t) program_threads_alive[thread_id] = t self.notify_thread_created(thread_id, t, use_lock=False) # Compute and notify about threads which are no longer alive. thread_ids = list(self._running_thread_ids.keys()) for thread_id in thread_ids: if thread_id not in program_threads_alive: program_threads_dead.append(thread_id) for thread_id in program_threads_dead: self.notify_thread_not_alive(thread_id, use_lock=False) # Without self._lock_running_thread_ids if len(program_threads_alive) == 0: self.finish_debugging_session() for t in all_threads: if hasattr(t, 'do_kill_pydev_thread'): t.do_kill_pydev_thread() else: # Actually process the commands now (make sure we don't have a lock for _lock_running_thread_ids # acquired at this point as it could lead to a deadlock if some command evaluated tried to # create a thread and wait for it -- which would try to notify about it getting that lock). curr_thread_id = get_current_thread_id(threadingCurrentThread()) for thread_id in (curr_thread_id, '*'): queue = self.get_internal_queue(thread_id) # some commands must be processed by the thread itself... if that's the case, # we will re-add the commands to the queue after executing. cmds_to_add_back = [] try: while True: int_cmd = queue.get(False) if not self.mpl_hooks_in_debug_console and isinstance(int_cmd, InternalConsoleExec): # add import hooks for matplotlib patches if only debug console was started try: self.init_matplotlib_in_debug_console() self.mpl_in_use = True except: pydev_log.debug("Matplotlib support in debug console failed", traceback.format_exc()) self.mpl_hooks_in_debug_console = True if int_cmd.can_be_executed_by(curr_thread_id): pydev_log.verbose("processing internal command ", int_cmd) int_cmd.do_it(self) else: pydev_log.verbose("NOT processing internal command ", int_cmd) cmds_to_add_back.append(int_cmd) except _queue.Empty: # @UndefinedVariable # this is how we exit for int_cmd in cmds_to_add_back: queue.put(int_cmd)
python
def process_internal_commands(self): '''This function processes internal commands ''' with self._main_lock: self.check_output_redirect() program_threads_alive = {} all_threads = threadingEnumerate() program_threads_dead = [] with self._lock_running_thread_ids: reset_cache = not self._running_thread_ids for t in all_threads: if getattr(t, 'is_pydev_daemon_thread', False): pass # I.e.: skip the DummyThreads created from pydev daemon threads elif isinstance(t, PyDBDaemonThread): pydev_log.error_once('Error in debugger: Found PyDBDaemonThread not marked with is_pydev_daemon_thread=True.') elif is_thread_alive(t): if reset_cache: # Fix multiprocessing debug with breakpoints in both main and child processes # (https://youtrack.jetbrains.com/issue/PY-17092) When the new process is created, the main # thread in the new process already has the attribute 'pydevd_id', so the new thread doesn't # get new id with its process number and the debugger loses access to both threads. # Therefore we should update thread_id for every main thread in the new process. clear_cached_thread_id(t) thread_id = get_thread_id(t) program_threads_alive[thread_id] = t self.notify_thread_created(thread_id, t, use_lock=False) # Compute and notify about threads which are no longer alive. thread_ids = list(self._running_thread_ids.keys()) for thread_id in thread_ids: if thread_id not in program_threads_alive: program_threads_dead.append(thread_id) for thread_id in program_threads_dead: self.notify_thread_not_alive(thread_id, use_lock=False) # Without self._lock_running_thread_ids if len(program_threads_alive) == 0: self.finish_debugging_session() for t in all_threads: if hasattr(t, 'do_kill_pydev_thread'): t.do_kill_pydev_thread() else: # Actually process the commands now (make sure we don't have a lock for _lock_running_thread_ids # acquired at this point as it could lead to a deadlock if some command evaluated tried to # create a thread and wait for it -- which would try to notify about it getting that lock). curr_thread_id = get_current_thread_id(threadingCurrentThread()) for thread_id in (curr_thread_id, '*'): queue = self.get_internal_queue(thread_id) # some commands must be processed by the thread itself... if that's the case, # we will re-add the commands to the queue after executing. cmds_to_add_back = [] try: while True: int_cmd = queue.get(False) if not self.mpl_hooks_in_debug_console and isinstance(int_cmd, InternalConsoleExec): # add import hooks for matplotlib patches if only debug console was started try: self.init_matplotlib_in_debug_console() self.mpl_in_use = True except: pydev_log.debug("Matplotlib support in debug console failed", traceback.format_exc()) self.mpl_hooks_in_debug_console = True if int_cmd.can_be_executed_by(curr_thread_id): pydev_log.verbose("processing internal command ", int_cmd) int_cmd.do_it(self) else: pydev_log.verbose("NOT processing internal command ", int_cmd) cmds_to_add_back.append(int_cmd) except _queue.Empty: # @UndefinedVariable # this is how we exit for int_cmd in cmds_to_add_back: queue.put(int_cmd)
[ "def", "process_internal_commands", "(", "self", ")", ":", "with", "self", ".", "_main_lock", ":", "self", ".", "check_output_redirect", "(", ")", "program_threads_alive", "=", "{", "}", "all_threads", "=", "threadingEnumerate", "(", ")", "program_threads_dead", "...
This function processes internal commands
[ "This", "function", "processes", "internal", "commands" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1021-L1104
train
209,334
fabioz/PyDev.Debugger
pydevd.py
PyDB._send_breakpoint_condition_exception
def _send_breakpoint_condition_exception(self, thread, conditional_breakpoint_exception_tuple): """If conditional breakpoint raises an exception during evaluation send exception details to java """ thread_id = get_thread_id(thread) # conditional_breakpoint_exception_tuple - should contain 2 values (exception_type, stacktrace) if conditional_breakpoint_exception_tuple and len(conditional_breakpoint_exception_tuple) == 2: exc_type, stacktrace = conditional_breakpoint_exception_tuple int_cmd = InternalGetBreakpointException(thread_id, exc_type, stacktrace) self.post_internal_command(int_cmd, thread_id)
python
def _send_breakpoint_condition_exception(self, thread, conditional_breakpoint_exception_tuple): """If conditional breakpoint raises an exception during evaluation send exception details to java """ thread_id = get_thread_id(thread) # conditional_breakpoint_exception_tuple - should contain 2 values (exception_type, stacktrace) if conditional_breakpoint_exception_tuple and len(conditional_breakpoint_exception_tuple) == 2: exc_type, stacktrace = conditional_breakpoint_exception_tuple int_cmd = InternalGetBreakpointException(thread_id, exc_type, stacktrace) self.post_internal_command(int_cmd, thread_id)
[ "def", "_send_breakpoint_condition_exception", "(", "self", ",", "thread", ",", "conditional_breakpoint_exception_tuple", ")", ":", "thread_id", "=", "get_thread_id", "(", "thread", ")", "# conditional_breakpoint_exception_tuple - should contain 2 values (exception_type, stacktrace)"...
If conditional breakpoint raises an exception during evaluation send exception details to java
[ "If", "conditional", "breakpoint", "raises", "an", "exception", "during", "evaluation", "send", "exception", "details", "to", "java" ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1233-L1242
train
209,335
fabioz/PyDev.Debugger
pydevd.py
PyDB.send_caught_exception_stack_proceeded
def send_caught_exception_stack_proceeded(self, thread): """Sends that some thread was resumed and is no longer showing an exception trace. """ thread_id = get_thread_id(thread) int_cmd = InternalSendCurrExceptionTraceProceeded(thread_id) self.post_internal_command(int_cmd, thread_id) self.process_internal_commands()
python
def send_caught_exception_stack_proceeded(self, thread): """Sends that some thread was resumed and is no longer showing an exception trace. """ thread_id = get_thread_id(thread) int_cmd = InternalSendCurrExceptionTraceProceeded(thread_id) self.post_internal_command(int_cmd, thread_id) self.process_internal_commands()
[ "def", "send_caught_exception_stack_proceeded", "(", "self", ",", "thread", ")", ":", "thread_id", "=", "get_thread_id", "(", "thread", ")", "int_cmd", "=", "InternalSendCurrExceptionTraceProceeded", "(", "thread_id", ")", "self", ".", "post_internal_command", "(", "i...
Sends that some thread was resumed and is no longer showing an exception trace.
[ "Sends", "that", "some", "thread", "was", "resumed", "and", "is", "no", "longer", "showing", "an", "exception", "trace", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1253-L1259
train
209,336
fabioz/PyDev.Debugger
pydevd.py
PyDB.send_process_created_message
def send_process_created_message(self): """Sends a message that a new process has been created. """ cmd = self.cmd_factory.make_process_created_message() self.writer.add_command(cmd)
python
def send_process_created_message(self): """Sends a message that a new process has been created. """ cmd = self.cmd_factory.make_process_created_message() self.writer.add_command(cmd)
[ "def", "send_process_created_message", "(", "self", ")", ":", "cmd", "=", "self", ".", "cmd_factory", ".", "make_process_created_message", "(", ")", "self", ".", "writer", ".", "add_command", "(", "cmd", ")" ]
Sends a message that a new process has been created.
[ "Sends", "a", "message", "that", "a", "new", "process", "has", "been", "created", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1261-L1265
train
209,337
fabioz/PyDev.Debugger
pydevd.py
PyDB.do_wait_suspend
def do_wait_suspend(self, thread, frame, event, arg, is_unhandled_exception=False): # @UnusedVariable """ busy waits until the thread state changes to RUN it expects thread's state as attributes of the thread. Upon running, processes any outstanding Stepping commands. :param is_unhandled_exception: If True we should use the line of the exception instead of the current line in the frame as the paused location on the top-level frame (exception info must be passed on 'arg'). """ # print('do_wait_suspend %s %s %s %s' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event)) self.process_internal_commands() thread_id = get_current_thread_id(thread) # Send the suspend message message = thread.additional_info.pydev_message suspend_type = thread.additional_info.trace_suspend_type thread.additional_info.trace_suspend_type = 'trace' # Reset to trace mode for next call. frame_id_to_lineno = {} stop_reason = thread.stop_reason if is_unhandled_exception: # arg must be the exception info (tuple(exc_type, exc, traceback)) tb = arg[2] while tb is not None: frame_id_to_lineno[id(tb.tb_frame)] = tb.tb_lineno tb = tb.tb_next with self.suspended_frames_manager.track_frames(self) as frames_tracker: frames_tracker.track(thread_id, frame, frame_id_to_lineno) cmd = frames_tracker.create_thread_suspend_command(thread_id, stop_reason, message, suspend_type) self.writer.add_command(cmd) with CustomFramesContainer.custom_frames_lock: # @UndefinedVariable from_this_thread = [] for frame_custom_thread_id, custom_frame in dict_iter_items(CustomFramesContainer.custom_frames): if custom_frame.thread_id == thread.ident: frames_tracker.track(thread_id, custom_frame.frame, frame_id_to_lineno, frame_custom_thread_id=frame_custom_thread_id) # print('Frame created as thread: %s' % (frame_custom_thread_id,)) self.writer.add_command(self.cmd_factory.make_custom_frame_created_message( frame_custom_thread_id, custom_frame.name)) self.writer.add_command( frames_tracker.create_thread_suspend_command(frame_custom_thread_id, CMD_THREAD_SUSPEND, "", suspend_type)) from_this_thread.append(frame_custom_thread_id) with self._threads_suspended_single_notification.notify_thread_suspended(thread_id, stop_reason): keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker) if keep_suspended: # This means that we should pause again after a set next statement. self._threads_suspended_single_notification.increment_suspend_time() self.do_wait_suspend(thread, frame, event, arg, is_unhandled_exception)
python
def do_wait_suspend(self, thread, frame, event, arg, is_unhandled_exception=False): # @UnusedVariable """ busy waits until the thread state changes to RUN it expects thread's state as attributes of the thread. Upon running, processes any outstanding Stepping commands. :param is_unhandled_exception: If True we should use the line of the exception instead of the current line in the frame as the paused location on the top-level frame (exception info must be passed on 'arg'). """ # print('do_wait_suspend %s %s %s %s' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, event)) self.process_internal_commands() thread_id = get_current_thread_id(thread) # Send the suspend message message = thread.additional_info.pydev_message suspend_type = thread.additional_info.trace_suspend_type thread.additional_info.trace_suspend_type = 'trace' # Reset to trace mode for next call. frame_id_to_lineno = {} stop_reason = thread.stop_reason if is_unhandled_exception: # arg must be the exception info (tuple(exc_type, exc, traceback)) tb = arg[2] while tb is not None: frame_id_to_lineno[id(tb.tb_frame)] = tb.tb_lineno tb = tb.tb_next with self.suspended_frames_manager.track_frames(self) as frames_tracker: frames_tracker.track(thread_id, frame, frame_id_to_lineno) cmd = frames_tracker.create_thread_suspend_command(thread_id, stop_reason, message, suspend_type) self.writer.add_command(cmd) with CustomFramesContainer.custom_frames_lock: # @UndefinedVariable from_this_thread = [] for frame_custom_thread_id, custom_frame in dict_iter_items(CustomFramesContainer.custom_frames): if custom_frame.thread_id == thread.ident: frames_tracker.track(thread_id, custom_frame.frame, frame_id_to_lineno, frame_custom_thread_id=frame_custom_thread_id) # print('Frame created as thread: %s' % (frame_custom_thread_id,)) self.writer.add_command(self.cmd_factory.make_custom_frame_created_message( frame_custom_thread_id, custom_frame.name)) self.writer.add_command( frames_tracker.create_thread_suspend_command(frame_custom_thread_id, CMD_THREAD_SUSPEND, "", suspend_type)) from_this_thread.append(frame_custom_thread_id) with self._threads_suspended_single_notification.notify_thread_suspended(thread_id, stop_reason): keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker) if keep_suspended: # This means that we should pause again after a set next statement. self._threads_suspended_single_notification.increment_suspend_time() self.do_wait_suspend(thread, frame, event, arg, is_unhandled_exception)
[ "def", "do_wait_suspend", "(", "self", ",", "thread", ",", "frame", ",", "event", ",", "arg", ",", "is_unhandled_exception", "=", "False", ")", ":", "# @UnusedVariable", "# print('do_wait_suspend %s %s %s %s' % (frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename, ev...
busy waits until the thread state changes to RUN it expects thread's state as attributes of the thread. Upon running, processes any outstanding Stepping commands. :param is_unhandled_exception: If True we should use the line of the exception instead of the current line in the frame as the paused location on the top-level frame (exception info must be passed on 'arg').
[ "busy", "waits", "until", "the", "thread", "state", "changes", "to", "RUN", "it", "expects", "thread", "s", "state", "as", "attributes", "of", "the", "thread", ".", "Upon", "running", "processes", "any", "outstanding", "Stepping", "commands", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd.py#L1308-L1362
train
209,338
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/version.py
_get_arch
def _get_arch(): """ Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: - L{ARCH_I386} (C{"i386"}) for Intel 32-bit x86 processor or compatible. - L{ARCH_AMD64} (C{"amd64"}) for Intel 64-bit x86_64 processor or compatible. May also return one of the following values if you get both Python and WinAppDbg to work in such machines... let me know if you do! :) - L{ARCH_MIPS} (C{"mips"}) for MIPS compatible processors. - L{ARCH_ALPHA} (C{"alpha"}) for Alpha processors. - L{ARCH_PPC} (C{"ppc"}) for PowerPC compatible processors. - L{ARCH_SHX} (C{"shx"}) for Hitachi SH processors. - L{ARCH_ARM} (C{"arm"}) for ARM compatible processors. - L{ARCH_IA64} (C{"ia64"}) for Intel Itanium processor or compatible. - L{ARCH_ALPHA64} (C{"alpha64"}) for Alpha64 processors. - L{ARCH_MSIL} (C{"msil"}) for the .NET virtual machine. - L{ARCH_SPARC} (C{"sparc"}) for Sun Sparc processors. Probably IronPython returns C{ARCH_MSIL} but I haven't tried it. Python on Windows CE and Windows Mobile should return C{ARCH_ARM}. Python on Solaris using Wine would return C{ARCH_SPARC}. Python in an Itanium machine should return C{ARCH_IA64} both on Wine and proper Windows. All other values should only be returned on Linux using Wine. """ try: si = GetNativeSystemInfo() except Exception: si = GetSystemInfo() try: return _arch_map[si.id.w.wProcessorArchitecture] except KeyError: return ARCH_UNKNOWN
python
def _get_arch(): """ Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: - L{ARCH_I386} (C{"i386"}) for Intel 32-bit x86 processor or compatible. - L{ARCH_AMD64} (C{"amd64"}) for Intel 64-bit x86_64 processor or compatible. May also return one of the following values if you get both Python and WinAppDbg to work in such machines... let me know if you do! :) - L{ARCH_MIPS} (C{"mips"}) for MIPS compatible processors. - L{ARCH_ALPHA} (C{"alpha"}) for Alpha processors. - L{ARCH_PPC} (C{"ppc"}) for PowerPC compatible processors. - L{ARCH_SHX} (C{"shx"}) for Hitachi SH processors. - L{ARCH_ARM} (C{"arm"}) for ARM compatible processors. - L{ARCH_IA64} (C{"ia64"}) for Intel Itanium processor or compatible. - L{ARCH_ALPHA64} (C{"alpha64"}) for Alpha64 processors. - L{ARCH_MSIL} (C{"msil"}) for the .NET virtual machine. - L{ARCH_SPARC} (C{"sparc"}) for Sun Sparc processors. Probably IronPython returns C{ARCH_MSIL} but I haven't tried it. Python on Windows CE and Windows Mobile should return C{ARCH_ARM}. Python on Solaris using Wine would return C{ARCH_SPARC}. Python in an Itanium machine should return C{ARCH_IA64} both on Wine and proper Windows. All other values should only be returned on Linux using Wine. """ try: si = GetNativeSystemInfo() except Exception: si = GetSystemInfo() try: return _arch_map[si.id.w.wProcessorArchitecture] except KeyError: return ARCH_UNKNOWN
[ "def", "_get_arch", "(", ")", ":", "try", ":", "si", "=", "GetNativeSystemInfo", "(", ")", "except", "Exception", ":", "si", "=", "GetSystemInfo", "(", ")", "try", ":", "return", "_arch_map", "[", "si", ".", "id", ".", "w", ".", "wProcessorArchitecture",...
Determines the current processor architecture. @rtype: str @return: On error, returns: - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. On success, returns one of the following values: - L{ARCH_I386} (C{"i386"}) for Intel 32-bit x86 processor or compatible. - L{ARCH_AMD64} (C{"amd64"}) for Intel 64-bit x86_64 processor or compatible. May also return one of the following values if you get both Python and WinAppDbg to work in such machines... let me know if you do! :) - L{ARCH_MIPS} (C{"mips"}) for MIPS compatible processors. - L{ARCH_ALPHA} (C{"alpha"}) for Alpha processors. - L{ARCH_PPC} (C{"ppc"}) for PowerPC compatible processors. - L{ARCH_SHX} (C{"shx"}) for Hitachi SH processors. - L{ARCH_ARM} (C{"arm"}) for ARM compatible processors. - L{ARCH_IA64} (C{"ia64"}) for Intel Itanium processor or compatible. - L{ARCH_ALPHA64} (C{"alpha64"}) for Alpha64 processors. - L{ARCH_MSIL} (C{"msil"}) for the .NET virtual machine. - L{ARCH_SPARC} (C{"sparc"}) for Sun Sparc processors. Probably IronPython returns C{ARCH_MSIL} but I haven't tried it. Python on Windows CE and Windows Mobile should return C{ARCH_ARM}. Python on Solaris using Wine would return C{ARCH_SPARC}. Python in an Itanium machine should return C{ARCH_IA64} both on Wine and proper Windows. All other values should only be returned on Linux using Wine.
[ "Determines", "the", "current", "processor", "architecture", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/version.py#L675-L716
train
209,339
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/version.py
_get_wow64
def _get_wow64(): """ Determines if the current process is running in Windows-On-Windows 64 bits. @rtype: bool @return: C{True} of the current process is a 32 bit program running in a 64 bit version of Windows, C{False} if it's either a 32 bit program in a 32 bit Windows or a 64 bit program in a 64 bit Windows. """ # Try to determine if the debugger itself is running on WOW64. # On error assume False. if bits == 64: wow64 = False else: try: wow64 = IsWow64Process( GetCurrentProcess() ) except Exception: wow64 = False return wow64
python
def _get_wow64(): """ Determines if the current process is running in Windows-On-Windows 64 bits. @rtype: bool @return: C{True} of the current process is a 32 bit program running in a 64 bit version of Windows, C{False} if it's either a 32 bit program in a 32 bit Windows or a 64 bit program in a 64 bit Windows. """ # Try to determine if the debugger itself is running on WOW64. # On error assume False. if bits == 64: wow64 = False else: try: wow64 = IsWow64Process( GetCurrentProcess() ) except Exception: wow64 = False return wow64
[ "def", "_get_wow64", "(", ")", ":", "# Try to determine if the debugger itself is running on WOW64.", "# On error assume False.", "if", "bits", "==", "64", ":", "wow64", "=", "False", "else", ":", "try", ":", "wow64", "=", "IsWow64Process", "(", "GetCurrentProcess", "...
Determines if the current process is running in Windows-On-Windows 64 bits. @rtype: bool @return: C{True} of the current process is a 32 bit program running in a 64 bit version of Windows, C{False} if it's either a 32 bit program in a 32 bit Windows or a 64 bit program in a 64 bit Windows.
[ "Determines", "if", "the", "current", "process", "is", "running", "in", "Windows", "-", "On", "-", "Windows", "64", "bits", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/version.py#L718-L736
train
209,340
fabioz/PyDev.Debugger
_pydev_bundle/pydev_log.py
log_context
def log_context(trace_level, stream): ''' To be used to temporarily change the logging settings. ''' original_trace_level = DebugInfoHolder.DEBUG_TRACE_LEVEL original_stream = DebugInfoHolder.DEBUG_STREAM DebugInfoHolder.DEBUG_TRACE_LEVEL = trace_level DebugInfoHolder.DEBUG_STREAM = stream try: yield finally: DebugInfoHolder.DEBUG_TRACE_LEVEL = original_trace_level DebugInfoHolder.DEBUG_STREAM = original_stream
python
def log_context(trace_level, stream): ''' To be used to temporarily change the logging settings. ''' original_trace_level = DebugInfoHolder.DEBUG_TRACE_LEVEL original_stream = DebugInfoHolder.DEBUG_STREAM DebugInfoHolder.DEBUG_TRACE_LEVEL = trace_level DebugInfoHolder.DEBUG_STREAM = stream try: yield finally: DebugInfoHolder.DEBUG_TRACE_LEVEL = original_trace_level DebugInfoHolder.DEBUG_STREAM = original_stream
[ "def", "log_context", "(", "trace_level", ",", "stream", ")", ":", "original_trace_level", "=", "DebugInfoHolder", ".", "DEBUG_TRACE_LEVEL", "original_stream", "=", "DebugInfoHolder", ".", "DEBUG_STREAM", "DebugInfoHolder", ".", "DEBUG_TRACE_LEVEL", "=", "trace_level", ...
To be used to temporarily change the logging settings.
[ "To", "be", "used", "to", "temporarily", "change", "the", "logging", "settings", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_log.py#L11-L24
train
209,341
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
Crash.__is_control_flow
def __is_control_flow(self): """ Private method to tell if the instruction pointed to by the program counter is a control flow instruction. Currently only works for x86 and amd64 architectures. """ jump_instructions = ( 'jmp', 'jecxz', 'jcxz', 'ja', 'jnbe', 'jae', 'jnb', 'jb', 'jnae', 'jbe', 'jna', 'jc', 'je', 'jz', 'jnc', 'jne', 'jnz', 'jnp', 'jpo', 'jp', 'jpe', 'jg', 'jnle', 'jge', 'jnl', 'jl', 'jnge', 'jle', 'jng', 'jno', 'jns', 'jo', 'js' ) call_instructions = ( 'call', 'ret', 'retn' ) loop_instructions = ( 'loop', 'loopz', 'loopnz', 'loope', 'loopne' ) control_flow_instructions = call_instructions + loop_instructions + \ jump_instructions isControlFlow = False instruction = None if self.pc is not None and self.faultDisasm: for disasm in self.faultDisasm: if disasm[0] == self.pc: instruction = disasm[2].lower().strip() break if instruction: for x in control_flow_instructions: if x in instruction: isControlFlow = True break return isControlFlow
python
def __is_control_flow(self): """ Private method to tell if the instruction pointed to by the program counter is a control flow instruction. Currently only works for x86 and amd64 architectures. """ jump_instructions = ( 'jmp', 'jecxz', 'jcxz', 'ja', 'jnbe', 'jae', 'jnb', 'jb', 'jnae', 'jbe', 'jna', 'jc', 'je', 'jz', 'jnc', 'jne', 'jnz', 'jnp', 'jpo', 'jp', 'jpe', 'jg', 'jnle', 'jge', 'jnl', 'jl', 'jnge', 'jle', 'jng', 'jno', 'jns', 'jo', 'js' ) call_instructions = ( 'call', 'ret', 'retn' ) loop_instructions = ( 'loop', 'loopz', 'loopnz', 'loope', 'loopne' ) control_flow_instructions = call_instructions + loop_instructions + \ jump_instructions isControlFlow = False instruction = None if self.pc is not None and self.faultDisasm: for disasm in self.faultDisasm: if disasm[0] == self.pc: instruction = disasm[2].lower().strip() break if instruction: for x in control_flow_instructions: if x in instruction: isControlFlow = True break return isControlFlow
[ "def", "__is_control_flow", "(", "self", ")", ":", "jump_instructions", "=", "(", "'jmp'", ",", "'jecxz'", ",", "'jcxz'", ",", "'ja'", ",", "'jnbe'", ",", "'jae'", ",", "'jnb'", ",", "'jb'", ",", "'jnae'", ",", "'jbe'", ",", "'jna'", ",", "'jc'", ",", ...
Private method to tell if the instruction pointed to by the program counter is a control flow instruction. Currently only works for x86 and amd64 architectures.
[ "Private", "method", "to", "tell", "if", "the", "instruction", "pointed", "to", "by", "the", "program", "counter", "is", "a", "control", "flow", "instruction", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L847-L876
train
209,342
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
Crash.__is_block_data_move
def __is_block_data_move(self): """ Private method to tell if the instruction pointed to by the program counter is a block data move instruction. Currently only works for x86 and amd64 architectures. """ block_data_move_instructions = ('movs', 'stos', 'lods') isBlockDataMove = False instruction = None if self.pc is not None and self.faultDisasm: for disasm in self.faultDisasm: if disasm[0] == self.pc: instruction = disasm[2].lower().strip() break if instruction: for x in block_data_move_instructions: if x in instruction: isBlockDataMove = True break return isBlockDataMove
python
def __is_block_data_move(self): """ Private method to tell if the instruction pointed to by the program counter is a block data move instruction. Currently only works for x86 and amd64 architectures. """ block_data_move_instructions = ('movs', 'stos', 'lods') isBlockDataMove = False instruction = None if self.pc is not None and self.faultDisasm: for disasm in self.faultDisasm: if disasm[0] == self.pc: instruction = disasm[2].lower().strip() break if instruction: for x in block_data_move_instructions: if x in instruction: isBlockDataMove = True break return isBlockDataMove
[ "def", "__is_block_data_move", "(", "self", ")", ":", "block_data_move_instructions", "=", "(", "'movs'", ",", "'stos'", ",", "'lods'", ")", "isBlockDataMove", "=", "False", "instruction", "=", "None", "if", "self", ".", "pc", "is", "not", "None", "and", "se...
Private method to tell if the instruction pointed to by the program counter is a block data move instruction. Currently only works for x86 and amd64 architectures.
[ "Private", "method", "to", "tell", "if", "the", "instruction", "pointed", "to", "by", "the", "program", "counter", "is", "a", "block", "data", "move", "instruction", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L878-L898
train
209,343
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
CrashContainer.marshall_key
def marshall_key(self, key): """ Marshalls a Crash key to be used in the database. @see: L{__init__} @type key: L{Crash} key. @param key: Key to convert. @rtype: str or buffer @return: Converted key. """ if key in self.__keys: return self.__keys[key] skey = pickle.dumps(key, protocol = 0) if self.compressKeys: skey = zlib.compress(skey, zlib.Z_BEST_COMPRESSION) if self.escapeKeys: skey = skey.encode('hex') if self.binaryKeys: skey = buffer(skey) self.__keys[key] = skey return skey
python
def marshall_key(self, key): """ Marshalls a Crash key to be used in the database. @see: L{__init__} @type key: L{Crash} key. @param key: Key to convert. @rtype: str or buffer @return: Converted key. """ if key in self.__keys: return self.__keys[key] skey = pickle.dumps(key, protocol = 0) if self.compressKeys: skey = zlib.compress(skey, zlib.Z_BEST_COMPRESSION) if self.escapeKeys: skey = skey.encode('hex') if self.binaryKeys: skey = buffer(skey) self.__keys[key] = skey return skey
[ "def", "marshall_key", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "__keys", ":", "return", "self", ".", "__keys", "[", "key", "]", "skey", "=", "pickle", ".", "dumps", "(", "key", ",", "protocol", "=", "0", ")", "if", "sel...
Marshalls a Crash key to be used in the database. @see: L{__init__} @type key: L{Crash} key. @param key: Key to convert. @rtype: str or buffer @return: Converted key.
[ "Marshalls", "a", "Crash", "key", "to", "be", "used", "in", "the", "database", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L1229-L1251
train
209,344
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
CrashContainer.unmarshall_key
def unmarshall_key(self, key): """ Unmarshalls a Crash key read from the database. @type key: str or buffer @param key: Key to convert. @rtype: L{Crash} key. @return: Converted key. """ key = str(key) if self.escapeKeys: key = key.decode('hex') if self.compressKeys: key = zlib.decompress(key) key = pickle.loads(key) return key
python
def unmarshall_key(self, key): """ Unmarshalls a Crash key read from the database. @type key: str or buffer @param key: Key to convert. @rtype: L{Crash} key. @return: Converted key. """ key = str(key) if self.escapeKeys: key = key.decode('hex') if self.compressKeys: key = zlib.decompress(key) key = pickle.loads(key) return key
[ "def", "unmarshall_key", "(", "self", ",", "key", ")", ":", "key", "=", "str", "(", "key", ")", "if", "self", ".", "escapeKeys", ":", "key", "=", "key", ".", "decode", "(", "'hex'", ")", "if", "self", ".", "compressKeys", ":", "key", "=", "zlib", ...
Unmarshalls a Crash key read from the database. @type key: str or buffer @param key: Key to convert. @rtype: L{Crash} key. @return: Converted key.
[ "Unmarshalls", "a", "Crash", "key", "read", "from", "the", "database", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L1253-L1269
train
209,345
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
CrashContainer.unmarshall_value
def unmarshall_value(self, value): """ Unmarshalls a Crash object read from the database. @type value: str @param value: Object to convert. @rtype: L{Crash} @return: Converted object. """ value = str(value) if self.escapeValues: value = value.decode('hex') if self.compressValues: value = zlib.decompress(value) value = pickle.loads(value) return value
python
def unmarshall_value(self, value): """ Unmarshalls a Crash object read from the database. @type value: str @param value: Object to convert. @rtype: L{Crash} @return: Converted object. """ value = str(value) if self.escapeValues: value = value.decode('hex') if self.compressValues: value = zlib.decompress(value) value = pickle.loads(value) return value
[ "def", "unmarshall_value", "(", "self", ",", "value", ")", ":", "value", "=", "str", "(", "value", ")", "if", "self", ".", "escapeValues", ":", "value", "=", "value", ".", "decode", "(", "'hex'", ")", "if", "self", ".", "compressValues", ":", "value", ...
Unmarshalls a Crash object read from the database. @type value: str @param value: Object to convert. @rtype: L{Crash} @return: Converted object.
[ "Unmarshalls", "a", "Crash", "object", "read", "from", "the", "database", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L1314-L1330
train
209,346
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
CrashContainer.add
def add(self, crash): """ Adds a new crash to the container. If the crash appears to be already known, it's ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add. """ if crash not in self: key = crash.key() skey = self.marshall_key(key) data = self.marshall_value(crash, storeMemoryMap = True) self.__db[skey] = data
python
def add(self, crash): """ Adds a new crash to the container. If the crash appears to be already known, it's ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add. """ if crash not in self: key = crash.key() skey = self.marshall_key(key) data = self.marshall_value(crash, storeMemoryMap = True) self.__db[skey] = data
[ "def", "add", "(", "self", ",", "crash", ")", ":", "if", "crash", "not", "in", "self", ":", "key", "=", "crash", ".", "key", "(", ")", "skey", "=", "self", ".", "marshall_key", "(", "key", ")", "data", "=", "self", ".", "marshall_value", "(", "cr...
Adds a new crash to the container. If the crash appears to be already known, it's ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add.
[ "Adds", "a", "new", "crash", "to", "the", "container", ".", "If", "the", "crash", "appears", "to", "be", "already", "known", "it", "s", "ignored", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L1439-L1453
train
209,347
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/crash.py
DummyCrashContainer.add
def add(self, crash): """ Adds a new crash to the container. @note: When the C{allowRepeatedKeys} parameter of the constructor is set to C{False}, duplicated crashes are ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add. """ self.__keys.add( crash.signature ) self.__count += 1
python
def add(self, crash): """ Adds a new crash to the container. @note: When the C{allowRepeatedKeys} parameter of the constructor is set to C{False}, duplicated crashes are ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add. """ self.__keys.add( crash.signature ) self.__count += 1
[ "def", "add", "(", "self", ",", "crash", ")", ":", "self", ".", "__keys", ".", "add", "(", "crash", ".", "signature", ")", "self", ".", "__count", "+=", "1" ]
Adds a new crash to the container. @note: When the C{allowRepeatedKeys} parameter of the constructor is set to C{False}, duplicated crashes are ignored. @see: L{Crash.key} @type crash: L{Crash} @param crash: Crash object to add.
[ "Adds", "a", "new", "crash", "to", "the", "container", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L1798-L1812
train
209,348
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_stackless.py
_schedule_callback
def _schedule_callback(prev, next): ''' Called when a context is stopped or a new context is made runnable. ''' try: if not prev and not next: return current_frame = sys._getframe() if next: register_tasklet_info(next) # Ok, making next runnable: set the tracing facility in it. debugger = get_global_debugger() if debugger is not None: next.trace_function = debugger.get_thread_local_trace_func() frame = next.frame if frame is current_frame: frame = frame.f_back if hasattr(frame, 'f_trace'): # Note: can be None (but hasattr should cover for that too). frame.f_trace = debugger.get_thread_local_trace_func() debugger = None if prev: register_tasklet_info(prev) try: for tasklet_ref, tasklet_info in dict_items(_weak_tasklet_registered_to_info): # Make sure it's a copy! tasklet = tasklet_ref() if tasklet is None or not tasklet.alive: # Garbage-collected already! try: del _weak_tasklet_registered_to_info[tasklet_ref] except KeyError: pass if tasklet_info.frame_id is not None: remove_custom_frame(tasklet_info.frame_id) else: is_running = stackless.get_thread_info(tasklet.thread_id)[1] is tasklet if tasklet is prev or (tasklet is not next and not is_running): # the tasklet won't run after this scheduler action: # - the tasklet is the previous tasklet # - it is not the next tasklet and it is not an already running tasklet frame = tasklet.frame if frame is current_frame: frame = frame.f_back if frame is not None: abs_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) # print >>sys.stderr, "SchedCB: %r, %d, '%s', '%s'" % (tasklet, frame.f_lineno, _filename, base) if debugger.get_file_type(abs_real_path_and_base) is None: tasklet_info.update_name() if tasklet_info.frame_id is None: tasklet_info.frame_id = add_custom_frame(frame, tasklet_info.tasklet_name, tasklet.thread_id) else: update_custom_frame(tasklet_info.frame_id, frame, tasklet.thread_id, name=tasklet_info.tasklet_name) elif tasklet is next or is_running: if tasklet_info.frame_id is not None: # Remove info about stackless suspended when it starts to run. remove_custom_frame(tasklet_info.frame_id) tasklet_info.frame_id = None finally: tasklet = None tasklet_info = None frame = None except: pydev_log.exception() if _application_set_schedule_callback is not None: return _application_set_schedule_callback(prev, next)
python
def _schedule_callback(prev, next): ''' Called when a context is stopped or a new context is made runnable. ''' try: if not prev and not next: return current_frame = sys._getframe() if next: register_tasklet_info(next) # Ok, making next runnable: set the tracing facility in it. debugger = get_global_debugger() if debugger is not None: next.trace_function = debugger.get_thread_local_trace_func() frame = next.frame if frame is current_frame: frame = frame.f_back if hasattr(frame, 'f_trace'): # Note: can be None (but hasattr should cover for that too). frame.f_trace = debugger.get_thread_local_trace_func() debugger = None if prev: register_tasklet_info(prev) try: for tasklet_ref, tasklet_info in dict_items(_weak_tasklet_registered_to_info): # Make sure it's a copy! tasklet = tasklet_ref() if tasklet is None or not tasklet.alive: # Garbage-collected already! try: del _weak_tasklet_registered_to_info[tasklet_ref] except KeyError: pass if tasklet_info.frame_id is not None: remove_custom_frame(tasklet_info.frame_id) else: is_running = stackless.get_thread_info(tasklet.thread_id)[1] is tasklet if tasklet is prev or (tasklet is not next and not is_running): # the tasklet won't run after this scheduler action: # - the tasklet is the previous tasklet # - it is not the next tasklet and it is not an already running tasklet frame = tasklet.frame if frame is current_frame: frame = frame.f_back if frame is not None: abs_real_path_and_base = get_abs_path_real_path_and_base_from_frame(frame) # print >>sys.stderr, "SchedCB: %r, %d, '%s', '%s'" % (tasklet, frame.f_lineno, _filename, base) if debugger.get_file_type(abs_real_path_and_base) is None: tasklet_info.update_name() if tasklet_info.frame_id is None: tasklet_info.frame_id = add_custom_frame(frame, tasklet_info.tasklet_name, tasklet.thread_id) else: update_custom_frame(tasklet_info.frame_id, frame, tasklet.thread_id, name=tasklet_info.tasklet_name) elif tasklet is next or is_running: if tasklet_info.frame_id is not None: # Remove info about stackless suspended when it starts to run. remove_custom_frame(tasklet_info.frame_id) tasklet_info.frame_id = None finally: tasklet = None tasklet_info = None frame = None except: pydev_log.exception() if _application_set_schedule_callback is not None: return _application_set_schedule_callback(prev, next)
[ "def", "_schedule_callback", "(", "prev", ",", "next", ")", ":", "try", ":", "if", "not", "prev", "and", "not", "next", ":", "return", "current_frame", "=", "sys", ".", "_getframe", "(", ")", "if", "next", ":", "register_tasklet_info", "(", "next", ")", ...
Called when a context is stopped or a new context is made runnable.
[ "Called", "when", "a", "context", "is", "stopped", "or", "a", "new", "context", "is", "made", "runnable", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_stackless.py#L176-L249
train
209,349
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_stackless.py
patch_stackless
def patch_stackless(): ''' This function should be called to patch the stackless module so that new tasklets are properly tracked in the debugger. ''' global _application_set_schedule_callback _application_set_schedule_callback = stackless.set_schedule_callback(_schedule_callback) def set_schedule_callback(callable): global _application_set_schedule_callback old = _application_set_schedule_callback _application_set_schedule_callback = callable return old def get_schedule_callback(): global _application_set_schedule_callback return _application_set_schedule_callback set_schedule_callback.__doc__ = stackless.set_schedule_callback.__doc__ if hasattr(stackless, "get_schedule_callback"): get_schedule_callback.__doc__ = stackless.get_schedule_callback.__doc__ stackless.set_schedule_callback = set_schedule_callback stackless.get_schedule_callback = get_schedule_callback if not hasattr(stackless.tasklet, "trace_function"): # Older versions of Stackless, released before 2014 __call__.__doc__ = stackless.tasklet.__call__.__doc__ stackless.tasklet.__call__ = __call__ setup.__doc__ = stackless.tasklet.setup.__doc__ stackless.tasklet.setup = setup run.__doc__ = stackless.run.__doc__ stackless.run = run
python
def patch_stackless(): ''' This function should be called to patch the stackless module so that new tasklets are properly tracked in the debugger. ''' global _application_set_schedule_callback _application_set_schedule_callback = stackless.set_schedule_callback(_schedule_callback) def set_schedule_callback(callable): global _application_set_schedule_callback old = _application_set_schedule_callback _application_set_schedule_callback = callable return old def get_schedule_callback(): global _application_set_schedule_callback return _application_set_schedule_callback set_schedule_callback.__doc__ = stackless.set_schedule_callback.__doc__ if hasattr(stackless, "get_schedule_callback"): get_schedule_callback.__doc__ = stackless.get_schedule_callback.__doc__ stackless.set_schedule_callback = set_schedule_callback stackless.get_schedule_callback = get_schedule_callback if not hasattr(stackless.tasklet, "trace_function"): # Older versions of Stackless, released before 2014 __call__.__doc__ = stackless.tasklet.__call__.__doc__ stackless.tasklet.__call__ = __call__ setup.__doc__ = stackless.tasklet.setup.__doc__ stackless.tasklet.setup = setup run.__doc__ = stackless.run.__doc__ stackless.run = run
[ "def", "patch_stackless", "(", ")", ":", "global", "_application_set_schedule_callback", "_application_set_schedule_callback", "=", "stackless", ".", "set_schedule_callback", "(", "_schedule_callback", ")", "def", "set_schedule_callback", "(", "callable", ")", ":", "global"...
This function should be called to patch the stackless module so that new tasklets are properly tracked in the debugger.
[ "This", "function", "should", "be", "called", "to", "patch", "the", "stackless", "module", "so", "that", "new", "tasklets", "are", "properly", "tracked", "in", "the", "debugger", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_stackless.py#L380-L413
train
209,350
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.attach
def attach(self, dwProcessId): """ Attaches to an existing process for debugging. @see: L{detach}, L{execv}, L{execl} @type dwProcessId: int @param dwProcessId: Global ID of a process to attach to. @rtype: L{Process} @return: A new Process object. Normally you don't need to use it now, it's best to interact with the process from the event handler. @raise WindowsError: Raises an exception on error. Depending on the circumstances, the debugger may or may not have attached to the target process. """ # Get the Process object from the snapshot, # if missing create a new one. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Warn when mixing 32 and 64 bits. # This also allows the user to stop attaching altogether, # depending on how the warnings are configured. if System.bits != aProcess.get_bits(): msg = "Mixture of 32 and 64 bits is considered experimental." \ " Use at your own risk!" warnings.warn(msg, MixedBitsWarning) # Attach to the process. win32.DebugActiveProcess(dwProcessId) # Add the new PID to the set of debugees. self.__attachedDebugees.add(dwProcessId) # Match the system kill-on-exit flag to our own. self.__setSystemKillOnExitMode() # If the Process object was not in the snapshot, add it now. if not self.system.has_process(dwProcessId): self.system._add_process(aProcess) # Scan the process threads and loaded modules. # This is prefered because the thread and library events do not # properly give some information, like the filename for each module. aProcess.scan_threads() aProcess.scan_modules() # Return the Process object, like the execv() and execl() methods. return aProcess
python
def attach(self, dwProcessId): """ Attaches to an existing process for debugging. @see: L{detach}, L{execv}, L{execl} @type dwProcessId: int @param dwProcessId: Global ID of a process to attach to. @rtype: L{Process} @return: A new Process object. Normally you don't need to use it now, it's best to interact with the process from the event handler. @raise WindowsError: Raises an exception on error. Depending on the circumstances, the debugger may or may not have attached to the target process. """ # Get the Process object from the snapshot, # if missing create a new one. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Warn when mixing 32 and 64 bits. # This also allows the user to stop attaching altogether, # depending on how the warnings are configured. if System.bits != aProcess.get_bits(): msg = "Mixture of 32 and 64 bits is considered experimental." \ " Use at your own risk!" warnings.warn(msg, MixedBitsWarning) # Attach to the process. win32.DebugActiveProcess(dwProcessId) # Add the new PID to the set of debugees. self.__attachedDebugees.add(dwProcessId) # Match the system kill-on-exit flag to our own. self.__setSystemKillOnExitMode() # If the Process object was not in the snapshot, add it now. if not self.system.has_process(dwProcessId): self.system._add_process(aProcess) # Scan the process threads and loaded modules. # This is prefered because the thread and library events do not # properly give some information, like the filename for each module. aProcess.scan_threads() aProcess.scan_modules() # Return the Process object, like the execv() and execl() methods. return aProcess
[ "def", "attach", "(", "self", ",", "dwProcessId", ")", ":", "# Get the Process object from the snapshot,", "# if missing create a new one.", "try", ":", "aProcess", "=", "self", ".", "system", ".", "get_process", "(", "dwProcessId", ")", "except", "KeyError", ":", "...
Attaches to an existing process for debugging. @see: L{detach}, L{execv}, L{execl} @type dwProcessId: int @param dwProcessId: Global ID of a process to attach to. @rtype: L{Process} @return: A new Process object. Normally you don't need to use it now, it's best to interact with the process from the event handler. @raise WindowsError: Raises an exception on error. Depending on the circumstances, the debugger may or may not have attached to the target process.
[ "Attaches", "to", "an", "existing", "process", "for", "debugging", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L211-L264
train
209,351
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.__cleanup_process
def __cleanup_process(self, dwProcessId, bIgnoreExceptions = False): """ Perform the necessary cleanup of a process about to be killed or detached from. This private method is called by L{kill} and L{detach}. @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # If the process is being debugged... if self.is_debugee(dwProcessId): # Make sure a Process object exists or the following calls fail. if not self.system.has_process(dwProcessId): aProcess = Process(dwProcessId) try: aProcess.get_handle() except WindowsError: pass # fails later on with more specific reason self.system._add_process(aProcess) # Erase all breakpoints in the process. try: self.erase_process_breakpoints(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Stop tracing all threads in the process. try: self.stop_tracing_process(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # The process is no longer a debugee. try: if dwProcessId in self.__attachedDebugees: self.__attachedDebugees.remove(dwProcessId) if dwProcessId in self.__startedDebugees: self.__startedDebugees.remove(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Clear and remove the process from the snapshot. # If the user wants to do something with it after detaching # a new Process instance should be created. try: if self.system.has_process(dwProcessId): try: self.system.get_process(dwProcessId).clear() finally: self.system._del_process(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # If the last debugging event is related to this process, forget it. try: if self.lastEvent and self.lastEvent.get_pid() == dwProcessId: self.lastEvent = None except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
python
def __cleanup_process(self, dwProcessId, bIgnoreExceptions = False): """ Perform the necessary cleanup of a process about to be killed or detached from. This private method is called by L{kill} and L{detach}. @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # If the process is being debugged... if self.is_debugee(dwProcessId): # Make sure a Process object exists or the following calls fail. if not self.system.has_process(dwProcessId): aProcess = Process(dwProcessId) try: aProcess.get_handle() except WindowsError: pass # fails later on with more specific reason self.system._add_process(aProcess) # Erase all breakpoints in the process. try: self.erase_process_breakpoints(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Stop tracing all threads in the process. try: self.stop_tracing_process(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # The process is no longer a debugee. try: if dwProcessId in self.__attachedDebugees: self.__attachedDebugees.remove(dwProcessId) if dwProcessId in self.__startedDebugees: self.__startedDebugees.remove(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Clear and remove the process from the snapshot. # If the user wants to do something with it after detaching # a new Process instance should be created. try: if self.system.has_process(dwProcessId): try: self.system.get_process(dwProcessId).clear() finally: self.system._del_process(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # If the last debugging event is related to this process, forget it. try: if self.lastEvent and self.lastEvent.get_pid() == dwProcessId: self.lastEvent = None except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
[ "def", "__cleanup_process", "(", "self", ",", "dwProcessId", ",", "bIgnoreExceptions", "=", "False", ")", ":", "# If the process is being debugged...", "if", "self", ".", "is_debugee", "(", "dwProcessId", ")", ":", "# Make sure a Process object exists or the following calls...
Perform the necessary cleanup of a process about to be killed or detached from. This private method is called by L{kill} and L{detach}. @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Perform", "the", "necessary", "cleanup", "of", "a", "process", "about", "to", "be", "killed", "or", "detached", "from", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L582-L664
train
209,352
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.kill
def kill(self, dwProcessId, bIgnoreExceptions = False): """ Kills a process currently being debugged. @see: L{detach} @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # Keep a reference to the process. We'll need it later. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Cleanup all data referring to the process. self.__cleanup_process(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) # Kill the process. try: try: if self.is_debugee(dwProcessId): try: if aProcess.is_alive(): aProcess.suspend() finally: self.detach(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) finally: aProcess.kill() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup what remains of the process data. try: aProcess.clear() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
python
def kill(self, dwProcessId, bIgnoreExceptions = False): """ Kills a process currently being debugged. @see: L{detach} @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # Keep a reference to the process. We'll need it later. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Cleanup all data referring to the process. self.__cleanup_process(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) # Kill the process. try: try: if self.is_debugee(dwProcessId): try: if aProcess.is_alive(): aProcess.suspend() finally: self.detach(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) finally: aProcess.kill() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup what remains of the process data. try: aProcess.clear() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
[ "def", "kill", "(", "self", ",", "dwProcessId", ",", "bIgnoreExceptions", "=", "False", ")", ":", "# Keep a reference to the process. We'll need it later.", "try", ":", "aProcess", "=", "self", ".", "system", ".", "get_process", "(", "dwProcessId", ")", "except", ...
Kills a process currently being debugged. @see: L{detach} @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing the process. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Kills", "a", "process", "currently", "being", "debugged", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L666-L718
train
209,353
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.kill_all
def kill_all(self, bIgnoreExceptions = False): """ Kills from all processes currently being debugged. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing each process. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ for pid in self.get_debugee_pids(): self.kill(pid, bIgnoreExceptions = bIgnoreExceptions)
python
def kill_all(self, bIgnoreExceptions = False): """ Kills from all processes currently being debugged. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing each process. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ for pid in self.get_debugee_pids(): self.kill(pid, bIgnoreExceptions = bIgnoreExceptions)
[ "def", "kill_all", "(", "self", ",", "bIgnoreExceptions", "=", "False", ")", ":", "for", "pid", "in", "self", ".", "get_debugee_pids", "(", ")", ":", "self", ".", "kill", "(", "pid", ",", "bIgnoreExceptions", "=", "bIgnoreExceptions", ")" ]
Kills from all processes currently being debugged. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when killing each process. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Kills", "from", "all", "processes", "currently", "being", "debugged", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L720-L733
train
209,354
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.detach
def detach(self, dwProcessId, bIgnoreExceptions = False): """ Detaches from a process currently being debugged. @note: On Windows 2000 and below the process is killed. @see: L{attach}, L{detach_from_all} @type dwProcessId: int @param dwProcessId: Global ID of a process to detach from. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # Keep a reference to the process. We'll need it later. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Determine if there is support for detaching. # This check should only fail on Windows 2000 and older. try: win32.DebugActiveProcessStop can_detach = True except AttributeError: can_detach = False # Continue the last event before detaching. # XXX not sure about this... try: if can_detach and self.lastEvent and \ self.lastEvent.get_pid() == dwProcessId: self.cont(self.lastEvent) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup all data referring to the process. self.__cleanup_process(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) try: # Detach from the process. # On Windows 2000 and before, kill the process. if can_detach: try: win32.DebugActiveProcessStop(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) else: try: aProcess.kill() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) finally: # Cleanup what remains of the process data. aProcess.clear()
python
def detach(self, dwProcessId, bIgnoreExceptions = False): """ Detaches from a process currently being debugged. @note: On Windows 2000 and below the process is killed. @see: L{attach}, L{detach_from_all} @type dwProcessId: int @param dwProcessId: Global ID of a process to detach from. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ # Keep a reference to the process. We'll need it later. try: aProcess = self.system.get_process(dwProcessId) except KeyError: aProcess = Process(dwProcessId) # Determine if there is support for detaching. # This check should only fail on Windows 2000 and older. try: win32.DebugActiveProcessStop can_detach = True except AttributeError: can_detach = False # Continue the last event before detaching. # XXX not sure about this... try: if can_detach and self.lastEvent and \ self.lastEvent.get_pid() == dwProcessId: self.cont(self.lastEvent) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup all data referring to the process. self.__cleanup_process(dwProcessId, bIgnoreExceptions = bIgnoreExceptions) try: # Detach from the process. # On Windows 2000 and before, kill the process. if can_detach: try: win32.DebugActiveProcessStop(dwProcessId) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) else: try: aProcess.kill() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) finally: # Cleanup what remains of the process data. aProcess.clear()
[ "def", "detach", "(", "self", ",", "dwProcessId", ",", "bIgnoreExceptions", "=", "False", ")", ":", "# Keep a reference to the process. We'll need it later.", "try", ":", "aProcess", "=", "self", ".", "system", ".", "get_process", "(", "dwProcessId", ")", "except", ...
Detaches from a process currently being debugged. @note: On Windows 2000 and below the process is killed. @see: L{attach}, L{detach_from_all} @type dwProcessId: int @param dwProcessId: Global ID of a process to detach from. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. C{False} to stop and raise an exception when encountering an error. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Detaches", "from", "a", "process", "currently", "being", "debugged", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L735-L808
train
209,355
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.detach_from_all
def detach_from_all(self, bIgnoreExceptions = False): """ Detaches from all processes currently being debugged. @note: To better handle last debugging event, call L{stop} instead. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ for pid in self.get_debugee_pids(): self.detach(pid, bIgnoreExceptions = bIgnoreExceptions)
python
def detach_from_all(self, bIgnoreExceptions = False): """ Detaches from all processes currently being debugged. @note: To better handle last debugging event, call L{stop} instead. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ for pid in self.get_debugee_pids(): self.detach(pid, bIgnoreExceptions = bIgnoreExceptions)
[ "def", "detach_from_all", "(", "self", ",", "bIgnoreExceptions", "=", "False", ")", ":", "for", "pid", "in", "self", ".", "get_debugee_pids", "(", ")", ":", "self", ".", "detach", "(", "pid", ",", "bIgnoreExceptions", "=", "bIgnoreExceptions", ")" ]
Detaches from all processes currently being debugged. @note: To better handle last debugging event, call L{stop} instead. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Detaches", "from", "all", "processes", "currently", "being", "debugged", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L810-L824
train
209,356
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.wait
def wait(self, dwMilliseconds = None): """ Waits for the next debug event. @see: L{cont}, L{dispatch}, L{loop} @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout in milliseconds. Use C{INFINITE} or C{None} for no timeout. @rtype: L{Event} @return: An event that occured in one of the debugees. @raise WindowsError: Raises an exception on error. If no target processes are left to debug, the error code is L{win32.ERROR_INVALID_HANDLE}. """ # Wait for the next debug event. raw = win32.WaitForDebugEvent(dwMilliseconds) event = EventFactory.get(self, raw) # Remember it. self.lastEvent = event # Return it. return event
python
def wait(self, dwMilliseconds = None): """ Waits for the next debug event. @see: L{cont}, L{dispatch}, L{loop} @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout in milliseconds. Use C{INFINITE} or C{None} for no timeout. @rtype: L{Event} @return: An event that occured in one of the debugees. @raise WindowsError: Raises an exception on error. If no target processes are left to debug, the error code is L{win32.ERROR_INVALID_HANDLE}. """ # Wait for the next debug event. raw = win32.WaitForDebugEvent(dwMilliseconds) event = EventFactory.get(self, raw) # Remember it. self.lastEvent = event # Return it. return event
[ "def", "wait", "(", "self", ",", "dwMilliseconds", "=", "None", ")", ":", "# Wait for the next debug event.", "raw", "=", "win32", ".", "WaitForDebugEvent", "(", "dwMilliseconds", ")", "event", "=", "EventFactory", ".", "get", "(", "self", ",", "raw", ")", "...
Waits for the next debug event. @see: L{cont}, L{dispatch}, L{loop} @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout in milliseconds. Use C{INFINITE} or C{None} for no timeout. @rtype: L{Event} @return: An event that occured in one of the debugees. @raise WindowsError: Raises an exception on error. If no target processes are left to debug, the error code is L{win32.ERROR_INVALID_HANDLE}.
[ "Waits", "for", "the", "next", "debug", "event", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L828-L854
train
209,357
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.dispatch
def dispatch(self, event = None): """ Calls the debug event notify callbacks. @see: L{cont}, L{loop}, L{wait} @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error. """ # If no event object was given, use the last event. if event is None: event = self.lastEvent # Ignore dummy events. if not event: return # Determine the default behaviour for this event. # XXX HACK # Some undocumented flags are used, but as far as I know in those # versions of Windows that don't support them they should behave # like DGB_CONTINUE. code = event.get_event_code() if code == win32.EXCEPTION_DEBUG_EVENT: # At this point, by default some exception types are swallowed by # the debugger, because we don't know yet if it was caused by the # debugger itself or the debugged process. # # Later on (see breakpoint.py) if we determined the exception was # not caused directly by the debugger itself, we set the default # back to passing the exception to the debugee. # # The "invalid handle" exception is also swallowed by the debugger # because it's not normally generated by the debugee. But in # hostile mode we want to pass it to the debugee, as it may be the # result of an anti-debug trick. In that case it's best to disable # bad handles detection with Microsoft's gflags.exe utility. See: # http://msdn.microsoft.com/en-us/library/windows/hardware/ff549557(v=vs.85).aspx exc_code = event.get_exception_code() if exc_code in ( win32.EXCEPTION_BREAKPOINT, win32.EXCEPTION_WX86_BREAKPOINT, win32.EXCEPTION_SINGLE_STEP, win32.EXCEPTION_GUARD_PAGE, ): event.continueStatus = win32.DBG_CONTINUE elif exc_code == win32.EXCEPTION_INVALID_HANDLE: if self.__bHostileCode: event.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED else: event.continueStatus = win32.DBG_CONTINUE else: event.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED elif code == win32.RIP_EVENT and \ event.get_rip_type() == win32.SLE_ERROR: # RIP events that signal fatal events should kill the process. event.continueStatus = win32.DBG_TERMINATE_PROCESS else: # Other events need this continue code. # Sometimes other codes can be used and are ignored, sometimes not. # For example, when using the DBG_EXCEPTION_NOT_HANDLED code, # debug strings are sent twice (!) event.continueStatus = win32.DBG_CONTINUE # Dispatch the debug event. return EventDispatcher.dispatch(self, event)
python
def dispatch(self, event = None): """ Calls the debug event notify callbacks. @see: L{cont}, L{loop}, L{wait} @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error. """ # If no event object was given, use the last event. if event is None: event = self.lastEvent # Ignore dummy events. if not event: return # Determine the default behaviour for this event. # XXX HACK # Some undocumented flags are used, but as far as I know in those # versions of Windows that don't support them they should behave # like DGB_CONTINUE. code = event.get_event_code() if code == win32.EXCEPTION_DEBUG_EVENT: # At this point, by default some exception types are swallowed by # the debugger, because we don't know yet if it was caused by the # debugger itself or the debugged process. # # Later on (see breakpoint.py) if we determined the exception was # not caused directly by the debugger itself, we set the default # back to passing the exception to the debugee. # # The "invalid handle" exception is also swallowed by the debugger # because it's not normally generated by the debugee. But in # hostile mode we want to pass it to the debugee, as it may be the # result of an anti-debug trick. In that case it's best to disable # bad handles detection with Microsoft's gflags.exe utility. See: # http://msdn.microsoft.com/en-us/library/windows/hardware/ff549557(v=vs.85).aspx exc_code = event.get_exception_code() if exc_code in ( win32.EXCEPTION_BREAKPOINT, win32.EXCEPTION_WX86_BREAKPOINT, win32.EXCEPTION_SINGLE_STEP, win32.EXCEPTION_GUARD_PAGE, ): event.continueStatus = win32.DBG_CONTINUE elif exc_code == win32.EXCEPTION_INVALID_HANDLE: if self.__bHostileCode: event.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED else: event.continueStatus = win32.DBG_CONTINUE else: event.continueStatus = win32.DBG_EXCEPTION_NOT_HANDLED elif code == win32.RIP_EVENT and \ event.get_rip_type() == win32.SLE_ERROR: # RIP events that signal fatal events should kill the process. event.continueStatus = win32.DBG_TERMINATE_PROCESS else: # Other events need this continue code. # Sometimes other codes can be used and are ignored, sometimes not. # For example, when using the DBG_EXCEPTION_NOT_HANDLED code, # debug strings are sent twice (!) event.continueStatus = win32.DBG_CONTINUE # Dispatch the debug event. return EventDispatcher.dispatch(self, event)
[ "def", "dispatch", "(", "self", ",", "event", "=", "None", ")", ":", "# If no event object was given, use the last event.", "if", "event", "is", "None", ":", "event", "=", "self", ".", "lastEvent", "# Ignore dummy events.", "if", "not", "event", ":", "return", "...
Calls the debug event notify callbacks. @see: L{cont}, L{loop}, L{wait} @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error.
[ "Calls", "the", "debug", "event", "notify", "callbacks", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L856-L931
train
209,358
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.cont
def cont(self, event = None): """ Resumes execution after processing a debug event. @see: dispatch(), loop(), wait() @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error. """ # If no event object was given, use the last event. if event is None: event = self.lastEvent # Ignore dummy events. if not event: return # Get the event continue status information. dwProcessId = event.get_pid() dwThreadId = event.get_tid() dwContinueStatus = event.continueStatus # Check if the process is still being debugged. if self.is_debugee(dwProcessId): # Try to flush the instruction cache. try: if self.system.has_process(dwProcessId): aProcess = self.system.get_process(dwProcessId) else: aProcess = Process(dwProcessId) aProcess.flush_instruction_cache() except WindowsError: pass # XXX TODO # # Try to execute the UnhandledExceptionFilter for second chance # exceptions, at least when in hostile mode (in normal mode it # would be breaking compatibility, as users may actually expect # second chance exceptions to be raised again). # # Reportedly in Windows 7 (maybe in Vista too) this seems to be # happening already. In XP and below the UnhandledExceptionFilter # was never called for processes being debugged. # Continue execution of the debugee. win32.ContinueDebugEvent(dwProcessId, dwThreadId, dwContinueStatus) # If the event is the last event, forget it. if event == self.lastEvent: self.lastEvent = None
python
def cont(self, event = None): """ Resumes execution after processing a debug event. @see: dispatch(), loop(), wait() @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error. """ # If no event object was given, use the last event. if event is None: event = self.lastEvent # Ignore dummy events. if not event: return # Get the event continue status information. dwProcessId = event.get_pid() dwThreadId = event.get_tid() dwContinueStatus = event.continueStatus # Check if the process is still being debugged. if self.is_debugee(dwProcessId): # Try to flush the instruction cache. try: if self.system.has_process(dwProcessId): aProcess = self.system.get_process(dwProcessId) else: aProcess = Process(dwProcessId) aProcess.flush_instruction_cache() except WindowsError: pass # XXX TODO # # Try to execute the UnhandledExceptionFilter for second chance # exceptions, at least when in hostile mode (in normal mode it # would be breaking compatibility, as users may actually expect # second chance exceptions to be raised again). # # Reportedly in Windows 7 (maybe in Vista too) this seems to be # happening already. In XP and below the UnhandledExceptionFilter # was never called for processes being debugged. # Continue execution of the debugee. win32.ContinueDebugEvent(dwProcessId, dwThreadId, dwContinueStatus) # If the event is the last event, forget it. if event == self.lastEvent: self.lastEvent = None
[ "def", "cont", "(", "self", ",", "event", "=", "None", ")", ":", "# If no event object was given, use the last event.", "if", "event", "is", "None", ":", "event", "=", "self", ".", "lastEvent", "# Ignore dummy events.", "if", "not", "event", ":", "return", "# Ge...
Resumes execution after processing a debug event. @see: dispatch(), loop(), wait() @type event: L{Event} @param event: (Optional) Event object returned by L{wait}. @raise WindowsError: Raises an exception on error.
[ "Resumes", "execution", "after", "processing", "a", "debug", "event", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L933-L987
train
209,359
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.stop
def stop(self, bIgnoreExceptions = True): """ Stops debugging all processes. If the kill on exit mode is on, debugged processes are killed when the debugger is stopped. Otherwise when the debugger stops it detaches from all debugged processes and leaves them running (default). For more details see: L{__init__} @note: This method is better than L{detach_from_all} because it can gracefully handle the last debugging event before detaching. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. """ # Determine if we have a last debug event that we need to continue. try: event = self.lastEvent has_event = bool(event) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) has_event = False # If we do... if has_event: # Disable all breakpoints in the process before resuming execution. try: pid = event.get_pid() self.disable_process_breakpoints(pid) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Disable all breakpoints in the thread before resuming execution. try: tid = event.get_tid() self.disable_thread_breakpoints(tid) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Resume execution. try: event.continueDebugEvent = win32.DBG_CONTINUE self.cont(event) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Detach from or kill all debuggees. try: if self.__bKillOnExit: self.kill_all(bIgnoreExceptions) else: self.detach_from_all(bIgnoreExceptions) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup the process snapshots. try: self.system.clear() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Close all Win32 handles the Python garbage collector failed to close. self.force_garbage_collection(bIgnoreExceptions)
python
def stop(self, bIgnoreExceptions = True): """ Stops debugging all processes. If the kill on exit mode is on, debugged processes are killed when the debugger is stopped. Otherwise when the debugger stops it detaches from all debugged processes and leaves them running (default). For more details see: L{__init__} @note: This method is better than L{detach_from_all} because it can gracefully handle the last debugging event before detaching. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. """ # Determine if we have a last debug event that we need to continue. try: event = self.lastEvent has_event = bool(event) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) has_event = False # If we do... if has_event: # Disable all breakpoints in the process before resuming execution. try: pid = event.get_pid() self.disable_process_breakpoints(pid) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Disable all breakpoints in the thread before resuming execution. try: tid = event.get_tid() self.disable_thread_breakpoints(tid) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Resume execution. try: event.continueDebugEvent = win32.DBG_CONTINUE self.cont(event) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Detach from or kill all debuggees. try: if self.__bKillOnExit: self.kill_all(bIgnoreExceptions) else: self.detach_from_all(bIgnoreExceptions) except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Cleanup the process snapshots. try: self.system.clear() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) # Close all Win32 handles the Python garbage collector failed to close. self.force_garbage_collection(bIgnoreExceptions)
[ "def", "stop", "(", "self", ",", "bIgnoreExceptions", "=", "True", ")", ":", "# Determine if we have a last debug event that we need to continue.", "try", ":", "event", "=", "self", ".", "lastEvent", "has_event", "=", "bool", "(", "event", ")", "except", "Exception"...
Stops debugging all processes. If the kill on exit mode is on, debugged processes are killed when the debugger is stopped. Otherwise when the debugger stops it detaches from all debugged processes and leaves them running (default). For more details see: L{__init__} @note: This method is better than L{detach_from_all} because it can gracefully handle the last debugging event before detaching. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching.
[ "Stops", "debugging", "all", "processes", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L989-L1072
train
209,360
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.next
def next(self): """ Handles the next debug event. @see: L{cont}, L{dispatch}, L{wait}, L{stop} @raise WindowsError: Raises an exception on error. If the wait operation causes an error, debugging is stopped (meaning all debugees are either killed or detached from). If the event dispatching causes an error, the event is still continued before returning. This may happen, for example, if the event handler raises an exception nobody catches. """ try: event = self.wait() except Exception: self.stop() raise try: self.dispatch() finally: self.cont()
python
def next(self): """ Handles the next debug event. @see: L{cont}, L{dispatch}, L{wait}, L{stop} @raise WindowsError: Raises an exception on error. If the wait operation causes an error, debugging is stopped (meaning all debugees are either killed or detached from). If the event dispatching causes an error, the event is still continued before returning. This may happen, for example, if the event handler raises an exception nobody catches. """ try: event = self.wait() except Exception: self.stop() raise try: self.dispatch() finally: self.cont()
[ "def", "next", "(", "self", ")", ":", "try", ":", "event", "=", "self", ".", "wait", "(", ")", "except", "Exception", ":", "self", ".", "stop", "(", ")", "raise", "try", ":", "self", ".", "dispatch", "(", ")", "finally", ":", "self", ".", "cont",...
Handles the next debug event. @see: L{cont}, L{dispatch}, L{wait}, L{stop} @raise WindowsError: Raises an exception on error. If the wait operation causes an error, debugging is stopped (meaning all debugees are either killed or detached from). If the event dispatching causes an error, the event is still continued before returning. This may happen, for example, if the event handler raises an exception nobody catches.
[ "Handles", "the", "next", "debug", "event", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1074-L1097
train
209,361
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.interactive
def interactive(self, bConfirmQuit = True, bShowBanner = True): """ Start an interactive debugging session. @type bConfirmQuit: bool @param bConfirmQuit: Set to C{True} to ask the user for confirmation before closing the session, C{False} otherwise. @type bShowBanner: bool @param bShowBanner: Set to C{True} to show a banner before entering the session and after leaving it, C{False} otherwise. @warn: This will temporarily disable the user-defined event handler! This method returns when the user closes the session. """ print('') print("-" * 79) print("Interactive debugging session started.") print("Use the \"help\" command to list all available commands.") print("Use the \"quit\" command to close this session.") print("-" * 79) if self.lastEvent is None: print('') console = ConsoleDebugger() console.confirm_quit = bConfirmQuit console.load_history() try: console.start_using_debugger(self) console.loop() finally: console.stop_using_debugger() console.save_history() print('') print("-" * 79) print("Interactive debugging session closed.") print("-" * 79) print('')
python
def interactive(self, bConfirmQuit = True, bShowBanner = True): """ Start an interactive debugging session. @type bConfirmQuit: bool @param bConfirmQuit: Set to C{True} to ask the user for confirmation before closing the session, C{False} otherwise. @type bShowBanner: bool @param bShowBanner: Set to C{True} to show a banner before entering the session and after leaving it, C{False} otherwise. @warn: This will temporarily disable the user-defined event handler! This method returns when the user closes the session. """ print('') print("-" * 79) print("Interactive debugging session started.") print("Use the \"help\" command to list all available commands.") print("Use the \"quit\" command to close this session.") print("-" * 79) if self.lastEvent is None: print('') console = ConsoleDebugger() console.confirm_quit = bConfirmQuit console.load_history() try: console.start_using_debugger(self) console.loop() finally: console.stop_using_debugger() console.save_history() print('') print("-" * 79) print("Interactive debugging session closed.") print("-" * 79) print('')
[ "def", "interactive", "(", "self", ",", "bConfirmQuit", "=", "True", ",", "bShowBanner", "=", "True", ")", ":", "print", "(", "''", ")", "print", "(", "\"-\"", "*", "79", ")", "print", "(", "\"Interactive debugging session started.\"", ")", "print", "(", "...
Start an interactive debugging session. @type bConfirmQuit: bool @param bConfirmQuit: Set to C{True} to ask the user for confirmation before closing the session, C{False} otherwise. @type bShowBanner: bool @param bShowBanner: Set to C{True} to show a banner before entering the session and after leaving it, C{False} otherwise. @warn: This will temporarily disable the user-defined event handler! This method returns when the user closes the session.
[ "Start", "an", "interactive", "debugging", "session", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1204-L1241
train
209,362
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug.force_garbage_collection
def force_garbage_collection(bIgnoreExceptions = True): """ Close all Win32 handles the Python garbage collector failed to close. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. """ try: import gc gc.collect() bRecollect = False for obj in list(gc.garbage): try: if isinstance(obj, win32.Handle): obj.close() elif isinstance(obj, Event): obj.debug = None elif isinstance(obj, Process): obj.clear() elif isinstance(obj, Thread): obj.set_process(None) obj.clear() elif isinstance(obj, Module): obj.set_process(None) elif isinstance(obj, Window): obj.set_process(None) else: continue gc.garbage.remove(obj) del obj bRecollect = True except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) if bRecollect: gc.collect() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
python
def force_garbage_collection(bIgnoreExceptions = True): """ Close all Win32 handles the Python garbage collector failed to close. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching. """ try: import gc gc.collect() bRecollect = False for obj in list(gc.garbage): try: if isinstance(obj, win32.Handle): obj.close() elif isinstance(obj, Event): obj.debug = None elif isinstance(obj, Process): obj.clear() elif isinstance(obj, Thread): obj.set_process(None) obj.clear() elif isinstance(obj, Module): obj.set_process(None) elif isinstance(obj, Window): obj.set_process(None) else: continue gc.garbage.remove(obj) del obj bRecollect = True except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning) if bRecollect: gc.collect() except Exception: if not bIgnoreExceptions: raise e = sys.exc_info()[1] warnings.warn(str(e), RuntimeWarning)
[ "def", "force_garbage_collection", "(", "bIgnoreExceptions", "=", "True", ")", ":", "try", ":", "import", "gc", "gc", ".", "collect", "(", ")", "bRecollect", "=", "False", "for", "obj", "in", "list", "(", "gc", ".", "garbage", ")", ":", "try", ":", "if...
Close all Win32 handles the Python garbage collector failed to close. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when detaching.
[ "Close", "all", "Win32", "handles", "the", "Python", "garbage", "collector", "failed", "to", "close", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1246-L1289
train
209,363
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug._notify_load_dll
def _notify_load_dll(self, event): """ Notify the load of a new module. @warning: This method is meant to be used internally by the debugger. @type event: L{LoadDLLEvent} @param event: Load DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ # Pass the event to the breakpoint container. bCallHandler = _BreakpointContainer._notify_load_dll(self, event) # Get the process where the DLL was loaded. aProcess = event.get_process() # Pass the event to the process. bCallHandler = aProcess._notify_load_dll(event) and bCallHandler # Anti-anti-debugging tricks on ntdll.dll. if self.__bHostileCode: aModule = event.get_module() if aModule.match_name('ntdll.dll'): # Since we've overwritten the PEB to hide # ourselves, we no longer have the system # breakpoint when attaching to the process. # Set a breakpoint at ntdll!DbgUiRemoteBreakin # instead (that's where the debug API spawns # it's auxiliary threads). This also defeats # a simple anti-debugging trick: the hostile # process could have overwritten the int3 # instruction at the system breakpoint. self.break_at(aProcess.get_pid(), aProcess.resolve_label('ntdll!DbgUiRemoteBreakin')) return bCallHandler
python
def _notify_load_dll(self, event): """ Notify the load of a new module. @warning: This method is meant to be used internally by the debugger. @type event: L{LoadDLLEvent} @param event: Load DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ # Pass the event to the breakpoint container. bCallHandler = _BreakpointContainer._notify_load_dll(self, event) # Get the process where the DLL was loaded. aProcess = event.get_process() # Pass the event to the process. bCallHandler = aProcess._notify_load_dll(event) and bCallHandler # Anti-anti-debugging tricks on ntdll.dll. if self.__bHostileCode: aModule = event.get_module() if aModule.match_name('ntdll.dll'): # Since we've overwritten the PEB to hide # ourselves, we no longer have the system # breakpoint when attaching to the process. # Set a breakpoint at ntdll!DbgUiRemoteBreakin # instead (that's where the debug API spawns # it's auxiliary threads). This also defeats # a simple anti-debugging trick: the hostile # process could have overwritten the int3 # instruction at the system breakpoint. self.break_at(aProcess.get_pid(), aProcess.resolve_label('ntdll!DbgUiRemoteBreakin')) return bCallHandler
[ "def", "_notify_load_dll", "(", "self", ",", "event", ")", ":", "# Pass the event to the breakpoint container.", "bCallHandler", "=", "_BreakpointContainer", ".", "_notify_load_dll", "(", "self", ",", "event", ")", "# Get the process where the DLL was loaded.", "aProcess", ...
Notify the load of a new module. @warning: This method is meant to be used internally by the debugger. @type event: L{LoadDLLEvent} @param event: Load DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise.
[ "Notify", "the", "load", "of", "a", "new", "module", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1362-L1401
train
209,364
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug._notify_unload_dll
def _notify_unload_dll(self, event): """ Notify the unload of a module. @warning: This method is meant to be used internally by the debugger. @type event: L{UnloadDLLEvent} @param event: Unload DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ bCallHandler1 = _BreakpointContainer._notify_unload_dll(self, event) bCallHandler2 = event.get_process()._notify_unload_dll(event) return bCallHandler1 and bCallHandler2
python
def _notify_unload_dll(self, event): """ Notify the unload of a module. @warning: This method is meant to be used internally by the debugger. @type event: L{UnloadDLLEvent} @param event: Unload DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ bCallHandler1 = _BreakpointContainer._notify_unload_dll(self, event) bCallHandler2 = event.get_process()._notify_unload_dll(event) return bCallHandler1 and bCallHandler2
[ "def", "_notify_unload_dll", "(", "self", ",", "event", ")", ":", "bCallHandler1", "=", "_BreakpointContainer", ".", "_notify_unload_dll", "(", "self", ",", "event", ")", "bCallHandler2", "=", "event", ".", "get_process", "(", ")", ".", "_notify_unload_dll", "("...
Notify the unload of a module. @warning: This method is meant to be used internally by the debugger. @type event: L{UnloadDLLEvent} @param event: Unload DLL event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise.
[ "Notify", "the", "unload", "of", "a", "module", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1450-L1464
train
209,365
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug._notify_debug_control_c
def _notify_debug_control_c(self, event): """ Notify of a Debug Ctrl-C exception. @warning: This method is meant to be used internally by the debugger. @note: This exception is only raised when a debugger is attached, and applications are not supposed to handle it, so we need to handle it ourselves or the application may crash. @see: U{http://msdn.microsoft.com/en-us/library/aa363082(VS.85).aspx} @type event: L{ExceptionEvent} @param event: Debug Ctrl-C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ if event.is_first_chance(): event.continueStatus = win32.DBG_EXCEPTION_HANDLED return True
python
def _notify_debug_control_c(self, event): """ Notify of a Debug Ctrl-C exception. @warning: This method is meant to be used internally by the debugger. @note: This exception is only raised when a debugger is attached, and applications are not supposed to handle it, so we need to handle it ourselves or the application may crash. @see: U{http://msdn.microsoft.com/en-us/library/aa363082(VS.85).aspx} @type event: L{ExceptionEvent} @param event: Debug Ctrl-C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ if event.is_first_chance(): event.continueStatus = win32.DBG_EXCEPTION_HANDLED return True
[ "def", "_notify_debug_control_c", "(", "self", ",", "event", ")", ":", "if", "event", ".", "is_first_chance", "(", ")", ":", "event", ".", "continueStatus", "=", "win32", ".", "DBG_EXCEPTION_HANDLED", "return", "True" ]
Notify of a Debug Ctrl-C exception. @warning: This method is meant to be used internally by the debugger. @note: This exception is only raised when a debugger is attached, and applications are not supposed to handle it, so we need to handle it ourselves or the application may crash. @see: U{http://msdn.microsoft.com/en-us/library/aa363082(VS.85).aspx} @type event: L{ExceptionEvent} @param event: Debug Ctrl-C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise.
[ "Notify", "of", "a", "Debug", "Ctrl", "-", "C", "exception", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1481-L1501
train
209,366
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/debug.py
Debug._notify_ms_vc_exception
def _notify_ms_vc_exception(self, event): """ Notify of a Microsoft Visual C exception. @warning: This method is meant to be used internally by the debugger. @note: This allows the debugger to understand the Microsoft Visual C thread naming convention. @see: U{http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx} @type event: L{ExceptionEvent} @param event: Microsoft Visual C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ dwType = event.get_exception_information(0) if dwType == 0x1000: pszName = event.get_exception_information(1) dwThreadId = event.get_exception_information(2) dwFlags = event.get_exception_information(3) aProcess = event.get_process() szName = aProcess.peek_string(pszName, fUnicode = False) if szName: if dwThreadId == -1: dwThreadId = event.get_tid() if aProcess.has_thread(dwThreadId): aThread = aProcess.get_thread(dwThreadId) else: aThread = Thread(dwThreadId) aProcess._add_thread(aThread) ## if aThread.get_name() is None: ## aThread.set_name(szName) aThread.set_name(szName) return True
python
def _notify_ms_vc_exception(self, event): """ Notify of a Microsoft Visual C exception. @warning: This method is meant to be used internally by the debugger. @note: This allows the debugger to understand the Microsoft Visual C thread naming convention. @see: U{http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx} @type event: L{ExceptionEvent} @param event: Microsoft Visual C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise. """ dwType = event.get_exception_information(0) if dwType == 0x1000: pszName = event.get_exception_information(1) dwThreadId = event.get_exception_information(2) dwFlags = event.get_exception_information(3) aProcess = event.get_process() szName = aProcess.peek_string(pszName, fUnicode = False) if szName: if dwThreadId == -1: dwThreadId = event.get_tid() if aProcess.has_thread(dwThreadId): aThread = aProcess.get_thread(dwThreadId) else: aThread = Thread(dwThreadId) aProcess._add_thread(aThread) ## if aThread.get_name() is None: ## aThread.set_name(szName) aThread.set_name(szName) return True
[ "def", "_notify_ms_vc_exception", "(", "self", ",", "event", ")", ":", "dwType", "=", "event", ".", "get_exception_information", "(", "0", ")", "if", "dwType", "==", "0x1000", ":", "pszName", "=", "event", ".", "get_exception_information", "(", "1", ")", "dw...
Notify of a Microsoft Visual C exception. @warning: This method is meant to be used internally by the debugger. @note: This allows the debugger to understand the Microsoft Visual C thread naming convention. @see: U{http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx} @type event: L{ExceptionEvent} @param event: Microsoft Visual C exception event. @rtype: bool @return: C{True} to call the user-defined handle, C{False} otherwise.
[ "Notify", "of", "a", "Microsoft", "Visual", "C", "exception", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/debug.py#L1503-L1543
train
209,367
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pgen2/driver.py
_newer
def _newer(a, b): """Inquire whether file a was written since file b.""" if not os.path.exists(a): return False if not os.path.exists(b): return True return os.path.getmtime(a) >= os.path.getmtime(b)
python
def _newer(a, b): """Inquire whether file a was written since file b.""" if not os.path.exists(a): return False if not os.path.exists(b): return True return os.path.getmtime(a) >= os.path.getmtime(b)
[ "def", "_newer", "(", "a", ",", "b", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "a", ")", ":", "return", "False", "if", "not", "os", ".", "path", ".", "exists", "(", "b", ")", ":", "return", "True", "return", "os", ".", "pa...
Inquire whether file a was written since file b.
[ "Inquire", "whether", "file", "a", "was", "written", "since", "file", "b", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pgen2/driver.py#L134-L140
train
209,368
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pgen2/driver.py
Driver.parse_tokens
def parse_tokens(self, tokens, debug=False): """Parse a series of tokens and return the syntax tree.""" # XXX Move the prefix computation into a wrapper around tokenize. p = parse.Parser(self.grammar, self.convert) p.setup() lineno = 1 column = 0 type = value = start = end = line_text = None prefix = u"" for quintuple in tokens: type, value, start, end, line_text = quintuple if start != (lineno, column): assert (lineno, column) <= start, ((lineno, column), start) s_lineno, s_column = start if lineno < s_lineno: prefix += "\n" * (s_lineno - lineno) lineno = s_lineno column = 0 if column < s_column: prefix += line_text[column:s_column] column = s_column if type in (tokenize.COMMENT, tokenize.NL): prefix += value lineno, column = end if value.endswith("\n"): lineno += 1 column = 0 continue if type == token.OP: type = grammar.opmap[value] if debug: self.logger.debug("%s %r (prefix=%r)", token.tok_name[type], value, prefix) if p.addtoken(type, value, (prefix, start)): if debug: self.logger.debug("Stop.") break prefix = "" lineno, column = end if value.endswith("\n"): lineno += 1 column = 0 else: # We never broke out -- EOF is too soon (how can this happen???) raise parse.ParseError("incomplete input", type, value, (prefix, start)) return p.rootnode
python
def parse_tokens(self, tokens, debug=False): """Parse a series of tokens and return the syntax tree.""" # XXX Move the prefix computation into a wrapper around tokenize. p = parse.Parser(self.grammar, self.convert) p.setup() lineno = 1 column = 0 type = value = start = end = line_text = None prefix = u"" for quintuple in tokens: type, value, start, end, line_text = quintuple if start != (lineno, column): assert (lineno, column) <= start, ((lineno, column), start) s_lineno, s_column = start if lineno < s_lineno: prefix += "\n" * (s_lineno - lineno) lineno = s_lineno column = 0 if column < s_column: prefix += line_text[column:s_column] column = s_column if type in (tokenize.COMMENT, tokenize.NL): prefix += value lineno, column = end if value.endswith("\n"): lineno += 1 column = 0 continue if type == token.OP: type = grammar.opmap[value] if debug: self.logger.debug("%s %r (prefix=%r)", token.tok_name[type], value, prefix) if p.addtoken(type, value, (prefix, start)): if debug: self.logger.debug("Stop.") break prefix = "" lineno, column = end if value.endswith("\n"): lineno += 1 column = 0 else: # We never broke out -- EOF is too soon (how can this happen???) raise parse.ParseError("incomplete input", type, value, (prefix, start)) return p.rootnode
[ "def", "parse_tokens", "(", "self", ",", "tokens", ",", "debug", "=", "False", ")", ":", "# XXX Move the prefix computation into a wrapper around tokenize.", "p", "=", "parse", ".", "Parser", "(", "self", ".", "grammar", ",", "self", ".", "convert", ")", "p", ...
Parse a series of tokens and return the syntax tree.
[ "Parse", "a", "series", "of", "tokens", "and", "return", "the", "syntax", "tree", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pgen2/driver.py#L38-L84
train
209,369
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pgen2/driver.py
Driver.parse_stream_raw
def parse_stream_raw(self, stream, debug=False): """Parse a stream and return the syntax tree.""" tokens = tokenize.generate_tokens(stream.readline) return self.parse_tokens(tokens, debug)
python
def parse_stream_raw(self, stream, debug=False): """Parse a stream and return the syntax tree.""" tokens = tokenize.generate_tokens(stream.readline) return self.parse_tokens(tokens, debug)
[ "def", "parse_stream_raw", "(", "self", ",", "stream", ",", "debug", "=", "False", ")", ":", "tokens", "=", "tokenize", ".", "generate_tokens", "(", "stream", ".", "readline", ")", "return", "self", ".", "parse_tokens", "(", "tokens", ",", "debug", ")" ]
Parse a stream and return the syntax tree.
[ "Parse", "a", "stream", "and", "return", "the", "syntax", "tree", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pgen2/driver.py#L86-L89
train
209,370
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pgen2/driver.py
Driver.parse_file
def parse_file(self, filename, encoding=None, debug=False): """Parse a file and return the syntax tree.""" stream = codecs.open(filename, "r", encoding) try: return self.parse_stream(stream, debug) finally: stream.close()
python
def parse_file(self, filename, encoding=None, debug=False): """Parse a file and return the syntax tree.""" stream = codecs.open(filename, "r", encoding) try: return self.parse_stream(stream, debug) finally: stream.close()
[ "def", "parse_file", "(", "self", ",", "filename", ",", "encoding", "=", "None", ",", "debug", "=", "False", ")", ":", "stream", "=", "codecs", ".", "open", "(", "filename", ",", "\"r\"", ",", "encoding", ")", "try", ":", "return", "self", ".", "pars...
Parse a file and return the syntax tree.
[ "Parse", "a", "file", "and", "return", "the", "syntax", "tree", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pgen2/driver.py#L95-L101
train
209,371
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pgen2/driver.py
Driver.parse_string
def parse_string(self, text, debug=False): """Parse a string and return the syntax tree.""" tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline) return self.parse_tokens(tokens, debug)
python
def parse_string(self, text, debug=False): """Parse a string and return the syntax tree.""" tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline) return self.parse_tokens(tokens, debug)
[ "def", "parse_string", "(", "self", ",", "text", ",", "debug", "=", "False", ")", ":", "tokens", "=", "tokenize", ".", "generate_tokens", "(", "StringIO", ".", "StringIO", "(", "text", ")", ".", "readline", ")", "return", "self", ".", "parse_tokens", "("...
Parse a string and return the syntax tree.
[ "Parse", "a", "string", "and", "return", "the", "syntax", "tree", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pgen2/driver.py#L103-L106
train
209,372
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_utils.py
dump_threads
def dump_threads(stream=None): ''' Helper to dump thread info. ''' if stream is None: stream = sys.stderr thread_id_to_name = {} try: for t in threading.enumerate(): thread_id_to_name[t.ident] = '%s (daemon: %s, pydevd thread: %s)' % ( t.name, t.daemon, getattr(t, 'is_pydev_daemon_thread', False)) except: pass from _pydevd_bundle.pydevd_additional_thread_info_regular import _current_frames stream.write('===============================================================================\n') stream.write('Threads running\n') stream.write('================================= Thread Dump =================================\n') stream.flush() for thread_id, stack in _current_frames().items(): stream.write('\n-------------------------------------------------------------------------------\n') stream.write(" Thread %s" % thread_id_to_name.get(thread_id, thread_id)) stream.write('\n\n') for i, (filename, lineno, name, line) in enumerate(traceback.extract_stack(stack)): stream.write(' File "%s", line %d, in %s\n' % (filename, lineno, name)) if line: stream.write(" %s\n" % (line.strip())) if i == 0 and 'self' in stack.f_locals: stream.write(' self: ') try: stream.write(str(stack.f_locals['self'])) except: stream.write('Unable to get str of: %s' % (type(stack.f_locals['self']),)) stream.write('\n') stream.flush() stream.write('\n=============================== END Thread Dump ===============================') stream.flush()
python
def dump_threads(stream=None): ''' Helper to dump thread info. ''' if stream is None: stream = sys.stderr thread_id_to_name = {} try: for t in threading.enumerate(): thread_id_to_name[t.ident] = '%s (daemon: %s, pydevd thread: %s)' % ( t.name, t.daemon, getattr(t, 'is_pydev_daemon_thread', False)) except: pass from _pydevd_bundle.pydevd_additional_thread_info_regular import _current_frames stream.write('===============================================================================\n') stream.write('Threads running\n') stream.write('================================= Thread Dump =================================\n') stream.flush() for thread_id, stack in _current_frames().items(): stream.write('\n-------------------------------------------------------------------------------\n') stream.write(" Thread %s" % thread_id_to_name.get(thread_id, thread_id)) stream.write('\n\n') for i, (filename, lineno, name, line) in enumerate(traceback.extract_stack(stack)): stream.write(' File "%s", line %d, in %s\n' % (filename, lineno, name)) if line: stream.write(" %s\n" % (line.strip())) if i == 0 and 'self' in stack.f_locals: stream.write(' self: ') try: stream.write(str(stack.f_locals['self'])) except: stream.write('Unable to get str of: %s' % (type(stack.f_locals['self']),)) stream.write('\n') stream.flush() stream.write('\n=============================== END Thread Dump ===============================') stream.flush()
[ "def", "dump_threads", "(", "stream", "=", "None", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "sys", ".", "stderr", "thread_id_to_name", "=", "{", "}", "try", ":", "for", "t", "in", "threading", ".", "enumerate", "(", ")", ":", "thre...
Helper to dump thread info.
[ "Helper", "to", "dump", "thread", "info", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_utils.py#L145-L187
train
209,373
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.request_debug_privileges
def request_debug_privileges(cls, bIgnoreExceptions = False): """ Requests debug privileges. This may be needed to debug processes running as SYSTEM (such as services) since Windows XP. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when requesting debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ try: cls.request_privileges(win32.SE_DEBUG_NAME) return True except Exception: if not bIgnoreExceptions: raise return False
python
def request_debug_privileges(cls, bIgnoreExceptions = False): """ Requests debug privileges. This may be needed to debug processes running as SYSTEM (such as services) since Windows XP. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when requesting debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ try: cls.request_privileges(win32.SE_DEBUG_NAME) return True except Exception: if not bIgnoreExceptions: raise return False
[ "def", "request_debug_privileges", "(", "cls", ",", "bIgnoreExceptions", "=", "False", ")", ":", "try", ":", "cls", ".", "request_privileges", "(", "win32", ".", "SE_DEBUG_NAME", ")", "return", "True", "except", "Exception", ":", "if", "not", "bIgnoreExceptions"...
Requests debug privileges. This may be needed to debug processes running as SYSTEM (such as services) since Windows XP. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when requesting debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Requests", "debug", "privileges", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L215-L238
train
209,374
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.drop_debug_privileges
def drop_debug_privileges(cls, bIgnoreExceptions = False): """ Drops debug privileges. This may be needed to avoid being detected by certain anti-debug tricks. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when dropping debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ try: cls.drop_privileges(win32.SE_DEBUG_NAME) return True except Exception: if not bIgnoreExceptions: raise return False
python
def drop_debug_privileges(cls, bIgnoreExceptions = False): """ Drops debug privileges. This may be needed to avoid being detected by certain anti-debug tricks. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when dropping debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}. """ try: cls.drop_privileges(win32.SE_DEBUG_NAME) return True except Exception: if not bIgnoreExceptions: raise return False
[ "def", "drop_debug_privileges", "(", "cls", ",", "bIgnoreExceptions", "=", "False", ")", ":", "try", ":", "cls", ".", "drop_privileges", "(", "win32", ".", "SE_DEBUG_NAME", ")", "return", "True", "except", "Exception", ":", "if", "not", "bIgnoreExceptions", ":...
Drops debug privileges. This may be needed to avoid being detected by certain anti-debug tricks. @type bIgnoreExceptions: bool @param bIgnoreExceptions: C{True} to ignore any exceptions that may be raised when dropping debug privileges. @rtype: bool @return: C{True} on success, C{False} on failure. @raise WindowsError: Raises an exception on error, unless C{bIgnoreExceptions} is C{True}.
[ "Drops", "debug", "privileges", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L241-L264
train
209,375
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.adjust_privileges
def adjust_privileges(state, privileges): """ Requests or drops privileges. @type state: bool @param state: C{True} to request, C{False} to drop. @type privileges: list(int) @param privileges: Privileges to request or drop. @raise WindowsError: Raises an exception on error. """ with win32.OpenProcessToken(win32.GetCurrentProcess(), win32.TOKEN_ADJUST_PRIVILEGES) as hToken: NewState = ( (priv, state) for priv in privileges ) win32.AdjustTokenPrivileges(hToken, NewState)
python
def adjust_privileges(state, privileges): """ Requests or drops privileges. @type state: bool @param state: C{True} to request, C{False} to drop. @type privileges: list(int) @param privileges: Privileges to request or drop. @raise WindowsError: Raises an exception on error. """ with win32.OpenProcessToken(win32.GetCurrentProcess(), win32.TOKEN_ADJUST_PRIVILEGES) as hToken: NewState = ( (priv, state) for priv in privileges ) win32.AdjustTokenPrivileges(hToken, NewState)
[ "def", "adjust_privileges", "(", "state", ",", "privileges", ")", ":", "with", "win32", ".", "OpenProcessToken", "(", "win32", ".", "GetCurrentProcess", "(", ")", ",", "win32", ".", "TOKEN_ADJUST_PRIVILEGES", ")", "as", "hToken", ":", "NewState", "=", "(", "...
Requests or drops privileges. @type state: bool @param state: C{True} to request, C{False} to drop. @type privileges: list(int) @param privileges: Privileges to request or drop. @raise WindowsError: Raises an exception on error.
[ "Requests", "or", "drops", "privileges", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L291-L306
train
209,376
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_file_version_info
def get_file_version_info(cls, filename): """ Get the program version from an executable file, if available. @type filename: str @param filename: Pathname to the executable file to query. @rtype: tuple(str, str, bool, bool, str, str) @return: Tuple with version information extracted from the executable file metadata, containing the following: - File version number (C{"major.minor"}). - Product version number (C{"major.minor"}). - C{True} for debug builds, C{False} for production builds. - C{True} for legacy OS builds (DOS, OS/2, Win16), C{False} for modern OS builds. - Binary file type. May be one of the following values: - "application" - "dynamic link library" - "static link library" - "font" - "raster font" - "TrueType font" - "vector font" - "driver" - "communications driver" - "display driver" - "installable driver" - "keyboard driver" - "language driver" - "legacy driver" - "mouse driver" - "network driver" - "printer driver" - "sound driver" - "system driver" - "versioned printer driver" - Binary creation timestamp. Any of the fields may be C{None} if not available. @raise WindowsError: Raises an exception on error. """ # Get the file version info structure. pBlock = win32.GetFileVersionInfo(filename) pBuffer, dwLen = win32.VerQueryValue(pBlock, "\\") if dwLen != ctypes.sizeof(win32.VS_FIXEDFILEINFO): raise ctypes.WinError(win32.ERROR_BAD_LENGTH) pVersionInfo = ctypes.cast(pBuffer, ctypes.POINTER(win32.VS_FIXEDFILEINFO)) VersionInfo = pVersionInfo.contents if VersionInfo.dwSignature != 0xFEEF04BD: raise ctypes.WinError(win32.ERROR_BAD_ARGUMENTS) # File and product versions. FileVersion = "%d.%d" % (VersionInfo.dwFileVersionMS, VersionInfo.dwFileVersionLS) ProductVersion = "%d.%d" % (VersionInfo.dwProductVersionMS, VersionInfo.dwProductVersionLS) # Debug build? if VersionInfo.dwFileFlagsMask & win32.VS_FF_DEBUG: DebugBuild = (VersionInfo.dwFileFlags & win32.VS_FF_DEBUG) != 0 else: DebugBuild = None # Legacy OS build? LegacyBuild = (VersionInfo.dwFileOS != win32.VOS_NT_WINDOWS32) # File type. FileType = cls.__binary_types.get(VersionInfo.dwFileType) if VersionInfo.dwFileType == win32.VFT_DRV: FileType = cls.__driver_types.get(VersionInfo.dwFileSubtype) elif VersionInfo.dwFileType == win32.VFT_FONT: FileType = cls.__font_types.get(VersionInfo.dwFileSubtype) # Timestamp, ex: "Monday, July 7, 2013 (12:20:50.126)". # FIXME: how do we know the time zone? FileDate = (VersionInfo.dwFileDateMS << 32) + VersionInfo.dwFileDateLS if FileDate: CreationTime = win32.FileTimeToSystemTime(FileDate) CreationTimestamp = "%s, %s %d, %d (%d:%d:%d.%d)" % ( cls.__days_of_the_week[CreationTime.wDayOfWeek], cls.__months[CreationTime.wMonth], CreationTime.wDay, CreationTime.wYear, CreationTime.wHour, CreationTime.wMinute, CreationTime.wSecond, CreationTime.wMilliseconds, ) else: CreationTimestamp = None # Return the file version info. return ( FileVersion, ProductVersion, DebugBuild, LegacyBuild, FileType, CreationTimestamp, )
python
def get_file_version_info(cls, filename): """ Get the program version from an executable file, if available. @type filename: str @param filename: Pathname to the executable file to query. @rtype: tuple(str, str, bool, bool, str, str) @return: Tuple with version information extracted from the executable file metadata, containing the following: - File version number (C{"major.minor"}). - Product version number (C{"major.minor"}). - C{True} for debug builds, C{False} for production builds. - C{True} for legacy OS builds (DOS, OS/2, Win16), C{False} for modern OS builds. - Binary file type. May be one of the following values: - "application" - "dynamic link library" - "static link library" - "font" - "raster font" - "TrueType font" - "vector font" - "driver" - "communications driver" - "display driver" - "installable driver" - "keyboard driver" - "language driver" - "legacy driver" - "mouse driver" - "network driver" - "printer driver" - "sound driver" - "system driver" - "versioned printer driver" - Binary creation timestamp. Any of the fields may be C{None} if not available. @raise WindowsError: Raises an exception on error. """ # Get the file version info structure. pBlock = win32.GetFileVersionInfo(filename) pBuffer, dwLen = win32.VerQueryValue(pBlock, "\\") if dwLen != ctypes.sizeof(win32.VS_FIXEDFILEINFO): raise ctypes.WinError(win32.ERROR_BAD_LENGTH) pVersionInfo = ctypes.cast(pBuffer, ctypes.POINTER(win32.VS_FIXEDFILEINFO)) VersionInfo = pVersionInfo.contents if VersionInfo.dwSignature != 0xFEEF04BD: raise ctypes.WinError(win32.ERROR_BAD_ARGUMENTS) # File and product versions. FileVersion = "%d.%d" % (VersionInfo.dwFileVersionMS, VersionInfo.dwFileVersionLS) ProductVersion = "%d.%d" % (VersionInfo.dwProductVersionMS, VersionInfo.dwProductVersionLS) # Debug build? if VersionInfo.dwFileFlagsMask & win32.VS_FF_DEBUG: DebugBuild = (VersionInfo.dwFileFlags & win32.VS_FF_DEBUG) != 0 else: DebugBuild = None # Legacy OS build? LegacyBuild = (VersionInfo.dwFileOS != win32.VOS_NT_WINDOWS32) # File type. FileType = cls.__binary_types.get(VersionInfo.dwFileType) if VersionInfo.dwFileType == win32.VFT_DRV: FileType = cls.__driver_types.get(VersionInfo.dwFileSubtype) elif VersionInfo.dwFileType == win32.VFT_FONT: FileType = cls.__font_types.get(VersionInfo.dwFileSubtype) # Timestamp, ex: "Monday, July 7, 2013 (12:20:50.126)". # FIXME: how do we know the time zone? FileDate = (VersionInfo.dwFileDateMS << 32) + VersionInfo.dwFileDateLS if FileDate: CreationTime = win32.FileTimeToSystemTime(FileDate) CreationTimestamp = "%s, %s %d, %d (%d:%d:%d.%d)" % ( cls.__days_of_the_week[CreationTime.wDayOfWeek], cls.__months[CreationTime.wMonth], CreationTime.wDay, CreationTime.wYear, CreationTime.wHour, CreationTime.wMinute, CreationTime.wSecond, CreationTime.wMilliseconds, ) else: CreationTimestamp = None # Return the file version info. return ( FileVersion, ProductVersion, DebugBuild, LegacyBuild, FileType, CreationTimestamp, )
[ "def", "get_file_version_info", "(", "cls", ",", "filename", ")", ":", "# Get the file version info structure.", "pBlock", "=", "win32", ".", "GetFileVersionInfo", "(", "filename", ")", "pBuffer", ",", "dwLen", "=", "win32", ".", "VerQueryValue", "(", "pBlock", ",...
Get the program version from an executable file, if available. @type filename: str @param filename: Pathname to the executable file to query. @rtype: tuple(str, str, bool, bool, str, str) @return: Tuple with version information extracted from the executable file metadata, containing the following: - File version number (C{"major.minor"}). - Product version number (C{"major.minor"}). - C{True} for debug builds, C{False} for production builds. - C{True} for legacy OS builds (DOS, OS/2, Win16), C{False} for modern OS builds. - Binary file type. May be one of the following values: - "application" - "dynamic link library" - "static link library" - "font" - "raster font" - "TrueType font" - "vector font" - "driver" - "communications driver" - "display driver" - "installable driver" - "keyboard driver" - "language driver" - "legacy driver" - "mouse driver" - "network driver" - "printer driver" - "sound driver" - "system driver" - "versioned printer driver" - Binary creation timestamp. Any of the fields may be C{None} if not available. @raise WindowsError: Raises an exception on error.
[ "Get", "the", "program", "version", "from", "an", "executable", "file", "if", "available", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L375-L477
train
209,377
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.set_kill_on_exit_mode
def set_kill_on_exit_mode(bKillOnExit = False): """ Defines the behavior of the debugged processes when the debugging thread dies. This method only affects the calling thread. Works on the following platforms: - Microsoft Windows XP and above. - Wine (Windows Emulator). Fails on the following platforms: - Microsoft Windows 2000 and below. - ReactOS. @type bKillOnExit: bool @param bKillOnExit: C{True} to automatically kill processes when the debugger thread dies. C{False} to automatically detach from processes when the debugger thread dies. @rtype: bool @return: C{True} on success, C{False} on error. @note: This call will fail if a debug port was not created. That is, if the debugger isn't attached to at least one process. For more info see: U{http://msdn.microsoft.com/en-us/library/ms679307.aspx} """ try: # won't work before calling CreateProcess or DebugActiveProcess win32.DebugSetProcessKillOnExit(bKillOnExit) except (AttributeError, WindowsError): return False return True
python
def set_kill_on_exit_mode(bKillOnExit = False): """ Defines the behavior of the debugged processes when the debugging thread dies. This method only affects the calling thread. Works on the following platforms: - Microsoft Windows XP and above. - Wine (Windows Emulator). Fails on the following platforms: - Microsoft Windows 2000 and below. - ReactOS. @type bKillOnExit: bool @param bKillOnExit: C{True} to automatically kill processes when the debugger thread dies. C{False} to automatically detach from processes when the debugger thread dies. @rtype: bool @return: C{True} on success, C{False} on error. @note: This call will fail if a debug port was not created. That is, if the debugger isn't attached to at least one process. For more info see: U{http://msdn.microsoft.com/en-us/library/ms679307.aspx} """ try: # won't work before calling CreateProcess or DebugActiveProcess win32.DebugSetProcessKillOnExit(bKillOnExit) except (AttributeError, WindowsError): return False return True
[ "def", "set_kill_on_exit_mode", "(", "bKillOnExit", "=", "False", ")", ":", "try", ":", "# won't work before calling CreateProcess or DebugActiveProcess", "win32", ".", "DebugSetProcessKillOnExit", "(", "bKillOnExit", ")", "except", "(", "AttributeError", ",", "WindowsError...
Defines the behavior of the debugged processes when the debugging thread dies. This method only affects the calling thread. Works on the following platforms: - Microsoft Windows XP and above. - Wine (Windows Emulator). Fails on the following platforms: - Microsoft Windows 2000 and below. - ReactOS. @type bKillOnExit: bool @param bKillOnExit: C{True} to automatically kill processes when the debugger thread dies. C{False} to automatically detach from processes when the debugger thread dies. @rtype: bool @return: C{True} on success, C{False} on error. @note: This call will fail if a debug port was not created. That is, if the debugger isn't attached to at least one process. For more info see: U{http://msdn.microsoft.com/en-us/library/ms679307.aspx}
[ "Defines", "the", "behavior", "of", "the", "debugged", "processes", "when", "the", "debugging", "thread", "dies", ".", "This", "method", "only", "affects", "the", "calling", "thread", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L739-L772
train
209,378
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.enable_step_on_branch_mode
def enable_step_on_branch_mode(cls): """ When tracing, call this on every single step event for step on branch mode. @raise WindowsError: Raises C{ERROR_DEBUGGER_INACTIVE} if the debugger is not attached to least one process. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far. """ cls.write_msr(DebugRegister.DebugCtlMSR, DebugRegister.BranchTrapFlag | DebugRegister.LastBranchRecord)
python
def enable_step_on_branch_mode(cls): """ When tracing, call this on every single step event for step on branch mode. @raise WindowsError: Raises C{ERROR_DEBUGGER_INACTIVE} if the debugger is not attached to least one process. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far. """ cls.write_msr(DebugRegister.DebugCtlMSR, DebugRegister.BranchTrapFlag | DebugRegister.LastBranchRecord)
[ "def", "enable_step_on_branch_mode", "(", "cls", ")", ":", "cls", ".", "write_msr", "(", "DebugRegister", ".", "DebugCtlMSR", ",", "DebugRegister", ".", "BranchTrapFlag", "|", "DebugRegister", ".", "LastBranchRecord", ")" ]
When tracing, call this on every single step event for step on branch mode. @raise WindowsError: Raises C{ERROR_DEBUGGER_INACTIVE} if the debugger is not attached to least one process. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far.
[ "When", "tracing", "call", "this", "on", "every", "single", "step", "event", "for", "step", "on", "branch", "mode", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L836-L859
train
209,379
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_last_branch_location
def get_last_branch_location(cls): """ Returns the source and destination addresses of the last taken branch. @rtype: tuple( int, int ) @return: Source and destination addresses of the last taken branch. @raise WindowsError: Raises an exception on error. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far. """ LastBranchFromIP = cls.read_msr(DebugRegister.LastBranchFromIP) LastBranchToIP = cls.read_msr(DebugRegister.LastBranchToIP) return ( LastBranchFromIP, LastBranchToIP )
python
def get_last_branch_location(cls): """ Returns the source and destination addresses of the last taken branch. @rtype: tuple( int, int ) @return: Source and destination addresses of the last taken branch. @raise WindowsError: Raises an exception on error. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far. """ LastBranchFromIP = cls.read_msr(DebugRegister.LastBranchFromIP) LastBranchToIP = cls.read_msr(DebugRegister.LastBranchToIP) return ( LastBranchFromIP, LastBranchToIP )
[ "def", "get_last_branch_location", "(", "cls", ")", ":", "LastBranchFromIP", "=", "cls", ".", "read_msr", "(", "DebugRegister", ".", "LastBranchFromIP", ")", "LastBranchToIP", "=", "cls", ".", "read_msr", "(", "DebugRegister", ".", "LastBranchToIP", ")", "return",...
Returns the source and destination addresses of the last taken branch. @rtype: tuple( int, int ) @return: Source and destination addresses of the last taken branch. @raise WindowsError: Raises an exception on error. @raise NotImplementedError: Current architecture is not C{i386} or C{amd64}. @warning: This method uses the processor's machine specific registers (MSR). It could potentially brick your machine. It works on my machine, but your mileage may vary. @note: It doesn't seem to work in VMWare or VirtualBox machines. Maybe it fails in other virtualization/emulation environments, no extensive testing was made so far.
[ "Returns", "the", "source", "and", "destination", "addresses", "of", "the", "last", "taken", "branch", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L862-L887
train
209,380
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_postmortem_debugger
def get_postmortem_debugger(cls, bits = None): """ Returns the postmortem debugging settings from the Registry. @see: L{set_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}. @rtype: tuple( str, bool, int ) @return: A tuple containing the command line string to the postmortem debugger, a boolean specifying if user interaction is allowed before attaching, and an integer specifying a user defined hotkey. Any member of the tuple may be C{None}. See L{set_postmortem_debugger} for more details. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' key = cls.registry[keyname] debugger = key.get('Debugger') auto = key.get('Auto') hotkey = key.get('UserDebuggerHotkey') if auto is not None: auto = bool(auto) return (debugger, auto, hotkey)
python
def get_postmortem_debugger(cls, bits = None): """ Returns the postmortem debugging settings from the Registry. @see: L{set_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}. @rtype: tuple( str, bool, int ) @return: A tuple containing the command line string to the postmortem debugger, a boolean specifying if user interaction is allowed before attaching, and an integer specifying a user defined hotkey. Any member of the tuple may be C{None}. See L{set_postmortem_debugger} for more details. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' key = cls.registry[keyname] debugger = key.get('Debugger') auto = key.get('Auto') hotkey = key.get('UserDebuggerHotkey') if auto is not None: auto = bool(auto) return (debugger, auto, hotkey)
[ "def", "get_postmortem_debugger", "(", "cls", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "(", "32", ",", "64", ")", ":", "raise", "NotImplementedError", "(", "\"U...
Returns the postmortem debugging settings from the Registry. @see: L{set_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}. @rtype: tuple( str, bool, int ) @return: A tuple containing the command line string to the postmortem debugger, a boolean specifying if user interaction is allowed before attaching, and an integer specifying a user defined hotkey. Any member of the tuple may be C{None}. See L{set_postmortem_debugger} for more details. @raise WindowsError: Raises an exception on error.
[ "Returns", "the", "postmortem", "debugging", "settings", "from", "the", "Registry", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L892-L931
train
209,381
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_postmortem_exclusion_list
def get_postmortem_exclusion_list(cls, bits = None): """ Returns the exclusion list for the postmortem debugger. @see: L{get_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: list( str ) @return: List of excluded application filenames. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: return [] return [name for (name, enabled) in key.items() if enabled]
python
def get_postmortem_exclusion_list(cls, bits = None): """ Returns the exclusion list for the postmortem debugger. @see: L{get_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: list( str ) @return: List of excluded application filenames. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: return [] return [name for (name, enabled) in key.items() if enabled]
[ "def", "get_postmortem_exclusion_list", "(", "cls", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "(", "32", ",", "64", ")", ":", "raise", "NotImplementedError", "(", ...
Returns the exclusion list for the postmortem debugger. @see: L{get_postmortem_debugger} @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: list( str ) @return: List of excluded application filenames. @raise WindowsError: Raises an exception on error.
[ "Returns", "the", "exclusion", "list", "for", "the", "postmortem", "debugger", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L934-L965
train
209,382
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.set_postmortem_debugger
def set_postmortem_debugger(cls, cmdline, auto = None, hotkey = None, bits = None): """ Sets the postmortem debugging settings in the Registry. @warning: This method requires administrative rights. @see: L{get_postmortem_debugger} @type cmdline: str @param cmdline: Command line to the new postmortem debugger. When the debugger is invoked, the first "%ld" is replaced with the process ID and the second "%ld" is replaced with the event handle. Don't forget to enclose the program filename in double quotes if the path contains spaces. @type auto: bool @param auto: Set to C{True} if no user interaction is allowed, C{False} to prompt a confirmation dialog before attaching. Use C{None} to leave this value unchanged. @type hotkey: int @param hotkey: Virtual key scan code for the user defined hotkey. Use C{0} to disable the hotkey. Use C{None} to leave this value unchanged. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: tuple( str, bool, int ) @return: Previously defined command line and auto flag. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' key = cls.registry[keyname] if cmdline is not None: key['Debugger'] = cmdline if auto is not None: key['Auto'] = int(bool(auto)) if hotkey is not None: key['UserDebuggerHotkey'] = int(hotkey)
python
def set_postmortem_debugger(cls, cmdline, auto = None, hotkey = None, bits = None): """ Sets the postmortem debugging settings in the Registry. @warning: This method requires administrative rights. @see: L{get_postmortem_debugger} @type cmdline: str @param cmdline: Command line to the new postmortem debugger. When the debugger is invoked, the first "%ld" is replaced with the process ID and the second "%ld" is replaced with the event handle. Don't forget to enclose the program filename in double quotes if the path contains spaces. @type auto: bool @param auto: Set to C{True} if no user interaction is allowed, C{False} to prompt a confirmation dialog before attaching. Use C{None} to leave this value unchanged. @type hotkey: int @param hotkey: Virtual key scan code for the user defined hotkey. Use C{0} to disable the hotkey. Use C{None} to leave this value unchanged. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: tuple( str, bool, int ) @return: Previously defined command line and auto flag. @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug' key = cls.registry[keyname] if cmdline is not None: key['Debugger'] = cmdline if auto is not None: key['Auto'] = int(bool(auto)) if hotkey is not None: key['UserDebuggerHotkey'] = int(hotkey)
[ "def", "set_postmortem_debugger", "(", "cls", ",", "cmdline", ",", "auto", "=", "None", ",", "hotkey", "=", "None", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "...
Sets the postmortem debugging settings in the Registry. @warning: This method requires administrative rights. @see: L{get_postmortem_debugger} @type cmdline: str @param cmdline: Command line to the new postmortem debugger. When the debugger is invoked, the first "%ld" is replaced with the process ID and the second "%ld" is replaced with the event handle. Don't forget to enclose the program filename in double quotes if the path contains spaces. @type auto: bool @param auto: Set to C{True} if no user interaction is allowed, C{False} to prompt a confirmation dialog before attaching. Use C{None} to leave this value unchanged. @type hotkey: int @param hotkey: Virtual key scan code for the user defined hotkey. Use C{0} to disable the hotkey. Use C{None} to leave this value unchanged. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @rtype: tuple( str, bool, int ) @return: Previously defined command line and auto flag. @raise WindowsError: Raises an exception on error.
[ "Sets", "the", "postmortem", "debugging", "settings", "in", "the", "Registry", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L968-L1021
train
209,383
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.add_to_postmortem_exclusion_list
def add_to_postmortem_exclusion_list(cls, pathname, bits = None): """ Adds the given filename to the exclusion list for postmortem debugging. @warning: This method requires administrative rights. @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to exclude from postmortem debugging. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: key = cls.registry.create(keyname) key[pathname] = 1
python
def add_to_postmortem_exclusion_list(cls, pathname, bits = None): """ Adds the given filename to the exclusion list for postmortem debugging. @warning: This method requires administrative rights. @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to exclude from postmortem debugging. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: key = cls.registry.create(keyname) key[pathname] = 1
[ "def", "add_to_postmortem_exclusion_list", "(", "cls", ",", "pathname", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "(", "32", ",", "64", ")", ":", "raise", "NotIm...
Adds the given filename to the exclusion list for postmortem debugging. @warning: This method requires administrative rights. @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to exclude from postmortem debugging. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error.
[ "Adds", "the", "given", "filename", "to", "the", "exclusion", "list", "for", "postmortem", "debugging", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1024-L1058
train
209,384
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.remove_from_postmortem_exclusion_list
def remove_from_postmortem_exclusion_list(cls, pathname, bits = None): """ Removes the given filename to the exclusion list for postmortem debugging from the Registry. @warning: This method requires administrative rights. @warning: Don't ever delete entries you haven't created yourself! Some entries are set by default for your version of Windows. Deleting them might deadlock your system under some circumstances. For more details see: U{http://msdn.microsoft.com/en-us/library/bb204634(v=vs.85).aspx} @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to remove from the postmortem debugging exclusion list. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: return try: del key[pathname] except KeyError: return
python
def remove_from_postmortem_exclusion_list(cls, pathname, bits = None): """ Removes the given filename to the exclusion list for postmortem debugging from the Registry. @warning: This method requires administrative rights. @warning: Don't ever delete entries you haven't created yourself! Some entries are set by default for your version of Windows. Deleting them might deadlock your system under some circumstances. For more details see: U{http://msdn.microsoft.com/en-us/library/bb204634(v=vs.85).aspx} @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to remove from the postmortem debugging exclusion list. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error. """ if bits is None: bits = cls.bits elif bits not in (32, 64): raise NotImplementedError("Unknown architecture (%r bits)" % bits) if bits == 32 and cls.bits == 64: keyname = 'HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' else: keyname = 'HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList' try: key = cls.registry[keyname] except KeyError: return try: del key[pathname] except KeyError: return
[ "def", "remove_from_postmortem_exclusion_list", "(", "cls", ",", "pathname", ",", "bits", "=", "None", ")", ":", "if", "bits", "is", "None", ":", "bits", "=", "cls", ".", "bits", "elif", "bits", "not", "in", "(", "32", ",", "64", ")", ":", "raise", "...
Removes the given filename to the exclusion list for postmortem debugging from the Registry. @warning: This method requires administrative rights. @warning: Don't ever delete entries you haven't created yourself! Some entries are set by default for your version of Windows. Deleting them might deadlock your system under some circumstances. For more details see: U{http://msdn.microsoft.com/en-us/library/bb204634(v=vs.85).aspx} @see: L{get_postmortem_exclusion_list} @type pathname: str @param pathname: Application pathname to remove from the postmortem debugging exclusion list. @type bits: int @param bits: Set to C{32} for the 32 bits debugger, or C{64} for the 64 bits debugger. Set to {None} for the default (L{System.bits}). @raise WindowsError: Raises an exception on error.
[ "Removes", "the", "given", "filename", "to", "the", "exclusion", "list", "for", "postmortem", "debugging", "from", "the", "Registry", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1061-L1106
train
209,385
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_services
def get_services(): """ Retrieve a list of all system services. @see: L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: try: return win32.EnumServicesStatusEx(hSCManager) except AttributeError: return win32.EnumServicesStatus(hSCManager)
python
def get_services(): """ Retrieve a list of all system services. @see: L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: try: return win32.EnumServicesStatusEx(hSCManager) except AttributeError: return win32.EnumServicesStatus(hSCManager)
[ "def", "get_services", "(", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_ENUMERATE_SERVICE", ")", "as", "hSCManager", ":", "try", ":", "return", "win32", ".", "EnumServicesStatusEx", "(", "hSCManager", "...
Retrieve a list of all system services. @see: L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors.
[ "Retrieve", "a", "list", "of", "all", "system", "services", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1111-L1128
train
209,386
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_active_services
def get_active_services(): """ Retrieve a list of all active system services. @see: L{get_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return [ entry for entry in win32.EnumServicesStatusEx(hSCManager, dwServiceType = win32.SERVICE_WIN32, dwServiceState = win32.SERVICE_ACTIVE) \ if entry.ProcessId ]
python
def get_active_services(): """ Retrieve a list of all active system services. @see: L{get_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return [ entry for entry in win32.EnumServicesStatusEx(hSCManager, dwServiceType = win32.SERVICE_WIN32, dwServiceState = win32.SERVICE_ACTIVE) \ if entry.ProcessId ]
[ "def", "get_active_services", "(", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_ENUMERATE_SERVICE", ")", "as", "hSCManager", ":", "return", "[", "entry", "for", "entry", "in", "win32", ".", "EnumServices...
Retrieve a list of all active system services. @see: L{get_services}, L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @rtype: list( L{win32.ServiceStatusProcessEntry} ) @return: List of service status descriptors.
[ "Retrieve", "a", "list", "of", "all", "active", "system", "services", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1131-L1148
train
209,387
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_service
def get_service(name): """ Get the service descriptor for the given service name. @see: L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: L{win32.ServiceStatusProcess} @return: Service status descriptor. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_QUERY_STATUS ) as hService: try: return win32.QueryServiceStatusEx(hService) except AttributeError: return win32.QueryServiceStatus(hService)
python
def get_service(name): """ Get the service descriptor for the given service name. @see: L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: L{win32.ServiceStatusProcess} @return: Service status descriptor. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_QUERY_STATUS ) as hService: try: return win32.QueryServiceStatusEx(hService) except AttributeError: return win32.QueryServiceStatus(hService)
[ "def", "get_service", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_ENUMERATE_SERVICE", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManager", ",", "name", ",...
Get the service descriptor for the given service name. @see: L{start_service}, L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: L{win32.ServiceStatusProcess} @return: Service status descriptor.
[ "Get", "the", "service", "descriptor", "for", "the", "given", "service", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1151-L1175
train
209,388
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_service_display_name
def get_service_display_name(name): """ Get the service display name for the given service name. @see: L{get_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service display name. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return win32.GetServiceDisplayName(hSCManager, name)
python
def get_service_display_name(name): """ Get the service display name for the given service name. @see: L{get_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service display name. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return win32.GetServiceDisplayName(hSCManager, name)
[ "def", "get_service_display_name", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_ENUMERATE_SERVICE", ")", "as", "hSCManager", ":", "return", "win32", ".", "GetServiceDisplayName", "(", "hSCManage...
Get the service display name for the given service name. @see: L{get_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service display name.
[ "Get", "the", "service", "display", "name", "for", "the", "given", "service", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1178-L1195
train
209,389
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.get_service_from_display_name
def get_service_from_display_name(displayName): """ Get the service unique name given its display name. @see: L{get_service} @type displayName: str @param displayName: Service display name. You can get this value from the C{DisplayName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service unique name. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return win32.GetServiceKeyName(hSCManager, displayName)
python
def get_service_from_display_name(displayName): """ Get the service unique name given its display name. @see: L{get_service} @type displayName: str @param displayName: Service display name. You can get this value from the C{DisplayName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service unique name. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_ENUMERATE_SERVICE ) as hSCManager: return win32.GetServiceKeyName(hSCManager, displayName)
[ "def", "get_service_from_display_name", "(", "displayName", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_ENUMERATE_SERVICE", ")", "as", "hSCManager", ":", "return", "win32", ".", "GetServiceKeyName", "(", "h...
Get the service unique name given its display name. @see: L{get_service} @type displayName: str @param displayName: Service display name. You can get this value from the C{DisplayName} member of the service descriptors returned by L{get_services} or L{get_active_services}. @rtype: str @return: Service unique name.
[ "Get", "the", "service", "unique", "name", "given", "its", "display", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1198-L1215
train
209,390
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.start_service
def start_service(name, argv = None): """ Start the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_START ) as hService: win32.StartService(hService)
python
def start_service(name, argv = None): """ Start the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}. """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_START ) as hService: win32.StartService(hService)
[ "def", "start_service", "(", "name", ",", "argv", "=", "None", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_CONNECT", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManag...
Start the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{stop_service}, L{pause_service}, L{resume_service} @type name: str @param name: Service unique name. You can get this value from the C{ServiceName} member of the service descriptors returned by L{get_services} or L{get_active_services}.
[ "Start", "the", "service", "given", "by", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1218-L1237
train
209,391
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.stop_service
def stop_service(name): """ Stop the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{get_services}, L{get_active_services}, L{start_service}, L{pause_service}, L{resume_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_STOP ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_STOP)
python
def stop_service(name): """ Stop the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{get_services}, L{get_active_services}, L{start_service}, L{pause_service}, L{resume_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_STOP ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_STOP)
[ "def", "stop_service", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_CONNECT", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManager", ",", "name", ",", "dwD...
Stop the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @see: L{get_services}, L{get_active_services}, L{start_service}, L{pause_service}, L{resume_service}
[ "Stop", "the", "service", "given", "by", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1240-L1255
train
209,392
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.pause_service
def pause_service(name): """ Pause the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{resume_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_PAUSE_CONTINUE ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_PAUSE)
python
def pause_service(name): """ Pause the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{resume_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_PAUSE_CONTINUE ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_PAUSE)
[ "def", "pause_service", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_CONNECT", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManager", ",", "name", ",", "dw...
Pause the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{resume_service}
[ "Pause", "the", "service", "given", "by", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1258-L1275
train
209,393
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/system.py
System.resume_service
def resume_service(name): """ Resume the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_PAUSE_CONTINUE ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_CONTINUE)
python
def resume_service(name): """ Resume the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service} """ with win32.OpenSCManager( dwDesiredAccess = win32.SC_MANAGER_CONNECT ) as hSCManager: with win32.OpenService(hSCManager, name, dwDesiredAccess = win32.SERVICE_PAUSE_CONTINUE ) as hService: win32.ControlService(hService, win32.SERVICE_CONTROL_CONTINUE)
[ "def", "resume_service", "(", "name", ")", ":", "with", "win32", ".", "OpenSCManager", "(", "dwDesiredAccess", "=", "win32", ".", "SC_MANAGER_CONNECT", ")", "as", "hSCManager", ":", "with", "win32", ".", "OpenService", "(", "hSCManager", ",", "name", ",", "d...
Resume the service given by name. @warn: This method requires UAC elevation in Windows Vista and above. @note: Not all services support this. @see: L{get_services}, L{get_active_services}, L{start_service}, L{stop_service}, L{pause_service}
[ "Resume", "the", "service", "given", "by", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/system.py#L1278-L1295
train
209,394
fabioz/PyDev.Debugger
_pydev_imps/_pydev_uuid_old.py
_ifconfig_getnode
def _ifconfig_getnode(): """Get the hardware address on Unix by running ifconfig.""" # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes. for args in ('', '-a', '-av'): mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1) if mac: return mac import socket ip_addr = socket.gethostbyname(socket.gethostname()) # Try getting the MAC addr from arp based on our IP address (Solaris). mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1) if mac: return mac # This might work on HP-UX. mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0) if mac: return mac return None
python
def _ifconfig_getnode(): """Get the hardware address on Unix by running ifconfig.""" # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes. for args in ('', '-a', '-av'): mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1) if mac: return mac import socket ip_addr = socket.gethostbyname(socket.gethostname()) # Try getting the MAC addr from arp based on our IP address (Solaris). mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1) if mac: return mac # This might work on HP-UX. mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0) if mac: return mac return None
[ "def", "_ifconfig_getnode", "(", ")", ":", "# This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.", "for", "args", "in", "(", "''", ",", "'-a'", ",", "'-av'", ")", ":", "mac", "=", "_find_mac", "(", "'ifconfig'", ",", "args", ",", "[", "'hwaddr'",...
Get the hardware address on Unix by running ifconfig.
[ "Get", "the", "hardware", "address", "on", "Unix", "by", "running", "ifconfig", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_uuid_old.py#L316-L338
train
209,395
fabioz/PyDev.Debugger
_pydev_imps/_pydev_uuid_old.py
_ipconfig_getnode
def _ipconfig_getnode(): """Get the hardware address on Windows by running ipconfig.exe.""" import os, re dirs = ['', r'c:\windows\system32', r'c:\winnt\system32'] try: import ctypes buffer = ctypes.create_string_buffer(300) ctypes.windll.kernel32.GetSystemDirectoryA(buffer, 300) # @UndefinedVariable dirs.insert(0, buffer.value.decode('mbcs')) except: pass for dir in dirs: try: pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') except IOError: continue for line in pipe: value = line.split(':')[-1].strip().lower() if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): return int(value.replace('-', ''), 16)
python
def _ipconfig_getnode(): """Get the hardware address on Windows by running ipconfig.exe.""" import os, re dirs = ['', r'c:\windows\system32', r'c:\winnt\system32'] try: import ctypes buffer = ctypes.create_string_buffer(300) ctypes.windll.kernel32.GetSystemDirectoryA(buffer, 300) # @UndefinedVariable dirs.insert(0, buffer.value.decode('mbcs')) except: pass for dir in dirs: try: pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') except IOError: continue for line in pipe: value = line.split(':')[-1].strip().lower() if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): return int(value.replace('-', ''), 16)
[ "def", "_ipconfig_getnode", "(", ")", ":", "import", "os", ",", "re", "dirs", "=", "[", "''", ",", "r'c:\\windows\\system32'", ",", "r'c:\\winnt\\system32'", "]", "try", ":", "import", "ctypes", "buffer", "=", "ctypes", ".", "create_string_buffer", "(", "300",...
Get the hardware address on Windows by running ipconfig.exe.
[ "Get", "the", "hardware", "address", "on", "Windows", "by", "running", "ipconfig", ".", "exe", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_uuid_old.py#L340-L359
train
209,396
fabioz/PyDev.Debugger
_pydev_imps/_pydev_uuid_old.py
getnode
def getnode(): """Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122. """ global _node if _node is not None: return _node import sys if sys.platform == 'win32': getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] else: getters = [_unixdll_getnode, _ifconfig_getnode] for getter in getters + [_random_getnode]: try: _node = getter() except: continue if _node is not None: return _node
python
def getnode(): """Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122. """ global _node if _node is not None: return _node import sys if sys.platform == 'win32': getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] else: getters = [_unixdll_getnode, _ifconfig_getnode] for getter in getters + [_random_getnode]: try: _node = getter() except: continue if _node is not None: return _node
[ "def", "getnode", "(", ")", ":", "global", "_node", "if", "_node", "is", "not", "None", ":", "return", "_node", "import", "sys", "if", "sys", ".", "platform", "==", "'win32'", ":", "getters", "=", "[", "_windll_getnode", ",", "_netbios_getnode", ",", "_i...
Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122.
[ "Get", "the", "hardware", "address", "as", "a", "48", "-", "bit", "positive", "integer", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_uuid_old.py#L444-L469
train
209,397
fabioz/PyDev.Debugger
_pydev_imps/_pydev_uuid_old.py
uuid3
def uuid3(namespace, name): """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" import md5 hash = md5.md5(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=3)
python
def uuid3(namespace, name): """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" import md5 hash = md5.md5(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=3)
[ "def", "uuid3", "(", "namespace", ",", "name", ")", ":", "import", "md5", "hash", "=", "md5", ".", "md5", "(", "namespace", ".", "bytes", "+", "name", ")", ".", "digest", "(", ")", "return", "UUID", "(", "bytes", "=", "hash", "[", ":", "16", "]",...
Generate a UUID from the MD5 hash of a namespace UUID and a name.
[ "Generate", "a", "UUID", "from", "the", "MD5", "hash", "of", "a", "namespace", "UUID", "and", "a", "name", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_imps/_pydev_uuid_old.py#L507-L511
train
209,398
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_dont_trace.py
default_should_trace_hook
def default_should_trace_hook(frame, filename): ''' Return True if this frame should be traced, False if tracing should be blocked. ''' # First, check whether this code object has a cached value ignored_lines = _filename_to_ignored_lines.get(filename) if ignored_lines is None: # Now, look up that line of code and check for a @DontTrace # preceding or on the same line as the method. # E.g.: # #@DontTrace # def test(): # pass # ... or ... # def test(): #@DontTrace # pass ignored_lines = {} lines = linecache.getlines(filename) for i_line, line in enumerate(lines): j = line.find('#') if j >= 0: comment = line[j:] if DONT_TRACE_TAG in comment: ignored_lines[i_line] = 1 #Note: when it's found in the comment, mark it up and down for the decorator lines found. k = i_line - 1 while k >= 0: if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k -= 1 else: break k = i_line + 1 while k <= len(lines): if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k += 1 else: break _filename_to_ignored_lines[filename] = ignored_lines func_line = frame.f_code.co_firstlineno - 1 # co_firstlineno is 1-based, so -1 is needed return not ( func_line - 1 in ignored_lines or #-1 to get line before method func_line in ignored_lines)
python
def default_should_trace_hook(frame, filename): ''' Return True if this frame should be traced, False if tracing should be blocked. ''' # First, check whether this code object has a cached value ignored_lines = _filename_to_ignored_lines.get(filename) if ignored_lines is None: # Now, look up that line of code and check for a @DontTrace # preceding or on the same line as the method. # E.g.: # #@DontTrace # def test(): # pass # ... or ... # def test(): #@DontTrace # pass ignored_lines = {} lines = linecache.getlines(filename) for i_line, line in enumerate(lines): j = line.find('#') if j >= 0: comment = line[j:] if DONT_TRACE_TAG in comment: ignored_lines[i_line] = 1 #Note: when it's found in the comment, mark it up and down for the decorator lines found. k = i_line - 1 while k >= 0: if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k -= 1 else: break k = i_line + 1 while k <= len(lines): if RE_DECORATOR.match(lines[k]): ignored_lines[k] = 1 k += 1 else: break _filename_to_ignored_lines[filename] = ignored_lines func_line = frame.f_code.co_firstlineno - 1 # co_firstlineno is 1-based, so -1 is needed return not ( func_line - 1 in ignored_lines or #-1 to get line before method func_line in ignored_lines)
[ "def", "default_should_trace_hook", "(", "frame", ",", "filename", ")", ":", "# First, check whether this code object has a cached value", "ignored_lines", "=", "_filename_to_ignored_lines", ".", "get", "(", "filename", ")", "if", "ignored_lines", "is", "None", ":", "# No...
Return True if this frame should be traced, False if tracing should be blocked.
[ "Return", "True", "if", "this", "frame", "should", "be", "traced", "False", "if", "tracing", "should", "be", "blocked", "." ]
ed9c4307662a5593b8a7f1f3389ecd0e79b8c503
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_dont_trace.py#L30-L78
train
209,399