MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / installTraps

Method installTraps

src/profiler.cpp:583–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583Error 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
615void Profiler::uninstallTraps() {
616 _begin_trap.uninstall();

Callers

nothing calls this directly

Calls 6

resolveSymbolFunction · 0.85
ErrorClass · 0.85
assignMethod · 0.80
enableEventsMethod · 0.80
installMethod · 0.80
entryMethod · 0.45

Tested by

no test coverage detected