* Evaluate a matching. */
| 2594 | * Evaluate a matching. |
| 2595 | */ |
| 2596 | bool matchEval(const MatchExpr *expr, const ELF &elf, |
| 2597 | const std::vector<Instr> &Is, size_t idx, const InstrInfo *I) |
| 2598 | { |
| 2599 | if (option_debug) |
| 2600 | { |
| 2601 | debug("%s0x%lx%s:\tinstr %s%s%s", |
| 2602 | (option_is_tty? "\33[31m": ""), I->address, |
| 2603 | (option_is_tty? "\33[0m": ""), (option_is_tty? "\33[32m": ""), |
| 2604 | I->string.instr, (option_is_tty? "\33[0m": "")); |
| 2605 | } |
| 2606 | uint8_t scratch[PATH_MAX+1]; |
| 2607 | static_assert(sizeof(scratch) >= 64 * sizeof(MatchVal), |
| 2608 | "scratch too small"); |
| 2609 | MatchVal result = matchCastToBool(matchDoEval(expr, elf, Is, idx, I, |
| 2610 | scratch)); |
| 2611 | bool pass = (result.i != 0); |
| 2612 | if (option_debug) |
| 2613 | { |
| 2614 | std::string str_expr, str_val; |
| 2615 | dumpExpr(*expr, str_expr); |
| 2616 | dumpVal(result, str_val); |
| 2617 | debug("%s0x%lx%s: expr %s = %s%s%s", |
| 2618 | (option_is_tty? "\33[31m": ""), I->address, |
| 2619 | (option_is_tty? "\33[0m": ""), str_expr.c_str(), |
| 2620 | (option_is_tty? (pass? "\33[32m": "\33[31m"): ""), |
| 2621 | (pass? "TRUE": "FALSE"), |
| 2622 | (option_is_tty? "\33[0m": ""), |
| 2623 | str_val.c_str()); |
| 2624 | } |
| 2625 | return pass; |
| 2626 | } |
| 2627 |
no test coverage detected