removed dependence on libtraceback
implemented our own traceback after error by attaching gdb
This commit is contained in:
		
							parent
							
								
									256de57333
								
							
						
					
					
						commit
						7f84abb541
					
				@ -24,13 +24,11 @@ AM_CXXFLAGS += -DNO_STRASSEN -DFORTRAN_
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
AM_CXXFLAGS += $(CBLASOPT) $(CLAPACKOPT) 
 | 
					AM_CXXFLAGS += $(CBLASOPT) $(CLAPACKOPT) 
 | 
				
			||||||
AM_CXXFLAGS += $(MKLOPT)
 | 
					AM_CXXFLAGS += $(MKLOPT)
 | 
				
			||||||
AM_CXXFLAGS += $(TRACEBACKOPT)
 | 
					 | 
				
			||||||
#AM_LDFLAGS += .libs/libla.a
 | 
					#AM_LDFLAGS += .libs/libla.a
 | 
				
			||||||
AM_LDFLAGS += $(CBLASLIB)
 | 
					AM_LDFLAGS += $(CBLASLIB)
 | 
				
			||||||
AM_LDFLAGS += $(BLASLIB)
 | 
					AM_LDFLAGS += $(BLASLIB)
 | 
				
			||||||
AM_LDFLAGS += $(ATLASLIB)
 | 
					AM_LDFLAGS += $(ATLASLIB)
 | 
				
			||||||
AM_LDFLAGS += $(MKLLIB)
 | 
					AM_LDFLAGS += $(MKLLIB)
 | 
				
			||||||
AM_LDFLAGS += $(CUDALIBS)
 | 
					AM_LDFLAGS += $(CUDALIBS)
 | 
				
			||||||
AM_LDFLAGS += $(TRACEBACKLIB)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
include $(top_srcdir)/aminclude.am
 | 
					include $(top_srcdir)/aminclude.am
 | 
				
			||||||
 | 
				
			|||||||
@ -105,12 +105,6 @@ AC_SUBST([NVCCFLAGS])
 | 
				
			|||||||
AC_SUBST([MATPTROPT])
 | 
					AC_SUBST([MATPTROPT])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#the check for traceback needs bfd to be linked into
 | 
					 | 
				
			||||||
AC_CHECK_LIB([bfd], [bfd_fprintf_vma])
 | 
					 | 
				
			||||||
AC_CHECK_LIB([traceback], [sigtraceback], [TRACEBACKLIB="-ltraceback -lbfd" TRACEBACKOPT="-DUSE_TRACEBACK -fno-omit-frame-pointer"])
 | 
					 | 
				
			||||||
AC_SUBST([TRACEBACKOPT])
 | 
					 | 
				
			||||||
AC_SUBST([TRACEBACKLIB])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#process options
 | 
					#process options
 | 
				
			||||||
FORINTOPT=""
 | 
					FORINTOPT=""
 | 
				
			||||||
AC_ARG_ENABLE([fotran64int],[  --enable-fotran64int to link with 64-bit-integer-BLAS+LAPACK ],
 | 
					AC_ARG_ENABLE([fotran64int],[  --enable-fotran64int to link with 64-bit-integer-BLAS+LAPACK ],
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								la.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								la.h
									
									
									
									
									
								
							@ -20,9 +20,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
//this should be the single include file for the end user
 | 
					//this should be the single include file for the end user
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
#ifdef USE_TRACEBACK
 | 
					 | 
				
			||||||
#include "traceback.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#include "la_traits.h"
 | 
					#include "la_traits.h"
 | 
				
			||||||
#include "laerror.h"
 | 
					#include "laerror.h"
 | 
				
			||||||
#include "auxstorage.h"
 | 
					#include "auxstorage.h"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										63
									
								
								laerror.cc
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								laerror.cc
									
									
									
									
									
								
							@ -24,12 +24,17 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <sys/mman.h>
 | 
				
			||||||
 | 
					#include <setjmp.h>
 | 
				
			||||||
 | 
					#include <sys/stat.h>
 | 
				
			||||||
 | 
					#include <sys/wait.h>
 | 
				
			||||||
 | 
					#include <sys/prctl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cuda_la.h"
 | 
					#include "cuda_la.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef USE_TRACEBACK
 | 
					 | 
				
			||||||
#include "traceback.h"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace LA {
 | 
					namespace LA {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -42,8 +47,60 @@ bool _LA_count_check=true;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern "C" void _findme(void) {}; //for autoconf test we need a function with C linkage
 | 
					extern "C" void _findme(void) {}; //for autoconf test we need a function with C linkage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//traceback routines
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//simple traceback by calling gdb on ourselves 
 | 
				
			||||||
 | 
					int traceback(int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    char pid_buf[256];
 | 
				
			||||||
 | 
					    sprintf(pid_buf, "%d", getpid());
 | 
				
			||||||
 | 
					    char name_buf[512];
 | 
				
			||||||
 | 
					    name_buf[readlink("/proc/self/exe", name_buf, 511)]=0;
 | 
				
			||||||
 | 
					    prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
 | 
				
			||||||
 | 
					    int child_pid = fork();
 | 
				
			||||||
 | 
					    if (!child_pid) {
 | 
				
			||||||
 | 
					        dup2(2,1); // redirect output to stderr - edit: unnecessary?
 | 
				
			||||||
 | 
					        execl("/usr/bin/gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", name_buf, pid_buf, NULL);
 | 
				
			||||||
 | 
					        abort(); /* If gdb failed to start */
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        waitpid(child_pid,NULL,0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int tracebackflags;
 | 
				
			||||||
 | 
					static int washere=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void tracebackhandler(int i, siginfo_t *info, void *x)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					fflush(stdout);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					traceback(tracebackflags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(!washere) {washere=1; raise(i);} /*generate core*/
 | 
				
			||||||
 | 
					else _exit(1); /*prevent endless loop if something goes very wrong*/
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void sigtraceback(int sig,int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					struct sigaction action;
 | 
				
			||||||
 | 
					action.sa_sigaction=tracebackhandler;
 | 
				
			||||||
 | 
					action.sa_flags=SA_ONESHOT|SA_SIGINFO;
 | 
				
			||||||
 | 
					memset(&action.sa_mask,0,sizeof(sigset_t));
 | 
				
			||||||
 | 
					tracebackflags=flags;
 | 
				
			||||||
 | 
					if(sigaction(sig,&action,NULL)) perror("cannot install signal handler");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}//extern C
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void laerror2(const char *s1, const char *s2)
 | 
					void laerror2(const char *s1, const char *s2)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  std::cout.flush();
 | 
				
			||||||
 | 
					  std::cerr.flush();
 | 
				
			||||||
  std::cerr << "LA:ERROR - ";
 | 
					  std::cerr << "LA:ERROR - ";
 | 
				
			||||||
  std::cout << "LA:ERROR - ";
 | 
					  std::cout << "LA:ERROR - ";
 | 
				
			||||||
  if(s1)
 | 
					  if(s1)
 | 
				
			||||||
 | 
				
			|||||||
@ -19,8 +19,15 @@
 | 
				
			|||||||
#define _LAERROR_H_
 | 
					#define _LAERROR_H_
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace LA {
 | 
					namespace LA {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					extern int traceback(int flags);
 | 
				
			||||||
 | 
					extern void sigtraceback(int sig,int flags);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//exception class for laerror
 | 
					//exception class for laerror
 | 
				
			||||||
class LAerror
 | 
					class LAerror
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								t.cc
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								t.cc
									
									
									
									
									
								
							@ -123,12 +123,10 @@ cout <<y;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int main()
 | 
					int main()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#ifdef USE_TRACEBACK
 | 
					 | 
				
			||||||
sigtraceback(SIGSEGV,1);
 | 
					sigtraceback(SIGSEGV,1);
 | 
				
			||||||
sigtraceback(SIGABRT,1);
 | 
					sigtraceback(SIGABRT,1);
 | 
				
			||||||
sigtraceback(SIGBUS,1);
 | 
					sigtraceback(SIGBUS,1);
 | 
				
			||||||
sigtraceback(SIGFPE,1);
 | 
					sigtraceback(SIGFPE,1);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NRVec<double> x(1.,10);
 | 
					NRVec<double> x(1.,10);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user