diff options
| -rw-r--r-- | python/architecture.py | 123 | ||||
| -rw-r--r-- | python/binaryview.py | 154 | ||||
| -rw-r--r-- | python/callingconvention.py | 40 | ||||
| -rw-r--r-- | python/datarender.py | 8 | ||||
| -rw-r--r-- | python/debuginfo.py | 6 | ||||
| -rw-r--r-- | python/demangle.py | 8 | ||||
| -rw-r--r-- | python/downloadprovider.py | 22 | ||||
| -rw-r--r-- | python/fileaccessor.py | 8 | ||||
| -rw-r--r-- | python/filemetadata.py | 8 | ||||
| -rw-r--r-- | python/flowgraph.py | 18 | ||||
| -rw-r--r-- | python/functionrecognizer.py | 6 | ||||
| -rw-r--r-- | python/interaction.py | 39 | ||||
| -rw-r--r-- | python/languagerepresentation.py | 34 | ||||
| -rw-r--r-- | python/log.py | 18 | ||||
| -rw-r--r-- | python/platform.py | 12 | ||||
| -rw-r--r-- | python/plugin.py | 48 | ||||
| -rw-r--r-- | python/renderlayer.py | 8 | ||||
| -rw-r--r-- | python/scriptingprovider.py | 40 | ||||
| -rw-r--r-- | python/secretsprovider.py | 10 | ||||
| -rw-r--r-- | python/transform.py | 10 | ||||
| -rw-r--r-- | python/typearchive.py | 8 | ||||
| -rw-r--r-- | python/typeparser.py | 16 | ||||
| -rw-r--r-- | python/typeprinter.py | 24 | ||||
| -rw-r--r-- | python/update.py | 4 | ||||
| -rw-r--r-- | python/websocketprovider.py | 8 | ||||
| -rw-r--r-- | python/workflow.py | 4 |
26 files changed, 350 insertions, 334 deletions
diff --git a/python/architecture.py b/python/architecture.py index a3307146..0a2890d3 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -30,7 +30,7 @@ from .enums import ( Endianness, ImplicitRegisterExtend, BranchType, LowLevelILFlagCondition, FlagRole, LowLevelILOperation, InstructionTextTokenType, InstructionTextTokenContext, IntrinsicClass ) -from .log import log_error +from .log import log_error_for_exception, log_debug_for_exception from . import lowlevelil from . import types from . import databuffer @@ -930,42 +930,42 @@ class Architecture(metaclass=_ArchitectureMetaClass): try: return self.endianness except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_endianness") return Endianness.LittleEndian def _get_address_size(self, ctxt): try: return self.address_size except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_address_size") return 8 def _get_default_integer_size(self, ctxt): try: return self.default_int_size except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_default_integer_size") return 4 def _get_instruction_alignment(self, ctxt): try: return self.instr_alignment except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_instruction_alignment") return 1 def _get_max_instruction_length(self, ctxt): try: return self.max_instr_length except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_max_instruction_length") return 16 def _get_opcode_display_length(self, ctxt): try: return self.opcode_display_length except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_opcode_display_length") return 8 def _get_associated_arch_by_address(self, ctxt, addr): @@ -974,7 +974,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): addr[0] = new_addr return ctypes.cast(result.handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_associated_arch_by_address") return ctypes.cast(self.handle, ctypes.c_void_p).value def _get_instruction_info(self, ctxt, data, addr, max_len, result): @@ -1001,7 +1001,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): result[0].branchArch[i] = arch.handle return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_instruction_info") return False def _get_instruction_text(self, ctxt, data, addr, length, result, count): @@ -1020,7 +1020,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_token_lists[ptr.value] = (ptr.value, token_buf) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_instruction_text") return False def _free_instruction_text(self, tokens, count): @@ -1030,7 +1030,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): raise ValueError("freeing token list that wasn't allocated") del self._pending_token_lists[buf.value] except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._free_instruction_text") def _get_instruction_low_level_il(self, ctxt, data, addr, length, il): try: @@ -1044,7 +1044,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): length[0] = result return True except OSError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_instruction_low_level_il") return False def _analyze_basic_blocks(self, ctx, func, ptr_bn_bb_context): @@ -1053,7 +1053,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): context = BasicBlockAnalysisContext.from_core_struct(bn_bb_context) self.analyze_basic_blocks(function.Function(handle=core.BNNewFunctionReference(func)), context) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._analyze_basic_blocks") def _get_register_name(self, ctxt, reg): try: @@ -1061,7 +1061,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._regs_by_index[reg]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_register_name") return core.BNAllocString("") def _get_flag_name(self, ctxt, flag): @@ -1070,7 +1070,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._flags_by_index[flag]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flag_name") return core.BNAllocString("") def _get_flag_write_type_name(self, ctxt, write_type: FlagWriteTypeIndex): @@ -1079,7 +1079,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._flag_write_types_by_index[write_type]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flag_write_type_name") return core.BNAllocString("") def _get_semantic_flag_class_name(self, ctxt, sem_class): @@ -1088,7 +1088,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._semantic_flag_classes_by_index[sem_class]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_semantic_flag_class_name") return core.BNAllocString("") def _get_semantic_flag_group_name(self, ctxt, sem_group): @@ -1097,7 +1097,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._semantic_flag_groups_by_index[sem_group]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_semantic_flag_group_name") return core.BNAllocString("") def _get_full_width_registers(self, ctxt, count): @@ -1111,7 +1111,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_full_width_registers") count[0] = 0 return None @@ -1126,7 +1126,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_registers") count[0] = 0 return None @@ -1141,7 +1141,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, flag_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_flags") count[0] = 0 return None @@ -1156,7 +1156,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, type_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_flag_write_types") count[0] = 0 return None @@ -1171,7 +1171,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, class_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_semantic_flag_classes") count[0] = 0 return None @@ -1186,7 +1186,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, group_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_semantic_flag_groups") count[0] = 0 return None @@ -1216,7 +1216,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, flag_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flags_required_for_flag_condition") count[0] = 0 return None @@ -1234,7 +1234,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, flag_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flags_required_for_semantic_flag_group") count[0] = 0 return None @@ -1255,7 +1255,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_condition_lists[result.value] = (result, cond_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flag_conditions_for_semantic_flag_group") count[0] = 0 return None @@ -1266,7 +1266,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): raise ValueError("freeing condition list that wasn't allocated") del self._pending_condition_lists[buf.value] except (ValueError, KeyError): - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._free_flag_conditions_for_semantic_flag_group") def _get_flags_written_by_flag_write_type(self, ctxt, write_type, count): try: @@ -1282,7 +1282,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, flag_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flags_written_by_flag_write_type") count[0] = 0 return None @@ -1293,7 +1293,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): else: return 0 except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_semantic_class_for_flag_write_type") return 0 def _get_flag_write_low_level_il(self, ctxt, op, size, write_type, flag, operands, operand_count, il): @@ -1315,7 +1315,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)) ) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flag_write_low_level_il") return False def _get_flag_condition_low_level_il(self, ctxt, cond, sem_class, il): @@ -1328,7 +1328,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): cond, sem_class_name, lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)) ) except OSError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_flag_condition_low_level_il") return 0 def _get_semantic_flag_group_low_level_il(self, ctxt, sem_group, il): @@ -1341,7 +1341,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): sem_group_name, lowlevelil.LowLevelILFunction(self, core.BNNewLowLevelILFunctionReference(il)) ) except OSError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_semantic_flag_group_low_level_il") return 0 def _free_register_list(self, ctxt, regs, count): @@ -1351,7 +1351,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): raise ValueError("freeing register list that wasn't allocated") del self._pending_reg_lists[buf.value] except (ValueError, KeyError): - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._free_register_list") def _get_register_info(self, ctxt, reg, result): try: @@ -1370,7 +1370,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): else: result[0].extend = info.extend except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_register_info") result[0].fullWidthRegister = 0 result[0].offset = 0 result[0].size = 0 @@ -1382,7 +1382,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): try: return self._all_regs[self.stack_pointer] except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_stack_pointer_register") return 0 def _get_link_register(self, ctxt): @@ -1391,7 +1391,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return 0xffffffff return self._all_regs[self.link_reg] except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_link_register") return 0 def _get_global_registers(self, ctxt, count): @@ -1404,7 +1404,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_global_registers") count[0] = 0 return None @@ -1418,7 +1418,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_system_registers") count[0] = 0 return None @@ -1428,7 +1428,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._reg_stacks_by_index[reg_stack]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_register_stack_name") return core.BNAllocString("") def _get_all_register_stacks(self, ctxt, count): @@ -1442,7 +1442,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_register_stacks") count[0] = 0 return None @@ -1466,7 +1466,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): result[0].topRelativeCount = 0 result[0].stackTopReg = self._all_regs[info.stack_top_reg] except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_register_stack_info") result[0].firstStorageReg = 0 result[0].firstTopRelativeReg = 0 result[0].storageCount = 0 @@ -1484,7 +1484,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): return core.BNAllocString(self._intrinsics_by_index[intrinsic][0]) return core.BNAllocString("") except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_intrinsic_name") return core.BNAllocString("") def _get_all_intrinsics(self, ctxt, count): @@ -1498,7 +1498,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except KeyError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_all_intrinsics") count[0] = 0 return None @@ -1518,7 +1518,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): count[0] = 0 return None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_intrinsic_inputs") count[0] = 0 return None @@ -1533,7 +1533,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): core.BNFreeType(name_and_types[i].type) del self._pending_name_and_type_lists[buf.value] except (ValueError, KeyError): - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._free_name_and_type_list") def _get_intrinsic_outputs(self, ctxt, intrinsic, count): try: @@ -1550,7 +1550,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): count[0] = 0 return None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._get_intrinsic_outputs") count[0] = 0 return None @@ -1565,7 +1565,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): core.BNFreeType(_types[i].type) del self._pending_type_lists[buf.value] except (ValueError, KeyError): - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._free_type_list") def _assemble(self, ctxt, code, addr, result, errors): """ @@ -1582,11 +1582,11 @@ class Architecture(metaclass=_ArchitectureMetaClass): core.BNSetDataBufferContents(result, buf, len(data)) return True except ValueError as e: # Overridden `assemble` functions should raise a ValueError if the input was invalid (with a reasonable error message) - log_error(traceback.format_exc()) + log_debug_for_exception("Assemble failed") errors[0] = core.BNAllocString(str(e)) return False except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._assemble") errors[0] = core.BNAllocString("Unhandled exception during assembly.\n") return False @@ -1596,7 +1596,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(buf, data, length) return self.is_never_branch_patch_available(buf.raw, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._is_never_branch_patch_available") return False def _is_always_branch_patch_available(self, ctxt, data, addr, length): @@ -1605,7 +1605,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(buf, data, length) return self.is_always_branch_patch_available(buf.raw, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._is_always_branch_patch_available") return False def _is_invert_branch_patch_available(self, ctxt, data, addr, length): @@ -1614,7 +1614,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(buf, data, length) return self.is_invert_branch_patch_available(buf.raw, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._is_invert_branch_patch_available") return False def _is_skip_and_return_zero_patch_available(self, ctxt, data, addr, length): @@ -1623,7 +1623,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(buf, data, length) return self.is_skip_and_return_zero_patch_available(buf.raw, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._is_skip_and_return_zero_patch_available") return False def _is_skip_and_return_value_patch_available(self, ctxt, data, addr, length): @@ -1632,7 +1632,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(buf, data, length) return self.is_skip_and_return_value_patch_available(buf.raw, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._is_skip_and_return_value_patch_available") return False def _convert_to_nop(self, ctxt, data, addr, length): @@ -1647,7 +1647,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(data, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._convert_to_nop") return False def _always_branch(self, ctxt, data, addr, length): @@ -1662,7 +1662,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(data, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._always_branch") return False def _invert_branch(self, ctxt, data, addr, length): @@ -1677,7 +1677,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(data, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._invert_branch") return False def _skip_and_return_value(self, ctxt, data, addr, length, value): @@ -1692,7 +1692,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): ctypes.memmove(data, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture._skip_and_return_value") return False def get_associated_arch_by_address(self, addr: int) -> Tuple['Architecture', int]: @@ -1783,7 +1783,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): try: core.BNArchitectureDefaultAnalyzeBasicBlocks(func.handle, context._handle) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Architecture.analyze_basic_blocks") def get_low_level_il_from_bytes(self, data: bytes, addr: int) -> 'lowlevelil.LowLevelILInstruction': """ @@ -1847,8 +1847,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): assert index is not None return index except KeyError: - log_error(f"Failed to map string {reg} to register index: ") - log_error(traceback.format_exc()) + log_error_for_exception(f"Failed to map string {reg} to register index") elif isinstance(reg, lowlevelil.ILRegister): return reg.index elif isinstance(reg, int): diff --git a/python/binaryview.py b/python/binaryview.py index c50fdf06..ff106f28 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -50,7 +50,7 @@ from .enums import ( from .exceptions import RelocationWriteException, ExternalLinkException from . import associateddatastore # required for _BinaryViewAssociatedDataStore -from .log import log_warn, log_error, Logger +from .log import log_warn, log_error_for_exception, Logger from . import typelibrary from . import fileaccessor from . import databuffer @@ -556,7 +556,7 @@ class AnalysisCompletionEvent: else: self.callback() # type: ignore except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in AnalysisCompletionEvent._notify") def _empty_callback(self): pass @@ -619,7 +619,7 @@ class BinaryViewEvent: view_obj = BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) callback(view_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryViewEvent._notify") @dataclass(frozen=True) @@ -831,43 +831,43 @@ class BinaryDataNotificationCallbacks: try: return self._notify.notification_barrier(self._view) except OSError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._notification_barrier") def _data_written(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None: try: self._notify.data_written(self._view, offset, length) except OSError: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_written") def _data_inserted(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None: try: self._notify.data_inserted(self._view, offset, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_inserted") def _data_removed(self, ctxt, view: core.BNBinaryView, offset: int, length: int) -> None: try: self._notify.data_removed(self._view, offset, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_removed") def _function_added(self, ctxt, view: core.BNBinaryView, func: core.BNFunctionHandle) -> None: try: self._notify.function_added(self._view, _function.Function(self._view, core.BNNewFunctionReference(func))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._function_added") def _function_removed(self, ctxt, view: core.BNBinaryView, func: core.BNFunctionHandle) -> None: try: self._notify.function_removed(self._view, _function.Function(self._view, core.BNNewFunctionReference(func))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._function_removed") def _function_updated(self, ctxt, view: core.BNBinaryView, func: core.BNFunctionHandle) -> None: try: self._notify.function_updated(self._view, _function.Function(self._view, core.BNNewFunctionReference(func))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._function_updated") def _function_update_requested(self, ctxt, view: core.BNBinaryView, func: core.BNFunctionHandle) -> None: try: @@ -875,31 +875,31 @@ class BinaryDataNotificationCallbacks: self._view, _function.Function(self._view, core.BNNewFunctionReference(func)) ) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._function_update_requested") def _data_var_added(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariableHandle) -> None: try: self._notify.data_var_added(self._view, DataVariable.from_core_struct(var[0], self._view)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_var_added") def _data_var_removed(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariableHandle) -> None: try: self._notify.data_var_removed(self._view, DataVariable.from_core_struct(var[0], self._view)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_var_removed") def _data_var_updated(self, ctxt, view: core.BNBinaryView, var: core.BNDataVariableHandle) -> None: try: self._notify.data_var_updated(self._view, DataVariable.from_core_struct(var[0], self._view)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_var_updated") def _data_metadata_updated(self, ctxt, view: core.BNBinaryView, offset: int) -> None: try: self._notify.data_metadata_updated(self._view, offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._data_metadata_updated") def _tag_type_updated(self, ctxt, view: core.BNBinaryView, tag_type: core.BNTagTypeHandle) -> None: try: @@ -907,7 +907,7 @@ class BinaryDataNotificationCallbacks: assert core_tag_type is not None, "core.BNNewTagTypeReference returned None" self._notify.tag_type_updated(self._view, TagType(core_tag_type)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._tag_type_updated") def _tag_added(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReferenceHandle) -> None: try: @@ -928,7 +928,7 @@ class BinaryDataNotificationCallbacks: addr = tag_ref[0].addr self._notify.tag_added(self._view, tag, ref_type, auto_defined, arch, func, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._tag_added") def _tag_updated(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReferenceHandle) -> None: try: @@ -949,7 +949,7 @@ class BinaryDataNotificationCallbacks: addr = tag_ref[0].addr self._notify.tag_updated(self._view, tag, ref_type, auto_defined, arch, func, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._tag_updated") def _tag_removed(self, ctxt, view: core.BNBinaryView, tag_ref: core.BNTagReferenceHandle) -> None: try: @@ -970,7 +970,7 @@ class BinaryDataNotificationCallbacks: addr = tag_ref[0].addr self._notify.tag_removed(self._view, tag, ref_type, auto_defined, arch, func, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._tag_removed") def _symbol_added(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None: try: @@ -978,7 +978,7 @@ class BinaryDataNotificationCallbacks: assert _handle is not None, "core.BNNewSymbolReference returned None" self._notify.symbol_added(self._view, _types.CoreSymbol(_handle)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._symbol_added") def _symbol_updated(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None: try: @@ -986,7 +986,7 @@ class BinaryDataNotificationCallbacks: assert _handle is not None, "core.BNNewSymbolReference returned None" self._notify.symbol_updated(self._view, _types.CoreSymbol(_handle)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._symbol_updated") def _symbol_removed(self, ctxt, view: core.BNBinaryView, sym: core.BNSymbol) -> None: try: @@ -994,19 +994,19 @@ class BinaryDataNotificationCallbacks: assert _handle is not None, "core.BNNewSymbolReference returned None" self._notify.symbol_removed(self._view, _types.CoreSymbol(_handle)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._symbol_removed") def _string_found(self, ctxt, view: core.BNBinaryView, string_type: int, offset: int, length: int) -> None: try: self._notify.string_found(self._view, StringType(string_type), offset, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._string_found") def _string_removed(self, ctxt, view: core.BNBinaryView, string_type: int, offset: int, length: int) -> None: try: self._notify.string_removed(self._view, StringType(string_type), offset, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._string_removed") def _type_defined(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None: try: @@ -1016,7 +1016,7 @@ class BinaryDataNotificationCallbacks: _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform) ) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_defined") def _type_undefined(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None: try: @@ -1026,7 +1026,7 @@ class BinaryDataNotificationCallbacks: _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform) ) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_undefined") def _type_ref_changed(self, ctxt, view: core.BNBinaryView, name: str, type_obj: '_types.Type') -> None: try: @@ -1036,14 +1036,14 @@ class BinaryDataNotificationCallbacks: _types.Type.create(core.BNNewTypeReference(type_obj), platform=self._view.platform) ) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_ref_changed") def _type_field_ref_changed(self, ctxt, view: core.BNBinaryView, name: str, offset: int) -> None: try: qualified_name = _types.QualifiedName._from_core_struct(name[0]) self._notify.type_field_ref_changed(self._view, qualified_name, offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_field_ref_changed") def _segment_added(self, ctxt, view: core.BNBinaryView, segment_obj: core.BNSegment) -> None: try: @@ -1052,7 +1052,7 @@ class BinaryDataNotificationCallbacks: result = Segment(segment_handle) self._notify.segment_added(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._segment_added") def _segment_updated(self, ctxt, view: core.BNBinaryView, segment_obj: core.BNSegment) -> None: try: @@ -1061,7 +1061,7 @@ class BinaryDataNotificationCallbacks: result = Segment(segment_handle) self._notify.segment_updated(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._segment_updated") def _segment_removed(self, ctxt, view: core.BNBinaryView, segment_obj: core.BNSegment) -> None: try: @@ -1070,7 +1070,7 @@ class BinaryDataNotificationCallbacks: result = Segment(segment_handle) self._notify.segment_removed(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._segment_removed") def _section_added(self, ctxt, view: core.BNBinaryView, section_obj: core.BNSection) -> None: try: @@ -1079,7 +1079,7 @@ class BinaryDataNotificationCallbacks: result = Section(section_handle) self._notify.section_added(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._section_added") def _section_updated(self, ctxt, view: core.BNBinaryView, section_obj: core.BNSection) -> None: try: @@ -1088,7 +1088,7 @@ class BinaryDataNotificationCallbacks: result = Section(section_handle) self._notify.section_updated(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._section_updated") def _section_removed(self, ctxt, view: core.BNBinaryView, section_obj: core.BNSection) -> None: try: @@ -1097,7 +1097,7 @@ class BinaryDataNotificationCallbacks: result = Section(section_handle) self._notify.section_removed(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._section_removed") def _component_added(self, ctxt, view: core.BNBinaryView, _component: core.BNComponent): try: @@ -1106,7 +1106,7 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_added(self._view, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_added") def _component_removed(self, ctxt, view: core.BNBinaryView, formerParent: core.BNComponent, _component: core.BNComponent): try: @@ -1118,7 +1118,7 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_removed(self._view, formerParentResult, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_removed") def _component_name_updated(self, ctxt, view: core.BNBinaryView, previous_name: str, _component: core.BNComponent): try: @@ -1127,7 +1127,7 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_name_updated(self._view, previous_name, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_name_updated") def _component_moved(self, ctxt, view: core.BNBinaryView, formerParent: core.BNComponent, newParent: core.BNComponent, _component: core.BNComponent): @@ -1143,7 +1143,7 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_moved(self._view, formerParentResult, newParentResult, result) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_moved") def _component_function_added(self, ctxt, view: core.BNBinaryView, _component: core.BNComponent, func: '_function.Function'): @@ -1156,7 +1156,7 @@ class BinaryDataNotificationCallbacks: function = _function.Function(self._view, function_handle) self._notify.component_function_added(self._view, result, function) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_function_added") def _component_function_removed(self, ctxt, view: core.BNBinaryView, _component: core.BNComponent, func: '_function.Function'): @@ -1169,7 +1169,7 @@ class BinaryDataNotificationCallbacks: function = _function.Function(self._view, function_handle) self._notify.component_function_removed(self._view, result, function) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_function_removed") def _component_data_variable_added(self, ctxt, view: core.BNBinaryView, _component: core.BNComponent, var: core.BNDataVariable): @@ -1179,7 +1179,7 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_data_var_added(self._view, result, DataVariable.from_core_struct(var, self._view)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_data_variable_added") def _component_data_variable_removed(self, ctxt, view: core.BNBinaryView, _component: core.BNComponent, var: core.BNDataVariable): @@ -1189,54 +1189,54 @@ class BinaryDataNotificationCallbacks: result = component.Component(component_handle) self._notify.component_data_var_removed(self._view, result, DataVariable.from_core_struct(var, self._view)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._component_data_variable_removed") def _type_archive_attached(self, ctxt, view: core.BNBinaryView, id: ctypes.c_char_p, path: ctypes.c_char_p): try: self._notify.type_archive_attached(self._view, core.pyNativeStr(id), core.pyNativeStr(path)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_archive_attached") def _type_archive_detached(self, ctxt, view: core.BNBinaryView, id: ctypes.c_char_p, path: ctypes.c_char_p): try: self._notify.type_archive_detached(self._view, core.pyNativeStr(id), core.pyNativeStr(path)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_archive_detached") def _type_archive_connected(self, ctxt, view: core.BNBinaryView, archive: core.BNTypeArchive): try: py_archive = typearchive.TypeArchive(handle=core.BNNewTypeArchiveReference(archive)) self._notify.type_archive_connected(self._view, py_archive) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_archive_connected") def _type_archive_disconnected(self, ctxt, view: core.BNBinaryView, archive: core.BNTypeArchive): try: py_archive = typearchive.TypeArchive(handle=core.BNNewTypeArchiveReference(archive)) self._notify.type_archive_disconnected(self._view, py_archive) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._type_archive_disconnected") def _undo_entry_added(self, ctxt, view: core.BNBinaryView, entry: core.BNUndoEntry): try: py_entry = undo.UndoEntry(handle=core.BNNewUndoEntryReference(entry)) self._notify.undo_entry_added(self._view, py_entry) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._undo_entry_added") def _undo_entry_taken(self, ctxt, view: core.BNBinaryView, entry: core.BNUndoEntry): try: py_entry = undo.UndoEntry(handle=core.BNNewUndoEntryReference(entry)) self._notify.undo_entry_taken(self._view, py_entry) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._undo_entry_taken") def _redo_entry_taken(self, ctxt, view: core.BNBinaryView, entry: core.BNUndoEntry): try: py_entry = undo.UndoEntry(handle=core.BNNewUndoEntryReference(entry)) self._notify.redo_entry_taken(self._view, py_entry) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryDataNotificationCallbacks._redo_entry_taken") @property def view(self) -> 'BinaryView': @@ -1374,7 +1374,7 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass): assert handle is not None, "core.BNNewPlatformReference returned None" return ctypes.cast(handle, ctypes.c_void_p).value except: - binaryninja.log_error(traceback.format_exc()) + binaryninja.log_error_for_exception("Unhandled Python exception in BinaryViewType.register_platform_recognizer") return None callback_obj = ctypes.CFUNCTYPE( @@ -2812,7 +2812,7 @@ class BinaryView: assert view_handle is not None, "core.BNNewViewReference returned None" return ctypes.cast(view_handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._create") return None @classmethod @@ -2827,7 +2827,7 @@ class BinaryView: assert view_handle is not None, "core.BNNewViewReference returned None" return ctypes.cast(view_handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._parse") return None @classmethod @@ -2836,7 +2836,7 @@ class BinaryView: # I'm not sure whats going on here even so I've suppressed the linter warning return cls.is_valid_for_data(BinaryView(handle=core.BNNewViewReference(data))) # type: ignore except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_valid_for_data") return False @classmethod @@ -2849,7 +2849,7 @@ class BinaryView: try: return cls.is_deprecated() # type: ignore except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_deprecated") return False @classmethod @@ -2860,7 +2860,7 @@ class BinaryView: try: return cls.is_force_loadable() # type: ignore except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_force_loadable") return False @classmethod @@ -2877,7 +2877,7 @@ class BinaryView: else: return None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_load_settings_for_data") return None @staticmethod @@ -3773,20 +3773,20 @@ class BinaryView: try: return self.init() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._init") return False def _external_ref_taken(self, ctxt): try: self.__class__._registered_instances.append(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._external_ref_taken") def _external_ref_released(self, ctxt): try: self.__class__._registered_instances.remove(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._external_ref_released") def _read(self, ctxt, dest, offset, length): try: @@ -3798,7 +3798,7 @@ class BinaryView: ctypes.memmove(dest, data, len(data)) return len(data) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._read") return 0 def _write(self, ctxt, offset, src, length): @@ -3807,7 +3807,7 @@ class BinaryView: ctypes.memmove(data, src, length) return self.perform_write(offset, data.raw) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._write") return 0 def _insert(self, ctxt, offset, src, length): @@ -3816,112 +3816,112 @@ class BinaryView: ctypes.memmove(data, src, length) return self.perform_insert(offset, data.raw) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._insert") return 0 def _remove(self, ctxt, offset, length): try: return self.perform_remove(offset, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._remove") return 0 def _get_modification(self, ctxt, offset): try: return self.perform_get_modification(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_modification") return ModificationStatus.Original def _is_valid_offset(self, ctxt, offset): try: return self.perform_is_valid_offset(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_valid_offset") return False def _is_offset_readable(self, ctxt, offset): try: return self.perform_is_offset_readable(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_offset_readable") return False def _is_offset_writable(self, ctxt, offset): try: return self.perform_is_offset_writable(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_offset_writable") return False def _is_offset_executable(self, ctxt, offset): try: return self.perform_is_offset_executable(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_offset_executable") return False def _get_next_valid_offset(self, ctxt, offset): try: return self.perform_get_next_valid_offset(offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_next_valid_offset") return offset def _get_start(self, ctxt): try: return self.perform_get_start() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_start") return 0 def _get_length(self, ctxt): try: return self.perform_get_length() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_length") return 0 def _get_entry_point(self, ctxt): try: return self.perform_get_entry_point() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_entry_point") return 0 def _is_executable(self, ctxt): try: return self.perform_is_executable() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_executable") return False def _get_default_endianness(self, ctxt): try: return self.perform_get_default_endianness() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_default_endianness") return Endianness.LittleEndian def _is_relocatable(self, ctxt): try: return self.perform_is_relocatable() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._is_relocatable") return False def _get_address_size(self, ctxt): try: return self.perform_get_address_size() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._get_address_size") return 8 def _save(self, ctxt, file_accessor): try: return self.perform_save(fileaccessor.CoreFileAccessor(file_accessor)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in BinaryView._save") return False def init(self) -> bool: diff --git a/python/callingconvention.py b/python/callingconvention.py index f6d266b2..60a3c768 100644 --- a/python/callingconvention.py +++ b/python/callingconvention.py @@ -24,7 +24,7 @@ from typing import Optional, Union # Binary Ninja components from . import _binaryninjacore as core -from .log import log_error +from .log import log_error_for_exception from . import variable from . import function from . import architecture @@ -232,7 +232,7 @@ class CallingConvention: self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_caller_saved_regs") count[0] = 0 return None @@ -247,7 +247,7 @@ class CallingConvention: self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_callee_saved_regs") count[0] = 0 return None @@ -262,7 +262,7 @@ class CallingConvention: self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_int_arg_regs") count[0] = 0 return None @@ -277,7 +277,7 @@ class CallingConvention: self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_float_arg_regs") count[0] = 0 return None @@ -288,41 +288,41 @@ class CallingConvention: raise ValueError("freeing register list that wasn't allocated") del self._pending_reg_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._free_register_list") def _arg_regs_share_index(self, ctxt): try: return self.__class__.arg_regs_share_index except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._arg_regs_share_index") return False def _arg_regs_used_for_varargs(self, ctxt): try: return self.__class__.arg_regs_for_varargs except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._arg_regs_used_for_varargs") return False def _stack_reserved_for_arg_regs(self, ctxt): try: return self.__class__.stack_reserved_for_arg_regs except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._stack_reserved_for_arg_regs") return False def _stack_adjusted_on_return(self, ctxt): try: return self.__class__.stack_adjusted_on_return except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._stack_adjusted_on_return") return False def _eligible_for_heuristics(self, ctxt): try: return self.__class__.eligible_for_heuristics except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._eligible_for_heuristics") return False def _get_int_return_reg(self, ctxt): @@ -333,7 +333,7 @@ class CallingConvention: try: return self.arch.regs[self.__class__.int_return_reg].index except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_int_return_reg") return False def _get_high_int_return_reg(self, ctxt): @@ -342,7 +342,7 @@ class CallingConvention: return 0xffffffff return self.arch.regs[self.__class__.high_int_return_reg].index except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_high_int_return_reg") return False def _get_float_return_reg(self, ctxt): @@ -351,7 +351,7 @@ class CallingConvention: return 0xffffffff return self.arch.regs[self.__class__.float_return_reg].index except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_float_return_reg") return False def _get_global_pointer_reg(self, ctxt): @@ -360,7 +360,7 @@ class CallingConvention: return 0xffffffff return self.arch.regs[self.__class__.global_pointer_reg].index except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_global_pointer_reg") return False def _get_implicitly_defined_regs(self, ctxt, count): @@ -374,7 +374,7 @@ class CallingConvention: self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_implicitly_defined_regs") count[0] = 0 return None @@ -384,7 +384,7 @@ class CallingConvention: reg_name = self.arch.get_reg_name(reg) api_obj = self.perform_get_incoming_reg_value(reg_name, func_obj)._to_core_struct() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_incoming_reg_value") api_obj = variable.Undetermined()._to_core_struct() result[0].state = api_obj.state result[0].value = api_obj.value @@ -395,7 +395,7 @@ class CallingConvention: reg_name = self.arch.get_reg_name(reg) api_obj = self.perform_get_incoming_flag_value(reg_name, func_obj)._to_core_struct() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_incoming_flag_value") api_obj = variable.Undetermined()._to_core_struct() result[0].state = api_obj.state result[0].value = api_obj.value @@ -412,7 +412,7 @@ class CallingConvention: result[0].index = out_var.index result[0].storage = out_var.storage except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_incoming_var_for_parameter_var") result[0].type = in_var[0].type result[0].index = in_var[0].index result[0].storage = in_var[0].storage @@ -429,7 +429,7 @@ class CallingConvention: result[0].index = out_var.index result[0].storage = out_var.storage except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in CallingConvention._get_parameter_var_for_incoming_var") result[0].type = in_var[0].type result[0].index = in_var[0].index result[0].storage = in_var[0].storage diff --git a/python/datarender.py b/python/datarender.py index 6b1a2bd8..d516f26e 100644 --- a/python/datarender.py +++ b/python/datarender.py @@ -27,7 +27,7 @@ from . import filemetadata from . import binaryview from . import function from . import enums -from .log import log_error +from .log import log_error_for_exception from . import types from . import highlight from . import types @@ -113,7 +113,7 @@ class DataRenderer: try: self.perform_free_object(ctxt) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DataRenderer._free_object") def _is_valid_for_data(self, ctxt, view, addr, type, context, ctxCount): try: @@ -127,7 +127,7 @@ class DataRenderer: ) return self.perform_is_valid_for_data(ctxt, view, addr, type, pycontext) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DataRenderer._is_valid_for_data") return False def _get_lines_for_data(self, ctxt, view, addr, type, prefix, prefixCount, width, count, typeCtx, ctxCount, language): @@ -175,7 +175,7 @@ class DataRenderer: return ctypes.cast(self.line_buf, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DataRenderer._get_lines_for_data") return None def _free_lines(self, ctxt, lines, count): diff --git a/python/debuginfo.py b/python/debuginfo.py index 1b8aac74..376e2b5e 100644 --- a/python/debuginfo.py +++ b/python/debuginfo.py @@ -28,7 +28,7 @@ import binaryninja from . import _binaryninjacore as core from . import platform as _platform from . import types as _types -from .log import log_error +from .log import log_error_for_exception from . import binaryview from . import filemetadata from . import typecontainer @@ -102,7 +102,7 @@ class _DebugInfoParserMetaClass(type): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) return callback(view_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in _DebugInfoParserMetaClass._is_valid") return False @staticmethod @@ -119,7 +119,7 @@ class _DebugInfoParserMetaClass(type): assert parser_ref is not None, "core.BNNewDebugInfoReference returned None" return callback(DebugInfo(parser_ref), view_obj, debug_view_obj, progress) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in _DebugInfoParserMetaClass._parse_info") return False @classmethod diff --git a/python/demangle.py b/python/demangle.py index 1ea7a7f3..714f76cc 100644 --- a/python/demangle.py +++ b/python/demangle.py @@ -26,7 +26,7 @@ import binaryninja from . import _binaryninjacore as core from . import binaryview from . import types -from .log import log_error +from .log import log_error_for_exception from .architecture import Architecture, CoreArchitecture from .platform import Platform from typing import Iterable, List, Optional, Union, Tuple @@ -369,7 +369,7 @@ class Demangler(metaclass=_DemanglerMetaclass): try: return self.is_mangled_string(core.pyNativeStr(name)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Demangler._is_mangled_string") return False def _demangle(self, ctxt, arch, name, out_type, out_var_name, view): @@ -395,14 +395,14 @@ class Demangler(metaclass=_DemanglerMetaclass): out_var_name[0] = Demangler._cached_name return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Demangler._demangle") return False def _free_var_name(self, ctxt, name): try: Demangler._cached_name = None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Demangler._free_var_name") def is_mangled_string(self, name: str) -> bool: """ diff --git a/python/downloadprovider.py b/python/downloadprovider.py index d2eb241f..a82161bb 100644 --- a/python/downloadprovider.py +++ b/python/downloadprovider.py @@ -29,7 +29,7 @@ from urllib.parse import urlencode import binaryninja import binaryninja._binaryninjacore as core from . import settings -from .log import log_error +from .log import log_error_for_exception def to_bytes(field): @@ -75,13 +75,13 @@ class DownloadInstance(object): self.__class__._registered_instances.remove(self) self.perform_destroy_instance() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._destroy_instance") def _perform_request(self, ctxt, url): try: return self.perform_request(url) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._perform_request") return -1 def _perform_custom_request(self, ctxt, method, url, header_count, header_keys, header_values, response): @@ -117,7 +117,7 @@ class DownloadInstance(object): except Exception as e: out_response[0] = None core.BNSetErrorForDownloadInstance(self.handle, e.__class__.__name__) - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._perform_custom_request") return -1 if py_response is not None: @@ -137,7 +137,7 @@ class DownloadInstance(object): return 0 if py_response is not None else -1 except: out_response[0] = None - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._perform_custom_request") return -1 def _free_response(self, ctxt, response): @@ -168,7 +168,7 @@ class DownloadInstance(object): return bytes_len except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._read_callback") return 0 def _write_callback(self, data, len, ctxt): @@ -177,7 +177,7 @@ class DownloadInstance(object): self._response = self._response + str_bytes return len except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadInstance._write_callback") return 0 def get_response(self, url): @@ -297,7 +297,7 @@ class DownloadProvider(metaclass=_DownloadProviderMetaclass): assert download_instance is not None, "core.BNNewDownloadInstanceReference returned None" return ctypes.cast(download_instance, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in DownloadProvider._create_instance") return None def create_instance(self): @@ -387,7 +387,7 @@ try: return -1 except: core.BNSetErrorForDownloadInstance(self.handle, "Unknown Exception!") - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PythonDownloadInstance.perform_request") return -1 return 0 @@ -486,11 +486,11 @@ if not _loaded and (sys.platform != "win32"): except URLError as e: core.BNSetErrorForDownloadInstance(self.handle, e.__class__.__name__) - log_error(str(e)) + log_error_for_exception(str(e)) return -1 except: core.BNSetErrorForDownloadInstance(self.handle, "Unknown Exception!") - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PythonDownloadInstance.perform_request") return -1 return 0 diff --git a/python/fileaccessor.py b/python/fileaccessor.py index bc7024d6..9bf0eb85 100644 --- a/python/fileaccessor.py +++ b/python/fileaccessor.py @@ -23,7 +23,7 @@ import ctypes # Binary Ninja components from . import _binaryninjacore as core -from .log import log_error +from .log import log_error_for_exception class FileAccessor: @@ -50,7 +50,7 @@ class FileAccessor: try: return self.get_length() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FileAccessor._get_length") return 0 def _read(self, ctxt, dest, offset, length): @@ -63,7 +63,7 @@ class FileAccessor: ctypes.memmove(dest, data, len(data)) return len(data) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FileAccessor._read") return 0 def _write(self, ctxt, offset, src, length): @@ -72,7 +72,7 @@ class FileAccessor: ctypes.memmove(data, src, length) return self.write(offset, data.raw) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FileAccessor._write") return 0 diff --git a/python/filemetadata.py b/python/filemetadata.py index 651de470..fd1fc328 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -27,7 +27,7 @@ import binaryninja from . import _binaryninjacore as core from .enums import SaveOption from . import associateddatastore #required for _FileMetadataAssociatedDataStore -from .log import log_error +from .log import log_error_for_exception from . import binaryview from . import database from . import deprecation @@ -51,7 +51,7 @@ class NavigationHandler: try: view = self.get_current_view() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in NavigationHandler._get_current_view") view = "" return core.BNAllocString(view) @@ -59,14 +59,14 @@ class NavigationHandler: try: return self.get_current_offset() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in NavigationHandler._get_current_offset") return 0 def _navigate(self, ctxt: Any, view: ViewName, offset: int) -> bool: try: return self.navigate(view, offset) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in NavigationHandler._navigate") return False def get_current_view(self) -> str: diff --git a/python/flowgraph.py b/python/flowgraph.py index acc2ae92..4cbb40d8 100644 --- a/python/flowgraph.py +++ b/python/flowgraph.py @@ -35,7 +35,7 @@ from . import lowlevelil from . import mediumlevelil from . import highlevelil from . import basicblock -from .log import log_error +from .log import log_error_for_exception from . import highlight from . import interaction @@ -359,7 +359,7 @@ class FlowGraphLayoutRequest: if self.on_complete is not None: self.on_complete() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraphLayoutRequest._complete") @property def complete(self): @@ -475,19 +475,19 @@ class FlowGraph: try: self.prepare_for_layout() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._prepare_for_layout") def _populate_nodes(self, ctxt): try: self.populate_nodes() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._populate_nodes") def _complete_layout(self, ctxt): try: self.complete_layout() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._complete_layout") def _update(self, ctxt): try: @@ -498,20 +498,20 @@ class FlowGraph: assert flow_graph is not None, "core.BNNewFlowGraphReference returned None" return ctypes.cast(flow_graph, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._update") return None def _external_ref_taken(self, ctxt): try: self.__class__._registered_instances.append(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._external_ref_taken") def _external_ref_released(self, ctxt): try: self.__class__._registered_instances.remove(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraph._external_ref_released") def finish_prepare_for_layout(self): """ @@ -952,7 +952,7 @@ class FlowGraphLayout: nodes.append(FlowGraphNode(graph=graph, handle=node_handles[i])) return self.layout(graph, nodes) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FlowGraphLayout._layout") return False def layout(self, graph: FlowGraph, nodes: List[FlowGraphNode]) -> bool: diff --git a/python/functionrecognizer.py b/python/functionrecognizer.py index 3a81b989..4b0c21f8 100644 --- a/python/functionrecognizer.py +++ b/python/functionrecognizer.py @@ -26,7 +26,7 @@ from . import function from . import filemetadata from . import binaryview from . import lowlevelil -from .log import log_error +from .log import log_error_for_exception from . import mediumlevelil @@ -60,7 +60,7 @@ class FunctionRecognizer: il = lowlevelil.LowLevelILFunction(func.arch, handle=core.BNNewLowLevelILFunctionReference(il)) return self.recognize_low_level_il(view, func, il) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FunctionRecognizer._recognize_low_level_il") return False def recognize_low_level_il(self, data, func, il): @@ -74,7 +74,7 @@ class FunctionRecognizer: il = mediumlevelil.MediumLevelILFunction(func.arch, handle=core.BNNewMediumLevelILFunctionReference(il)) return self.recognize_medium_level_il(view, func, il) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in FunctionRecognizer._recognize_mediumlevel_il") return False def recognize_medium_level_il(self, data, func, il): diff --git a/python/interaction.py b/python/interaction.py index fe370008..65b8b2a1 100644 --- a/python/interaction.py +++ b/python/interaction.py @@ -27,7 +27,7 @@ from typing import Optional, Callable, List from . import _binaryninjacore as core from .enums import FormInputFieldType, MessageBoxIcon, MessageBoxButtonSet, MessageBoxButtonResult, ReportType from . import binaryview -from .log import log_error +from .log import log_error_for_exception from . import flowgraph from . import mainthread @@ -573,7 +573,7 @@ class InteractionHandler: view = None self.show_plain_text_report(view, title, contents) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_plain_text_report") def _show_markdown_report(self, ctxt, view, title, contents, plaintext): try: @@ -583,7 +583,7 @@ class InteractionHandler: view = None self.show_markdown_report(view, title, contents, plaintext) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_markdown_report") def _show_html_report(self, ctxt, view, title, contents, plaintext): try: @@ -593,7 +593,7 @@ class InteractionHandler: view = None self.show_html_report(view, title, contents, plaintext) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_html_report") def _show_graph_report(self, ctxt, view, title, graph): try: @@ -603,13 +603,13 @@ class InteractionHandler: view = None self.show_graph_report(view, title, flowgraph.CoreFlowGraph(core.BNNewFlowGraphReference(graph))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_graph_report") def _show_report_collection(self, ctxt, title, reports): try: self.show_report_collection(title, ReportCollection(core.BNNewReportCollectionReference(reports))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_report_collection") def _get_text_line_input(self, ctxt, result, prompt, title): try: @@ -619,7 +619,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_text_line_input") def _get_int_input(self, ctxt, result, prompt, title): try: @@ -629,7 +629,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_int_input") def _get_address_input(self, ctxt, result, prompt, title, view, current_address): try: @@ -643,7 +643,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_address_input") def _get_choice_input(self, ctxt, result, prompt, title, choice_buf, count): try: @@ -656,7 +656,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_choice_input") def _get_large_choice_input(self, ctxt, result, prompt, title, choice_buf, count): try: @@ -669,7 +669,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_large_choice_input") def _get_open_filename_input(self, ctxt, result, prompt, ext): try: @@ -679,7 +679,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_open_filename_input") def _get_save_filename_input(self, ctxt, result, prompt, ext, default_name): try: @@ -689,7 +689,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_save_filename_input") def _get_directory_name_input(self, ctxt, result, prompt, default_name): try: @@ -699,7 +699,7 @@ class InteractionHandler: result[0] = core.BNAllocString(str(value)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_directory_name_input") def _get_checkbox_input(self, ctxt, result, prompt, default_choice): try: @@ -709,7 +709,7 @@ class InteractionHandler: result[0] = value return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_checkbox_input") def _get_form_input(self, ctxt, fields, count, title): try: @@ -776,7 +776,6 @@ class InteractionHandler: ) ) elif fields[i].type == FormInputFieldType.CheckboxFormField: - log_error(fields[i].hasDefault) field_objs.append( CheckboxField( fields[i].prompt, @@ -791,19 +790,19 @@ class InteractionHandler: field_objs[i]._fill_core_result(fields[i]) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._get_form_input") def _show_message_box(self, ctxt, title, text, buttons, icon): try: return self.show_message_box(title, text, buttons, icon) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._show_message_box") def _open_url(self, ctxt, url): try: return self.open_url(url) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._open_url") return False def _run_progress_dialog(self, title, can_cancel, task, task_ctxt): @@ -814,7 +813,7 @@ class InteractionHandler: return self.run_progress_dialog(title, can_cancel, py_task) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in InteractionHandler._run_progress_dialog") return False def show_plain_text_report(self, view, title, contents): diff --git a/python/languagerepresentation.py b/python/languagerepresentation.py index a8241b30..b7dc840d 100644 --- a/python/languagerepresentation.py +++ b/python/languagerepresentation.py @@ -33,7 +33,7 @@ from . import highlight from . import lineformatter from . import variable from . import types -from .log import log_error +from .log import log_error_for_exception from .enums import BraceRequirement, HighlightStandardColor, InstructionTextTokenType, OperatorPrecedence, ScopeType, \ SymbolDisplayType, SymbolDisplayResult, InstructionTextTokenContext @@ -440,20 +440,20 @@ class LanguageRepresentationFunction: try: self.__class__._registered_instances.append(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._external_ref_taken") def _external_ref_released(self, ctxt): try: self.__class__._registered_instances.remove(self) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._external_ref_released") def _init_token_emitter(self, ctxt, emitter: core.BNHighLevelILTokenEmitterHandle): try: emitter = HighLevelILTokenEmitter(core.BNNewHighLevelILTokenEmitterReference(emitter)) self.perform_init_token_emitter(emitter) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._init_token_emitter") def _get_expr_text( self, ctxt, hlil: core.BNHighLevelILFunctionHandle, expr_index: int, @@ -468,7 +468,7 @@ class LanguageRepresentationFunction: settings = function.DisassemblySettings(core.BNNewDisassemblySettingsReference(settings)) self.perform_get_expr_text(instr, tokens, settings, precedence, statement) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._get_expr_text") def _begin_lines( self, ctxt, hlil: core.BNHighLevelILFunctionHandle, expr_index: int, @@ -480,7 +480,7 @@ class LanguageRepresentationFunction: tokens = HighLevelILTokenEmitter(core.BNNewHighLevelILTokenEmitterReference(tokens)) self.perform_begin_lines(instr, tokens) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._begin_lines") def _end_lines( self, ctxt, hlil: core.BNHighLevelILFunctionHandle, expr_index: int, @@ -492,34 +492,34 @@ class LanguageRepresentationFunction: tokens = HighLevelILTokenEmitter(core.BNNewHighLevelILTokenEmitterReference(tokens)) self.perform_end_lines(instr, tokens) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._end_lines") def _comment_start_string(self, ctxt): try: return core.BNAllocString(self.comment_start_string) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._comment_start_string") return core.BNAllocString("// ") def _comment_end_string(self, ctxt): try: return core.BNAllocString(self.comment_end_string) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._comment_end_string") return core.BNAllocString("") def _annotation_start_string(self, ctxt): try: return core.BNAllocString(self.annotation_start_string) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._annotation_start_string") return core.BNAllocString("{") def _annotation_end_string(self, ctxt): try: return core.BNAllocString(self.annotation_end_string) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunction._annotation_end_string") return core.BNAllocString("}") def perform_init_token_emitter(self, emitter: HighLevelILTokenEmitter): @@ -709,7 +709,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti assert handle is not None, "core.BNNewLanguageRepresentationFunctionReference returned None" return ctypes.cast(handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LangugeRepresentationFunctionType._create") return None def _is_valid(self, ctxt, view: core.BNBinaryViewHandle) -> bool: @@ -717,7 +717,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti view = binaryview.BinaryView(handle=core.BNNewViewReference(view)) return self.is_valid(view) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunctionType._is_valid") return False def _type_printer(self, ctxt): @@ -727,7 +727,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti return None return ctypes.cast(result.handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunctionType._type_printer") return None def _type_parser(self, ctxt): @@ -737,7 +737,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti return None return ctypes.cast(result.handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunctionType._type_parser") return None def _line_formatter(self, ctxt): @@ -747,7 +747,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti return None return ctypes.cast(result.handle, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunctionType._line_formatter") return None def _function_type_tokens( @@ -787,7 +787,7 @@ class LanguageRepresentationFunctionType(metaclass=_LanguageRepresentationFuncti return ctypes.cast(self.line_buf, ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in LanguageRepresentationFunctionType._function_type_tokens") count[0] = 0 return None diff --git a/python/log.py b/python/log.py index 25b692ac..678482b6 100644 --- a/python/log.py +++ b/python/log.py @@ -304,3 +304,21 @@ class Logger: def log_alert(self, message: str) -> None: log(LogLevel.AlertLog, message, self.logger_name, self.session_id) + + def log_for_exception(self, level: LogLevel, message: str) -> None: + log_for_exception(level, message, self.logger_name, self.session_id) + + def log_debug_for_exception(self, message: str) -> None: + log_for_exception(LogLevel.DebugLog, message, self.logger_name, self.session_id) + + def log_info_for_exception(self, message: str) -> None: + log_for_exception(LogLevel.InfoLog, message, self.logger_name, self.session_id) + + def log_warn_for_exception(self, message: str) -> None: + log_for_exception(LogLevel.WarningLog, message, self.logger_name, self.session_id) + + def log_error_for_exception(self, message: str) -> None: + log_for_exception(LogLevel.ErrorLog, message, self.logger_name, self.session_id) + + def log_alert_for_exception(self, message: str) -> None: + log_for_exception(LogLevel.AlertLog, message, self.logger_name, self.session_id) diff --git a/python/platform.py b/python/platform.py index 29eb81b0..98f3109a 100644 --- a/python/platform.py +++ b/python/platform.py @@ -34,7 +34,7 @@ from . import typelibrary from . import architecture from . import typecontainer from . import binaryview -from .log import log_error +from .log import log_error_for_exception class _PlatformMetaClass(type): @@ -160,7 +160,7 @@ class Platform(metaclass=_PlatformMetaClass): view_obj = binaryview.BinaryView(handle=core.BNNewViewReference(view)) self.view_init(view) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._view_init") def _get_global_regs(self, ctxt, count): try: @@ -173,7 +173,7 @@ class Platform(metaclass=_PlatformMetaClass): self._pending_reg_lists[result.value] = (result, reg_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._get_global_regs") count[0] = 0 return None @@ -184,7 +184,7 @@ class Platform(metaclass=_PlatformMetaClass): raise ValueError("freeing register list that wasn't allocated") del self._pending_reg_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._free_register_list") def _get_global_reg_type(self, ctxt, reg): try: @@ -195,7 +195,7 @@ class Platform(metaclass=_PlatformMetaClass): return ctypes.cast(handle, ctypes.c_void_p).value return None except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._get_global_reg_type") return None def _get_address_size(self, ctxt): @@ -289,7 +289,7 @@ class Platform(metaclass=_PlatformMetaClass): raise ValueError("freeing source_file_values list that wasn't allocated") del self._pending_parser_input_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Platform._free_type_parser_input") def adjust_type_parser_input( self, diff --git a/python/plugin.py b/python/plugin.py index 761591e5..c2d25948 100644 --- a/python/plugin.py +++ b/python/plugin.py @@ -35,7 +35,7 @@ from . import lowlevelil from . import mediumlevelil from .project import Project from .enums import PluginCommandType -from .log import log_error +from .log import log_error_for_exception class PluginCommandContext: @@ -147,7 +147,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) action(view_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._default_action") @staticmethod def _address_action(view, addr, action): @@ -156,7 +156,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) action(view_obj, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._address_action") @staticmethod def _range_action(view, addr, length, action): @@ -165,7 +165,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) action(view_obj, addr, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._range_action") @staticmethod def _function_action(view, func, action): @@ -175,7 +175,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = function.Function(view_obj, core.BNNewFunctionReference(func)) action(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._function_action") @staticmethod def _low_level_il_function_action(view, func, action): @@ -186,7 +186,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner) action(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._low_level_il_function_action") @staticmethod def _low_level_il_instruction_action(view, func, instr, action): @@ -197,7 +197,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner) action(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._low_level_il_instruction_action") @staticmethod def _medium_level_il_function_action(view, func, action): @@ -210,7 +210,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): ) action(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._medium_level_il_function_action") @staticmethod def _medium_level_il_instruction_action(view, func, instr, action): @@ -223,7 +223,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): ) action(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._medium_level_il_instruction_action") @staticmethod def _high_level_il_function_action(view, func, action): @@ -234,7 +234,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner) action(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._high_level_il_function_action") @staticmethod def _high_level_il_instruction_action(view, func, instr, action): @@ -245,7 +245,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner) action(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._high_level_il_instruction_action") @staticmethod def _project_action(project, action): @@ -253,7 +253,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): project_obj = Project(handle=core.BNNewProjectReference(project)) action(project_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._project_action") @staticmethod def _default_is_valid(view, is_valid): @@ -264,7 +264,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) return is_valid(view_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._default_is_valid") return False @staticmethod @@ -276,7 +276,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) return is_valid(view_obj, addr) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._address_is_valid") return False @staticmethod @@ -288,7 +288,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): view_obj = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view)) return is_valid(view_obj, addr, length) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._range_is_valid") return False @staticmethod @@ -301,7 +301,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = function.Function(view_obj, core.BNNewFunctionReference(func)) return is_valid(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._function_is_valid") return False @staticmethod @@ -315,7 +315,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner) return is_valid(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._low_level_il_function_is_valid") return False @staticmethod @@ -331,7 +331,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = lowlevelil.LowLevelILFunction(owner.arch, core.BNNewLowLevelILFunctionReference(func), owner) return is_valid(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._low_level_il_instruction_is_valid") return False @staticmethod @@ -347,7 +347,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): ) return is_valid(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._medium_level_il_function_is_valid") return False @staticmethod @@ -365,7 +365,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): ) return is_valid(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._medium_level_il_instruction_is_valid") return False @staticmethod @@ -379,7 +379,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner) return is_valid(view_obj, func_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._high_level_il_function_is_valid") return False @staticmethod @@ -395,7 +395,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): func_obj = highlevelil.HighLevelILFunction(owner.arch, core.BNNewHighLevelILFunctionReference(func), owner) return is_valid(view_obj, func_obj[instr]) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._high_level_il_instruction_is_valid") return False @staticmethod @@ -406,7 +406,7 @@ class PluginCommand(metaclass=_PluginCommandMetaClass): project_obj = Project(handle=core.BNNewProjectReference(project)) return is_valid(project_obj) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in PluginCommand._project_is_valid") return False @classmethod @@ -1041,7 +1041,7 @@ class MainThreadActionHandler: try: self.add_action(MainThreadAction(action)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in MainThreadActionHandler._add_action") def add_action(self, action): pass diff --git a/python/renderlayer.py b/python/renderlayer.py index c37fb298..0570ac3f 100644 --- a/python/renderlayer.py +++ b/python/renderlayer.py @@ -27,7 +27,7 @@ from . import _binaryninjacore as core, LinearDisassemblyLine from .enums import LinearDisassemblyLineType, RenderLayerDefaultEnableState from . import binaryview from . import types -from .log import log_error +from .log import log_error_for_exception from typing import Iterable, List, Optional, Union, Tuple @@ -117,7 +117,7 @@ class RenderLayer(metaclass=_RenderLayerMetaclass): try: self.apply_to_flow_graph(binaryninja.FlowGraph(handle=core.BNNewFlowGraphReference(graph))) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in RenderLayer._apply_to_flow_graph") def _apply_to_linear_view_object(self, ctxt, obj, prev, next, in_lines, in_line_count, out_lines, out_line_count): try: @@ -139,7 +139,7 @@ class RenderLayer(metaclass=_RenderLayerMetaclass): out_lines[0] = out_lines_buf self._pending_lines[out_lines_ptr.value] = (out_lines_ptr.value, out_lines_buf) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in RenderLayer._apply_to_linear_view_object") out_lines[0] = None out_line_count[0] = 0 @@ -151,7 +151,7 @@ class RenderLayer(metaclass=_RenderLayerMetaclass): raise ValueError("freeing lines list that wasn't allocated") del self._pending_lines[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in RenderLayer._free_lines") def apply_to_disassembly_block( self, diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 3b7747bb..41b7d8d7 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -98,26 +98,26 @@ class ScriptingOutputListener: try: self.notify_output(text) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingOutputListener._output") def _warning(self, ctxt, text): try: self.notify_warning(text) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingOutputListener._warning") def _error(self, ctxt, text): try: self.notify_error(text) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingOutputListener._error") def _input_ready_state_changed(self, ctxt, state): try: self.notify_input_ready_state_changed(state) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingOutputListener._input_ready_state_changed") def notify_output(self, text): pass @@ -167,40 +167,40 @@ class ScriptingInstance: try: self.__class__._registered_instances.append(self) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._external_ref_taken") def _external_ref_released(self, ctxt): try: self.__class__._registered_instances.remove(self) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._external_ref_released") def _execute_script_input(self, ctxt, text): try: return self.perform_execute_script_input(text) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._execute_script_input") return ScriptingProviderExecuteResult.InvalidScriptInput def _execute_script_input_from_filename(self, ctxt, filename): try: return self.perform_execute_script_input_from_filename(filename) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._execute_script_input_from_filename") return ScriptingProviderExecuteResult.InvalidScriptInput def _cancel_script_input(self, ctxt): try: return self.perform_cancel_script_input() except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._cancel_script_input") return ScriptingProviderExecuteResult.ScriptExecutionCancelled def _release_binary_view(self, ctxt, view): try: binaryview.BinaryView._cache_remove(view) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._release_binary_view") def _set_current_binary_view(self, ctxt, view): try: @@ -211,7 +211,7 @@ class ScriptingInstance: view = None self.perform_set_current_binary_view(view) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._set_current_binary_view") def _set_current_function(self, ctxt, func): try: @@ -221,7 +221,7 @@ class ScriptingInstance: func = None self.perform_set_current_function(func) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._set_current_function") def _set_current_basic_block(self, ctxt, block): try: @@ -240,19 +240,19 @@ class ScriptingInstance: block = None self.perform_set_current_basic_block(block) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._set_current_basic_block") def _set_current_address(self, ctxt, addr): try: self.perform_set_current_address(addr) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._set_current_address") def _set_current_selection(self, ctxt, begin, end): try: self.perform_set_current_selection(begin, end) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._set_current_selection") def _complete_input(self, ctxt, text, state): try: @@ -260,14 +260,14 @@ class ScriptingInstance: text = text.decode("utf-8") return core.BNAllocString(self.perform_complete_input(text, state)) except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._complete_input") return core.BNAllocString("") def _stop(self, ctxt): try: self.perform_stop() except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingInstance._stop") @abc.abstractmethod def perform_execute_script_input(self, text): @@ -431,7 +431,7 @@ class ScriptingProvider(metaclass=_ScriptingProviderMetaclass): assert script_instance is not None, "core.BNNewScriptingInstanceReference returned None" return ctypes.cast(script_instance, ctypes.c_void_p).value except: - logger.log_error(traceback.format_exc()) + logger.log_error_for_exception("Unhandled Python exception in ScriptingProvider._create_instance") return None def create_instance(self) -> Optional[ScriptingInstance]: @@ -1101,9 +1101,9 @@ class PythonScriptingProvider(ScriptingProvider): __import__(module) return True except KeyError: - logger.log_error(f"Failed to find python plugin: {repo_path}/{module}") + logger.log_error_for_exception(f"Failed to find python plugin: {repo_path}/{module}") except ImportError as ie: - logger.log_error(f"Failed to import python plugin: {repo_path}/{module}: {ie}") + logger.log_error_for_exception(f"Failed to import python plugin: {repo_path}/{module}: {ie}") except binaryninja.UIPluginInHeadlessError: logger.log_info(f"Ignored python UI plugin: {repo_path}/{module}") return False diff --git a/python/secretsprovider.py b/python/secretsprovider.py index f87e8d50..d6815ae6 100644 --- a/python/secretsprovider.py +++ b/python/secretsprovider.py @@ -29,7 +29,7 @@ from urllib.parse import urlencode import binaryninja import binaryninja._binaryninjacore as core from . import settings -from .log import log_error +from .log import log_error_for_exception def to_bytes(field): @@ -83,7 +83,7 @@ class SecretsProvider(metaclass=_SecretsProviderMetaclass): try: return self.perform_has_data(key) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in SecretsProvider._has_data") return False def _get_data(self, ctxt, key: str): @@ -91,21 +91,21 @@ class SecretsProvider(metaclass=_SecretsProviderMetaclass): data = self.perform_get_data(key) return core.BNAllocString(data) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in SecretsProvider._get_data") return None def _store_data(self, ctxt, key: str, data: str) -> bool: try: return self.perform_store_data(key, data) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in SecretsProvider._store_data") return False def _delete_data(self, ctxt, key: str) -> bool: try: return self.perform_delete_data(key) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in SecretsProvider._delete_data") return False def perform_has_data(self, key: str) -> bool: diff --git a/python/transform.py b/python/transform.py index c19a7cb1..54641f91 100644 --- a/python/transform.py +++ b/python/transform.py @@ -24,7 +24,7 @@ import abc # Binary Ninja components import binaryninja -from .log import log_error +from .log import log_error_for_exception from . import databuffer from . import _binaryninjacore as core from .enums import TransformType @@ -179,7 +179,7 @@ class Transform(metaclass=_TransformMetaClass): self._pending_param_lists[result.value] = (result, param_buf) return result.value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Transform._get_parameters") count[0] = 0 return None @@ -190,7 +190,7 @@ class Transform(metaclass=_TransformMetaClass): raise ValueError("freeing parameter list that wasn't allocated") del self._pending_param_lists[buf.value] except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Transform._free_parameters") def _decode(self, ctxt, input_buf, output_buf, params, count): try: @@ -206,7 +206,7 @@ class Transform(metaclass=_TransformMetaClass): core.BNSetDataBufferContents(output_buf, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Transform._decode") return False def _encode(self, ctxt, input_buf, output_buf, params, count): @@ -223,7 +223,7 @@ class Transform(metaclass=_TransformMetaClass): core.BNSetDataBufferContents(output_buf, result, len(result)) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Transform._encode") return False @abc.abstractmethod diff --git a/python/typearchive.py b/python/typearchive.py index bc2dea7a..0085fe10 100644 --- a/python/typearchive.py +++ b/python/typearchive.py @@ -771,25 +771,25 @@ class TypeArchiveNotificationCallbacks: try: self._notify.type_added(self._archive, core.pyNativeStr(id), _types.Type.create(handle=core.BNNewTypeReference(definition))) except: - log.log_error(traceback.format_exc()) + log.log_error_for_exception("Unhandled Python exception in TypeArchiveNotificationCallbacks._type_added") def _type_updated(self, ctxt, archive: ctypes.POINTER(core.BNTypeArchive), id: ctypes.c_char_p, old_definition: ctypes.POINTER(core.BNType), new_definition: ctypes.POINTER(core.BNType)) -> None: try: self._notify.type_updated(self._archive, core.pyNativeStr(id), _types.Type.create(handle=core.BNNewTypeReference(old_definition)), _types.Type.create(handle=core.BNNewTypeReference(new_definition))) except: - log.log_error(traceback.format_exc()) + log.log_error_for_exception("Unhandled Python exception in TypeArchiveNotificationCallbacks._type_updated") def _type_renamed(self, ctxt, archive: ctypes.POINTER(core.BNTypeArchive), id: ctypes.c_char_p, old_name: ctypes.POINTER(core.BNQualifiedName), new_name: ctypes.POINTER(core.BNQualifiedName)) -> None: try: self._notify.type_renamed(self._archive, core.pyNativeStr(id), _types.QualifiedName._from_core_struct(old_name.contents), _types.QualifiedName._from_core_struct(new_name.contents)) except: - log.log_error(traceback.format_exc()) + log.log_error_for_exception("Unhandled Python exception in TypeArchiveNotificationCallbacks._type_renamed") def _type_deleted(self, ctxt, archive: ctypes.POINTER(core.BNTypeArchive), id: ctypes.c_char_p, definition: ctypes.POINTER(core.BNType)) -> None: try: self._notify.type_deleted(self._archive, core.pyNativeStr(id), _types.Type.create(handle=core.BNNewTypeReference(definition))) except: - log.log_error(traceback.format_exc()) + log.log_error_for_exception("Unhandled Python exception in TypeArchiveNotificationCallbacks._type_deleted") @property def archive(self) -> 'TypeArchive': diff --git a/python/typeparser.py b/python/typeparser.py index fc7f5630..e44d13b5 100644 --- a/python/typeparser.py +++ b/python/typeparser.py @@ -37,7 +37,7 @@ from . import platform from . import typecontainer from . import types from . import deprecation -from .log import log_error +from .log import log_error_for_exception from .enums import TypeParserErrorSeverity, TypeParserOption @@ -255,7 +255,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): result[0] = TypeParser._cached_string return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._get_option_text") return False def _preprocess_source( @@ -299,7 +299,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): return output_py is not None except: errorCount[0] = 0 - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._preprocess_source") return False def _parse_types_from_source( @@ -350,7 +350,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): result[0].variableCount = 0 result[0].functionCount = 0 errorCount[0] = 0 - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._parse_types_from_source") return False def _parse_type_string( @@ -384,7 +384,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): return result_py is not None except: errorCount[0] = 0 - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._parse_type_string") return False def _free_string( @@ -394,7 +394,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): TypeParser._cached_string = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._free_string") return False def _free_result( @@ -411,7 +411,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): TypeParser._cached_result = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._free_result") return False def _free_error_list( @@ -421,7 +421,7 @@ class TypeParser(metaclass=_TypeParserMetaclass): TypeParser._cached_error = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypeParser._free_error_list") return False def get_option_text(self, option: TypeParserOption, value: str) -> Optional[str]: diff --git a/python/typeprinter.py b/python/typeprinter.py index 20c1f829..be885c07 100644 --- a/python/typeprinter.py +++ b/python/typeprinter.py @@ -36,7 +36,7 @@ from . import types from . import function as _function from . import binaryview from . import typecontainer -from .log import log_error +from .log import log_error_for_exception from .enums import TokenEscapingType @@ -128,7 +128,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_tokens") return False def _get_type_tokens_before_name(self, ctxt, type, platform, base_confidence, parent_type, escaping, result, result_count): @@ -149,7 +149,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_tokens_before_name") return False def _get_type_tokens_after_name(self, ctxt, type, platform, base_confidence, parent_type, escaping, result, result_count): @@ -170,7 +170,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_tokens_after_name") return False def _get_type_string(self, ctxt, type, platform, name, escaping, result): @@ -186,7 +186,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): result[0] = TypePrinter._cached_string return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_string") return False def _get_type_string_before_name(self, ctxt, type, platform, escaping, result): @@ -202,7 +202,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): result[0] = TypePrinter._cached_string return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_string_before_name") return False def _get_type_string_after_name(self, ctxt, type, platform, escaping, result): @@ -218,7 +218,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): result[0] = TypePrinter._cached_string return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_string_after_name") return False def _get_type_lines(self, ctxt, type, container, name, padding_cols, collapsed, escaping, result, result_count): @@ -237,7 +237,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._get_type_lines") return False def _print_all_types(self, ctxt, names, types_, type_count, data, padding_cols, escaping, result): @@ -258,7 +258,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): result[0] = TypePrinter._cached_string return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._print_all_types") return False def _free_tokens(self, ctxt, tokens, count): @@ -266,7 +266,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): TypePrinter._cached_tokens = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._free_tokens") return False def _free_string(self, ctxt, string): @@ -274,7 +274,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): TypePrinter._cached_string = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._free_string") return False def _free_lines(self, ctxt, lines, count): @@ -285,7 +285,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass): TypePrinter._cached_lines = None return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in TypePrinter._free_lines") return False def _default_print_all_types(self, types_: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, padding_cols = 64, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str: diff --git a/python/update.py b/python/update.py index 3bdb677c..308094f7 100644 --- a/python/update.py +++ b/python/update.py @@ -25,7 +25,7 @@ import ctypes import binaryninja from . import _binaryninjacore as core from .enums import UpdateResult -from .log import log_error +from .log import log_error_for_exception class _UpdateChannelMetaClass(type): @@ -78,7 +78,7 @@ class UpdateProgressCallback: return self.func(progress, total) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in update progress callback") @property def active(cls): diff --git a/python/websocketprovider.py b/python/websocketprovider.py index e33c247d..0d77ae0b 100644 --- a/python/websocketprovider.py +++ b/python/websocketprovider.py @@ -27,7 +27,7 @@ import traceback import binaryninja._binaryninjacore as core import binaryninja -from .log import log_error +from .log import log_error_for_exception def nop(*args, **kwargs): @@ -77,7 +77,7 @@ class WebsocketClient(object): self.__class__._registered_clients.remove(self) self.perform_destroy_client() except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in WebsocketClient._destroy_client") def _connect(self, ctxt, host, header_count, header_keys, header_values): # Extract headers @@ -97,7 +97,7 @@ class WebsocketClient(object): self.perform_write(data_bytes) return True except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in WebsocketClient._write") return False def _disconnect(self, ctxt): @@ -281,7 +281,7 @@ class WebsocketProvider(metaclass=_WebsocketProviderMetaclass): return None return ctypes.cast(core.BNNewWebsocketClientReference(result.handle), ctypes.c_void_p).value except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in WebsocketProvider._create_instance") return None def create_instance(self): diff --git a/python/workflow.py b/python/workflow.py index 6e4c6730..4db530f8 100644 --- a/python/workflow.py +++ b/python/workflow.py @@ -27,7 +27,7 @@ from typing import List, Union, Callable, Optional, Any # Binary Ninja components import binaryninja -from .log import log_error +from .log import log_error_for_exception from . import _binaryninjacore as core from .flowgraph import FlowGraph, CoreFlowGraph @@ -224,7 +224,7 @@ class Activity(object): if self.action is not None: self.action(AnalysisContext(ac)) except: - log_error(traceback.format_exc()) + log_error_for_exception("Unhandled Python exception in Activity._action") def __del__(self): if core is not None: |
