www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - automatic debugging / disabling D's built-in exeption handler

reply Bill Baxter <wbaxter gmail.com> writes:
By following the instructions given, eg, here:


it should be possible to make the debugger pop up automatically for 
programs that have exceptions.

According to the article above:
"WinDbg will be launched if an application throws an exception while not 
being debugged and does not handle the exception itself"

Apparently D does some sort of top-level catch of such exceptions right 
now, because sticking an "asm { int 3; }" in the code just prints the 
message "Error: Win32 Exception" instead of launching the debugger.  Is 
there some way to disable that?

--
Really what I was trying to do was see if I could get Visual Studio to 
debug D code.  Actually it sort of works.  If you have a program with a 
main loop, you can use visual studio's Tools->Debug Processes... to 
attach to the running process.  If you've built your program with -g, 
you can see the stack trace and step through the program normally, and 
even set breakpoints.

But you can't examine variables.  VisualStudio could tell that there was 
a "this" pointer, and knew it was of type MyClass, but it couldn't tell 
what was inside of 'this'.  I wonder if there's a way to make a Visual 
Studio plugin that would give you this ability?

--bb
Nov 05 2006
next sibling parent reply Sean Kelly <sean f4.ca> writes:
Bill Baxter wrote:
 By following the instructions given, eg, here:

 
 it should be possible to make the debugger pop up automatically for 
 programs that have exceptions.
 
 According to the article above:
 "WinDbg will be launched if an application throws an exception while not 
 being debugged and does not handle the exception itself"
 
 Apparently D does some sort of top-level catch of such exceptions right 
 now, because sticking an "asm { int 3; }" in the code just prints the 
 message "Error: Win32 Exception" instead of launching the debugger.  Is 
 there some way to disable that?
 
 -- 
 Really what I was trying to do was see if I could get Visual Studio to 
 debug D code.  Actually it sort of works.  If you have a program with a 
 main loop, you can use visual studio's Tools->Debug Processes... to 
 attach to the running process.  If you've built your program with -g, 
 you can see the stack trace and step through the program normally, and 
 even set breakpoints.
 
 But you can't examine variables.  VisualStudio could tell that there was 
 a "this" pointer, and knew it was of type MyClass, but it couldn't tell 
 what was inside of 'this'.  I wonder if there's a way to make a Visual 
 Studio plugin that would give you this ability?
 
 --bb
Try: extern (C) bool no_catch_exceptions; no_catch_exceptions = true;
Nov 05 2006
parent reply Bill Baxter <wbaxter gmail.com> writes:
Sean Kelly wrote:
 Bill Baxter wrote:
 
 By following the instructions given, eg, here:


 it should be possible to make the debugger pop up automatically for 
 programs that have exceptions.

 According to the article above:
 "WinDbg will be launched if an application throws an exception while 
 not being debugged and does not handle the exception itself"

 Apparently D does some sort of top-level catch of such exceptions 
 right now, because sticking an "asm { int 3; }" in the code just 
 prints the message "Error: Win32 Exception" instead of launching the 
 debugger.  Is there some way to disable that?

 -- 
 Really what I was trying to do was see if I could get Visual Studio to 
 debug D code.  Actually it sort of works.  If you have a program with 
 a main loop, you can use visual studio's Tools->Debug Processes... to 
 attach to the running process.  If you've built your program with -g, 
 you can see the stack trace and step through the program normally, and 
 even set breakpoints.

 But you can't examine variables.  VisualStudio could tell that there 
 was a "this" pointer, and knew it was of type MyClass, but it couldn't 
 tell what was inside of 'this'.  I wonder if there's a way to make a 
 Visual Studio plugin that would give you this ability?

 --bb
Try: extern (C) bool no_catch_exceptions; no_catch_exceptions = true;
Doesn't quite work. --> : no identifier for declarator no_catch_exceptions If you stick the 'no_catch_exceptions=true' into main() or static this() then phobos complains that the value changed: --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2) Offset 1D89AH Record Type 0091 Error 1: Previous Definition Different : _no_catch_exceptions --- errorlevel 1"
Nov 05 2006
next sibling parent reply Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
Bill Baxter wrote:
 Doesn't quite work.
 --> : no identifier for declarator no_catch_exceptions
 
 If you stick the 'no_catch_exceptions=true' into main() or static this() 
 then phobos complains that the value changed:
 --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2)  Offset 1D89AH 
 Record Type 0091
  Error 1: Previous Definition Different : _no_catch_exceptions
 --- errorlevel 1"
You could try extern (C) extern bool no_catch_exceptions;
Nov 05 2006
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Tom S wrote:
 Bill Baxter wrote:
 Doesn't quite work.
 --> : no identifier for declarator no_catch_exceptions

 If you stick the 'no_catch_exceptions=true' into main() or static 
 this() then phobos complains that the value changed:
 --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2)  Offset 1D89AH 
 Record Type 0091
  Error 1: Previous Definition Different : _no_catch_exceptions
 --- errorlevel 1"
You could try extern (C) extern bool no_catch_exceptions;
Nope. Same deal. --bb
Nov 05 2006
prev sibling next sibling parent reply Carlos Santander <csantander619 gmail.com> writes:
Bill Baxter escribió:
 
 If you stick the 'no_catch_exceptions=true' into main() or static this() 
 then phobos complains that the value changed:
 --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2)  Offset 1D89AH 
 Record Type 0091
  Error 1: Previous Definition Different : _no_catch_exceptions
 --- errorlevel 1"
Put it in a different module. Import it, but don't link it. -- Carlos Santander Bernal
Nov 05 2006
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Carlos Santander wrote:
 Bill Baxter escribió:
 If you stick the 'no_catch_exceptions=true' into main() or static 
 this() then phobos complains that the value changed:
 --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2)  Offset 1D89AH 
 Record Type 0091
  Error 1: Previous Definition Different : _no_catch_exceptions
 --- errorlevel 1"
Put it in a different module. Import it, but don't link it.
Devious. I like it. But it doesn't work. --bb
Nov 05 2006
parent Carlos Santander <csantander619 gmail.com> writes:
Bill Baxter escribió:
 Carlos Santander wrote:
 Bill Baxter escribió:
 If you stick the 'no_catch_exceptions=true' into main() or static 
 this() then phobos complains that the value changed:
 --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2)  Offset 
 1D89AH Record Type 0091
  Error 1: Previous Definition Different : _no_catch_exceptions
 --- errorlevel 1"
Put it in a different module. Import it, but don't link it.
Devious. I like it. But it doesn't work. --bb
What's the error message? AFAIK, it should work. -- Carlos Santander Bernal
Nov 05 2006
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
Bill Baxter wrote:
 Sean Kelly wrote:
 Bill Baxter wrote:

 By following the instructions given, eg, here:


 it should be possible to make the debugger pop up automatically for 
 programs that have exceptions.

 According to the article above:
 "WinDbg will be launched if an application throws an exception while 
 not being debugged and does not handle the exception itself"

 Apparently D does some sort of top-level catch of such exceptions 
 right now, because sticking an "asm { int 3; }" in the code just 
 prints the message "Error: Win32 Exception" instead of launching the 
 debugger.  Is there some way to disable that?

 -- 
 Really what I was trying to do was see if I could get Visual Studio 
 to debug D code.  Actually it sort of works.  If you have a program 
 with a main loop, you can use visual studio's Tools->Debug 
 Processes... to attach to the running process.  If you've built your 
 program with -g, you can see the stack trace and step through the 
 program normally, and even set breakpoints.

 But you can't examine variables.  VisualStudio could tell that there 
 was a "this" pointer, and knew it was of type MyClass, but it 
 couldn't tell what was inside of 'this'.  I wonder if there's a way 
 to make a Visual Studio plugin that would give you this ability?

 --bb
