Always flush to get a slightly better guarantee of getting the error
message out. Use stderr, and put a "yes, we're done with the error message" marker at the end of the error message so that you know if you saw it all or the message was truncated. This commit was SVN r4333.
Этот коммит содержится в:
родитель
a8099eaa07
Коммит
f7918064ff
@ -15,6 +15,11 @@
|
|||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
#include "include/constants.h"
|
#include "include/constants.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
#ifdef HAVE_EXECINFO_H
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
@ -62,6 +67,7 @@ static void ompi_show_stackframe (int signo, siginfo_t * info, void * p)
|
|||||||
int size = sizeof (print_buffer);
|
int size = sizeof (print_buffer);
|
||||||
int ret;
|
int ret;
|
||||||
char * str="";
|
char * str="";
|
||||||
|
char eof_msg[] = "*** End of error message ***\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Yes, we are doing printf inside a signal-handler.
|
* Yes, we are doing printf inside a signal-handler.
|
||||||
@ -204,41 +210,46 @@ static void ompi_show_stackframe (int signo, siginfo_t * info, void * p)
|
|||||||
case SIGFPE:
|
case SIGFPE:
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
case SIGBUS:
|
case SIGBUS:
|
||||||
{
|
{
|
||||||
ret = snprintf (tmp, size, "Failing at addr:%p\n",
|
ret = snprintf (tmp, size, "Failing at addr:%p\n",
|
||||||
info->si_addr);
|
info->si_addr);
|
||||||
size -= ret;
|
size -= ret;
|
||||||
tmp += ret;
|
tmp += ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SIGCHLD: {
|
case SIGCHLD: {
|
||||||
ret = snprintf (tmp, size, "si_pid:%d si_uid:%d si_status:%d\n",
|
ret = snprintf (tmp, size, "si_pid:%d si_uid:%d si_status:%d\n",
|
||||||
info->si_pid, info->si_uid, info->si_status);
|
info->si_pid, info->si_uid, info->si_status);
|
||||||
size -= ret;
|
size -= ret;
|
||||||
tmp += ret;
|
tmp += ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef SIGPOLL
|
#ifdef SIGPOLL
|
||||||
case SIGPOLL: {
|
case SIGPOLL: {
|
||||||
ret = snprintf (tmp, size, "si_band:%ld si_fd:%d\n",
|
ret = snprintf (tmp, size, "si_band:%ld si_fd:%d\n",
|
||||||
info->si_band, info->si_fd);
|
info->si_band, info->si_fd);
|
||||||
size -= ret;
|
size -= ret;
|
||||||
tmp += ret;
|
tmp += ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("%s", print_buffer);
|
write(1, print_buffer, size);
|
||||||
fflush(stdout);
|
fflush(stderr);
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
trace_size = backtrace (trace, 32);
|
trace_size = backtrace (trace, 32);
|
||||||
messages = backtrace_symbols (trace, trace_size);
|
messages = backtrace_symbols (trace, trace_size);
|
||||||
|
|
||||||
for (i = 0; i < trace_size; i++)
|
for (i = 0; i < trace_size; i++) {
|
||||||
printf ("[%d] func:%s\n", i, messages[i]);
|
fprintf(stderr, "[%d] func:%s\n", i, messages[i]);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
write(1, eof_msg, sizeof(eof_msg));
|
||||||
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
@ -283,25 +294,23 @@ int ompi_util_register_stackhandlers (void)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sig = strtol (tmp, &next, 10);
|
sig = strtol (tmp, &next, 10);
|
||||||
/*
|
|
||||||
printf ("ompi_util_register_stackhandlers: sig:%d tmp:%p next:%p "
|
|
||||||
"tmp:[%s] next:[%s] _NSIG:%d\n",
|
|
||||||
sig, tmp, next, tmp, next, _NSIG);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is no sensible number in the string, exit.
|
* If there is no sensible number in the string, exit.
|
||||||
* Similarly for any number which is not in the signal-number range
|
* Similarly for any number which is not in the signal-number range
|
||||||
*/
|
*/
|
||||||
if (((0 == sig) && (tmp == next)) || (0 > sig) || (_NSIG <= sig))
|
if (((0 == sig) && (tmp == next)) || (0 > sig) || (_NSIG <= sig)) {
|
||||||
return OMPI_ERR_BAD_PARAM;
|
return OMPI_ERR_BAD_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
if ((next == NULL) || ((*next != ',') && (*next != '\0')))
|
if ((next == NULL) || ((*next != ',') && (*next != '\0'))) {
|
||||||
return OMPI_ERR_BAD_PARAM;
|
return OMPI_ERR_BAD_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = sigaction (sig, &act, NULL);
|
ret = sigaction (sig, &act, NULL);
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
return OMPI_ERR_IN_ERRNO;
|
return OMPI_ERR_IN_ERRNO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
*
|
*
|
||||||
* $HEADER$
|
* $HEADER$
|
||||||
|
*
|
||||||
|
* @file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OMPI_STACKTRACE_H
|
#ifndef OMPI_STACKTRACE_H
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user