godebug icon indicating copy to clipboard operation
godebug copied to clipboard

Flag to automatically break at program/test start

Open willfaught opened this issue 10 years ago • 4 comments

I suppose this can always be done manually by putting _ = "breakpoint" as the first line in your main or Test* funcs, but it would be really handy to be able to go to any main package and just do godebug run or godebug test and be debugging immediately.

Perhaps an optional -debug.break flag or something could enable this: godebug run -debug.break and godebug test -debug.break

willfaught avatar Jul 07 '15 23:07 willfaught

This is doable. It's not something I have wanted myself, though -- can you give an example where this would be helpful, so I can better understand the use case?

One thing I have considered doing is automatically inserting a breakpoint at program/test start when there are no other breakpoints. Would that provide what you want? Or are there times when you have inserted explicit _ = "breakpoint" lines in your source and you also want to beak at program/test start?

jeremyschlatter avatar Jul 08 '15 05:07 jeremyschlatter

Automatically inserting a breakpoint at program/test start when there are no other breakpoints would be perfect.

willfaught avatar Jul 08 '15 21:07 willfaught

Not to necro this... but for use in environments with strict code quality control, having devs forget to remove _ = "breakpoint" lines when committing becomes an annoying overhead problem. So related to this particular feature request, would also be nice to have the ability to pass in breakpoints via the command line by specifying the file+line number. Something like: godebug run -break=file1.go:34,file2.go:183 ...

blamarche avatar Feb 16 '16 16:02 blamarche

I've had that problem too. I like that idea. The ability to name funcs/methods to break at the start of would be useful too.

willfaught avatar Feb 16 '16 20:02 willfaught