[diffoscope] 01/05: Add support for reading LLVM bitcode files

Ximin Luo infinity0 at debian.org
Sat Aug 13 03:05:03 CEST 2016


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 17b7c1f93db7ed09c2303662721b55de7fc9228c
Author: Ximin Luo <infinity0 at debian.org>
Date:   Sat Aug 13 00:43:19 2016 +0200

    Add support for reading LLVM bitcode files
---
 diffoscope/__init__.py                        |  8 ++++++++
 diffoscope/comparators/__init__.py            |  2 ++
 diffoscope/comparators/{sqlite.py => llvm.py} | 19 ++++++++++++-------
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/diffoscope/__init__.py b/diffoscope/__init__.py
index 249e06d..5c0507f 100644
--- a/diffoscope/__init__.py
+++ b/diffoscope/__init__.py
@@ -109,6 +109,14 @@ class RequiredToolNotFound(Exception):
             'debian': 'default-jdk | java-sdk',
             'arch': 'java-environment',
         },
+        'llvm-bcanalyzer': {
+            'debian': 'llvm',
+            'arch': 'llvm',
+        },
+        'llvm-dis': {
+            'debian': 'llvm',
+            'arch': 'llvm',
+        },
         'ls': {
             'debian': 'coreutils',
             'arch': 'coreutils',
diff --git a/diffoscope/comparators/__init__.py b/diffoscope/comparators/__init__.py
index 4fb31d3..faa0c16 100644
--- a/diffoscope/comparators/__init__.py
+++ b/diffoscope/comparators/__init__.py
@@ -59,6 +59,7 @@ from diffoscope.comparators.image import ImageFile
 from diffoscope.comparators.ipk import IpkFile
 from diffoscope.comparators.iso9660 import Iso9660File
 from diffoscope.comparators.json import JSONFile
+from diffoscope.comparators.llvm import LlvmBitCodeFile
 from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.mono import MonoExeFile
 from diffoscope.comparators.pdf import PdfFile
@@ -147,6 +148,7 @@ FILE_CLASSES = (
     MachoFile,
     FsImageFile,
     StaticLibFile,
+    LlvmBitCodeFile,
     Sqlite3Database,
     TtfFile,
     MoFile,
diff --git a/diffoscope/comparators/sqlite.py b/diffoscope/comparators/llvm.py
similarity index 68%
copy from diffoscope/comparators/sqlite.py
copy to diffoscope/comparators/llvm.py
index 16706d7..a740bf8 100644
--- a/diffoscope/comparators/sqlite.py
+++ b/diffoscope/comparators/llvm.py
@@ -3,6 +3,7 @@
 # diffoscope: in-depth comparison of files, archives, and directories
 #
 # Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+# Copyright © 2016 Ximin Luo <infinity0 at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,17 +24,21 @@ from diffoscope.comparators.utils import Command
 from diffoscope.difference import Difference
 
 
-class Sqlite3Dump(Command):
-    @tool_required('sqlite3')
+class LlvmBcAnalyzer(Command):
+    @tool_required('llvm-bcanalyzer')
     def cmdline(self):
-        return ['sqlite3', self.path, '.dump']
+        return ['llvm-bcanalyzer', '-dump', self.path]
 
+class LlvmBcDisassembler(Command):
+    @tool_required('llvm-dis')
+    def cmdline(self):
+        return ['llvm-dis', '-o', '-', self.path]
 
-class Sqlite3Database(File):
+class LlvmBitCodeFile(File):
     @staticmethod
     def recognizes(file):
-        return file.magic_file_type and file.magic_file_type.startswith('SQLite 3.x database')
+        return file.magic_file_type and file.magic_file_type.startswith('LLVM IR bitcode')
 
     def compare_details(self, other, source=None):
-        return [Difference.from_command(Sqlite3Dump, self.path, other.path)]
-
+        return [Difference.from_command(LlvmBcAnalyzer,   self.path, other.path),
+                Difference.from_command(LlvmBcDisassembler, self.path, other.path)]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list