-
Notifications
You must be signed in to change notification settings - Fork 223
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
Run target in debugger #373
Comments
Not a core developer, but another constant debugger user. I'm just curious how you envision this working. buck2 would have to know which debugger you want to use, and it would have to know how to find it on your system. Maybe you want to launch it in Visual Studio Code, or in Visual Studio, or in WinDbg for example. If you're a Visual Studio user, then perhaps what you really want is IDE integration, because then you just hit F5 and it works. It seems like this is something that would be pretty trivial to implement outside of buck2. You could have a python script (for example) that ran |
FWIW, you can just use something like If you need something reusable, you can write a macro for it (e.g. write your own See also #86; assuming #86 (comment) was implemented, you'd be able to also do this in BXL trivially, and then map the long-and-verbose BXL command back to a quick shorthand such as |
Thanks for the comments!
I'm not totally sure yet, but to me important points include:
I'm not (anymore), I personally just want to get gdb running in a terminal. I agree that debugging from within an IDE should be solved by whatver the IDE integration is, but I don't know if that also applies to e.g. standalone graphical debuggers, which I would expect not to be build system aware.
Sure, but the big revelation for me when working in a debugger-first environment was how much of an impact there is that it is the path of least resistance. Then again, I would understand if this was out of scope for a build system. @thoughtpolice: very interesting suggestions, though I don't understand the implications as I don't know BXL yet. Some initial concerns that you might have answers to:
|
By the way @zjturner, since you've mentioned that you're a constant debugger user, what is your current workflow with buck2? Say that a That's what I've been doing so far and it's... not great; so maybe I'm just missing something. |
TBH I haven't gotten that far yet. I'm porting a very large codebase, and it's going to be a long effort before I get to the point that I can even think about debugging some targets. That said, it will probably be some kind of external solution. I don't think it usually makes sense to integrate debugging with the build system. The build system should just build, but it should also provide the necessary discoverability and introspection necessary to allow external integration of the build with debuggers. That probably means either IDE integration or a shell / python script that runs buck2 targets --show-output behind the scenes and launches the executable. IDE integration also applies to GDB or LLDB too. You can alias a command in GDB to run a GDB Extension script, so from within your GDB terminal you can write something like |
I'm fairly supportive of this idea. Telling a user to dump their last run command and slip a |
I think it’s extremely different, for all of the reasons described earlier. But in particular, which debugger and what is the interface for talking to it? there is one way to run a process, by calling exec or CreateProcess. No configuration is required because you are interfacing directly with the operating system. if you’re going to run a debugger, user configuration is necessary because debugger is third party software buck2 has no control over. Maybe it's not in I actually think it’s optimal to do this in the reverse direction (teach debugger about build system rather than teach build system about debugger). It’s very simple (couple of line debugger extension script) and supports every possible use case. Furthermore, with the exception of Linux / GDB, most people are using graphical debuggers that make more sense to integrate with from the IDE side. So it feels like the idea of integrating debugging as a first class thing in buck2 is very very specific to Linux / GDB, which rules it out by virtue of not being general purpose enough to warrant first class inclusion in the core runtime.
The approach I suggested in my earlier message is quite a bit more streamlined than this. You don't run a command and slip gdb into it. You instead write |
The configuration that you're describing could be exposed by the toolchain, and there doesn't need to be a default. I also don't really see how it is so much more complicated than
Which sounds exactly like the toolchains that you'd have to setup in buck2 as well anyway. I get that buck2 is not a debugger configuration system, but this could all easily be passed e.g. to a toolchain as a
And people using an IDE are more likely to build/run/test from within it, yet buck2 exposes user-facing commands for that.
I don't have statistics on debugger popularity/usage, but debuggers outside of GDB and lldb also work in a standalone way (e.g. RemedyBG, DDD and I'm sure more). The fact that not many build systems integrate with them is a mistake to me. Also, oher build systems don't have native, convenient way of running specific targets or tests, whereas buck2 does, and for good reason. On the other hand, it really feels like a missing piece to be able to conveniently build, run, test your code, but just not debug it.
I essentially do this at work on a CMake codebase and it's annoying that it's just a local hack. Even if I check it in, it wouldn't be part of other people's PATH and would just be a random script that some people might want to use, as opposed to something well integrated and fairly standard. I'll resort to scripting for myself if I have to, but scripting around an otherwise consistent and accessible system for something common is weird to me. Anecdotally, I've suggested a colleague to run his code in a debugger to quickly figure out where a segfault was happening earlier today, but it was too much of a hassle for them to setup a debugger, where I wish they could have just |
Back at the studio I was at, we solved this by adding a Internal to Meta, the debugging tooling prefixes buck2, however I'm naive to its implementation. Perhaps another team member might explain. Basically it's a |
A common workflow for me is to always run binaries (both applications and tests) under a debugger, so that I can immediately investigate what is going on (as a side note, this is very common among Visual Studio users, e.g. in the games industry).
This is very useful to save time and to catch rare bugs, but it empirically only really works if it's convenient enough. Unfortunately, manually typing out
buck-out
paths or hacking around the output ofbuck2 build --show-output
is hardly convenient.Would you be open to adding support for this use-case via a new command/flag (e.g.
buck2 debug
orbuck2 run --debug
)? If so, I'd be happy to discuss the actual design and/or work on the implementation.The text was updated successfully, but these errors were encountered: