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
3311e1b6
Commit
3311e1b6
authored
Jun 26, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- dump registers in case of signal (linux)
SVN=124702
parent
c137d6b8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
14 deletions
+157
-14
rt1_amd64_darwin.c
src/runtime/rt1_amd64_darwin.c
+5
-2
rt1_amd64_linux.c
src/runtime/rt1_amd64_linux.c
+115
-11
golden.out
test/golden.out
+37
-1
No files found.
src/runtime/rt1_amd64_darwin.c
View file @
3311e1b6
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
typedef
uint64
__uint64_t
;
typedef
uint64
__uint64_t
;
/
/ From /usr/include/mach/i386/_structs.h
/
* From /usr/include/mach/i386/_structs.h */
#define _STRUCT_X86_THREAD_STATE64 struct __darwin_x86_thread_state64
#define _STRUCT_X86_THREAD_STATE64 struct __darwin_x86_thread_state64
_STRUCT_X86_THREAD_STATE64
_STRUCT_X86_THREAD_STATE64
{
{
...
@@ -64,7 +64,7 @@ print_thread_state(_STRUCT_X86_THREAD_STATE64* ss)
...
@@ -64,7 +64,7 @@ print_thread_state(_STRUCT_X86_THREAD_STATE64* ss)
}
}
/* Code generated via: g++ -m64
signals
.cc && a.out */
/* Code generated via: g++ -m64
gen_signals_support
.cc && a.out */
static
void
*
adr_at
(
void
*
ptr
,
int32
offs
)
{
static
void
*
adr_at
(
void
*
ptr
,
int32
offs
)
{
return
(
void
*
)((
uint8
*
)
ptr
+
offs
);
return
(
void
*
)((
uint8
*
)
ptr
+
offs
);
...
@@ -119,6 +119,7 @@ typedef struct siginfo {
...
@@ -119,6 +119,7 @@ typedef struct siginfo {
/* more stuff here */
/* more stuff here */
}
siginfo
;
}
siginfo
;
typedef
struct
sigaction
{
typedef
struct
sigaction
{
union
{
union
{
void
(
*
sa_handler
)(
int32
);
void
(
*
sa_handler
)(
int32
);
...
@@ -129,6 +130,7 @@ typedef struct sigaction {
...
@@ -129,6 +130,7 @@ typedef struct sigaction {
int32
sa_flags
;
/* see signal options below */
int32
sa_flags
;
/* see signal options below */
}
sigaction
;
}
sigaction
;
void
void
sighandler
(
int32
sig
,
siginfo
*
info
,
void
*
context
)
sighandler
(
int32
sig
,
siginfo
*
info
,
void
*
context
)
{
{
...
@@ -152,6 +154,7 @@ sighandler(int32 sig, siginfo *info, void *context)
...
@@ -152,6 +154,7 @@ sighandler(int32 sig, siginfo *info, void *context)
sys
·
exit
(
2
);
sys
·
exit
(
2
);
}
}
sigaction
a
;
sigaction
a
;
extern
void
sigtramp
(
void
);
extern
void
sigtramp
(
void
);
...
...
src/runtime/rt1_amd64_linux.c
View file @
3311e1b6
...
@@ -5,6 +5,101 @@
...
@@ -5,6 +5,101 @@
#include "runtime.h"
#include "runtime.h"
#include "signals.h"
#include "signals.h"
/* From /usr/include/asm-x86_64/sigcontext.h */
struct
_fpstate
{
uint16
cwd
;
uint16
swd
;
uint16
twd
;
/* Note this is not the same as the 32bit/x87/FSAVE twd */
uint16
fop
;
uint64
rip
;
uint32
rdp
;
uint32
mxcsr
;
uint32
mxcsr_mask
;
uint32
st_space
[
32
];
/* 8*16 bytes for each FP-reg */
uint32
xmm_space
[
64
];
/* 16*16 bytes for each XMM-reg */
uint32
reserved2
[
24
];
};
struct
sigcontext
{
uint64
r8
;
uint64
r9
;
uint64
r10
;
uint64
r11
;
uint64
r12
;
uint64
r13
;
uint64
r14
;
uint64
r15
;
uint64
rdi
;
uint64
rsi
;
uint64
rbp
;
uint64
rbx
;
uint64
rdx
;
uint64
rax
;
uint64
rcx
;
uint64
rsp
;
uint64
rip
;
uint64
eflags
;
/* RFLAGS */
uint16
cs
;
uint16
gs
;
uint16
fs
;
uint16
__pad0
;
uint64
err
;
uint64
trapno
;
uint64
oldmask
;
uint64
cr2
;
struct
_fpstate
*
fpstate
;
/* zero when no FPU context */
uint64
reserved1
[
8
];
};
/* From /usr/include/asm-x86_64/signal.h */
typedef
struct
sigaltstack
{
void
/*__user*/
*
ss_sp
;
int32
ss_flags
;
uint64
ss_size
;
}
stack_t
;
typedef
uint64
sigset_t
;
/* From /usr/include/asm-x86_64/ucontext.h */
struct
ucontext
{
uint64
uc_flags
;
struct
ucontext
*
uc_link
;
stack_t
uc_stack
;
struct
sigcontext
uc_mcontext
;
sigset_t
uc_sigmask
;
/* mask last for extensibility */
};
void
print_sigcontext
(
struct
sigcontext
*
sc
)
{
prints
(
"
\n
rax 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rax
);
prints
(
"
\n
rbx 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rbx
);
prints
(
"
\n
rcx 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rcx
);
prints
(
"
\n
rdx 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rdx
);
prints
(
"
\n
rdi 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rdi
);
prints
(
"
\n
rsi 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rsi
);
prints
(
"
\n
rbp 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rbp
);
prints
(
"
\n
rsp 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rsp
);
prints
(
"
\n
r8 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r8
);
prints
(
"
\n
r9 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r9
);
prints
(
"
\n
r10 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r10
);
prints
(
"
\n
r11 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r11
);
prints
(
"
\n
r12 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r12
);
prints
(
"
\n
r13 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r13
);
prints
(
"
\n
r14 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r14
);
prints
(
"
\n
r15 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
r15
);
prints
(
"
\n
rip 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rip
);
prints
(
"
\n
rflags 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
eflags
);
prints
(
"
\n
cs 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
cs
);
prints
(
"
\n
fs 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
fs
);
prints
(
"
\n
gs 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
gs
);
prints
(
"
\n
"
);
}
/*
/*
* This assembler routine takes the args from registers, puts them on the stack,
* This assembler routine takes the args from registers, puts them on the stack,
* and calls sighandler().
* and calls sighandler().
...
@@ -15,6 +110,7 @@ extern void sigtramp();
...
@@ -15,6 +110,7 @@ extern void sigtramp();
* Rudimentary reverse-engineered definition of signal interface.
* Rudimentary reverse-engineered definition of signal interface.
* You'd think it would be documented.
* You'd think it would be documented.
*/
*/
/* From /usr/include/bits/siginfo.h */
typedef
struct
siginfo
{
typedef
struct
siginfo
{
int32
si_signo
;
/* signal number */
int32
si_signo
;
/* signal number */
int32
si_errno
;
/* errno association */
int32
si_errno
;
/* errno association */
...
@@ -24,6 +120,9 @@ typedef struct siginfo {
...
@@ -24,6 +120,9 @@ typedef struct siginfo {
/* more stuff here */
/* more stuff here */
}
siginfo
;
}
siginfo
;
/* From /usr/include/bits/sigaction.h */
/* (gri) Is this correct? See e.g. /usr/include/asm-x86_64/signal.h */
typedef
struct
sigaction
{
typedef
struct
sigaction
{
union
{
union
{
void
(
*
sa_handler
)(
int32
);
void
(
*
sa_handler
)(
int32
);
...
@@ -34,8 +133,10 @@ typedef struct sigaction {
...
@@ -34,8 +133,10 @@ typedef struct sigaction {
void
(
*
sa_restorer
)
(
void
);
/* unused here; needed to return from trap? */
void
(
*
sa_restorer
)
(
void
);
/* unused here; needed to return from trap? */
}
sigaction
;
}
sigaction
;
void
void
sighandler
(
int32
sig
,
siginfo
*
info
,
void
**
context
)
{
sighandler
(
int32
sig
,
siginfo
*
info
,
void
**
context
)
{
int32
i
;
int32
i
;
if
(
sig
<
0
||
sig
>=
NSIG
){
if
(
sig
<
0
||
sig
>=
NSIG
){
...
@@ -44,18 +145,21 @@ sighandler(int32 sig, siginfo* info, void** context) {
...
@@ -44,18 +145,21 @@ sighandler(int32 sig, siginfo* info, void** context) {
}
else
{
}
else
{
prints
(
sigtab
[
sig
].
name
);
prints
(
sigtab
[
sig
].
name
);
}
}
prints
(
"
\n
Faulting address: 0x"
);
sys
·
printpointer
(
info
->
si_addr
);
struct
sigcontext
*
sc
=
&
(((
struct
ucontext
*
)
context
)
->
uc_mcontext
);
prints
(
"
\n
PC: 0x"
);
sys
·
printpointer
(
context
[
21
]);
prints
(
"
\n
Faulting address: 0x"
);
sys
·
printpointer
(
info
->
si_addr
);
prints
(
"
\n
SP: 0x"
);
prints
(
"
\n
pc: 0x"
);
sys
·
printpointer
((
void
*
)
sc
->
rip
);
sys
·
printpointer
(
context
[
20
]);
prints
(
"
\n\n
"
);
prints
(
"
\n
"
);
traceback
(
context
[
21
],
context
[
20
]);
/* empirically discovered locations */
traceback
((
void
*
)
sc
->
rip
,
(
void
*
)
sc
->
rsp
);
print_sigcontext
(
sc
);
sys
·
breakpoint
();
sys
·
breakpoint
();
sys
·
exit
(
2
);
sys
·
exit
(
2
);
}
}
sigaction
a
;
sigaction
a
;
void
void
...
@@ -63,11 +167,11 @@ initsig(void)
...
@@ -63,11 +167,11 @@ initsig(void)
{
{
int32
i
;
int32
i
;
a
.
u
.
sa_sigaction
=
(
void
*
)
sigtramp
;
a
.
u
.
sa_sigaction
=
(
void
*
)
sigtramp
;
a
.
sa_flags
|
=
0x04
;
/* SA_SIGINFO */
a
.
sa_flags
=
0x04
;
/* SA_SIGINFO */
for
(
i
=
0
;
i
<
sizeof
(
a
.
sa_mask
);
i
++
)
for
(
i
=
0
;
i
<
sizeof
(
a
.
sa_mask
);
i
++
)
a
.
sa_mask
[
i
]
=
0xFF
;
a
.
sa_mask
[
i
]
=
0xFF
;
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
for
(
i
=
0
;
i
<
NSIG
;
i
++
)
if
(
sigtab
[
i
].
catch
){
if
(
sigtab
[
i
].
catch
){
sys
·
rt_sigaction
(
i
,
&
a
,
(
void
*
)
0
,
8
);
sys
·
rt_sigaction
(
i
,
&
a
,
(
void
*
)
0
,
8
);
}
}
...
...
test/golden.out
View file @
3311e1b6
=========== ./args.go
=========== ./args.go
argc
panic on line 171 PC=0x150c
0x150c?zi
mainM-BM-7main(0, 0, 0, ...)
mainM-BM-7main(0x0, 0x0, 0x3, ...)
0x12e5?zi
=========== ./char_lit.go
=========== ./char_lit.go
...
@@ -170,7 +176,7 @@ bugs/bug025.go:7: fatal error: dumpexportvar: oname nil: Foo
...
@@ -170,7 +176,7 @@ bugs/bug025.go:7: fatal error: dumpexportvar: oname nil: Foo
BUG: known to fail incorrectly or at least with a bad message
BUG: known to fail incorrectly or at least with a bad message
=========== bugs/bug026.go
=========== bugs/bug026.go
traceback: main
·
sigs_I: not defined
traceback: main
M-BM-7
sigs_I: not defined
BUG: known to fail incorrectly
BUG: known to fail incorrectly
=========== bugs/bug027.go
=========== bugs/bug027.go
...
@@ -262,6 +268,36 @@ bugs/bug051.go:10: fatal error: too many errors
...
@@ -262,6 +268,36 @@ bugs/bug051.go:10: fatal error: too many errors
BUG: infinite loop in error reporting
BUG: infinite loop in error reporting
=========== bugs/bug052.go
=========== bugs/bug052.go
SIGSEGV: segmentation violation
Faulting address: 0x1
pc: 0x152c
0x152c?zi
mainM-BM-7main(0, 0, 0, ...)
mainM-BM-7main(0x0, 0x0, 0x1, ...)
0x12e5?zi
rax 0x1
rbx 0x7
rcx 0x7fffffffe8f8
rdx 0x3
rdi 0x7fffffffe920
rsi 0x5b00
rbp 0x7fffffffe938
rsp 0x7fffffffe8f0
r8 0x0
r9 0x0
r10 0x8
r11 0x202
r12 0x0
r13 0x0
r14 0x0
r15 0x0
rip 0x152c
rflags 0x10202
cs 0x33
fs 0x0
gs 0x0
BUG: incorrect code for division
BUG: incorrect code for division
=========== bugs/bug053.go
=========== bugs/bug053.go
...
...
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