diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-10-16 20:08:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-17 03:54:01 -0400 |
commit | 9769833b8e4425dc93fc837bf124c6cb02a51abb (patch) | |
tree | 3e5d2a12e8df8528e50f35c4f122d56b4f59b2cd /tools | |
parent | 89c69c0eee7515cdc217f4278de43547284b3458 (diff) |
perf: Add DIE_IF() macro for error checking
Add DIE_IF() macro and replace ERR_IF() with it, and use
linux/stringify.h.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091017000818.16556.82452.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 1 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 82 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.h | 10 | ||||
-rw-r--r-- | tools/perf/util/util.h | 9 |
4 files changed, 51 insertions, 51 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 03c27b9068aa..1abbf9a5ee57 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -321,6 +321,7 @@ LIB_FILE=libperf.a | |||
321 | LIB_H += ../../include/linux/perf_event.h | 321 | LIB_H += ../../include/linux/perf_event.h |
322 | LIB_H += ../../include/linux/rbtree.h | 322 | LIB_H += ../../include/linux/rbtree.h |
323 | LIB_H += ../../include/linux/list.h | 323 | LIB_H += ../../include/linux/list.h |
324 | LIB_H += ../../include/linux/stringify.h | ||
324 | LIB_H += util/include/linux/list.h | 325 | LIB_H += util/include/linux/list.h |
325 | LIB_H += perf.h | 326 | LIB_H += perf.h |
326 | LIB_H += util/types.h | 327 | LIB_H += util/types.h |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index db24c913225f..be997abdf5b1 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -146,7 +146,7 @@ static int die_compare_name(Dwarf_Die dw_die, const char *tname) | |||
146 | char *name; | 146 | char *name; |
147 | int ret; | 147 | int ret; |
148 | ret = dwarf_diename(dw_die, &name, &__dw_error); | 148 | ret = dwarf_diename(dw_die, &name, &__dw_error); |
149 | ERR_IF(ret == DW_DLV_ERROR); | 149 | DIE_IF(ret == DW_DLV_ERROR); |
150 | if (ret == DW_DLV_OK) { | 150 | if (ret == DW_DLV_OK) { |
151 | ret = strcmp(tname, name); | 151 | ret = strcmp(tname, name); |
152 | dwarf_dealloc(__dw_debug, name, DW_DLA_STRING); | 152 | dwarf_dealloc(__dw_debug, name, DW_DLA_STRING); |
@@ -164,11 +164,11 @@ static int die_within_subprogram(Dwarf_Die sp_die, Dwarf_Addr addr, | |||
164 | 164 | ||
165 | /* TODO: check ranges */ | 165 | /* TODO: check ranges */ |
166 | ret = dwarf_lowpc(sp_die, &lopc, &__dw_error); | 166 | ret = dwarf_lowpc(sp_die, &lopc, &__dw_error); |
167 | ERR_IF(ret == DW_DLV_ERROR); | 167 | DIE_IF(ret == DW_DLV_ERROR); |
168 | if (ret == DW_DLV_NO_ENTRY) | 168 | if (ret == DW_DLV_NO_ENTRY) |
169 | return 0; | 169 | return 0; |
170 | ret = dwarf_highpc(sp_die, &hipc, &__dw_error); | 170 | ret = dwarf_highpc(sp_die, &hipc, &__dw_error); |
171 | ERR_IF(ret != DW_DLV_OK); | 171 | DIE_IF(ret != DW_DLV_OK); |
172 | if (lopc <= addr && addr < hipc) { | 172 | if (lopc <= addr && addr < hipc) { |
173 | *offs = addr - lopc; | 173 | *offs = addr - lopc; |
174 | return 1; | 174 | return 1; |
@@ -184,7 +184,7 @@ static Dwarf_Bool die_inlined_subprogram(Dwarf_Die dw_die) | |||
184 | int ret; | 184 | int ret; |
185 | 185 | ||
186 | ret = dwarf_hasattr(dw_die, DW_AT_inline, &inl, &__dw_error); | 186 | ret = dwarf_hasattr(dw_die, DW_AT_inline, &inl, &__dw_error); |
187 | ERR_IF(ret == DW_DLV_ERROR); | 187 | DIE_IF(ret == DW_DLV_ERROR); |
188 | return inl; | 188 | return inl; |
189 | } | 189 | } |
190 | 190 | ||
@@ -196,9 +196,9 @@ static Dwarf_Off die_get_abstract_origin(Dwarf_Die dw_die) | |||
196 | int ret; | 196 | int ret; |
197 | 197 | ||
198 | ret = dwarf_attr(dw_die, DW_AT_abstract_origin, &attr, &__dw_error); | 198 | ret = dwarf_attr(dw_die, DW_AT_abstract_origin, &attr, &__dw_error); |
199 | ERR_IF(ret != DW_DLV_OK); | 199 | DIE_IF(ret != DW_DLV_OK); |
200 | ret = dwarf_formref(attr, &cu_offs, &__dw_error); | 200 | ret = dwarf_formref(attr, &cu_offs, &__dw_error); |
201 | ERR_IF(ret != DW_DLV_OK); | 201 | DIE_IF(ret != DW_DLV_OK); |
202 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); | 202 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); |
203 | return cu_offs; | 203 | return cu_offs; |
204 | } | 204 | } |
@@ -215,28 +215,28 @@ static Dwarf_Addr die_get_entrypc(Dwarf_Die dw_die) | |||
215 | 215 | ||
216 | /* Try to get entry pc */ | 216 | /* Try to get entry pc */ |
217 | ret = dwarf_attr(dw_die, DW_AT_entry_pc, &attr, &__dw_error); | 217 | ret = dwarf_attr(dw_die, DW_AT_entry_pc, &attr, &__dw_error); |
218 | ERR_IF(ret == DW_DLV_ERROR); | 218 | DIE_IF(ret == DW_DLV_ERROR); |
219 | if (ret == DW_DLV_OK) { | 219 | if (ret == DW_DLV_OK) { |
220 | ret = dwarf_formaddr(attr, &addr, &__dw_error); | 220 | ret = dwarf_formaddr(attr, &addr, &__dw_error); |
221 | ERR_IF(ret != DW_DLV_OK); | 221 | DIE_IF(ret != DW_DLV_OK); |
222 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); | 222 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); |
223 | return addr; | 223 | return addr; |
224 | } | 224 | } |
225 | 225 | ||
226 | /* Try to get low pc */ | 226 | /* Try to get low pc */ |
227 | ret = dwarf_lowpc(dw_die, &addr, &__dw_error); | 227 | ret = dwarf_lowpc(dw_die, &addr, &__dw_error); |
228 | ERR_IF(ret == DW_DLV_ERROR); | 228 | DIE_IF(ret == DW_DLV_ERROR); |
229 | if (ret == DW_DLV_OK) | 229 | if (ret == DW_DLV_OK) |
230 | return addr; | 230 | return addr; |
231 | 231 | ||
232 | /* Try to get ranges */ | 232 | /* Try to get ranges */ |
233 | ret = dwarf_attr(dw_die, DW_AT_ranges, &attr, &__dw_error); | 233 | ret = dwarf_attr(dw_die, DW_AT_ranges, &attr, &__dw_error); |
234 | ERR_IF(ret != DW_DLV_OK); | 234 | DIE_IF(ret != DW_DLV_OK); |
235 | ret = dwarf_formref(attr, &offs, &__dw_error); | 235 | ret = dwarf_formref(attr, &offs, &__dw_error); |
236 | ERR_IF(ret != DW_DLV_OK); | 236 | DIE_IF(ret != DW_DLV_OK); |
237 | ret = dwarf_get_ranges(__dw_debug, offs, &ranges, &cnt, NULL, | 237 | ret = dwarf_get_ranges(__dw_debug, offs, &ranges, &cnt, NULL, |
238 | &__dw_error); | 238 | &__dw_error); |
239 | ERR_IF(ret != DW_DLV_OK); | 239 | DIE_IF(ret != DW_DLV_OK); |
240 | addr = ranges[0].dwr_addr1; | 240 | addr = ranges[0].dwr_addr1; |
241 | dwarf_ranges_dealloc(__dw_debug, ranges, cnt); | 241 | dwarf_ranges_dealloc(__dw_debug, ranges, cnt); |
242 | return addr; | 242 | return addr; |
@@ -261,7 +261,7 @@ static int __search_die_tree(struct die_link *cur_link, | |||
261 | while (!(ret = die_cb(cur_link, data))) { | 261 | while (!(ret = die_cb(cur_link, data))) { |
262 | /* Check child die */ | 262 | /* Check child die */ |
263 | ret = dwarf_child(cur_link->die, &new_die, &__dw_error); | 263 | ret = dwarf_child(cur_link->die, &new_die, &__dw_error); |
264 | ERR_IF(ret == DW_DLV_ERROR); | 264 | DIE_IF(ret == DW_DLV_ERROR); |
265 | if (ret == DW_DLV_OK) { | 265 | if (ret == DW_DLV_OK) { |
266 | new_link.parent = cur_link; | 266 | new_link.parent = cur_link; |
267 | new_link.die = new_die; | 267 | new_link.die = new_die; |
@@ -273,7 +273,7 @@ static int __search_die_tree(struct die_link *cur_link, | |||
273 | /* Move to next sibling */ | 273 | /* Move to next sibling */ |
274 | ret = dwarf_siblingof(__dw_debug, cur_link->die, &new_die, | 274 | ret = dwarf_siblingof(__dw_debug, cur_link->die, &new_die, |
275 | &__dw_error); | 275 | &__dw_error); |
276 | ERR_IF(ret == DW_DLV_ERROR); | 276 | DIE_IF(ret == DW_DLV_ERROR); |
277 | dwarf_dealloc(__dw_debug, cur_link->die, DW_DLA_DIE); | 277 | dwarf_dealloc(__dw_debug, cur_link->die, DW_DLA_DIE); |
278 | cur_link->die = new_die; | 278 | cur_link->die = new_die; |
279 | if (ret == DW_DLV_NO_ENTRY) | 279 | if (ret == DW_DLV_NO_ENTRY) |
@@ -293,7 +293,7 @@ static int search_die_from_children(Dwarf_Die parent_die, | |||
293 | 293 | ||
294 | new_link.parent = NULL; | 294 | new_link.parent = NULL; |
295 | ret = dwarf_child(parent_die, &new_link.die, &__dw_error); | 295 | ret = dwarf_child(parent_die, &new_link.die, &__dw_error); |
296 | ERR_IF(ret == DW_DLV_ERROR); | 296 | DIE_IF(ret == DW_DLV_ERROR); |
297 | if (ret == DW_DLV_OK) | 297 | if (ret == DW_DLV_OK) |
298 | return __search_die_tree(&new_link, die_cb, data); | 298 | return __search_die_tree(&new_link, die_cb, data); |
299 | else | 299 | else |
@@ -309,7 +309,7 @@ static int attr_get_locdesc(Dwarf_Attribute attr, Dwarf_Locdesc *desc, | |||
309 | int ret, i; | 309 | int ret, i; |
310 | 310 | ||
311 | ret = dwarf_loclist_n(attr, &llbuf, &lcnt, &__dw_error); | 311 | ret = dwarf_loclist_n(attr, &llbuf, &lcnt, &__dw_error); |
312 | ERR_IF(ret != DW_DLV_OK); | 312 | DIE_IF(ret != DW_DLV_OK); |
313 | ret = DW_DLV_NO_ENTRY; | 313 | ret = DW_DLV_NO_ENTRY; |
314 | for (i = 0; i < lcnt; ++i) { | 314 | for (i = 0; i < lcnt; ++i) { |
315 | if (llbuf[i]->ld_lopc <= addr && | 315 | if (llbuf[i]->ld_lopc <= addr && |
@@ -317,7 +317,7 @@ static int attr_get_locdesc(Dwarf_Attribute attr, Dwarf_Locdesc *desc, | |||
317 | memcpy(desc, llbuf[i], sizeof(Dwarf_Locdesc)); | 317 | memcpy(desc, llbuf[i], sizeof(Dwarf_Locdesc)); |
318 | desc->ld_s = | 318 | desc->ld_s = |
319 | malloc(sizeof(Dwarf_Loc) * llbuf[i]->ld_cents); | 319 | malloc(sizeof(Dwarf_Loc) * llbuf[i]->ld_cents); |
320 | ERR_IF(desc->ld_s == NULL); | 320 | DIE_IF(desc->ld_s == NULL); |
321 | memcpy(desc->ld_s, llbuf[i]->ld_s, | 321 | memcpy(desc->ld_s, llbuf[i]->ld_s, |
322 | sizeof(Dwarf_Loc) * llbuf[i]->ld_cents); | 322 | sizeof(Dwarf_Loc) * llbuf[i]->ld_cents); |
323 | ret = DW_DLV_OK; | 323 | ret = DW_DLV_OK; |
@@ -383,8 +383,8 @@ static void show_location(Dwarf_Loc *loc, struct probe_finder *pf) | |||
383 | " %s=%+lld(%s)", pf->var, offs, regs); | 383 | " %s=%+lld(%s)", pf->var, offs, regs); |
384 | else | 384 | else |
385 | ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs); | 385 | ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs); |
386 | ERR_IF(ret < 0); | 386 | DIE_IF(ret < 0); |
387 | ERR_IF(ret >= pf->len); | 387 | DIE_IF(ret >= pf->len); |
388 | } | 388 | } |
389 | 389 | ||
390 | /* Show a variables in kprobe event format */ | 390 | /* Show a variables in kprobe event format */ |
@@ -401,7 +401,7 @@ static void show_variable(Dwarf_Die vr_die, struct probe_finder *pf) | |||
401 | if (ret != DW_DLV_OK) | 401 | if (ret != DW_DLV_OK) |
402 | goto error; | 402 | goto error; |
403 | /* TODO? */ | 403 | /* TODO? */ |
404 | ERR_IF(ld.ld_cents != 1); | 404 | DIE_IF(ld.ld_cents != 1); |
405 | show_location(&ld.ld_s[0], pf); | 405 | show_location(&ld.ld_s[0], pf); |
406 | free(ld.ld_s); | 406 | free(ld.ld_s); |
407 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); | 407 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); |
@@ -418,7 +418,7 @@ static int variable_callback(struct die_link *dlink, void *data) | |||
418 | int ret; | 418 | int ret; |
419 | 419 | ||
420 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); | 420 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); |
421 | ERR_IF(ret == DW_DLV_ERROR); | 421 | DIE_IF(ret == DW_DLV_ERROR); |
422 | if ((tag == DW_TAG_formal_parameter || | 422 | if ((tag == DW_TAG_formal_parameter || |
423 | tag == DW_TAG_variable) && | 423 | tag == DW_TAG_variable) && |
424 | (die_compare_name(dlink->die, pf->var) == 0)) { | 424 | (die_compare_name(dlink->die, pf->var) == 0)) { |
@@ -437,8 +437,8 @@ static void find_variable(Dwarf_Die sp_die, struct probe_finder *pf) | |||
437 | if (!is_c_varname(pf->var)) { | 437 | if (!is_c_varname(pf->var)) { |
438 | /* Output raw parameters */ | 438 | /* Output raw parameters */ |
439 | ret = snprintf(pf->buf, pf->len, " %s", pf->var); | 439 | ret = snprintf(pf->buf, pf->len, " %s", pf->var); |
440 | ERR_IF(ret < 0); | 440 | DIE_IF(ret < 0); |
441 | ERR_IF(ret >= pf->len); | 441 | DIE_IF(ret >= pf->len); |
442 | return ; | 442 | return ; |
443 | } | 443 | } |
444 | 444 | ||
@@ -456,9 +456,9 @@ static void get_current_frame_base(Dwarf_Die sp_die, struct probe_finder *pf) | |||
456 | int ret; | 456 | int ret; |
457 | 457 | ||
458 | ret = dwarf_attr(sp_die, DW_AT_frame_base, &attr, &__dw_error); | 458 | ret = dwarf_attr(sp_die, DW_AT_frame_base, &attr, &__dw_error); |
459 | ERR_IF(ret != DW_DLV_OK); | 459 | DIE_IF(ret != DW_DLV_OK); |
460 | ret = attr_get_locdesc(attr, &pf->fbloc, (pf->addr - pf->cu_base)); | 460 | ret = attr_get_locdesc(attr, &pf->fbloc, (pf->addr - pf->cu_base)); |
461 | ERR_IF(ret != DW_DLV_OK); | 461 | DIE_IF(ret != DW_DLV_OK); |
462 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); | 462 | dwarf_dealloc(__dw_debug, attr, DW_DLA_ATTR); |
463 | } | 463 | } |
464 | 464 | ||
@@ -479,7 +479,7 @@ static void show_probepoint(Dwarf_Die sp_die, Dwarf_Signed offs, | |||
479 | 479 | ||
480 | /* Output name of probe point */ | 480 | /* Output name of probe point */ |
481 | ret = dwarf_diename(sp_die, &name, &__dw_error); | 481 | ret = dwarf_diename(sp_die, &name, &__dw_error); |
482 | ERR_IF(ret == DW_DLV_ERROR); | 482 | DIE_IF(ret == DW_DLV_ERROR); |
483 | if (ret == DW_DLV_OK) { | 483 | if (ret == DW_DLV_OK) { |
484 | ret = snprintf(tmp, MAX_PROBE_BUFFER, "%s+%u", name, | 484 | ret = snprintf(tmp, MAX_PROBE_BUFFER, "%s+%u", name, |
485 | (unsigned int)offs); | 485 | (unsigned int)offs); |
@@ -488,8 +488,8 @@ static void show_probepoint(Dwarf_Die sp_die, Dwarf_Signed offs, | |||
488 | /* This function has no name. */ | 488 | /* This function has no name. */ |
489 | ret = snprintf(tmp, MAX_PROBE_BUFFER, "0x%llx", pf->addr); | 489 | ret = snprintf(tmp, MAX_PROBE_BUFFER, "0x%llx", pf->addr); |
490 | } | 490 | } |
491 | ERR_IF(ret < 0); | 491 | DIE_IF(ret < 0); |
492 | ERR_IF(ret >= MAX_PROBE_BUFFER); | 492 | DIE_IF(ret >= MAX_PROBE_BUFFER); |
493 | len = ret; | 493 | len = ret; |
494 | 494 | ||
495 | /* Find each argument */ | 495 | /* Find each argument */ |
@@ -515,7 +515,7 @@ static int probeaddr_callback(struct die_link *dlink, void *data) | |||
515 | int ret; | 515 | int ret; |
516 | 516 | ||
517 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); | 517 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); |
518 | ERR_IF(ret == DW_DLV_ERROR); | 518 | DIE_IF(ret == DW_DLV_ERROR); |
519 | /* Check the address is in this subprogram */ | 519 | /* Check the address is in this subprogram */ |
520 | if (tag == DW_TAG_subprogram && | 520 | if (tag == DW_TAG_subprogram && |
521 | die_within_subprogram(dlink->die, pf->addr, &offs)) { | 521 | die_within_subprogram(dlink->die, pf->addr, &offs)) { |
@@ -537,21 +537,21 @@ static void find_by_line(Dwarf_Die cu_die, struct probe_finder *pf) | |||
537 | int ret; | 537 | int ret; |
538 | 538 | ||
539 | ret = dwarf_srclines(cu_die, &lines, &cnt, &__dw_error); | 539 | ret = dwarf_srclines(cu_die, &lines, &cnt, &__dw_error); |
540 | ERR_IF(ret != DW_DLV_OK); | 540 | DIE_IF(ret != DW_DLV_OK); |
541 | 541 | ||
542 | for (i = 0; i < cnt; i++) { | 542 | for (i = 0; i < cnt; i++) { |
543 | ret = dwarf_line_srcfileno(lines[i], &fno, &__dw_error); | 543 | ret = dwarf_line_srcfileno(lines[i], &fno, &__dw_error); |
544 | ERR_IF(ret != DW_DLV_OK); | 544 | DIE_IF(ret != DW_DLV_OK); |
545 | if (fno != pf->fno) | 545 | if (fno != pf->fno) |
546 | continue; | 546 | continue; |
547 | 547 | ||
548 | ret = dwarf_lineno(lines[i], &lineno, &__dw_error); | 548 | ret = dwarf_lineno(lines[i], &lineno, &__dw_error); |
549 | ERR_IF(ret != DW_DLV_OK); | 549 | DIE_IF(ret != DW_DLV_OK); |
550 | if (lineno != (Dwarf_Unsigned)pp->line) | 550 | if (lineno != (Dwarf_Unsigned)pp->line) |
551 | continue; | 551 | continue; |
552 | 552 | ||
553 | ret = dwarf_lineaddr(lines[i], &addr, &__dw_error); | 553 | ret = dwarf_lineaddr(lines[i], &addr, &__dw_error); |
554 | ERR_IF(ret != DW_DLV_OK); | 554 | DIE_IF(ret != DW_DLV_OK); |
555 | eprintf("Probe point found: 0x%llx\n", addr); | 555 | eprintf("Probe point found: 0x%llx\n", addr); |
556 | pf->addr = addr; | 556 | pf->addr = addr; |
557 | /* Search a real subprogram including this line, */ | 557 | /* Search a real subprogram including this line, */ |
@@ -574,7 +574,7 @@ static int probefunc_callback(struct die_link *dlink, void *data) | |||
574 | int ret; | 574 | int ret; |
575 | 575 | ||
576 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); | 576 | ret = dwarf_tag(dlink->die, &tag, &__dw_error); |
577 | ERR_IF(ret == DW_DLV_ERROR); | 577 | DIE_IF(ret == DW_DLV_ERROR); |
578 | if (tag == DW_TAG_subprogram) { | 578 | if (tag == DW_TAG_subprogram) { |
579 | if (die_compare_name(dlink->die, pp->function) == 0) { | 579 | if (die_compare_name(dlink->die, pp->function) == 0) { |
580 | if (die_inlined_subprogram(dlink->die)) { | 580 | if (die_inlined_subprogram(dlink->die)) { |
@@ -582,7 +582,7 @@ static int probefunc_callback(struct die_link *dlink, void *data) | |||
582 | ret = dwarf_die_CU_offset(dlink->die, | 582 | ret = dwarf_die_CU_offset(dlink->die, |
583 | &pf->inl_offs, | 583 | &pf->inl_offs, |
584 | &__dw_error); | 584 | &__dw_error); |
585 | ERR_IF(ret != DW_DLV_OK); | 585 | DIE_IF(ret != DW_DLV_OK); |
586 | eprintf("inline definition offset %lld\n", | 586 | eprintf("inline definition offset %lld\n", |
587 | pf->inl_offs); | 587 | pf->inl_offs); |
588 | return 0; | 588 | return 0; |
@@ -604,7 +604,7 @@ static int probefunc_callback(struct die_link *dlink, void *data) | |||
604 | for (lk = dlink->parent; lk != NULL; lk = lk->parent) { | 604 | for (lk = dlink->parent; lk != NULL; lk = lk->parent) { |
605 | tag = 0; | 605 | tag = 0; |
606 | dwarf_tag(lk->die, &tag, &__dw_error); | 606 | dwarf_tag(lk->die, &tag, &__dw_error); |
607 | ERR_IF(ret == DW_DLV_ERROR); | 607 | DIE_IF(ret == DW_DLV_ERROR); |
608 | if (tag == DW_TAG_subprogram && | 608 | if (tag == DW_TAG_subprogram && |
609 | !die_inlined_subprogram(lk->die)) | 609 | !die_inlined_subprogram(lk->die)) |
610 | goto found; | 610 | goto found; |
@@ -613,7 +613,7 @@ static int probefunc_callback(struct die_link *dlink, void *data) | |||
613 | found: | 613 | found: |
614 | /* Get offset from subprogram */ | 614 | /* Get offset from subprogram */ |
615 | ret = die_within_subprogram(lk->die, pf->addr, &offs); | 615 | ret = die_within_subprogram(lk->die, pf->addr, &offs); |
616 | ERR_IF(!ret); | 616 | DIE_IF(!ret); |
617 | show_probepoint(lk->die, offs, pf); | 617 | show_probepoint(lk->die, offs, pf); |
618 | /* Continue to search */ | 618 | /* Continue to search */ |
619 | } | 619 | } |
@@ -644,13 +644,13 @@ int find_probepoint(int fd, struct probe_point *pp) | |||
644 | /* Search CU (Compilation Unit) */ | 644 | /* Search CU (Compilation Unit) */ |
645 | ret = dwarf_next_cu_header(__dw_debug, NULL, NULL, NULL, | 645 | ret = dwarf_next_cu_header(__dw_debug, NULL, NULL, NULL, |
646 | &addr_size, &next_cuh, &__dw_error); | 646 | &addr_size, &next_cuh, &__dw_error); |
647 | ERR_IF(ret == DW_DLV_ERROR); | 647 | DIE_IF(ret == DW_DLV_ERROR); |
648 | if (ret == DW_DLV_NO_ENTRY) | 648 | if (ret == DW_DLV_NO_ENTRY) |
649 | break; | 649 | break; |
650 | 650 | ||
651 | /* Get the DIE(Debugging Information Entry) of this CU */ | 651 | /* Get the DIE(Debugging Information Entry) of this CU */ |
652 | ret = dwarf_siblingof(__dw_debug, 0, &cu_die, &__dw_error); | 652 | ret = dwarf_siblingof(__dw_debug, 0, &cu_die, &__dw_error); |
653 | ERR_IF(ret != DW_DLV_OK); | 653 | DIE_IF(ret != DW_DLV_OK); |
654 | 654 | ||
655 | /* Check if target file is included. */ | 655 | /* Check if target file is included. */ |
656 | if (pp->file) | 656 | if (pp->file) |
@@ -659,7 +659,7 @@ int find_probepoint(int fd, struct probe_point *pp) | |||
659 | if (!pp->file || pf.fno) { | 659 | if (!pp->file || pf.fno) { |
660 | /* Save CU base address (for frame_base) */ | 660 | /* Save CU base address (for frame_base) */ |
661 | ret = dwarf_lowpc(cu_die, &pf.cu_base, &__dw_error); | 661 | ret = dwarf_lowpc(cu_die, &pf.cu_base, &__dw_error); |
662 | ERR_IF(ret == DW_DLV_ERROR); | 662 | DIE_IF(ret == DW_DLV_ERROR); |
663 | if (ret == DW_DLV_NO_ENTRY) | 663 | if (ret == DW_DLV_NO_ENTRY) |
664 | pf.cu_base = 0; | 664 | pf.cu_base = 0; |
665 | if (pp->line) | 665 | if (pp->line) |
@@ -670,7 +670,7 @@ int find_probepoint(int fd, struct probe_point *pp) | |||
670 | dwarf_dealloc(__dw_debug, cu_die, DW_DLA_DIE); | 670 | dwarf_dealloc(__dw_debug, cu_die, DW_DLA_DIE); |
671 | } | 671 | } |
672 | ret = dwarf_finish(__dw_debug, &__dw_error); | 672 | ret = dwarf_finish(__dw_debug, &__dw_error); |
673 | ERR_IF(ret != DW_DLV_OK); | 673 | DIE_IF(ret != DW_DLV_OK); |
674 | 674 | ||
675 | return pp->found; | 675 | return pp->found; |
676 | } | 676 | } |
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 6a7cb0c04e9e..d17fafc21351 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h | |||
@@ -1,16 +1,6 @@ | |||
1 | #ifndef _PROBE_FINDER_H | 1 | #ifndef _PROBE_FINDER_H |
2 | #define _PROBE_FINDER_H | 2 | #define _PROBE_FINDER_H |
3 | 3 | ||
4 | #define _stringify(n) #n | ||
5 | #define stringify(n) _stringify(n) | ||
6 | |||
7 | #define ERR_IF(cnd) \ | ||
8 | do { if (cnd) { \ | ||
9 | fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \ | ||
10 | "): " stringify(cnd) "\n"); \ | ||
11 | exit(1); \ | ||
12 | } } while (0) | ||
13 | |||
14 | #define MAX_PATH_LEN 256 | 4 | #define MAX_PATH_LEN 256 |
15 | #define MAX_PROBE_BUFFER 1024 | 5 | #define MAX_PROBE_BUFFER 1024 |
16 | #define MAX_PROBES 128 | 6 | #define MAX_PROBES 128 |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 9de2329dd44d..0daa341734f9 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -134,6 +134,15 @@ extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, | |||
134 | extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); | 134 | extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); |
135 | extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); | 135 | extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); |
136 | 136 | ||
137 | #include "../../../include/linux/stringify.h" | ||
138 | |||
139 | #define DIE_IF(cnd) \ | ||
140 | do { if (cnd) \ | ||
141 | die(" at (" __FILE__ ":" __stringify(__LINE__) "): " \ | ||
142 | __stringify(cnd) "\n"); \ | ||
143 | } while (0) | ||
144 | |||
145 | |||
137 | extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); | 146 | extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); |
138 | 147 | ||
139 | extern int prefixcmp(const char *str, const char *prefix); | 148 | extern int prefixcmp(const char *str, const char *prefix); |