From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31526 invoked by alias); 26 Mar 2002 01:29:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31519 invoked from network); 26 Mar 2002 01:29:55 -0000 Received: from unknown (HELO dair.pair.com) (209.68.1.49) by sources.redhat.com with SMTP; 26 Mar 2002 01:29:55 -0000 Received: (qmail 22941 invoked by uid 20157); 26 Mar 2002 01:29:54 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 26 Mar 2002 01:29:54 -0000 Date: Mon, 25 Mar 2002 17:29:00 -0000 From: Hans-Peter Nilsson X-Sender: To: cc: Subject: lib/libgloss.exp: wrap _exit. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-03/txt/msg00479.txt.bz2 The gcc test-suite, namely g++.old-deja/g++.mike/p755.C and g++.old-deja/g++.mike/p755a.C calls _exit (0), not exit (0), in order to avoid running destructors. Since _exit isn't wrapped, those tests will fail on targets needing testglue wrappers after (a.k.a ) was applied. I think it should be valid to call _exit in the test-suite for the purpose, and so it should be properly "wrapped". I don't know what to do about those strange targets already wrapping _exit instead of exit, but at least nothing will change there with this patch. The patch is against the sourceware repo, but applies with no fuzz to the savannah repo. (BTW, the sourceware and savannah dejagnu repos seem to be drifting apart.) 2002-03-26 Hans-Peter Nilsson * 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: testglue.c =================================================================== RCS file: /cvs/src/src/dejagnu/testglue.c,v retrieving revision 1.1.1.1 diff -p -c -r1.1.1.1 testglue.c *** testglue.c 1999/11/09 01:28:42 1.1.1.1 --- testglue.c 2002/03/26 00:39:29 *************** *** 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,48 **** --- 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; #ifdef VXWORKS *************** ORIG_EXIT (code) *** 81,89 **** --- 90,121 ---- 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: lib/libgloss.exp =================================================================== RCS file: /cvs/src/src/dejagnu/lib/libgloss.exp,v retrieving revision 1.6 diff -p -c -r1.6 libgloss.exp *** libgloss.exp 2002/02/09 02:09:06 1.6 --- libgloss.exp 2002/03/26 00:39:29 *************** 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]"; brgds, H-P