Skip to content

Variable Substitution in launch.json not visible in debug configuration provider #85206

Closed

Description

Issue Type: Bug

According to this paragraph variable substitution is supposed to work also in launch.json, used to configure debug sessions. However it appears not to work, at least I don't get the resolved variables in my DebugConfigurationProvider.resolveDebugConfiguration function. The passed in options still contain the unresolved variables, making it so impossible to use the given values (e.g. the current file, given as ${file} to set up my debugger.

Here's a sshot that shows the extension host with the launch setting and the debug config resolver:

var-substitution

VS Code version: Code 1.40.1 (8795a98, 2019-11-13T16:47:44.719Z)
OS version: Darwin x64 19.0.0

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz (12 x 3500)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 32.00GB (9.08GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (21)
Extension Author (truncated) Version
dot Ste 0.0.1
numbered-bookmarks ale 6.2.1
spellright ban 3.0.48
vscode-svgviewer css 2.0.0
vscode-eslint dba 1.9.1
xml Dot 2.5.0
vscode-wasm dts 1.2.1
gitlens eam 10.2.0
tslint eg2 1.0.44
php-intellisense fel 2.3.13
vscode-mysql for 0.4.0
duk-debug Har 0.5.6
live-html-previewer hdg 0.3.0
vscode-auto-open-markdown-preview hnw 0.0.4
beautify Hoo 1.5.0
svg joc 1.0.5
vscode-phpfmt kok 1.0.30
vscode-antlr4 mik 2.2.3
prettify-json moh 0.0.3
debugger-for-chrome msj 4.12.1
vscode-yacc se2 1.1.0

Activity

  1. vscodebot commented on Nov 20, 2019

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. weinand commented on Nov 20, 2019

    @weinand
    Contributor

    By design variable substitution occurs after DebugConfigurationProvider.resolveDebugConfiguration and before passing the launch config to the debug adapter.
    This makes it possible to have DebugConfigurationProvider.resolveDebugConfiguration add additional variables.

  3. added
    debug
    on Nov 20, 2019
  4. mike-lischke commented on Nov 20, 2019

    @mike-lischke
    Author

    But how can I then determine the actual values for the variables if not in that method, which is supposed to resolve the configuration?

  5. weinand commented on Nov 20, 2019

    @weinand
    Contributor

    All resolved values are available in your debug adapter which is part of your extension.

  6. mike-lischke commented on Nov 21, 2019

    @mike-lischke
    Author

    Hmm, sorry, that makes not much sense given the description of the resolve function:

    Resolves a debug configuration by filling in missing values or by adding/changing/removing attributes.

    How can I change attributes, if I cannot understand them? Seems there is a discrepancy between the purpose you intent and what can be understood from the description.

    That bears a side question: if the resolve function is not intented to validate configuration values (and cancel the debug session if something is wrong), what else should we use instead for that kind of processing?

  7. weinand commented on Nov 21, 2019

    @weinand
    Contributor

    The description of resolveDebugConfiguration makes a lot of sense since "filling in missing" values and "adding/changing/removing attributes" can be done without a need to see the "final" values.

    Evidence for this you can see in node-debug's resolve method.

    Any validation that can only be performed on the final values can be done (and is actually done) in the debug adapter (see launchRequest in the node-debug DA).

    Having said this, I can still imagine to introduce a new aboutToLaunch method on the DebugConfigurationProvider that receives the "final" fully resolved debug configuration.

    I've changed this issue into a feature request and I'm now waiting for upvotes...

  8. added
    feature-request
    on Nov 21, 2019
  9. mike-lischke commented on Nov 21, 2019

    @mike-lischke
    Author

    I see your points, however launching the debug adapter might involve quite a few things to do, which are unnecessary when there are problems with the files being debugged. Hence my original idea was to figure out everything in the resolve function upfront, before I even create the debug adapter. I'll move my validation logic to launchRequest then. Thanks for the hint.

    A new validation function might still be useful (be it named aboutToLaunch or validate or whatever).

  10. weinand commented on Dec 20, 2019

    @weinand
    Contributor

    We will add another hook resolveDebugConfiguration2 to the DebugConfigurationProvider that receives the debug configuration with all variables resolved.

    I've created an extension API request for this: #87450

    With this API all code that relies on resolved variables can be moved from resolveDebugConfiguration to resolveDebugConfiguration2.

    Mike Lischke (@mike-lischke) Connor Peet (@connor4312) roblourens Isidor Nikolic (@isidorn)
    Please let me know if anybody has ideas for a better name than resolveDebugConfiguration2.

  11. mike-lischke commented on Dec 21, 2019

    @mike-lischke
    Author

    That's great news Andre Weinand (@weinand)! As for the naming I suggest processResolvedDebugConfiguration to indicate this something that follows the resolution step. Another name could be validateDebugConfiguration which also indicates that this is a step after resolution and should be used to check all final values for their correctness (do file exists? etc.). I prefer the second name, now that I found it :-)

  12. 1 remaining item

  13. isidorn commented on Dec 23, 2019

    @isidorn

    resolveDebugConfiguration2 works best for me. The name is clear that it does the same thing as resolveDebugConfiguration with minor differences.
    processResolvedDebugConfiguration is also ok for me.

    Some other naming ideas: handleResolvedDebugConfiguration, resolveResolvedDebugConfiguration (sounds funky)

    validateDebugConfiguration does not work for me since it sounds like it does more than what it actually will do

  14. weinand commented on Dec 23, 2019

    @weinand
    Contributor

    Johannes Rieken (@jrieken) processResolvedDebugConfiguration or resolveDebugConfiguration2, what do you prefer?

  15. weinand commented on Dec 23, 2019

    @weinand
    Contributor

    After talking to Johannes Rieken (@jrieken) we agreed on the expressive resolveDebugConfigurationWithSubstitutedVariables (which becomes a nominee at the VS Code longest-variable-name contest).

  16. isidorn commented on Dec 23, 2019

    @isidorn

    Works for me. At least it is clear what it does exactly.

  17. mike-lischke commented on Dec 23, 2019

    @mike-lischke
    Author

    If it's only about the variables substitution you could go another route: provide an API to resolve the values. It would be totally fine for me to call that to resolve all variables and act on them in the original resolveDebugConfiguration. You probably already have such a function interally. Just make it public and you you will not need that new hook.

  18. weinand commented on Dec 23, 2019

    @weinand
    Contributor

    Mike Lischke (@mike-lischke) yes, we've considered this as well but providing (and using) a variable resolver function as API is tricky because variables can be tied to commands which might result in arbitrary user interactions (e.g. if an interactive variable is used more than once, we only show the UI once and apply the resulting value in different places). So we really want to stay away from that approach and use the two-phase approach instead.

  19. weinand commented on Dec 23, 2019

    @weinand
    Contributor

    I've added a new optional hook resolveDebugConfigurationWithSubstitutedVariables to the DebugConfigurationProvider.
    Support for it will be available in the next Insiders (or immediately if you are running out of source).

    Please note: this is proposed API which might still change until the end of this milestone (January).

  20. removed this from the January 2020 milestone on Jan 8, 2020
  21. weinand commented on Jan 8, 2020

    @weinand
    Contributor

    /duplicate #87450

  22. added
    *duplicate
    on Jan 8, 2020
  23. vscodebot commented on Jan 8, 2020

    @vscodebot

    Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

    Happy Coding!

  24. weinand commented on Jan 8, 2020

    @weinand
    Contributor

    Mike Lischke (@mike-lischke) the new API is now official and in vscode.d.ts.

  25. locked and limited conversation to collaborators on Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicatedebugfeature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions