builtin-mem.c (a30450e6a43b7f4b4df9bb3eb7dfaebd96f09682) builtin-mem.c (70f4b20d07df94916230b6783097358703c90113)
1// SPDX-License-Identifier: GPL-2.0
2#include <inttypes.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <unistd.h>
6#include "builtin.h"
7
8#include <subcmd/parse-options.h>

--- 58 unchanged lines hidden (view full) ---

67 "perf mem record [<options>] -- <command> [<options>]",
68 NULL
69};
70
71static const char * const *record_mem_usage = __usage;
72
73static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
74{
1// SPDX-License-Identifier: GPL-2.0
2#include <inttypes.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <unistd.h>
6#include "builtin.h"
7
8#include <subcmd/parse-options.h>

--- 58 unchanged lines hidden (view full) ---

67 "perf mem record [<options>] -- <command> [<options>]",
68 NULL
69};
70
71static const char * const *record_mem_usage = __usage;
72
73static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
74{
75 int rec_argc, i = 0, j, tmp_nr = 0;
75 int rec_argc, i = 0, j;
76 int start, end;
77 const char **rec_argv;
76 int start, end;
77 const char **rec_argv;
78 char **rec_tmp;
79 int ret;
80 bool all_user = false, all_kernel = false;
81 struct perf_mem_event *e;
82 struct perf_pmu *pmu;
83 struct option options[] = {
84 OPT_CALLBACK('e', "event", &mem, "event",
85 "event selector. use 'perf mem record -e list' to list available events",
86 parse_record_events),

--- 24 unchanged lines hidden (view full) ---

111
112 if (mem->cpu_list)
113 rec_argc += 2;
114
115 rec_argv = calloc(rec_argc + 1, sizeof(char *));
116 if (!rec_argv)
117 return -1;
118
78 int ret;
79 bool all_user = false, all_kernel = false;
80 struct perf_mem_event *e;
81 struct perf_pmu *pmu;
82 struct option options[] = {
83 OPT_CALLBACK('e', "event", &mem, "event",
84 "event selector. use 'perf mem record -e list' to list available events",
85 parse_record_events),

--- 24 unchanged lines hidden (view full) ---

110
111 if (mem->cpu_list)
112 rec_argc += 2;
113
114 rec_argv = calloc(rec_argc + 1, sizeof(char *));
115 if (!rec_argv)
116 return -1;
117
119 /*
120 * Save the allocated event name strings.
121 */
122 rec_tmp = calloc(rec_argc + 1, sizeof(char *));
123 if (!rec_tmp) {
124 free(rec_argv);
125 return -1;
126 }
127
128 rec_argv[i++] = "record";
129
130 e = perf_pmu__mem_events_ptr(pmu, PERF_MEM_EVENTS__LOAD_STORE);
131
132 /*
133 * The load and store operations are required, use the event
134 * PERF_MEM_EVENTS__LOAD_STORE if it is supported.
135 */

--- 22 unchanged lines hidden (view full) ---

158
159 if (mem->phys_addr)
160 rec_argv[i++] = "--phys-data";
161
162 if (mem->data_page_size)
163 rec_argv[i++] = "--data-page-size";
164
165 start = i;
118 rec_argv[i++] = "record";
119
120 e = perf_pmu__mem_events_ptr(pmu, PERF_MEM_EVENTS__LOAD_STORE);
121
122 /*
123 * The load and store operations are required, use the event
124 * PERF_MEM_EVENTS__LOAD_STORE if it is supported.
125 */

--- 22 unchanged lines hidden (view full) ---

148
149 if (mem->phys_addr)
150 rec_argv[i++] = "--phys-data";
151
152 if (mem->data_page_size)
153 rec_argv[i++] = "--data-page-size";
154
155 start = i;
166 ret = perf_mem_events__record_args(rec_argv, &i, rec_tmp, &tmp_nr);
156 ret = perf_mem_events__record_args(rec_argv, &i);
167 if (ret)
168 goto out;
169 end = i;
170
171 if (all_user)
172 rec_argv[i++] = "--all-user";
173
174 if (all_kernel)

--- 13 unchanged lines hidden (view full) ---

188 for (j = start; j < end; j++)
189 pr_debug("%s ", rec_argv[j]);
190
191 pr_debug("\n");
192 }
193
194 ret = cmd_record(i, rec_argv);
195out:
157 if (ret)
158 goto out;
159 end = i;
160
161 if (all_user)
162 rec_argv[i++] = "--all-user";
163
164 if (all_kernel)

--- 13 unchanged lines hidden (view full) ---

178 for (j = start; j < end; j++)
179 pr_debug("%s ", rec_argv[j]);
180
181 pr_debug("\n");
182 }
183
184 ret = cmd_record(i, rec_argv);
185out:
196 for (i = 0; i < tmp_nr; i++)
197 free(rec_tmp[i]);
198
199 free(rec_tmp);
200 free(rec_argv);
201 return ret;
202}
203
204static int
205dump_raw_samples(struct perf_tool *tool,
206 union perf_event *event,
207 struct perf_sample *sample,

--- 328 unchanged lines hidden ---
186 free(rec_argv);
187 return ret;
188}
189
190static int
191dump_raw_samples(struct perf_tool *tool,
192 union perf_event *event,
193 struct perf_sample *sample,

--- 328 unchanged lines hidden ---