8000 Make pypcode required by twizmwazin · Pull Request #5471 · angr/angr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make pypcode required #5471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions angr/analyses/disassembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from collections.abc import Sequence
from typing import Any

import pyvex
import archinfo
import pypcode
import pyvex

from . import Analysis

from angr.analyses import AnalysesHub
from angr.engines import pcode
from angr.errors import AngrTypeError
from angr.knowledge_plugins import Function
from angr.utils.library import get_cpp_function_name
Expand All @@ -20,16 +21,9 @@
from angr.codenode import BlockNode
from .disassembly_utils import decode_instruction

try:
from angr.engines import pcode
import pypcode

IRSBType = pyvex.IRSB | pcode.lifter.IRSB
IROpObjType = pyvex.stmt.IRStmt | pypcode.PcodeOp
except ImportError:
pcode = None
IRSBType = pyvex.IRSB
IROpObjType = pyvex.stmt
IRSBType = pyvex.IRSB | pcode.lifter.IRSB
IROpObjType = pyvex.stmt.IRStmt | pypcode.PcodeOp

l = logging.getLogger(name=__name__)

Expand Down
10 changes: 3 additions & 7 deletions angr/analyses/stack_pointer_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import logging
from collections import defaultdict

from archinfo.arch_arm import is_arm_arch
import pypcode
import pyvex
from archinfo.arch_arm import is_arm_arch

from angr.analyses import ForwardAnalysis, visitors
from angr.engines import pcode
from angr.utils.constants import is_alignment_mask
from angr.analyses import AnalysesHub
from angr.knowledge_plugins import Function
Expand All @@ -21,12 +23,6 @@

from .analysis import Analysis

try:
import pypcode
from angr.engines import pcode
except ImportError:
pypcode = None
pcode = None

if TYPE_CHECKING:
from angr.block import Block
Expand Down
5 changes: 1 addition & 4 deletions angr/engines/pcode/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

import claripy
from claripy.ast.bv import BV
from pypcode import OpCode

from angr.errors import AngrError

try:
from pypcode import OpCode
except ImportError:
OpCode = None

# pylint:disable=abstract-method

Expand Down
5 changes: 1 addition & 4 deletions angr/engines/pcode/emulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@

import claripy
from claripy.ast.bv import BV
from pypcode import OpCode, Varnode, PcodeOp

from angr.engines.engine import SimEngine
from angr.utils.constants import DEFAULT_STATEMENT
from .lifter import IRSB
from .behavior import OpBehavior
from angr.errors import AngrError
from angr.state_plugins.inspect import BP_BEFORE, BP_AFTER
import contextlib

with contextlib.suppress(ImportError):
from pypcode import OpCode, Varnode, PcodeOp


l = logging.getLogger(__name__)
Expand Down
12 changes: 2 additions & 10 deletions angr/engines/pcode/lifter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from collections.abc import Iterable, Sequence

import archinfo
from archinfo import ArchARM, ArchPcode
import cle
import pypcode
from archinfo import ArchARM, ArchPcode
from cachetools import LRUCache

# FIXME: Reusing these errors from pyvex for compatibility. Eventually these
Expand All @@ -28,16 +29,7 @@
from angr import sim_options as o
from angr.block import DisassemblerBlock, DisassemblerInsn


try:
import pypcode
except ImportError:
pypcode = None


if TYPE_CHECKING:
# this is to make pyright happy; otherwise it believes pypcode is None
import pypcode
from pypcode import PcodeOp, Context


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies = [
"pycparser>=2.18",
"pydemumble",
"pyformlang",
"pypcode>=3.2.1,<4.0",
"pyvex==9.2.157.dev0",
"rich>=13.1.0",
"sortedcontainers",
Expand All @@ -52,7 +53,6 @@ Repository = "https://github.com/angr/angr"

[project.optional-dependencies]
angrdb = ["sqlalchemy"]
pcode = ["pypcode~=3.0"]
keystone = ["keystone-engine"]
telemetry = ["opentelemetry-api"]
unicorn = ["unicorn==2.0.1.post1"]
Expand All @@ -72,7 +72,7 @@ dev = [
"ruff>=0.11.7",
]
docs = ["furo", "myst-parser", "sphinx", "sphinx-autodoc-typehints"]
extras = ["angr[angrdb,keystone,pcode]"]
extras = ["angr[angrdb,keystone]"]

[tool.setuptools]
include-package-data = true
Expand Down
12 changes: 4 additions & 8 deletions tests/engines/pcode/test_emulate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import logging
import unittest
import operator
import unittest
from dataclasses import dataclass

import claripy
import pypcode
from pypcode import OpCode

import angr
from angr.engines.pcode.behavior import BehaviorFactory
Expand All @@ -13,13 +16,6 @@
from angr.engines import SimSuccessors


try:
import pypcode
from pypcode import OpCode
except ImportError:
pypcode = None


log = logging.getLogger(__name__)


Expand Down
10 changes: 4 additions & 6 deletions tests/engines/pcode/test_pcode.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env python3
from __future__ import annotations
from unittest import TestCase, skipUnless, main

import os
from unittest import TestCase, skipUnless, main

import archinfo
import angr
import pypcode

try:
import pypcode
except ModuleNotFoundError:
pypcode = None
import angr


test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "..", "..", "binaries", "tests")
Expand Down
Loading
0