MakeReady behavior.

This commit is contained in:
Ben Vanik 2013-12-22 16:48:50 -08:00
parent 076fb70335
commit e45a7afabc
4 changed files with 86 additions and 37 deletions

View File

@ -61,6 +61,39 @@ module.service('DataSource', function($q) {
DataSource.prototype.dispose = function() {}; DataSource.prototype.dispose = function() {};
DataSource.prototype.issue = function(command) {}; DataSource.prototype.issue = function(command) {};
DataSource.prototype.makeReady = function() {
return this.issue({
command: 'debug.make_ready'
});
};
DataSource.prototype.getModuleList = function() {
return this.issue({
command: 'cpu.get_module_list'
});
};
DataSource.prototype.getModule = function(moduleName) {
return this.issue({
command: 'cpu.get_module',
module: moduleName
});
};
DataSource.prototype.getFunctionList = function(moduleName) {
return this.issue({
command: 'cpu.get_function_list',
module: moduleName
});
};
DataSource.prototype.getFunction = function(address) {
return this.issue({
command: 'cpu.get_function',
address: address
});
};
DataSource.prototype.addBreakpoint = function(breakpoint) { DataSource.prototype.addBreakpoint = function(breakpoint) {
return this.addBreakpoints([breakpoint]); return this.addBreakpoints([breakpoint]);
}; };
@ -96,33 +129,6 @@ module.service('DataSource', function($q) {
}); });
}; };
DataSource.prototype.getModuleList = function() {
return this.issue({
command: 'cpu.get_module_list'
});
};
DataSource.prototype.getModule = function(moduleName) {
return this.issue({
command: 'cpu.get_module',
module: moduleName
});
};
DataSource.prototype.getFunctionList = function(moduleName) {
return this.issue({
command: 'cpu.get_function_list',
module: moduleName
});
};
DataSource.prototype.getFunction = function(address) {
return this.issue({
command: 'cpu.get_function',
address: address
});
};
return DataSource; return DataSource;
}); });

View File

@ -52,7 +52,9 @@ module.service('Session', function(
}; };
for (var key in this.breakpoints) { for (var key in this.breakpoints) {
var breakpoint = this.breakpoints[key]; var breakpoint = this.breakpoints[key];
json.breakpoints.push(breakpoint.toJSON()); if (breakpoint.type != Breakpoint.TEMP) {
json.breakpoints.push(breakpoint.toJSON());
}
} }
window.localStorage[this.id] = JSON.stringify(json); window.localStorage[this.id] = JSON.stringify(json);
}; };
@ -100,8 +102,11 @@ module.service('Session', function(
p.then((function() { p.then((function() {
log.info('Connected!'); log.info('Connected!');
log.clearProgress(); log.clearProgress();
this.setDataSource(dataSource); this.setDataSource(dataSource).then((function() {
d.resolve(this); d.resolve(this);
}).bind(this), (function(e) {
d.reject(e);
}).bind(this));
}).bind(this), (function(e) { }).bind(this), (function(e) {
log.error('Unable to connect: ' + e); log.error('Unable to connect: ' + e);
log.clearProgress(); log.clearProgress();
@ -119,22 +124,42 @@ module.service('Session', function(
}; };
Session.prototype.setDataSource = function(dataSource) { Session.prototype.setDataSource = function(dataSource) {
var d = $q.defer();
if (this.dataSource) { if (this.dataSource) {
this.dataSource.dispose(); this.dataSource.dispose();
this.dataSource = null; this.dataSource = null;
$rootScope.$emit('refresh');
} }
$rootScope.$emit('refresh');
if (!dataSource) { if (!dataSource) {
return; d.resolve();
return d.promise;
} }
this.dataSource = dataSource; this.dataSource = dataSource;
var ps = [];
// Add breakpoints.
var breakpointList = []; var breakpointList = [];
for (var key in this.breakpoints) { for (var key in this.breakpoints) {
breakpointList.push(this.breakpoints[key]); breakpointList.push(this.breakpoints[key]);
} }
this.dataSource.addBreakpoints(breakpointList); ps.push(this.dataSource.addBreakpoints(breakpointList));
$q.all(ps).then((function() {
this.dataSource.makeReady().then(function() {
d.resolve();
}, function(e) {
log.error('Error making target ready: ' + e);
d.reject(e);
});
}).bind(this), (function(e) {
log.error('Errors preparing target: ' + e);
this.disconnect();
d.reject(e);
}).bind(this));
return d.promise;
}; };
Session.prototype.addBreakpoint = function(breakpoint) { Session.prototype.addBreakpoint = function(breakpoint) {

View File

@ -279,6 +279,14 @@ json_t* Processor::OnDebugRequest(
delete fn; delete fn;
return fn_json; return fn_json;
} else if (xestrcmpa(command, "add_breakpoints") == 0) {
// breakpoints: []
return json_null();
} else if (xestrcmpa(command, "remove_breakpoints") == 0) {
// breakpointIds: ['id']
return json_null();
} else if (xestrcmpa(command, "remove_all_breakpoints") == 0) {
return json_null();
} else { } else {
succeeded = false; succeeded = false;
return json_string("Unknown command"); return json_string("Unknown command");

View File

@ -36,9 +36,9 @@ using namespace xe::kernel::xboxkrnl;
WSClient::WSClient(DebugServer* debug_server, socket_t socket_id) : WSClient::WSClient(DebugServer* debug_server, socket_t socket_id) :
DebugClient(debug_server),
thread_(NULL), thread_(NULL),
socket_id_(socket_id) { socket_id_(socket_id),
DebugClient(debug_server) {
mutex_ = xe_mutex_alloc(1000); mutex_ = xe_mutex_alloc(1000);
loop_ = xe_socket_loop_create(socket_id); loop_ = xe_socket_loop_create(socket_id);
@ -322,8 +322,6 @@ void WSClient::EventThread() {
return; return;
} }
MakeReady();
// Prep callbacks. // Prep callbacks.
struct wslay_event_callbacks callbacks = { struct wslay_event_callbacks callbacks = {
(wslay_event_recv_callback)WSClientRecvCallback, (wslay_event_recv_callback)WSClientRecvCallback,
@ -505,6 +503,18 @@ json_t* WSClient::HandleMessage(const char* command, json_t* request,
command, dot - command); command, dot - command);
const char* sub_command = command + (dot - command + 1); const char* sub_command = command + (dot - command + 1);
// Check debugger meta commands.
if (xestrcmpa(target_name, "debug") == 0) {
succeeded = true;
if (xestrcmpa(sub_command, "make_ready") == 0) {
MakeReady();
return json_true();
} else {
succeeded = false;
return json_string("Unknown command");
}
}
// Lookup target. // Lookup target.
DebugTarget* target = debug_server_->GetTarget(target_name); DebugTarget* target = debug_server_->GetTarget(target_name);
if (!target) { if (!target) {