Skip to content
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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shs96c
Copy link

@shs96c shs96c commented Aug 30, 2024

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • 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

@tpasternak
Copy link
Collaborator

Unfortunately the setting doesn't work with gdbserver wrapper. I think it could be fixed here

if (useRemoteDebuggingWrapper.getValue()) {
String runUnderOption =
String.format(
"--run_under='%s' '%s' '%s' --once localhost:%d --target",
"bash",
GDBSERVER_WRAPPER.getValue(),
gdbServerPath,
handlerState.getDebugPortState().port);
builder.add(runUnderOption);
} else {
String runUnderOption =
String.format(
"--run_under='%s' --once localhost:%d",
gdbServerPath, handlerState.getDebugPortState().port);
builder.add(runUnderOption);
}

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

@ujohnny
Copy link
Collaborator

ujohnny commented Sep 3, 2024

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 ujohnny self-requested a review September 3, 2024 15:25
Copy link
Collaborator

@ujohnny ujohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Could you please update BlazeGDBServerProvider as @tpasternak suggested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Awaiting review from Bazel team on PRs product: CLion CLion plugin product: GoLand GoLand plugin product: IntelliJ IntelliJ plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants