def event_processor(self, frame, event, event_arg, prompt="Trepan"): "command event processor: reading a commands do something with them." self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = { "output": "plain", "reload_on_change": self.settings("reload"), "strip_nl": False, } line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings("skip") is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.process_commands() return True
def event_processor(self, frame, event, event_arg, prompt='trepan3k'): 'command event processor: reading a commands do something with them.' self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = { 'output': 'plain', 'reload_on_change': self.settings('reload'), 'strip_nl': False } m = re.search('^<frozen (.*)>', filename) if m and m.group(1): filename = pyficache.unmap_file(m.group(1)) line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings('skip') is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.set_prompt(prompt) self.process_commands() if filename == '<string>': pyficache.remove_remap_file('<string>') return True
def event_processor(self, frame, event, event_arg, prompt='Trepan'): 'command event processor: reading a commands do something with them.' self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = { 'output': 'plain', 'reload_on_change': self.settings('reload'), 'strip_nl': False } line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings('skip') is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.process_commands() return True
def event_processor(self, frame, event, event_arg, prompt='trepan2'): 'command event processor: reading a commands do something with them.' self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno if sys.version_info[0] == 2 and sys.version_info[1] <= 4: line = None else: line = linecache.getline(filename, lineno, frame.f_globals) pass if not line: opts = {'output': 'plain', 'reload_on_change': self.settings('reload'), 'strip_nl': False} line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings('skip') is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.set_prompt(prompt) self.process_commands() if filename == '<string>': pyficache.remove_remap_file('<string>') return True
def event_processor(self, frame, event, event_arg, prompt='trepan2'): 'command event processor: reading a commands do something with them.' self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno if sys.version_info[0] == 2 and sys.version_info[1] <= 4: line = None else: line = linecache.getline(filename, lineno, frame.f_globals) pass if not line: opts = { 'output': 'plain', 'reload_on_change': self.settings('reload'), 'strip_nl': False } line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings('skip') is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.set_prompt(prompt) self.process_commands() if filename == '<string>': pyficache.remove_remap_file('<string>') return True
def event_processor(self, frame, event, event_arg, prompt="trepan2"): "command event processor: reading a commands do something with them." self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno if sys.version_info[0] == 2 and sys.version_info[1] <= 4: line = None else: line = linecache.getline(filename, lineno, frame.f_globals) pass if not line: opts = { "output": "plain", "reload_on_change": self.settings("reload"), "strip_nl": False, } line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings("skip") is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.set_prompt(prompt) self.process_commands() if filename == "<string>": pyficache.remove_remap_file("<string>") return True
def event_processor(self, frame, event, event_arg, prompt='Trepan'): 'command event processor: reading a commands do something with them.' self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = {'output': 'plain', 'reload_on_change': self.settings('reload'), 'strip_nl': False} line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings('skip') is not None: if Mbytecode.is_def_stmt(line, frame): return True if Mbytecode.is_class_def(line, frame): return True pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.process_commands() return True
def event_processor(self, frame, event, event_arg, prompt="trepan3k"): """ command event processor: reading a commands do something with them. See https://docs.python.org/3/library/sys.html#sys.settrace for how this protocol works and what the events means. Of particular note those is what we return: The local trace function should return a reference to itself (or to another function for further tracing in that scope), or None to turn off tracing in that scope. If there is any error occurred in the trace function, it will be unset, just like settrace(None) is called. """ self.frame = frame self.event = event self.event_arg = event_arg filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = { "output": "plain", "reload_on_change": self.settings("reload"), "strip_nl": False, } m = re.search("^<frozen (.*)>", filename) if m and m.group(1): filename = pyficache.unmap_file(m.group(1)) line = pyficache.getline(filename, lineno, opts) self.current_source_text = line if self.settings("skip") is not None: if is_def_stmt(line, frame): return self.event_processor if is_class_def(line, frame): return self.event_processor pass self.thread_name = Mthread.current_thread_name() self.frame_thread_name = self.thread_name self.set_prompt(prompt) self.process_commands() if filename == "<string>": pyficache.remove_remap_file("<string>") return self.event_processor
def event_hook( self, event: str, offset: int, byteName: str, byteCode: int, line_number: int, intArg: Optional[int], event_arg: Any, vm: Any, prompt="trepan-xpy", ): "command event processor: reading a commands do something with them." def frame_setup(frame): filename = frame.f_code.co_filename lineno = frame.f_lineno line = linecache.getline(filename, lineno, frame.f_globals) if not line: opts = { "output": "plain", "reload_on_change": self.settings("reload"), "strip_nl": False, } m = re.search("^<frozen (.*)>", filename) if m and m.group(1): filename = pyficache.unmap_file(m.group(1)) line = pyficache.getline(filename, lineno, opts) self.current_source_text = line return line, filename self.vm = vm self.frame = vm.frame self.event = event self.event_arg = event_arg # In order to follow Python's sys.settrace()'s convention: # returning "None" turns off tracing for the scope. # However we do not need to return a reference to ourself, # a callable (this may be allowed in the future though). # Instead for now a string status is returned # * "skip" for skip next instruction, and # * "return" for immediate return # * "finish" for "step out" self.return_status = True if event == "fatal": self.core.execution_status = "Terminated" # One last hurrah! tb = vm.last_traceback if tb: frame_setup(tb.tb_frame) self.vm.frames = [] while tb: self.vm.frames.insert(0, tb.tb_frame) tb = tb.tb_next self.curframe = self.frame = self.vm.frames[0] self.setup() self.curindex = len(vm.frames) - 1 print_location(self) self.set_prompt("trepan-xpy:pm") self.process_commands() return None if self.vm.frame: self.core.execution_status = "Running" else: self.core.execution_status = "Terminated" return line, filename = frame_setup(self.frame) if self.settings("skip"): # Note that in contrast to skipping intructions # when return_status is set to "skip", here # we are execution the instruction but just skipping # any handling this instruction the debugger. if Mbytecode.is_def_stmt(line, self.frame): return self if Mbytecode.is_class_def(line, self.frame): return pass self.thread_name = current_thread_name() self.frame_thread_name = self.thread_name self.setup() print_location(self) if offset >= 0 and event not in ('call', 'return'): self.msg("%s" % format_instruction_with_highlight( vm.frame, vm.opc, byteName, intArg, event_arg, offset, line_number, extra_debug=False, settings=self.debugger.settings, show_line= False, # We show the line number in our location reporting vm=self.vm, repr=self._repr.repr)) self.set_prompt(prompt) self.process_commands() if filename == "<string>": pyficache.remove_remap_file("<string>") return self.return_status