emscripten-core / emscripten-core/emscripten

Generated source map does not specify sources properly

Open
#14,831 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hello.
I have compiled my c++ project to wasm file and and then I load it to html.
No compile Errors detected but have some Runtime Errors when execution.
So I need to debug it but it appears that generated source map doesn't match with source files.

I compiled source with following flags.

` -g4 -v -s WASM=1 -s SAFE_HEAP=0 -s TOTAL_MEMORY=1024mb -s TOTAL_STACK=64mb -s LLD_REPORT_UNDEFINED -s DISABLE_EXCEPTION_CATCHING=0 -Oz -s EXPORTED_FUNCTIONS='["_cardScan", "_cardDetect"]' -s EXPORTED_RUNTIME_METHODS='["cwrap"]' -gsource-map --source-map-base http://localhost:8000/`

And generated source map is following.

`{"version":3,"sources":["../../../../../../../b/s/w/ir/k/install/emscripten/cache/sysroot/include/c++/v1/stdexcept","../../../../../../../b/s/w/ir/k/install/emscripten/cache/sysroot/include/c++/v1/string","../../../../../../../b/s/w/ir/k/install/emscripten/cache/sysroot/include/c++/v1/locale","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/pthread/library_pthread_stub.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stat/fstat.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/fcntl/open.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fgets.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fopen.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fmemopen.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/vsscanf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/sscanf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/ofl_add.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/vfscanf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/ferror.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/sprintf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fputc.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/remove.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/ofl.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fseek.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fclose.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__fmodeflags.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__toread.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fread.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fflush.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/fscanf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/rewind.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__string_read.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/stdout.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__stdio_read.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__stdio_seek.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/vsprintf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/tmpfile.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/putchar.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/vsnprintf.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__stdio_write.c","../../../../../../../b/s/w/ir/k/install/emscripten/system/lib/libc/musl/src/stdio/__uflow.c",
...... .......... ............. .......... ..........
AADQ,AAAH,MAAG,UACR,KAAF,cAMI,QAAV,UACQ,aACA,QACT,IAGA,GACmB,OAKV,IAHR,UACI,2BAEG,SAAgB,KAAvB,EC9BD,CAES,AADG,IACH,IADG,OACH,KAAuB,IAA/B,ECUD,YAGC,OACM,AAAU,QAAV,QAEN,SAID,YAGC,OACM,AAAiB,QAAjB,QAEN,SC7BD,GAEC,gBAC2B,AAD3B,AACM,OADN,KAC8B,uDAE9B,EEED,SAKqB,OAAmB,UAAT,cAA9B,WAC2B,8BAA3B,SAGA,OAAO,SAAK,SAAZ,MAJsC,KAMvC"}`

So below error message appears when click source in browser.

`Could not load content for http://localhost:8000/b/s/w/ir/k/install/emscripten/cache/sysroot/include/math.h (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE)`

Operating System is "Ubuntu 20.04", emcc version is 2.0.25, clang version is 13.0.0.

I don't have any idea why source map contains path like `"../../../../../../../b/s/w/ir/k/"`.
Did I miss any environment variable or compile flag for source map generating?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.