about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2012-04-15 23:18:02 +0200
committerserpilliere <devnull@localhost>2012-04-15 23:18:02 +0200
commitd0e0a1e4b880114dd29aaacf2c4c8ecdd3dc82d9 (patch)
treedc7e63b2af52dfd99ffa5e5ba9cb0f0999b26605
parent0720dbf62ec5e001c10f80b2e19c521d976fdef5 (diff)
downloadmiasm-d0e0a1e4b880114dd29aaacf2c4c8ecdd3dc82d9.tar.gz
miasm-d0e0a1e4b880114dd29aaacf2c4c8ecdd3dc82d9.zip
arch: add comments to instructions
Diffstat (limited to '')
-rw-r--r--miasm/arch/arm_arch.py1
-rw-r--r--miasm/arch/ia32_arch.py7
-rw-r--r--miasm/arch/ppc_arch.py1
-rw-r--r--miasm/core/asmbloc.py5
-rwxr-xr-xmiasm/graph/graph_qt.py10
5 files changed, 20 insertions, 4 deletions
diff --git a/miasm/arch/arm_arch.py b/miasm/arch/arm_arch.py
index 258ad933..5cffb5d7 100644
--- a/miasm/arch/arm_arch.py
+++ b/miasm/arch/arm_arch.py
@@ -880,6 +880,7 @@ class arm_mn(object):
         self.l = 4
         self.m = None
         self.arg = []
+        self.cmt = ""
 
 
 
diff --git a/miasm/arch/ia32_arch.py b/miasm/arch/ia32_arch.py
index f1c920bd..0c81ec30 100644
--- a/miasm/arch/ia32_arch.py
+++ b/miasm/arch/ia32_arch.py
@@ -1348,6 +1348,7 @@ class x86_mn:
         self.admode = admode
         self.opmode = opmode
         self.mnemo_mode = self.opmode
+        self.cmt = ""
 
     @classmethod
     def prefix2hex(self, prefix):
@@ -1425,7 +1426,11 @@ class x86_mn:
                 args_str+="%s, "%dict_to_ad(a, self.m.modifs, self.opmode, self.admode)
             else:
                 raise ValueError("arg zarbi %s"%str(a))
-        return args_str[:-2]
+
+        o = args_str[:-2]
+        if self.cmt:
+            o = "%-50s%s"%(o, self.cmt)
+        return o
 
     def intsize(self, im, ext = False):
         if ext:
diff --git a/miasm/arch/ppc_arch.py b/miasm/arch/ppc_arch.py
index 8cb66b2d..6a7ac957 100644
--- a/miasm/arch/ppc_arch.py
+++ b/miasm/arch/ppc_arch.py
@@ -749,6 +749,7 @@ class ppc_mn(object):
         self.l = 4
         self.m = None
         self.arg = []
+        self.cmt = ""
         
         for m in self.mask_orig:
             mc = m(self, off)            
diff --git a/miasm/core/asmbloc.py b/miasm/core/asmbloc.py
index f9115105..1860b856 100644
--- a/miasm/core/asmbloc.py
+++ b/miasm/core/asmbloc.py
@@ -1107,9 +1107,8 @@ def getlineby_offset(all_bloc, o):
 
 def getblocby_offset(all_bloc, o):
     for b in all_bloc:
-        for l in b.lines:
-            if l.offset == o:
-                return b
+        if b.lines and b.lines[0].offset == o:
+            return b
     return None
 
 def getblocby_label(all_bloc, l):
diff --git a/miasm/graph/graph_qt.py b/miasm/graph/graph_qt.py
index adb4fe50..7fccc76f 100755
--- a/miasm/graph/graph_qt.py
+++ b/miasm/graph/graph_qt.py
@@ -62,6 +62,7 @@ def gen_syntax_rules(symbols = []):
     highlightingRules = []
     number = QtGui.QTextCharFormat()
     label = QtGui.QTextCharFormat()
+    comment = QtGui.QTextCharFormat()
     my_id = QtGui.QTextCharFormat()
     highlight_word = QtGui.QTextCharFormat()
 
@@ -80,6 +81,15 @@ def gen_syntax_rules(symbols = []):
     rule = HighlightingRule( pattern, number )
     highlightingRules.append( rule )
 
+    #comment
+    brushr = QtGui.QBrush( Qt.red, Qt.SolidPattern )
+    pattern = QtCore.QRegExp( ";.*$" )
+    pattern.setMinimal( False )
+    comment.setForeground( brushr )
+    rule = HighlightingRule( pattern, comment )
+    highlightingRules.append( rule )
+
+
     """
     #label
     brushb = QtGui.QBrush( Qt.blue, Qt.SolidPattern )