diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps')
5 files changed, 38 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/README.md b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/README.md new file mode 100644 index 0000000000..4b4c269f57 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/README.md @@ -0,0 +1,20 @@ +# Building WebAssembly source with source maps + +First download and install WASI SDK: +https://github.com/WebAssembly/wasi-sdk/blob/47e5865191c02a8943a1ce2dfb202167219435b8/README.md +``` +export WASI_VERSION=12 +export WASI_VERSION_FULL=${WASI_VERSION}.0 +wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz +tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz + +export WASI_SDK_PATH=`pwd`/wasi-sdk-${WASI_VERSION_FULL} +CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" +``` + +Then, build the wasm file + its source map file +``` +$CC --target=wasm32-unknown-unknown-wasm -nostartfiles -nostdlib -Wl,-no-entry,--export=fib -g fib.c -o fib.wasm + +python3 wasm-sourcemap.py fib.wasm -o fib.wasm.map --dwarfdump=$WASI_SDK_PATH/bin/llvm-dwarfdump --source-map-url=https://example.com/browser/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm.map -w fib.wasm +``` diff --git a/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.c b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.c new file mode 100644 index 0000000000..19afc33c60 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.c @@ -0,0 +1,17 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +void swap(int* a, int* b) { + int t = *a; + *a = *b; + *b = t; +} + +int fib(int n) { + int i, t, a = 0, b = 1; + for (i = 0; i < n; i++) { + a += b; + swap(&a, &b); + } + return b; +} diff --git a/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.debug.wasm b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.debug.wasm Binary files differnew file mode 100644 index 0000000000..be261987ae --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.debug.wasm diff --git a/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm Binary files differnew file mode 100644 index 0000000000..d4b5d33416 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm diff --git a/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm.map b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm.map new file mode 100644 index 0000000000..32e295cf56 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/wasm-sourcemaps/fib.wasm.map @@ -0,0 +1 @@ +{"version":3,"names":[],"sources":["fib.c"],"sourcesContent":null,"mappings":"uEAGA,oCACW,OAAD,OAAJ,OACE,OAAD,OAAJ,OAAE,OACE,OAAJ,OAAE,OACL,CAAA,GAEA,6CACY,OAAO,OACV,OAAK,WAAI,OAAF,eAAd,8CACO,OAAH,qBACF,UAFkB,yBAApB,EAAA,EAIO,OAAP,sBAAA"}
\ No newline at end of file |