about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-01-12 09:57:23 +0100
committerAjax <commial@gmail.com>2016-01-15 17:25:04 +0100
commitdadb70e2f3b0061c27f2b0a89bf9fd31331b6829 (patch)
treec8220f067e134c42b87ee088c14068d8c9f876a4
parentf2452a5b0ad72eda7193b6027ea565726d8011a9 (diff)
downloadmiasm-dadb70e2f3b0061c27f2b0a89bf9fd31331b6829.tar.gz
miasm-dadb70e2f3b0061c27f2b0a89bf9fd31331b6829.zip
AsmBlock: introduce asm_block_bad
-rw-r--r--miasm2/core/asmbloc.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index 103b674c..6c09ddc7 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -262,6 +262,36 @@ class asm_bloc(object):
                        for constraints in dests.itervalues())
 
 
+class asm_block_bad(asm_bloc):
+    """Stand for a *bad* ASM block (malformed, unreachable,
+    not disassembled, ...)"""
+
+    ERROR_TYPES = {-1: "Unknown error",
+               }
+
+    def __init__(self, label=None, alignment=1, errno=-1, *args, **kwargs):
+        """Instanciate an asm_block_bad.
+        @label, @alignement: same as asm_bloc.__init__
+        @errno: (optional) specify a error type associated with the block
+        """
+        super(asm_block_bad, self).__init__(label, alignment, *args, **kwargs)
+        self._errno = errno
+
+    def __str__(self):
+        return "\n".join([str(self.label),
+                          "\tBad block: %s" % self.ERROR_TYPES.get(self.errno,
+                                                                   self.errno)])
+
+    def addline(self, *args, **kwargs):
+        raise RuntimeError("An asm_block_bad cannot have line")
+
+    def addto(self, *args, **kwargs):
+        raise RuntimeError("An asm_block_bad cannot have bto")
+
+    def split(self, *args, **kwargs):
+        raise RuntimeError("An asm_block_bad cannot be splitted")
+
+
 class asm_symbol_pool:
 
     def __init__(self):