diff --git a/debugger/assets/ui/code/function-view.js b/debugger/assets/ui/code/function-view.js index 5d1160170..246c4dddd 100644 --- a/debugger/assets/ui/code/function-view.js +++ b/debugger/assets/ui/code/function-view.js @@ -190,7 +190,7 @@ module.controller('FunctionViewController', function( var address = sourceLine[1]; var breakpoint = app.session.breakpoints[address]; var el; - if (breakpoint) { + if (breakpoint && breakpoint.type == 'code') { el = document.createElement('span'); el.classList.add('debugger-fnview-gutter-icon-el'); if (breakpoint.enabled) { diff --git a/debugger/src/app.js b/debugger/src/app.js index 7edb3d9af..fe043c904 100644 --- a/debugger/src/app.js +++ b/debugger/src/app.js @@ -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); diff --git a/debugger/src/session.js b/debugger/src/session.js index bf60d6261..7340deb8e 100644 --- a/debugger/src/session.js +++ b/debugger/src/session.js @@ -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); }); diff --git a/src/alloy/backend/ivm/ivm_function.cc b/src/alloy/backend/ivm/ivm_function.cc index e616dada4..e5ee570e8 100644 --- a/src/alloy/backend/ivm/ivm_function.cc +++ b/src/alloy/backend/ivm/ivm_function.cc @@ -82,7 +82,7 @@ int IVMFunction::RemoveBreakpointImpl(Breakpoint* breakpoint) { if (i->debug_flags) { auto old_breakpoint = FindBreakpoint(breakpoint->address()); if (old_breakpoint) { - uint64_t breakpoint_ptr = (uint64_t)breakpoint; + uint64_t breakpoint_ptr = (uint64_t)old_breakpoint; i->src2_reg = (uint32_t)breakpoint_ptr; i->src3_reg = (uint32_t)(breakpoint_ptr >> 32); }