2015-11-04 67 views
3

我在維護一個必須運行op Alpha OpenVMS(7.3-2)和Itanium OpenVMS(8.4)的應用程序。 它用C++編寫,編譯器版本爲Alpha上的6.5-046和IA64上的7.4-004。

我遇到的問題是LIB $ SIGNAL()。一旦它發出致命信息,程序就會中止。

首先代碼重現這個(爲生成並構建代碼DCL腳本):

$ create mtst.msg 
.TITLE Message file for MTST 
.IDENT 'VERSION 1.1' 
.FACILITY MTST,1 /PREFIX=MTST_ 
.SEVERITY INFORMATIONAL 
HELLO  <Hello World> /fao_count=0 
.SEVERITY SUCCESS 
SUCCESS  <Opdracht succesvol uitgevoerd> /fao_count=0 
.SEVERITY WARNING 
WHOOPS  <Dit is een waarschuwing: !AZ> /fao_count=1 
.SEVERITY ERROR 
WHAAA  <Oeioeioei dat was op het randje> /fao_count=0 
.SEVERITY FATAL 
AARGH  <Nu is het helemaal mis> /fao_count=0 
.END 
$! 
$ create msgtest.h 
#define __NEW_STARLET 1 
#include<lib$routines.h> 
#include<stsdef.h> 

#pragma extern_model globalvalue 

extern unsigned long MTST_HELLO; 
extern unsigned long MTST_SUCCESS; 
extern unsigned long MTST_WHOOPS; 
extern unsigned long MTST_WHAAA; 
extern unsigned long MTST_AARGH; 

#pragma extern_model relaxed_refdef 
$! 
$ create msgctest.c 
#include<msgtest.h> 
#include<stdio> 
#include<stdlib.h> 

int main(void) { 
    char* msgArgument = "Boe!"; 
    printf ("Test: info message...\n"); 
    LIB$SIGNAL(MTST_HELLO); 
    printf("\n"); 

    printf ("Test: success message...\n"); 
    LIB$SIGNAL(MTST_SUCCESS); 
    printf("\n"); 

    printf ("Test: warning message...\n"); 
    LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument); 
    printf("\n"); 

    printf ("Test: error message...\n"); 
    LIB$SIGNAL(MTST_WHAAA); 
    printf("\n"); 

    printf ("Test: fatal message...\n"); 
    LIB$SIGNAL(MTST_AARGH); 
    printf("\n"); 

    printf ("Einde test!\n"); 
} 
$! 
$ create msgtest.cpp 
#include<msgtest.h> 
#include<iostream> 
#include<stdlib.h> 
using namespace std; 
#include <chfdef.h> 
int main(void) { 
    char* msgArgument = "Boe!"; 
    cout << "Using IOStream:" << endl << "Test: info message..." << endl; 
    LIB$SIGNAL(MTST_HELLO); 
    cout << endl << "Test: success message..." << endl; 
    LIB$SIGNAL(MTST_SUCCESS); 
    cout << endl << "Test: warning message..." << endl; 
    LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument); 
    cout << endl << "Test: error message..." << endl; 
    LIB$SIGNAL(MTST_WHAAA); 
    cout << endl << "Test: fatal message..." << endl; 
    LIB$SIGNAL(MTST_AARGH); 

    // Next line is, of course, never displayed... 
    cout << endl << "Einde test!" << endl; 

} 
$! 
$! Compile the message file 
$ message mtst 
$! 
$! As a reference, build an executable using the C-source. Will always work both on Alpha and Itanium 
$ cc/lis=[] /include=[] msgctest.c /warn=(disa=dollarid)/notrace 
$ link msgctest,mtst /map=[]/cross/notrace 
$! 
$! Now build the C++ based exe. 
$ cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/standard=strict_ansi 
$! Using this compile statement it works on Itanium: 
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace 
$! Using this compile statement it fails again: 
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/define=(__USE_STD_IOSTREAM) 
$ cxxlink msgtest,mtst /map=[]/cross/notrace 
$! 

的C源總是工作和阿爾法兩個腳本。

編譯時如果沒有/ STANDARD,它在Itanium上運行良好,但在原始程序中,我使用iostream時遇到問題:我需要ANSI,但使用/ DEFINE =(__ USE_STD_IOSTREAM)編譯帶回原始問題。

$r msgtest 
Test: info message... 
%MTST-I-HELLO, Hello World 

Test: success message... 
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd 

Test: inwarningfo message... 
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe! 

