Re: [Fwd: sigcontext on Linux-ppc in user space]
Ok, actually the segfault was for a more complicated function, but the simplified example still gives the wrong answer. i.e scp should point to a struct sigcontext and scp->signal should be 10 in the sample program. John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) "Kevin B. Hendricks" <[EMAIL PROTECTED]> on 01/25/2001 01:10:40 PM Please respond to [EMAIL PROTECTED] To: John Kacur/Toronto/IBM@IBMCA cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [Fwd: sigcontext on Linux-ppc in user space] Hi, Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods and glibc-2.1.3). But no segfault. Kevin [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c [kbhend@localhost ~]$ ./junk SIGUSR1 = 10 scp = 7fffe9a4 scp->signal = 0 [kbhend@localhost ~]$ On Thursday, January 25, 2001, at 10:09 AM, [EMAIL PROTECTED] wrote: > #include > #include > > /* Function Prototypes */ > void install_sigusr1_handler(void); > void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); > > int main(void) > { > install_sigusr1_handler(); > printf("SIGUSR1 = %d\n", SIGUSR1); > raise(SIGUSR1); > exit(0); > } > > void install_sigusr1_handler(void) > { > struct sigaction newAct; > > if (sigemptyset(_mask) != 0) { > fprintf(stderr, "Warning, sigemptyset failed.\n"); > } > > newAct.sa_flags = 0; > newAct.sa_flags |= SA_SIGINFO | SA_RESTART; > > newAct.sa_sigaction = (void > (*)(int,siginfo_t*,void*))sigusr_handler; > > if (sigaction(SIGUSR1, , NULL) != 0) { > fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); > fprintf(stderr, "Exiting.\n"); > exit(1); > } > } > > void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) > { > printf("scp = %08x\n", scp); > printf("scp->signal = %d\n", scp->signal); > } > > - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: [Fwd: sigcontext on Linux-ppc in user space]
Hi, If it matters I am running some kernel fixes to enable RT signal handling properly. A version of this patch was supposed to be included into the 2.4 series but I don't work with those kernels so I never checked to see if it was ever included. I have attached the patch which should apply cleanly over stable 2.2 kernels just in case it helps. By the way, this was not my patch it was contributed awhile ago by someone else. The 2.3.XX version is out there someplace, perhaps someone remembers where. I backported it to my stable kernel. Hope this helps, Kevin posix_stable.patch On Thursday, January 25, 2001, at 01:10 PM, Kevin B. Hendricks wrote: > > Hi, > > Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with >some mods > and glibc-2.1.3). > > But no segfault. > > Kevin > > > [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c > [kbhend@localhost ~]$ ./junk > SIGUSR1 = 10 > scp = 7fffe9a4 > scp->signal = 0 > [kbhend@localhost ~]$ > > > > > On Thursday, January 25, 2001, at 10:09 AM, [EMAIL PROTECTED] wrote: > > > #include > > #include > > > > /* Function Prototypes */ > > void install_sigusr1_handler(void); > > void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); > > > > int main(void) > > { > > install_sigusr1_handler(); > > printf("SIGUSR1 = %d\n", SIGUSR1); > > raise(SIGUSR1); > > exit(0); > > } > > > > void install_sigusr1_handler(void) > > { > > struct sigaction newAct; > > > > if (sigemptyset(_mask) != 0) { > > fprintf(stderr, "Warning, sigemptyset failed.\n"); > > } > > > > newAct.sa_flags = 0; > > newAct.sa_flags |= SA_SIGINFO | SA_RESTART; > > > > newAct.sa_sigaction = (void > > (*)(int,siginfo_t*,void*))sigusr_handler; > > > > if (sigaction(SIGUSR1, , NULL) != 0) { > > fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); > > fprintf(stderr, "Exiting.\n"); > > exit(1); > > } > > } > > > > void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) > > { > > printf("scp = %08x\n", scp); > > printf("scp->signal = %d\n", scp->signal); > > } > > > > > > ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/ > >
Re: [Fwd: sigcontext on Linux-ppc in user space]
[EMAIL PROTECTED] wrote: > .. But I > still can't get at the sigcontext.c on Linux Powerpc. For example, this > simple program gives me a segmentation fault. (Linux ppc, suse 6.4, kernel > 2.2.14 You are not the only one. I recently discovered some inconsistent data structures and function calls (sigaction, old_sigaction, different context structures, etc.). I spent some time trying to sort it out but didn't have enough time. I was fortunate and just bailed out using old signal handler semantics. I was using what I believed were the latest glibc2.1, and also the latest 2.4 kernels (which is what I was really developing and testing). I mentioned this to some folks closer to the glibc action, but haven't followed up. Something is amiss here with PowerPC. Sorry I can't provide a solution. -- Dan - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: [Fwd: sigcontext on Linux-ppc in user space]
Hi, Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods and glibc-2.1.3). But no segfault. Kevin [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c [kbhend@localhost ~]$ ./junk SIGUSR1 = 10 scp = 7fffe9a4 scp->signal = 0 [kbhend@localhost ~]$ On Thursday, January 25, 2001, at 10:09 AM, [EMAIL PROTECTED] wrote: > #include > #include > > /* Function Prototypes */ > void install_sigusr1_handler(void); > void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); > > int main(void) > { > install_sigusr1_handler(); > printf("SIGUSR1 = %d\n", SIGUSR1); > raise(SIGUSR1); > exit(0); > } > > void install_sigusr1_handler(void) > { > struct sigaction newAct; > > if (sigemptyset(_mask) != 0) { > fprintf(stderr, "Warning, sigemptyset failed.\n"); > } > > newAct.sa_flags = 0; > newAct.sa_flags |= SA_SIGINFO | SA_RESTART; > > newAct.sa_sigaction = (void > (*)(int,siginfo_t*,void*))sigusr_handler; > > if (sigaction(SIGUSR1, , NULL) != 0) { > fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); > fprintf(stderr, "Exiting.\n"); > exit(1); > } > } > > void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) > { > printf("scp = %08x\n", scp); > printf("scp->signal = %d\n", scp->signal); > } > > - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: [Fwd: sigcontext on Linux-ppc in user space]
John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) -- Forwarded by John Kacur/Toronto/IBM on 01/25/2001 10:06 AM --- John Kacur 01/24/2001 04:47 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] From: John Kacur/Toronto/IBM@IBMCA Subject: Re: [Fwd: sigcontext on Linux-ppc in user space] (Document link: John Kacur) Thanks for your reply. Yes, you are right I shouldn't include kernel files in user space programs, and signal.h will contain what I need anyway. But I still can't get at the sigcontext.c on Linux Powerpc. For example, this simple program gives me a segmentation fault. (Linux ppc, suse 6.4, kernel 2.2.14 #include #include /* Function Prototypes */ void install_sigusr1_handler(void); void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); int main(void) { install_sigusr1_handler(); printf("SIGUSR1 = %d\n", SIGUSR1); raise(SIGUSR1); exit(0); } void install_sigusr1_handler(void) { struct sigaction newAct; if (sigemptyset(_mask) != 0) { fprintf(stderr, "Warning, sigemptyset failed.\n"); } newAct.sa_flags = 0; newAct.sa_flags |= SA_SIGINFO | SA_RESTART; newAct.sa_sigaction = (void (*)(int,siginfo_t*,void*))sigusr_handler; if (sigaction(SIGUSR1, , NULL) != 0) { fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); fprintf(stderr, "Exiting.\n"); exit(1); } } void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) { printf("scp = %08x\n", scp); printf("scp->signal = %d\n", scp->signal); } Ultimately, I want to get at the regs, ie scp->pt_regs->nip for example. Any ideas? Thanks. John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) John Kacur <[EMAIL PROTECTED]>@e1.ny.us.ibm.com on 01/24/2001 10:26:30 AM Please respond to John Kacur <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] To: John Kacur/Toronto/IBM@IBMCA cc: Subject: [Fwd: sigcontext on Linux-ppc in user space] - Message from on - John Kacur <[EMAIL PROTECTED]> writes: > Does anyone know how to get at the struct sigcontext in a signal handler > on Linux for powerpc? sigaction of course lets you create a signal > handler as a function with the prototype void(*)(int, siginfo_t *, void > *) > where the last argument, a pointer to void, is the sigcontext. I believe > that the last argument is NOT defined by POSIX and so is implementation > dependent. > > On Intel it seems sufficient to use #include > to get the definition of struct sigcontext, and then get the values > you'd like out of the signal handler. But on Linux for powerpc, the same > thing doesn't work. Does anyone know what the trick is here to > accomplish this? You should never include kernel headers in user space. If you have a glibc 2.1 (or newer) based system, just include which will include with the struct (this works on all architectures). Andreas -- Andreas Jaeger SuSE Labs [EMAIL PROTECTED] private [EMAIL PROTECTED] http://www.suse.de/~aj - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: [Fwd: sigcontext on Linux-ppc in user space]
John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) -- Forwarded by John Kacur/Toronto/IBM on 01/25/2001 10:06 AM --- John Kacur 01/24/2001 04:47 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] From: John Kacur/Toronto/IBM@IBMCA Subject: Re: [Fwd: sigcontext on Linux-ppc in user space] (Document link: John Kacur) Thanks for your reply. Yes, you are right I shouldn't include kernel files in user space programs, and signal.h will contain what I need anyway. But I still can't get at the sigcontext.c on Linux Powerpc. For example, this simple program gives me a segmentation fault. (Linux ppc, suse 6.4, kernel 2.2.14 #include stdio.h #include signal.h /* Function Prototypes */ void install_sigusr1_handler(void); void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); int main(void) { install_sigusr1_handler(); printf("SIGUSR1 = %d\n", SIGUSR1); raise(SIGUSR1); exit(0); } void install_sigusr1_handler(void) { struct sigaction newAct; if (sigemptyset(newAct.sa_mask) != 0) { fprintf(stderr, "Warning, sigemptyset failed.\n"); } newAct.sa_flags = 0; newAct.sa_flags |= SA_SIGINFO | SA_RESTART; newAct.sa_sigaction = (void (*)(int,siginfo_t*,void*))sigusr_handler; if (sigaction(SIGUSR1, newAct, NULL) != 0) { fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); fprintf(stderr, "Exiting.\n"); exit(1); } } void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) { printf("scp = %08x\n", scp); printf("scp-signal = %d\n", scp-signal); } Ultimately, I want to get at the regs, ie scp-pt_regs-nip for example. Any ideas? Thanks. John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) John Kacur [EMAIL PROTECTED]@e1.ny.us.ibm.com on 01/24/2001 10:26:30 AM Please respond to John Kacur [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] To: John Kacur/Toronto/IBM@IBMCA cc: Subject: [Fwd: sigcontext on Linux-ppc in user space] - Message from on - John Kacur [EMAIL PROTECTED] writes: Does anyone know how to get at the struct sigcontext in a signal handler on Linux for powerpc? sigaction of course lets you create a signal handler as a function with the prototype void(*)(int, siginfo_t *, void *) where the last argument, a pointer to void, is the sigcontext. I believe that the last argument is NOT defined by POSIX and so is implementation dependent. On Intel it seems sufficient to use #include asm/sigcontext.h to get the definition of struct sigcontext, and then get the values you'd like out of the signal handler. But on Linux for powerpc, the same thing doesn't work. Does anyone know what the trick is here to accomplish this? You should never include kernel headers in user space. If you have a glibc 2.1 (or newer) based system, just include signal.h which will include bits/sigcontext.h with the struct (this works on all architectures). Andreas -- Andreas Jaeger SuSE Labs [EMAIL PROTECTED] private [EMAIL PROTECTED] http://www.suse.de/~aj - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: [Fwd: sigcontext on Linux-ppc in user space]
Hi, If it matters I am running some kernel fixes to enable RT signal handling properly. A version of this patch was supposed to be included into the 2.4 series but I don't work with those kernels so I never checked to see if it was ever included. I have attached the patch which should apply cleanly over stable 2.2 kernels just in case it helps. By the way, this was not my patch it was contributed awhile ago by someone else. The 2.3.XX version is out there someplace, perhaps someone remembers where. I backported it to my stable kernel. Hope this helps, Kevin posix_stable.patch On Thursday, January 25, 2001, at 01:10 PM, Kevin B. Hendricks wrote: Hi, Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods and glibc-2.1.3). But no segfault. Kevin [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c [kbhend@localhost ~]$ ./junk SIGUSR1 = 10 scp = 7fffe9a4 scp-signal = 0 [kbhend@localhost ~]$ On Thursday, January 25, 2001, at 10:09 AM, [EMAIL PROTECTED] wrote: #include stdio.h #include signal.h /* Function Prototypes */ void install_sigusr1_handler(void); void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); int main(void) { install_sigusr1_handler(); printf("SIGUSR1 = %d\n", SIGUSR1); raise(SIGUSR1); exit(0); } void install_sigusr1_handler(void) { struct sigaction newAct; if (sigemptyset(newAct.sa_mask) != 0) { fprintf(stderr, "Warning, sigemptyset failed.\n"); } newAct.sa_flags = 0; newAct.sa_flags |= SA_SIGINFO | SA_RESTART; newAct.sa_sigaction = (void (*)(int,siginfo_t*,void*))sigusr_handler; if (sigaction(SIGUSR1, newAct, NULL) != 0) { fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); fprintf(stderr, "Exiting.\n"); exit(1); } } void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) { printf("scp = %08x\n", scp); printf("scp-signal = %d\n", scp-signal); } ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Re: [Fwd: sigcontext on Linux-ppc in user space]
Ok, actually the segfault was for a more complicated function, but the simplified example still gives the wrong answer. i.e scp should point to a struct sigcontext and scp-signal should be 10 in the sample program. John Kacur/Toronto/IBM@IBMCA [EMAIL PROTECTED] (416) 448-2584 (phone) 778-2584 (tie line) "Kevin B. Hendricks" [EMAIL PROTECTED] on 01/25/2001 01:10:40 PM Please respond to [EMAIL PROTECTED] To: John Kacur/Toronto/IBM@IBMCA cc: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [Fwd: sigcontext on Linux-ppc in user space] Hi, Here is what I get from running it on my system (ppc linux with 2.2.15 kernel with some mods and glibc-2.1.3). But no segfault. Kevin [kbhend@localhost ~]$ gcc -O2 -ojunk junk.c [kbhend@localhost ~]$ ./junk SIGUSR1 = 10 scp = 7fffe9a4 scp-signal = 0 [kbhend@localhost ~]$ On Thursday, January 25, 2001, at 10:09 AM, [EMAIL PROTECTED] wrote: #include stdio.h #include signal.h /* Function Prototypes */ void install_sigusr1_handler(void); void sigusr_handler(int , siginfo_t *, struct sigcontext * scp); int main(void) { install_sigusr1_handler(); printf("SIGUSR1 = %d\n", SIGUSR1); raise(SIGUSR1); exit(0); } void install_sigusr1_handler(void) { struct sigaction newAct; if (sigemptyset(newAct.sa_mask) != 0) { fprintf(stderr, "Warning, sigemptyset failed.\n"); } newAct.sa_flags = 0; newAct.sa_flags |= SA_SIGINFO | SA_RESTART; newAct.sa_sigaction = (void (*)(int,siginfo_t*,void*))sigusr_handler; if (sigaction(SIGUSR1, newAct, NULL) != 0) { fprintf(stderr, "Couldn't install SIGUSR1 handler.\n"); fprintf(stderr, "Exiting.\n"); exit(1); } } void sigusr_handler(int signo, siginfo_t *siginfp, struct sigcontext * scp) { printf("scp = %08x\n", scp); printf("scp-signal = %d\n", scp-signal); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: sigcontext on Linux-ppc in user space
John Kacur <[EMAIL PROTECTED]> writes: > Does anyone know how to get at the struct sigcontext in a signal handler > on Linux for powerpc? sigaction of course lets you create a signal > handler as a function with the prototype void(*)(int, siginfo_t *, void > *) > where the last argument, a pointer to void, is the sigcontext. I believe > that the last argument is NOT defined by POSIX and so is implementation > dependent. > > On Intel it seems sufficient to use #include > to get the definition of struct sigcontext, and then get the values > you'd like out of the signal handler. But on Linux for powerpc, the same > thing doesn't work. Does anyone know what the trick is here to > accomplish this? You should never include kernel headers in user space. If you have a glibc 2.1 (or newer) based system, just include which will include with the struct (this works on all architectures). Andreas -- Andreas Jaeger SuSE Labs [EMAIL PROTECTED] private [EMAIL PROTECTED] http://www.suse.de/~aj - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
sigcontext on Linux-ppc in user space
Does anyone know how to get at the struct sigcontext in a signal handler on Linux for powerpc? sigaction of course lets you create a signal handler as a function with the prototype void(*)(int, siginfo_t *, void *) where the last argument, a pointer to void, is the sigcontext. I believe that the last argument is NOT defined by POSIX and so is implementation dependent. On Intel it seems sufficient to use #include to get the definition of struct sigcontext, and then get the values you'd like out of the signal handler. But on Linux for powerpc, the same thing doesn't work. Does anyone know what the trick is here to accomplish this? Thanks in advance John Kacur [EMAIL PROTECTED] [EMAIL PROTECTED] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
sigcontext on Linux-ppc in user space
Does anyone know how to get at the struct sigcontext in a signal handler on Linux for powerpc? sigaction of course lets you create a signal handler as a function with the prototype void(*)(int, siginfo_t *, void *) where the last argument, a pointer to void, is the sigcontext. I believe that the last argument is NOT defined by POSIX and so is implementation dependent. On Intel it seems sufficient to use #include asm/sigcontext.h to get the definition of struct sigcontext, and then get the values you'd like out of the signal handler. But on Linux for powerpc, the same thing doesn't work. Does anyone know what the trick is here to accomplish this? Thanks in advance John Kacur [EMAIL PROTECTED] [EMAIL PROTECTED] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: sigcontext on Linux-ppc in user space
John Kacur [EMAIL PROTECTED] writes: Does anyone know how to get at the struct sigcontext in a signal handler on Linux for powerpc? sigaction of course lets you create a signal handler as a function with the prototype void(*)(int, siginfo_t *, void *) where the last argument, a pointer to void, is the sigcontext. I believe that the last argument is NOT defined by POSIX and so is implementation dependent. On Intel it seems sufficient to use #include asm/sigcontext.h to get the definition of struct sigcontext, and then get the values you'd like out of the signal handler. But on Linux for powerpc, the same thing doesn't work. Does anyone know what the trick is here to accomplish this? You should never include kernel headers in user space. If you have a glibc 2.1 (or newer) based system, just include signal.h which will include bits/sigcontext.h with the struct (this works on all architectures). Andreas -- Andreas Jaeger SuSE Labs [EMAIL PROTECTED] private [EMAIL PROTECTED] http://www.suse.de/~aj - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/