-
Notifications
You must be signed in to change notification settings - Fork 107
ftrace_log: Add override for tracefs location #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| #include <errno.h> | ||
| #include <math.h> | ||
| #include <stdarg.h> | ||
| #include <mntent.h> | ||
|
|
||
| #include "rt-app_utils.h" | ||
|
|
||
|
|
@@ -267,6 +268,60 @@ resource_to_string(resource_t resource, char *resource_name) | |
| return 0; | ||
| } | ||
|
|
||
| /* point directly to the tracing directory */ | ||
| #define DEFAULT_FTRACE_DIR "/sys/kernel/debug/tracing" | ||
|
|
||
| char *mtab_by_type(const char *type, int typelen) | ||
| { | ||
| FILE *fd_mntent; | ||
|
|
||
| fd_mntent = setmntent("/etc/mtab", "r"); | ||
| if(fd_mntent) | ||
| { | ||
| struct mntent *mntent; | ||
|
|
||
| while(mntent = getmntent(fd_mntent), mntent) | ||
| { | ||
| log_debug("mntent->dir=%s type=%s", mntent->mnt_dir, mntent->mnt_type); | ||
| if(!strncmp(type, mntent->mnt_type, typelen)) | ||
| { | ||
| char *path = strdup(mntent->mnt_dir); | ||
| endmntent(fd_mntent); | ||
| return path; | ||
| } | ||
| } | ||
| endmntent(fd_mntent); | ||
| } | ||
| return NULL; | ||
| } | ||
|
|
||
| char *ftrace_dir(void) | ||
| { | ||
| char *path; | ||
|
|
||
| /* tracefs paths point directly to the tracing directory */ | ||
| path = mtab_by_type("tracefs", sizeof("tracefs")-1); | ||
| if(path) | ||
| return path; | ||
|
|
||
| /* debugfs paths point one level above the tracing directory */ | ||
| path = mtab_by_type("debugfs", sizeof("debugfs")-1); | ||
| if(path) | ||
| { | ||
| char *tmp; | ||
| int len = strlen(path) + sizeof("/tracing"); | ||
| tmp = malloc(len); | ||
| if(!tmp) | ||
| return NULL; | ||
| strcpy(tmp, path); | ||
| free(path); | ||
| strcat(tmp, "/tracing"); | ||
| return tmp; | ||
| } | ||
|
|
||
| return strdup(DEFAULT_FTRACE_DIR); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need to return a default path ? there is no chance that this can work, isn't ? Should be better return null and escape early in the main thread
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I return NULL here, it means that if the mtab code fails we cannot use ftrace unless we provide a path in the global section. That's probably OK, I don't mind that if you dont.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wondering if there is a usecase where mtab would fail but the default path could work
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, and if that does happen you can always add ftracedir to your global options file to force it to a specific location. I'll push a new squashed rev up once I've tested it a bit. |
||
| } | ||
|
|
||
| int ftrace_setup(char *categories) | ||
| { | ||
| char *cat = strtok(categories, ","); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.