intellij icon indicating copy to clipboard operation
intellij copied to clipboard

feat(clion): Add working directory to CLion Run configurations

Open shs96c opened this issue 1 year ago • 2 comments

Checklist

  • [ ] I have filed an issue about this change and discussed potential changes with the maintainers.
  • [x] I have received the approval from the maintainers to make this change.
  • [x] This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See the Contributions section in the README for more details.

Discussion thread for this change

Issue number: N/A

Description of this change

In CMake CLion, one has the option of setting a working directory under which the binary will be run. This is useful for debugging single binaries (i.e. they need no runfiles) under different contexts.

This PR adds some of that capability to the Bazel plugin by creating a setting for run configurations, and adding it to the Cidr debug process handlers.

Limitations:

  • For now, this only applies to CLion debugging configurations. Other debuggers will have to be modified to use the setting, as well as non-debug configurations.
  • Previously, we defaulted to the runfiles dir as the pwd if there was one. The explicit working dir has precedence over it now.
242549858-02f0d9e3-aa6a-4e78-9bf3-90f25b296e60

shs96c avatar Aug 30 '24 16:08 shs96c

Unfortunately the setting doesn't work with gdbserver wrapper. I think it could be fixed here https://github.com/bazelbuild/intellij/blob/9343e7e9dce962b5e5358bede4083e3a57a607bd/clwb/src/com/google/idea/blaze/clwb/run/BlazeGDBServerProvider.java#L100-L115

maybe we could just add cd <path> && there

tpasternak avatar Sep 02 '24 10:09 tpasternak

Indeed since gdbserver is a default run type for linux I'd appreciate to see its support. Though I'm unsure if we should cd in run_under as I'd expect it to inherit cwd from bazel cwd.

edit: unfortunately cwd is not inherited, so run_under should be adjusted

ujohnny avatar Sep 03 '24 15:09 ujohnny