#-------------------------------------------------------------------------------
__version__ = '0.21'
-
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import maxint, bytes2str
from elftools.elf.elffile import ELFFile
def decode_funcname(dwarfinfo, address):
# Go over all DIEs in the DWARF information, looking for a subprogram
# entry with an address range that includes the given address. Note that
- # this simplifies things by disregarding subprograms that may have
+ # this simplifies things by disregarding subprograms that may have
# split address ranges.
for CU in dwarfinfo.iter_CUs():
for DIE in CU.iter_DIEs():
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import itervalues
from elftools.elf.elffile import ELFFile
else:
d.append(str(loc_entity))
return '\n'.join(indent + s for s in d)
-
+
def attribute_has_location_list(attr):
""" Only some attributes can have location list values, if they have the
#-------------------------------------------------------------------------------
# elftools example: dwarf_range_lists.py
#
-# Examine DIE entries which have range list values, and decode these range
+# Examine DIE entries which have range list values, and decode these range
# lists.
#
# Eli Bendersky (eliben@gmail.com)
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import itervalues
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.elf.elffile import ELFFile
try:
import elftools
except ImportError:
- sys.path.extend(['.', '..'])
+ sys.path[0:0] = ['.', '..']
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile
from optparse import OptionParser
import string
-# If we're running from the root of the development directory, elftools should
-# be loaded from there.
+# For running from development directory.
sys.path.insert(0, '.')
+
from elftools import __version__
from elftools.common.exceptions import ELFError
from elftools.common.py3compat import (
if __name__ == '__main__':
- try:
+ import os
+ if not os.path.isdir('test'):
+ print('!! Please execute from the root directory of pyelftools')
+ else:
tests = unittest.TestLoader().discover('test', 'test*.py', 'test')
unittest.TextTestRunner().run(tests)
- except ImportError as err:
- print(err)
- print('!! Please execute from the root directory of pyelftools')
-
-
#-------------------------------------------------------------------------------
import os, sys
import logging
-
-from test.utils import run_exe, is_in_rootdir, dump_output_to_temp_files
+from utils import setup_syspath; setup_syspath()
+from utils import run_exe, is_in_rootdir, dump_output_to_temp_files
# Create a global logger object
from optparse import OptionParser
import logging
import platform
-from test.utils import run_exe, is_in_rootdir, dump_output_to_temp_files
+from utils import setup_syspath; setup_syspath()
+from utils import run_exe, is_in_rootdir, dump_output_to_temp_files
# Create a global logger object
if __name__ == '__main__':
sys.exit(main())
-
-
-
import unittest
import os
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.elf.elffile import ELFFile
class TestARMSupport(unittest.TestCase):
except ImportError:
import unittest
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.common.py3compat import BytesIO
from elftools.dwarf.callframe import (
CallFrameInfo, CIE, FDE, instruction_name, CallFrameInstruction,
except ImportError:
import unittest
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.dwarf.descriptions import ExprDumper, set_global_machine_arch
from elftools.dwarf.structs import DWARFStructs
except ImportError:
import unittest
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.common.py3compat import BytesIO, iteritems
from elftools.dwarf.lineprogram import LineProgram, LineState, LineProgramEntry
from elftools.dwarf.structs import DWARFStructs
except ImportError:
import unittest
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.dwarf.structs import DWARFStructs
import unittest
from random import randint
-from test.utils import setup_syspath; setup_syspath()
+from utils import setup_syspath; setup_syspath()
from elftools.common.py3compat import int2byte, BytesIO
from elftools.common.utils import (parse_cstring_from_stream,
preserve_stream_pos)
# This code is in the public domain
#-------------------------------------------------------------------------------
import os, sys, subprocess, tempfile
-from elftools.common.py3compat import bytes2str
+# This module should not import elftools before setup_syspath() is called!
+# See the Hacking Guide in the documentation for more details.
def setup_syspath():
""" Setup sys.path so that tests pick up local pyelftools before the
popen_cmd.insert(0, sys.executable)
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE)
proc_stdout = proc.communicate()[0]
+ from elftools.common.py3compat import bytes2str
return proc.returncode, bytes2str(proc_stdout)