本文整理汇总了Python中angr.SimState.with_condition方法的典型用法代码示例。如果您正苦于以下问题:Python SimState.with_condition方法的具体用法?Python SimState.with_condition怎么用?Python SimState.with_condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angr.SimState
的用法示例。
在下文中一共展示了SimState.with_condition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_global_condition
# 需要导入模块: from angr import SimState [as 别名]
# 或者: from angr.SimState import with_condition [as 别名]
def test_global_condition():
s = SimState(arch="AMD64")
s.regs.rax = 10
old_rax = s.regs.rax
with s.with_condition(False):
nose.tools.assert_false(s.se.satisfiable())
s.regs.rax = 20
nose.tools.assert_is(s._global_condition, None)
nose.tools.assert_is(old_rax, s.regs.rax)
with s.with_condition(True):
s.regs.rax = 20
nose.tools.assert_is(s._global_condition, None)
nose.tools.assert_is_not(old_rax, s.regs.rax)
nose.tools.assert_is(s.se.BVV(20, s.arch.bits), s.regs.rax)
with s.with_condition(s.regs.rbx != 0):
s.regs.rax = 25
nose.tools.assert_is(s._global_condition, None)
nose.tools.assert_is_not(s.se.BVV(25, s.arch.bits), s.regs.rax)
with s.with_condition(s.regs.rbx != 1):
s.regs.rax = 30
nose.tools.assert_is(s._global_condition, None)
nose.tools.assert_is_not(s.se.BVV(30, s.arch.bits), s.regs.rax)
with s.with_condition(s.regs.rbx == 0):
nose.tools.assert_equals(s.se.eval_upto(s.regs.rbx, 10), [ 0 ])
nose.tools.assert_items_equal(s.se.eval_upto(s.regs.rax, 10), [ 30 ])
with s.with_condition(s.regs.rbx == 1):
nose.tools.assert_equals(s.se.eval_upto(s.regs.rbx, 10), [ 1 ])
nose.tools.assert_items_equal(s.se.eval_upto(s.regs.rax, 10), [ 25 ])