diff options
Diffstat (limited to 'meta/recipes-kernel/oprofile/oprofile/opstart.patch')
-rw-r--r-- | meta/recipes-kernel/oprofile/oprofile/opstart.patch | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/meta/recipes-kernel/oprofile/oprofile/opstart.patch b/meta/recipes-kernel/oprofile/oprofile/opstart.patch new file mode 100644 index 0000000000..d61c30095f --- /dev/null +++ b/meta/recipes-kernel/oprofile/oprofile/opstart.patch | |||
@@ -0,0 +1,235 @@ | |||
1 | Index: oprofile/utils/Makefile.am | ||
2 | =================================================================== | ||
3 | --- oprofile.orig/utils/Makefile.am 2005-03-31 18:20:41.000000000 +0100 | ||
4 | +++ oprofile/utils/Makefile.am 2008-07-02 15:14:07.000000000 +0100 | ||
5 | @@ -3,8 +3,15 @@ | ||
6 | |||
7 | LIBS=@POPT_LIBS@ @LIBERTY_LIBS@ | ||
8 | |||
9 | -bin_PROGRAMS = ophelp | ||
10 | +bin_PROGRAMS = ophelp opstart | ||
11 | dist_bin_SCRIPTS = opcontrol | ||
12 | |||
13 | ophelp_SOURCES = ophelp.c | ||
14 | ophelp_LDADD = ../libop/libop.a ../libutil/libutil.a | ||
15 | + | ||
16 | +opstart_SOURCES = opstart.c | ||
17 | + | ||
18 | +install-exec-local: | ||
19 | + cd $(DESTDIR)/$(bindir) && \ | ||
20 | + rm -f opstop && \ | ||
21 | + $(LN_S) opstart opstop | ||
22 | Index: oprofile/utils/opstart.c | ||
23 | =================================================================== | ||
24 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
25 | +++ oprofile/utils/opstart.c 2008-07-02 15:14:07.000000000 +0100 | ||
26 | @@ -0,0 +1,110 @@ | ||
27 | +/** | ||
28 | + * @file opstart.c | ||
29 | + * Start/Stop oprofile | ||
30 | + * | ||
31 | + * @remark Copyright 2007 Openedhand Ltd. | ||
32 | + * @remark Read the file COPYING | ||
33 | + * | ||
34 | + * @author Richard Purdie | ||
35 | + */ | ||
36 | + | ||
37 | +#include <signal.h> | ||
38 | +#include <stdio.h> | ||
39 | +#include <stdlib.h> | ||
40 | +#include <string.h> | ||
41 | +#include <unistd.h> | ||
42 | +#include <sys/types.h> | ||
43 | +#include <sys/stat.h> | ||
44 | + | ||
45 | +int main(const int argc, const char* argv[]) | ||
46 | +{ | ||
47 | + const char *enable = "/dev/oprofile/enable"; | ||
48 | + const char *lockfile; | ||
49 | + unsigned long dpid; | ||
50 | + struct stat sbuf; | ||
51 | + FILE *lfile, *efile; | ||
52 | + int sig, enb, err; | ||
53 | + | ||
54 | + if (argc >= 2) { | ||
55 | + printf("Error: Invalid options.\n"); | ||
56 | + return 1; | ||
57 | + } | ||
58 | + | ||
59 | + lockfile = getenv("LOCK_FILE"); | ||
60 | + if (!lockfile) | ||
61 | + lockfile = "/var/lib/oprofile/lock"; | ||
62 | + | ||
63 | + /* Add SESSION_DIR support? */ | ||
64 | + | ||
65 | + if (geteuid()) { | ||
66 | + printf("Error: This program must be run as root.\n"); | ||
67 | + return 1; | ||
68 | + } | ||
69 | + | ||
70 | + if (stat(enable, &sbuf)) { | ||
71 | + printf("Error: Could not find /dev/oprofile/enable, the" | ||
72 | + " kernel module probably isn't loaded.\n"); | ||
73 | + printf("This binary only works with 2.6 kernels and oprofile" | ||
74 | + " must have been initialised with 'opcontrol --start-daemon'.\n"); | ||
75 | + return 1; | ||
76 | + } | ||
77 | + | ||
78 | + if (stat(lockfile, &sbuf)) { | ||
79 | + printf("Error: Could not find lockfile %s.\n", lockfile); | ||
80 | + printf("The oprofile daemon must be running (oprofile must" | ||
81 | + " have been initialised with 'opcontrol --start-daemon').\n"); | ||
82 | + return 1; | ||
83 | + } | ||
84 | + | ||
85 | + lfile = fopen(lockfile, "r"); | ||
86 | + if (!lfile) { | ||
87 | + printf("Error opening lockfile %s.\n", lockfile); | ||
88 | + return 1; | ||
89 | + } | ||
90 | + | ||
91 | + err = fscanf(lfile, "%lud", (unsigned long *) &dpid); | ||
92 | + if (err != 1) { | ||
93 | + printf("Error reading pid from lockfile %s.\n", lockfile); | ||
94 | + return 1; | ||
95 | + } | ||
96 | + fclose(lfile); | ||
97 | + | ||
98 | + efile = fopen(enable, "r"); | ||
99 | + if (!efile) { | ||
100 | + printf("Error opening %s.\n", enable); | ||
101 | + return 1; | ||
102 | + } | ||
103 | + | ||
104 | + if (strstr(argv[0], "opstart")) { | ||
105 | + printf("Starting Profiler\n"); | ||
106 | + sig = SIGUSR1; | ||
107 | + enb = 1; | ||
108 | + } else if (strstr(argv[0], "opstop")) { | ||
109 | + printf("Stopping Oprofile.\n"); | ||
110 | + printf("You need to run 'opcontrol --dump' when the session" | ||
111 | + " is finished.\n"); | ||
112 | + sig = SIGUSR2; | ||
113 | + enb = 0; | ||
114 | + } else { | ||
115 | + printf("Error: Please call as 'opstart' or 'opstop'\n"); | ||
116 | + return 1; | ||
117 | + } | ||
118 | + | ||
119 | + err = kill(dpid, 0); | ||
120 | + if (err) { | ||
121 | + printf("Error sending signal to oprofiled. Stale lockfile" | ||
122 | + " (%s) ?\n", lockfile); | ||
123 | + return 1; | ||
124 | + } | ||
125 | + | ||
126 | + fprintf(efile, "%d\n", enb); | ||
127 | + err = kill(dpid, sig); | ||
128 | + if (err) { | ||
129 | + printf("Error sending signal to oprofiled. Stale lockfile" | ||
130 | + " (%s) ?\n", lockfile); | ||
131 | + return 1; | ||
132 | + } | ||
133 | + | ||
134 | + return 0; | ||
135 | +} | ||
136 | + | ||
137 | Index: oprofile/configure.in | ||
138 | =================================================================== | ||
139 | --- oprofile.orig/configure.in 2008-07-02 15:13:58.000000000 +0100 | ||
140 | +++ oprofile/configure.in 2008-07-02 15:17:37.000000000 +0100 | ||
141 | @@ -16,6 +16,7 @@ | ||
142 | AM_CONFIG_HEADER(config.h) | ||
143 | |||
144 | AC_PROG_RANLIB | ||
145 | +AC_PROG_LN_S | ||
146 | AC_PROG_LIBTOOL | ||
147 | |||
148 | dnl for the man page | ||
149 | @@ -241,6 +242,8 @@ | ||
150 | doc/xsl/catalog-1.xml \ | ||
151 | doc/oprofile.1 \ | ||
152 | doc/opcontrol.1 \ | ||
153 | + doc/opstart.1 \ | ||
154 | + doc/opstop.1 \ | ||
155 | doc/ophelp.1 \ | ||
156 | doc/opreport.1 \ | ||
157 | doc/opannotate.1 \ | ||
158 | Index: oprofile/doc/Makefile.am | ||
159 | =================================================================== | ||
160 | --- oprofile.orig/doc/Makefile.am 2008-07-02 15:13:59.000000000 +0100 | ||
161 | +++ oprofile/doc/Makefile.am 2008-07-02 15:14:07.000000000 +0100 | ||
162 | @@ -11,6 +11,8 @@ | ||
163 | man_MANS = \ | ||
164 | oprofile.1 \ | ||
165 | opcontrol.1 \ | ||
166 | + opstart.1 \ | ||
167 | + opstop.1 \ | ||
168 | opreport.1 \ | ||
169 | opannotate.1 \ | ||
170 | opgprof.1 \ | ||
171 | Index: oprofile/doc/opstart.1.in | ||
172 | =================================================================== | ||
173 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
174 | +++ oprofile/doc/opstart.1.in 2008-07-02 15:14:07.000000000 +0100 | ||
175 | @@ -0,0 +1,27 @@ | ||
176 | +.TH OPSTART 1 "@DATE@" "oprofile @VERSION@" | ||
177 | +.UC 4 | ||
178 | +.SH NAME | ||
179 | +opstart \- start OProfile profiling | ||
180 | +.SH SYNOPSIS | ||
181 | +.br | ||
182 | +.B opstart | ||
183 | +.SH DESCRIPTION | ||
184 | +.B opstart | ||
185 | +is a simple optimised command to start profiling with 2.6 Linux kernels. | ||
186 | +OProfile should have already been initialised by calling "opcontrol --start-daemon". | ||
187 | + | ||
188 | +.SH ENVIRONMENT | ||
189 | +No special environment variables are recognised by opstart. | ||
190 | + | ||
191 | +.SH FILES | ||
192 | +.TP | ||
193 | +.I /var/lib/oprofile/samples/ | ||
194 | +The location of the generated sample files. | ||
195 | + | ||
196 | +.SH VERSION | ||
197 | +.TP | ||
198 | +This man page is current for @PACKAGE@-@VERSION@. | ||
199 | + | ||
200 | +.SH SEE ALSO | ||
201 | +.BR @OP_DOCDIR@, | ||
202 | +.BR oprofile(1) | ||
203 | Index: oprofile/doc/opstop.1.in | ||
204 | =================================================================== | ||
205 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
206 | +++ oprofile/doc/opstop.1.in 2008-07-02 15:14:07.000000000 +0100 | ||
207 | @@ -0,0 +1,28 @@ | ||
208 | +.TH OPSTOP 1 "@DATE@" "oprofile @VERSION@" | ||
209 | +.UC 4 | ||
210 | +.SH NAME | ||
211 | +opstop \- stop OProfile profiling | ||
212 | +.SH SYNOPSIS | ||
213 | +.br | ||
214 | +.B opstop | ||
215 | +.SH DESCRIPTION | ||
216 | +.B opstop | ||
217 | +is a simple optimsed command to stop profiling with 2.6 Linux kernels. | ||
218 | +You need to run "opcontrol --dump" before being able to view a profile | ||
219 | +with opreport. | ||
220 | + | ||
221 | +.SH ENVIRONMENT | ||
222 | +No special environment variables are recognised by opstop. | ||
223 | + | ||
224 | +.SH FILES | ||
225 | +.TP | ||
226 | +.I /var/lib/oprofile/samples/ | ||
227 | +The location of the generated sample files. | ||
228 | + | ||
229 | +.SH VERSION | ||
230 | +.TP | ||
231 | +This man page is current for @PACKAGE@-@VERSION@. | ||
232 | + | ||
233 | +.SH SEE ALSO | ||
234 | +.BR @OP_DOCDIR@, | ||
235 | +.BR oprofile(1) | ||