some documentation for the dwarf_expr module
[pyelftools.git] / z.py
1 # Just a script for playing around with pyelftools during testing
2 # please ignore it!
3 #
4
5 import sys, pprint
6 from elftools.elf.structs import ELFStructs
7 from elftools.elf.elffile import ELFFile
8 from elftools.elf.sections import *
9
10 from elftools.elf.relocation import *
11
12 # read a little-endian, 64-bit file
13 es = ELFStructs(True, 64)
14
15 stream = open('tests/testfiles/exe_simple64.elf', 'rb')
16 #stream = open('binfiles/z32.elf', 'rb')
17
18 efile = ELFFile(stream)
19 print 'elfclass', efile.elfclass
20 print '===> %s sections!' % efile.num_sections()
21
22 #~ print efile.has_dwarf_info()
23
24 dwarfinfo = efile.get_dwarf_info()
25 CUs = list(dwarfinfo.iter_CUs())
26 print 'num CUs:', len(CUs)
27 print 'CU:', CUs[2]
28
29 lp = dwarfinfo.line_program_for_CU(CUs[2])
30 print 'lp:', lp, lp.header
31 print 'linetable:', lp.get_line_table()
32 #for lp in dwarfinfo.iter_line_programs():
33 #print lp
34 #print lp.header
35