angr 9.2.102__py3-none-manylinux2014_x86_64.whl → 9.2.104__py3-none-manylinux2014_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of angr might be problematic. Click here for more details.

Files changed (239) hide show
  1. angr/__init__.py +1 -1
  2. angr/analyses/analysis.py +7 -6
  3. angr/analyses/calling_convention.py +33 -35
  4. angr/analyses/cdg.py +2 -4
  5. angr/analyses/cfg/cfb.py +4 -3
  6. angr/analyses/cfg/cfg_base.py +14 -14
  7. angr/analyses/cfg/cfg_emulated.py +3 -4
  8. angr/analyses/cfg/cfg_fast.py +46 -46
  9. angr/analyses/cfg/cfg_fast_soot.py +1 -2
  10. angr/analyses/cfg/cfg_job_base.py +2 -2
  11. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +14 -13
  12. angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +5 -5
  13. angr/analyses/cfg_slice_to_sink/cfg_slice_to_sink.py +3 -3
  14. angr/analyses/complete_calling_conventions.py +13 -12
  15. angr/analyses/data_dep/data_dependency_analysis.py +24 -24
  16. angr/analyses/data_dep/dep_nodes.py +3 -3
  17. angr/analyses/ddg.py +1 -2
  18. angr/analyses/decompiler/ail_simplifier.py +35 -34
  19. angr/analyses/decompiler/block_io_finder.py +20 -20
  20. angr/analyses/decompiler/block_similarity.py +4 -6
  21. angr/analyses/decompiler/block_simplifier.py +17 -16
  22. angr/analyses/decompiler/callsite_maker.py +25 -10
  23. angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +1 -3
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +2 -4
  25. angr/analyses/decompiler/clinic.py +250 -45
  26. angr/analyses/decompiler/condition_processor.py +15 -8
  27. angr/analyses/decompiler/decompilation_cache.py +7 -7
  28. angr/analyses/decompiler/decompilation_options.py +4 -4
  29. angr/analyses/decompiler/decompiler.py +19 -15
  30. angr/analyses/decompiler/expression_counters.py +10 -9
  31. angr/analyses/decompiler/goto_manager.py +2 -4
  32. angr/analyses/decompiler/graph_region.py +9 -9
  33. angr/analyses/decompiler/jump_target_collector.py +1 -2
  34. angr/analyses/decompiler/optimization_passes/__init__.py +4 -3
  35. angr/analyses/decompiler/optimization_passes/code_motion.py +5 -6
  36. angr/analyses/decompiler/optimization_passes/const_derefs.py +4 -4
  37. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +73 -0
  38. angr/analyses/decompiler/optimization_passes/engine_base.py +25 -3
  39. angr/analyses/decompiler/optimization_passes/expr_op_swapper.py +6 -5
  40. angr/analyses/decompiler/optimization_passes/flip_boolean_cmp.py +2 -2
  41. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +3 -0
  42. angr/analyses/decompiler/optimization_passes/ite_expr_converter.py +2 -2
  43. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +17 -17
  44. angr/analyses/decompiler/optimization_passes/optimization_pass.py +12 -13
  45. angr/analyses/decompiler/optimization_passes/register_save_area_simplifier.py +25 -21
  46. angr/analyses/decompiler/optimization_passes/ret_addr_save_simplifier.py +3 -3
  47. angr/analyses/decompiler/optimization_passes/ret_deduplicator.py +1 -2
  48. angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +7 -7
  49. angr/analyses/decompiler/optimization_passes/spilled_register_finder.py +18 -0
  50. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +2 -3
  51. angr/analyses/decompiler/optimization_passes/win_stack_canary_simplifier.py +1 -2
  52. angr/analyses/decompiler/optimization_passes/x86_gcc_getpc_simplifier.py +2 -2
  53. angr/analyses/decompiler/peephole_optimizations/__init__.py +4 -3
  54. angr/analyses/decompiler/peephole_optimizations/base.py +13 -15
  55. angr/analyses/decompiler/peephole_optimizations/bswap.py +1 -3
  56. angr/analyses/decompiler/peephole_optimizations/cmpord_rewriter.py +72 -0
  57. angr/analyses/decompiler/peephole_optimizations/const_mull_a_shift.py +1 -2
  58. angr/analyses/decompiler/peephole_optimizations/eager_eval.py +1 -1
  59. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy.py +5 -10
  60. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy_consolidation.py +3 -4
  61. angr/analyses/decompiler/peephole_optimizations/inlined_wstrcpy.py +7 -10
  62. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +2 -3
  63. angr/analyses/decompiler/peephole_optimizations/sar_to_signed_div.py +1 -2
  64. angr/analyses/decompiler/peephole_optimizations/tidy_stack_addr.py +4 -4
  65. angr/analyses/decompiler/redundant_label_remover.py +4 -5
  66. angr/analyses/decompiler/region_identifier.py +4 -5
  67. angr/analyses/decompiler/region_simplifiers/cascading_cond_transformer.py +1 -2
  68. angr/analyses/decompiler/region_simplifiers/expr_folding.py +19 -20
  69. angr/analyses/decompiler/region_simplifiers/goto.py +2 -3
  70. angr/analyses/decompiler/region_simplifiers/loop.py +1 -2
  71. angr/analyses/decompiler/region_simplifiers/node_address_finder.py +1 -2
  72. angr/analyses/decompiler/region_simplifiers/region_simplifier.py +1 -3
  73. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +19 -19
  74. angr/analyses/decompiler/return_maker.py +1 -2
  75. angr/analyses/decompiler/structured_codegen/base.py +5 -6
  76. angr/analyses/decompiler/structured_codegen/c.py +39 -38
  77. angr/analyses/decompiler/structuring/__init__.py +1 -1
  78. angr/analyses/decompiler/structuring/dream.py +17 -16
  79. angr/analyses/decompiler/structuring/phoenix.py +45 -46
  80. angr/analyses/decompiler/structuring/recursive_structurer.py +4 -4
  81. angr/analyses/decompiler/structuring/structurer_base.py +16 -15
  82. angr/analyses/decompiler/structuring/structurer_nodes.py +10 -9
  83. angr/analyses/decompiler/utils.py +17 -16
  84. angr/analyses/disassembly.py +7 -6
  85. angr/analyses/flirt.py +9 -9
  86. angr/analyses/forward_analysis/forward_analysis.py +15 -14
  87. angr/analyses/forward_analysis/visitors/function_graph.py +1 -2
  88. angr/analyses/forward_analysis/visitors/graph.py +16 -15
  89. angr/analyses/propagator/engine_ail.py +30 -26
  90. angr/analyses/propagator/outdated_definition_walker.py +8 -7
  91. angr/analyses/propagator/propagator.py +11 -13
  92. angr/analyses/proximity_graph.py +21 -21
  93. angr/analyses/reaching_definitions/__init__.py +3 -3
  94. angr/analyses/reaching_definitions/call_trace.py +3 -6
  95. angr/analyses/reaching_definitions/dep_graph.py +41 -48
  96. angr/analyses/reaching_definitions/engine_ail.py +11 -5
  97. angr/analyses/reaching_definitions/engine_vex.py +9 -8
  98. angr/analyses/reaching_definitions/function_handler.py +51 -34
  99. angr/analyses/reaching_definitions/heap_allocator.py +3 -4
  100. angr/analyses/reaching_definitions/rd_initializer.py +8 -8
  101. angr/analyses/reaching_definitions/rd_state.py +57 -58
  102. angr/analyses/reaching_definitions/reaching_definitions.py +18 -17
  103. angr/analyses/reaching_definitions/subject.py +2 -3
  104. angr/analyses/stack_pointer_tracker.py +15 -6
  105. angr/analyses/typehoon/dfa.py +4 -4
  106. angr/analyses/typehoon/simple_solver.py +48 -52
  107. angr/analyses/typehoon/translator.py +3 -6
  108. angr/analyses/typehoon/typeconsts.py +13 -14
  109. angr/analyses/typehoon/typehoon.py +9 -9
  110. angr/analyses/typehoon/typevars.py +18 -17
  111. angr/analyses/variable_recovery/engine_ail.py +5 -5
  112. angr/analyses/variable_recovery/engine_base.py +25 -21
  113. angr/analyses/variable_recovery/irsb_scanner.py +8 -9
  114. angr/analyses/variable_recovery/variable_recovery.py +1 -2
  115. angr/analyses/variable_recovery/variable_recovery_base.py +14 -13
  116. angr/analyses/variable_recovery/variable_recovery_fast.py +8 -8
  117. angr/analyses/veritesting.py +1 -2
  118. angr/analyses/vfg.py +57 -56
  119. angr/analyses/xrefs.py +1 -2
  120. angr/angrdb/db.py +7 -7
  121. angr/angrdb/serializers/kb.py +16 -13
  122. angr/angrdb/serializers/loader.py +1 -2
  123. angr/angrdb/serializers/structured_code.py +2 -2
  124. angr/annocfg.py +1 -2
  125. angr/block.py +16 -6
  126. angr/calling_conventions.py +28 -27
  127. angr/code_location.py +8 -8
  128. angr/codenode.py +1 -2
  129. angr/concretization_strategies/max.py +1 -3
  130. angr/distributed/server.py +1 -3
  131. angr/distributed/worker.py +1 -2
  132. angr/engines/engine.py +2 -3
  133. angr/engines/light/engine.py +4 -4
  134. angr/engines/pcode/behavior.py +20 -2
  135. angr/engines/pcode/emulate.py +1 -1
  136. angr/engines/pcode/engine.py +7 -7
  137. angr/engines/pcode/lifter.py +78 -77
  138. angr/engines/vex/claripy/ccall.py +1 -2
  139. angr/engines/vex/claripy/datalayer.py +1 -2
  140. angr/engines/vex/light/light.py +1 -2
  141. angr/exploration_techniques/tracer.py +4 -4
  142. angr/factory.py +12 -15
  143. angr/flirt/__init__.py +8 -8
  144. angr/flirt/build_sig.py +2 -3
  145. angr/keyed_region.py +2 -2
  146. angr/knowledge_base/knowledge_base.py +3 -3
  147. angr/knowledge_plugins/callsite_prototypes.py +4 -6
  148. angr/knowledge_plugins/cfg/cfg_manager.py +19 -6
  149. angr/knowledge_plugins/cfg/cfg_model.py +26 -27
  150. angr/knowledge_plugins/cfg/cfg_node.py +2 -2
  151. angr/knowledge_plugins/cfg/indirect_jump.py +6 -8
  152. angr/knowledge_plugins/cfg/memory_data.py +8 -9
  153. angr/knowledge_plugins/custom_strings.py +1 -3
  154. angr/knowledge_plugins/debug_variables.py +2 -2
  155. angr/knowledge_plugins/functions/function.py +21 -22
  156. angr/knowledge_plugins/functions/function_manager.py +5 -5
  157. angr/knowledge_plugins/indirect_jumps.py +1 -3
  158. angr/knowledge_plugins/key_definitions/atoms.py +7 -7
  159. angr/knowledge_plugins/key_definitions/definition.py +14 -14
  160. angr/knowledge_plugins/key_definitions/environment.py +5 -7
  161. angr/knowledge_plugins/key_definitions/heap_address.py +1 -3
  162. angr/knowledge_plugins/key_definitions/key_definition_manager.py +3 -2
  163. angr/knowledge_plugins/key_definitions/live_definitions.py +60 -59
  164. angr/knowledge_plugins/key_definitions/liveness.py +16 -16
  165. angr/knowledge_plugins/key_definitions/rd_model.py +15 -15
  166. angr/knowledge_plugins/key_definitions/uses.py +11 -11
  167. angr/knowledge_plugins/patches.py +4 -8
  168. angr/knowledge_plugins/propagations/prop_value.py +10 -9
  169. angr/knowledge_plugins/propagations/propagation_manager.py +3 -5
  170. angr/knowledge_plugins/propagations/propagation_model.py +9 -9
  171. angr/knowledge_plugins/propagations/states.py +52 -22
  172. angr/knowledge_plugins/structured_code/manager.py +2 -2
  173. angr/knowledge_plugins/sync/sync_controller.py +3 -3
  174. angr/knowledge_plugins/variables/variable_access.py +4 -4
  175. angr/knowledge_plugins/variables/variable_manager.py +39 -39
  176. angr/knowledge_plugins/xrefs/xref.py +9 -11
  177. angr/knowledge_plugins/xrefs/xref_manager.py +3 -4
  178. angr/misc/ansi.py +1 -2
  179. angr/misc/autoimport.py +3 -3
  180. angr/misc/plugins.py +9 -9
  181. angr/procedures/definitions/__init__.py +16 -16
  182. angr/procedures/definitions/linux_kernel.py +1 -1
  183. angr/procedures/definitions/parse_win32json.py +1 -1
  184. angr/procedures/java_jni/__init__.py +1 -1
  185. angr/procedures/java_jni/array_operations.py +1 -2
  186. angr/procedures/java_jni/method_calls.py +1 -2
  187. angr/procedures/posix/inet_ntoa.py +1 -2
  188. angr/procedures/stubs/format_parser.py +3 -3
  189. angr/project.py +13 -11
  190. angr/sim_manager.py +12 -12
  191. angr/sim_procedure.py +7 -3
  192. angr/sim_state.py +2 -2
  193. angr/sim_type.py +60 -45
  194. angr/sim_variable.py +5 -5
  195. angr/simos/simos.py +1 -2
  196. angr/simos/userland.py +1 -2
  197. angr/state_plugins/callstack.py +3 -2
  198. angr/state_plugins/history.py +1 -2
  199. angr/state_plugins/solver.py +34 -34
  200. angr/storage/memory_mixins/__init__.py +4 -3
  201. angr/storage/memory_mixins/actions_mixin.py +1 -3
  202. angr/storage/memory_mixins/address_concretization_mixin.py +1 -3
  203. angr/storage/memory_mixins/convenient_mappings_mixin.py +3 -4
  204. angr/storage/memory_mixins/default_filler_mixin.py +1 -1
  205. angr/storage/memory_mixins/label_merger_mixin.py +2 -2
  206. angr/storage/memory_mixins/multi_value_merger_mixin.py +4 -3
  207. angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +9 -8
  208. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +12 -11
  209. angr/storage/memory_mixins/paged_memory/pages/cooperation.py +8 -8
  210. angr/storage/memory_mixins/paged_memory/pages/history_tracking_mixin.py +2 -3
  211. angr/storage/memory_mixins/paged_memory/pages/list_page.py +10 -11
  212. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +11 -10
  213. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +18 -17
  214. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +12 -11
  215. angr/storage/memory_mixins/regioned_memory/abstract_address_descriptor.py +3 -3
  216. angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +3 -2
  217. angr/storage/memory_mixins/regioned_memory/region_data.py +1 -2
  218. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +2 -2
  219. angr/storage/memory_mixins/regioned_memory/regioned_address_concretization_mixin.py +3 -3
  220. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +18 -21
  221. angr/storage/memory_mixins/size_resolution_mixin.py +1 -2
  222. angr/storage/memory_mixins/symbolic_merger_mixin.py +3 -2
  223. angr/storage/memory_mixins/top_merger_mixin.py +3 -2
  224. angr/storage/memory_object.py +2 -4
  225. angr/utils/algo.py +3 -2
  226. angr/utils/dynamic_dictlist.py +5 -5
  227. angr/utils/formatting.py +4 -4
  228. angr/utils/funcid.py +1 -2
  229. angr/utils/graph.py +5 -6
  230. angr/utils/library.py +5 -5
  231. angr/utils/mp.py +5 -4
  232. angr/utils/segment_list.py +3 -4
  233. angr/utils/typing.py +3 -2
  234. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/METADATA +9 -11
  235. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/RECORD +239 -236
  236. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/LICENSE +0 -0
  237. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/WHEEL +0 -0
  238. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/entry_points.txt +0 -0
  239. {angr-9.2.102.dist-info → angr-9.2.104.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- from typing import Set, List, Tuple, Dict, Union, Optional, Literal, TYPE_CHECKING
1
+ from typing import Literal, TYPE_CHECKING
2
2
  import logging
3
3
  from collections import defaultdict
4
4
  from itertools import count, chain
@@ -74,22 +74,22 @@ class VariableManagerInternal(Serializable):
74
74
 
75
75
  self.func_addr = func_addr
76
76
 
77
- self._variables: Set[SimVariable] = OrderedSet() # all variables that are added to any region
77
+ self._variables: set[SimVariable] = OrderedSet() # all variables that are added to any region
78
78
  self._global_region = KeyedRegion()
79
79
  self._stack_region = KeyedRegion()
80
80
  self._register_region = KeyedRegion()
81
81
  self._live_variables = {} # a mapping between addresses of program points and live variable collections
82
82
 
83
- self._variable_accesses: Dict[SimVariable, Set[VariableAccess]] = defaultdict(set)
84
- self._insn_to_variable: Dict[int, Set[Tuple[SimVariable, int]]] = defaultdict(set)
85
- self._stmt_to_variable: Dict[Union[Tuple[int, int], Tuple[int, int, int]], Set[Tuple[SimVariable, int]]] = (
83
+ self._variable_accesses: dict[SimVariable, set[VariableAccess]] = defaultdict(set)
84
+ self._insn_to_variable: dict[int, set[tuple[SimVariable, int]]] = defaultdict(set)
85
+ self._stmt_to_variable: dict[tuple[int, int] | tuple[int, int, int], set[tuple[SimVariable, int]]] = (
86
86
  defaultdict(set)
87
87
  )
88
- self._variable_to_stmt: Dict[SimVariable, Set[Union[Tuple[int, int], Tuple[int, int, int]]]] = defaultdict(set)
89
- self._atom_to_variable: Dict[
90
- Union[Tuple[int, int], Tuple[int, int, int]], Dict[int, Set[Tuple[SimVariable, int]]]
88
+ self._variable_to_stmt: dict[SimVariable, set[tuple[int, int] | tuple[int, int, int]]] = defaultdict(set)
89
+ self._atom_to_variable: dict[
90
+ tuple[int, int] | tuple[int, int, int], dict[int, set[tuple[SimVariable, int]]]
91
91
  ] = defaultdict(_defaultdict_set)
92
- self._ident_to_variable: Dict[str, SimVariable] = {}
92
+ self._ident_to_variable: dict[str, SimVariable] = {}
93
93
  self._variable_counters = {
94
94
  "register": count(),
95
95
  "stack": count(),
@@ -98,15 +98,15 @@ class VariableManagerInternal(Serializable):
98
98
  "global": count(),
99
99
  }
100
100
 
101
- self._unified_variables: Set[SimVariable] = set()
102
- self._variables_to_unified_variables: Dict[SimVariable, SimVariable] = {}
101
+ self._unified_variables: set[SimVariable] = set()
102
+ self._variables_to_unified_variables: dict[SimVariable, SimVariable] = {}
103
103
 
104
104
  self._phi_variables = {}
105
105
  self._variables_to_phivars = defaultdict(set)
106
106
  self._phi_variables_by_block = defaultdict(set)
107
107
 
108
108
  self.types = TypesStore(self.manager._kb)
109
- self.variable_to_types: Dict[SimVariable, SimType] = {}
109
+ self.variable_to_types: dict[SimVariable, SimType] = {}
110
110
  self.variables_with_manual_types = set()
111
111
 
112
112
  # optimization
@@ -207,7 +207,7 @@ class VariableManagerInternal(Serializable):
207
207
  unified_stack_variables = []
208
208
  unified_memory_variables = []
209
209
 
210
- unified_variable_idents: Set[str] = set()
210
+ unified_variable_idents: set[str] = set()
211
211
  for variable in self._unified_variables:
212
212
  unified_variable_idents.add(variable.ident)
213
213
  if isinstance(variable, SimRegisterVariable):
@@ -586,15 +586,15 @@ class VariableManagerInternal(Serializable):
586
586
 
587
587
  return vars_and_offset
588
588
 
589
- def is_variable_used_at(self, variable: SimVariable, loc: Tuple[int, int]) -> bool:
589
+ def is_variable_used_at(self, variable: SimVariable, loc: tuple[int, int]) -> bool:
590
590
  return loc in self._variable_to_stmt[variable]
591
591
 
592
- def find_variable_by_stmt(self, block_addr, stmt_idx, sort, block_idx: Optional[int] = None):
592
+ def find_variable_by_stmt(self, block_addr, stmt_idx, sort, block_idx: int | None = None):
593
593
  return next(iter(self.find_variables_by_stmt(block_addr, stmt_idx, sort, block_idx=block_idx)), None)
594
594
 
595
595
  def find_variables_by_stmt(
596
- self, block_addr: int, stmt_idx: int, sort: str, block_idx: Optional[int] = None
597
- ) -> List[Tuple[SimVariable, int]]:
596
+ self, block_addr: int, stmt_idx: int, sort: str, block_idx: int | None = None
597
+ ) -> list[tuple[SimVariable, int]]:
598
598
  key = (block_addr, stmt_idx) if block_idx is None else (block_addr, block_idx, stmt_idx)
599
599
 
600
600
  if key not in self._stmt_to_variable:
@@ -620,12 +620,12 @@ class VariableManagerInternal(Serializable):
620
620
 
621
621
  return var_and_offsets
622
622
 
623
- def find_variable_by_atom(self, block_addr, stmt_idx, atom, block_idx: Optional[int] = None):
623
+ def find_variable_by_atom(self, block_addr, stmt_idx, atom, block_idx: int | None = None):
624
624
  return next(iter(self.find_variables_by_atom(block_addr, stmt_idx, atom, block_idx=block_idx)), None)
625
625
 
626
626
  def find_variables_by_atom(
627
- self, block_addr, stmt_idx, atom, block_idx: Optional[int] = None
628
- ) -> Set[Tuple[SimVariable, int]]:
627
+ self, block_addr, stmt_idx, atom, block_idx: int | None = None
628
+ ) -> set[tuple[SimVariable, int]]:
629
629
  if block_idx is None:
630
630
  key = block_addr, stmt_idx
631
631
  else:
@@ -640,15 +640,15 @@ class VariableManagerInternal(Serializable):
640
640
 
641
641
  return self._atom_to_variable[key][atom_hash]
642
642
 
643
- def find_variables_by_stack_offset(self, offset: int) -> Set[SimVariable]:
643
+ def find_variables_by_stack_offset(self, offset: int) -> set[SimVariable]:
644
644
  return self._stack_region.get_variables_by_offset(offset)
645
645
 
646
- def find_variables_by_register(self, reg: Union[str, int]) -> Set[SimVariable]:
646
+ def find_variables_by_register(self, reg: str | int) -> set[SimVariable]:
647
647
  if type(reg) is str:
648
648
  reg = self.manager._kb._project.arch.registers.get(reg)[0]
649
649
  return self._register_region.get_variables_by_offset(reg)
650
650
 
651
- def get_variable_accesses(self, variable: SimVariable, same_name: bool = False) -> List[VariableAccess]:
651
+ def get_variable_accesses(self, variable: SimVariable, same_name: bool = False) -> list[VariableAccess]:
652
652
  if not same_name:
653
653
  if variable in self._variable_accesses:
654
654
  return list(self._variable_accesses[variable])
@@ -670,8 +670,8 @@ class VariableManagerInternal(Serializable):
670
670
  return accesses
671
671
 
672
672
  def get_variables(
673
- self, sort: Optional[Literal["stack", "reg"]] = None, collapse_same_ident=False
674
- ) -> List[Union[SimStackVariable, SimRegisterVariable]]:
673
+ self, sort: Literal["stack", "reg"] | None = None, collapse_same_ident=False
674
+ ) -> list[SimStackVariable | SimRegisterVariable]:
675
675
  """
676
676
  Get a list of variables.
677
677
 
@@ -695,8 +695,8 @@ class VariableManagerInternal(Serializable):
695
695
  return variables
696
696
 
697
697
  def get_unified_variables(
698
- self, sort: Optional[Literal["stack", "reg"]] = None
699
- ) -> List[Union[SimStackVariable, SimRegisterVariable]]:
698
+ self, sort: Literal["stack", "reg"] | None = None
699
+ ) -> list[SimStackVariable | SimRegisterVariable]:
700
700
  """
