Ejemplo n.º 1
0
int main(void)
{
    List array[MAXN];
    int n, i;

    init(array);

    while (scanf("%d", &n) && n != 0)
        printf("%d\n", findm(array, n));

    return 0;
}
Ejemplo n.º 2
0
int main(void)
{
    int k, i;
    int answer[MAX];

    for (i = 0; i < MAX; i++)
        answer[i] = findm(i + 1);

    while (scanf("%d", &k) && k != 0)
        printf("%d\n", answer[k - 1]);

    return 0;
}
Ejemplo n.º 3
0
int main(void)
{
    List array[MAXN];
    int n, i;
    int ans[MAXN];

    init(array);

    for (i = 3; i < MAXN + 1; i++)
        ans[i - 1] = findm(array, i);

    while (scanf("%d", &n) && n != 0)
        printf("%d\n", ans[n - 1]);

    return 0;
}
Ejemplo n.º 4
0
// get_debug_command()
//
// Read a command from standard input.
// This is useful when you have a debugger
// which doesn't support calling into functions.
//
void get_debug_command()
{
  ssize_t count;
  int i,j;
  bool gotcommand;
  intptr_t addr;
  char buffer[256];
  nmethod *nm;
  methodOop m;

  tty->print_cr("You have entered the diagnostic command interpreter");
  tty->print("The supported commands are:\n");
  for ( i=0; ; i++ ) {
    if ( CommandList[i].code == CMDID_ILLEGAL )
      break;
    tty->print_cr("  %s \n", CommandList[i].name );
  }

  while ( 1 ) {
    gotcommand = false;
    tty->print("Please enter a command: ");
    count = scanf("%s", buffer) ;
    if ( count >=0 ) {
      for ( i=0; ; i++ ) {
        if ( CommandList[i].code == CMDID_ILLEGAL ) {
          if (!gotcommand) tty->print("Invalid command, please try again\n");
          break;
        }
        if ( strcmp(buffer, CommandList[i].name) == 0 ) {
          gotcommand = true;
          switch ( CommandList[i].code ) {
              case CMDID_PS:
                ps();
                break;
              case CMDID_PSS:
                pss();
                break;
              case CMDID_PSF:
                psf();
                break;
              case CMDID_FINDM:
                tty->print("Please enter the hex addr to pass to findm: ");
                scanf("%I64X", &addr);
                m = (methodOop)findm(addr);
                tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m);
                break;
              case CMDID_FINDNM:
                tty->print("Please enter the hex addr to pass to findnm: ");
                scanf("%I64X", &addr);
                nm = (nmethod*)findnm(addr);
                tty->print("findnm(0x%I64X) returned 0x%I64X\n", addr, nm);
                break;
              case CMDID_PP:
                tty->print("Please enter the hex addr to pass to pp: ");
                scanf("%I64X", &addr);
                pp((void*)addr);
                break;
              case CMDID_EXIT:
                exit(0);
              case CMDID_HELP:
                tty->print("Here are the supported commands: ");
                for ( j=0; ; j++ ) {
                  if ( CommandList[j].code == CMDID_ILLEGAL )
                    break;
                  tty->print_cr("  %s --  %s\n", CommandList[j].name,
                                                 CommandList[j].description );
                }
                break;
              case CMDID_QUIT:
                return;
                break;
              case CMDID_BPT:
                BREAKPOINT;
                break;
              case CMDID_VERIFY:
                verify();;
                break;
              case CMDID_THREADS:
                threads();;
                break;
              case CMDID_HSFIND:
                tty->print("Please enter the hex addr to pass to hsfind: ");
                scanf("%I64X", &addr);
                tty->print("Calling hsfind(0x%I64X)\n", addr);
                hsfind(addr);
                break;
              default:
              case CMDID_ILLEGAL:
                break;
          }
        }
      }
    }
  }
}