Try: extern (C) bool no_catch_exceptions; no_catch_exceptions = true;
Doesn't quite work. --> : no identifier for declarator no_catch_exceptions If you stick the 'no_catch_exceptions=true' into main() or static this() then phobos complains that the value changed: --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2) Offset 1D89AH Record Type 0091 Error 1: Previous Definition Different : _no_catch_exceptions --- errorlevel 1"
This is what I thought would work. That or "extern (C) extern bool ..." There has to be some variant that doesn't make DMD think you're actually declaring a new variable. Sean
Nov 05 2006
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Sean Kelly wrote:
 Bill Baxter wrote:
 Sean Kelly wrote:
 Bill Baxter wrote:

 By following the instructions given, eg, here:


 it should be possible to make the debugger pop up automatically for 
 programs that have exceptions.

 According to the article above:
 "WinDbg will be launched if an application throws an exception while 
 not being debugged and does not handle the exception itself"

 Apparently D does some sort of top-level catch of such exceptions 
 right now, because sticking an "asm { int 3; }" in the code just 
 prints the message "Error: Win32 Exception" instead of launching the 
 debugger.  Is there some way to disable that?

 -- 
 Really what I was trying to do was see if I could get Visual Studio 
 to debug D code.  Actually it sort of works.  If you have a program 
 with a main loop, you can use visual studio's Tools->Debug 
 Processes... to attach to the running process.  If you've built your 
 program with -g, you can see the stack trace and step through the 
 program normally, and even set breakpoints.

 But you can't examine variables.  VisualStudio could tell that there 
 was a "this" pointer, and knew it was of type MyClass, but it 
 couldn't tell what was inside of 'this'.  I wonder if there's a way 
 to make a Visual Studio plugin that would give you this ability?

 --bb
Try: extern (C) bool no_catch_exceptions; no_catch_exceptions = true;
Doesn't quite work. --> : no identifier for declarator no_catch_exceptions If you stick the 'no_catch_exceptions=true' into main() or static this() then phobos complains that the value changed: --> "f:\usr\pkg\Dlang\dmd\bin\..\lib\phobos.lib(dmain2) Offset 1D89AH Record Type 0091 Error 1: Previous Definition Different : _no_catch_exceptions --- errorlevel 1"
This is what I thought would work. That or "extern (C) extern bool ..." There has to be some variant that doesn't make DMD think you're actually declaring a new variable. Sean
Isn't this what we have 'export' for? export extern(C) bool no_catch_exceptions;
Nov 05 2006
prev sibling parent Jascha Wetzel <"[firstname]" mainia.de> writes:
this is dealt with by Ddbg 0.0.3 now, btw ;)
it only breaks on unhandled exceptions and lets you examine the full
stacktrace with locations and parameter values.

Bill Baxter wrote:
 By following the instructions given, eg, here:

 
 it should be possible to make the debugger pop up automatically for
 programs that have exceptions.
 
 According to the article above:
 "WinDbg will be launched if an application throws an exception while not
 being debugged and does not handle the exception itself"
 
 Apparently D does some sort of top-level catch of such exceptions right
 now, because sticking an "asm { int 3; }" in the code just prints the
 message "Error: Win32 Exception" instead of launching the debugger.  Is
 there some way to disable that?
 
 -- 
 Really what I was trying to do was see if I could get Visual Studio to
 debug D code.  Actually it sort of works.  If you have a program with a
 main loop, you can use visual studio's Tools->Debug Processes... to
 attach to the running process.  If you've built your program with -g,
 you can see the stack trace and step through the program normally, and
 even set breakpoints.
 
 But you can't examine variables.  VisualStudio could tell that there was
 a "this" pointer, and knew it was of type MyClass, but it couldn't tell
 what was inside of 'this'.  I wonder if there's a way to make a Visual
 Studio plugin that would give you this ability?
 
 --bb
Feb 26 2007