@@ -32,76 +32,45 @@ runtime·dumpregs(Context *r)
32
32
runtime·printf ("gs %X\n" , (uint64 )r -> SegGs );
33
33
}
34
34
35
- bool
36
- runtime·isgoexception (ExceptionRecord * info , Context * r )
35
+ // Called by sigtramp from Windows VEH handler.
36
+ // Return value signals whether the exception has been handled (-1)
37
+ // or should be made available to other handlers in the chain (0).
38
+ uint32
39
+ runtime·sighandler (ExceptionRecord * info , Context * r , G * gp )
37
40
{
41
+ bool crash ;
42
+ uintptr * sp ;
38
43
extern byte runtime·text [], runtime·etext [];
39
44
40
45
// Only handle exception if executing instructions in Go binary
41
46
// (not Windows library code).
42
47
if (r -> Rip < (uint64 )runtime·text || (uint64 )runtime·etext < r -> Rip )
43
- return false;
44
-
45
- if (!runtime·issigpanic (info -> ExceptionCode ))
46
- return false;
47
-
48
- return true;
49
- }
50
-
51
- // Called by sigtramp from Windows VEH handler.
52
- // Return value signals whether the exception has been handled (EXCEPTION_CONTINUE_EXECUTION)
53
- // or should be made available to other handlers in the chain (EXCEPTION_CONTINUE_SEARCH).
54
- uint32
55
- runtime·exceptionhandler (ExceptionRecord * info , Context * r , G * gp )
56
- {
57
- uintptr * sp ;
58
-
59
- if (!runtime·isgoexception (info , r ))
60
- return EXCEPTION_CONTINUE_SEARCH ;
61
-
62
- // Make it look like a call to the signal func.
63
- // Have to pass arguments out of band since
64
- // augmenting the stack frame would break
65
- // the unwinding code.
66
- gp -> sig = info -> ExceptionCode ;
67
- gp -> sigcode0 = info -> ExceptionInformation [0 ];
68
- gp -> sigcode1 = info -> ExceptionInformation [1 ];
69
- gp -> sigpc = r -> Rip ;
70
-
71
- // Only push runtime·sigpanic if r->rip != 0.
72
- // If r->rip == 0, probably panicked because of a
73
- // call to a nil func. Not pushing that onto sp will
74
- // make the trace look like a call to runtime·sigpanic instead.
75
- // (Otherwise the trace will end at runtime·sigpanic and we
76
- // won't get to see who faulted.)
77
- if (r -> Rip != 0 ) {
78
- sp = (uintptr * )r -> Rsp ;
79
- * -- sp = r -> Rip ;
80
- r -> Rsp = (uintptr )sp ;
48
+ return 0 ;
49
+
50
+ if (gp != nil && runtime·issigpanic (info -> ExceptionCode )) {
51
+ // Make it look like a call to the signal func.
52
+ // Have to pass arguments out of band since
53
+ // augmenting the stack frame would break
54
+ // the unwinding code.
55
+ gp -> sig = info -> ExceptionCode ;
56
+ gp -> sigcode0 = info -> ExceptionInformation [0 ];
57
+ gp -> sigcode1 = info -> ExceptionInformation [1 ];
58
+ gp -> sigpc = r -> Rip ;
59
+
60
+ // Only push runtime·sigpanic if r->rip != 0.
61
+ // If r->rip == 0, probably panicked because of a
62
+ // call to a nil func. Not pushing that onto sp will
63
+ // make the trace look like a call to runtime·sigpanic instead.
64
+ // (Otherwise the trace will end at runtime·sigpanic and we
65
+ // won't get to see who faulted.)
66
+ if (r -> Rip != 0 ) {
67
+ sp = (uintptr * )r -> Rsp ;
68
+ * -- sp = r -> Rip ;
69
+ r -> Rsp = (uintptr )sp ;
70
+ }
71
+ r -> Rip = (uintptr )runtime·sigpanic ;
72
+ return -1 ;
81
73
}
82
- r -> Rip = (uintptr )runtime·sigpanic ;
83
- return EXCEPTION_CONTINUE_EXECUTION ;
84
- }
85
-
86
- // It seems Windows searches ContinueHandler's list even
87
- // if ExceptionHandler returns EXCEPTION_CONTINUE_EXECUTION.
88
- // firstcontinuehandler will stop that search,
89
- // if exceptionhandler did the same earlier.
90
- uint32
91
- runtime·firstcontinuehandler (ExceptionRecord * info , Context * r , G * gp )
92
- {
93
- USED (gp );
94
- if (!runtime·isgoexception (info , r ))
95
- return EXCEPTION_CONTINUE_SEARCH ;
96
- return EXCEPTION_CONTINUE_EXECUTION ;
97
- }
98
-
99
- // lastcontinuehandler is reached, because runtime cannot handle
100
- // current exception. lastcontinuehandler will print crash info and exit.
101
- uint32
102
- runtime·lastcontinuehandler (ExceptionRecord * info , Context * r , G * gp )
103
- {
104
- bool crash ;
105
74
106
75
if (runtime·panicking ) // traceback already printed
107
76
runtime·exit (2 );
@@ -128,7 +97,7 @@ runtime·lastcontinuehandler(ExceptionRecord *info, Context *r, G *gp)
128
97
runtime·crash ();
129
98
130
99
runtime·exit (2 );
131
- return 0 ; // not reached
100
+ return -1 ; // not reached
132
101
}
133
102
134
103
void
0 commit comments