Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Ning Zhang
Tue, 16 Jan 1996 00:00
signal/sigcontext problem with HPUX 9.0.5/GCC 2.7.1
Author: Ning Zhang
Date: Tue, 16 Jan 1996 00:00
Date: Tue, 16 Jan 1996 00:00
96 lines
2320 bytes
2320 bytes
I have a problem with a simple test program compiled by GCC 2.7.1 on HPUX 9.0.5.
The problem is that the r3 value stored in the sigcontext structure passed to a
signal handler is not correct. However, when the program is running under xdb
or gdb, the value is OK. This program works find if compiled with HPC.
It seems to me that something very strange happened there. If the following
test program compiled with HPC, it runs OK both with and without gdb/xdb.
If it is compiled with GCC, it runs OK under gdb/xdb, i.e. sc_gr3 is the same
as the one obtained by calling GetR3(); if it runs without gdb/xdb,
sc_gr3 is garbage.
Is this a bug with GCC or simply the HPUX kernel?
Here is the test program (getr3.s and testr3.c):
=====================
getr3.s
=====================
.CODE
GetR3
.PROC
.CALLINFO NO_CALLS
.ENTRY
bv 0(2)
.EXIT
copy 3,28
.PROCEND
.EXPORT GetR3
.END
=====================
testr3.c
=====================
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
int r3;
void
SigHandlerUSR1(sig, code, scp, addr)
int sig, code, addr;
struct sigcontext * scp;
{
fprintf(stderr, "INIT R3 = 0x%x USR1 R3 = 0x%x\n", r3, scp->sc_gr3);
fflush(stderr);
if( (r3 != 0) && (scp->sc_gr3 != r3) )
{
int i = 1;
/* force an infinite loop */
while(i);
}
fflush(stderr);
} /* SigHandlerUSR1(... */
main()
{
struct sigvec osv;
struct sigvec sv;
memset((char *) (&sv), 0, sizeof(sv));
sv.sv_handler = SigHandlerUSR1;
sv.sv_flags = 0;
if( sigvector(SIGUSR1, &sv, &osv) != 0 )
{
perror("sigvec");
exit(-1);
}
/*
* generate signal SIGUSR1
*/
KillThisProc(SIGUSR1);
} /* main(... */
KillThisProc(sig)
int sig;
{
int i;
r3 = GetR3();
kill(getpid(), sig);
for( i = 0; i < 0x7FFFFF; i++ )
{
i = i;
}
return(0);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads