T.R | Title | User | Personal Name | Date | Lines |
---|
3566.1 | Note sent to developer | HYDRA::NEWMAN | Chuck Newman, 508/467-5499 (DTN 297), MRO1-3/F26 | Fri May 02 1997 14:41 | 23 |
| Marian --
I agree that the default behavior is different depending on whether the failure
is in a thread or not, but I'm not quite sure exactly what behavior you want.
By "default" I mean what happens when you have not specified your own condition
handler.
In your MAIL you said that you want to have a traceback and also have your
condition handler execute. To the best of my knowledge this is not something
you can get, independant of whether you're using threads or not.
There are routines to help you walk the frames, but I don't know of any
supported way to get the symbol information (i.e., routine names and line
numbers). These routines are LIB$GET_CURRENT_INVO_CONTEXT and friends.
And no, I don't know any way to force a traceback from a thread.
Make sure you read the section titled "Using the DECthreads Exception Package"
in the "Guide to DECthreads" manual on the Documentation CD that ships with
OpenVMS.
-- Chuck Newman
|
3566.2 | A little more information (not yet sent to developer) | HYDRA::NEWMAN | Chuck Newman, 508/467-5499 (DTN 297), MRO1-3/F26 | Fri May 02 1997 18:43 | 41 |
| Well, it *IS* possible to get a traceback without dieing -- but I haven't yet
been able to do it from a thread. Here's the test program I'm working on:
$ cc/REENTRANCY=MULTITHREAD
$ link a,a/opt
(a.opt = sys$share:CMA$OPEN_RTL/shar)
#include <pthread.h>
#include <stdio.h>
#include <lib$routines.h>
static void a_function(int *);
main()
{
pthread_t a_thread;
volatile int doit=0;
printf("Before thread: traceback\n");
lib$signal(0);
printf("traced back\n");
pthread_create(&a_thread, pthread_attr_default, (void * ((*)(void
*)))(&a_function), (void *)(&doit));
while (doit == 0) ;
printf("After thread: traceback\n");
lib$signal(0);
printf("traced back\n");
}
static void a_function(int *doit)
{
printf("in a thread: traceback\n");
lib$signal(0);
printf("traced back\n");
*doit = 1;
}
Another option would be to signal ss$_debug, and tell the debugger to SHOW
CALLS;GO, but that would leave the problem of the image exiting to the debugger.
|
3566.3 | The following worked on V7.1 -- sent to developer | HYDRA::NEWMAN | Chuck Newman, 508/467-5499 (DTN 297), MRO1-3/F26 | Tue May 27 1997 15:41 | 113 |
| Marion --
The following works on OpenVMS Alpha V7.1. I hope it is close to what you need.
$ cc/REENTRANCY=MULTITHREAD a
$ link a,a/opt
(a.opt = sys$share:CMA$OPEN_RTL/shar)
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <ssdef.h>
#include <lib$routines.h>
static void a_function(int *);
static int value1, value2, value3;
main(int argc, char *argv[])
{
pthread_t a_thread;
pthread_attr_t pthread_attr;
volatile int doit=0;
if (argc <= 1)
{
value1 = 0;
value2 = 0;
value3 = 0;
}
else
{
value1 = atoi(argv[1]);
if (argc == 3)
{
value2 = atoi(argv[2]);
if (argc == 4)
{
value3 = atoi(argv[3]);
}
else
{
value3 = 0;
}
}
else
{
value2 = 0;
value3 = 0;
}
}
pthread_attr_init(&pthread_attr);
printf("Before thread: traceback\n");
lib$signal(value1);
printf("traced back\n");
pthread_create(&a_thread, &pthread_attr, (void * ((*)(void *)))(&a_function),
(void *)(&doit));
while (doit == 0) ;
printf("After thread: traceback\n");
lib$signal(value2);
printf("traced back\n");
}
static void a_function(int *doit)
{
printf("in a thread: traceback\n");
PTHREAD_TRY_NP {
}
PTHREAD_CATCH_ALL_NP {
PTHREAD_RERAISE_NP;
}
PTHREAD_ENDTRY_NP
lib$signal(value3);
printf("traced back\n");
*doit = 1;
}
$ run a
Before thread: traceback
%NONAME-W-NOMSG, Message number 00000000
%TRACE-W-NOMSG, Message number 00098048
image module routine line rel PC abs PC
A A main 12996 0000000000000220 0000000000020220
A A __main 0 00000000000000C0 00000000000200C0
PTHREAD$RTL 0 000000000004C148 000000000008E148
PTHREAD$RTL 0 0000000000030664 0000000000072664
0 FFFFFFFF82E8D0D8 FFFFFFFF82E8D0D8
traced back
in a thread: traceback
%NONAME-W-NOMSG, Message number 00000000
%TRACE-W-NOMSG, Message number 00098048
image module routine line rel PC abs PC
A A a_function 13014 0000000000000414 0000000000020414
PTHREAD$RTL 0 000000000004C148 000000000008E148
PTHREAD$RTL 0 000000000003D294 000000000007F294
0 0000000000000000 0000000000000000
PTHREAD$RTL ? ?
0 FFFFFFFF82E8D0D8 FFFFFFFF82E8D0D8
traced back
After thread: traceback
%NONAME-W-NOMSG, Message number 00000000
%TRACE-W-NOMSG, Message number 00098048
image module routine line rel PC abs PC
A A main 13001 000000000000029C 000000000002029C
A A __main 0 00000000000000C0 00000000000200C0
PTHREAD$RTL 0 000000000004C148 000000000008E148
PTHREAD$RTL 0 0000000000030664 0000000000072664
0 FFFFFFFF82E8D0D8 FFFFFFFF82E8D0D8
traced back
$
|