-
Notifications
You must be signed in to change notification settings - Fork 305
Relay correct source paths in DWARF debug info #2303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently, this PR sets the correct source maps for php-src and php_wasm.c. ⛔ Some things aren't implemented yet:
|
echo -n ' sapi/cli/php_cli_process_title.c sapi/cli/ps_title.c sapi/cli/php_http_parser.c sapi/cli/php_cli_server.c sapi/cli/php_cli.c ' \ | ||
echo -n ' /root/php-src/sapi/cli/php_cli_process_title.c /root/php-src/sapi/cli/ps_title.c ' \ | ||
'/root/php-src/sapi/cli/php_http_parser.c /root/php-src/sapi/cli/php_cli_server.c ' \ | ||
'/root/php-src/sapi/cli/php_cli.c ' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making these paths absolute helped the php-src mapping to be applied properly.
@@ -2069,6 +2087,7 @@ RUN set -euxo pipefail; \ | |||
-s MIN_NODE_VERSION=200900 \ | |||
-s INITIAL_MEMORY=1024MB \ | |||
-s ALLOW_MEMORY_GROWTH=1 \ | |||
-s ASSERTIONS=0 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed mistakenly by #2231. Without disabled ASSERTIONS, php-wasm/web builds seem to fail to load due to assertion errors.
Note: |
I implemented building libsqlite3 with DWARF debug info and, using a JSPI build, tested that it was possible to hit breakpoints in both php_wasm.c and sqlite3.c in the same build with no additional config. |
To build libsqlite3 with DWARF debug info:
Then build php-wasm/node with that libsqlite with:
|
Let's go ahead and mark this as ready for review because it is better than what we have today. Once we have this, I plan to write instructions for debugging php-wasm. Compared to before this PR, it should be a lot easier to get started. |
Really good work, thank you @brandonpayton ! |
Motivation for the change, related issues
It is possible to build php-wasm with DWARF debug info today, but actually using the debugger to step through source lines requires additional configuration to map original source file paths (from Docker) to actual source file paths in the host OS.
The purpose of this PR is to set the correct source paths at build time so folks can debug php-wasm without additional configuration.
This is not just a matter of convenience. Some debuggers (VSCode) only allow a single path mapping, so we cannot step into source files from different directory subtrees at the same time (for example, php-src and php_wasm.c). It would be simpler, faster, and more complete for debugging with DWARF to work out of the box.
Implementation details
This PR adds compilation flags like the following to establish compilation dir and source file paths relative to that:
-fdebug-compilation-dir=${OUTPUT_DIR_FOR_SOURCE_MAP_BASE}/${PHP_VERSION_ESCAPED}/
-fdebug-prefix-map=/root/php_wasm.c=${DEBUG_OFFSET_TO_PHP_WASM_PACKAGE}/compile/php/php_wasm.c
Testing Instructions (or ideally a Blueprint)
For php-wasm/node
run_cli()
inphp_wasm.c
For php-wasm/web
npm run dev
php_wasm.c
. If the file shows up, it indicates there are DWARF mappings to that file.zend_alloc.c
. If the file shows up, it indicates the DWARF mappings to PHP source files are working.