Skip to content
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
1 change: 1 addition & 0 deletions chb/app/BasicBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def to_string(
bytes: bool = False,
opcodetxt: bool = True,
opcodewidth: int = 25,
typingrules: bool = False,
sp: bool = True) -> str:
...

Expand Down
2 changes: 1 addition & 1 deletion chb/app/CHVersion.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chbversion: str = "0.3.0-20250714"
chbversion: str = "0.3.0-20250722"
3 changes: 2 additions & 1 deletion chb/app/Function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -604,6 +604,7 @@ def to_string(
opcodewidth: int = 25, # alignment width for opcode text
sp: bool = True,
proofobligations: bool = False,
typingrules: bool = False,
stacklayout: bool = False) -> str:
...

Expand Down
1 change: 1 addition & 0 deletions chb/app/Instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def to_string(
bytes: bool = False,
opcodetxt: bool = True,
opcodewidth: int = 25,
typingrules: bool = False,
sp: bool = True) -> str:
...

Expand Down
9 changes: 8 additions & 1 deletion chb/arm/ARMBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -41,6 +41,7 @@
from chb.invariants.XXpr import XXpr

if TYPE_CHECKING:
from chb.app.AppAccess import AppAccess
from chb.arm.ARMFunction import ARMFunction


Expand All @@ -55,6 +56,10 @@ def __init__(self, armf: "ARMFunction", xnode: ET.Element) -> None:
def armfunction(self) -> "ARMFunction":
return self._armf

@property
def app(self) -> "AppAccess":
return self.armfunction.app

@property
def armdictionary(self) -> ARMDictionary:
return self.armfunction.armdictionary
Expand All @@ -74,13 +79,15 @@ def to_string(
bytes: bool = False,
opcodetxt: bool = True,
opcodewidth: int = 40,
typingrules: bool = False,
sp: bool = True) -> str:
lines: List[str] = []
for (ia, instr) in sorted(self.instructions.items()):
pinstr = instr.to_string(
bytes=bytes,
opcodetxt=opcodetxt,
opcodewidth=opcodewidth,
typingrules=typingrules,
sp=sp)
lines.append(str(ia).rjust(10) + " " + pinstr)
return "\n".join(lines)
Expand Down
9 changes: 8 additions & 1 deletion chb/arm/ARMFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -59,6 +59,7 @@
import chb.util.fileutil as UF

if TYPE_CHECKING:
from chb.app.AppAccess import AppAccess
from chb.cmdline.PatchResults import PatchEvent


Expand Down Expand Up @@ -93,6 +94,10 @@ def __init__(
def armdictionary(self) -> ARMDictionary:
return self._armd

@property
def app(self) -> "AppAccess":
return self.armdictionary.app

@property
def armfunctiondictionary(self) -> FunctionDictionary:
if self._armfnd is None:
Expand Down Expand Up @@ -289,6 +294,7 @@ def to_string(
opcodewidth: int = 40,
sp: bool = True,
proofobligations: bool = False,
typingrules: bool = False,
stacklayout: bool = False) -> str:
lines: List[str] = []
if stacklayout:
Expand All @@ -311,6 +317,7 @@ def to_string(
bytes=bytes,
opcodetxt=opcodetxt,
opcodewidth=opcodewidth,
typingrules=typingrules,
sp=sp))
lines.append("-" * 80)
if self.has_jumptable(self.blocks[b].lastaddr):
Expand Down
18 changes: 17 additions & 1 deletion chb/arm/ARMInstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@


if TYPE_CHECKING:
from chb.app.AppAccess import AppAccess
from chb.arm.ARMBlock import ARMBlock
from chb.arm.ARMFunction import ARMFunction
from chb.arm.ARMJumpTable import ARMJumpTable
Expand Down Expand Up @@ -88,6 +89,10 @@ def armfunction(self) -> "ARMFunction":
def armdictionary(self) -> ARMDictionary:
return self.armblock.armdictionary

@property
def app(self) -> "AppAccess":
return self.armfunction.app

@property
def armfunctiondictionary(self) -> "FunctionDictionary":
return self.armfunction.armfunctiondictionary
Expand Down Expand Up @@ -434,13 +439,24 @@ def to_string(
bytes: bool = False,
opcodetxt: bool = True,
opcodewidth: int = 40,
typingrules: bool = False,
sp: bool = False) -> str:
if typingrules:
lines: List[str] = []
rulesapplied = self.app.type_constraints.rules_applied_to_instruction(
self.armfunction.faddr, self.iaddr)
for r in sorted(str(r) for r in rulesapplied):
lines.append(" " + str(r))
try:
pbytes = self.bytestring.ljust(10) + " " if bytes else ""
pesp = str(self.stackpointer_offset) + " " if sp else ""
popcode = (
self.opcodetext.ljust(opcodewidth) if opcodetxt else "")
return pesp + pbytes + popcode + self.annotation
codeline = pesp + pbytes + popcode + self.annotation
if len(lines) > 0:
return codeline + "\n " + "\n ".join(lines)
else:
return codeline
except Exception as e:
print(
"Error in instruction: "
Expand Down
12 changes: 9 additions & 3 deletions chb/arm/ARMOperand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Aarno Labs LLC
# Copyright (c) 2021-2025 Aarno Labs LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -109,16 +109,22 @@ def offset(self) -> int:
def ast_lvalue(
self,
astree: ASTInterface,
iaddr: Optional[str] = None,
bytestring: Optional[str] = None,
vtype: Optional[AST.ASTTyp] = None) -> Tuple[
AST.ASTLval, List[AST.ASTInstruction], List[AST.ASTInstruction]]:
return self.opkind.ast_lvalue(astree)
return self.opkind.ast_lvalue(
astree, iaddr=iaddr, bytestring=bytestring, vtype=vtype)

def ast_rvalue(
self,
astree: ASTInterface,
iaddr: Optional[str] = None,
bytestring: Optional[str] = None,
vtype: Optional[AST.ASTTyp] = None) -> Tuple[
AST.ASTExpr, List[AST.ASTInstruction], List[AST.ASTInstruction]]:
return self.opkind.ast_rvalue(astree)
return self.opkind.ast_rvalue(
astree, iaddr=iaddr, bytestring=bytestring, vtype=vtype)

def __str__(self) -> str:
return str(self.opkind)
Loading