Back to index

apport  2.4
Public Member Functions
test_parse_segv.T Class Reference

List of all members.

Public Member Functions

def test_invalid_00_registers
def test_invalid_01_disassembly
def test_ioport_operation
def test_invalid_02_maps
def test_debug
def test_register_values
def test_segv_unknown
def test_segv_pc_missing
def test_segv_pc_null
def test_segv_pc_nx_writable
def test_segv_pc_nx_unwritable
def test_segv_src_missing
def test_segv_src_null
def test_segv_src_not_readable
def test_segv_dest_missing
def test_segv_dest_null
def test_segv_dest_not_writable
def test_segv_crackful_disasm
def test_segv_stack_failure
def test_segv_stack_kernel_segfault

Detailed Description

Test Segfault Parser

Definition at line 122 of file test_parse_segv.py.


Member Function Documentation

Debug mode works

Definition at line 302 of file test_parse_segv.py.

00302 
00303     def test_debug(self):
00304         '''Debug mode works'''
00305 
00306         regs = 'a 0x10'
00307         disasm = 'Dump ...\n0x08083540 <main+0>:    lea    0x4(%esp),%ecx\n'
00308         maps = '''005a3000-005a4000 rw-p 00035000 08:06 65575      /lib/libncurses.so.5.7
00309 00b67000-00b68000 r-xp 00000000 00:00 0          [vdso]
00310 00c67000-00c68000 r--p 00000000 00:00 0 '''
00311 
00312         sys.stderr = tempfile.NamedTemporaryFile(prefix='parse_segv-stderr-')
00313         segv = parse_segv.ParseSegv(regs, disasm, maps, debug=True)
00314         self.assertTrue(segv is not None, segv)

Require valid registers

Definition at line 125 of file test_parse_segv.py.

00125 
00126     def test_invalid_00_registers(self):
00127         '''Require valid registers'''
00128 
00129         regs = 'a 0x10\nb !!!\n'
00130         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, '', '')
00131         try:
00132             segv = parse_segv.ParseSegv(regs, '', '')
00133         except ValueError as e:
00134             self.assertTrue('invalid literal for int()' in str(e), str(e))
00135 
00136         regs = 'a 0x10'
00137         disasm = '0x08083540 <main+0>:    lea    0x4(%esp),%ecx\n'
00138         segv = parse_segv.ParseSegv(regs, disasm, '')
00139         self.assertEqual(segv.regs['a'], 0x10, segv)
00140 
00141         segv.regs = None
00142         self.assertRaises(ValueError, segv.parse_disassembly, '')

Require valid disassembly

Definition at line 143 of file test_parse_segv.py.

00143 
00144     def test_invalid_01_disassembly(self):
00145         '''Require valid disassembly'''
00146         regs = 'a 0x10'
00147 
00148         disasm = ''
00149         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, disasm, '')
00150 
00151         disasm = 'Dump ...'
00152         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, disasm, '')
00153 
00154         disasm = 'Dump ...\nmonkey'
00155         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, disasm, '')
00156 
00157         disasm = 'monkey'
00158         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, disasm, '')
00159 
00160         disasm = '0x1111111111: Cannot access memory at address 0x1111111111\n'
00161         segv = parse_segv.ParseSegv(regs, disasm, '')
00162         self.assertEqual(segv.pc, 0x1111111111, segv.pc)
00163         self.assertEqual(segv.insn, None, segv.insn)
00164         self.assertEqual(segv.src, None, segv.src)
00165         self.assertEqual(segv.dest, None, segv.dest)
00166 
00167         disasm = '0x2111111111: \n'
00168         segv = parse_segv.ParseSegv(regs, disasm, '')
00169         self.assertEqual(segv.pc, 0x2111111111, segv.pc)
00170         self.assertEqual(segv.insn, None, segv.insn)
00171         self.assertEqual(segv.src, None, segv.src)
00172         self.assertEqual(segv.dest, None, segv.dest)
00173 
00174         disasm = '0x8069ff0 <fopen@plt+132220>: cmpb   $0x0,(%eax,%ebx,1)\n'
00175         segv = parse_segv.ParseSegv(regs, disasm, '')
00176         self.assertEqual(segv.pc, 0x8069ff0, segv.pc)
00177         self.assertEqual(segv.insn, 'cmpb', segv.insn)
00178         self.assertEqual(segv.src, '$0x0', segv.src)
00179         self.assertEqual(segv.dest, '(%eax,%ebx,1)', segv.dest)
00180 
00181         disasm = '0xb765bb48 <_XSend+440>:  call   *0x40(%edi)\n'
00182         segv = parse_segv.ParseSegv(regs, disasm, '')
00183         self.assertEqual(segv.pc, 0xb765bb48, segv.pc)
00184         self.assertEqual(segv.insn, 'call', segv.insn)
00185         self.assertEqual(segv.src, '*0x40(%edi)', segv.src)
00186         self.assertEqual(segv.dest, None, segv.dest)
00187 
00188         disasm = '0xb7aae5a0:   call   0xb7a805af <_Unwind_Find_FDE@plt+111>\n'
00189         segv = parse_segv.ParseSegv(regs, disasm, '')
00190         self.assertEqual(segv.pc, 0xb7aae5a0, segv.pc)
00191         self.assertEqual(segv.insn, 'call', segv.insn)
00192         self.assertEqual(segv.src, '0xb7a805af', segv.src)
00193         self.assertEqual(segv.dest, None, segv.dest)
00194 
00195         disasm = '0x09083540:    mov    0x4(%esp),%es:%ecx\n'
00196         segv = parse_segv.ParseSegv(regs, disasm, '')
00197         self.assertEqual(segv.pc, 0x09083540, segv.pc)
00198         self.assertEqual(segv.insn, 'mov', segv.insn)
00199         self.assertEqual(segv.src, '0x4(%esp)', segv.src)
00200         self.assertEqual(segv.dest, '%es:%ecx', segv.dest)
00201 
00202         disasm = '0x08083540 <main+0>:    lea    0x4(%esp),%ecx\n'
00203         segv = parse_segv.ParseSegv(regs, disasm, '')
00204         self.assertEqual(segv.pc, 0x08083540, segv.pc)
00205         self.assertEqual(segv.insn, 'lea', segv.insn)
00206         self.assertEqual(segv.src, '0x4(%esp)', segv.src)
00207         self.assertEqual(segv.dest, '%ecx', segv.dest)
00208 
00209         disasm = '''0x404127 <exo_mount_hal_device_mount+167>:
00210     repz cmpsb %es:(%rdi),%ds:(%rsi)\n'''
00211         segv = parse_segv.ParseSegv(regs, disasm, '')
00212         self.assertEqual(segv.pc, 0x0404127, segv.pc)
00213         self.assertEqual(segv.insn, 'repz cmpsb', segv.insn)
00214         self.assertEqual(segv.src, '%es:(%rdi)', segv.src)
00215         self.assertEqual(segv.dest, '%ds:(%rsi)', segv.dest)
00216 
00217         disasm = '0xb031765a <hufftab16+570>: add    0x3430433,%eax'
00218         segv = parse_segv.ParseSegv(regs, disasm, '')
00219         self.assertEqual(segv.pc, 0xb031765a, segv.pc)
00220         self.assertEqual(segv.insn, 'add', segv.insn)
00221         self.assertEqual(segv.src, '0x3430433', segv.src)
00222         self.assertEqual(segv.dest, '%eax', segv.dest)
00223 
00224         disasm = 'Dump ...\n0x08083540 <main+0>:    lea    0x4(%esp),%ecx\n'
00225         segv = parse_segv.ParseSegv(regs, disasm, '')
00226         self.assertEqual(segv.pc, 0x08083540, segv.pc)
00227         self.assertEqual(segv.insn, 'lea', segv.insn)
00228         self.assertEqual(segv.src, '0x4(%esp)', segv.src)
00229         self.assertEqual(segv.dest, '%ecx', segv.dest)
00230 
00231         disasm = '0x08083550 <main+0>:    nop\n'
00232         segv = parse_segv.ParseSegv(regs, disasm, '')
00233         self.assertEqual(segv.pc, 0x08083550, segv.pc)
00234         self.assertEqual(segv.insn, 'nop', segv.insn)
00235         self.assertEqual(segv.src, None, segv.src)
00236         self.assertEqual(segv.dest, None, segv.dest)
00237 
00238         regs = 'esp 0x444'
00239         disasm = '0x08083560 <main+0>:    push %ecx\n'
00240         segv = parse_segv.ParseSegv(regs, disasm, '')
00241         self.assertEqual(segv.pc, 0x08083560, segv.pc)
00242         self.assertEqual(segv.insn, 'push', segv.insn)
00243         self.assertEqual(segv.src, '%ecx', segv.src)
00244         self.assertEqual(segv.dest, '(%esp)', segv.dest)
00245 
00246         # GDB 7.1
00247         regs = 'esp 0x444'
00248         disasm = '=> 0x08083560 <main+0>:    push %ecx\n'
00249         segv = parse_segv.ParseSegv(regs, disasm, '')
00250         self.assertEqual(segv.pc, 0x08083560, segv.pc)
00251         self.assertEqual(segv.insn, 'push', segv.insn)
00252         self.assertEqual(segv.src, '%ecx', segv.src)
00253         self.assertEqual(segv.dest, '(%esp)', segv.dest)

Require valid maps

Definition at line 275 of file test_parse_segv.py.

00275 
00276     def test_invalid_02_maps(self):
00277         '''Require valid maps'''
00278         regs = 'a 0x10'
00279         disasm = 'Dump ...\n0x08083540 <main+0>:    lea    0x4(%esp),%ecx\n'
00280 
00281         maps = 'asdlkfjaadf'
00282         self.assertRaises(ValueError, parse_segv.ParseSegv, regs, disasm, maps)
00283 
00284         maps = '''005a3000-005a4000 rw-p 00035000 08:06 65575      /lib/libncurses.so.5.7
00285 00b67000-00b68000 r-xp 00000000 00:00 0          [vdso]
00286 00c67000-00c68000 r--p 00000000 00:00 0 '''
00287         segv = parse_segv.ParseSegv(regs, disasm, maps)
00288         self.assertEqual(segv.maps[0]['start'], 0x005a3000, segv)
00289         self.assertEqual(segv.maps[0]['end'], 0x005a4000, segv)
00290         self.assertEqual(segv.maps[0]['perms'], 'rw-p', segv)
00291         self.assertEqual(segv.maps[0]['name'], '/lib/libncurses.so.5.7', segv)
00292 
00293         self.assertEqual(segv.maps[1]['start'], 0x00b67000, segv)
00294         self.assertEqual(segv.maps[1]['end'], 0x00b68000, segv)
00295         self.assertEqual(segv.maps[1]['perms'], 'r-xp', segv)
00296         self.assertEqual(segv.maps[1]['name'], '[vdso]', segv)
00297 
00298         self.assertEqual(segv.maps[2]['start'], 0x00c67000, segv)
00299         self.assertEqual(segv.maps[2]['end'], 0x00c68000, segv)
00300         self.assertEqual(segv.maps[2]['perms'], 'r--p', segv)
00301         self.assertEqual(segv.maps[2]['name'], None, segv)

I/O port violations

Definition at line 254 of file test_parse_segv.py.

00254 
00255     def test_ioport_operation(self):
00256         '''I/O port violations'''
00257 
00258         regs = 'rax            0x3  3'
00259         disasm = '''0x4087f1 <snd_pcm_hw_params_set_channels_near@plt+19345>:
00260     out    %al,$0xb3
00261 '''
00262         maps = '''00400000-00412000 r-xp 00000000 08:04 10371157                           /usr/sbin/pommed
00263 00611000-00614000 rw-p 00011000 08:04 10371157                           /usr/sbin/pommed
00264 00614000-00635000 rw-p 00614000 00:00 0                                  [heap]
00265 '''
00266         segv = parse_segv.ParseSegv(regs, disasm, maps)
00267         self.assertEqual(segv.pc, 0x4087f1, segv.pc)
00268         self.assertEqual(segv.insn, 'out', segv.insn)
00269         self.assertEqual(segv.src, '%al', segv.src)
00270         self.assertEqual(segv.dest, '$0xb3', segv.dest)
00271 
00272         understood, reason, details = segv.report()
00273         self.assertTrue(understood, details)
00274         self.assertTrue('disallowed I/O port operation on port 3' in reason, reason)

Sub-register parsing

Definition at line 315 of file test_parse_segv.py.

00315 
00316     def test_register_values(self):
00317         '''Sub-register parsing'''
00318 
00319         disasm = '''0x08083540 <main+0>:    mov    $1,%ecx'''
00320         segv = parse_segv.ParseSegv(regs64, disasm, '')
00321 
00322         val = segv.register_value('%rdx')
00323         self.assertEqual(val, 0xffffffffff600180, hex(val))
00324         val = segv.register_value('%edx')
00325         self.assertEqual(val, 0xff600180, hex(val))
00326         val = segv.register_value('%dx')
00327         self.assertEqual(val, 0x0180, hex(val))
00328         val = segv.register_value('%dl')
00329         self.assertEqual(val, 0x80, hex(val))

Rejects insane disassemblies

Definition at line 485 of file test_parse_segv.py.

00485 
00486     def test_segv_crackful_disasm(self):
00487         '''Rejects insane disassemblies'''
00488 
00489         disasm = '0x08083547 <main+7>:    pushl  -0x4(blah)'
00490         segv = parse_segv.ParseSegv(regs, disasm, maps)
00491         self.assertRaises(ValueError, segv.report)
00492 
00493         disasm = '0x08083547 <main+7>:    pushl  -04(%ecx)'
00494         segv = parse_segv.ParseSegv(regs, disasm, maps)
00495         self.assertRaises(ValueError, segv.report)

Handles destintation in missing VMA

Definition at line 450 of file test_parse_segv.py.

00450 
00451     def test_segv_dest_missing(self):
00452         '''Handles destintation in missing VMA'''
00453 
00454         reg = regs + 'esp            0x0006af24   0xbfc6af24'
00455         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00456 
00457         segv = parse_segv.ParseSegv(reg, disasm, maps)
00458         understood, reason, details = segv.report()
00459         self.assertTrue(understood, details)
00460         self.assertTrue('destination "(%esp)" (0x0006af24) not located in a known VMA region' in details, details)
00461         self.assertTrue('writing unknown VMA' in reason, reason)

Handles destination not in writable VMA

Definition at line 474 of file test_parse_segv.py.

00474 
00475     def test_segv_dest_not_writable(self):
00476         '''Handles destination not in writable VMA'''
00477 
00478         reg = regs + 'esp            0x08048080   0xbfc6af24'
00479         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00480         segv = parse_segv.ParseSegv(reg, disasm, maps)
00481         understood, reason, details = segv.report()
00482         self.assertTrue(understood, details)
00483         self.assertTrue('destination "(%esp)" (0x08048080) in non-writable VMA region:' in details, details)
00484         self.assertTrue('writing VMA /usr/bin/gdb' in reason, reason)

Handles destintation in NULL VMA

Definition at line 462 of file test_parse_segv.py.

00462 
00463     def test_segv_dest_null(self):
00464         '''Handles destintation in NULL VMA'''
00465 
00466         reg = regs + 'esp            0x00000024   0xbfc6af24'
00467         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00468 
00469         segv = parse_segv.ParseSegv(reg, disasm, maps)
00470         understood, reason, details = segv.report()
00471         self.assertTrue(understood, details)
00472         self.assertTrue('destination "(%esp)" (0x00000024) not located in a known VMA region' in details, details)
00473         self.assertTrue('writing NULL VMA' in reason, reason)

Handles PC in missing VMA

Definition at line 357 of file test_parse_segv.py.

00357 
00358     def test_segv_pc_missing(self):
00359         '''Handles PC in missing VMA'''
00360 
00361         disasm = '''0x00083540 <main+0>:    lea    0x4(%esp),%ecx'''
00362         segv = parse_segv.ParseSegv(regs, disasm, maps)
00363         understood, reason, details = segv.report()
00364         self.assertTrue(understood, details)
00365         self.assertTrue('PC (0x00083540) not located in a known VMA region' in details, details)
00366         self.assertTrue('executing unknown VMA' in reason, reason)
00367 
00368         disasm = '''0x00083544:'''
00369         segv = parse_segv.ParseSegv(regs, disasm, maps)
00370         understood, reason, details = segv.report()
00371         self.assertTrue(understood, details)
00372         self.assertTrue('PC (0x00083544) not located in a known VMA region' in details, details)
00373         self.assertTrue('executing unknown VMA' in reason, reason)

Handles PC in NULL VMA

Definition at line 374 of file test_parse_segv.py.

00374 
00375     def test_segv_pc_null(self):
00376         '''Handles PC in NULL VMA'''
00377 
00378         disasm = '''0x00000540 <main+0>:    lea    0x4(%esp),%ecx'''
00379         segv = parse_segv.ParseSegv(regs, disasm, maps)
00380         understood, reason, details = segv.report()
00381         self.assertTrue(understood, details)
00382         self.assertTrue('PC (0x00000540) not located in a known VMA region' in details, details)
00383         self.assertTrue('executing NULL VMA' in reason, reason)

Handles PC in non-writable NX VMA

Definition at line 394 of file test_parse_segv.py.

