Changeset 14291


Ignore:
Timestamp:
Sep 20, 2010, 7:05:26 PM (9 years ago)
Author:
rme
Message:

In describe_memfault(), use new function describe_siginfo() to
show the resason for the fault.

In describe_info(), add a comment describing why it's a no-op
for Windows, FreeBSD, and Darwin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/lisp-debug.c

    r14275 r14291  
    292292}
    293293
     294void
     295describe_siginfo(siginfo_t *info)
     296{
     297#if defined(WINDOWS) || defined(FREEBSD) || defined(DARWIN)
     298  /*
     299   * It's not surprising that Windows doesn't have this signal stuff.
     300   * It is somewhat surprising that FreeBSD 6.x lacks the si_code
     301   * constants.  (Subsequent FreeBSD versions define them, though.)
     302   *
     303   * On Darwin, recall that we handle exceptions at the Mach level,
     304   * and build a "fake" signal context ourselves.  We don't try very
     305   * hard to translate the Mach exception information to Unix-style
     306   * information, so avoid printing out possibly-misleading garbage.
     307   * (bsd/dev/i386/unix_signal.c from the xnu sources is where that
     308   * happens for Mac OS X's own Mach-exception-to-Unix-signal
     309   * translation.
     310   */
     311#else
     312  if (info->si_code > 0) {
     313    if (info->si_signo == SIGSEGV) {
     314      switch (info->si_code) {
     315      case SEGV_MAPERR:
     316        fprintf(dbgout, "address not mapped to object\n");
     317        break;
     318      case SEGV_ACCERR:
     319        fprintf(dbgout, "invalid permissions for mapped object\n");
     320        break;
     321      default:
     322        fprintf(dbgout, "unexpected si_code value: %d\n", info->si_code);
     323        break;
     324      }
     325    } else if (info->si_signo == SIGBUS) {
     326      switch (info->si_code) {
     327      case BUS_ADRALN:
     328        fprintf(dbgout, "invalid address alignment\n");
     329        break;
     330      case BUS_ADRERR:
     331        fprintf(dbgout, "non-existent physical address");
     332        break;
     333      case BUS_OBJERR:
     334        fprintf(dbgout, "object-specific hardware error");
     335        break;
     336      default:
     337        fprintf(dbgout, "unexpected si_code value: %d\n", info->si_code);
     338      }
     339    }
     340  }
     341#endif
     342}
    294343
    295344void
     
    304353          dsisr & (1<<27) ? "protected" : "unmapped",
    305354          addr);
    306 #elif defined(WINDOWS) || defined(FREEBSD)
    307   /*
    308    * It's not surprising that Windows doesn't have this signal stuff.
    309    * It is somewhat surprising that FreeBSD 6.x lacks the si_code
    310    * constants.  (Subsequent FreeBSD versions define them, though.)
    311    */
    312355#else
    313356  if (info) {
    314357    fprintf(dbgout, "received signal %d; faulting address: %p\n",
    315358            info->si_signo, info->si_addr);
    316     if (info->si_code > 0) {
    317       if (info->si_signo == SIGSEGV) {
    318         switch (info->si_code) {
    319         case SEGV_MAPERR:
    320           fprintf(dbgout, "address not mapped to object\n");
    321           break;
    322         case SEGV_ACCERR:
    323           fprintf(dbgout, "invalid permissions for mapped object\n");
    324           break;
    325         default:
    326           fprintf(dbgout, "unexpected si_code value: %d\n", info->si_code);
    327           break;
    328         }
    329       } else if (info->si_signo == SIGBUS) {
    330         switch (info->si_code) {
    331         case BUS_ADRALN:
    332           fprintf(dbgout, "invalid address alignment\n");
    333           break;
    334         case BUS_ADRERR:
    335           fprintf(dbgout, "non-existent physical address");
    336           break;
    337         case BUS_OBJERR:
    338           fprintf(dbgout, "object-specific hardware error");
    339           break;
    340         default:
    341           fprintf(dbgout, "unexpected si_code value: %d\n", info->si_code);
    342         }
    343       }
    344     }
     359    describe_siginfo(info);
    345360  }
    346361#endif
Note: See TracChangeset for help on using the changeset viewer.