Added disassembly function

This commit is contained in:
Matthias Neeracher 2014-12-10 15:30:51 +01:00 committed by Matthias Neeracher
parent 9b0422f0c5
commit e3520d91ee
10 changed files with 69 additions and 6 deletions

View File

@ -18,11 +18,15 @@ class ASBuilder {
termination = NSNotificationCenter.defaultCenter().addObserverForName(NSTaskDidTerminateNotification, termination = NSNotificationCenter.defaultCenter().addObserverForName(NSTaskDidTerminateNotification,
object: nil, queue: nil, usingBlock: object: nil, queue: nil, usingBlock:
{ (notification: NSNotification!) in { (notification: NSNotification!) in
if notification.object as? NSTask == self.task && self.task!.terminationStatus == 0 { if notification.object as? NSTask == self.task {
if self.task!.terminationStatus == 0 {
if let cont = self.continuation { if let cont = self.continuation {
self.continuation = nil self.continuation = nil
cont() cont()
} }
} else {
self.continuation = nil
}
} }
}) })
} }
@ -121,4 +125,23 @@ class ASBuilder {
task!.arguments = args; task!.arguments = args;
task!.launch() task!.launch()
} }
func disassembleProject(board: String) {
task = NSTask()
task!.currentDirectoryPath = dir.path!
task!.launchPath = "/usr/local/CrossPack-AVR/bin/avr-objdump"
let fileManager = NSFileManager.defaultManager()
let logURL = dir.URLByAppendingPathComponent("build/disasm.log")
fileManager.createFileAtPath(logURL.path!, contents: NSData(), attributes: nil)
let logOut = NSFileHandle(forWritingAtPath: logURL.path!)!
task!.standardOutput = logOut
task!.standardError = logOut
var args = ["-d", "-S", "build/"+board+"/"+dir.lastPathComponent+".elf"]
let cmdLine = task!.launchPath+" "+(args as NSArray).componentsJoinedByString(" ")+"\n"
logOut.writeData(cmdLine.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)
task!.arguments = args;
task!.launch()
}
} }

View File

@ -203,6 +203,7 @@ class ASFileTree : NSObject, NSOutlineViewDataSource {
var dir = NSURL() var dir = NSURL()
var buildLog = ASLogNode(name: "Build Log", path: "build/build.log") var buildLog = ASLogNode(name: "Build Log", path: "build/build.log")
var uploadLog = ASLogNode(name: "Upload Log", path: "build/upload.log") var uploadLog = ASLogNode(name: "Upload Log", path: "build/upload.log")
var disassembly = ASLogNode(name: "Disassembly", path: "build/disasm.log")
func addFileURL(url: NSURL, omitUnknown: Bool = true) { func addFileURL(url: NSURL, omitUnknown: Bool = true) {
let type = ASFileType.guessForURL(url) let type = ASFileType.guessForURL(url)
@ -230,7 +231,7 @@ class ASFileTree : NSObject, NSOutlineViewDataSource {
// MARK: Outline Data Source // MARK: Outline Data Source
func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int { func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int {
if item == nil { if item == nil {
return 3 return 4
} else { } else {
return (item as ASFileGroup).children.count return (item as ASFileGroup).children.count
} }
@ -242,6 +243,8 @@ class ASFileTree : NSObject, NSOutlineViewDataSource {
return buildLog return buildLog
case 2: case 2:
return uploadLog return uploadLog
case 3:
return disassembly
default: default:
return root return root
} }

View File

@ -287,7 +287,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
updateChangeCount(.ChangeDone) updateChangeCount(.ChangeDone)
} }
func outlineView(outlineView: NSOutlineView, willDisplayCell cell: AnyObject, forTableColumn tableColumn: NSTableColumn?, item: AnyObject) { func outlineView(outlineView: NSOutlineView, willDisplayCell cell: AnyObject, forTableColumn tableColumn: NSTableColumn?, item: AnyObject) {
if item === files.root || item === files.buildLog || item === files.uploadLog { if item === files.root || item === files.buildLog || item === files.uploadLog || item === files.disassembly {
(cell as NSCell).font = NSFont.boldSystemFontOfSize(13.0) (cell as NSCell).font = NSFont.boldSystemFontOfSize(13.0)
} else { } else {
(cell as NSCell).font = NSFont.systemFontOfSize(13.0) (cell as NSCell).font = NSFont.systemFontOfSize(13.0)
@ -476,5 +476,13 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
} }
buildProject(sender) buildProject(sender)
} }
@IBAction func disassembleProject(sender: AnyObject) {
builder.continuation = {
self.selectNodeInOutline(self.files.disassembly)
self.builder.disassembleProject(self.board)
}
buildProject(sender)
}
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7096" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7096" systemVersion="14C82" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7096"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7096"/>
</dependencies> </dependencies>
@ -109,6 +109,11 @@
<action selector="buildProject:" target="-1" id="Rkc-yl-Vwi"/> <action selector="buildProject:" target="-1" id="Rkc-yl-Vwi"/>
</connections> </connections>
</toolbarItem> </toolbarItem>
<toolbarItem implicitItemIdentifier="8F4A4234-688B-4341-96E1-BEE9BB98AF4B" label="Disasm" paletteLabel="Disassemble" tag="-1" image="DisassIcon" id="MP9-gL-Y3I">
<connections>
<action selector="disassembleProject:" target="-2" id="idL-cS-KK9"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="2B98B0B2-C192-4A20-9C17-8CDBD6A9002F" label="Clean" paletteLabel="Clean" tag="-1" image="CleanIcon" id="lGv-lT-Eh9"> <toolbarItem implicitItemIdentifier="2B98B0B2-C192-4A20-9C17-8CDBD6A9002F" label="Clean" paletteLabel="Clean" tag="-1" image="CleanIcon" id="lGv-lT-Eh9">
<connections> <connections>
<action selector="cleanProject:" target="-1" id="LzL-6C-IDi"/> <action selector="cleanProject:" target="-1" id="LzL-6C-IDi"/>
@ -198,6 +203,7 @@
<defaultToolbarItems> <defaultToolbarItems>
<toolbarItem reference="2cP-cC-Cr8"/> <toolbarItem reference="2cP-cC-Cr8"/>
<toolbarItem reference="69r-aN-6vG"/> <toolbarItem reference="69r-aN-6vG"/>
<toolbarItem reference="MP9-gL-Y3I"/>
<toolbarItem reference="FYt-ZW-Epr"/> <toolbarItem reference="FYt-ZW-Epr"/>
<toolbarItem reference="lGv-lT-Eh9"/> <toolbarItem reference="lGv-lT-Eh9"/>
<toolbarItem reference="FYt-ZW-Epr"/> <toolbarItem reference="FYt-ZW-Epr"/>
@ -218,6 +224,7 @@
<resources> <resources>
<image name="BuildIcon" width="32" height="32"/> <image name="BuildIcon" width="32" height="32"/>
<image name="CleanIcon" width="32" height="32"/> <image name="CleanIcon" width="32" height="32"/>
<image name="DisassIcon" width="32" height="32"/>
<image name="UploadIcon" width="32" height="32"/> <image name="UploadIcon" width="32" height="32"/>
</resources> </resources>
</document> </document>

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "DisassIcon 1x.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "DisassIcon 2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Binary file not shown.