Displaying (unformatted) function code.

This commit is contained in:
Ben Vanik 2013-12-22 09:25:44 -08:00
parent 4ecdfed46f
commit c92142ca02
20 changed files with 242 additions and 44 deletions

View file

@ -21,7 +21,11 @@ module.controller('CodeTabController', function(
$scope.selectedModule = null;
$scope.functionList = [];
$rootScope.$on('refresh', function() {
function refresh() {
if (!app.session || !app.session.dataSource) {
$scope.moduleList = [];
return;
}
var dataSource = app.session.dataSource;
dataSource.getModuleList().then(function(list) {
@ -38,7 +42,8 @@ module.controller('CodeTabController', function(
});
console.log('refresh');
});
};
$rootScope.$on('refresh', refresh);
$scope.selectModule = function(module) {
var moduleChange = module != $scope.selectedModule;
@ -55,4 +60,8 @@ module.controller('CodeTabController', function(
log.error('Unable to fetch function list');
});
};
if (app.session.dataSource) {
refresh();
}
});

View file

@ -7,9 +7,12 @@
<div class="debugger-fnview-header-right">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'ppc'">PPC</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'source'">PPC</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'rawHir'">HIR (raw)</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'hir'">HIR</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'rawLir'">LIR (raw)</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'lir'">LIR</button>
<button type="button" class="btn btn-default" ng-model="codeType" btn-radio="'machineCode'">MC</button>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default">1</button>
@ -29,7 +32,6 @@
</div>
</div>
<div class="debugger-fnview-body">
<div ui-view></div>
<div class="debugger-fnview-codeview">
<textarea class="debugger-fnview-textarea"></textarea>
</div>

View file

@ -17,17 +17,47 @@ var module = angular.module('xe.ui.code.functionView', [
module.controller('FunctionViewController', function(
$rootScope, $scope, app, log) {
$scope.codeType = 'ppc';
$scope.codeType = 'source';
function refresh() {
if (!app.session || !app.session.dataSource) {
$scope.fn = null;
return;
}
var dataSource = app.session.dataSource;
dataSource.getFunction($scope.functionAddress).then(function(fn) {
$scope.fn = fn;
updateCode();
}, function(e) {
log.error('Unable to fetch function');
});
};
$rootScope.$on('refresh', refresh);
$scope.$watch('functionAddress', refresh);
var textArea = document.querySelector('.debugger-fnview-textarea');
$scope.codeMirror = CodeMirror.fromTextArea(textArea, {
mode: 'javascript',
theme: 'default',
indentUnit: 2,
tabSize: 2,
lineNumbers: true,
firstLineNumber: 0,
lineNumberFormatter: function(line) {
return String(line);
},
gutters: [],
readOnly: true
});
function updateCode() {
var codeType = $scope.codeType;
var value = '';
if ($scope.fn) {
value = $scope.fn.disasm[codeType];
}
$scope.codeMirror.setValue(value || '');
};
$scope.$watch('codeType', updateCode);
});

View file

@ -16,9 +16,9 @@
<button type="button" class="btn btn-default" ng-click="connect()" ng-disabled="app.loading">
<span class="glyphicon glyphicon-link"></span> Connect
</button>
<button type="button" class="btn btn-default" ng-click="open()" ng-disabled="app.loading">
<!--<button type="button" class="btn btn-default" ng-click="open()" ng-disabled="app.loading">
<span class="glyphicon glyphicon-file"></span> Open
</button>
</button>-->
<button type="button" class="btn btn-default" ng-click="refresh()" ng-disabled="app.loading">
<span class="glyphicon glyphicon-refresh"></span> Refresh
</button>

View file

@ -6,22 +6,3 @@
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
/*
var myTextArea = document.querySelector('.debugger-fnview-textarea');
var myCodeMirror = CodeMirror.fromTextArea(myTextArea, {
mode: 'javascript',
theme: 'default',
indentUnit: 2,
tabSize: 2,
lineNumbers: true,
firstLineNumber: 0,
lineNumberFormatter: function(line) {
return String('0x00000000' + line);
},
gutters: [],
//readOnly: true,
});
*/

View file

@ -7,7 +7,7 @@
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.7.0.js"></script>
<script src="//angular-ui.github.io/ui-router/build/angular-ui-router.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<!--<link rel="stylesheet" href="//codemirror.net/lib/codemirror.css">-->
<link rel="stylesheet" href="//codemirror.net/lib/codemirror.css">
<link rel="stylesheet" href="assets/styles/app.css">
<style>
</style>
@ -19,7 +19,7 @@
<div class="app-console navbar-default" ng-include="'assets/ui/console/console.html'"></div>
</div>
<!--<script src="http://codemirror.net/lib/codemirror.js"></script>-->
<script src="http://codemirror.net/lib/codemirror.js"></script>
<script src="src/base.js"></script>

View file

@ -41,6 +41,7 @@ module.service('app', function(
this.close();
this.session = session;
$rootScope.$emit('refresh');
};
App.prototype.close = function() {

View file

@ -87,7 +87,7 @@ module.service('DataSource', function($q) {
return DataSource;
});
module.service('RemoteDataSource', function($q, DataSource) {
module.service('RemoteDataSource', function($q, log, DataSource) {
var RemoteDataSource = function(url) {
DataSource.call(this, url);
this.url = url;
@ -121,6 +121,7 @@ module.service('RemoteDataSource', function($q, DataSource) {
d.reject(e.code + ' ' + e.reason);
} else {
this.status = 'disconnected';
log.info('Disconnected');
}
}).bind(this);

View file

@ -13,7 +13,7 @@ var module = angular.module('xe.session', []);
module.service('Session', function(
$q, $http, log, FileDataSource, RemoteDataSource) {
$rootScope, $q, $http, log, FileDataSource, RemoteDataSource) {
var Session = function(id, opt_dataSource) {
this.id = id;
@ -85,6 +85,7 @@ module.service('Session', function(
if (this.dataSource) {
this.dataSource.dispose();
this.dataSource = null;
$rootScope.$emit('refresh');
}
};