[Cin] ppc64le incomplete patch #2

Andrew Randrianasulu randrianasulu at gmail.com
Mon Mar 11 00:17:55 CET 2019


В сообщении от Thursday 07 March 2019 22:49:32 Daniel Reurich написал(а):
> Hi Andrew,
> 
> For fixing BCSignals, I found that struct sigcontext which ultimately
> comes from sigcontext.h in the kernel headers doesn't provide a
> conistent mapping of the registers across all architectures - but struct
> pt_reg from <asm/ptrace.h> does.

Thanks, I see  patch was pulled into git recently. Will try in few days 

(sorry had gmail 'box full' problem, freed some space, now mails thankfully arrived 'from somewhere')

> 
> So you might want to give this patch a spin:
> 
> diff --git a/guicast/bcsignals.C b/guicast/bcsignals.C
> index ed50cfb..b7549de 100644
> --- a/guicast/bcsignals.C
> +++ b/guicast/bcsignals.C
> @@ -382,6 +382,7 @@ const char* BC_Signals::sig_to_str(int number)
>  #include <ucontext.h>
>  #include <sys/wait.h>
>  #include "thread.h"
> +#include <asm/ptrace.h>
> 
>  #if __i386__
>  #define IP eip
> @@ -389,6 +390,9 @@ const char* BC_Signals::sig_to_str(int number)
>  #if __x86_64__
>  #define IP rip
>  #endif
> +#if __powerpc__ || __powerpc64__ || __powerpc64le__
> +#define IP nip
> +#endif
>  #ifndef IP
>  #error gotta have IP
>  #endif
> @@ -406,7 +410,7 @@ static void handle_dump(int n, siginfo_t * info,
> void *sc)
>  //     if( uid != 0 ) return;
>         ucontext_t *uc = (ucontext_t *)sc;
>         int pid = getpid(), tid = gettid();
> -       struct sigcontext *c = (struct sigcontext *)&uc->uc_mcontext;
> +       struct pt_regs *c = (struct pt_regs *)&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",
> 
> 
> 
> On 25/02/19 17:18, Andrew Randrianasulu wrote:
> > diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C
> > index ed50cfb..8442847 100644
> > --- a/cinelerra-5.1/guicast/bcsignals.C
> > +++ b/cinelerra-5.1/guicast/bcsignals.C
> > @@ -389,6 +389,9 @@ const char* BC_Signals::sig_to_str(int number)
> >  #if __x86_64__
> >  #define IP rip
> >  #endif
> > +#if __powerpc64__
> > +#define IP nip
> > +#endif
> >  #ifndef IP
> >  #error gotta have IP
> >  #endif
> > @@ -404,13 +407,14 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
> >  // it is not necessary to be root if ptrace is allowed via:
> >  // echo 0 > /proc/sys/kernel/yama/ptrace_scope (usually set to 1)
> >  //	if( uid != 0 ) return;
> > +
> >  	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*)ip, pid, tid);
> > +//	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*)ip, pid, tid);
> >  	FILE *fp = 0;
> >  	char fn[PATH_MAX];
> >  	if( BC_Signals::trap_path ) {
> > @@ -419,9 +423,9 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
> >  	}
> >  	if( fp ) {
> >  		fprintf(stderr,"writing debug data to %s\n", fn);
> > -		fprintf(fp,"** %s at %p in pid %d, tid %d\n",
> > -			n==SIGSEGV? "segv" : n==SIGINT? "intr" : "trap",
> > -			(void*)c->IP, pid, tid);
> > +//		fprintf(fp,"** %s at %p in pid %d, tid %d\n",
> > +//			n==SIGSEGV? "segv" : n==SIGINT? "intr" : "trap",
> > +//			(void*)c->IP, pid, tid);
> >  	}
> >  	else {
> >  		strcpy(fn, "stdout");
> > @@ -458,13 +462,13 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
> >  	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");
> > -		}
> > +//		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);
> >  	}
> > @@ -494,5 +498,6 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
> >  	}
> >          char *const argv[4] = { (char*) "/bin/sh", (char*) "-c", cmd, 0 };
> >          execvp(argv[0], &argv[0]);
> > +
> >  }
> >  
> 
> 




More information about the Cin mailing list