Error Handler

I am attempting to write an error handler for an embedded system
running QNX 6.1. Once I receive a signal like SIGSEGV for example,
I would like to print to the screen select thread information like
the PC, SP, and register values at the faulting instruction. I have
successfully implemented the signal handler, but I am now trying to
figure out a way to print these values to the screen. I have tried using
tracing and the setjmp function, but neither could be used in my case.
However, there is a file called sigcontext.h that exists on linux and QNX
4. This file defines a struct that contains the desired information. In
addition, the struct is easily manageable and would be ideal for my
environment. However, this file does not exist on QNX 6.1 and when I
attempted to copy it over it would not compile most likely because it is
platform specific. Does anyone know if there is an equivalent file for QNX
6.1? If not does QNX 6.1 supply another method for attaining this
information? Thanks!

Adam

I’m sure that what you want to do can be done. I did it for QNX4. I know
that there is a dumper program for QNX6 so IT can get the information you
want. I just don’t know if that struct/header is “publicly available”.

QSSL?

“Adam” <adambomb223@yahoo.com> wrote in message
news:Xns920D8F3C9E344adambomb223@209.226.137.7

I am attempting to write an error handler for an embedded system
running QNX 6.1. Once I receive a signal like SIGSEGV for example,
I would like to print to the screen select thread information like
the PC, SP, and register values at the faulting instruction. I have
successfully implemented the signal handler, but I am now trying to
figure out a way to print these values to the screen. I have tried using
tracing and the setjmp function, but neither could be used in my case.
However, there is a file called sigcontext.h that exists on linux and QNX
4. This file defines a struct that contains the desired information. In
addition, the struct is easily manageable and would be ideal for my
environment. However, this file does not exist on QNX 6.1 and when I
attempted to copy it over it would not compile most likely because it is
platform specific. Does anyone know if there is an equivalent file for
QNX
6.1? If not does QNX 6.1 supply another method for attaining this
information? Thanks!

Adam

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in
news:abp0rg$hnq$1@inn.qnx.com:

Yes, I am aware of the dumper command line program, but the embedded system
that I will be using will be unable to make use of that. I need to find a
way of accomplishing this completely in the software. How did you
accomplish it for QNX 4? Did you do it in software or did you use a
command line utility? Thanks!

Adam




I’m sure that what you want to do can be done. I did it for QNX4. I
know that there is a dumper program for QNX6 so IT can get the
information you want. I just don’t know if that struct/header is
“publicly available”.

“Adam” <adambomb223@yahoo.com> wrote in message
news:Xns920E5E3BD12AEadambomb223@209.226.137.7

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in
news:abp0rg$hnq$> 1@inn.qnx.com> :

Yes, I am aware of the dumper command line program, but the embedded
system
that I will be using will be unable to make use of that. I need to find a
way of accomplishing this completely in the software. How did you
accomplish it for QNX 4? Did you do it in software or did you use a
command line utility? Thanks!

Adam

system message _SYSMSG_DEATH should have some additional parameters where
included dead process’s register values and so so on. afair someone posted
code displying this feature in qnd.public.qnx4 during this year but i lost
it. check archives or ask again :slight_smile:

ps: this i guess only for QNX4 due to os specific.

// wbr

Adam <adambomb223@yahoo.com> wrote in
news:Xns920E5E3BD12AEadambomb223@209.226.137.7:

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in
news:abp0rg$hnq$> 1@inn.qnx.com> :

Yes, I am aware of the dumper command line program, but the embedded
system that I will be using will be unable to make use of that. I need
to find a way of accomplishing this completely in the software. How
did you accomplish it for QNX 4? Did you do it in software or did you
use a command line utility? Thanks!

I whipped up a little demo program that will show how to get the IP address
of a SIGSEGV. That should get you going - the info is in the siginfo
struct passed in when using sigaction.

Below is the code snippet.


Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>



#include <stdio.h>
#include <stdlib.h>
#include <signal.h>


void shand(int signo, siginfo_t info, void other);

int main(int argc, char* argv[])
{
sigset_t set;
struct sigaction act;
char* p =(char*) 0x0;

sigemptyset(&set);
sigaddset(&set, SIGSEGV);

act.sa_flags = 0;
act.sa_mask = set;
act.sa_handler = shand;
act.sa_sigaction = shand;

sigaction(SIGSEGV, &act, NULL);

/* this should SIGSEGV */
printf("%s\n", p);

return(0);
}

void shand(int signo, siginfo_t info, void other)
{
printf(“Bad things happend at %p!\n”, (void*)info-

__data.__fault.__fltip);
exit(-1);

}

Someone from QSSL sent me the header file and all the hooks necessary and I
wrote the routine that examined the stack. We needed to send just a small
amount of data out a serial port from an embedded system.

“Adam” <adambomb223@yahoo.com> wrote in message
news:Xns920E5E3BD12AEadambomb223@209.226.137.7

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in
news:abp0rg$hnq$> 1@inn.qnx.com> :

Yes, I am aware of the dumper command line program, but the embedded
system
that I will be using will be unable to make use of that. I need to find a
way of accomplishing this completely in the software. How did you
accomplish it for QNX 4? Did you do it in software or did you use a
command line utility? Thanks!

Adam




I’m sure that what you want to do can be done. I did it for QNX4. I
know that there is a dumper program for QNX6 so IT can get the
information you want. I just don’t know if that struct/header is
“publicly available”.

“Ian Zagorskih” <NOSPAM-ianzag@mail.ru> wrote in message
news:abr2eq$4np$1@inn.qnx.com

system message _SYSMSG_DEATH should have some additional parameters where
included dead process’s register values and so so on. afair someone posted
code displying this feature in qnd.public.qnx4 during this year but i lost
it. check archives or ask again > :slight_smile:

ps: this i guess only for QNX4 due to os specific.

I don’t remember this for QNX4. It could be though. I guess there are

still some things about QNX4 I don’t know.

Adam Mallory <amallory@qnx.com> wrote in
news:Xns920E7C0C8721Famalloryqnxcom@209.226.137.4:

Adam <> adambomb223@yahoo.com> > wrote in
news:Xns920E5E3BD12AEadambomb223@209.226.137.7:

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in
news:abp0rg$hnq$> 1@inn.qnx.com> :

Yes, I am aware of the dumper command line program, but the embedded
system that I will be using will be unable to make use of that. I
need to find a way of accomplishing this completely in the software.
How did you accomplish it for QNX 4? Did you do it in software or
did you use a command line utility? Thanks!

I whipped up a little demo program that will show how to get the IP
address of a SIGSEGV. That should get you going - the info is in the
siginfo struct passed in when using sigaction.

Below is the code snippet.

Adam,

Once again thanks for the help! I have tried your code and it works
perfectly. However, I do not believe that the siginfo_t struct includes
register values and stack info like the stack pointer. It had the pid and
some other info. Is there another struct where I can get this info from,
or have I overlooked something inside siginfo.h. Thanks in advance!

Adam

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:abrhuq$fp3$1@inn.qnx.com

“Ian Zagorskih” <> NOSPAM-ianzag@mail.ru> > wrote in message
news:abr2eq$4np$> 1@inn.qnx.com> …

system message _SYSMSG_DEATH should have some additional parameters
where
included dead process’s register values and so so on. afair someone
posted
code displying this feature in qnd.public.qnx4 during this year but i
lost
it. check archives or ask again > :slight_smile:

ps: this i guess only for QNX4 due to os specific.

I don’t remember this for QNX4. It could be though. I guess there are
still some things about QNX4 I don’t know.

As an example http://qdn.qnx.com/support/bok/solution.qnx?10013

// wbr