* Called by KASSERT, this decides if we will panic * or if we will log via printf and/or ktr. */
| 766 | * or if we will log via printf and/or ktr. |
| 767 | */ |
| 768 | void |
| 769 | kassert_panic(const char *fmt, ...) |
| 770 | { |
| 771 | static char buf[256]; |
| 772 | va_list ap; |
| 773 | |
| 774 | va_start(ap, fmt); |
| 775 | (void)vsnprintf(buf, sizeof(buf), fmt, ap); |
| 776 | va_end(ap); |
| 777 | |
| 778 | /* |
| 779 | * If we are suppressing secondary panics, log the warning but do not |
| 780 | * re-enter panic/kdb. |
| 781 | */ |
| 782 | if (panicstr != NULL && kassert_suppress_in_panic) { |
| 783 | if (kassert_do_log) { |
| 784 | printf("KASSERT failed: %s\n", buf); |
| 785 | #ifdef KDB |
| 786 | if (trace_all_panics && trace_on_panic) |
| 787 | kdb_backtrace(); |
| 788 | #endif |
| 789 | } |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | /* |
| 794 | * panic if we're not just warning, or if we've exceeded |
| 795 | * kassert_log_panic_at warnings. |
| 796 | */ |
| 797 | if (!kassert_warn_only || |
| 798 | (kassert_log_panic_at > 0 && |
| 799 | kassert_warnings >= kassert_log_panic_at)) { |
| 800 | va_start(ap, fmt); |
| 801 | vpanic(fmt, ap); |
| 802 | /* NORETURN */ |
| 803 | } |
| 804 | #ifdef KTR |
| 805 | if (kassert_do_ktr) |
| 806 | CTR0(ktr_mask, buf); |
| 807 | #endif /* KTR */ |
| 808 | /* |
| 809 | * log if we've not yet met the mute limit. |
| 810 | */ |
| 811 | if (kassert_do_log && |
| 812 | (kassert_log_mute_at == 0 || |
| 813 | kassert_warnings < kassert_log_mute_at)) { |
| 814 | static struct timeval lasterr; |
| 815 | static int curerr; |
| 816 | |
| 817 | if (ppsratecheck(&lasterr, &curerr, kassert_log_pps_limit)) { |
| 818 | printf("KASSERT failed: %s\n", buf); |
| 819 | kdb_backtrace(); |
| 820 | } |
| 821 | } |
| 822 | #ifdef KDB |
| 823 | if (kassert_do_kdb) { |
| 824 | kdb_enter(KDB_WHY_KASSERT, buf); |
| 825 | } |
no test coverage detected