renamed 'location expression' to the more general 'dwarf expression'
diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py
index 57df8a4..4f88bf3 100644
--- a/elftools/dwarf/descriptions.py
+++ b/elftools/dwarf/descriptions.py
@@ -9,7 +9,7 @@
from collections import defaultdict
from .constants import *
-from .location_expr import LocationExpressionDumper
+from .dwarf_expr import ExprDumper
from .die import DIE
from ..common.utils import preserve_stream_pos
@@ -214,7 +214,7 @@
return extra
-_LOCATION_EXPR_DUMPER_CACHE = {}
+_DWARF_EXPR_DUMPER_CACHE = {}
def _location_list_extra(attr, die, section_offset):
# According to section 2.6 of the DWARF spec v3, class loclistptr means
@@ -228,13 +228,13 @@
# caching scheme is in place to create only one such dumper per
# processed CU.
cache_key = id(die.cu.structs)
- if cache_key not in _LOCATION_EXPR_DUMPER_CACHE:
- _LOCATION_EXPR_DUMPER_CACHE[cache_key] = \
- LocationExpressionDumper(die.cu.structs)
- location_expr_dumper = _LOCATION_EXPR_DUMPER_CACHE[cache_key]
- location_expr_dumper.clear()
- location_expr_dumper.process_expr(attr.value)
- return '(' + location_expr_dumper.get_str() + ')'
+ if cache_key not in _DWARF_EXPR_DUMPER_CACHE:
+ _DWARF_EXPR_DUMPER_CACHE[cache_key] = \
+ ExprDumper(die.cu.structs)
+ dwarf_expr_dumper = _DWARF_EXPR_DUMPER_CACHE[cache_key]
+ dwarf_expr_dumper.clear()
+ dwarf_expr_dumper.process_expr(attr.value)
+ return '(' + dwarf_expr_dumper.get_str() + ')'
def _import_extra(attr, die, section_offset):
diff --git a/elftools/dwarf/location_expr.py b/elftools/dwarf/dwarf_expr.py
similarity index 96%
rename from elftools/dwarf/location_expr.py
rename to elftools/dwarf/dwarf_expr.py
index 1d92da3..6140d20 100644
--- a/elftools/dwarf/location_expr.py
+++ b/elftools/dwarf/dwarf_expr.py
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
-# elftools: dwarf/location_expr.py
+# elftools: dwarf/dwarf_expr.py
#
-# Decoding DWARF location expressions
+# Decoding DWARF expressions
#
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
@@ -11,7 +11,7 @@
from ..common.utils import struct_parse, bytelist2string
-# Location expression opcodes. name -> opcode mapping
+# DWARF expression opcodes. name -> opcode mapping
DW_OP_name2opcode = dict(
DW_OP_addr=0x03,
DW_OP_deref=0x06,
@@ -89,7 +89,7 @@
DW_OP_opcode2name = dict((v, k) for k, v in DW_OP_name2opcode.iteritems())
-class GenericLocationExprVisitor(object):
+class GenericExprVisitor(object):
def __init__(self, structs):
self.structs = structs
self._init_dispatch_table()
@@ -99,7 +99,7 @@
self._cur_args = []
def process_expr(self, loc_expr):
- """ Process (visit) a location expression. Currently two possible
+ """ Process (visit) a DWARF expression. Currently two possible
types are supported for expr:
1. File-like stream object
@@ -249,9 +249,9 @@
self._make_visitor_arg_struct(self.structs.Dwarf_offset('')))
-class LocationExpressionDumper(GenericLocationExprVisitor):
+class ExprDumper(GenericExprVisitor):
def __init__(self, structs):
- super(LocationExpressionDumper, self).__init__(structs)
+ super(ExprDumper, self).__init__(structs)
self._init_lookups()
self._str_parts = []
diff --git a/tests/test_dwarf_location_expr.py b/tests/test_dwarf_expr.py
similarity index 90%
rename from tests/test_dwarf_location_expr.py
rename to tests/test_dwarf_expr.py
index d0d6ab0..4202633 100644
--- a/tests/test_dwarf_location_expr.py
+++ b/tests/test_dwarf_expr.py
@@ -2,18 +2,18 @@
from cStringIO import StringIO
sys.path.extend(('..', '.'))
-from elftools.dwarf.location_expr import LocationExpressionDumper
+from elftools.dwarf.dwarf_expr import ExprDumper
from elftools.dwarf.structs import DWARFStructs
-class TestLocationExpressionDumper(unittest.TestCase):
+class TestExprDumper(unittest.TestCase):
structs32 = DWARFStructs(
little_endian=True,
dwarf_format=32,
address_size=4)
def setUp(self):
- self.visitor = LocationExpressionDumper(self.structs32)
+ self.visitor = ExprDumper(self.structs32)
def test_basic_single(self):
self.visitor.process_expr([0x1b])