Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
8f72a87b
Commit
8f72a87b
authored
Jun 22, 2011
by
Anthony Martin
Committed by
Russ Cox
Jun 22, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libmach: fix tracing on linux (for cov)
R=rsc, dave CC=golang-dev
https://golang.org/cl/4629064
parent
c475c307
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
src/libmach/linux.c
src/libmach/linux.c
+17
-6
No files found.
src/libmach/linux.c
View file @
8f72a87b
...
@@ -238,8 +238,7 @@ fixup:
...
@@ -238,8 +238,7 @@ fixup:
PTRACE_O_TRACEVFORK
|
PTRACE_O_TRACEVFORK
|
PTRACE_O_TRACECLONE
|
PTRACE_O_TRACECLONE
|
PTRACE_O_TRACEEXEC
|
PTRACE_O_TRACEEXEC
|
PTRACE_O_TRACEVFORKDONE
|
PTRACE_O_TRACEVFORKDONE
;
PTRACE_O_TRACEEXIT
;
if
(
ptrace
(
PTRACE_SETOPTIONS
,
tid
,
0
,
(
void
*
)
flags
)
<
0
)
{
if
(
ptrace
(
PTRACE_SETOPTIONS
,
tid
,
0
,
(
void
*
)
flags
)
<
0
)
{
fprint
(
2
,
"ptrace PTRACE_SETOPTIONS %d: %r
\n
"
,
tid
);
fprint
(
2
,
"ptrace PTRACE_SETOPTIONS %d: %r
\n
"
,
tid
);
return
nil
;
return
nil
;
...
@@ -358,6 +357,12 @@ wait1(int nohang)
...
@@ -358,6 +357,12 @@ wait1(int nohang)
break
;
break
;
case
PTRACE_EVENT_EXIT
:
case
PTRACE_EVENT_EXIT
:
// We won't see this unless we set PTRACE_O_TRACEEXIT.
// The debuggers assume that a read or write on a Map
// will fail for a thread that has exited. This event
// breaks that assumption. It's not a big deal: we
// only lose the ability to see the register state at
// the time of exit.
if
(
trace
)
if
(
trace
)
fprint
(
2
,
"tid %d: exiting %#x
\n
"
,
tid
,
status
);
fprint
(
2
,
"tid %d: exiting %#x
\n
"
,
tid
,
status
);
t
->
state
=
Exiting
;
t
->
state
=
Exiting
;
...
@@ -755,13 +760,19 @@ static int
...
@@ -755,13 +760,19 @@ static int
ptracerw
(
int
type
,
int
xtype
,
int
isr
,
int
pid
,
uvlong
addr
,
void
*
v
,
uint
n
)
ptracerw
(
int
type
,
int
xtype
,
int
isr
,
int
pid
,
uvlong
addr
,
void
*
v
,
uint
n
)
{
{
int
i
;
int
i
;
uintptr
u
;
uintptr
u
,
a
;
uchar
buf
[
sizeof
(
uintptr
)];
uchar
buf
[
sizeof
(
uintptr
)];
for
(
i
=
0
;
i
<
n
;
i
+=
sizeof
(
uintptr
)){
for
(
i
=
0
;
i
<
n
;
i
+=
sizeof
(
uintptr
)){
// Tread carefully here. On recent versions of glibc,
// ptrace is a variadic function which means the third
// argument will be pushed onto the stack as a uvlong.
// This is fine on amd64 but will not work for 386.
// We must convert addr to a uintptr.
a
=
addr
+
i
;
if
(
isr
){
if
(
isr
){
errno
=
0
;
errno
=
0
;
u
=
ptrace
(
type
,
pid
,
a
ddr
+
i
,
0
);
u
=
ptrace
(
type
,
pid
,
a
,
0
);
if
(
errno
)
if
(
errno
)
goto
ptraceerr
;
goto
ptraceerr
;
if
(
n
-
i
>=
sizeof
(
uintptr
))
if
(
n
-
i
>=
sizeof
(
uintptr
))
...
@@ -775,14 +786,14 @@ ptracerw(int type, int xtype, int isr, int pid, uvlong addr, void *v, uint n)
...
@@ -775,14 +786,14 @@ ptracerw(int type, int xtype, int isr, int pid, uvlong addr, void *v, uint n)
u
=
*
(
uintptr
*
)((
char
*
)
v
+
i
);
u
=
*
(
uintptr
*
)((
char
*
)
v
+
i
);
else
{
else
{
errno
=
0
;
errno
=
0
;
u
=
ptrace
(
xtype
,
pid
,
a
ddr
+
i
,
0
);
u
=
ptrace
(
xtype
,
pid
,
a
,
0
);
if
(
errno
)
if
(
errno
)
return
-
1
;
return
-
1
;
memmove
(
buf
,
&
u
,
sizeof
u
);
memmove
(
buf
,
&
u
,
sizeof
u
);
memmove
(
buf
,
(
char
*
)
v
+
i
,
n
-
i
);
memmove
(
buf
,
(
char
*
)
v
+
i
,
n
-
i
);
memmove
(
&
u
,
buf
,
sizeof
u
);
memmove
(
&
u
,
buf
,
sizeof
u
);
}
}
if
(
ptrace
(
type
,
pid
,
a
ddr
+
i
,
u
)
<
0
)
if
(
ptrace
(
type
,
pid
,
a
,
u
)
<
0
)
goto
ptraceerr
;
goto
ptraceerr
;
}
}
}
}
...
...
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