Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1126)

Delta Between Two Patch Sets: src/pkg/runtime/traceback_x86.c

Issue 68150047: all: merge NaCl branch (part 1)
Left Patch Set: Created 11 years, 1 month ago
Right Patch Set: diff -r 737d232b573b ssh://hg@bitbucket.org/davecheney/go.nacl Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/syscall_nacl.h ('k') | src/pkg/runtime/vlrt_386.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build amd64 386 5 // +build amd64 amd64p32 386
6 6
7 #include "runtime.h" 7 #include "runtime.h"
8 #include "arch_GOARCH.h" 8 #include "arch_GOARCH.h"
9 #include "malloc.h" 9 #include "malloc.h"
10 #include "funcdata.h" 10 #include "funcdata.h"
11 11
12 void runtime·sigpanic(void); 12 void runtime·sigpanic(void);
13 13
14 // This code is also used for the 386 tracebacks. 14 // This code is also used for the 386 tracebacks.
15 // Use uintptr for an appropriate word-sized integer. 15 // Use uintptr for an appropriate word-sized integer.
(...skipping 29 matching lines...) Expand all
45 runtime·memclr((byte*)&frame, sizeof frame); 45 runtime·memclr((byte*)&frame, sizeof frame);
46 frame.pc = pc0; 46 frame.pc = pc0;
47 frame.sp = sp0; 47 frame.sp = sp0;
48 waspanic = false; 48 waspanic = false;
49 printing = pcbuf==nil && callback==nil; 49 printing = pcbuf==nil && callback==nil;
50 ········ 50 ········
51 // If the PC is zero, it's likely a nil function call. 51 // If the PC is zero, it's likely a nil function call.
52 // Start in the caller's frame. 52 // Start in the caller's frame.
53 if(frame.pc == 0) { 53 if(frame.pc == 0) {
54 frame.pc = *(uintptr*)frame.sp; 54 frame.pc = *(uintptr*)frame.sp;
55 » » frame.sp += sizeof(uintptr); 55 » » frame.sp += sizeof(uintreg);
56 } 56 }
57 ········ 57 ········
58 f = runtime·findfunc(frame.pc); 58 f = runtime·findfunc(frame.pc);
59 if(f == nil) { 59 if(f == nil) {
60 if(callback != nil) { 60 if(callback != nil) {
61 runtime·printf("runtime: unknown pc %p\n", frame.pc); 61 runtime·printf("runtime: unknown pc %p\n", frame.pc);
62 runtime·throw("unknown pc"); 62 runtime·throw("unknown pc");
63 } 63 }
64 return 0; 64 return 0;
65 } 65 }
(...skipping 28 matching lines...) Expand all
94 } 94 }
95 frame.fn = f; 95 frame.fn = f;
96 continue; 96 continue;
97 } 97 }
98 f = frame.fn; 98 f = frame.fn;
99 99
100 // Found an actual function. 100 // Found an actual function.
101 // Derive frame pointer and link register. 101 // Derive frame pointer and link register.
102 if(frame.fp == 0) { 102 if(frame.fp == 0) {
103 frame.fp = frame.sp + runtime·funcspdelta(f, frame.pc); 103 frame.fp = frame.sp + runtime·funcspdelta(f, frame.pc);
104 » » » frame.fp += sizeof(uintptr); // caller PC 104 » » » frame.fp += sizeof(uintreg); // caller PC
105 } 105 }
106 if(runtime·topofstack(f)) { 106 if(runtime·topofstack(f)) {
107 frame.lr = 0; 107 frame.lr = 0;
108 flr = nil; 108 flr = nil;
109 } else { 109 } else {
110 if(frame.lr == 0) 110 if(frame.lr == 0)
111 » » » » frame.lr = ((uintptr*)frame.fp)[-1]; 111 » » » » frame.lr = ((uintreg*)frame.fp)[-1];
112 flr = runtime·findfunc(frame.lr); 112 flr = runtime·findfunc(frame.lr);
113 if(flr == nil) { 113 if(flr == nil) {
114 runtime·printf("runtime: unexpected return pc fo r %s called from %p\n", runtime·funcname(f), frame.lr); 114 runtime·printf("runtime: unexpected return pc fo r %s called from %p\n", runtime·funcname(f), frame.lr);
115 if(callback != nil) 115 if(callback != nil)
116 runtime·throw("unknown caller pc"); 116 runtime·throw("unknown caller pc");
117 } 117 }
118 } 118 }
119 ················ 119 ················
120 » » frame.varp = (byte*)frame.fp - sizeof(uintptr); 120 » » frame.varp = (byte*)frame.fp - sizeof(uintreg);
121 121
122 // Derive size of arguments. 122 // Derive size of arguments.
123 // Most functions have a fixed-size argument block, 123 // Most functions have a fixed-size argument block,
124 // so we can use metadata about the function f. 124 // so we can use metadata about the function f.
125 // Not all, though: there are some variadic functions 125 // Not all, though: there are some variadic functions
126 // in package runtime and reflect, and for those we use call-spe cific 126 // in package runtime and reflect, and for those we use call-spe cific
127 // metadata recorded by f's caller. 127 // metadata recorded by f's caller.
128 if(callback != nil || printing) { 128 if(callback != nil || printing) {
129 frame.argp = (byte*)frame.fp; 129 frame.argp = (byte*)frame.fp;
130 if(f->args != ArgsSizeUnknown) 130 if(f->args != ArgsSizeUnknown)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 int32 255 int32
256 runtime·callers(int32 skip, uintptr *pcbuf, int32 m) 256 runtime·callers(int32 skip, uintptr *pcbuf, int32 m)
257 { 257 {
258 uintptr pc, sp; 258 uintptr pc, sp;
259 259
260 sp = runtime·getcallersp(&skip); 260 sp = runtime·getcallersp(&skip);
261 pc = (uintptr)runtime·getcallerpc(&skip); 261 pc = (uintptr)runtime·getcallerpc(&skip);
262 262
263 return runtime·gentraceback(pc, sp, 0, g, skip, pcbuf, m, nil, nil, fals e); 263 return runtime·gentraceback(pc, sp, 0, g, skip, pcbuf, m, nil, nil, fals e);
264 } 264 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b