3 ms·
To get the callstack before the exceptions unroll, on Windows you can utilize https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingap
by malkia 7y ago
To get the callstack before the exceptions unroll, on Windows you can utilize https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-addvectoredexceptionhandler https://docs.microsoft.com/en-us/windows/win32/api/errhandli... but then you would have to skip few specific exceptions (that are normally issued, since these come really fast, and you'll see them)
- quietbritishjim 7y agoUnless I've misunderstood the context, you can just open the "exceptions" debugging pane and check a few checkboxes. Then when the exception gets thrown the whole thing stops in a debugger and you can do all the usual things including look at the stack trace, indirect local variables at the throw point, etc.
- ComputerGuru 7y agoThat’s for doing it in code, without a debugger attached.
- pjmlp 7y agoOn Windows there is always Dr.Watson to give an helping hand, even without debugger.
- malkia 7y agoIs this still a thing? I've never encountered Dr.Watson recently. I do remember really long time ago Soft-ICE - that was exciting back then - debugging DOS/Windows really low level (I think it was through serial port on another machine)....
- quietbritishjim 7y agoAh OK. But the context was "students in college ... who were just starting out". I would say they would be running their programs, at least initially, in an IDE. And they should be using an IDE to develop: getting students to develop without IDE support is just unfair (although I know people get religious about using a text editor for code development). This is how I keep finding new grads who have no idea how to use a debugger e.g. just set a breakpoint and inspect variables.
- malkia 7y agoSorry, I'm lately in the "CI" mood, testing, automation so bit became a bit of habit to spawn what I've learned last few months. The Visual Studio Debugger is simply the best. Okay, it's not a powerhouse like WinDBG, or have the knowledge of IDAPro, and various other cool debuggers (OllyDbg, others..), but it's the easiest one to learn (IMHO), and teach. Few bits and tricks, press F5 and you are done :)
- ComputerGuru 7y agoIn Windows, you’ll typically always have symbols available regardless of the compilation mode since PE executables (always?) store their debug info and symbols in an external debug symbols database file (.pdb) rather than in the binary itself. (This is now possible with ELF/DWARF too, I believe).