(self)
| 260 | dbg.quit_and_wait() |
| 261 | |
| 262 | def test_assembly_code(self): |
| 263 | if self.arch == 'x86_64': |
| 264 | fpath = name_to_fpath('asmtest', 'x86_64') |
| 265 | bv = load(fpath) |
| 266 | dbg = DebuggerController(bv) |
| 267 | self.assertNotIn(dbg.launch_and_wait(), [DebugStopReason.ProcessExited, DebugStopReason.InternalError]) |
| 268 | entry = dbg.data.entry_point |
| 269 | self.assertEqual(dbg.ip, entry) |
| 270 | |
| 271 | # TODO: we can use BN to disassemble the binary and find out how long is the instruction |
| 272 | # step into nop |
| 273 | dbg.step_into_and_wait() |
| 274 | self.assertEqual(dbg.ip, entry+1) |
| 275 | # step into call, return |
| 276 | dbg.step_into_and_wait() |
| 277 | dbg.step_into_and_wait() |
| 278 | # back |
| 279 | self.assertEqual(dbg.ip, entry+6) |
| 280 | dbg.step_into_and_wait() |
| 281 | # step into call, return |
| 282 | dbg.step_into_and_wait() |
| 283 | dbg.step_into_and_wait() |
| 284 | # back |
| 285 | self.assertEqual(dbg.ip, entry+12) |
| 286 | |
| 287 | reason = dbg.go_and_wait() |
| 288 | self.assertEqual(reason, DebugStopReason.ProcessExited) |
| 289 | |
| 290 | @unittest.skipIf(platform.system() == 'Linux', 'Cannot attach to pid unless running as root') |
| 291 | def test_attach(self): |
nothing calls this directly
no test coverage detected