update cin.po, goog xlat update xx.po
[goodguy/history.git] / cinelerra-5.1 / guicast / bcsignals.C
index 609ea1e2afbbbd0c5633948c9dcc77f0241d2dc0..e7c14074e9715ac69e4e2eae408f8f605fd9b08c 100644 (file)
 
 #include "bcsignals.h"
 #include "bcwindowbase.h"
+#include "bccmodels.h"
 #include "bckeyboard.h"
 #include "bcresources.h"
 
 #include <ctype.h>
 #include <dirent.h>
 #include <execinfo.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -419,6 +421,10 @@ void BC_Signals::set_sighup_exit(int enable)
 BC_Signals::BC_Signals()
 {
 }
+BC_Signals::~BC_Signals()
+{
+  BC_CModels::bcxfer_stop_slicers();
+}
 
 void BC_Signals::dump_traces(FILE *fp)
 {
@@ -503,8 +509,9 @@ int BC_Signals::x_error_handler(Display *display, XErrorEvent *event)
 {
        char string[1024];
        XGetErrorText(event->display, event->error_code, string, 1024);
-       fprintf(stderr, "BC_Signals::x_error_handler: error_code=%d opcode=%d,%d %s\n",
-               event->error_code, event->request_code, event->minor_code, string);
+       fprintf(stderr, "BC_Signals::x_error_handler: error_code=%d opcode=%d,%d id=0x%jx %s\n",
+               event->error_code, event->request_code, event->minor_code,
+               (int64_t)event->resourceid, string);
        return 0;
 }
 
@@ -830,9 +837,10 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
        ucontext_t *uc = (ucontext_t *)sc;
        int pid = getpid(), tid = gettid();
        struct sigcontext *c = (struct sigcontext *)&uc->uc_mcontext;
+       uint8_t *ip = (uint8_t *)c->IP;
        fprintf(stderr,"** %s at %p in pid %d, tid %d\n",
                n==SIGSEGV? "segv" : n==SIGINT? "intr" : "trap",
-               (void*)c->IP, pid, tid);
+               (void*)ip, pid, tid);
        FILE *fp = 0;
        char fn[PATH_MAX];
        if( BC_Signals::trap_path ) {
@@ -869,6 +877,27 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
        fprintf(fp,"\nVERSION:\n");  bc_copy_textfile(INT_MAX, fp,"/proc/version");
        fprintf(fp,"\nMEMINFO:\n");  bc_copy_textfile(INT_MAX, fp,"/proc/meminfo");
        fprintf(fp,"\nMAPS:\n");     bc_copy_textfile(INT_MAX, fp,"/proc/%d/maps",pid);
+       char proc_mem[64];
+       if( tid > 0 && tid != pid )
+               sprintf(proc_mem,"/proc/%d/task/%d/mem",pid,tid);
+       else
+               sprintf(proc_mem,"/proc/%d/mem",pid);
+       int pfd = open(proc_mem,O_RDONLY);
+       if( pfd >= 0 ) {
+               fprintf(fp,"\nCODE:\n");
+               for( int i=-32; i<32; ) {
+                       uint8_t v;  void *vp = (void *)(ip + i);
+                       if( !(i & 7) ) fprintf(fp,"%p:  ", vp);
+                       if( pread(pfd,&v,sizeof(v),(off_t)vp) != sizeof(v) ) break;
+                       fprintf(fp,"%c%02x", !i ? '>' : ' ', v);
+                       if( !(++i & 7) ) fprintf(fp,"\n");
+               }
+               fprintf(fp,"\n");
+               close(pfd);
+       }
+       else
+               fprintf(fp,"err opening: %s, %m\n", proc_mem);
+
        fprintf(fp,"\n\n");
        if( fp != stdout ) fclose(fp);
        char cmd[1024], *cp = cmd;