Beispiel #1
0
 def test_fns_called(self, monkeypatch, pygdb):
     self.call_count = 0
     def callme(self):
         # TODO nasty.. so much state modification
         def inner():
             self.call_count += 1
         return inner
     monkeypatch.setattr(pygdb, 'get_methods', lambda: [('first', callme(self))])
     take_input(pygdb, 'first')
     assert self.call_count == 1
Beispiel #2
0
 def test_breakpoint_set_mem(self, pygdb, capsys):
     take_input(pygdb, 'example')
     take_input(pygdb, 'read 0x8048080 4')
     assert "0x8048080: ['0xcc', '0x7', '0x0', '0x0']" in capsys_output_only(capsys)
     take_input(pygdb, 'set 0x8048080 0x11 0x12')
     take_input(pygdb, 'read 0x8048080 4')
     assert "0x8048080: ['0x11', '0x12', '0x0', '0x0']" in capsys_output_only(capsys)
Beispiel #3
0
 def test_breakpoint_set_mem_cool(self, pygdb, capfd):
     take_input(pygdb, 'example')
     take_input(pygdb, 'set 0x80490b4 0x49')
     take_input(pygdb, 'c')
     assert "Iello," in capfd_output_only(capfd)
Beispiel #4
0
    def test_breakpoint_in_loop(self, pygdb, capsys):
        take_input(pygdb, 'b 0x8048414')
        assert 'NotLoadedException' in capsys_output_only(capsys)
        take_input(pygdb, 'exec-file traced_c_loop')
        take_input(pygdb, 'b 0x8048414')
        assert 'Adding breakpoint at  0x8048414' in capsys_output_only(capsys)

        take_input(pygdb, 'c')
        assert 'NotRunningException' in capsys_output_only(capsys)

        take_input(pygdb, 'run')
        take_input(pygdb, 'regs')
        assert 'eip: 0x8048415' in capsys_output_only(capsys)
        take_input(pygdb, 'c')
        take_input(pygdb, 'c')
        take_input(pygdb, 'c')
        assert 'Child exited' not in capsys_output_only(capsys)
        take_input(pygdb, 'c')
        assert 'Child exited' in capsys_output_only(capsys)
Beispiel #5
0
 def test_arguments_mismatch(self, monkeypatch, pygdb):
     def bad_fn(one, two, three):
         return True
     monkeypatch.setattr(pygdb, 'get_methods', lambda: [('first', bad_fn)])
     assert take_input(pygdb, 'first') == False
Beispiel #6
0
 def test_nomethod(self, monkeypatch, pygdb):
     def bad_fn():
         raise Exception
     monkeypatch.setattr(pygdb, 'get_methods', lambda: [('first', bad_fn)])
     assert take_input(pygdb, 'wrong') == False