00394 
00395     def test_segv_pc_nx_unwritable(self):
00396         '''Handles PC in non-writable NX VMA'''
00397 
00398         disasm = '''0x00dfb000 <main+0>:    lea    0x4(%esp),%ecx'''
00399         segv = parse_segv.ParseSegv(regs, disasm, maps)
00400         understood, reason, details = segv.report()
00401         self.assertTrue(understood, details)
00402         self.assertTrue('PC (0x00dfb000) in non-executable VMA region:' in details, details)
00403         self.assertTrue('executing non-writable VMA /lib/libreadline.so.5.2' in reason, reason)

Handles PC in writable NX VMA

Definition at line 384 of file test_parse_segv.py.

00384 
00385     def test_segv_pc_nx_writable(self):
00386         '''Handles PC in writable NX VMA'''
00387 
00388         disasm = '''0x005a3000 <main+0>:    lea    0x4(%esp),%ecx'''
00389         segv = parse_segv.ParseSegv(regs, disasm, maps)
00390         understood, reason, details = segv.report()
00391         self.assertTrue(understood, details)
00392         self.assertTrue('PC (0x005a3000) in non-executable VMA region:' in details, details)
00393         self.assertTrue('executing writable VMA /lib/libncurses.so.5.7' in reason, reason)

Handles source in missing VMA

Definition at line 404 of file test_parse_segv.py.

00404 
00405     def test_segv_src_missing(self):
00406         '''Handles source in missing VMA'''
00407 
00408         reg = regs + 'ecx            0x0006af24   0xbfc6af24'
00409         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00410 
00411         # Valid crash
00412         segv = parse_segv.ParseSegv(reg, disasm, maps)
00413         understood, reason, details = segv.report()
00414         self.assertTrue(understood, details)
00415         self.assertTrue('source "-0x4(%ecx)" (0x0006af20) not located in a known VMA region' in details, details)
00416         self.assertTrue('reading unknown VMA' in reason, reason)
00417 
00418         # Valid crash
00419         disasm = '0x08083547 <main+7>:    callq  *%ecx'
00420         segv = parse_segv.ParseSegv(reg, disasm, maps)
00421         understood, reason, details = segv.report()
00422         self.assertTrue(understood, details)
00423         self.assertTrue('source "*%ecx" (0x0006af24) not located in a known VMA region' in details, details)
00424         self.assertTrue('reading unknown VMA' in reason, reason)

Handles source not in readable VMA

Definition at line 437 of file test_parse_segv.py.

00437 
00438     def test_segv_src_not_readable(self):
00439         '''Handles source not in readable VMA'''
00440 
00441         reg = regs + 'ecx            0x0026c080   0xbfc6af24'
00442         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00443         segv = parse_segv.ParseSegv(reg, disasm, maps)
00444         understood, reason, details = segv.report()
00445         self.assertTrue(understood, details)
00446         self.assertTrue('source "-0x4(%ecx)" (0x0026c07c) in non-readable VMA region:' in details, details)
00447         self.assertTrue('reading VMA /lib/tls/i686/cmov/libc-2.9.so' in reason, reason)
00448         self.assertFalse('Stack memory exhausted' in details, details)
00449         self.assertFalse('Stack pointer not within stack segment' in details, details)

Handles source in NULL VMA

Definition at line 425 of file test_parse_segv.py.

00425 
00426     def test_segv_src_null(self):
00427         '''Handles source in NULL VMA'''
00428 
00429         reg = regs + 'ecx            0x00000024   0xbfc6af24'
00430         disasm = '0x08083547 <main+7>:    pushl  -0x4(%ecx)'
00431 
00432         segv = parse_segv.ParseSegv(reg, disasm, maps)
00433         understood, reason, details = segv.report()
00434         self.assertTrue(understood, details)
00435         self.assertTrue('source "-0x4(%ecx)" (0x00000020) not located in a known VMA region' in details, details)
00436         self.assertTrue('reading NULL VMA' in reason, reason)

Handles walking off the stack

Definition at line 496 of file test_parse_segv.py.

