changeset 282:c137f1fe3e65

Add codeship hook
author Windel Bouwman
date Fri, 15 Nov 2013 09:32:37 +0100
parents 4496cae24d7f
children c9781c73e7e2
files python/ide.py readme.rst
diffstat 2 files changed, 66 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/python/ide.py	Sat Nov 02 11:11:40 2013 +0100
+++ b/python/ide.py	Fri Nov 15 09:32:37 2013 +0100
@@ -16,8 +16,17 @@
 import c3
 import zcc
 import outstream
+import traceback
 
 
+def handle_exception(tp, v, tb):
+    logging.critical(str(v))
+    tb = traceback.format_tb(tb)
+    for i in tb:
+        logging.critical(i.strip())
+
+sys.excepthook = handle_exception
+
 class BuildErrors(QTreeView):
     sigErrorSelected = pyqtSignal(object)
 
@@ -56,6 +65,52 @@
         self.sigErrorSelected.emit(err)
 
 
+class DisAsmModel(QAbstractTableModel):
+    def __init__(self):
+        super().__init__()
+        self.outs = None
+        self.instructions = []
+        self.headers = ['Address', 'Bytes', 'Instruction']
+        self.txts = []
+        self.txts.append(lambda i: '0x{:08x}'.format(i.address))
+        self.txts.append(lambda i: str(i.encode()))
+        self.txts.append(lambda i: str(i))
+
+    def rowCount(self, parent):
+        return len(self.instructions)
+        
+    def columnCount(self, parent):
+        return len(self.headers)
+
+    def data(self, index, role):
+        if not index.isValid():
+            return
+        row, col = index.row(), index.column()
+        if role == Qt.DisplayRole:
+            i = self.instructions[row]
+            return self.txts[col](i)
+
+    def headerData(self, section, orientation, role):
+        if orientation == Qt.Horizontal and role == Qt.DisplayRole:
+            return self.headers[section]
+            
+    def setInstructions(self, ins):
+        self.instructions = ins
+        self.modelReset.emit()
+    
+
+class Disassembly(QTableView):
+    def __init__(self):
+        super().__init__()
+        self.dm = DisAsmModel()
+        self.setModel(self.dm)
+
+    def showPos(self, p):
+        for i in self.dm.instructions:
+            if i.address == p:
+                row = self.dm.instructions.index(i)
+                self.selectRow(row)
+
 class AboutDialog(QDialog):
     def __init__(self, parent=None):
         super(AboutDialog, self).__init__(parent)
@@ -63,11 +118,8 @@
         l = QVBoxLayout(self)
         txt = QTextEdit(self)
         txt.setReadOnly(True)
-        aboutText = """<h1>lcfOS IDE</h1>
-        <p>An all-in-one IDE for OS development.</p>
-        <p>https://www.assembla.com/spaces/lcfOS/wiki</p>
-        <p>Author: Windel Bouwman</p>
-        """
+        with open(os.path.join('..', 'readme.rst'), 'r') as f:
+            aboutText = f.read()
         txt.append(aboutText)
         l.addWidget(txt)
         but = QPushButton('OK')
@@ -116,6 +168,7 @@
         self.devxplr = addComponent('Device explorer', stutil.DeviceExplorer())
         self.regview = addComponent('Registers', stutil.RegisterView())
         self.memview = addComponent('Memory', stutil.MemoryView())
+        self.disasm = addComponent('Disasm', Disassembly())
         self.ctrlToolbar = stutil.DebugToolbar()
         self.addToolBar(self.ctrlToolbar)
         self.ctrlToolbar.setObjectName('debugToolbar')
@@ -241,12 +294,12 @@
         if loc:
             ce.setRowCol(loc.row, loc.col)
             ce.setFocus()
-        else:
-            ce.clearErrors()
 
     def pointCode(self, p):
         # Lookup pc in debug infos:
         loc = None
+        print(p)
+        self.disasm.showPos(p)
         if hasattr(self, 'debugInfo'):
             for di in self.debugInfo:
                 if di.address > p:
@@ -260,6 +313,7 @@
 
     # Build recepy:
     def parseFile(self):
+        self.logger.info('Parsing!')
         ce = self.activeMdiChild()
         if not ce:
             return
@@ -270,7 +324,8 @@
         self.builderrors.setErrorList(self.diag.diags)
         ce.setErrors(self.diag.diags)
         self.astViewer.setAst(pkg)
-        c3.AstPrinter().printAst(pkg)
+        if pkg:
+            c3.AstPrinter().printAst(pkg)
         self.logger.info('Done!')
 
     def buildFile(self):
@@ -303,6 +358,7 @@
 
         outs.dump()
         code_s = outs.getSection('code')
+        self.disasm.dm.setInstructions(code_s.instructions)
         self.debugInfo = code_s.debugInfos()
         if self.ctrlToolbar.device:
             logging.info('Flashing stm32f4 discovery')
--- a/readme.rst	Sat Nov 02 11:11:40 2013 +0100
+++ b/readme.rst	Fri Nov 15 09:32:37 2013 +0100
@@ -36,5 +36,7 @@
     python -m unittest
 
 .. image:: https://drone.io/bitbucket.org/windel/lcfos/status.png
+.. image:: https://codeship.io/projects/f4a4da90-2ffd-0131-58c6-5ea61a10d89b/status
 
 
+