]> gcc.gnu.org Git - gcc.git/commitdiff
libtool-version: New version.
authorAlexander Ivchenko <alexander.ivchenko@intel.com>
Mon, 26 Dec 2016 15:14:06 +0000 (15:14 +0000)
committerAlexander Ivchenko <aivchenk@gcc.gnu.org>
Mon, 26 Dec 2016 15:14:06 +0000 (15:14 +0000)
2016-12-26  Alexander Ivchenko  <alexander.ivchenko@intel.com>

    * mpxrt/libtool-version: New version.
    * mpxrt/mpxrt-utils.c (set_mpx_rt_stop_handler): New function.
    (print_help): Add help for CHKP_RT_STOP_HANDLER environment
    variable.
    (__mpxrt_init_env_vars): Add initialization of stop_handler.
    (__mpxrt_stop_handler): New function.
    (__mpxrt_stop): Ditto.
    * mpxrt/mpxrt-utils.h (mpx_rt_stop_mode_handler_t): New enum.
    * mpxrt/mpxrt.c (handler): Replace exit(255) with __mpxrt_stop
    function call.

From-SVN: r243928

libmpx/ChangeLog
libmpx/mpxrt/libtool-version
libmpx/mpxrt/mpxrt-utils.c
libmpx/mpxrt/mpxrt-utils.h
libmpx/mpxrt/mpxrt.c

index 07a4dd7636f3f6a3e993c61c43a87ae7a4ffa23d..4f7a68425daa67e5bcd5c1e557141681e0c3ce61 100644 (file)
@@ -1,3 +1,16 @@
+2016-12-26  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+
+       * mpxrt/libtool-version: New version.
+       * mpxrt/mpxrt-utils.c (set_mpx_rt_stop_handler): New function.
+       (print_help): Add help for CHKP_RT_STOP_HANDLER environment
+       variable.
+       (__mpxrt_init_env_vars): Add initialization of stop_handler.
+       (__mpxrt_stop_handler): New function.
+       (__mpxrt_stop): Ditto.
+       * mpxrt/mpxrt-utils.h (mpx_rt_stop_mode_handler_t): New enum.
+       * mpxrt/mpxrt.c (handler): Replace exit(255) with __mpxrt_stop
+       function call.
+
 2016-11-15  Matthias Klose  <doko@ubuntu.com>
 
        * configure: Regenerate.
index 7d9925549d1c02d83430cb7bac6ca097b52da3f0..736d763e6052e273d1e099518302a4b6c5022ef5 100644 (file)
@@ -3,4 +3,4 @@
 # a separate file so that version updates don't involve re-running
 # automake.
 # CURRENT:REVISION:AGE
-2:0:0
+2:1:0
index 057a3553cb5b1f03eaeca64d42c5e72164b50922..63ee7c6ae63f0cc6c6a5f94856d7e348e7453482 100644 (file)
@@ -60,6 +60,9 @@
 #define MPX_RT_MODE "CHKP_RT_MODE"
 #define MPX_RT_MODE_DEFAULT MPX_RT_COUNT
 #define MPX_RT_MODE_DEFAULT_STR "count"
+#define MPX_RT_STOP_HANDLER "CHKP_RT_STOP_HANDLER"
+#define MPX_RT_STOP_HANDLER_DEFAULT MPX_RT_STOP_HANDLER_ABORT
+#define MPX_RT_STOP_HANDLER_DEFAULT_STR "abort"
 #define MPX_RT_HELP "CHKP_RT_HELP"
 #define MPX_RT_ADDPID "CHKP_RT_ADDPID"
 #define MPX_RT_BNDPRESERVE "CHKP_RT_BNDPRESERVE"
@@ -84,6 +87,7 @@ typedef struct {
 static int summary;
 static int add_pid;
 static mpx_rt_mode_t mode;
+static mpx_rt_stop_mode_handler_t stop_handler;
 static env_var_list_t env_var_list;
 static verbose_type verbose_val;
 static FILE *out;
@@ -226,6 +230,23 @@ set_mpx_rt_mode (const char *env)
   }
 }
 
+static mpx_rt_stop_mode_handler_t
+set_mpx_rt_stop_handler (const char *env)
+{
+  if (env == 0)
+    return MPX_RT_STOP_HANDLER_DEFAULT;
+  else if (strcmp (env, "abort") == 0)
+    return MPX_RT_STOP_HANDLER_ABORT;
+  else if (strcmp (env, "exit") == 0)
+    return MPX_RT_STOP_HANDLER_EXIT;
+  {
+    __mpxrt_print (VERB_ERROR, "Illegal value '%s' for %s. Legal values are"
+                  "[abort | exit]\nUsing default value %s\n",
+                  env, MPX_RT_STOP_HANDLER, MPX_RT_STOP_HANDLER_DEFAULT);
+    return MPX_RT_STOP_HANDLER_DEFAULT;
+  }
+}
+
 static void
 print_help (void)
 {
@@ -244,6 +265,11 @@ print_help (void)
   fprintf (out, "%s \t\t set MPX runtime behavior on #BR exception."
           " [stop | count]\n"
           "\t\t\t [default: %s]\n", MPX_RT_MODE, MPX_RT_MODE_DEFAULT_STR);
+  fprintf (out, "%s \t set the handler function MPX runtime will call\n"
+           "\t\t\t on #BR exception when %s is set to \'stop\'."
+          " [abort | exit]\n"
+          "\t\t\t [default: %s]\n", MPX_RT_STOP_HANDLER, MPX_RT_MODE,
+           MPX_RT_STOP_HANDLER_DEFAULT_STR);
   fprintf (out, "%s \t\t generate out,err file for each process.\n"
           "\t\t\t generated file will be MPX_RT_{OUT,ERR}_FILE.pid\n"
           "\t\t\t [default: no]\n", MPX_RT_ADDPID);
@@ -357,6 +383,10 @@ __mpxrt_init_env_vars (int* bndpreserve)
   env_var_list_add (MPX_RT_MODE, env);
   mode = set_mpx_rt_mode (env);
 
+  env = secure_getenv (MPX_RT_STOP_HANDLER);
+  env_var_list_add (MPX_RT_STOP_HANDLER, env);
+  stop_handler = set_mpx_rt_stop_handler (env);
+
   env = secure_getenv (MPX_RT_BNDPRESERVE);
   env_var_list_add (MPX_RT_BNDPRESERVE, env);
   validate_bndpreserve (env, bndpreserve);
@@ -487,6 +517,22 @@ __mpxrt_mode (void)
   return mode;
 }
 
+mpx_rt_mode_t
+__mpxrt_stop_handler (void)
+{
+  return stop_handler;
+}
+
+void __attribute__ ((noreturn))
+__mpxrt_stop (void)
+{
+  if (__mpxrt_stop_handler () == MPX_RT_STOP_HANDLER_ABORT)
+    abort ();
+  else if (__mpxrt_stop_handler () == MPX_RT_STOP_HANDLER_EXIT)
+    exit (255);
+  __builtin_unreachable ();
+}
+
 void
 __mpxrt_print_summary (uint64_t num_brs, uint64_t l1_size)
 {
index d62937df7d0b48fd4eba92aad007a297a6510058..6da12ccb803e027a6e8101616d517d779dd35e5e 100644 (file)
@@ -54,6 +54,11 @@ typedef enum {
   MPX_RT_STOP
 } mpx_rt_mode_t;
 
+typedef enum {
+  MPX_RT_STOP_HANDLER_ABORT,
+  MPX_RT_STOP_HANDLER_EXIT
+} mpx_rt_stop_mode_handler_t;
+
 void __mpxrt_init_env_vars (int* bndpreserve);
 void __mpxrt_write_uint (verbose_type vt, uint64_t val, unsigned base);
 void __mpxrt_write (verbose_type vt, const char* str);
index b52906bb9e8950f411b93897b7803584c4994c95..76d11f71fd1c7173842101efd6b25213cbc80064 100644 (file)
@@ -252,7 +252,7 @@ handler (int sig __attribute__ ((unused)),
          uctxt->uc_mcontext.gregs[REG_IP_IDX] =
            (greg_t)get_next_inst_ip ((uint8_t *)ip);
          if (__mpxrt_mode () == MPX_RT_STOP)
-           exit (255);
+           __mpxrt_stop ();
          return;
 
        default:
@@ -269,7 +269,7 @@ handler (int sig __attribute__ ((unused)),
       __mpxrt_write (VERB_ERROR, ", ip = 0x");
       __mpxrt_write_uint (VERB_ERROR, ip, 16);
       __mpxrt_write (VERB_ERROR, "\n");
-      exit (255);
+      __mpxrt_stop ();
     }
   else
     {
@@ -278,7 +278,7 @@ handler (int sig __attribute__ ((unused)),
       __mpxrt_write (VERB_ERROR, "! at 0x");
       __mpxrt_write_uint (VERB_ERROR, ip, 16);
       __mpxrt_write (VERB_ERROR, "\n");
-      exit (255);
+      __mpxrt_stop ();
     }
 }
 
This page took 0.068847 seconds and 5 git commands to generate.