| 581 | } |
| 582 | |
| 583 | Error Profiler::installTraps(const char* begin, const char* end, bool nostop) { |
| 584 | const void* begin_addr = NULL; |
| 585 | if (begin != NULL && (begin_addr = resolveSymbol(begin)) == NULL) { |
| 586 | return Error("Begin address not found"); |
| 587 | } |
| 588 | |
| 589 | const void* end_addr = NULL; |
| 590 | if (end != NULL && (end_addr = resolveSymbol(end)) == NULL) { |
| 591 | return Error("End address not found"); |
| 592 | } |
| 593 | |
| 594 | // Having 'begin' and 'end' traps at the same address would result in an infinite loop |
| 595 | if (begin_addr && begin_addr == end_addr) { |
| 596 | return Error("begin and end symbols should not resolve to the same address"); |
| 597 | } |
| 598 | |
| 599 | _begin_trap.assign(begin_addr); |
| 600 | _end_trap.assign(end_addr); |
| 601 | _nostop = nostop; |
| 602 | |
| 603 | if (_begin_trap.entry() == 0) { |
| 604 | _engine->enableEvents(true); |
| 605 | } else { |
| 606 | _engine->enableEvents(nostop); |
| 607 | if (!_begin_trap.install()) { |
| 608 | return Error("Cannot install begin breakpoint"); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | return Error::OK; |
| 613 | } |
| 614 | |
| 615 | void Profiler::uninstallTraps() { |
| 616 | _begin_trap.uninstall(); |
nothing calls this directly
no test coverage detected