提交 d7e13484 编写于 作者: A Arnaldo Carvalho de Melo

perf trace: Move the files table resizing to outside set_pathname()

So that we can have that table expanded when setting other attributes.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-hzvpe3qwafe6sqcq3bhtbxds@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 f4a74fcb
...@@ -1040,15 +1040,13 @@ void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg, ...@@ -1040,15 +1040,13 @@ void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,
static const size_t trace__entry_str_size = 2048; static const size_t trace__entry_str_size = 2048;
static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pathname) static struct file *thread_trace__files_entry(struct thread_trace *ttrace, int fd)
{ {
struct thread_trace *ttrace = thread__priv(thread);
if (fd > ttrace->files.max) { if (fd > ttrace->files.max) {
struct file *nfiles = realloc(ttrace->files.table, (fd + 1) * sizeof(struct file)); struct file *nfiles = realloc(ttrace->files.table, (fd + 1) * sizeof(struct file));
if (nfiles == NULL) if (nfiles == NULL)
return -1; return NULL;
if (ttrace->files.max != -1) { if (ttrace->files.max != -1) {
memset(nfiles + ttrace->files.max + 1, 0, memset(nfiles + ttrace->files.max + 1, 0,
...@@ -1061,9 +1059,21 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat ...@@ -1061,9 +1059,21 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat
ttrace->files.max = fd; ttrace->files.max = fd;
} }
ttrace->files.table[fd].pathname = strdup(pathname); return ttrace->files.table + fd;
}
static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pathname)
{
struct thread_trace *ttrace = thread__priv(thread);
struct file *file = thread_trace__files_entry(ttrace, fd);
return ttrace->files.table[fd].pathname != NULL ? 0 : -1; if (file != NULL) {
file->pathname = strdup(pathname);
if (file->pathname)
return 0;
}
return -1;
} }
static int thread__read_fd_path(struct thread *thread, int fd) static int thread__read_fd_path(struct thread *thread, int fd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册