Exemple #1
0
void dbg_processReg()
{
     char ch;
     int regno;
     unsigned int val;
     int nd;

     ch = dbg_getchar();
     switch(ch) {
     case '?': DispRegs(); break;
     default:
         if (isdigit(ch)) {
             linendx--;
             regno = dbg_getDecNumber();
             ch = dbg_nextNonSpace();
             switch(ch) {
             case '?':
                  DispReg(regno);
                  return;
             case '=':
                  nd = dbg_getHexNumber(&val);  
                  if (nd > 0) {
                         regs[regno] = val;
                  }
                  return;
             default:
                  return;
             }
         }
         return;
     }
}
Exemple #2
0
pascal int dbg_getHexNumber(unsigned int *ad)
{
     char ch;
     unsigned int num;
     int nd;  // number of digits

     num = 0;
     nd = 0;
     dbg_nextNonSpace();
     linendx--;
     while (1) {
           ch = dbg_getchar();
           if (ch >= '0' && ch <= '9')
               num = (num << 4) | (ch - '0');
           else if (ch >= 'A' && ch <= 'F')
               num = (num << 4) | (ch - 'A' + 10);
           else if (ch >= 'a' && ch <= 'f')
               num = (num << 4) | (ch - 'a' + 10);
           else {
                *ad = num;
                return nd;
           }
           nd = nd + 1;
     }    
}
Exemple #3
0
char dbg_nextSpace()
{
    char ch;

    do {
      ch = dbg_getchar();
      if (ch==-1)
           break;
    } while (ch != ' ');
    return ch;
}
Exemple #4
0
char dbg_nextNonSpace()
{
     char ch;

     while (linendx < 84) {
           ch = dbg_getchar();
           if (ch!=' ' || ch==-1)
               return ch;
     }
     return -1;
}
Exemple #5
0
void dbg_getDumpFormat()
{
     int nn;
     char ch;
     unsigned int ui;
     unsigned int ad;

     nn = dbg_getDecNumber(&ui);
     if (nn > 0) currep = ui;
     ch = dbg_getchar();
     switch(ch) {
     case 'i':
          curfmt = 'i';
          nn = dbg_getHexNumber(&ad);
          if (nn > 0)
              curaddr = ad;
          break;
     case 's':
          curfmt = 's';
          nn = dbg_getHexNumber(&ad);
          if (nn > 0)
             curaddr = ad;
          break;
     case 'x':
          curfmt = 'x';
          ch = dbg_getchar();
          switch(ch) {
          case 'b': cursz = 'b'; muol = 16; break;
          case 'c': cursz = 'c'; muol = 8; break;
          case 'h': cursz = 'h'; muol = 4; break;
          case 'w': cursz = 'w'; muol = 2; break;
          default: linendx--;
          }
          nn = dbg_getHexNumber(&ad);
          if (nn > 0) curaddr = ad;
          break;
     }
}
Exemple #6
0
pascal int dbg_getDecNumber(int *n)
{
    int num;
    char ch;
    int nd;

    if (n==(int *)0) return 0;
    num = 0;
    nd = 0;
     while(isdigit(ch=dbg_getchar())) {
        num = num * 10 + (ch - '0');
        nd++;
    }
    linendx--;
    *n = num;
    return nd;
}
Exemple #7
0
/**
 * Wait for input
 * \param keys pointer to buffer to store inputs
 * \param nb_keys max number of keys
 * \param ctrl_flags flags to control inputs (DBGIN_ECHO_ON, DBGIN_NUM_ONLY,
 *                   DBGIN_WANT_ESC and DBGIN_WANT_CR can be used)
 * \return -1 if ESC, else number of input chars
 */
