Test environment:

Ubuntu 22.04.2 LTS
Google Chrome
emcc 3.1.33
clang version 17.0.0
Target: wasm32-unknown-emscripten

Write a simple test program.

main.c:

#include <stdlib.h>

void assert_less(int x, int y) {
  if (x >= y) {
    abort();
  }
}

int main() {
  assert_less(10, 20);
  assert_less(30, 20);
}

Compile it with DWARF debug information included.

emcc -g main.c -o main.html

Download chrome (stable version):

https://www.google.com/chrome/

Install chrome on ubuntu.

sudo dpkg -i google-chrome-stable_current_amd64.deb

Set up a light http server for viewing it on chrome.

python3 -m http.server 4001

Then open the web page at http://0.0.0.0:4001/main.html

Go to Sources -> Breakpoints -> Pause on caught exceptions, check it.

Group source files.

Allow DevTools to load resources in setting.
Make sure WebAssembly Debugging works in setting.

Next, we can click on the location in the call stack to open the corresponding source file.

Categories: Web

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] Debug C/C++ WebAssembly On Chrome […]

XOR Strings
: Input your strings, the tool can encrypt and decrypt them.

X
1
0
Would love your thoughts, please comment.x
()
x