Debugging Web Modules
To debug Web Modules, you need to have the Google Chrome Browser installed. With a default installation, the IDEs will usually find Chrome automatically, but the following topics will help you set up Chrome or point your IDE to a custom Chrome version:
- Setting up for Web Module Development with Fire on Mac
- Setting up for Web Module Development with Water on Windows
- Setting up for Web Module Development with Visual Studio on Windows
When running your project from the IDE, the Debugger takes care of launching a new Chrome window and pointing it to an internal HTTP server that serves all the right files, including all the static files in the
Web folder of your project, as well as a virtual
wasm subfolder that contains the compiled binary and related files.
This way, the path relationship between the test
.html file (and related files you might add such as images or stylesheets) and the compiler-generated files is in tact.
By default, your project created with the Web Module template contains a dummy
index.html for debugging and testing purposes. That file will be loaded in Chrome, load in the compiled
.wasm binary, and initialize it. The file contains relative paths that expect the binary in the (virtual)
./wasm subfolder of the HTTP server.
There are two Project Settings used to control this behavior:
<DebugIndexHtmlFile>Web\index.html</DebugIndexHtmlFile>– specifies the test
.htmlfile. The path to the file (which usually is relative to the project, but may also be absolute) will determine the root folder for the HTTP server, while the filename itself will determine the URL to be opened in the browser on launch.
<DebugUrl>http://localhost:1234/</DebugUrl>– optionally, a full URL to a test server can be provided. If so, the debugger will not launch its own HTTP server, but assume a server is running at the given URL, and that you have set it up to properly serve the test HTML and the WebAssembly files.
Once your webpage and the .
wasm module is loaded, you can debug your code the same as you would any other project. For example, you can set Breakpoints to pause execution when a certain part of your code is it, and you will automatically "break" into the debugger, if any Exception occurs.