maziac / DeZog

Visual Studio Code Debugger for Z80/ZX Spectrum.
MIT License
210 stars 34 forks source link

Reverse engineering: Call Graph and Flow Chart failing to render #108

Closed zx-ade closed 1 year ago

zx-ade commented 1 year ago

I am using the reverse engineering feature and am able to build up a personal disassembly file from a .nex binary running on CSpect. However when I try to generate a "Call Graph" or "Flow Chart" I get an initial error in the console

"Error: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined"

subsequent attempts give the error

"Error: n.default is not a function"

It is the same regardless of the binary I use or the location in the disassembly file (either personal or "disasm.list"). I tried with your sample Next program "z80-sample-program.nex" and the same "fill_bckg_line" subroutine shown in the example (at address $6017) and I get the same errors.

I am on Windows 10 Home (22H2) and running... VS Code v1.75.1 DeZog v3.2.1 CSpect v2.19.1.0 (with DeZogPlugin v2.1.0.31481)

maziac commented 1 year ago

I found the problem. In 3.2 I changed to esbuild packaging. But that dropped the flowchart etc. functionality. Please try the attached vsix file. dezog-3.2.2-rc1.vsix.zip

zx-ade commented 1 year ago

I installed that revised extension but when I launch DeZog it briefly shows the disassembly control bar, but with the 'continue' button missing, and after a few seconds the control bar disappears and no active debug session occurs. I noticed with version 3.2.1 it shows 'DeZogPlugin v2.1.0.31481' initialized, in the console, but nothing appears in the revised version. I then checked the VS Code extension log and it shows this...

2023-02-24 17:07:12.049 [error] Activating extension maziac.dezog failed due to an error:
2023-02-24 17:07:12.049 [error] Error: Cannot find module '@aduh95/viz.js/async'
Require stack:
- c:\Users\Adrian\.vscode\extensions\maziac.dezog-3.2.2-rc1\out\extension.js
- c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
    at i._resolveFilename (node:electron/js2c/utility_init:17:840)
    at Module._load (node:internal/modules/cjs/loader:832:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:122:13360)
    at g._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:117:62400)
    at E._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:117:61793)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at p (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
    at Object.<anonymous> (c:\Users\Adrian\.vscode\extensions\maziac.dezog-3.2.2-rc1\out\extension.js:170:49953)
    at u._compile (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
    at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:122:13360)
    at g._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:117:62400)
    at E._load (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:117:61793)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Function.r [as __$__nodeRequire] (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:5:101)
    at f.pb (c:\Users\Adrian\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:117:63664)
    at async Promise.all (index 0)

I can confirm that in the unpacked extension location in .vscode the referenced package "@aduh95/viz.js" is missing from the node_modules directory.

maziac commented 1 year ago

This all has something to do with the esbuild bundler. I can start the program and debug it without any problems build by esbuild and it will show the flowcharts. But when I put in a vsix package it stops working, even if the npm package is present. I tried some more and it seems it has to do with a worker thread that is used in the duh95/viz package. Using the sync API seems to work fine. So I'm switching to the sync API for now. Please try the attached vsix and especially let me know if you experience any blocking when generating flow chart, caller graphs or a smart disassembly. dezog-3.2.2-rc2.vsix.zip

zx-ade commented 1 year ago

Excellent those features are working now! The flow chart and caller graphs are both appearing and look to be really powerful and useful to get an overview of the code structure. Not used the smart disassembly yet but I see that you have updated the documentation on reverse engineering so will take a close read through that now that everything is working. Also not experiencing any 'blocking' when running any of these features.

maziac commented 1 year ago

Good to hear that it is working. In case of any problem let me know.