diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-14 13:13:22 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-14 13:13:22 -0500 |
| commit | 2205afa7d13ec716935dfd4b8ff71059ee7aeb0c (patch) | |
| tree | 19e63ed8040e8a82c3cdd331458d246247466a28 /tools/perf/util/data_map.c | |
| parent | 491424c0f46c282a854b88830212bdb0763e93dc (diff) | |
| parent | 2cd9046cc53dd2625e2cf5854d6cbb1ba61de914 (diff) | |
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
perf sched: Fix build failure on sparc
perf bench: Add "all" pseudo subsystem and "all" pseudo suite
perf tools: Introduce perf_session class
perf symbols: Ditch dso->find_symbol
perf symbols: Allow lookups by symbol name too
perf symbols: Add missing "Variables" entry to map_type__name
perf symbols: Add support for 'variable' symtabs
perf symbols: Introduce ELF counterparts to symbol_type__is_a
perf symbols: Introduce symbol_type__is_a
perf symbols: Rename kthreads to kmaps, using another abstraction for it
perf tools: Allow building for ARM
hw-breakpoints: Handle bad modify_user_hw_breakpoint off-case return value
perf tools: Allow cross compiling
tracing, slab: Fix no callsite ifndef CONFIG_KMEMTRACE
tracing, slab: Define kmem_cache_alloc_notrace ifdef CONFIG_TRACING
Trivial conflict due to different fixes to modify_user_hw_breakpoint()
in include/linux/hw_breakpoint.h
Diffstat (limited to 'tools/perf/util/data_map.c')
| -rw-r--r-- | tools/perf/util/data_map.c | 71 |
1 files changed, 11 insertions, 60 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 59b65d0bd7c1..6d46dda53a29 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
| @@ -129,23 +129,16 @@ out: | |||
| 129 | return err; | 129 | return err; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | int mmap_dispatch_perf_file(struct perf_header **pheader, | 132 | int perf_session__process_events(struct perf_session *self, |
| 133 | const char *input_name, | 133 | int full_paths, int *cwdlen, char **cwd) |
| 134 | int force, | ||
| 135 | int full_paths, | ||
| 136 | int *cwdlen, | ||
| 137 | char **cwd) | ||
| 138 | { | 134 | { |
| 139 | int err; | 135 | int err; |
| 140 | struct perf_header *header; | ||
| 141 | unsigned long head, shift; | 136 | unsigned long head, shift; |
| 142 | unsigned long offset = 0; | 137 | unsigned long offset = 0; |
| 143 | struct stat input_stat; | ||
| 144 | size_t page_size; | 138 | size_t page_size; |
| 145 | u64 sample_type; | 139 | u64 sample_type; |
| 146 | event_t *event; | 140 | event_t *event; |
| 147 | uint32_t size; | 141 | uint32_t size; |
| 148 | int input; | ||
| 149 | char *buf; | 142 | char *buf; |
| 150 | 143 | ||
| 151 | if (curr_handler == NULL) { | 144 | if (curr_handler == NULL) { |
| @@ -155,56 +148,19 @@ int mmap_dispatch_perf_file(struct perf_header **pheader, | |||
| 155 | 148 | ||
| 156 | page_size = getpagesize(); | 149 | page_size = getpagesize(); |
| 157 | 150 | ||
| 158 | input = open(input_name, O_RDONLY); | 151 | head = self->header.data_offset; |
| 159 | if (input < 0) { | 152 | sample_type = perf_header__sample_type(&self->header); |
| 160 | pr_err("Failed to open file: %s", input_name); | ||
| 161 | if (!strcmp(input_name, "perf.data")) | ||
| 162 | pr_err(" (try 'perf record' first)"); | ||
| 163 | pr_err("\n"); | ||
| 164 | return -errno; | ||
| 165 | } | ||
| 166 | |||
| 167 | if (fstat(input, &input_stat) < 0) { | ||
| 168 | pr_err("failed to stat file"); | ||
| 169 | err = -errno; | ||
| 170 | goto out_close; | ||
| 171 | } | ||
| 172 | |||
| 173 | err = -EACCES; | ||
| 174 | if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) { | ||
| 175 | pr_err("file: %s not owned by current user or root\n", | ||
| 176 | input_name); | ||
| 177 | goto out_close; | ||
| 178 | } | ||
| 179 | |||
| 180 | if (input_stat.st_size == 0) { | ||
| 181 | pr_info("zero-sized file, nothing to do!\n"); | ||
| 182 | goto done; | ||
| 183 | } | ||
| 184 | |||
| 185 | err = -ENOMEM; | ||
| 186 | header = perf_header__new(); | ||
| 187 | if (header == NULL) | ||
| 188 | goto out_close; | ||
| 189 | |||
| 190 | err = perf_header__read(header, input); | ||
| 191 | if (err < 0) | ||
| 192 | goto out_delete; | ||
| 193 | *pheader = header; | ||
| 194 | head = header->data_offset; | ||
| 195 | |||
| 196 | sample_type = perf_header__sample_type(header); | ||
| 197 | 153 | ||
| 198 | err = -EINVAL; | 154 | err = -EINVAL; |
| 199 | if (curr_handler->sample_type_check && | 155 | if (curr_handler->sample_type_check && |
| 200 | curr_handler->sample_type_check(sample_type) < 0) | 156 | curr_handler->sample_type_check(sample_type) < 0) |
| 201 | goto out_delete; | 157 | goto out_err; |
| 202 | 158 | ||
| 203 | if (!full_paths) { | 159 | if (!full_paths) { |
| 204 | if (getcwd(__cwd, sizeof(__cwd)) == NULL) { | 160 | if (getcwd(__cwd, sizeof(__cwd)) == NULL) { |
| 205 | pr_err("failed to get the current directory\n"); | 161 | pr_err("failed to get the current directory\n"); |
| 206 | err = -errno; | 162 | err = -errno; |
| 207 | goto out_delete; | 163 | goto out_err; |
| 208 | } | 164 | } |
| 209 | *cwd = __cwd; | 165 | *cwd = __cwd; |
| 210 | *cwdlen = strlen(*cwd); | 166 | *cwdlen = strlen(*cwd); |
| @@ -219,11 +175,11 @@ int mmap_dispatch_perf_file(struct perf_header **pheader, | |||
| 219 | 175 | ||
| 220 | remap: | 176 | remap: |
| 221 | buf = mmap(NULL, page_size * mmap_window, PROT_READ, | 177 | buf = mmap(NULL, page_size * mmap_window, PROT_READ, |
| 222 | MAP_SHARED, input, offset); | 178 | MAP_SHARED, self->fd, offset); |
| 223 | if (buf == MAP_FAILED) { | 179 | if (buf == MAP_FAILED) { |
| 224 | pr_err("failed to mmap file\n"); | 180 | pr_err("failed to mmap file\n"); |
| 225 | err = -errno; | 181 | err = -errno; |
| 226 | goto out_delete; | 182 | goto out_err; |
| 227 | } | 183 | } |
| 228 | 184 | ||
| 229 | more: | 185 | more: |
| @@ -273,19 +229,14 @@ more: | |||
| 273 | 229 | ||
| 274 | head += size; | 230 | head += size; |
| 275 | 231 | ||
| 276 | if (offset + head >= header->data_offset + header->data_size) | 232 | if (offset + head >= self->header.data_offset + self->header.data_size) |
| 277 | goto done; | 233 | goto done; |
| 278 | 234 | ||
| 279 | if (offset + head < (unsigned long)input_stat.st_size) | 235 | if (offset + head < self->size) |
| 280 | goto more; | 236 | goto more; |
| 281 | 237 | ||
| 282 | done: | 238 | done: |
| 283 | err = 0; | 239 | err = 0; |
| 284 | out_close: | 240 | out_err: |
| 285 | close(input); | ||
| 286 | |||
| 287 | return err; | 241 | return err; |
| 288 | out_delete: | ||
| 289 | perf_header__delete(header); | ||
| 290 | goto out_close; | ||
| 291 | } | 242 | } |
