| 576 | } |
| 577 | |
| 578 | TinyDBR::IndirectInstrumentation TinyDBR::ShouldInstrumentIndirect( |
| 579 | ModuleInfo* module, |
| 580 | Instruction& inst, |
| 581 | size_t instruction_address) |
| 582 | { |
| 583 | |
| 584 | if (inst.iclass == InstructionClass::RET) |
| 585 | { |
| 586 | if (!patch_return_addresses) |
| 587 | { |
| 588 | return II_NONE; |
| 589 | } |
| 590 | } |
| 591 | else |
| 592 | { |
| 593 | if ((inst.iclass != InstructionClass::IJUMP) && |
| 594 | (inst.iclass != InstructionClass::ICALL)) |
| 595 | return II_NONE; |
| 596 | } |
| 597 | |
| 598 | if (indirect_instrumentation_mode != II_AUTO) |
| 599 | { |
| 600 | return indirect_instrumentation_mode; |
| 601 | } |
| 602 | else |
| 603 | { |
| 604 | // default to the most performant mode which is II_GLOBAL |
| 605 | #ifdef ARM64 |
| 606 | return II_LOCAL; |
| 607 | #else |
| 608 | return II_GLOBAL; |
| 609 | #endif |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | // when an invalid instruction is encountered |
| 614 | // emit a breakpoint followed by crashing the process |