aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-probe.c23
-rw-r--r--tools/perf/util/probe-finder.c12
-rw-r--r--tools/perf/util/probe-finder.h7
3 files changed, 21 insertions, 21 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index a1467d12547a..b5ad86a265ff 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -35,6 +35,8 @@
35#include "perf.h" 35#include "perf.h"
36#include "builtin.h" 36#include "builtin.h"
37#include "util/util.h" 37#include "util/util.h"
38#include "util/event.h"
39#include "util/debug.h"
38#include "util/parse-options.h" 40#include "util/parse-options.h"
39#include "util/parse-events.h" /* For debugfs_path */ 41#include "util/parse-events.h" /* For debugfs_path */
40#include "util/probe-finder.h" 42#include "util/probe-finder.h"
@@ -76,7 +78,7 @@ static int parse_probepoint(const struct option *opt __used,
76 if (!str) /* The end of probe points */ 78 if (!str) /* The end of probe points */
77 return 0; 79 return 0;
78 80
79 debug("Probe-define(%d): %s\n", session.nr_probe, str); 81 eprintf("probe-definition(%d): %s\n", session.nr_probe, str);
80 if (++session.nr_probe == MAX_PROBES) 82 if (++session.nr_probe == MAX_PROBES)
81 semantic_error("Too many probes"); 83 semantic_error("Too many probes");
82 84
@@ -101,7 +103,7 @@ static int parse_probepoint(const struct option *opt __used,
101 die("strndup"); 103 die("strndup");
102 if (++argc == MAX_PROBE_ARGS) 104 if (++argc == MAX_PROBE_ARGS)
103 semantic_error("Too many arguments"); 105 semantic_error("Too many arguments");
104 debug("argv[%d]=%s\n", argc, argv[argc - 1]); 106 eprintf("argv[%d]=%s\n", argc, argv[argc - 1]);
105 } 107 }
106 } while (*str != '\0'); 108 } while (*str != '\0');
107 if (argc < 2) 109 if (argc < 2)
@@ -131,7 +133,7 @@ static int parse_probepoint(const struct option *opt __used,
131 pp->line = atoi(ptr); 133 pp->line = atoi(ptr);
132 if (!pp->file || !pp->line) 134 if (!pp->file || !pp->line)
133 semantic_error("Failed to parse line."); 135 semantic_error("Failed to parse line.");
134 debug("file:%s line:%d\n", pp->file, pp->line); 136 eprintf("file:%s line:%d\n", pp->file, pp->line);
135 } else { 137 } else {
136 /* Function name */ 138 /* Function name */
137 ptr = strchr(arg, '+'); 139 ptr = strchr(arg, '+');
@@ -148,7 +150,7 @@ static int parse_probepoint(const struct option *opt __used,
148 pp->file = strdup(ptr); 150 pp->file = strdup(ptr);
149 } 151 }
150 pp->function = strdup(arg); 152 pp->function = strdup(arg);
151 debug("symbol:%s file:%s offset:%d\n", 153 eprintf("symbol:%s file:%s offset:%d\n",
152 pp->function, pp->file, pp->offset); 154 pp->function, pp->file, pp->offset);
153 } 155 }
154 free(argv[1]); 156 free(argv[1]);
@@ -173,7 +175,7 @@ static int parse_probepoint(const struct option *opt __used,
173 session.need_dwarf = 1; 175 session.need_dwarf = 1;
174 } 176 }
175 177
176 debug("%d arguments\n", pp->nr_args); 178 eprintf("%d arguments\n", pp->nr_args);
177 return 0; 179 return 0;
178} 180}
179 181
@@ -186,7 +188,7 @@ static int open_default_vmlinux(void)
186 188
187 ret = uname(&uts); 189 ret = uname(&uts);
188 if (ret) { 190 if (ret) {
189 debug("uname() failed.\n"); 191 eprintf("uname() failed.\n");
190 return -errno; 192 return -errno;
191 } 193 }
192 session.release = uts.release; 194 session.release = uts.release;
@@ -194,11 +196,12 @@ static int open_default_vmlinux(void)
194 ret = snprintf(fname, MAX_PATH_LEN, 196 ret = snprintf(fname, MAX_PATH_LEN,
195 default_search_path[i], session.release); 197 default_search_path[i], session.release);
196 if (ret >= MAX_PATH_LEN || ret < 0) { 198 if (ret >= MAX_PATH_LEN || ret < 0) {
197 debug("Filename(%d,%s) is too long.\n", i, uts.release); 199 eprintf("Filename(%d,%s) is too long.\n", i,
200 uts.release);
198 errno = E2BIG; 201 errno = E2BIG;
199 return -E2BIG; 202 return -E2BIG;
200 } 203 }
201 debug("try to open %s\n", fname); 204 eprintf("try to open %s\n", fname);
202 fd = open(fname, O_RDONLY); 205 fd = open(fname, O_RDONLY);
203 if (fd >= 0) 206 if (fd >= 0)
204 break; 207 break;
@@ -213,6 +216,8 @@ static const char * const probe_usage[] = {
213}; 216};
214 217
215static const struct option options[] = { 218static const struct option options[] = {
219 OPT_BOOLEAN('v', "verbose", &verbose,
220 "be more verbose (show parsed arguments, etc)"),
216#ifndef NO_LIBDWARF 221#ifndef NO_LIBDWARF
217 OPT_STRING('k', "vmlinux", &session.vmlinux, "file", 222 OPT_STRING('k', "vmlinux", &session.vmlinux, "file",
218 "vmlinux/module pathname"), 223 "vmlinux/module pathname"),
@@ -336,7 +341,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
336 ret = find_probepoint(fd, pp); 341 ret = find_probepoint(fd, pp);
337 if (ret <= 0) 342 if (ret <= 0)
338 die("No probe point found.\n"); 343 die("No probe point found.\n");
339 debug("probe event %s found\n", session.events[j]); 344 eprintf("probe event %s found\n", session.events[j]);
340 } 345 }
341 close(fd); 346 close(fd);
342 347
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 338fdb9e093d..db24c913225f 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -32,6 +32,8 @@
32#include <stdarg.h> 32#include <stdarg.h>
33#include <ctype.h> 33#include <ctype.h>
34 34
35#include "event.h"
36#include "debug.h"
35#include "util.h" 37#include "util.h"
36#include "probe-finder.h" 38#include "probe-finder.h"
37 39
@@ -134,7 +136,7 @@ static Dwarf_Unsigned die_get_fileno(Dwarf_Die cu_die, const char *fname)
134 dwarf_dealloc(__dw_debug, srcs, DW_DLA_LIST); 136 dwarf_dealloc(__dw_debug, srcs, DW_DLA_LIST);
135 } 137 }
136 if (found) 138 if (found)
137 debug("found fno: %d\n", (int)found); 139 eprintf("found fno: %d\n", (int)found);
138 return found; 140 return found;
139} 141}
140 142
@@ -440,7 +442,7 @@ static void find_variable(Dwarf_Die sp_die, struct probe_finder *pf)
440 return ; 442 return ;
441 } 443 }
442 444
443 debug("Searching '%s' variable in context.\n", pf->var); 445 eprintf("Searching '%s' variable in context.\n", pf->var);
444 /* Search child die for local variables and parameters. */ 446 /* Search child die for local variables and parameters. */
445 ret = search_die_from_children(sp_die, variable_callback, pf); 447 ret = search_die_from_children(sp_die, variable_callback, pf);
446 if (!ret) 448 if (!ret)
@@ -550,7 +552,7 @@ static void find_by_line(Dwarf_Die cu_die, struct probe_finder *pf)
550 552
551 ret = dwarf_lineaddr(lines[i], &addr, &__dw_error); 553 ret = dwarf_lineaddr(lines[i], &addr, &__dw_error);
552 ERR_IF(ret != DW_DLV_OK); 554 ERR_IF(ret != DW_DLV_OK);
553 debug("Probe point found: 0x%llx\n", addr); 555 eprintf("Probe point found: 0x%llx\n", addr);
554 pf->addr = addr; 556 pf->addr = addr;
555 /* Search a real subprogram including this line, */ 557 /* Search a real subprogram including this line, */
556 ret = search_die_from_children(cu_die, probeaddr_callback, pf); 558 ret = search_die_from_children(cu_die, probeaddr_callback, pf);
@@ -581,7 +583,7 @@ static int probefunc_callback(struct die_link *dlink, void *data)
581 &pf->inl_offs, 583 &pf->inl_offs,
582 &__dw_error); 584 &__dw_error);
583 ERR_IF(ret != DW_DLV_OK); 585 ERR_IF(ret != DW_DLV_OK);
584 debug("inline definition offset %lld\n", 586 eprintf("inline definition offset %lld\n",
585 pf->inl_offs); 587 pf->inl_offs);
586 return 0; 588 return 0;
587 } 589 }
@@ -597,7 +599,7 @@ static int probefunc_callback(struct die_link *dlink, void *data)
597 /* Get probe address */ 599 /* Get probe address */
598 pf->addr = die_get_entrypc(dlink->die); 600 pf->addr = die_get_entrypc(dlink->die);
599 pf->addr += pp->offset; 601 pf->addr += pp->offset;
600 debug("found inline addr: 0x%llx\n", pf->addr); 602 eprintf("found inline addr: 0x%llx\n", pf->addr);
601 /* Inlined function. Get a real subprogram */ 603 /* Inlined function. Get a real subprogram */
602 for (lk = dlink->parent; lk != NULL; lk = lk->parent) { 604 for (lk = dlink->parent; lk != NULL; lk = lk->parent) {
603 tag = 0; 605 tag = 0;
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index 306810c32f6b..6a7cb0c04e9e 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -4,13 +4,6 @@
4#define _stringify(n) #n 4#define _stringify(n) #n
5#define stringify(n) _stringify(n) 5#define stringify(n) _stringify(n)
6 6
7#ifdef DEBUG
8#define debug(fmt ...) \
9 fprintf(stderr, "DBG(" __FILE__ ":" stringify(__LINE__) "): " fmt)
10#else
11#define debug(fmt ...) do {} while (0)
12#endif
13
14#define ERR_IF(cnd) \ 7#define ERR_IF(cnd) \
15 do { if (cnd) { \ 8 do { if (cnd) { \
16 fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \ 9 fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \