Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
ab9f27b2
Commit
ab9f27b2
authored
Sep 12, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix up linux trap handling - INTB 5 gives SEGV
R=rsc OCL=15244 CL=15244
parent
c8e18767
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
38 deletions
+60
-38
rt1_amd64_darwin.c
src/runtime/rt1_amd64_darwin.c
+31
-3
rt1_amd64_linux.c
src/runtime/rt1_amd64_linux.c
+29
-4
rt2_amd64.c
src/runtime/rt2_amd64.c
+0
-29
runtime.h
src/runtime/runtime.h
+0
-2
No files found.
src/runtime/rt1_amd64_darwin.c
View file @
ab9f27b2
...
...
@@ -6,9 +6,6 @@
#include "amd64_darwin.h"
#include "signals.h"
extern
void
_rt0_amd64_darwin
();
byte
*
startsym
=
(
byte
*
)
_rt0_amd64_darwin
;
typedef
uint64
__uint64_t
;
/* From /usr/include/mach/i386/_structs.h */
...
...
@@ -133,6 +130,37 @@ typedef struct sigaction {
int32
sa_flags
;
/* see signal options below */
}
sigaction
;
/*
* For trace traps, disassemble instruction to see if it's INTB of known type.
*/
int32
inlinetrap
(
int32
sig
,
byte
*
pc
)
{
extern
void
etext
();
extern
void
_rt0_amd64_darwin
();
if
(
sig
!=
5
)
/* INTB 5 looks like TRAP */
return
0
;
pc
-=
2
;
// mac steps across INTB
if
(
pc
<
(
byte
*
)
_rt0_amd64_darwin
||
pc
+
2
>=
(
byte
*
)
etext
)
return
0
;
if
(
pc
[
0
]
!=
0xcd
)
/* INTB */
return
0
;
switch
(
pc
[
1
])
{
case
5
:
prints
(
"
\n
TRAP: array out of bounds
\n
"
);
break
;
case
6
:
prints
(
"
\n
TRAP: leaving function with returning a value
\n
"
);
break
;
default:
prints
(
"
\n
TRAP: unknown run-time trap "
);
sys
·
printint
(
pc
[
1
]);
prints
(
"
\n
"
);
}
return
1
;
}
void
sighandler
(
int32
sig
,
siginfo
*
info
,
void
*
context
)
{
...
...
src/runtime/rt1_amd64_linux.c
View file @
ab9f27b2
...
...
@@ -6,9 +6,6 @@
#include "amd64_linux.h"
#include "signals.h"
extern
void
_rt0_amd64_linux
();
byte
*
startsym
=
(
byte
*
)
_rt0_amd64_linux
;
/* From /usr/include/asm-x86_64/sigcontext.h */
struct
_fpstate
{
uint16
cwd
;
...
...
@@ -137,6 +134,35 @@ typedef struct sigaction {
void
(
*
sa_restorer
)
(
void
);
/* unused here; needed to return from trap? */
}
sigaction
;
/*
* For trace traps, disassemble instruction to see if it's INTB of known type.
*/
int32
inlinetrap
(
int32
sig
,
byte
*
pc
)
{
extern
void
etext
();
extern
void
_rt0_amd64_linux
();
if
(
sig
!=
5
&&
sig
!=
11
)
/* 5 is for trap, but INTB 5 looks like SEGV */
return
0
;
if
(
pc
<
(
byte
*
)
_rt0_amd64_linux
||
pc
+
2
>=
(
byte
*
)
etext
)
return
0
;
if
(
pc
[
0
]
!=
0xcd
)
/* INTB */
return
0
;
switch
(
pc
[
1
])
{
case
5
:
prints
(
"
\n
TRAP: array out of bounds
\n
"
);
break
;
case
6
:
prints
(
"
\n
TRAP: leaving function with returning a value
\n
"
);
break
;
default:
prints
(
"
\n
TRAP: unknown run-time trap "
);
sys
·
printint
(
pc
[
1
]);
prints
(
"
\n
"
);
}
return
1
;
}
void
sighandler
(
int32
sig
,
siginfo
*
info
,
void
**
context
)
...
...
@@ -167,7 +193,6 @@ sighandler(int32 sig, siginfo* info, void** context)
sys
·
exit
(
2
);
}
static
sigaction
a
;
void
...
...
src/runtime/rt2_amd64.c
View file @
ab9f27b2
...
...
@@ -86,32 +86,3 @@ traceback(uint8 *pc, uint8 *sp, void* r15)
prints
(
", ...)
\n
"
);
}
}
/*
* For trace traps, disassemble instruction to see if it's INTB of known type.
*/
int32
inlinetrap
(
int32
sig
,
byte
*
pc
)
{
extern
void
etext
();
if
(
sig
!=
5
)
/* SIGTRAP */
return
0
;
if
(
pc
-
2
<
startsym
||
pc
>=
(
byte
*
)
etext
)
return
0
;
if
(
pc
[
-
2
]
!=
0xcd
)
/* INTB */
return
0
;
switch
(
pc
[
-
1
])
{
case
5
:
prints
(
"
\n
TRAP: array out of bounds
\n
"
);
break
;
case
6
:
prints
(
"
\n
TRAP: leaving function with returning a value
\n
"
);
break
;
default:
prints
(
"
\n
TRAP: unknown run-time trap "
);
sys
·
printint
(
pc
[
-
1
]);
prints
(
"
\n
"
);
}
return
1
;
}
src/runtime/runtime.h
View file @
ab9f27b2
...
...
@@ -208,7 +208,6 @@ G* allg;
int32
goidgen
;
extern
int32
gomaxprocs
;
extern
int32
panicking
;
extern
byte
*
startsym
;
/*
* common functions and data
...
...
@@ -238,7 +237,6 @@ uint32 cmpstring(string, string);
void
initsig
(
void
);
void
traceback
(
uint8
*
pc
,
uint8
*
sp
,
G
*
gp
);
void
tracebackothers
(
G
*
);
int32
inlinetrap
(
int32
sig
,
byte
*
pc
);
int32
open
(
byte
*
,
int32
,
...);
int32
read
(
int32
,
void
*
,
int32
);
int32
write
(
int32
,
void
*
,
int32
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment