~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/libmach/linux.c

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
                        PTRACE_O_TRACEVFORK |
239
239
                        PTRACE_O_TRACECLONE |
240
240
                        PTRACE_O_TRACEEXEC |
241
 
                        PTRACE_O_TRACEVFORKDONE |
242
 
                        PTRACE_O_TRACEEXIT;
 
241
                        PTRACE_O_TRACEVFORKDONE;
243
242
                if(ptrace(PTRACE_SETOPTIONS, tid, 0, (void*)flags) < 0) {
244
243
                        fprint(2, "ptrace PTRACE_SETOPTIONS %d: %r\n", tid);
245
244
                        return nil;
358
357
                                break;
359
358
 
360
359
                        case PTRACE_EVENT_EXIT:
 
360
                                // We won't see this unless we set PTRACE_O_TRACEEXIT.
 
361
                                // The debuggers assume that a read or write on a Map
 
362
                                // will fail for a thread that has exited.  This event
 
363
                                // breaks that assumption.  It's not a big deal: we
 
364
                                // only lose the ability to see the register state at
 
365
                                // the time of exit.
361
366
                                if(trace)
362
367
                                        fprint(2, "tid %d: exiting %#x\n", tid, status);
363
368
                                t->state = Exiting;
755
760
ptracerw(int type, int xtype, int isr, int pid, uvlong addr, void *v, uint n)
756
761
{
757
762
        int i;
758
 
        uintptr u;
 
763
        uintptr u, a;
759
764
        uchar buf[sizeof(uintptr)];
760
765
 
761
766
        for(i=0; i<n; i+=sizeof(uintptr)){
 
767
                // Tread carefully here.  On recent versions of glibc,
 
768
                // ptrace is a variadic function which means the third
 
769
                // argument will be pushed onto the stack as a uvlong.
 
770
                // This is fine on amd64 but will not work for 386.
 
771
                // We must convert addr to a uintptr.
 
772
                a = addr+i;
762
773
                if(isr){
763
774
                        errno = 0;
764
 
                        u = ptrace(type, pid, addr+i, 0);
 
775
                        u = ptrace(type, pid, a, 0);
765
776
                        if(errno)
766
777
                                goto ptraceerr;
767
778
                        if(n-i >= sizeof(uintptr))
775
786
                                u = *(uintptr*)((char*)v+i);
776
787
                        else{
777
788
                                errno = 0;
778
 
                                u = ptrace(xtype, pid, addr+i, 0);
 
789
                                u = ptrace(xtype, pid, a, 0);
779
790
                                if(errno)
780
791
                                        return -1;
781
792
                                memmove(buf, &u, sizeof u);
782
793
                                memmove(buf, (char*)v+i, n-i);
783
794
                                memmove(&u, buf, sizeof u);
784
795
                        }
785
 
                        if(ptrace(type, pid, addr+i, u) < 0)
 
796
                        if(ptrace(type, pid, a, u) < 0)
786
797
                                goto ptraceerr;
787
798
                }
788
799
        }