1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +00:00

profile view works for disassembly now

This commit is contained in:
Steven Hugg 2017-04-22 13:33:20 -04:00
parent 604a5a1a74
commit 52c80a98e1

View File

@ -97,6 +97,7 @@ var SourceFile = function(lines, text) {
} }
return 0; return 0;
} }
this.lineCount = function() { return this.line2offset.length; }
} }
var TOOL_TO_SOURCE_STYLE = { var TOOL_TO_SOURCE_STYLE = {
@ -129,10 +130,19 @@ var disasmview = CodeMirror(document.getElementById('disassembly'), {
readOnly: true, readOnly: true,
styleActiveLine: true styleActiveLine: true
}); });
scrollProfileView(disasmview);
var memoryview; var memoryview;
var profileview; var profileview;
function scrollProfileView(_ed) {
_ed.on('scroll', function(ed, changeobj) {
if (profileview) {
profileview.container.scrollTop = ed.getScrollInfo().top;
}
});
}
function newEditor(mode) { function newEditor(mode) {
var isAsm = (mode != 'text/x-csrc'); var isAsm = (mode != 'text/x-csrc');
editor = CodeMirror(document.getElementById('editor'), { editor = CodeMirror(document.getElementById('editor'), {
@ -151,11 +161,7 @@ function newEditor(mode) {
setCode(editor.getValue()); setCode(editor.getValue());
}, 200); }, 200);
}); });
editor.on('scroll', function(ed, changeobj) { scrollProfileView(editor);
if (profileview) {
profileview.container.scrollTop = editor.getScrollInfo().top;
}
});
editor.setOption("mode", mode); editor.setOption("mode", mode);
} }
@ -647,6 +653,11 @@ function jumpToLine(ed, i) {
ed.scrollTo(null, t - middleHeight - 5); ed.scrollTo(null, t - middleHeight - 5);
} }
function getVisibleSourceFile() {
var div = $("#disassembly");
return div.is(':visible') ? assemblyfile : sourcefile;
}
function updateDisassembly() { function updateDisassembly() {
var div = $("#disassembly"); var div = $("#disassembly");
if (div.is(':visible')) { if (div.is(':visible')) {
@ -706,6 +717,7 @@ function toggleDisassembly() {
$("#disassembly").toggle(); $("#disassembly").toggle();
$("#editor").toggle(); $("#editor").toggle();
updateDisassembly(); updateDisassembly();
if ($("#profileview").is(':visible')) createProfileWindow();
} }
function resetAndDebug() { function resetAndDebug() {
@ -800,8 +812,8 @@ function getMemoryLineAt(row) {
return s; return s;
} }
function getEditorLineHeight() { function getVisibleEditorLineHeight() {
return $("#editor").find(".CodeMirror-line").first().height(); return $(".CodeMirror-line:visible").first().height();
} }
function getDumpLineAt(line) { function getDumpLineAt(line) {
@ -858,7 +870,7 @@ function showMemoryWindow() {
memoryview = new VirtualList({ memoryview = new VirtualList({
w:$("#emulator").width(), w:$("#emulator").width(),
h:$("#emulator").height(), h:$("#emulator").height(),
itemHeight: getEditorLineHeight(), itemHeight: getVisibleEditorLineHeight(),
totalRows: 0x1000, totalRows: 0x1000,
generatorFn: function(row) { generatorFn: function(row) {
var s = getMemoryLineAt(row); var s = getMemoryLineAt(row);
@ -893,8 +905,8 @@ function createProfileWindow() {
profileview = new VirtualList({ profileview = new VirtualList({
w:$("#emulator").width(), w:$("#emulator").width(),
h:$("#emulator").height(), h:$("#emulator").height(),
itemHeight: getEditorLineHeight(), itemHeight: getVisibleEditorLineHeight(),
totalRows: editor.lineCount(), totalRows: getVisibleSourceFile().lineCount(),
generatorFn: function(row) { generatorFn: function(row) {
var div = document.createElement("div"); var div = document.createElement("div");
div.appendChild(document.createTextNode(".")); div.appendChild(document.createTextNode("."));
@ -923,7 +935,6 @@ function profileWindowCallback(a,v) {
if (!pcd) { if (!pcd) {
pcd = pcdata[pc] = {nv:1}; pcd = pcdata[pc] = {nv:1};
} }
pcd.nv++;
if (a != pc) { if (a != pc) {
if (v >= 0) { if (v >= 0) {
pcd.lastwa = a; pcd.lastwa = a;
@ -932,19 +943,14 @@ function profileWindowCallback(a,v) {
pcd.lastra = a; pcd.lastra = a;
pcd.lastrv = platform.readAddress(a); pcd.lastrv = platform.readAddress(a);
} }
}
} else {
// TODO
if (v >= 0) {
prof_writes[a] = (prof_writes[a]|0)+1;
} else { } else {
prof_reads[a] = (prof_reads[a]|0)+1; pcd.nv++;
} }
} }
} }
function getProfileLine(line) { function getProfileLine(line) {
var offset = sourcefile.line2offset[line]; var offset = getVisibleSourceFile().line2offset[line];
if (offset >= 0) { if (offset >= 0) {
var pcd = pcdata[offset]; var pcd = pcdata[offset];
if (pcd) { if (pcd) {