📄 oops.c
字号:
&re_Oops_eip_ia64_pmatch); i = regexec(&re_Oops_eip_ia64, line, re_Oops_eip_ia64.re_nsub+1, re_Oops_eip_ia64_pmatch, 0); DEBUG(4, "regexec eip_ia64 %d", i); if (i == 0) { re_string_check(re_Oops_eip_ia64.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_ia64, line, re_Oops_eip_ia64_pmatch, string); return((*string)[re_Oops_eip_ia64.re_nsub]); } /* MCA 'IP' line for ia64. [x]ip at start of line, space, '('regname'), * spaces, :, space, 0x, UNBRACKETED_ADDRESS. */ RE_COMPILE(&re_Oops_mca_ip_ia64, "[xi]ip *\\([^)]*\\) *: *" "0x" UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_mca_ip_ia64_pmatch); i = regexec(&re_Oops_mca_ip_ia64, line, re_Oops_mca_ip_ia64.re_nsub+1, re_Oops_mca_ip_ia64_pmatch, 0); DEBUG(4, "regexec mca_ip_ia64 %d", i); if (i == 0) { re_string_check(re_Oops_mca_ip_ia64.re_nsub+1, string_max, procname); re_strings(&re_Oops_mca_ip_ia64, line, re_Oops_mca_ip_ia64_pmatch, string); return((*string)[re_Oops_mca_ip_ia64.re_nsub]); } /* SGI kdb backtrace EIP. At start of line, 0x unbracketed * address, 0x unbracketed address, anything, '+0x'. The second * unbracketed address is the EIP. * The initial kdb reports has lines like * Entering kdb on processor 2 due to panic @ 0x5005f426 */ RE_COMPILE(&re_Oops_eip_kdb, "(" /* 1 */ "^0x" UNBRACKETED_ADDRESS /* 2 */ "0x" UNBRACKETED_ADDRESS /* 3 */ ".*+0x" ")" "|(" /* 4 */ "^Entering kdb on processor.*0x" UNBRACKETED_ADDRESS /* 5 */ ")", REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_eip_kdb_pmatch); i = regexec(&re_Oops_eip_kdb, line, re_Oops_eip_kdb.re_nsub+1, re_Oops_eip_kdb_pmatch, 0); DEBUG(4, "regexec kdb %d", i); if (i == 0) { re_string_check(re_Oops_eip_kdb.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_kdb, line, re_Oops_eip_kdb_pmatch, string); if ((*string)[3] && *((*string)[3])) return((*string)[3]); if ((*string)[5] && *((*string)[5])) return((*string)[5]); } /* Oops 'IRP' line for CRIS: "^IRP: " unbracketed address. * Keep spacing optional. */ RE_COMPILE(&re_Oops_eip_cris, "^ *IRP *: *" UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_eip_cris_pmatch); i = regexec(&re_Oops_eip_cris, line, re_Oops_eip_cris.re_nsub+1, re_Oops_eip_cris_pmatch, 0); DEBUG(4, "regexec cris %d", i); if (i == 0) { re_string_check(re_Oops_eip_cris.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_cris, line, re_Oops_eip_cris_pmatch, string); return((*string)[re_Oops_eip_cris.re_nsub]); } /* Oops 'EIP:' line for other architectures */ RE_COMPILE(&re_Oops_eip_other, "^(" "EIP: +.*" /* i386 */ "|RIP: +.*" /* x86_64 */ "|PC *= *" /* m68k, alpha */ "|pc *: *" /* arm */ ")" BRACKETED_ADDRESS , REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_eip_other_pmatch); i = regexec(&re_Oops_eip_other, line, re_Oops_eip_other.re_nsub+1, re_Oops_eip_other_pmatch, 0); DEBUG(4, "regexec other %d", i); if (i == 0) { re_string_check(re_Oops_eip_other.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_other, line, re_Oops_eip_other_pmatch, string); return((*string)[re_Oops_eip_other.re_nsub]); } return(NULL);}/* Look for the arm lr line, returns start of the relevant hex value */static char *Oops_arm_lr(const char *line, char ***string, int string_max){ int i; static regex_t re_Oops_arm_lr; static regmatch_t *re_Oops_arm_lr_pmatch; static const char procname[] = "Oops_arm_lr"; RE_COMPILE(&re_Oops_arm_lr, "pc *: *" BRACKETED_ADDRESS /* 1 */ " *lr *: *" BRACKETED_ADDRESS, /* 2 */ REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_arm_lr_pmatch); i = regexec(&re_Oops_arm_lr, line, re_Oops_arm_lr.re_nsub+1, re_Oops_arm_lr_pmatch, 0); DEBUG(4, "regexec %d", i); if (i == 0) { re_string_check(re_Oops_arm_lr.re_nsub+1, string_max, procname); re_strings(&re_Oops_arm_lr, line, re_Oops_arm_lr_pmatch, string); return((*string)[re_Oops_arm_lr.re_nsub]); } return(NULL);}/* Set the arm lr from the lr line */static void Oops_set_arm_lr(const char *value, SYMBOL_SET *ss){ static const char procname[] = "Oops_set_arm_lr"; addr_t ra; ra = hexstring(value); if (errno) { ERROR(" Invalid hex value in ra line, ignored - '%s'", value); perror(prefix); ra = 0; } add_symbol_n(ss, ra, 'R', 1, ">>LR; ");}/* Look for the alpha ra line, returns start of the relevant hex value */static char *Oops_alpha_ra(const char *line, char ***string, int string_max){ int i; static regex_t re_Oops_alpha_ra; static regmatch_t *re_Oops_alpha_ra_pmatch; static const char procname[] = "Oops_alpha_ra"; RE_COMPILE(&re_Oops_alpha_ra, "pc *= *" BRACKETED_ADDRESS /* 1 */ " *ra *= *" BRACKETED_ADDRESS, /* 2 */ REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_alpha_ra_pmatch); i = regexec(&re_Oops_alpha_ra, line, re_Oops_alpha_ra.re_nsub+1, re_Oops_alpha_ra_pmatch, 0); DEBUG(4, "regexec %d", i); if (i == 0) { re_string_check(re_Oops_alpha_ra.re_nsub+1, string_max, procname); re_strings(&re_Oops_alpha_ra, line, re_Oops_alpha_ra_pmatch, string); return((*string)[re_Oops_alpha_ra.re_nsub]); } return(NULL);}/* Set the alpha ra from the ra line */static void Oops_set_alpha_ra(const char *value, SYMBOL_SET *ss){ static const char procname[] = "Oops_set_alpha_ra"; addr_t ra; ra = hexstring(value); if (errno) { ERROR(" Invalid hex value in ra line, ignored - '%s'", value); perror(prefix); ra = 0; } add_symbol_n(ss, ra, 'R', 1, ">>RA; ");}/* Look for the alpha spinlock stuck line, returns TRUE with string[1] * containing the PC, string[2] containing the previous PC. */static int Oops_eip_alpha_spinlock(const char *line, char ***string, int string_max, OPTIONS *options){ int i; static regex_t re_Oops_eip_alpha_spinlock; static regmatch_t *re_Oops_eip_alpha_spinlock_pmatch; static const char procname[] = "Oops_eip_alpha_spinlock"; RE_COMPILE(&re_Oops_eip_alpha_spinlock, "^spinlock stuck at " UNBRACKETED_ADDRESS ".*owner.*at " UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_eip_alpha_spinlock_pmatch); i = regexec(&re_Oops_eip_alpha_spinlock, line, re_Oops_eip_alpha_spinlock.re_nsub+1, re_Oops_eip_alpha_spinlock_pmatch, 0); DEBUG(4, "regexec %d", i); if (i == 0) { re_string_check(re_Oops_eip_alpha_spinlock.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_alpha_spinlock, line, re_Oops_eip_alpha_spinlock_pmatch, string); return(1); } return(0);}/* Look for the sparc spinlock stuck line, returns TRUE with string[1] * containing the lock address, string[2] containing the caller PC, * string[3] containing the owning PC. */static int Oops_eip_sparc_spinlock(const char *line, char ***string, int string_max, OPTIONS *options){ int i; static regex_t re_Oops_eip_sparc_spinlock; static regmatch_t *re_Oops_eip_sparc_spinlock_pmatch; static const char procname[] = "Oops_eip_sparc_spinlock"; RE_COMPILE(&re_Oops_eip_sparc_spinlock, "^spin_lock[^ ]*\\(" UNBRACKETED_ADDRESS ".*stuck at *" UNBRACKETED_ADDRESS ".*PC\\(" UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_eip_sparc_spinlock_pmatch); i = regexec(&re_Oops_eip_sparc_spinlock, line, re_Oops_eip_sparc_spinlock.re_nsub+1, re_Oops_eip_sparc_spinlock_pmatch, 0); DEBUG(4, "regexec %d", i); if (i == 0) { re_string_check(re_Oops_eip_sparc_spinlock.re_nsub+1, string_max, procname); re_strings(&re_Oops_eip_sparc_spinlock, line, re_Oops_eip_sparc_spinlock_pmatch, string); return(1); } return(0);}/* Look for the mips ra line, returns start of the relevant hex value */static char *Oops_mips_ra(const char *line, char ***string, int string_max){ int i; static regex_t re_Oops_mips_ra; static regmatch_t *re_Oops_mips_ra_pmatch; static const char procname[] = "Oops_mips_ra"; /* Oops 'ra:' line for mips, ra, optional white space, one or * more '=', optional white space, unbracketed address. */ RE_COMPILE(&re_Oops_mips_ra, "ra *=+ *" UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_mips_ra_pmatch); i = regexec(&re_Oops_mips_ra, line, re_Oops_mips_ra.re_nsub+1, re_Oops_mips_ra_pmatch, 0); DEBUG(4, "regexec %d", i); if (i == 0) { re_string_check(re_Oops_mips_ra.re_nsub+1, string_max, procname); re_strings(&re_Oops_mips_ra, line, re_Oops_mips_ra_pmatch, string); return((*string)[re_Oops_mips_ra.re_nsub]); } return(NULL);}/* Set the mips ra from the ra line */static void Oops_set_mips_ra(const char *value, SYMBOL_SET *ss){ static const char procname[] = "Oops_set_mips_ra"; addr_t ra; ra = hexstring(value); if (errno) { ERROR(" Invalid hex value in ra line, ignored - '%s'", value); perror(prefix); ra = 0; } add_symbol_n(ss, ra, 'R', 1, ">>RA; ");}/* Extract mips registers. */static void Oops_mips_regs(const char *line, SYMBOL_SET *ss, const OPTIONS *options){ int i, reg_num; addr_t reg; char regname[7]; char **string = NULL; const char *p; static regex_t re_Oops_mips_regs; static regmatch_t *re_Oops_mips_regs_pmatch; static const char procname[] = "Oops_mips_regs"; RE_COMPILE(&re_Oops_mips_regs, "^(\\$[0-9]{1,2}) *: *" /* 1 */ UNBRACKETED_ADDRESS /* 2 */ , REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_mips_regs_pmatch); i = regexec(&re_Oops_mips_regs, line, re_Oops_mips_regs.re_nsub+1, re_Oops_mips_regs_pmatch, 0); DEBUG(4, "regexec %d", i); if (i) return; p = line + re_Oops_mips_regs_pmatch[0].rm_so + 1; reg_num = strtoul(p, NULL, 10); p = line + re_Oops_mips_regs_pmatch[2].rm_so; /* Loop over unbracketed addresses */ while (1) { if (regexec(&re_unbracketed_address, p, re_unbracketed_address.re_nsub+1, re_unbracketed_address_pmatch, 0) == 0) { re_strings(&re_unbracketed_address, p, re_unbracketed_address_pmatch, &string); reg = hexstring(string[1]); /* contents */ if (errno) { ERROR(" Invalid hex value in register line, ignored - '%s'", string[1]); perror(prefix); break; } reg = Oops_truncate_address(reg, options); snprintf(regname, sizeof(regname), ">>$%d;", reg_num); add_symbol_n(ss, reg, 'R', 1, regname); p += re_unbracketed_address_pmatch[0].rm_eo; ++reg_num; if (reg_num == 26) reg_num += 2; /* skip k0, k1 */ } else break; } if (*p) WARNING("garbage '%s' at end of mips register line ignored", p); re_strings_free(&re_unbracketed_address, &string);}/* Look for the ia64 b0 line and set all the values */static void Oops_set_ia64_b0(const char *line, char ***string, int string_max, SYMBOL_SET *ss){ int i; addr_t b; char label[6]; static regex_t re_Oops_ia64_b0; static regmatch_t *re_Oops_ia64_b0_pmatch; static const char procname[] = "Oops_ia64_b0"; /* Oops 'b0' line for ia64, b0 : unbracketed address, may be * repeated for b6, b7. MCA has b0 '('regname')' : 0x unbracketed address. */ RE_COMPILE(&re_Oops_ia64_b0, "^b[0-7] *(\\([^)]*\\) *)?: *(0x)?" UNBRACKETED_ADDRESS, REG_NEWLINE|REG_EXTENDED|REG_ICASE, &re_Oops_ia64_b0_pmatch); /* Scan entire line for b0, b6, b7 */ while(1) { i = regexec(&re_Oops_ia64_b0, line, re_Oops_ia64_b0.re_nsub+1, re_Oops_ia64_b0_pmatch, 0); DEBUG(4, "regexec %d", i); if (i) break; re_string_check(re_Oops_ia64_b0.re_nsub+1, string_max, procname); re_strings(&re_Oops_ia64_b0, line, re_Oops_ia64_b0_pmatch, string); strcpy(label, ">>bx; "); label[3] = line[1]; /* register number */ b = hexstring((*string)[re_Oops_ia64_b0.re_nsub]); if (errno) { ERROR(" Invalid hex value in b%c line, ignored - '%s'", line[1], (*string)[re_Oops_ia64_b0.re_nsub]); perror(prefix); b = 0; } add_symbol_n(ss, b, 'R', 1, label); line += re_Oops_ia64_b0_pmatch[0].rm_eo; }}/* Look for the sparc register dump lines end */static int Oops_sparc_regdump(const char *line, char ***string){ int i; static regex_t re_Oops_sparc_regdump; static regmatch_t *re_Oops_sparc_regdump_pmatch; static const char procname[] = "Oops_sparc_regdump"; RE_COMPILE(&re_Oops_sparc_regdump, "^(" "i[04]: "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -