[csw-devel] SF.net SVN: gar:[20982] csw/mgar/gar/v2/lib/python/inspective_package.py
chninkel at users.sourceforge.net
chninkel at users.sourceforge.net
Sat May 4 11:56:50 CEST 2013
Revision: 20982
http://gar.svn.sourceforge.net/gar/?rev=20982&view=rev
Author: chninkel
Date: 2013-05-04 09:56:50 +0000 (Sat, 04 May 2013)
Log Message:
-----------
put elfdump output in a temporary file and mmap it to limit unecessary memory usage
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/inspective_package.py
Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py 2013-05-04 09:56:31 UTC (rev 20981)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py 2013-05-04 09:56:50 UTC (rev 20982)
@@ -13,6 +13,8 @@
import configuration as c
import time
import shell
+import mmap
+import tempfile
from elftools.elf.elffile import ELFFile
from elftools.elf.enums import ENUM_E_MACHINE
@@ -233,8 +235,10 @@
if base_dir:
binary = os.path.join(base_dir, binary)
# elfdump is the only tool that give us all informations
+ elfdump_output_file = tempfile.TemporaryFile()
args = [common_constants.ELFDUMP_BIN, "-svy", binary_abspath]
- retcode, stdout, stderr = shell.ShellCommand(args, allow_error=True)
+ retcode, stdout, stderr = shell.ShellCommand(args, allow_error=True,
+ stdout=elfdump_output_file)
if retcode or stderr:
# we ignore for now these elfdump errors which can be catched
# later by check functions,
@@ -273,14 +277,20 @@
"as path of the error report. Logs are saved in " +
"/tmp/elfdump_std(out|err).log for your inspection.")
raise package.Error(msg)
- elfdump_out = stdout.splitlines()
symbols = {}
binary_info = {'version definition': [],
'version needed': []}
+ if not os.fstat(elfdump_output_file.fileno()).st_size:
+ binary_info['symbol table'] = []
+ binaries_elf_info[binary] = binary_info
+ continue
+
+ elfdump_output = mmap.mmap(elfdump_output_file.fileno(), 0, prot=mmap.PROT_READ)
+
cur_section = None
- for line in elfdump_out:
+ for line in iter(elfdump_output.readline, ""):
try:
elf_info, cur_section = self._ParseElfdumpLine(line, cur_section)
except package.StdoutSyntaxError as e:
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