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
bbb908fe
Commit
bbb908fe
authored
Oct 03, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow prof to launch the process
R=rsc DELTA=32 (30 added, 0 deleted, 2 changed) OCL=16440 CL=16445
parent
347cf67a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
src/cmd/prof/main.c
src/cmd/prof/main.c
+32
-2
No files found.
src/cmd/prof/main.c
View file @
bbb908fe
...
...
@@ -33,7 +33,7 @@ int stacks; // print stack traces
void
Usage
(
void
)
{
fprint
(
2
,
"Usage: prof -p pid [-t total_secs] [-d delta_msec] [6.out]
\n
"
);
fprint
(
2
,
"Usage: prof -p pid [-t total_secs] [-d delta_msec] [6.out
args ...
]
\n
"
);
fprint
(
2
,
"
\t
formats (default -h):
\n
"
);
fprint
(
2
,
"
\t\t
-h: histograms
\n
"
);
fprint
(
2
,
"
\t\t
-f: dynamic functions
\n
"
);
...
...
@@ -283,6 +283,33 @@ dumphistogram()
}
}
int
startprocess
(
char
**
argv
)
{
int
pid
;
if
((
pid
=
fork
())
==
0
)
{
pid
=
getpid
();
if
(
ctlproc
(
pid
,
"hang"
)
<
0
){
fprint
(
2
,
"prof: child process could not hang
\n
"
);
exits
(
0
);
}
execv
(
argv
[
0
],
argv
);
fprint
(
2
,
"prof: could not exec %s: %r
\n
"
,
argv
[
0
]);
exits
(
0
);
}
if
(
pid
==
-
1
)
{
fprint
(
2
,
"prof: could not fork
\n
"
);
exit
(
1
);
}
if
(
ctlproc
(
pid
,
"attached"
)
<
0
||
ctlproc
(
pid
,
"waitstop"
)
<
0
)
{
fprint
(
2
,
"prof: could not attach to child process: %r
\n
"
);
exit
(
1
);
}
return
pid
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -304,6 +331,7 @@ main(int argc, char *argv[])
break
;
case
'h'
:
histograms
=
1
;
break
;
case
'l'
:
linenums
=
1
;
break
;
...
...
@@ -314,7 +342,7 @@ main(int argc, char *argv[])
stacks
=
1
;
break
;
}
ARGEND
if
(
pid
<=
0
)
if
(
pid
<=
0
&&
argc
==
0
)
Usage
();
if
(
functions
+
linenums
+
registers
+
stacks
==
0
)
histograms
=
1
;
...
...
@@ -329,6 +357,8 @@ main(int argc, char *argv[])
fprint
(
2
,
"prof: can't open %s: %r
\n
"
,
file
);
exit
(
1
);
}
if
(
pid
<=
0
)
pid
=
startprocess
(
argv
);
map
=
attachproc
(
pid
,
&
fhdr
);
if
(
map
==
nil
)
{
fprint
(
2
,
"prof: can't attach to %d: %r
\n
"
,
pid
);
...
...
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