static int _app_dbg_input(uint8_t *keys, int nb_keys, uint32_t ctrl_flags)
{
	uint8_t key;
	int i;
	for (i = 0; i < nb_keys;) {
		if (!dbg_rx_ready()) {
			continue;
		}

		key = dbg_getchar();
		if (key == CR) {
			if (DBGIN_WANT_CR & ctrl_flags) {
				keys[i++] = 0;
				break;
			}

			/* Ignore */
			continue;
		} else if (key == ESC) {
			if (DBGIN_WANT_ESC & ctrl_flags) {
				keys[0] = 0;
				return -1;
			}
		} else {
			if (DBGIN_NUM_ONLY & ctrl_flags) {
				if (key < '0' || key > '9') {
					/* Not accepted */
					continue;
				}
			}

			if (key <= ' ' || key >= 'z') {
				/* Not accepted */
				continue;
			}
		}

		if (ctrl_flags & DBGIN_ECHO_ON) {
			dbg_putchar(key);
		}

		keys[i++] = key;
	}
	return i;
}
Exemple #8
0
void debug_kdb_handler(void)
{
	kdb_handler(dbg_getchar());
}
Exemple #9
0
int dbg_parse_line()
{
    char ch;
    unsigned int ad;
    unsigned int ln;
    unsigned int regno;
    unsigned int ui;
    int nn;
    int n2;

    while (linendx < 84) {
        ch = dbg_getchar();
        switch (ch) {
        case -1: return;
        case ' ': break;
        case '?': dbg_DisplayHelp(); break;
        case 'q': return 1;
        case 'a': dbg_arm(dbg_dbctrl); break;
        case 'i':
             ch = dbg_getchar();
             switch(ch) {
             case '?':  // query instruction breakpoints
                  if (((dbg_dbctrl & 0x030000)==0) && (dbg_dbctrl & 1) == 1)
                      printf("i0=%08X\r\n", dbg_GetDBAD(0));
                  if (((dbg_dbctrl & 0x300000)==0) && (dbg_dbctrl & 2) == 2)
                      printf("i1=%08X\r\n", dbg_GetDBAD(1));
                  if (((dbg_dbctrl & 0x3000000)==0) && (dbg_dbctrl & 4) == 4)
                      printf("i2=%08X\r\n", dbg_GetDBAD(2));
                  if (((dbg_dbctrl & 0x30000000)==0) && (dbg_dbctrl & 8) == 8)
                      printf("i2=%08X\r\n", dbg_GetDBAD(3));
                  break;
             case '0':  dbg_ReadSetIB(0); break;
             case '1':  dbg_ReadSetIB(1); break;
             case '2':  dbg_ReadSetIB(2); break;
             case '3':  dbg_ReadSetIB(3); break;
             }
             break;
        case 'd':
             ch = dbg_getchar();
             switch(ch) {
             case 'i':
                  dbg_nextSpace();
                  nn = dbg_getHexNumber(&ad);
                  if (nn > 0) {
                      n2 = dbg_getDecNumber(&ln);
                      if (n2 > 0) {
                          for (; n2 > 0; n2--)
                              disassem(&ad,0);
                      }
                      else
                          disassem20(ad,0);
                  }
                  break;
             case '?':  // query instruction breakpoints
                  printf("\r\n");
                  if (((dbg_dbctrl & 0x030000)==0x30000) && (dbg_dbctrl & 1) == 1)
                      printf("d0=%08X\r\n", dbg_GetDBAD(0));
                  if (((dbg_dbctrl & 0x300000)==0x300000) && (dbg_dbctrl & 2) == 2)
                      printf("d1=%08X\r\n", dbg_GetDBAD(1));
                  if (((dbg_dbctrl & 0x3000000)==0x3000000) && (dbg_dbctrl & 4) == 4)
                      printf("d2=%08X\r\n", dbg_GetDBAD(2));
                  if (((dbg_dbctrl & 0x30000000)==0x30000000) && (dbg_dbctrl & 8) == 8)
                      printf("d2=%08X\r\n", dbg_GetDBAD(3));
                  break;
              case '0':  dbg_ReadSetDB(0); break;
              case '1':  dbg_ReadSetDB(1); break;
              case '2':  dbg_ReadSetDB(2); break;
              case '3':  dbg_ReadSetDB(3); break;
              case 's':
                  ch = dbg_getchar();
                  switch(ch) {
                  case '?':
                      if (((dbg_dbctrl & 0x030000)==0x10000) && (dbg_dbctrl & 1) == 1)
                          printf("ds0=%08X\r\n", dbg_GetDBAD(0));
                      if (((dbg_dbctrl & 0x300000)==0x100000) && (dbg_dbctrl & 2) == 2)
                          printf("ds1=%08X\r\n", dbg_GetDBAD(1));
                      if (((dbg_dbctrl & 0x3000000)==0x1000000) && (dbg_dbctrl & 4) == 4)
                          printf("ds2=%08X\r\n", dbg_GetDBAD(2));
                      if (((dbg_dbctrl & 0x30000000)==0x10000000) && (dbg_dbctrl & 8) == 8)
                          printf("ds2=%08X\r\n", dbg_GetDBAD(3));
                      break;
                  case '0':  dbg_ReadSetDSB(0); break;
                  case '1':  dbg_ReadSetDSB(1); break;
                  case '2':  dbg_ReadSetDSB(2); break;
                  case '3':  dbg_ReadSetDSB(3); break;
                  }
                  break;
              default:
                  dbg_nextSpace();
                  dbg_SetDBAD(0,0);
                  dbg_SetDBAD(1,0);
                  dbg_SetDBAD(2,0);
                  dbg_SetDBAD(3,0);
                  dbg_arm(0);
                  break;
             }
             break;
        case 'r': dbg_processReg(); break;
        case 's':
             ch = dbg_getchar();
             if (ch=='s') {
                  ch = dbg_getchar();
                  if (ch=='-') {
                      dbg_dbctrl &= 0x3FFFFFFFFFFFFFFFL;
                      dbg_arm(dbg_dbctrl);
                      ssm = 0;
                  }
                  else if (ch=='+' || ch=='m') {
                      dbg_dbctrl |= 0x4000000000000000L;                 
                      dbg_arm(dbg_dbctrl);
                      ssm = 1;
                      return 1;
                  }
             }
             break;
        case 'f':
             ch = dbg_getchar();
             if (ch=='/')
                 dbg_getDumpFormat();
             ch = dbg_getchar();
             if (ch==',') {
                 if (curfmt=='x')
                     nn = dbg_getHexNumber(&ui);
                 else
                     nn = dbg_getDecNumber(&ui);
                 if (nn > 0)
                     curfill = ui;
             }
             switch(curfmt) {
             case 'x':
                  switch(cursz) {
                  case 'b':
                       for (nn = 0; nn < currep; nn++)
                           bmem[ad+nn] = curfill;
                       break;
                  case 'c':
                       for (nn = 0; nn < currep; nn++)
                           cmem[ad/2+nn] = curfill;
                       break;
                  case 'h':
                       for (nn = 0; nn < currep; nn++)
                           hmem[ad/4+nn] = curfill;
                       break;
                  case 'w':
                       for (nn = 0; nn < currep; nn++)
                           wmem[ad/8+nn] = curfill;
                       break;
                  }
             }
             break;
        case 'x':
             ch = dbg_getchar();
             if (ch=='/') {
                 dbg_getDumpFormat();
             }
             switch(curfmt) {
             case 'i':
                  printf("\r\n");
                  for (nn = 0; nn < currep; nn++) {
                      if (getcharNoWait()==3)
                         break;
                      disassem(&curaddr,0);
                  }
                  break;
             case 's':
                  for (nn = 0; nn < currep; nn++) {
                      if (getcharNoWait()==3)
                         break;
                      curaddr += putstr(&cmem[curaddr/2],84) * 2;
                      printf("\r\n");
                  }
                  break;
             case 'x':
                  for (nn = 0; nn < currep; nn++) {
                      if (getcharNoWait()==3)
                         break;
                      if ((nn % muol)==0) {
                          switch(cursz) {
                          case 'b': printf("\r\n%06X ", curaddr+nn); break;
                          case 'c': printf("\r\n%06X ", curaddr+nn*2); break;
                          case 'h': printf("\r\n%06X ", curaddr+nn*4); break;
                          case 'w': printf("\r\n%06X ", curaddr+nn*8); break;
                          }
                      }
                      asm {; right here ; };
                      switch(cursz) {
                      case 'b': printf("%02X ", bmem[curaddr+nn]); break;
                      case 'c': printf("%04X ", cmem[curaddr/2+nn]); break;
                      case 'h': printf("%08X ", hmem[curaddr/4+nn]); break;
                      case 'w': printf("%016X ", wmem[curaddr/8+nn]); break;
                      }
                  }
                  switch(cursz) {
                  case 'b': curaddr += nn; break;
                  case 'c': curaddr += nn * 2; break;
                  case 'h': curaddr += nn * 4; break;
                  case 'w': curaddr += nn * 8; break;
                  }
                  printf("\r\n");
                  break;
             }
        }
    }
    return 0;
}