bug-dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-dejagnu] RFA: Wrap _exit in testglue.c


From: Nick Clifton
Subject: [Bug-dejagnu] RFA: Wrap _exit in testglue.c
Date: 13 Apr 2002 07:05:15 +0100

Hi Rob,

  Hans-Peter has created a patch to testglue.c that allows it to wrap
  _exit as well as exit.  This is needed because some of the g++ tests
  call _exit, since the determination of correct execution is
  happening inside a destructor, not in the normal body of code.

  May I apply his patch (attached below) to the DejaGNU sources in the
  sourceware repository please ?

Cheers
        Nick

ChangeLog
Hans-Peter Nilsson  <address@hidden>

        * lib/libgloss.exp (build_wrapper): Wrap _exit too, unless
        wrap_m68k_aout, uses_underscores or is_vxworks are defined in
        target_info.

        * testglue.c [!VXWORKS && !UNDERSCORES && !WRAP_M68K_AOUT]
        (REAL__EXIT): Define.
        [!UNDERSCORES && !WRAP_M68K_AOUT] (ORIG__EXIT): Define.
        [REAL__EXIT] (REAL__EXIT): Prototype.
        [ORIG__EXIT] (ORIG__EXIT): New function wrapper.
        (done_exit_message): New static variable.
        (ORIG_EXIT): Set done_exit_message.

Index: dejagnu/testglue.c
===================================================================
RCS file: /cvs/src/src/dejagnu/testglue.c,v
retrieving revision 1.1.1.1
diff -c -3 -p -w -r1.1.1.1 testglue.c
*** dejagnu/testglue.c  9 Nov 1999 01:28:42 -0000       1.1.1.1
--- dejagnu/testglue.c  13 Apr 2002 06:04:28 -0000
***************
*** 12,18 ****
     because currently GNU ld doesn't deal well with a.out targets and
     the -wrap option. When GNU ld is fixed, this should definitely be
     removed. Note that we actually wrap __exit, not _exit on a target
!    that has UNDERSCORES defined. */
  
  #ifdef WRAP_M68K_AOUT
  #define REAL_EXIT(code) asm ( "trap %0" : : "i" (0) );
--- 12,19 ----
     because currently GNU ld doesn't deal well with a.out targets and
     the -wrap option. When GNU ld is fixed, this should definitely be
     removed. Note that we actually wrap __exit, not _exit on a target
!    that has UNDERSCORES defined.  On non-UNDERSCORE targets, we
!    wrap _exit separately; it's actually a different function.  */
  
  #ifdef WRAP_M68K_AOUT
  #define REAL_EXIT(code) asm ( "trap %0" : : "i" (0) );
***************
*** 29,37 ****
--- 30,42 ----
  #define ORIG_MAIN _wrap__main
  #else
  #define REAL_EXIT __real_exit
+ #ifndef VXWORKS
+ #define REAL__EXIT __real__exit
+ #endif
  #define REAL_MAIN __real_main
  #define REAL_ABORT __real_abort
  #define ORIG_EXIT __wrap_exit
+ #define ORIG__EXIT __wrap__exit
  #define ORIG_ABORT __wrap_abort
  #define ORIG_MAIN __wrap_main
  #endif
*************** extern void REAL_EXIT ();
*** 42,47 ****
--- 47,57 ----
  extern void REAL_ABORT ();
  extern int REAL_MAIN (int argc, char **argv, char **envp);
  #endif
+ #ifdef REAL__EXIT
+ extern void REAL__EXIT ();
+ #endif
+ 
+ static int done_exit_message = 0;
  
  int ___constval = 1;
  
*************** ORIG_EXIT (code)
*** 81,89 ****
--- 91,122 ----
    ptr = write_int (code, buf + strlen(buf));
    *(ptr++) = '\n';
    write (1, buf, ptr-buf);
+   done_exit_message = 1;
    REAL_EXIT (code);
    while (___constval);
  }
+ 
+ #ifdef ORIG__EXIT
+ void
+ ORIG__EXIT (code)
+      int code;
+ {
+   char buf[30];
+   char *ptr;
+ 
+   /* Since exit may call _exit, we need to avoid a second message.  */
+   if (! done_exit_message)
+     {
+       strcpy (buf, "\n*** EXIT code ");
+       ptr = write_int (code, buf + strlen(buf));
+       *(ptr++) = '\n';
+       write (1, buf, ptr-buf);
+     }
+ 
+   REAL__EXIT (code);
+   while (___constval);
+ }
+ #endif
  
  void
  ORIG_ABORT ()
Index: dejagnu/lib/libgloss.exp
===================================================================
RCS file: /cvs/src/src/dejagnu/lib/libgloss.exp,v
retrieving revision 1.6
diff -c -3 -p -w -r1.6 libgloss.exp
*** dejagnu/lib/libgloss.exp    9 Feb 2002 02:09:06 -0000       1.6
--- dejagnu/lib/libgloss.exp    13 Apr 2002 06:04:29 -0000
*************** proc build_wrapper { gluefile } {
*** 820,827 ****
        set flags "";
        if [target_info exists is_vxworks] {
            set flags "additional_flags=-DVXWORKS";
-       }
        set result "-Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort";
      }
      if [target_info exists wrap_compile_flags] {
        lappend flags "additional_flags=[target_info wrap_compile_flags]";
--- 820,829 ----
        set flags "";
        if [target_info exists is_vxworks] {
            set flags "additional_flags=-DVXWORKS";
            set result "-Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort";
+       } else {
+           set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main 
-Wl,-wrap,abort";
+       }
      }
      if [target_info exists wrap_compile_flags] {
        lappend flags "additional_flags=[target_info wrap_compile_flags]";

  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]