This document if for community members who wants to help debug and track down issues. Trying to support multiple OS's and versions of perl and perl5db is ambitious. Adding node and the vs code api to the calculation things just get harder to debug and workaround.
Short overview of how the extension works:
The extension provides a default configuration / settings
Details are in:
- The extension starts up in a separate process from vscode, a
debug server
- The
debug server
will then spawnperl5db
- somthing likeperl -d
(unless overwritten by user settings)
The current implementaion uses 3 streams for communicating with the spawned perl5db
these are:
in
stream for writing commandsout
stream for reading output fromperl5db
err
stream is used for getting the running program output
The extension basically just passes on any data from err
stream to the debug console
in vscode.
For talking with perl5db
it's using the streamCatcher to queue the commands and link together the command
and perl5db
response. The streamCatcher
is just a basic IO layer.
The adapter is the abstraction layer handling parsing
the perl5db
response data. It's also providing the perl5db
commands as a typescript api. So if some commands are not working correctly then this would be the first place to look.
The perlDebug.ts is the layer wiring up the perl5db adapter
to the vs code debugger api. This is where requests come in from the user / vs code and where we send a response that will populate inspector/watchers/breakpoints/exceptions or debug console view. (the cool part)
There are some gotchas around how filenames
and paths
are handled in the different places - actually mostly between perl and node - and mostly around absolute/relative paths and system path separators.
Theres also some inconsistencies in how the vs code debug api handles variables/breakpoints vs watchers etc. making somethings hard to keep track of - things we might workaround later on
In extension.ts
you can set EMBED_DEBUG_ADAPTER
to true
during
development. Visual Studio Code will then run the extension and any
instance of the debug adapter in the same process, so you can have
breakpoints in extension.ts
and other parts of the code that work
during the same session. This option is not suitable for releases.
Theres added a test matrix making it possible to test in macOS
/linux
and windows
- it's not perfect and not complete. First issue is to have a stable way of installing different distributions of perl is not solved.
The streamCatcher
and adapter
are both fairly well covered, but coverage of perDebug
is in it's beginnings.
If you find an issue you can try running the tests locally, it's a great help to see if any fail.
For running the tests you'll need to install nodejs. install nodejs
You can use both npm
and yarn
for installing the test depencencies.
npm
comes bundles with nodejs, but also take a look at yarn
- Install test depencies
npm install
oryarn
- Run tests
npm test
oryarn test
- If any of the tests fails then theres a bug to fix
- If no tests fail theres a test to write to replicate
If you are developing and want the tests running while editing the source in src/
then run:
yarn test:w
And live build and tests are up
If you found a bug and found a fix then don't be shy - do a pull request. When tests are passing and code review is done it's ready to be released.
If you haven't then take a look at github's "collaborating with issues and pull requests" you can tag issues in commits making it easier to track things
Happy coding!