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

Support interactive gdb for running individual tests #2815

Closed
htuch opened this issue Apr 13, 2017 · 7 comments
Closed

Support interactive gdb for running individual tests #2815

htuch opened this issue Apr 13, 2017 · 7 comments
Assignees
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request
Milestone

Comments

@htuch
Copy link

htuch commented Apr 13, 2017

Today, --run_under=gdb doesn't allow interactivity, as there is no stdin. It's possible to make a remote GDB flow with --run_under=gdbserver work, but it's a pain and requires wrapping to make presentable to developers who are familiar with a gdb <my test binary> kind of flow.

I managed to make this work for the Envoy project in envoyproxy/envoy#749, but this is a bit of a hack - I get --run_under to point to a script that scrapes out the environment and then generates another script to invokes the test binary and gdb with.

There should probably be a cleaner way to do this directly from Bazel.

CC envoyproxy/envoy#415

@aehlig aehlig added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request labels Apr 18, 2017
@aehlig
Copy link
Contributor

aehlig commented Apr 18, 2017

Thanks for reporting and I'm glad you found a solution. I see the need for a feature like this, and one way to implement it might be to add a similar wrapping to to bazel's standard skylark library.

@damienmg damienmg removed their assignment Jun 26, 2017
@damienmg damienmg added this to the post-1.0 milestone Jun 26, 2017
@lberki lberki added P1 I'll work on this now. (Assignee required) and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) labels Feb 2, 2018
@lberki lberki self-assigned this Feb 2, 2018
@lberki
Copy link
Contributor

lberki commented Feb 2, 2018

What we'll do is to make it so that if you do bazel run <test target>, you'd get an actual interactive shell done by exec()ing the test from the client.

This will also obviate the need for the blaze-run.sh that does the same and that we haven't open sourced for reasons of shame. A long-standing bug to be solved!

@lberki
Copy link
Contributor

lberki commented Feb 2, 2018

/cc @laszlocsomor -- I'm not planning to implement this for Windows and replace it instead with an "ERROR: not implemented" message

@laszlocsomor
Copy link
Contributor

Acknowledged, thanks for letting me know!

@lberki
Copy link
Contributor

lberki commented Feb 2, 2018

Note to self: make it possible to convey the current directory of the client somehow because that's what one would intuitively expect. This requirement is at odds with using bazel run to run tests because tests expect a specific pwd, so we'll have to come up with something smart.

@htuch
Copy link
Author

htuch commented Feb 2, 2018

So, one comment on the bazel run approach. I think that this will get us most of the way there. Where it falls slightly short is it's not a full repeater environment for a bazel test execution, since the cc_test args are not supplied AFAIK to the bazel run invocation. So, I think ideally if we could use whatever mechanism is being built but still get a full fidelity test execution it will be super helpful.

@lberki
Copy link
Contributor

lberki commented Feb 2, 2018

Well, you are 50% right :) I agree that it's not a full fidelity execution and that was one of the disadvantages of the approach I'm taking, but it gets us there much earlier than the 100% solution and it has the advantage of finally fixing a few decada e-old (!) bugs in bazel run.

However, the difference is not the command line arguments. Those will be handled correctly. It's that if I navigated through our layers of abstraction well, you won't get a sandbox with bazel run. Nor a timeout, but I doubt that's productive when debugging anyway.

bazel-io pushed a commit that referenced this issue Feb 5, 2018
… direct

child of the process where the Blaze client itself was run.

Limitations:

- Untested on Windows; it should work because ExecuteProgram() is implemented there, too, but since Windows doesn't support exec(), there is at least one process in between

Progress towards #2815.

RELNOTES[NEW]: The new "--direct_run" flag on "blaze run" lets one run interactive binaries.

PiperOrigin-RevId: 184528845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request
Projects
None yet
Development

No branches or pull requests

6 participants