예제 #1
0
파일: cleanup.c 프로젝트: mmmmhack/gstep
int cleanup() {
	// shutdown child
	gdb_write("quit\n");
  int rc = wait_for_child_gone();
  if(!rc)
    rc = term_child();
  return rc;
}
예제 #2
0
void
handle_exception (int exceptionVector)
{
  int sigval, stepping;
  int addr, length, i;
  unsigned char *ptr;
  unsigned char buf[16];
  int binary;

  if (!finish_from_step ())
    return;			/* "false step": let the target continue */

  gdb_m32r_vector = exceptionVector;

  if (remote_debug)
    {
      mem2hex ((unsigned char *) &exceptionVector, buf, 4, 0);
      gdb_error ("Handle exception %s, ", buf);
      mem2hex ((unsigned char *) &registers[PC], buf, 4, 0);
      gdb_error ("PC == 0x%s\n", buf);
    }

  /* reply to host that an exception has occurred */
  sigval = computeSignal (exceptionVector);

  ptr = remcomOutBuffer;

  *ptr++ = 'T';			/* notify gdb with signo, PC, FP and SP */
  *ptr++ = hexchars[sigval >> 4];
  *ptr++ = hexchars[sigval & 0xf];

  *ptr++ = hexchars[PC >> 4];
  *ptr++ = hexchars[PC & 0xf];
  *ptr++ = ':';
  ptr = mem2hex ((unsigned char *) &registers[PC], ptr, 4, 0);	/* PC */
  *ptr++ = ';';

  *ptr++ = hexchars[R13 >> 4];
  *ptr++ = hexchars[R13 & 0xf];
  *ptr++ = ':';
  ptr = mem2hex ((unsigned char *) &registers[R13], ptr, 4, 0);	/* FP */
  *ptr++ = ';';

  *ptr++ = hexchars[R15 >> 4];
  *ptr++ = hexchars[R15 & 0xf];
  *ptr++ = ':';
  ptr = mem2hex ((unsigned char *) &registers[R15], ptr, 4, 0);	/* SP */
  *ptr++ = ';';
  *ptr++ = 0;

  if (exceptionVector == 0)	/* simulated SYS call stuff */
    {
      mem2hex ((unsigned char *) &registers[PC], buf, 4, 0);
      switch (registers[R0])
	{
	case SYS_exit:
	  gdb_error ("Target program has exited at %s\n", buf);
	  ptr = remcomOutBuffer;
	  *ptr++ = 'W';
	  sigval = registers[R1] & 0xff;
	  *ptr++ = hexchars[sigval >> 4];
	  *ptr++ = hexchars[sigval & 0xf];
	  *ptr++ = 0;
	  break;
	case SYS_open:
	  gdb_error ("Target attempts SYS_open call at %s\n", buf);
	  break;
	case SYS_close:
	  gdb_error ("Target attempts SYS_close call at %s\n", buf);
	  break;
	case SYS_read:
	  gdb_error ("Target attempts SYS_read call at %s\n", buf);
	  break;
	case SYS_write:
	  if (registers[R1] == 1 ||	/* write to stdout  */
	      registers[R1] == 2)	/* write to stderr  */
	    {			/* (we can do that) */
	      registers[R0] =
		gdb_write ((void *) registers[R2], registers[R3]);
	      return;
	    }
	  else
	    gdb_error ("Target attempts SYS_write call at %s\n", buf);
	  break;
	case SYS_lseek:
	  gdb_error ("Target attempts SYS_lseek call at %s\n", buf);
	  break;
	case SYS_unlink:
	  gdb_error ("Target attempts SYS_unlink call at %s\n", buf);
	  break;
	case SYS_getpid:
	  gdb_error ("Target attempts SYS_getpid call at %s\n", buf);
	  break;
	case SYS_kill:
	  gdb_error ("Target attempts SYS_kill call at %s\n", buf);
	  break;
	case SYS_fstat:
	  gdb_error ("Target attempts SYS_fstat call at %s\n", buf);
	  break;
	default:
	  gdb_error ("Target attempts unknown SYS call at %s\n", buf);
	  break;
	}
    }