Skip to content

Commit

Permalink
- Corrected setting of unverified breakpoints.
Browse files Browse the repository at this point in the history
- Fixed error when fetching disassemblies.
  • Loading branch information
maziac committed Jun 17, 2018
1 parent da9c570 commit a6956f3
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.1
- Corrected setting of unverified breakpoints.
- Fixed error when fetching disassemblies.

## 0.4.0
- Settings cleaned up.
- Changing the program counter is now directly reflected in the UI.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Note: The Z80-Debug-Adapter does not include any support for building from assem
- supports only ZEsarUX emulator
- build output must
- create a .list file (format as of Savannah's Z80 Assembler: http://savannah.nongnu.org/projects/z80asm/)
- _alternatively you can use other list files (like z88dk) with limited functionality, please consult the documentation._
- _alternatively you can use other list files (like z88dk)with limited functionality, please consult the documentation. You can also simply fetch a disassembly of your code from ZEsarUX. Please see the "List file" section in the documentation._
- create a .sna file containing the binary


Expand Down
19 changes: 18 additions & 1 deletion documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ The key to use other assemblers is the 'filter' property. Here you can define a
The pattern "/^[0-9]+\\s+//" e.g. replaces all numbers at the start of the line with an empty string, i.e. it deltes the numbers from the line.


#### Without a listfile

If you don't setup any list file then you can still start z80-debug and it will work.
However, since vscode doesn't find any related sources, the variables view (which displays the disassembly) will vanish for every 'step'. To show it again click on the call stack.

To overcome this problem setup at least a disassembly that is retrieved from
ZEsarUX, so you have a disassembled teext that you can step through.
Of course, non of the goodies (i.e. label resolution etc.) will work. You just have the plain disassembly that you can step through. But still you can examine register values and memory content etc.

Configuration:
~~~~
"disassemblies": [
[ 0, 65356 ] // Fetch the complete RAM/ROM disassembly
],
~~~~


### Labelsfile

Because nowadays (>=0.4.0) the labels and constants are extracted directly from the list file there should normally no need to include a labels file anymore.
Expand Down Expand Up @@ -263,7 +280,7 @@ If you enter
in the debug console you open a memory viewer.

Here an example:

z80
![](images/memoryviewer1.gif)

The memory viewer will offer a few extra infos:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "z80-debug",
"displayName": "Z80 Debugger",
"version": "0.4.0",
"version": "0.4.1",
"publisher": "maziac",
"description": "Especially for the ZEsarUX ZX Spectrum Emulator.",
"description": "A debug adapter especially for use with the ZEsarUX ZX Spectrum Emulator.",
"author": {
"name": "Thomas Busse"
},
Expand Down
37 changes: 29 additions & 8 deletions src/emuldebugadapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class EmulDebugAdapter extends DebugSession {
// Load files
try {
// Load user list and labels files
for(var listFile of Settings.launch.listFiles) {
for(let listFile of Settings.launch.listFiles) {
Labels.loadAsmListFile(listFile.path, listFile.useFiles, listFile.filter, listFile.addOffset, listFile.useLabels, (address, line) => {
// quick search for WPMEM
if(line.indexOf('WPMEM') >= 0) {
Expand All @@ -260,7 +260,7 @@ export class EmulDebugAdapter extends DebugSession {
}
});
}
for(var labelsFile of Settings.launch.labelsFiles)
for(let labelsFile of Settings.launch.labelsFiles)
Labels.loadAsmLabelsFile(labelsFile);
}
catch(err) {
Expand All @@ -281,7 +281,7 @@ export class EmulDebugAdapter extends DebugSession {
const fileName = 'TMP_DISASSEMBLY_' + area[0] + '(' + area[1] + ').asm';
const absFileName = Utility.writeTmpFile(fileName, text);
// add disassembly file without labels
Labels.loadAsmListFile(absFileName, false, undefined, 0, listFile.useLabels);
Labels.loadAsmListFile(absFileName, false, undefined, 0, false);
// "Return"
this.serializer.endExec();
});
Expand Down Expand Up @@ -402,12 +402,33 @@ export class EmulDebugAdapter extends DebugSession {

// Set breakpoints for the file.
Machine.setBreakpoints(path, bps, (currentBreakpoints) => {
// Convert breakpoints for vscode
const vscodeBreakpoints = new Array<Breakpoint>();
currentBreakpoints.forEach( bp => {
var vscBp = new Breakpoint(true, this.convertDebuggerLineToClient(bp.lineNr));
vscodeBreakpoints.push(vscBp);
/*
// Go through original list of vscode breakpoints and check if they are verified or not
let source = this.createSource(path);
const vscodeBreakpoints = givenBps.map(gbp => {
let verified = false;
// Check if breakpoint is present in currentBreakpoints
const lineNr = this.convertClientLineToDebugger(gbp.line);
for(let cbp of currentBreakpoints) {
if(cbp.lineNr == lineNr && cbp.filePath == path) {
verified = true;
break;
}
}
// Create new breakpoint
let bp = new Breakpoint(verified, gbp.line, gbp.column, source);
return bp;
});
*/

const source = this.createSource(path);
const vscodeBreakpoints = currentBreakpoints.map(cbp => {
const lineNr = this.convertDebuggerLineToClient(cbp.lineNr);
const verified = (cbp.condition != ''); // Is not verified if no condition is set
let bp = new Breakpoint(verified, lineNr, 0, source);
return bp;
});


// send back the actual breakpoint positions
response.body = {
Expand Down
18 changes: 12 additions & 6 deletions src/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const DBG_DISABLE_BREAKPOINTS = false;
* The breakpoint representation.
*/
export interface MachineBreakpoint {
bpId: number; /// The breakpoint ID/number
bpId: number; /// The breakpoint ID/number (>0)
filePath: string; /// The file to which the breakpoint belongs
lineNr: number; /// The line number in the file starting at 0
condition: string; /// Usually the pc value (e.g. "PC=0A7f")
condition: string; /// Usually the pc value (e.g. "PC=0A7f"). If empty, the breakpoint is not set.
}


Expand Down Expand Up @@ -883,11 +883,17 @@ export class MachineClass extends EventEmitter {
currentBps.push(ebp);
}
}
else {
// Breakpoint position invalid
const ebp = { bpId: 0, filePath: path, lineNr: bp.lineNr, condition: '' };
// add to array
currentBps.push(ebp);
}
});

// Now check which breakpoints are new or removed (this includes 'changed').
const newBps = currentBps.filter(bp => oldBps.filter(obp => obp.condition == bp.condition).length == 0);
const removedBps = oldBps.filter(bp => currentBps.filter(obp => obp.condition == bp.condition).length == 0);
const newBps = currentBps.filter(bp => bp.condition != '' && oldBps.filter(obp => obp.condition == bp.condition).length == 0);
const removedBps = oldBps.filter(bp => bp.condition != '' && currentBps.filter(obp => obp.condition == bp.condition).length == 0);

// remove old breakpoints
removedBps.forEach(bp => {
Expand All @@ -902,11 +908,11 @@ export class MachineClass extends EventEmitter {
});

// get all breakpoints for the path
const resultingBps = this.breakpoints.filter(bp => bp.filePath == path);
//const resultingBps = this.breakpoints.filter(bp => bp.filePath == path);

// Return the real breakpoints for the file and sync with the socket.
zSocket.executeWhenQueueIsEmpty( () => {
handler(resultingBps);
handler(currentBps);
});

}
Expand Down

0 comments on commit a6956f3

Please sign in to comment.