Hacker News new | ask | show | jobs
by umanwizard 3482 days ago
You laugh, but Python works the same way.
3 comments

I recently learned you can do a similar thing with C/C++ too. Programmatically raise a SIGINT when running under gdb, and gdb will intercept that signal, at which point you can step through the code.
Yeah, in Windows you have the `DebugBreak/__debugbreak()` function [0].

For POSIX you have `raise(SIGTRAP)` or gcc you have `__builtin_trap()` which actually has some caveats. [1]

[0] https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...

[1] https://stackoverflow.com/questions/173618/is-there-a-portab...

I was laughing in a good way, it's always cool to see not only the "thing" but how it was debugged.

As for python, I debug it by adding print() statements. No debugger involved. If there's a way to insert debugger breakpoints in the source, I'm unaware of it.

import pdb ; pdb.set_trace()
Pdb has saved my sanity so many times I have lost count.
And I often find this very useful in JavaScript