Beispiel #1
0
    def test_adding_classes(self):
        old = read_objdump('examples/objdump/add-classes/tracer.old')
        new = read_objdump('examples/objdump/add-classes/tracer.new')
        peers = FunctionMatchupSet(old, new)
        # Verify that it matches up various functions that become
        # methods of class tracer_state:
        self.assertEqual(peers.gone, [])
        self.assertEqual(peers.appeared, [])

        oldfn = old.get_demangled_function(
            'find_best_predecessor(basic_block_def*)')
        newfn = peers.old_to_new[oldfn]

        oldinstr = oldfn.get_instr_at_relative_offset(0xaa)
        newinstr = newfn.get_instr_at_relative_offset(0xaa)
        # This changes from:
        #  FN+0xaa: Old: callq  3e1 <ignore_bb_p(basic_block_def const*)>
        #         : New: callq  353 <ignore_bb_p(basic_block_def const*)>
        # which isn't really a change
        self.assertEqual(oldinstr.disasm, 'callq  <ignore_bb_p(basic_block_def const*)>')
        self.assertEqual(newinstr.disasm, 'callq  <ignore_bb_p(basic_block_def const*)>')

        out = self.get_diff(old, new)
        self.assertIn(('\n'
                       '  Changed function: tail_duplicate()\n'
                       '    (renamed to tracer_state::tail_duplicate())\n'),
                      out)
Beispiel #2
0
 def test_size_diff(self):
     old = read_objdump('examples/objdump/add-classes/tracer.old')
     new = read_objdump('examples/objdump/add-classes/tracer.new')
     out = self.get_diff(old, new, just_sizes=True)
     self.assertEqual(out,
                      ('Old: examples/objdump/add-classes/tracer.old\n'
                       'New: examples/objdump/add-classes/tracer.new\n'))
Beispiel #3
0
 def test_size_diff(self):
     old = read_objdump('examples/objdump/add-classes/tracer.old')
     new = read_objdump('examples/objdump/add-classes/tracer.new')
     out = self.get_diff(old, new, just_sizes=True)
     self.assertEqual(out,
                      ('Old: examples/objdump/add-classes/tracer.old\n'
                       'New: examples/objdump/add-classes/tracer.new\n'))
Beispiel #4
0
    def test_adding_classes(self):
        old = read_objdump('examples/objdump/add-classes/tracer.old')
        new = read_objdump('examples/objdump/add-classes/tracer.new')
        peers = FunctionMatchupSet(old, new)
        # Verify that it matches up various functions that become
        # methods of class tracer_state:
        self.assertEqual(peers.gone, [])
        self.assertEqual(peers.appeared, [])

        oldfn = old.get_demangled_function(
            'find_best_predecessor(basic_block_def*)')
        newfn = peers.old_to_new[oldfn]

        oldinstr = oldfn.get_instr_at_relative_offset(0xaa)
        newinstr = newfn.get_instr_at_relative_offset(0xaa)
        # This changes from:
        #  FN+0xaa: Old: callq  3e1 <ignore_bb_p(basic_block_def const*)>
        #         : New: callq  353 <ignore_bb_p(basic_block_def const*)>
        # which isn't really a change
        self.assertEqual(oldinstr.disasm,
                         'callq  <ignore_bb_p(basic_block_def const*)>')
        self.assertEqual(newinstr.disasm,
                         'callq  <ignore_bb_p(basic_block_def const*)>')

        out = self.get_diff(old, new)
        self.assertIn(('\n'
                       '  Changed function: tail_duplicate()\n'
                       '    (renamed to tracer_state::tail_duplicate())\n'),
                      out)
Beispiel #5
0
 def test_demangling(self):
     asm = read_objdump('examples/objdump/add-classes/tracer.new')
     RAWNAME = '_ZN12tracer_state19find_best_successorEP15basic_block_def'
     self.assertIn(RAWNAME, asm.functions)
     fn = asm.functions[RAWNAME]
     self.assertEqual(fn.rawname, RAWNAME)
     self.assertEqual(fn.demangled,
                      'tracer_state::find_best_successor(basic_block_def*)')
     self.assertEqual(fn.offset, 0x560)
     self.assertEqual(fn.section.name, '.text')
Beispiel #6
0
 def test_demangling(self):
     asm = read_objdump('examples/objdump/add-classes/tracer.new')
     RAWNAME = '_ZN12tracer_state19find_best_successorEP15basic_block_def'
     self.assertIn(RAWNAME, asm.functions)
     fn = asm.functions[RAWNAME]
     self.assertEqual(fn.rawname, RAWNAME)
     self.assertEqual(
         fn.demangled,
         'tracer_state::find_best_successor(basic_block_def*)')
     self.assertEqual(fn.offset, 0x560)
     self.assertEqual(fn.section.name, '.text')
Beispiel #7
0
 def parse_objdump(self):
     # This is the output from "objdump -Cd"
     # i.e. it's already gone through demangling
     return read_objdump('examples/objdump/isra/tracer.old')
Beispiel #8
0
 def read_anon_namespace_files(self):
     old = read_objdump('examples/objdump/anon-namespace/tracer.old')
     new = read_objdump('examples/objdump/anon-namespace/tracer.new')
     return old, new
Beispiel #9
0
 def parse_objdump(self):
     # This is the output from "objdump -Cd"
     # i.e. it's already gone through demangling
     return read_objdump('examples/objdump/isra/tracer.old')
Beispiel #10
0
 def read_anon_namespace_files(self):
     old = read_objdump('examples/objdump/anon-namespace/tracer.old')
     new = read_objdump('examples/objdump/anon-namespace/tracer.new')
     return old, new