701
701
  Get a list of unified variables.
702
702
 
@@ -764,7 +764,7 @@ class VariableManagerInternal(Serializable):
764
764
  variables[phi] = self._phi_variables[phi]
765
765
  return variables
766
766
 
767
- def get_variables_without_writes(self) -> List[SimVariable]:
767
+ def get_variables_without_writes(self) -> list[SimVariable]:
768
768
  """
769
769
  Get all variables that have never been written to.
770
770
 
@@ -845,7 +845,7 @@ class VariableManagerInternal(Serializable):
845
845
  var.name = "g_%s" % var.addr
846
846
 
847
847
  def assign_unified_variable_names(
848
- self, labels=None, arg_names: Optional[List[str]] = None, reset: bool = False
848
+ self, labels=None, arg_names: list[str] | None = None, reset: bool = False
849
849
  ) -> None:
850
850
  """
851
851
  Assign default names to all unified variables.
@@ -918,7 +918,7 @@ class VariableManagerInternal(Serializable):
918
918
  var.name = arg_names[idx] if arg_names else f"a{idx}"
919
919
  var._hash = None
920
920
 
921
- def _register_struct_type(self, ty: SimStruct, name: Optional[str] = None) -> TypeRef:
921
+ def _register_struct_type(self, ty: SimStruct, name: str | None = None) -> TypeRef:
922
922
  if not name:
