Fixing various bugs.

This commit is contained in:
Ben Vanik 2013-12-24 23:29:40 -08:00
parent 44cbe1bbcf
commit 062610c596
4 changed files with 44 additions and 6 deletions

View file

@ -54,13 +54,22 @@ module.service('app', function(
};
App.prototype.open = function(sessionId) {
var d = $q.defer();
// Ignore if already open.
if (this.session && this.session.id == sessionId) {
d.resolve(this.session);
return d.promise;
}
// Close existing.
this.close();
var d = $q.defer();
this.loading = true;
log.info('Opening session ' + sessionId);
// Open session.
var session = new Session(sessionId);
this.loading = false;
this.setSession(session);

View file

@ -132,6 +132,8 @@ module.service('Session', function(
};
Session.prototype.setDataSource = function(dataSource) {
var self = this;
var d = $q.defer();
if (this.dataSource) {
this.dataSource.dispose();
@ -157,6 +159,29 @@ module.service('Session', function(
}
ps.push(this.dataSource.addBreakpoints(breakpointList));
// Fetch main module info.
// We need this for entry point info/etc.
var moduleInfoDeferred = $q.defer();
this.dataSource.getModuleList().then(function(moduleList) {
if (!moduleList.length) {
// Uh.
log.error('No modules loaded on startup!');
moduleInfoDeferred.reject(new Error('No modules found'));
return;
}
moduleList.forEach(function(module) {
dataSource.getModule(module.name).then(function(moduleInfo) {
// Put a breakpoint at the entry point.
var entryPoint = moduleInfo.exeEntryPoint;
self.addTempBreakpoint(entryPoint, entryPoint);
moduleInfoDeferred.resolve();
});
});
}, function(e) {
moduleInfoDeferred.reject(e);
});
ps.push(moduleInfoDeferred.promise);
$q.all(ps).then((function() {
this.dataSource.makeReady().then(function() {
d.resolve();
@ -227,6 +252,8 @@ module.service('Session', function(
// Now paused!
this.paused = true;
$rootScope.$emit('refresh');
if (breakpointId) {
var breakpoint = this.breakpointsById[breakpointId];
var thread = null; // TODO
@ -239,10 +266,11 @@ module.service('Session', function(
breakpoint.address.toString(16).toUpperCase() + '.');
$state.go('session.code.function', {
'function': breakpoint.fnAddress.toString(16).toUpperCase(),
'a': breakpoint.address.toString(16).toUpperCase()
sessionId: this.id,
function: breakpoint.fnAddress.toString(16).toUpperCase(),
a: breakpoint.address.toString(16).toUpperCase()
}, {
notify: false,
notify: true,
reloadOnSearch: false
});
} else {
@ -270,6 +298,7 @@ module.service('Session', function(
this.paused = true;
this.dataSource.breakExecution().then(function() {
log.info('Execution paused.');
$rootScope.$emit('refresh');
}, function(e) {
log.error('Unable to break: ' + e);
});