Test: error message... 
%MTST-E-WHAAA, Oeioeioei dat was op het randje 

Test: fatal message... 
%CXXL-F-TERMINATING, terminate() or unexpected() called 
$ 

我希望是這樣的:

$ r msgctest 
Test: info message... 
%MTST-I-HELLO, Hello World 

Test: success message... 
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd 

Test: warning message... 
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe! 

Test: error message... 
%MTST-E-WHAAA, Oeioeioei dat was op het randje 

Test: fatal message... 
%MTST-F-AARGH, Nu is het helemaal mis 
$ 

所以...%CPP - - 跆拳道,幫助請: -/

由於提前, 奧斯卡

注意:在我昨天發佈的原始文章中,有一個不同的腳本,其中包含更多測試代碼,如try/catch。當然這會改變testresult,正如user2116290在他/她的評論中所述。 我將DCL腳本更改爲原始測試,以重現我在原始應用程序中看到的內容。

回答

3

到目前爲止,我沒有看到一個問題。

$ sh symb x 
    X = 134316076 Hex = 0801802C Octal = 01000300054 
$ search *.lis 0801802C/noheader 
         0801802C 13 AARGH  <Nu is het helemaal mis> 

在Alpha,你正趕上您的錯誤代碼(我用HP的C++ V7.1-015爲的OpenVMS Alpha V8.3嘗試過)。然後你調用abort(),它發出0x434,OPCCUS,這對我來說看起來OK。

在Alpha上,如果我刪除了try/catch,C++程序的行爲與c程序相同。我無法訪問使用C++的I64,因此我無法仔細檢查I64上中止abort()的結果。它可能只是%CXXL-F-TERMINATING。

新更新:

它看起來像的嚴格ANSI模式和標準輸入輸出流的結合觸發了C++捕獲所有處理程序,它捕捉致命VMS條件/異常。在您的例子似乎有可能與禁止捕VMS條件:

$ diff -ub old.cpp new.cpp 
--- old.cpp  2015-11-11 19:42:52 +0100 
+++ new.cpp  2015-11-11 19:49:10 +0100 
@@ -1,8 +1,14 @@ 
#include<msgtest.h> 
#include<iostream> 
#include<stdlib.h> 
+#ifdef __ia64 
+#include<cxx_exception.h> 
+#endif 
using namespace std; 
int main(void) { 
+#ifdef __ia64 
+ cxxl$set_condition(pure_unix); 
+#endif 
    char* msgArgument = "Boe!"; 
    cout << "Using IOStream:" << endl << "Test: info message..." << endl; 
    LIB$SIGNAL(MTST_HELLO); 

編譯,鏈接和運行變化的例子:

$ cxx /standard=strict_ansi/lis/warn=(disa=dollarid)/notrace/incl=[]/repo=[] new.cpp 
    $ link /map=new/full=demangled/cross/notrace new, mtst 
    $ r new 
    Using IOStream: 
    Test: info message... 
    %MTST-I-HELLO, Hello World 

    Test: success message... 
    %MTST-S-SUCCESS, Opdracht succesvol uitgevoerd 

    Test: warning message... 
    %MTST-W-WHOOPS, Dit is een waarschuwing: Boe! 

    Test: error message... 
    %MTST-E-WHAAA, Oeioeioei dat was op het randje 

    Test: fatal message... 
    %MTST-F-AARGH, Nu is het helemaal mis 
    $ 

也許,你的作品也是如此。

+0

恐怕你是對的;我添加了try/catch來查看拋出的內容,這確實是預期的代碼。這會導致Alpha版本失敗。刪除try/catch使得它現在可以在Alpha和IA64上正常工作,所以我需要追溯昨天我在做什麼,以便在我的測試腳本中重現它。我會在這裏重新發布 – Oscar

+0

好吧,我的原始問題是使用工作腳本進行更新以重現此問題,並且說明/結果已更新。至少,你解釋了爲什麼我無法重現正在運行的Alpha版本......在這一問題的一天挖掘之後完全忽略了它......感謝! – Oscar

+0

也許有人用C++訪問I64系統可以給出一些見解。如果沒有,我會考慮向惠普詢問這種不兼容性。他們應該能夠解釋兩種平臺上的不同行爲和/或strict_ansi標準的影響。我可以考慮採用VMS條件(異常)處理程序的解決方法/破解方法,但當惠普知道/解決此「功能」問題時可能不值得。 PS:你可能在Alpha和I64上使用相同的構建命令,但是你確實只需要在Alpha上使用cxxlink。 – user2116290