code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
''' 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... | def do_it(self, dbg) | Get completions and write back to the client | 4.647596 | 3.857646 | 1.204775 |
''' Converts request into python variable '''
try:
try:
# don't trace new threads created by console command
disable_trace_thread_modules()
result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg)
... | def do_it(self, dbg) | Converts request into python variable | 5.093088 | 4.732234 | 1.076255 |
'''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
... | def do_it(self, dbg) | Starts a thread that will load values asynchronously | 4.974616 | 4.516438 | 1.101447 |
code = GetLastError()
if code != ERROR_SUCCESS:
raise ctypes.WinError(code)
return result | 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 t... | 3.798711 | 5.220104 | 0.727708 |
_Wow64EnableWow64FsRedirection = windll.kernel32.Wow64EnableWow64FsRedirection
_Wow64EnableWow64FsRedirection.argtypes = [BOOLEAN]
_Wow64EnableWow64FsRedirection.restype = BOOLEAN
_Wow64EnableWow64FsRedirection.errcheck = RaiseIfZero | def Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection) | This function may not work reliably when there are nested calls. Therefore,
this function has been replaced by the L{Wow64DisableWow64FsRedirection}
and L{Wow64RevertWow64FsRedirection} functions.
@see: U{http://msdn.microsoft.com/en-us/library/windows/desktop/aa365744(v=vs.85).aspx} | 1.540948 | 1.680687 | 0.916856 |
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) | Closes the Win32 handle. | 12.804081 | 11.327833 | 1.13032 |
if hasattr(value, 'value'):
value = value.value
if value is not None:
value = long(value)
return value | def _normalize(value) | Normalize handle values. | 4.096873 | 3.676937 | 1.114208 |
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) | 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. | 3.377237 | 3.475324 | 0.971776 |
self.fixers.append(fixer)
tree = reduce_tree(fixer.pattern_tree)
linear = tree.get_linear_subpattern()
match_nodes = self.add(linear, start=self.root)
for match_node in match_nodes:
match_node.fixers.append(fixer) | def add_fixer(self, fixer) | Reduces a fixer's pattern tree to a linear path and adds it
to the matcher(a common Aho-Corasick automaton). The fixer is
appended on the matching states and called when they are
reached | 5.613872 | 4.147364 | 1.3536 |
"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")
... | def add(self, pattern, start) | Recursively adds a linear pattern to the AC automaton | 3.681453 | 3.310982 | 1.111892 |
current_ac_node = self.root
results = defaultdict(list)
for leaf in leaves:
current_ast_node = leaf
while current_ast_node:
current_ast_node.was_checked = True
for child in current_ast_node.children:
# multiple ... | def run(self, leaves) | The main interface with the bottom matcher. The tree is
traversed from the bottom using the constructed
automaton. Nodes are only checked once as the tree is
retraversed. When the automaton fails, we give it one more
shot(in case the above tree matches as a whole with the
rejecte... | 3.091098 | 2.78075 | 1.111606 |
"Prints a graphviz diagram of the BM automaton(for debugging)"
print("digraph g{")
def print_node(node):
for subnode_key in node.transition_table.keys():
subnode = node.transition_table[subnode_key]
print("%d -> %d [label=%s] //%s" %
... | def print_ac(self) | Prints a graphviz diagram of the BM automaton(for debugging) | 5.299638 | 3.864891 | 1.371226 |
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 = __... | def _get_globals() | Return current Python interpreter globals namespace | 3.93937 | 3.680902 | 1.070219 |
try:
if hasattr(filename, 'decode'):
filename = filename.decode('utf-8')
except (UnicodeError, TypeError):
pass
global __umd__
if os.environ.get("PYDEV_UMD_ENABLED", "").lower() == "true":
if __umd__ is None:
namelist = os.environ.get("PYDEV_UMD_NAMEL... | def runfile(filename, args=None, wdir=None, namespace=None) | Run filename
args: command line arguments (string)
wdir: working directory | 2.30673 | 2.326133 | 0.991659 |
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 = ge... | 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 | 4.451091 | 4.062027 | 1.095781 |
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() | 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. | 2.757732 | 2.199167 | 1.253989 |
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) | 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 rea... | 2.769833 | 3.168462 | 0.874188 |
lines = copy.copy(lines)
while lines and lines[0].startswith("#"):
lines = lines[1:]
return "\n".join(lines) | def _strip_top_comments(lines) | Strips # comments that exist at the top of the given lines | 3.035533 | 2.731745 | 1.111207 |
for forced_separate in self.config['forced_separate']:
# Ensure all forced_separate patterns will match to end of string
path_glob = forced_separate
if not forced_separate.endswith('*'):
path_glob = '%s*' % forced_separate
if fnmatch(modu... | def place_module(self, module_name) | Tries to determine if a module is a python std import, third party import, or project code:
if it can't determine - it assumes it is project code | 3.827552 | 3.77435 | 1.014096 |
return comments and "{0} # {1}".format(self._strip_comments(original_string)[0],
"; ".join(comments)) or original_string | def _add_comments(self, comments, original_string="") | Returns a string with comments added | 7.735901 | 7.880767 | 0.981618 |
if comments is None:
comments = []
new_comments = False
comment_start = line.find("#")
if comment_start != -1:
comments.append(line[comment_start + 1:].strip())
new_comments = True
line = line[:comment_start]
return line,... | def _strip_comments(line, comments=None) | Removes comments from import line. | 2.314918 | 2.208221 | 1.048318 |
'''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 serve... | 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
... | 4.901727 | 1.245914 | 3.934242 |
'''
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.pyd... | def settrace_forked() | When creating a fork from a process in the debugger, we need to reset the whole debugger environment! | 5.845376 | 4.506875 | 1.296991 |
'''
:param abs_real_path_and_basename:
The result from get_abs_path_real_path_and_base_from_file or
get_abs_path_real_path_and_base_from_frame.
:return
_pydevd_bundle.pydevd_dont_trace_files.PYDEV_FILE:
If it's a file internal to the debugger ... | def get_file_type(self, abs_real_path_and_basename, _cache_file_type=_CACHE_FILE_TYPE) | :param abs_real_path_and_basename:
The result from get_abs_path_real_path_and_base_from_file or
get_abs_path_real_path_and_base_from_frame.
:return
_pydevd_bundle.pydevd_dont_trace_files.PYDEV_FILE:
If it's a file internal to the debugger which shouldn't be
... | 3.112996 | 1.448175 | 2.1496 |
'''
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... | 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 threa... | 4.918681 | 2.197959 | 2.23784 |
'''
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 breakp... | def on_breakpoints_changed(self, removed=False) | When breakpoints change, we have to re-evaluate all the assumptions we've made so far. | 9.220956 | 6.692783 | 1.377746 |
'''
Note: in general this method should not be used (apply_files_filter should be used
in most cases as it also handles the project scope check).
'''
try:
return self._in_project_scope_cache[filename]
except KeyError:
cache = self._in_project_scope... | def in_project_scope(self, filename) | Note: in general this method should not be used (apply_files_filter should be used
in most cases as it also handles the project scope check). | 5.587152 | 3.438545 | 1.624859 |
'''
:param str filename:
The filename to filter.
:return: True if it should be excluded, False if it should be included and None
if no rule matched the given file.
'''
try:
return self._exclude_by_filter_cache[filename]
except KeyError... | def _exclude_by_filter(self, frame, filename) | :param str filename:
The filename to filter.
:return: True if it should be excluded, False if it should be included and None
if no rule matched the given file. | 4.021332 | 3.164146 | 1.270906 |
'''
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 th... | 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 pro... | 3.645703 | 2.353951 | 1.548759 |
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) | returns internal command queue for a given thread.
if new queue is created, notify the RDB about it | 5.045266 | 4.593048 | 1.098457 |
queue = self.get_internal_queue(thread_id)
queue.put(int_cmd) | def post_internal_command(self, int_cmd, thread_id) | if thread_id is *, post to the '*' queue | 4.103518 | 3.36187 | 1.220606 |
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:
r... | def notify_thread_not_alive(self, thread_id, use_lock=True) | if thread is not alive, cancel trace_dispatch processing | 4.391347 | 4.260439 | 1.030727 |
'''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:
... | def process_internal_commands(self) | This function processes internal commands | 5.06001 | 5.025196 | 1.006928 |
'''
:param thread:
The thread which should be suspended.
:param stop_reason:
Reason why the thread was suspended.
:param suspend_other_threads:
Whether to force other threads to be suspended (i.e.: when hitting a breakpoint
with a suspend... | def set_suspend(self, thread, stop_reason, suspend_other_threads=False, is_pause=False) | :param thread:
The thread which should be suspended.
:param stop_reason:
Reason why the thread was suspended.
:param suspend_other_threads:
Whether to force other threads to be suspended (i.e.: when hitting a breakpoint
with a suspend all threads policy)... | 4.926497 | 3.710921 | 1.327567 |
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_exc... | def _send_breakpoint_condition_exception(self, thread, conditional_breakpoint_exception_tuple) | If conditional breakpoint raises an exception during evaluation
send exception details to java | 3.731052 | 3.591836 | 1.038759 |
thread_id = get_thread_id(thread)
int_cmd = InternalSendCurrExceptionTrace(thread_id, arg, curr_frame_id)
self.post_internal_command(int_cmd, thread_id) | def send_caught_exception_stack(self, thread, arg, curr_frame_id) | Sends details on the exception which was caught (and where we stopped) to the java side.
arg is: exception type, description, traceback object | 6.034667 | 7.012891 | 0.860511 |
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) | Sends that some thread was resumed and is no longer showing an exception trace. | 7.668965 | 6.626757 | 1.157273 |
cmd = self.cmd_factory.make_process_created_message()
self.writer.add_command(cmd) | def send_process_created_message(self) | Sends a message that a new process has been created. | 6.687088 | 5.594803 | 1.195232 |
# 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:
... | 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, event))
self.process_internal_commands()
thread_id = get_current_thread_id(thr... | 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
... | 3.578057 | 3.553244 | 1.006983 |
'''
This function should have frames tracked by unhandled exceptions (the `_exec` name is important).
'''
if not is_module:
pydev_imports.execfile(file, globals, locals) # execute the script
else:
# treat ':' as a separator between module and entry point ... | def _exec(self, is_module, entry_point_fn, module_name, file, globals, locals) | This function should have frames tracked by unhandled exceptions (the `_exec` name is important). | 4.484659 | 3.318631 | 1.351358 |
try:
si = GetNativeSystemInfo()
except Exception:
si = GetSystemInfo()
try:
return _arch_map[si.id.w.wProcessorArchitecture]
except KeyError:
return ARCH_UNKNOWN | 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"}) f... | 7.986921 | 7.849977 | 1.017445 |
# 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() | 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. | 5.116559 | 5.181659 | 0.987436 |
if not osvi:
osvi = GetVersionEx()
ntddi = 0
ntddi += (osvi.dwMajorVersion & 0xFF) << 24
ntddi += (osvi.dwMinorVersion & 0xFF) << 16
ntddi += (osvi.wServicePackMajor & 0xFF) << 8
ntddi += (osvi.wServicePackMinor & 0xFF)
return ntddi | def _get_ntddi(osvi) | Determines the current operating system.
This function allows you to quickly tell apart major OS differences.
For more detailed information call L{kernel32.GetVersionEx} instead.
@note:
Wine reports itself as Windows XP 32 bits
(even if the Linux host is 64 bits).
ReactOS may repor... | 2.330928 | 2.069716 | 1.126207 |
'''
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:
... | def log_context(trace_level, stream) | To be used to temporarily change the logging settings. | 2.561523 | 2.008519 | 1.275329 |
'''
Levels are:
0 most serious warnings/errors (always printed)
1 warnings/significant events
2 informational trace
3 verbose mode
'''
if level <= DebugInfoHolder.DEBUG_TRACE_LEVEL:
# yes, we can have errors printing if the console of the program has been finished (and we're sti... | def _pydevd_log(level, msg, *args) | Levels are:
0 most serious warnings/errors (always printed)
1 warnings/significant events
2 informational trace
3 verbose mode | 7.888815 | 4.424337 | 1.78305 |
'''
Note: don't call directly. Use PyDb.in_project_scope (no caching here).
'''
project_roots = self._get_project_roots()
if not filename.endswith('>'):
filename = self._normpath(filename)
found_in_project = []
for root in project_roots:
i... | def in_project_roots(self, filename) | Note: don't call directly. Use PyDb.in_project_scope (no caching here). | 4.129684 | 3.463382 | 1.192385 |
'''
:return: True if it should be excluded, False if it should be included and None
if no rule matched the given file.
'''
for exclude_filter in self._exclude_filters: # : :type exclude_filter: ExcludeFilter
if exclude_filter.is_path:
if glob_matc... | def exclude_by_filter(self, filename, module_name) | :return: True if it should be excluded, False if it should be included and None
if no rule matched the given file. | 3.880848 | 2.953616 | 1.313931 |
'''
:param list(ExcludeFilter) exclude_filters:
'''
self._exclude_filters = exclude_filters
self.require_module = False
for exclude_filter in exclude_filters:
if not exclude_filter.is_path:
self.require_module = True
break | def set_exclude_filters(self, exclude_filters) | :param list(ExcludeFilter) exclude_filters: | 3.872037 | 3.171125 | 1.221029 |
if isinstance(init, (str, unicode)):
if size is None:
size = len(init) + 1
buftype = c_char * size
buf = buftype()
buf.value = init
return buf
elif isinstance(init, (int, long)):
buftype = c_char * init
buf = buftype()
return buf
... | def create_string_buffer(init, size=None) | create_string_buffer(aString) -> character array
create_string_buffer(anInteger) -> character array
create_string_buffer(aString, anInteger) -> character array | 2.059632 | 2.221114 | 0.927297 |
try:
return _c_functype_cache[(restype, argtypes)]
except KeyError:
class CFunctionType(_CFuncPtr):
_argtypes_ = argtypes
_restype_ = restype
_flags_ = _FUNCFLAG_CDECL
_c_functype_cache[(restype, argtypes)] = CFunctionType
return CFunction... | def CFUNCTYPE(restype, *argtypes) | CFUNCTYPE(restype, *argtypes) -> function prototype.
restype: the result type
argtypes: a sequence specifying the argument types
The function prototype can be called in three ways to create a
callable object:
prototype(integer address) -> foreign function
prototype(callable) -> create and ret... | 2.274912 | 2.882975 | 0.789085 |
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'
... | 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. | 2.793469 | 2.764318 | 1.010546 |
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(... | 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. | 3.74701 | 3.454317 | 1.084733 |
msg = self.briefReport()
msg += '\n'
if self.bits == 32:
width = 16
else:
width = 8
if self.eventCode == win32.EXCEPTION_DEBUG_EVENT:
(exploitability, expcode, expdescription) = self.isExploitable()
msg += '\nSecurity ri... | def fullReport(self, bShowNotes = True) | @type bShowNotes: bool
@param bShowNotes: C{True} to show the user notes, C{False} otherwise.
@rtype: str
@return: Long description of the event. | 2.730659 | 2.761506 | 0.98883 |
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:
... | 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. | 2.863786 | 2.989365 | 0.957992 |
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) | 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. | 3.641973 | 4.435093 | 0.821172 |
if hasattr(value, 'memoryMap'):
crash = value
memoryMap = crash.memoryMap
try:
crash.memoryMap = None
if storeMemoryMap and memoryMap is not None:
# convert the generator to a list
crash.memoryMa... | def marshall_value(self, value, storeMemoryMap = False) | Marshalls a Crash object to be used in the database.
By default the C{memoryMap} member is B{NOT} stored here.
@warning: Setting the C{storeMemoryMap} argument to C{True} can lead to
a severe performance penalty!
@type value: L{Crash}
@param value: Object to convert.
... | 3.354664 | 3.347235 | 1.002219 |
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) | Unmarshalls a Crash object read from the database.
@type value: str
@param value: Object to convert.
@rtype: L{Crash}
@return: Converted object. | 4.066543 | 4.995083 | 0.814109 |
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) | 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. | 9.111738 | 9.352784 | 0.974227 |
skey = self.marshall_key(key)
data = self.__db[skey]
crash = self.unmarshall_value(data)
return crash | def get(self, key) | Retrieves a crash from the container.
@type key: L{Crash} unique key.
@param key: Key of the crash to get.
@rtype: L{Crash} object.
@return: Crash matching the given key.
@see: L{iterkeys}
@warning: A B{copy} of each object is returned,
so any changes... | 7.779871 | 8.983549 | 0.866013 |
found = self._dao.find(signature=key, limit=1, order=-1)
if not found:
raise KeyError(key)
return found[0] | def get(self, key) | Retrieves a crash from the container.
@type key: L{Crash} signature.
@param key: Heuristic signature of the crash to get.
@rtype: L{Crash} object.
@return: Crash matching the given signature. If more than one is found,
retrieve the newest one.
@see: L{iterkey... | 7.043251 | 8.088119 | 0.870815 |
self.__keys.add( crash.signature )
self.__count += 1 | 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. | 14.419532 | 25.874846 | 0.55728 |
'''
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... | def _schedule_callback(prev, next) | Called when a context is stopped or a new context is made runnable. | 3.92913 | 3.706296 | 1.060123 |
'''
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(callab... | def patch_stackless() | This function should be called to patch the stackless module so that new tasklets are properly tracked in the
debugger. | 2.395071 | 2.016962 | 1.187465 |
# 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 us... | 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 t... | 6.431426 | 5.970711 | 1.077163 |
if type(argv) in (str, compat.unicode):
raise TypeError("Debug.execv expects a list, not a string")
lpCmdLine = self.system.argv_to_cmdline(argv)
return self.execl(lpCmdLine, **kwargs) | def execv(self, argv, **kwargs) | Starts a new process for debugging.
This method uses a list of arguments. To use a command line string
instead, use L{execl}.
@see: L{attach}, L{detach}
@type argv: list( str... )
@param argv: List of command line arguments to pass to the debugee.
The first elemen... | 7.965952 | 10.200554 | 0.780933 |
# Register the process object with the snapshot.
if not self.system.has_process(dwProcessId):
aProcess = Process(dwProcessId)
self.system._add_process(aProcess)
else:
aProcess = self.system.get_process(dwProcessId)
# Test for debug privilege... | def add_existing_session(self, dwProcessId, bStarted = False) | Use this method only when for some reason the debugger's been attached
to the target outside of WinAppDbg (for example when integrating with
other tools).
You don't normally need to call this method. Most users should call
L{attach}, L{execv} or L{execl} instead.
@type dwProce... | 6.209615 | 6.065703 | 1.023726 |
# 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:
... | 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: ... | 2.654756 | 2.604389 | 1.019339 |
# 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,
... | 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 proce... | 3.038574 | 3.043725 | 0.998308 |
for pid in self.get_debugee_pids():
self.kill(pid, bIgnoreExceptions = bIgnoreExceptions) | 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 WindowsE... | 4.767862 | 5.587283 | 0.853342 |
# 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... | 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 bIgno... | 3.279203 | 3.230534 | 1.015065 |
for pid in self.get_debugee_pids():
self.detach(pid, bIgnoreExceptions = bIgnoreExceptions) | 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: Raise... | 5.092321 | 6.166854 | 0.825757 |
# 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) | 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 debug... | 7.587305 | 6.253953 | 1.213202 |
# 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 ... | 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. | 5.54849 | 5.532843 | 1.002828 |
# 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 ... | 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. | 6.352577 | 6.031078 | 1.053307 |
# 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(... | 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 ... | 2.588964 | 2.367764 | 1.093421 |
try:
event = self.wait()
except Exception:
self.stop()
raise
try:
self.dispatch()
finally:
self.cont() | 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 dispat... | 7.014825 | 4.198926 | 1.670624 |
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:
pri... | 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 enterin... | 3.502269 | 3.415474 | 1.025412 |
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):
... | 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. | 2.416749 | 2.405743 | 1.004575 |
dwProcessId = event.get_pid()
if dwProcessId not in self.__attachedDebugees:
if dwProcessId not in self.__startedDebugees:
self.__startedDebugees.add(dwProcessId)
retval = self.system._notify_create_process(event)
# Set a breakpoint on the program's... | def _notify_create_process(self, event) | Notify the creation of a new process.
@warning: This method is meant to be used internally by the debugger.
@type event: L{CreateProcessEvent}
@param event: Create process event.
@rtype: bool
@return: C{True} to call the user-defined handle, C{False} otherwise. | 7.671633 | 7.739474 | 0.991234 |
# 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... | 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. | 9.648598 | 9.652826 | 0.999562 |
bCallHandler1 = _BreakpointContainer._notify_exit_process(self, event)
bCallHandler2 = self.system._notify_exit_process(event)
try:
self.detach( event.get_pid() )
except WindowsError:
e = sys.exc_info()[1]
if e.winerror != win32.ERROR_INVALID... | def _notify_exit_process(self, event) | Notify the termination of a process.
@warning: This method is meant to be used internally by the debugger.
@type event: L{ExitProcessEvent}
@param event: Exit process event.
@rtype: bool
@return: C{True} to call the user-defined handle, C{False} otherwise. | 3.400597 | 3.483593 | 0.976175 |
bCallHandler1 = _BreakpointContainer._notify_exit_thread(self, event)
bCallHandler2 = event.get_process()._notify_exit_thread(event)
return bCallHandler1 and bCallHandler2 | def _notify_exit_thread(self, event) | Notify the termination of a thread.
@warning: This method is meant to be used internally by the debugger.
@type event: L{ExitThreadEvent}
@param event: Exit thread event.
@rtype: bool
@return: C{True} to call the user-defined handle, C{False} otherwise. | 6.297072 | 6.856499 | 0.918409 |
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) | 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. | 6.480187 | 6.917377 | 0.936798 |
if event.is_first_chance():
event.continueStatus = win32.DBG_EXCEPTION_HANDLED
return True | 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 c... | 25.333443 | 31.183548 | 0.812398 |
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()
... | 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}
@t... | 3.128945 | 3.196364 | 0.978908 |
if logger is None:
logger = logging.getLogger()
if gp is None:
head, tail = os.path.splitext(gt)
if tail == ".txt":
tail = ""
gp = head + tail + ".".join(map(str, sys.version_info)) + ".pickle"
if force or not _newer(gp, gt):
logger.info("Generating g... | def load_grammar(gt="Grammar.txt", gp=None,
save=True, force=False, logger=None) | Load the grammar (maybe from a pickle). | 3.061171 | 3.149779 | 0.971869 |
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) | Inquire whether file a was written since file b. | 1.937139 | 1.69715 | 1.141407 |
if not args:
args = sys.argv[1:]
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
format='%(message)s')
for gt in args:
load_grammar(gt, save=True, force=True)
return True | def main(*args) | Main program, when run as a script: produce grammar pickle files.
Calls load_grammar for each argument, a path to a grammar text file. | 4.344485 | 3.783026 | 1.148415 |
# 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, va... | def parse_tokens(self, tokens, debug=False) | Parse a series of tokens and return the syntax tree. | 3.846068 | 3.747682 | 1.026253 |
tokens = tokenize.generate_tokens(stream.readline)
return self.parse_tokens(tokens, debug) | def parse_stream_raw(self, stream, debug=False) | Parse a stream and return the syntax tree. | 4.261395 | 3.304369 | 1.289624 |
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) | Parse a file and return the syntax tree. | 2.716952 | 2.706639 | 1.00381 |
tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline)
return self.parse_tokens(tokens, debug) | def parse_string(self, text, debug=False) | Parse a string and return the syntax tree. | 2.841472 | 2.405281 | 1.181348 |
'''
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_... | def dump_threads(stream=None) | Helper to dump thread info. | 2.656539 | 2.561644 | 1.037045 |
# I'd love to reverse the order of the parameters
# but that might create some confusion. :(
hWnd = win32.FindWindow(className, windowName)
if hWnd:
return Window(hWnd) | def find_window(className = None, windowName = None) | Find the first top-level window in the current desktop to match the
given class name and/or window name. If neither are provided any
top-level window will match.
@see: L{get_window_at}
@type className: str
@param className: (Optional) Class name of the window to find.
... | 9.863647 | 12.351924 | 0.798552 |
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) | 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.
@r... | 3.523715 | 3.775884 | 0.933216 |
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) | 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
@retu... | 3.857978 | 3.654212 | 1.055762 |
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) | 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. | 4.742939 | 4.477026 | 1.059395 |
# 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(... | 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, ... | 2.515271 | 2.319585 | 1.084363 |
# If an explicit pathname was not given, search for the library.
if not pathname:
# Under WOW64 we'll treat AMD64 as I386.
arch = win32.arch
if arch == win32.ARCH_AMD64 and win32.bits == 32:
arch = win32.ARCH_I386
# Check if the... | def load_dbghelp(cls, pathname = None) | Load the specified version of the C{dbghelp.dll} library.
This library is shipped with the Debugging Tools for Windows, and it's
required to load debug symbols.
Normally you don't need to call this method, as WinAppDbg already tries
to load the latest version automatically - but it may... | 3.504616 | 3.411768 | 1.027214 |
try:
if symbol_store_path is None:
local_path = "C:\\SYMBOLS"
if not path.isdir(local_path):
local_path = "C:\\Windows\\Symbols"
if not path.isdir(local_path):
local_path = path.abspath(".")
... | def fix_symbol_store_path(symbol_store_path = None,
remote = True,
force = False) | Fix the symbol store path. Equivalent to the C{.symfix} command in
Microsoft WinDbg.
If the symbol store path environment variable hasn't been set, this
method will provide a default one.
@type symbol_store_path: str or None
@param symbol_store_path: (Optional) Symbol store pa... | 3.311931 | 3.367624 | 0.983462 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.