-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
libbpf-tools/offcputime: Add multi process/thread support #5111
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 |
---|---|---|
|
@@ -1247,3 +1247,45 @@ bool probe_ringbuf() | |
close(map_fd); | ||
return true; | ||
} | ||
|
||
int split_convert(char *s, const char* delim, void *elems, size_t elems_size, | ||
size_t elem_size, convert_fn_t convert) | ||
{ | ||
char *token; | ||
int ret; | ||
char *pos = (char *)elems; | ||
|
||
if (!s || !delim || !elems) | ||
return -EINVAL; | ||
|
||
token = strtok(s, delim); | ||
while (token) { | ||
if (pos + elem_size > (char*)elems + elems_size) | ||
return -ENOBUFS; | ||
|
||
ret = convert(token, pos); | ||
if (ret) | ||
return -ret; | ||
|
||
pos += elem_size; | ||
token = strtok(NULL, delim); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int str_to_int(const char *src, void *dest) | ||
{ | ||
errno = 0; | ||
*(int*)dest = strtol(src, NULL, 10); | ||
|
||
return errno; | ||
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. Since str_to_int() and str_to_long() are in trace_helpers.c, we should add 'error = 0;' before strtol(). It is possible that errno is not 0 before strtol() and if strtol() works perfectly, errno won't change and the return value will be non-zero. 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. Yes, it's right. It's fixed. Thank you very much. |
||
} | ||
|
||
int str_to_long(const char *src, void *dest) | ||
{ | ||
errno = 0; | ||
*(long*)dest = strtol(src, NULL, 10); | ||
|
||
return errno; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do both obj->rodata->filter_by_tgid and obj->rodata->filter_by_pid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's modified. thank you.