[csw-devel] SF.net SVN: gar:[19278] csw/mgar/gar/v2-yann/lib/python

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Sat Sep 22 18:38:28 CEST 2012


Revision: 19278
          http://gar.svn.sourceforge.net/gar/?rev=19278&view=rev
Author:   chninkel
Date:     2012-09-22 16:38:28 +0000 (Sat, 22 Sep 2012)
Log Message:
-----------
simplified elf_info parsing

Modified Paths:
--------------
    csw/mgar/gar/v2-yann/lib/python/inspective_package.py
    csw/mgar/gar/v2-yann/lib/python/inspective_package_test.py

Modified: csw/mgar/gar/v2-yann/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-22 16:26:07 UTC (rev 19277)
+++ csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-22 16:38:28 UTC (rev 19278)
@@ -271,46 +271,17 @@
       binary_info = {'version definition': [],
                      'version needed': []}
 
-      # The list of fields we want to retrieve in the elfdump output by section
-      # the key is the original field name
-      # the value is the destination field name
-      elf_fields = {'version definition': {
-                      'version': 'version',
-                      'dependency': 'dependency',
-                      },
-                    'version needed': {
-                      'file': 'soname',
-                      'version': 'version',
-                      },
-                    'symbol table': {
-                      'name': 'symbol',
-                      'ver': 'version',
-                      'type': 'type',
-                      'bind': 'bind',
-                      'shndx': 'shndx',
-                      },
-                    'syminfo': {
-                      'library': 'soname',
-                      'symbol': 'symbol',
-                      'flags': 'flags',
-                      }
-                    }
-
       cur_section = None
       for line in elfdump_out:
 
-        elfdump_data, cur_section = self._ParseElfdumpLine(line, cur_section)
+        elf_info, cur_section = self._ParseElfdumpLine(line, cur_section)
 
         # header or blank line contains no information
-        if not elfdump_data:
+        if not elf_info:
           continue
 
-        elf_info = {}
-        for src_field, dest_field in elf_fields[cur_section].items():
-          elf_info[dest_field] = elfdump_data[src_field]
-
         # symbol table and syminfo section store various informations
-        # about the same symbols, we merge them in a dict
+        # about the same symbols, so we merge them in a dict
         if cur_section in ('symbol table', 'syminfo'):
           symbols.setdefault(elf_info['symbol'], {}).update(elf_info)
         else:
@@ -433,22 +404,22 @@
 
     re_by_section = {
       'version definition': (r"""
-        \s*(?:\[(?P<index>\d+)\]\s+)? # index might be not present
+        \s*(?:\[\d+\]\s+)?            # index might be not present
                                       # if no version binding is enabled
         (?P<version>\S+)
         (?:\s+(?P<dependency>\S+))?
-        (?:\s+\[\s(?:BASE)\s\])?\s*$ #
+        (?:\s+\[\s(?:BASE)\s\])?\s*$
                               """),
       'version needed': (r"""
-        \s*(?:\[(?P<index>\d+)\]\s+)?     # index might be not present
+        \s*(?:\[\d+\]\s+)?     # index might be not present
                                           # if no version binding is enabled
 
-        (?:(?P<file>\S+)\s+               # file can be absent if the same as
+        (?:(?P<soname>\S+)\s+             # file can be absent if the same as
          (?!\[\s(?:INFO|WEAK)\s\]))?      # the previous line, we make sure
                                           # version is not confused with file
                                           # in that case
         (?P<version>\S+)
-        (?:\s+\[\s(?:INFO|WEAK)\s\])?\s*$ #
+        (?:\s+\[\s(?:INFO|WEAK)\s\])?\s*$
                           """),
       'symbol table': (r"""
          \s*\[\d+\]
@@ -457,15 +428,15 @@
          \s+(?P<type>\S+)
          \s+(?P<bind>\S+)
          \s+\S+
-         \s+(?P<ver>\S+)
+         \s+(?P<version>\S+)
          \s+(?P<shndx>\S+)
-         (?:\s+(?P<name>\S+))?\s*$
+         (?:\s+(?P<symbol>\S+))?\s*$
                         """),
       'syminfo': (r"""
          \s*\[\d+\]
          \s+(?P<flags>[ABCDFILNPS]+)
          \s+(?:(?:\[\d+\]                   # some kind of library index
-         \s+(?P<library>\S+)|<self>)\s+)?  # library is not present
+         \s+(?P<soname>\S+)|<self>)\s+)?    # library is not present
                                             # for external symbols not
                                             # directly bound
          (?P<symbol>\S+)\s*

Modified: csw/mgar/gar/v2-yann/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/inspective_package_test.py	2012-09-22 16:26:07 UTC (rev 19277)
+++ csw/mgar/gar/v2-yann/lib/python/inspective_package_test.py	2012-09-22 16:38:28 UTC (rev 19278)
@@ -165,9 +165,8 @@
   def test_ParseElfdumpLineVersionNeeded(self):
     line = '[13]                              SUNW_0.9             [ INFO ]'
     expected = {
-        'index': '13',
-	'version': 'SUNW_0.9',
-	'file': None
+      'version': 'SUNW_0.9',
+      'soname': None
     }
     self.assertEqual((expected, "version needed"), self.ip._ParseElfdumpLine(line, 'version needed'))
 
@@ -176,8 +175,8 @@
     expected = {
       'bind': 'GLOB',
       'shndx': '.text',
-      'name': 'vsf_log_line',
-      'ver': '1',
+      'symbol': 'vsf_log_line',
+      'version': '1',
       'type': 'FUNC',
     }
     self.assertEqual((expected, 'symbol table'), self.ip._ParseElfdumpLine(line, 'symbol table'))
@@ -186,7 +185,7 @@
     line = '      [152]  DB           [4] libc.so.1                strlen'
     expected = {
         'flags': 'DB',
-        'library': 'libc.so.1',
+        'soname': 'libc.so.1',
         'symbol': 'strlen',
     }
     self.assertEqual((expected, "syminfo"), self.ip._ParseElfdumpLine(line, "syminfo"))
@@ -195,7 +194,7 @@
     line = '      [116]  DB               <self>                   environ'
     expected = {
         'flags': 'DB',
-        'library': None,
+        'soname': None,
         'symbol': 'environ',
     }
     self.assertEqual((expected, "syminfo"), self.ip._ParseElfdumpLine(line, "syminfo"))

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list