923
923
  name = ty.name
924
924
  if not name:
@@ -933,7 +933,7 @@ class VariableManagerInternal(Serializable):
933
933
  self,
934
934
  var: SimVariable,
935
935
  ty: SimType,
936
- name: Optional[str] = None,
936
+ name: str | None = None,
937
937
  override_bot: bool = True,
938
938
  all_unified: bool = False,
939
939
  mark_manual: bool = False,
@@ -973,7 +973,7 @@ class VariableManagerInternal(Serializable):
973
973
  if mark_manual:
974
974
  self.variables_with_manual_types.add(other_var)
975
975
 
976
- def get_variable_type(self, var) -> Optional[SimType]:
976
+ def get_variable_type(self, var) -> SimType | None:
977
977
  return self.variable_to_types.get(var, None)
978
978
 
979
979
  def remove_types(self):
@@ -985,8 +985,8 @@ class VariableManagerInternal(Serializable):
985
985
  Map SSA variables to a unified variable. Fill in self._unified_variables.
986
986
  """
987
987
 
988
- stack_vars: Dict[int, List[SimStackVariable]] = defaultdict(list)
989
- reg_vars: Set[SimRegisterVariable] = set()
988
+ stack_vars: dict[int, list[SimStackVariable]] = defaultdict(list)
989
+ reg_vars: set[SimRegisterVariable] = set()
990
990
 
991
991
  # unify stack variables based on their locations
992
992
  for v in self.get_variables():
@@ -1060,7 +1060,7 @@ class VariableManagerInternal(Serializable):
1060
1060
  self._unified_variables.add(unified)
1061
1061
  self._variables_to_unified_variables[variable] = unified
1062
1062
 
1063
- def unified_variable(self, variable: SimVariable) -> Optional[SimVariable]:
1063
+ def unified_variable(self, variable: SimVariable) -> SimVariable | None:
1064
1064
  """
1065
1065
  Return the unified variable for a given SSA variable,
1066
1066
 
@@ -1079,7 +1079,7 @@ class VariableManager(KnowledgeBasePlugin):
1079
1079
  def __init__(self, kb):
1080
1080
  super().__init__(kb=kb)
1081
1081
  self.global_manager = VariableManagerInternal(self)
1082
- self.function_managers: Dict[int, VariableManagerInternal] = {}
1082
+ self.function_managers: dict[int, VariableManagerInternal] = {}
1083
1083
 
1084
1084
  def __contains__(self, key) -> bool:
1085
1085
  if key == "global":
@@ -1135,7 +1135,7 @@ class VariableManager(KnowledgeBasePlugin):
1135
1135
  for manager in self.function_managers.values():
1136
1136
  manager.assign_variable_names()
1137
1137
 
1138
- def get_variable_accesses(self, variable: SimVariable, same_name: bool = False) -> List[VariableAccess]:
1138
+ def get_variable_accesses(self, variable: SimVariable, same_name: bool = False) -> list[VariableAccess]:
1139
1139
  """
1140
1140
  Get a list of all references to the given variable.
1141
1141
 
@@ -1158,7 +1158,7 @@ class VariableManager(KnowledgeBasePlugin):
1158
1158
  raise NotImplementedError
1159
1159
 
1160
1160
  @staticmethod
1161
- def convert_variable_list(vlist: List[Variable], manager: VariableManagerInternal):
1161
+ def convert_variable_list(vlist: list[Variable], manager: VariableManagerInternal):
1162
1162
  for v in vlist:
1163
1163
  simv = None
1164
1164
  if v.type is None:
@@ -1176,7 +1176,7 @@ class VariableManager(KnowledgeBasePlugin):
1176
1176
  simv.name = v.name
1177
1177
  manager.add_variable(v.sort, v.addr, simv)
1178
1178
 
1179
- def load_from_dwarf(self, cu_list: List[CompilationUnit] = None):
1179
+ def load_from_dwarf(self, cu_list: list[CompilationUnit] = None):
1180
1180
  cu_list = cu_list or self._kb._project.loader.main_object.compilation_units
1181
1181
  if cu_list is None:
1182
1182
  l.warning("no CompilationUnit found")
@@ -1,5 +1,3 @@
1
- from typing import Optional
2
-
3
1
  from ...serializable import Serializable
4
2
  from ...protos import primitives_pb2
5
3
  from .xref_types import XRefType
@@ -23,22 +21,22 @@ class XRef(Serializable):
23
21
 
24
22
  def __init__(
25
23
  self,
26
- ins_addr: Optional[int] = None,
27
- block_addr: Optional[int] = None,
28
- stmt_idx: Optional[int] = None,
29
- insn_op_idx: Optional[int] = None,
24
+ ins_addr: int | None = None,
25
+ block_addr: int | None = None,
26
+ stmt_idx: int | None = None,
27
+ insn_op_idx: int | None = None,
30
28
  memory_data=None,
31
- dst: Optional[int] = None,
29
+ dst: int | None = None,
32
30
  xref_type=None,
33
31
  ):
34
32
  if dst is not None and not isinstance(dst, int):
35
33
  raise TypeError("XRefs must be pointing to a constant target. Target %r is not supported." % dst)
36
34
 
37
35
  # src
38
- self.ins_addr: Optional[int] = ins_addr
39
- self.insn_op_idx: Optional[int] = insn_op_idx
40
- self.block_addr: Optional[int] = block_addr
41
- self.stmt_idx: Optional[int] = stmt_idx
36
+ self.ins_addr: int | None = ins_addr
37
+ self.insn_op_idx: int | None = insn_op_idx
38
+ self.block_addr: int | None = block_addr
39
+ self.stmt_idx: int | None = stmt_idx
42
40
 
43
41
  # dst
44
42
  self.memory_data = memory_data # optional
@@ -1,4 +1,3 @@
1
- from typing import Set, Dict
2
1
  import logging
3
2
  from collections import defaultdict
4
3
 
@@ -15,8 +14,8 @@ class XRefManager(KnowledgeBasePlugin, Serializable):
15
14
  def __init__(self, kb):
16
15
  super().__init__(kb=kb)
17
16
 
18
- self.xrefs_by_ins_addr: Dict[int, Set[XRef]] = defaultdict(set)
19
- self.xrefs_by_dst: Dict[int, Set[XRef]] = defaultdict(set)
17
+ self.xrefs_by_ins_addr: dict[int, set[XRef]] = defaultdict(set)
18
+ self.xrefs_by_dst: dict[int, set[XRef]] = defaultdict(set)
20
19
 
21
20
  def copy(self):
22
21
  xm = XRefManager(self._kb)
@@ -70,7 +69,7 @@ class XRefManager(KnowledgeBasePlugin, Serializable):
70
69
  refs = refs.union(self.xrefs_by_dst[addr])
71
70
  return refs
72
71
 
73
- def get_xrefs_by_ins_addr_region(self, start, end) -> Set[XRef]:
72
+ def get_xrefs_by_ins_addr_region(self, start, end) -> set[XRef]:
74
73
  """
