- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a CVF 6.6B Fortran DLL that is called from a VS.NET 2003 C++ EXE. I call the DLL entry point from within a try() catch(...) block, and any Fortran DLL exceptions are caught in the C++ code, but catch(...) doesn'tgive me any information about the exception.
1)Should I be catch()'ing a different type? If so, what is it? (I've tried char* and unsigned int, but it still drops down to the catch(...))
2) Is there some function call I can make inside catch(...) that will give me the stack trace or something useful? I'm not trying to *interpret* the exception, just *report* it.
Any help would be appreciated.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would probably be better off asking this in a C++ forum.
I vaguely recall (although I'm not a C++ expert) that there's difference in semantics between try/catch and __try/__except. The former catches only C++ exceptions, the latter (being Microsoft extension) catches OS exceptions, which are (AFAIK) the only ones a CVF code can produce. MSDN also mentions _exception_code and _exception_info intrinsics (no documentation :-( ), as well as GetExceptionCode/GetExceptionInformation Win32 APIs.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's been suggested to me that this article is worth reading on this topic. Also, see the Programmer's Guide/User's Guide chapter on advanced exception handling.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve. Based on the article you linked, I set up an exception filter and caught the Fortran exception along with the info to interpret it!
As for the exceptions handling, I read the Advanced Exception Handling chapter, but it appears to beall about handling theexception in*Fortran* code. I have a legacy Fortran app that has been converted to a DLL and is invoked from C++, so the exception is actually handledin C++, not Fortran.And I couldn't use TRACEBACKQQ() until I had the context for walking the stack, which I couldn't get in C++ with the standard exception handling.
I'm not trying to *do* anything with the exception, per se, just report it. So, I'm trying to get the same kind of info that a Fortran .EXE gives on exception, preferably without walking the call stack to get it. The exception filter described gives me the exception condition information and a context for walking the stack through a call back to a Fortranroutine (straight out of the Advanced Exception chapter) that invokesTRACEBACKQQ. Unfortunately TRACEBACKQQ doesn't print anything at all, even though it reports back the status FOR$IOS_SUCCESS. (I capture both StdOut and StdErr, but nothing in there-- is there somewhere else it would get reported?)
(BTW, I found stack walker code at http://www.codeproject.com/cpp/exception.asp, but it only reports the C++ entries, none of the Fortran entries.)
-Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve. Based on the article you linked, I set up an exception filter and caught the Fortran exception along with the info to interpret it!
As for the exceptions handling, I read the Advanced Exception Handling chapter, but it appears to beall about handling theexception in*Fortran* code. I have a legacy Fortran app that has been converted to a DLL and is invoked from C++, so the exception is actually handledin C++, not Fortran.And I couldn't use TRACEBACKQQ() until I had the context for walking the stack, which I couldn't get in C++ with the standard exception handling.
I'm not trying to *do* anything with the exception, per se, just report it. So, I'm trying to get the same kind of info that a Fortran .EXE gives on exception, preferably without walking the call stack to get it. The exception filter described gives me the exception condition information and a context for walking the stack through a call back to a Fortranroutine (straight out of the Advanced Exception chapter) that invokesTRACEBACKQQ. Unfortunately TRACEBACKQQ doesn't print anything at all, even though it reports back the status FOR$IOS_SUCCESS. (I capture both StdOut and StdErr, but nothing in there-- is there somewhere else it would get reported?)
(BTW, I found stack walker code at http://www.codeproject.com/cpp/exception.asp, but it only reports the C++ entries, none of the Fortran entries.)
-Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve. Based on the article you linked, I set up an exception filter and caught the Fortran exception along with the info to interpret it!
As for the exceptions handling, I read the Advanced Exception Handling chapter, but it appears to beall about handling theexception in*Fortran* code. I have a legacy Fortran app that has been converted to a DLL and is invoked from C++, so the exception is actually handledin C++, not Fortran.And I couldn't use TRACEBACKQQ() until I had the context for walking the stack, which I couldn't get in C++ with the standard exception handling.
I'm not trying to *do* anything with the exception, per se, just report it. So, I'm trying to get the same kind of info that a Fortran .EXE gives on exception, preferably without walking the call stack to get it. The exception filter described gives me the exception condition information and a context for walking the stack through a call back to a Fortranroutine (straight out of the Advanced Exception chapter) that invokesTRACEBACKQQ. Unfortunately TRACEBACKQQ doesn't print anything at all, even though it reports back the status FOR$IOS_SUCCESS. (I capture both StdOut and StdErr, but nothing in there-- is there somewhere else it would get reported?)
(BTW, I found stack walker code at http://www.codeproject.com/cpp/exception.asp, but it only reports the C++ entries, none of the Fortran entries.)
-Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TRACEBACKQQ relies on additional data the compiler writes to a .TRACE section in the objectmodule. I'm not aware that this is documented. You shouldn't need that to just display the exception message, though.
I'm afraid I can't be of much help with the internals of TRACEBACKQQ.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page