You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add WITH_DEBUG option for building php-wasm with DWARF debug info (#47)
## Motivation for the change, related issues
Prior to this PR, we have built with DWARF debug info by manually
editing our php/Dockerfile, and it would be much better for devs to just
supply a command line option for creating such builds.
## Implementation details
This PR adds a `WITH_DEBUG` option that can be used like:
`npx nx recompile-php:asyncify php-wasm-web -- --PHP_VERSION=8.4
--WITH_DEBUG=yes`
It recompiles php-wasm to include DWARF debug info which may be used for
more detailed debugging in Chrome Canary. In contrast to debugging with
source maps, this way allows you to see more info like named variable
values in the step debugger. See
https://developer.chrome.com/docs/devtools/wasm for more info.
I considered merging the `WITH_SOURCEMAPS` option with this one, but in
my testing, it seemed like building with both DWARF info and sourcemaps
weakened the debug experience. For example, when building with just
DWARF debug info and debugging in Chrome canary, I noticed that I could
see the value of both `size` and `alignment` vars in the PHP memory
allocation code, but when building both debug info and sourcemaps, I
could only see the value of the `size` var. It's possible the difference
is a coincidence or due to some other issue, but I observed this
difference two or three times when testing different build types.
## Testing Instructions (or ideally a Blueprint)
- Install Chrome Canary if needed
- Add [the C/C++ Dev Tools Support
extension](https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb)
to Chrome Canary
- Run `npm run dev`
- Test building with source maps
- Run `npx nx recompile-php:asyncify php-wasm-web -- --PHP_VERSION=8.4
--WITH_SOURCEMAPS=yes`
- Make sure Playground web loads from the local server with PHP 8.4
selected
- Open dev tools to confirm you can open PHP source files like `main.c`
- Test building and using DWARF debug info
- Run `npx nx recompile-php:asyncify php-wasm-web -- --PHP_VERSION=8.4
--WITH_DEBUG=yes`
- Open the [debug extension
options](chrome-extension://pdcpmagijalfljmkmjngeonclgbbannb/ExtensionOptions.html)
- Add a path substitution to map `/root/php-src/` to the absolute path
the the php-src directory created by the php-wasm build.
- Note: Within your Playground repo, the relative path will be:
`packages/php-wasm/web/public/php/asyncify/8_4_0/php-src/`
- Make sure Playground web loads from the local server with PHP 8.4
selected.
- Open dev tools.
- Reload Playground (reloading often seems to be needed to properly see
the C source files).
- Open the PHP source file `zend_alloc.c`
- Locate the function `static void *zend_mm_chunk_alloc_int(size_t size,
size_t alignment)`
- Set a breakpoint on the first line that permits breakpoints
- Reload Playground and observe that you hit that breakpoint
- Confirm you can observe the function param values for `size` and
`alignment`
- Test normal php-wasm build
- Run `npx nx recompile-php:asyncify php-wasm-web -- --PHP_VERSION=8.4`
and confirm that Playground loads from the
local server with PHP 8.4 selected.
0 commit comments