00496 
00497     def test_segv_stack_failure(self):
00498         '''Handles walking off the stack'''
00499 
00500         # Triggered via "push"
00501         reg = regs + 'esp            0xbfc56ff0   0xbfc56ff0'
00502         disasm = '0x08083547 <main+7>:    push  %eax'
00503         segv = parse_segv.ParseSegv(reg, disasm, maps)
00504         understood, reason, details = segv.report()
00505         self.assertTrue(understood, details)
00506         self.assertTrue('destination "(%esp)" (0xbfc56ff0) not located in a known VMA region (needed writable region)!' in details, details)
00507 
00508         # Triggered via "call"
00509         reg = regs + 'esp            0xbfc56fff   0xbfc56fff'
00510         disasm = '0x08083547 <main+7>:    callq  0x08083540'
00511         segv = parse_segv.ParseSegv(reg, disasm, maps)
00512         understood, reason, details = segv.report()
00513         self.assertTrue(understood, details)
00514         self.assertTrue('destination "(%esp)" (0xbfc56fff) not located in a known VMA region (needed writable region)!' in details, details)
00515         self.assertTrue('Stack memory exhausted' in details, details)
00516 
00517         # Triggered via unknown reason
00518         reg = regs + 'esp            0xdfc56000   0xdfc56000'
00519         disasm = '''0x08083540 <main+0>:    mov    $1,%rcx'''
00520         segv = parse_segv.ParseSegv(reg, disasm, maps)
00521         understood, reason, details = segv.report()
00522         self.assertTrue(understood, details)
00523         self.assertTrue('SP (0xdfc56000) not located in a known VMA region (needed readable region)!' in details, details)
00524         self.assertTrue('Stack pointer not within stack segment' in details, details)

Handles unknown segfaults in kernel

Definition at line 525 of file test_parse_segv.py.

00525 
00526     def test_segv_stack_kernel_segfault(self):
00527         '''Handles unknown segfaults in kernel'''
00528 
00529         # Crash in valid code path
00530         disasm = '''0x0056e010: ret'''
00531         segv = parse_segv.ParseSegv(regs, disasm, maps)
00532         understood, reason, details = segv.report()
00533         self.assertFalse(understood, details)
00534         self.assertTrue('Reason could not be automatically determined.' in details, details)
00535         self.assertFalse('(Unhandled exception in kernel code?)' in details, details)
00536 
00537         # Crash from kernel code path
00538         disasm = '''0x00b67422 <__kernel_vsyscall+2>: ret'''
00539         segv = parse_segv.ParseSegv(regs, disasm, maps)
00540         understood, reason, details = segv.report()
00541         self.assertFalse(understood, details)
00542         self.assertTrue('Reason could not be automatically determined. (Unhandled exception in kernel code?)' in details, details)
00543 
00544 
00545 unittest.main()
Handles unknown segfaults

Definition at line 330 of file test_parse_segv.py.

00330 
00331     def test_segv_unknown(self):
00332         '''Handles unknown segfaults'''
00333 
00334         disasm = '''0x08083540 <main+0>:    mov    $1,%ecx'''
00335         segv = parse_segv.ParseSegv(regs, disasm, maps)
00336         understood, reason, details = segv.report()
00337         self.assertFalse(understood, details)
00338 
00339         # Verify calculations
00340         self.assertEqual(segv.calculate_arg('(%ecx)'), 0xbfc6af40, segv.regs['ecx'])
00341         self.assertEqual(segv.calculate_arg('0x10(%ecx)'), 0xbfc6af50, segv.regs['ecx'])
00342         self.assertEqual(segv.calculate_arg('-0x20(%ecx)'), 0xbfc6af20, segv.regs['ecx'])
00343         self.assertEqual(segv.calculate_arg('%fs:(%ecx)'), 0xbfc6af44, segv.regs['ecx'])
00344         self.assertEqual(segv.calculate_arg('0x3404403'), 0x3404403, '0x3404403')
00345         self.assertEqual(segv.calculate_arg('*0x40(%edi)'), 0x80834c0, segv.regs['edi'])
00346         self.assertEqual(segv.calculate_arg('(%edx,%ebx,1)'), 0x26eff5, segv.regs['ebx'])
00347         self.assertEqual(segv.calculate_arg('(%eax,%ebx,1)'), 0x26eff3, segv.regs['ebx'])
00348         self.assertEqual(segv.calculate_arg('0x10(,%ebx,1)'), 0x26f004, segv.regs['ebx'])
00349 
00350         # Again, but 64bit
00351         disasm = '''0x08083540 <main+0>:    mov    $1,%rcx'''
00352         segv = parse_segv.ParseSegv(regs64, disasm, maps)
00353         understood, reason, details = segv.report()
00354         self.assertFalse(understood, details)
00355 
00356         self.assertEqual(segv.calculate_arg('(%rax,%rbx,1)'), 0x26eff3, segv.regs['rbx'])


The documentation for this class was generated from the following file: