~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/runtime/sys_x86.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
 
5
 
// +build amd64 386
 
5
// +build amd64 amd64p32 386
6
6
 
7
7
#include "runtime.h"
8
8
 
14
14
        uintptr *sp;
15
15
        
16
16
        sp = (uintptr*)gobuf->sp;
 
17
        if(sizeof(uintreg) > sizeof(uintptr))
 
18
                *--sp = 0;
17
19
        *--sp = (uintptr)gobuf->pc;
18
20
        gobuf->sp = (uintptr)sp;
19
21
        gobuf->pc = (uintptr)fn;
27
29
runtime·rewindmorestack(Gobuf *gobuf)
28
30
{
29
31
        byte *pc;
30
 
        
 
32
 
31
33
        pc = (byte*)gobuf->pc;
32
34
        if(pc[0] == 0xe9) { // jmp 4-byte offset
33
35
                gobuf->pc = gobuf->pc + 5 + *(int32*)(pc+1);
37
39
                gobuf->pc = gobuf->pc + 2 + *(int8*)(pc+1);
38
40
                return;
39
41
        }
40
 
        if(pc[0] == 0xcc) {
41
 
                // This is a breakpoint inserted by gdb.  We could use
42
 
                // runtime·findfunc to find the function.  But if we
43
 
                // do that, then we will continue execution at the
44
 
                // function entry point, and we will not hit the gdb
45
 
                // breakpoint.  So for this case we don't change
46
 
                // gobuf->pc, so that when we return we will execute
47
 
                // the jump instruction and carry on.  This means that
48
 
                // stack unwinding may not work entirely correctly
49
 
                // (http://golang.org/issue/5723) but the user is
50
 
                // running under gdb anyhow.
51
 
                return;
 
42
        if(pc[0] == 0xcc) {
 
43
                // This is a breakpoint inserted by gdb.  We could use
 
44
                // runtime·findfunc to find the function.  But if we
 
45
                // do that, then we will continue execution at the
 
46
                // function entry point, and we will not hit the gdb
 
47
                // breakpoint.  So for this case we don't change
 
48
                // gobuf->pc, so that when we return we will execute
 
49
                // the jump instruction and carry on.  This means that
 
50
                // stack unwinding may not work entirely correctly
 
51
                // (http://golang.org/issue/5723) but the user is
 
52
                // running under gdb anyhow.
 
53
                return;
52
54
        }
53
55
        runtime·printf("runtime: pc=%p %x %x %x %x %x\n", pc, pc[0], pc[1], pc[2], pc[3], pc[4]);
54
56
        runtime·throw("runtime: misuse of rewindmorestack");