75
74
  Get a set of XRef objects that originate at a given address region
76
75
  bounded by start and end. Useful for finding references from a basic block or function.
angr/misc/ansi.py CHANGED
@@ -1,4 +1,3 @@
1
- from typing import Union
2
1
  from enum import Enum, unique
3
2
 
4
3
 
@@ -37,7 +36,7 @@ BackgroundColor = unique(Enum("BackgroundColor", {i.name: (i.value + 10) for i i
37
36
  #
38
37
 
39
38
 
40
- def color(c: Union[Color, BackgroundColor], bright: bool):
39
+ def color(c: Color | BackgroundColor, bright: bool):
41
40
  """
42
41
  Return the ansi prefix using the given code
43
42
  Bright may not be used with a BackgroundColor
angr/misc/autoimport.py CHANGED
@@ -3,7 +3,7 @@ import importlib
3
3
  import importlib.machinery
4
4
  import importlib.util
5
5
  import logging
6
- from typing import Optional, Callable
6
+ from collections.abc import Callable
7
7
 
8
8
 
9
9
  l = logging.getLogger(name=__name__)
@@ -36,7 +36,7 @@ def auto_import_packages(base_module, base_path, ignore_dirs=(), ignore_files=()
36
36
  yield lib_module_name, package
37
37
 
38
38
 
39
- def auto_import_modules(base_module, base_path, ignore_files=(), filter_func: Optional[Callable] = None):
39
+ def auto_import_modules(base_module, base_path, ignore_files=(), filter_func: Callable | None = None):
40
40
  for proc_file_name in os.listdir(base_path):
41
41
  if not proc_file_name.endswith(".py"):
42
42
  continue
@@ -65,7 +65,7 @@ def filter_module(mod, type_req=None, subclass_req=None):
65
65
  yield name, val
66
66
 
67
67
 
68
- def auto_import_source_files(base_path, ignore_files=(), filter_func: Optional[Callable] = None):
68
+ def auto_import_source_files(base_path, ignore_files=(), filter_func: Callable | None = None):
69
69
  for proc_file_name in os.listdir(base_path):
70
70
  if not proc_file_name.endswith(".py"):
71
71
  continue
angr/misc/plugins.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Type, Dict, Optional, List, TypeVar, Generic
1
+ from typing import TypeVar, Generic
2
2
 
3
3
  from angr.errors import AngrNoPluginError
4
4
 
@@ -26,15 +26,15 @@ class PluginHub(Generic[P]):
26
26
 
27
27
  def __init__(self):
28
28
  super().__init__()
29
- self._active_plugins: Dict[str, P] = {}
30
- self._active_preset: Optional[PluginPreset] = None
31
- self._provided_by_preset: List[int] = []
29
+ self._active_plugins: dict[str, P] = {}
30
+ self._active_preset: PluginPreset | None = None
31
+ self._provided_by_preset: list[int] = []
32
32
 
33
33
  #
34
34
  # Class methods for registration
35
35
  #
36
36
 
37
- _presets: Dict[str, Type[P]]
37
+ _presets: dict[str, type[P]]
38
38
 
39
39
  @classmethod
40
40
  def register_default(cls, name, plugin_cls, preset="default"):
@@ -157,7 +157,7 @@ class PluginHub(Generic[P]):
157
157
  return self._active_plugins[name]
158
158
 
159
159
  elif self._active_preset is not None:
160
- plugin_cls: Type[P] = self._active_preset.request_plugin(name)
160
+ plugin_cls: type[P] = self._active_preset.request_plugin(name)
161
161
  plugin = self._init_plugin(plugin_cls)
162
162
 
163
163
  # Remember that this plugin was provided by preset.
@@ -169,7 +169,7 @@ class PluginHub(Generic[P]):
169
169
  else:
170
170
  raise AngrNoPluginError("No such plugin: %s" % name)
171
171
 
172
- def _init_plugin(self, plugin_cls: Type[P]) -> P: # pylint: disable=no-self-use
172
+ def _init_plugin(self, plugin_cls: type[P]) -> P: # pylint: disable=no-self-use
173
173
  """
174
174
  Perform any initialization actions on plugin before it is added to the list of active plugins.
175
175
 
@@ -217,7 +217,7 @@ class PluginPreset:
217
217
  """
218
218
 
219
219
  def __init__(self):
220
- self._default_plugins: Dict[str, Type[P]] = {}
220
+ self._default_plugins: dict[str, type[P]] = {}
221
221
 
222
222
  def activate(self, hub): # pylint:disable=no-self-use,unused-argument
223
223
  """
@@ -243,7 +243,7 @@ class PluginPreset:
243
243
  """
244
244
  return self._default_plugins.keys()
245
245
 
246
- def request_plugin(self, name: str) -> Type[P]:
246
+ def request_plugin(self, name: str) -> type[P]:
247
247
  """
248
248
  Return the plugin class which is registered under the name ``name``, or raise NoPlugin if
249
249
  the name isn't available.
@@ -25,8 +25,8 @@ if TYPE_CHECKING:
25
25
 
26
26
 
27
27
  l = logging.getLogger(name=__name__)
28
- SIM_LIBRARIES: Dict[str, "SimLibrary"] = {}
29
- SIM_TYPE_COLLECTIONS: Dict[str, "SimTypeCollection"] = {}
28
+ SIM_LIBRARIES: dict[str, "SimLibrary"] = {}
29
+ SIM_TYPE_COLLECTIONS: dict[str, "SimTypeCollection"] = {}
30
30
 
31
31
 
32
32
  class SimTypeCollection:
@@ -35,8 +35,8 @@ class SimTypeCollection:
35
35
  """
36
36
 
37
37
  def __init__(self):
38
- self.names: Optional[List[str]] = None
39
- self.types: Dict[str, "SimType"] = {}
38
+ self.names: list[str] | None = None
39
+ self.types: dict[str, "SimType"] = {}
40
40
 
41
41
  def set_names(self, *names):
42
42
  self.names = names
@@ -98,10 +98,10 @@ class SimLibrary:
98
98
  """
99
99
 
100
100
  def __init__(self):
101
- self.type_collection_names: List[str] = []
101
+ self.type_collection_names: list[str] = []
102
102
  self.procedures = {}
103
103
  self.non_returning = set()
104
- self.prototypes: Dict[str, SimTypeFunction] = {}
104
+ self.prototypes: dict[str, SimTypeFunction] = {}
105
105
  self.default_ccs = {}
106
106
  self.names = []
107
107
  self.fallback_cc = dict(DEFAULT_CC)
@@ -292,7 +292,7 @@ class SimLibrary:
292
292
  self._apply_metadata(proc, arch)
293
293
  return proc
294
294
 
295
- def get_prototype(self, name: str, arch=None) -> Optional[SimTypeFunction]:
295
+ def get_prototype(self, name: str, arch=None) -> SimTypeFunction | None:
296
296
  """
297
297
  Get a prototype of the given function name, optionally specialize the prototype to a given architecture.
298
298
 
@@ -355,7 +355,7 @@ class SimCppLibrary(SimLibrary):
355
355
  return name
356
356
 
357
357
  @staticmethod
358
- def _proto_from_demangled_name(name: str) -> Optional[SimTypeFunction]:
358
+ def _proto_from_demangled_name(name: str) -> SimTypeFunction | None:
359
359
  """
360
360
  Attempt to extract arguments and calling convention information for a C++ function whose name was mangled
361
361
  according to the Itanium C++ ABI symbol mangling language.
@@ -411,7 +411,7 @@ class SimCppLibrary(SimLibrary):
411
411
  stub.num_args = len(stub.prototype.args)
412
412
  return stub
413
413
 
414
- def get_prototype(self, name: str, arch=None) -> Optional[SimTypeFunction]:
414
+ def get_prototype(self, name: str, arch=None) -> SimTypeFunction | None:
415
415
  """
416
416
  Get a prototype of the given function name, optionally specialize the prototype to a given architecture. The
417
417
  function name will be demangled first.
@@ -468,10 +468,10 @@ class SimSyscallLibrary(SimLibrary):
468
468
 
469
469
  def __init__(self):
470
470
  super().__init__()
471
- self.syscall_number_mapping: Dict[str, Dict[int, str]] = defaultdict(dict) # keyed by abi
472
- self.syscall_name_mapping: Dict[str, Dict[str, int]] = defaultdict(dict) # keyed by abi
473
- self.default_cc_mapping: Dict[str, Type["SimCCSyscall"]] = {} # keyed by abi
474
- self.syscall_prototypes: Dict[str, Dict[str, SimTypeFunction]] = defaultdict(dict) # keyed by abi
471
+ self.syscall_number_mapping: dict[str, dict[int, str]] = defaultdict(dict) # keyed by abi
472
+ self.syscall_name_mapping: dict[str, dict[str, int]] = defaultdict(dict) # keyed by abi
473
+ self.default_cc_mapping: dict[str, type["SimCCSyscall"]] = {} # keyed by abi
474
+ self.syscall_prototypes: dict[str, dict[str, SimTypeFunction]] = defaultdict(dict) # keyed by abi
475
475
  self.fallback_proc = stub_syscall
476
476
 
477
477
  def copy(self):
@@ -551,7 +551,7 @@ class SimSyscallLibrary(SimLibrary):
551
551
  """
552
552
  self.syscall_prototypes[abi][name] = proto
553
553
 
554
- def set_prototypes(self, abi: str, protos: Dict[str, SimTypeFunction]) -> None: # pylint: disable=arguments-differ
554
+ def set_prototypes(self, abi: str, protos: dict[str, SimTypeFunction]) -> None: # pylint: disable=arguments-differ
555
555
  """
556
556
  Set the prototypes of many syscalls.
557
557
 
@@ -621,7 +621,7 @@ class SimSyscallLibrary(SimLibrary):
621
621
  l.debug("unsupported syscall: %s", number)
622
622
  return proc
623
623
 
624
- def get_prototype(self, abi: str, name: str, arch=None) -> Optional[SimTypeFunction]:
624
+ def get_prototype(self, abi: str, name: str, arch=None) -> SimTypeFunction | None:
625
625
  """
626
626
  Get a prototype of the given syscall name and its ABI, optionally specialize the prototype to a given
627
627
  architecture.
@@ -686,7 +686,7 @@ class SimSyscallLibrary(SimLibrary):
686
686
  # - We will load all APIs when load_all_definitions() is called.
687
687
 
688
688
  _DEFINITIONS_BASEDIR = os.path.dirname(os.path.realpath(__file__))
689
- _EXTERNAL_DEFINITIONS_DIRS: Optional[List[str]] = None
689
+ _EXTERNAL_DEFINITIONS_DIRS: list[str] | None = None
690
690
 
691
691
 
692
692
  def load_type_collections(skip=None) -> None:
@@ -1279,7 +1279,7 @@ _amd64_fd_spots = \
1279
1279
  }
1280
1280
 
1281
1281
 
1282
- _syscall_abis: Dict[str,Dict[str,SimTypeFunction]] = {
1282
+ _syscall_abis: dict[str,dict[str,SimTypeFunction]] = {
1283
1283
  "amd64": {},
1284
1284
  "arm": {},
1285
1285
  "armhf": {},
@@ -22,7 +22,7 @@ altnames = set()
22
22
 
23
23
  typelib = SimTypeCollection()
24
24
  typelib.names = ["win32"]
25
- known_struct_names: Set[str] = set()
25
+ known_struct_names: set[str] = set()
26
26
 
27
27
 
28
28
  def is_anonymous_struct(s_name: str) -> bool:
@@ -20,7 +20,7 @@ class JNISimProcedure(SimProcedure):
20
20
  """
21
21
 
22
22
  # Java type of return value
23
- return_ty: typing.Optional[str] = None
23
+ return_ty: str | None = None
24
24
 
25
25
  # jboolean constants
26
26
  JNI_TRUE = 1
@@ -1,5 +1,4 @@
1
1
  import logging
2
- from typing import Optional
3
2
 
4
3
  from . import JNISimProcedure
5
4
  from ...engines.soot.expressions import SimSootExpr_NewArray
@@ -30,7 +29,7 @@ class GetArrayLength(JNISimProcedure):
30
29
 
31
30
 
32
31
  class NewArray(JNISimProcedure):
33
- element_type: Optional[str] = None
32
+ element_type: str | None = None
34
33
  return_ty = "reference"
35
34
 
36
35
  def run(self, ptr_env, length_):
@@ -1,5 +1,4 @@
1
1
  import logging
2
- from typing import Optional
3
2
 
4
3
  from archinfo.arch_soot import ArchSoot, SootAddressDescriptor, SootArgument, SootMethodDescriptor
5
4
 
@@ -38,7 +37,7 @@ class GetMethodID(JNISimProcedure):
38
37
 
39
38
 
40
39
  class CallMethodBase(JNISimProcedure):
41
- return_ty: Optional[str] = None
40
+ return_ty: str | None = None
42
41
 
43
42
  def _invoke(self, method_id, obj=None, dynamic_dispatch=True, args_in_array=None):
44
43
  # get invoke target
@@ -1,5 +1,4 @@
1
1
  from socket import inet_ntoa as _inet_ntoa
2
- from typing import List
3
2
 
4
3
  from claripy import BVS, BVV, Concat
5
4
  from claripy.ast import BV
@@ -28,7 +27,7 @@ class inet_ntoa(angr.SimProcedure):
28
27
  size=self.INET_INADDRSTRLEN,
29
28
  ).rebased_addr
30
29
 
31
- rv_exprs: List[BV] = []
30
+ rv_exprs: list[BV] = []
32
31
  addr_s_in = addr_in["s_addr"]
33
32
 
34
33
  if addr_s_in.concrete:
@@ -1,4 +1,4 @@
1
- from typing import List, Dict, TYPE_CHECKING
1
+ from typing import TYPE_CHECKING
2
2
  from string import digits as ascii_digits
3
3
  import logging
4
4
  import math
@@ -434,7 +434,7 @@ class FormatParser(SimProcedure):
434
434
  return FormatParser._MOD_SPEC
435
435
 
436
436
  @property
437
- def _all_spec(self) -> Dict[bytes, "SimType"]:
437
+ def _all_spec(self) -> dict[bytes, "SimType"]:
438
438
  """
439
439
  All specifiers and their lengths.
440
440
  """
@@ -506,7 +506,7 @@ class FormatParser(SimProcedure):
506
506
 
507
507
  return None
508
508
 
509
- def extract_components(self, fmt: List) -> List:
509
+ def extract_components(self, fmt: list) -> list:
510
510
  """
511
511
  Extract the actual formats from the format string `fmt`.
512
512