diff options
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index b86744f29eef..92db3f156b63 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -303,13 +303,26 @@ void set_term_quiet_input(struct termios *old) | |||
303 | tcsetattr(0, TCSANOW, &tc); | 303 | tcsetattr(0, TCSANOW, &tc); |
304 | } | 304 | } |
305 | 305 | ||
306 | static void set_tracing_events_path(const char *mountpoint) | 306 | static void set_tracing_events_path(const char *tracing, const char *mountpoint) |
307 | { | 307 | { |
308 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s", | 308 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", |
309 | mountpoint, "tracing/events"); | 309 | mountpoint, tracing, "events"); |
310 | } | 310 | } |
311 | 311 | ||
312 | const char *perf_debugfs_mount(const char *mountpoint) | 312 | static const char *__perf_tracefs_mount(const char *mountpoint) |
313 | { | ||
314 | const char *mnt; | ||
315 | |||
316 | mnt = tracefs_mount(mountpoint); | ||
317 | if (!mnt) | ||
318 | return NULL; | ||
319 | |||
320 | set_tracing_events_path("", mnt); | ||
321 | |||
322 | return mnt; | ||
323 | } | ||
324 | |||
325 | static const char *__perf_debugfs_mount(const char *mountpoint) | ||
313 | { | 326 | { |
314 | const char *mnt; | 327 | const char *mnt; |
315 | 328 | ||
@@ -317,7 +330,20 @@ const char *perf_debugfs_mount(const char *mountpoint) | |||
317 | if (!mnt) | 330 | if (!mnt) |
318 | return NULL; | 331 | return NULL; |
319 | 332 | ||
320 | set_tracing_events_path(mnt); | 333 | set_tracing_events_path("tracing/", mnt); |
334 | |||
335 | return mnt; | ||
336 | } | ||
337 | |||
338 | const char *perf_debugfs_mount(const char *mountpoint) | ||
339 | { | ||
340 | const char *mnt; | ||
341 | |||
342 | mnt = __perf_tracefs_mount(mountpoint); | ||
343 | if (mnt) | ||
344 | return mnt; | ||
345 | |||
346 | mnt = __perf_debugfs_mount(mountpoint); | ||
321 | 347 | ||
322 | return mnt; | 348 | return mnt; |
323 | } | 349 | } |
@@ -325,12 +351,19 @@ const char *perf_debugfs_mount(const char *mountpoint) | |||
325 | void perf_debugfs_set_path(const char *mntpt) | 351 | void perf_debugfs_set_path(const char *mntpt) |
326 | { | 352 | { |
327 | snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); | 353 | snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); |
328 | set_tracing_events_path(mntpt); | 354 | set_tracing_events_path("tracing/", mntpt); |
355 | } | ||
356 | |||
357 | static const char *find_tracefs(void) | ||
358 | { | ||
359 | const char *path = __perf_tracefs_mount(NULL); | ||
360 | |||
361 | return path; | ||
329 | } | 362 | } |
330 | 363 | ||
331 | static const char *find_debugfs(void) | 364 | static const char *find_debugfs(void) |
332 | { | 365 | { |
333 | const char *path = perf_debugfs_mount(NULL); | 366 | const char *path = __perf_debugfs_mount(NULL); |
334 | 367 | ||
335 | if (!path) | 368 | if (!path) |
336 | fprintf(stderr, "Your kernel does not support the debugfs filesystem"); | 369 | fprintf(stderr, "Your kernel does not support the debugfs filesystem"); |
@@ -344,6 +377,7 @@ static const char *find_debugfs(void) | |||
344 | */ | 377 | */ |
345 | const char *find_tracing_dir(void) | 378 | const char *find_tracing_dir(void) |
346 | { | 379 | { |
380 | const char *tracing_dir = ""; | ||
347 | static char *tracing; | 381 | static char *tracing; |
348 | static int tracing_found; | 382 | static int tracing_found; |
349 | const char *debugfs; | 383 | const char *debugfs; |
@@ -351,11 +385,15 @@ const char *find_tracing_dir(void) | |||
351 | if (tracing_found) | 385 | if (tracing_found) |
352 | return tracing; | 386 | return tracing; |
353 | 387 | ||
354 | debugfs = find_debugfs(); | 388 | debugfs = find_tracefs(); |
355 | if (!debugfs) | 389 | if (!debugfs) { |
356 | return NULL; | 390 | tracing_dir = "/tracing"; |
391 | debugfs = find_debugfs(); | ||
392 | if (!debugfs) | ||
393 | return NULL; | ||
394 | } | ||
357 | 395 | ||
358 | if (asprintf(&tracing, "%s/tracing", debugfs) < 0) | 396 | if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0) |
359 | return NULL; | 397 | return NULL; |
360 | 398 | ||
361 | tracing_found = 1; | 399 | tracing_found = 1; |