You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/07/12 17:19:21 UTC
svn commit: r555657 - in /incubator/stdcxx/trunk/util: exec.cpp runall.cpp
Author: faridz
Date: Thu Jul 12 08:19:20 2007
New Revision: 555657
URL: http://svn.apache.org/viewvc?view=rev&rev=555657
Log:
2007-07-12 Farid Zaripov <Fa...@epam.com>
* exec.cpp [WIN32]: Added map between NT_STATUS values and UNIX signals.
(exec_file) [WIN32]: Translate exit code to signal value using map.
* runall.cpp [WIN32]: Removed #include'ing of signal.h and windows.h.
Modified:
incubator/stdcxx/trunk/util/exec.cpp
incubator/stdcxx/trunk/util/runall.cpp
Modified: incubator/stdcxx/trunk/util/exec.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/exec.cpp?view=diff&rev=555657&r1=555656&r2=555657
==============================================================================
--- incubator/stdcxx/trunk/util/exec.cpp (original)
+++ incubator/stdcxx/trunk/util/exec.cpp Thu Jul 12 08:19:20 2007
@@ -48,7 +48,10 @@
# include <windows.h> /* for PROCESS_INFORMATION, ... */
# include <process.h> /* for CreateProcess, ... */
# ifndef SIGTRAP
-# define SIGTRAP 5 // STATUS_BREAKPOINT translated into SIGTRAP
+# define SIGTRAP 5 // STATUS_BREAKPOINT translated into SIGTRAP
+# endif
+# ifndef SIGBUS
+# define SIGBUS 10 // STATUS_IN_PAGE_ERROR translated into SIGBUS
# endif
#endif
#include <sys/stat.h> /* for S_* */
@@ -925,6 +928,29 @@
}
}
#else /* _WIN{32,64} */
+
+// map between NT_STATUS value and corresponding UNIX signal
+static const struct {
+ DWORD nt_status;
+ int signal;
+} nt_status_map [] = {
+ { STATUS_BREAKPOINT, SIGTRAP },
+ { STATUS_ACCESS_VIOLATION, SIGSEGV },
+ { STATUS_IN_PAGE_ERROR, SIGBUS },
+ { STATUS_ILLEGAL_INSTRUCTION, SIGILL },
+ { STATUS_PRIVILEGED_INSTRUCTION, SIGILL },
+ { STATUS_FLOAT_DENORMAL_OPERAND, SIGFPE },
+ { STATUS_FLOAT_DIVIDE_BY_ZERO, SIGFPE },
+ { STATUS_FLOAT_INEXACT_RESULT, SIGFPE },
+ { STATUS_FLOAT_INVALID_OPERATION, SIGFPE },
+ { STATUS_FLOAT_OVERFLOW, SIGFPE },
+ { STATUS_FLOAT_STACK_CHECK, SIGFPE },
+ { STATUS_FLOAT_UNDERFLOW, SIGFPE },
+ { STATUS_INTEGER_DIVIDE_BY_ZERO, SIGFPE },
+ { STATUS_INTEGER_OVERFLOW, SIGFPE }
+};
+
+
/**
Opens an input file, based on exec_name, using the child_sa security
setting.
@@ -1243,13 +1269,12 @@
if (0 == CloseHandle (child.hProcess))
warn_last_error ("Closing child process handle");
- if (STATUS_ACCESS_VIOLATION == result->exit) {
- result->exit = SIGSEGV;
- result->signaled = 1;
- }
- else if (STATUS_BREAKPOINT == result->exit) {
- result->exit = SIGTRAP;
- result->signaled = 1;
+ for (int i = 0; i < sizeof (nt_status_map) / sizeof (*nt_status_map); ++i) {
+ if (nt_status_map [i].nt_status == DWORD (result->exit)) {
+ result->exit = nt_status_map [i].signal;
+ result->signaled = 1;
+ break;
+ }
}
}
Modified: incubator/stdcxx/trunk/util/runall.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/runall.cpp?view=diff&rev=555657&r1=555656&r2=555657
==============================================================================
--- incubator/stdcxx/trunk/util/runall.cpp (original)
+++ incubator/stdcxx/trunk/util/runall.cpp Thu Jul 12 08:19:20 2007
@@ -35,9 +35,6 @@
#include <sys/stat.h>
#if !defined (_WIN32) && !defined (_WIN64)
# include <sys/wait.h> /* for WIFEXITED(), ... */
-#else
-# include <signal.h> /* for SIGSEGV */
-# include <windows.h> /* for STATUS_ACCESS_VIOLATION */
#endif
#include "cmdopt.h"