Back to index

enigmail  1.4.3
Functions
check_debug_ranges Namespace Reference

Functions

def get_range_for
def get_range_length
def main

Function Documentation

def check_debug_ranges.get_range_for (   compilation_unit,
  debug_info 
)
Returns the range offset for a given compilation unit
   in a given debug_info.

Definition at line 46 of file check_debug_ranges.py.

00046 
00047 def get_range_for(compilation_unit, debug_info):
00048     '''Returns the range offset for a given compilation unit
00049        in a given debug_info.'''
00050     name = ranges = ''
00051     search_cu = False
00052     for nfo in debug_info.splitlines():
00053         if 'DW_TAG_compile_unit' in nfo:
00054             search_cu = True
00055         elif 'DW_TAG_' in nfo or not nfo.strip():
00056             if name == compilation_unit:
00057                 return int(ranges, 16)
00058             name = ranges = ''
00059             search_cu = False
00060         if search_cu:
00061             if 'DW_AT_name' in nfo:
00062                 name = nfo.rsplit(None, 1)[1]
00063             elif 'DW_AT_ranges' in nfo:
00064                 ranges = nfo.rsplit(None, 1)[1]
00065     return None

Here is the caller graph for this function:

def check_debug_ranges.get_range_length (   range,
  debug_ranges 
)
Returns the number of items in the range starting at the
   given offset.

Definition at line 66 of file check_debug_ranges.py.

00066 
00067 def get_range_length(range, debug_ranges):
00068     '''Returns the number of items in the range starting at the
00069        given offset.'''
00070     length = 0
00071     for line in debug_ranges.splitlines():
00072         m = re.match('\s*([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)', line)
00073         if m and int(m.group(1), 16) == range:
00074             length += 1
00075     return length

Here is the caller graph for this function:

def check_debug_ranges.main (   bin,
  compilation_unit 
)

Definition at line 76 of file check_debug_ranges.py.

00076 
00077 def main(bin, compilation_unit):
00078     p = subprocess.Popen(['objdump', '-W', bin], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
00079     (out, err) = p.communicate()
00080     sections = re.split('\n(Contents of the|The section) ', out)
00081     debug_info = [s for s in sections if s.startswith('.debug_info')]
00082     debug_ranges = [s for s in sections if s.startswith('.debug_ranges')]
00083     if not debug_ranges or not debug_info:
00084         return 0
00085 
00086     range = get_range_for(compilation_unit, debug_info[0])
00087     if range is not None:
00088         return get_range_length(range, debug_ranges[0])
00089 
00090     return -1
00091 

Here is the call graph for this function: