Print this page
armv6: bop_panic should hexdump the stack
It's the little things that make debugging easier.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/armv6/os/fakebop.c
          +++ new/usr/src/uts/armv6/os/fakebop.c
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27  #include <sys/varargs.h>
  28   28  #include <sys/cmn_err.h>
  29   29  #include <sys/sysmacros.h>
  30   30  #include <sys/systm.h>
  31   31  #include <sys/ctype.h>
  32   32  #include <sys/bootstat.h>
  33   33  #include <sys/privregs.h>
  34   34  #include <sys/cpu_asm.h>
  35   35  #include <sys/boot_mmu.h>
  36   36  #include <sys/elf.h>
       37 +#include <sys/archsystm.h>
  37   38  
  38   39  static bootops_t bootop;
  39   40  
  40   41  /*
  41   42   * Debugging help
  42   43   */
  43   44  static int fakebop_prop_debug = 0;
  44   45  static int fakebop_alloc_debug = 0;
  45   46  static int fakebop_atag_debug = 0;
  46   47  
↓ open down ↓ 59 lines elided ↑ open up ↑
 106  107   */
 107  108  typedef struct bootprop {
 108  109          struct bootprop *bp_next;
 109  110          char *bp_name;
 110  111          uint_t bp_vlen;
 111  112          char *bp_value;
 112  113  } bootprop_t;
 113  114  
 114  115  static bootprop_t *bprops = NULL;
 115  116  
      117 +static void
      118 +hexdump_stack()
      119 +{
      120 +        extern char t0stack[];
      121 +
      122 +        uint8_t *start = (uint8_t *)t0stack;
      123 +        uint8_t *end = start + DEFAULTSTKSZ;
      124 +        uint8_t *ptr;
      125 +        int i;
      126 +
      127 +        bop_printf(NULL, "stack (fp = %x):\n", getfp());
      128 +
      129 +        ptr = (uint8_t *)(getfp() & ~0xf);
      130 +        if (ptr <= start || ptr >= end)
      131 +                ptr = start;
      132 +
      133 +        while (ptr < end) {
      134 +                uint32_t *tmp = (uint32_t *)ptr;
      135 +
      136 +                bop_printf(NULL, "%p: %08x %08x %08x %08x\n", ptr,
      137 +                    tmp[0], tmp[1], tmp[2], tmp[3]);
      138 +
      139 +                ptr += 16;
      140 +        }
      141 +
      142 +}
      143 +
 116  144  void
 117  145  bop_panic(const char *msg)
 118  146  {
 119      -        bop_printf(NULL, "ARM bop_panic:\n%s\nSpinning Forever...", msg);
      147 +        bop_printf(NULL, "ARM bop_panic:\n%s\n", msg);
      148 +
      149 +        hexdump_stack();
      150 +
      151 +        bop_printf(NULL, "Spinning Forever...", msg);
 120  152          for (;;)
 121  153                  ;
 122  154  }
 123  155  
 124  156  /*
 125  157   * XXX This is just a hack to let us see a bit more about what's going on.
 126  158   * Normally we'd use vsnprintf, but that includes sys/systm.h which requires
 127  159   * almost every header platform header in the world. Also, we're using hex,
 128  160   * because hex is cool. Actually, we're really using it because it means we can
 129  161   * bitshift instead of divide. There is no integer division in ARMv6 natively.
↓ open down ↓ 797 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX