예제 #1
0
static void jdwp_vm_classes(jdwp_command_packet cmd) {
  w_int length;
  w_ubyte *sig;
  w_string sig_string;
  w_fifo fifo_of_fifos;
  w_fifo clazz_fifo;
  w_fifo one_fifo;
  w_clazz clazz;

  woempa(7, "Searching all class loaders for all loaded classes\n");
  fifo_of_fifos = forEachClassLoader(getAllLoadedClasses);
  if (fifo_of_fifos) {
    woempa(7, "Found %d class loaders\n", occupancyOfFifo(fifo_of_fifos));
    clazz_fifo = allocFifo(254);
    while ((one_fifo = getFifo(fifo_of_fifos))) {
      woempa(7, "Reading fifo %p\n", one_fifo);
      while ((clazz = getFifo(one_fifo))) {
        if (!clazzIsPrimitive(clazz)) {
          woempa(1, "  %K -> clazz_fifo\n", clazz);
          putFifo(clazz, clazz_fifo);
        }
        else {
          woempa(7, "  %K is primitive class, ignoring\n", clazz);
        }
      }
      woempa(7, "Releasing fifo %p\n", one_fifo);
      releaseFifo(one_fifo);
    }
    woempa(7, "Found %d classes\n", occupancyOfFifo(clazz_fifo));

    jdwp_put_u4(&reply_grobag, occupancyOfFifo(clazz_fifo));
    woempa(7, "Reading clazz_fifo\n");
    while ((clazz = getFifo(clazz_fifo))) {
      jdwp_put_tagged_type(&reply_grobag, clazz);
      sig_string = clazz2desc(clazz);
      woempa(1, "  %K descriptor %w\n", clazz, sig_string);
      sig = jdwp_string2UTF8(sig_string, &length);
      jdwp_put_bytes(&reply_grobag, sig, length + 4);
      deregisterString(sig_string);
      releaseMem(sig);
      jdwp_put_u4(&reply_grobag, clazz2status(clazz));
    }
    woempa(7, "Releasing clazz_fifo\n");
    releaseFifo(clazz_fifo);
  }
  else {
    jdwp_put_u4(&reply_grobag, 0);
  }

  jdwp_send_reply(cmd->id, &reply_grobag, jdwp_err_none);
}
예제 #2
0
static void jdwp_vm_classes_by_sig(jdwp_command_packet cmd) {
  w_int length;
  w_ubyte *sig;
  w_string sig_string;
  w_fifo fifo_of_fifos;
  w_fifo clazz_fifo;
  w_fifo one_fifo;
  w_clazz clazz;

  sig = jdwp_UTF82cstring((w_ubyte*)cmd->data, &length);
  sig_string = cstring2String((char*)sig, (w_word)length);
  classname = undescriptifyClassName(sig_string);
  if (isSet(verbose_flags, VERBOSE_FLAG_JDWP)) {
    w_printf("JDWP: signature = %w -> classname = %w\n", sig_string, classname);
  }
  releaseMem(sig);
  deregisterString(sig_string);

  woempa(7, "Searching all class loaders for classes with signature %w\n", classname);
  fifo_of_fifos = forEachClassLoader(getMatchingClasses);
  if (fifo_of_fifos) {
    woempa(7, "Found %d class loaders\n", occupancyOfFifo(fifo_of_fifos));
    deregisterString(classname);
    clazz_fifo = allocFifo(254);
    while ((one_fifo = getFifo(fifo_of_fifos))) {
      woempa(7, "Reading fifo %p\n", one_fifo);
      while ((clazz = getFifo(one_fifo))) {
          woempa(1, "  %K -> clazz_fifo\n", clazz);
          putFifo(clazz, clazz_fifo);
      }
      woempa(7, "Releasing fifo %p\n", one_fifo);
      releaseFifo(one_fifo);
    }
    woempa(7, "Found %d classes\n", occupancyOfFifo(clazz_fifo));
    jdwp_put_u4(&reply_grobag, occupancyOfFifo(clazz_fifo));

    while ((clazz = getFifo(clazz_fifo))) {
      woempa(1, "  %K\n", clazz);
      jdwp_put_tagged_type(&reply_grobag, clazz);
      jdwp_put_u4(&reply_grobag, clazz2status(clazz));
    }
    releaseFifo(clazz_fifo);
  }
  else {
    jdwp_put_u4(&reply_grobag, 0);
  }

  jdwp_send_reply(cmd->id, &reply_grobag, jdwp_err_none);
}
예제 #3
0
static void jdwp_vm_threads(jdwp_command_packet cmd) {
  w_fifo    fifo;
  w_thread  thread = NULL;
  w_int     length;

  /*
  ** Use a fifo to get all the threads from the thread hashtable.
  ** Subtract one from the length for the JDWP thread. The debugger
  ** doesn't need to know about this.
  */

  fifo = ht_list_values(thread_hashtable);
  length = occupancyOfFifo(fifo) - 1;
  woempa(7, "We have %d threads (not counting the JDWP thread)\n", length);

  /*
  ** Store the number of threads in the reply.
  */

  jdwp_put_u4(&reply_grobag, length);

  /*
  ** Go over the entries one by one and put them into the reply packet.
  */

  while((thread = getFifo(fifo)) != NULL) {
    if(thread != jdwp_thread) {
      woempa(7, "  %t\n", thread);
      jdwp_put_objectref(&reply_grobag, thread->Thread);
    }
  }

  releaseFifo(fifo);
  jdwp_send_reply(cmd->id, &reply_grobag, jdwp_err_none);
}
예제 #4
0
파일: session.cpp 프로젝트: wf34/led
bool
Session::open(struct event_base* base) {
    reqFd_ = ::open(getFifo().c_str(), O_RDWR | O_NONBLOCK);

	if (reqFd_ == -1)
        return false;

    ev_ = event_new(base, reqFd_,
                    EV_READ|EV_PERSIST,
                    Session::readFromPipe, this); 
    event_add(ev_, NULL);
    return true;
}
예제 #5
0
/*
** Search the specified classloader for classes matching 'classname'.
*/
static void *getMatchingClasses(w_instance loader) {
  w_hashtable ht = getWotsitField(loader, F_ClassLoader_loaded_classes);
  w_fifo fifo1 = ht_list_values(ht);
  w_fifo fifo2 = allocFifo(254);
  w_clazz clazz;

  while ((clazz = getFifo(fifo1))) {
    if (matchClassname(clazz, classname)) {
      woempa(7, "%k matches %w\n", clazz, classname);
      putFifo(clazz, fifo2);
    }
  }
  woempa(7, "%j has loaded %d classes matching %w\n", loader, occupancyOfFifo(fifo2), classname);
  releaseFifo(fifo1);

  if (occupancyOfFifo(fifo2) == 0) {
    releaseFifo(fifo2);
    fifo2 = NULL;
  }

  return fifo2;
}
예제 #6
0
static void jdwp_vm_disconnect(jdwp_command_packet cmd) {
  w_fifo fifo = ht_list_values(thread_hashtable);
  w_thread thread;
  
  jdwp_send_reply(cmd->id, &reply_grobag, jdwp_err_none);

  while((thread = getFifo(fifo)) != NULL) {
    woempa(7, "Clearing suspend count of %t\n", thread);
    thread->flags &= ~WT_THREAD_SUSPEND_COUNT_MASK;
  }
  while (jdwp_global_suspend_count) {
    jdwp_internal_resume_all();
  }

  unsetFlag(blocking_all_threads, BLOCKED_BY_JDWP);

  jdwp_state = jdwp_state_initialised;
  jdwp_events_enabled = 0;

  jdwp_clear_all_events();

  /* TODO: if garbage collection was disabled, enable it again. */
}
예제 #7
0
w_instance NativeProperties_init(JNIEnv *env, w_instance classSystem) {
  w_thread thread = JNIEnv2w_thread(env);
  char *utf8;
  w_string s;
  w_fifo fifo;
  w_int i;

  prop_hashtable = ht_create("hashtable:native system properties", 17, ht_stringHash, ht_stringCompare, 0, 0);
  woempa(1, "Created prop_hashtable\n");
  s = cstring2String(UNICODE_SUBSETS, strlen(UNICODE_SUBSETS));
  ht_write(prop_hashtable, (w_word)cstring2String("mika.unicode.subsets", 20), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.unicode.subsets", s);

  utf8 = getInstallationDir();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("java.home", 9), (w_word)s);
  woempa(1, "Set %s -> %w\n", "java.home", s);

  utf8 = getExtensionDir();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("java.ext.dirs", 13), (w_word)s);
  woempa(1, "Set %s -> %w\n", "java.ext.dirs", s);

  utf8 = getLibraryPath();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("java.library.path", 17), (w_word)s);
  woempa(1, "Set %s -> %w\n", "java.library.path", s);

  s = utf2String(VERSION_STRING, strlen(VERSION_STRING));
  ht_write(prop_hashtable, (w_word)utf2String("mika.version", 12), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.version", s);

  s = utf2String(WONKA_INFO, strlen(WONKA_INFO));
  ht_write(prop_hashtable, (w_word)utf2String("mika.vm.options", 15), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.vm.options", s);

  s = utf2String(DEFAULT_HEAP_SIZE, strlen(DEFAULT_HEAP_SIZE));
  ht_write(prop_hashtable, (w_word)utf2String("mika.default.heap.size", 22), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.default.heap.size", s);

  s = utf2String(AWT_INFO, strlen(AWT_INFO));
  ht_write(prop_hashtable, (w_word)utf2String("mika.awt.options", 16), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.awt.options", s);

#ifdef O4P
  s = utf2String(O4P_INFO, strlen(O4P_INFO));
  ht_write(prop_hashtable, (w_word)utf2String("mika.o4p.options", 16), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.o4p.options", s);
#endif

#ifdef OSWALD
  s = utf2String(OSWALD_INFO, strlen(OSWALD_INFO));
  ht_write(prop_hashtable, (w_word)utf2String("mika.oswald.options", 19), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.oswald.options", s);
#endif

  s = utf2String(BUILD_HOST, strlen(BUILD_HOST));
  ht_write(prop_hashtable, (w_word)utf2String("mika.build.host", 15), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.build.host", s);

  utf8 = __DATE__ " " __TIME__;
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("mika.build.time", 15), (w_word)s);
  woempa(1, "Set %s -> %w\n", "mika.build.time", s);

  utf8 = getOSName();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("os.name", 7), (w_word)s);
  woempa(1, "Set %s -> %w\n", "os.name", s);

  utf8 = getOSVersion();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("os.version", 10), (w_word)s);
  woempa(1, "Set %s -> %w\n", "os.version", s);

  utf8 = getOSArch();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("os.arch", 7), (w_word)s);
  woempa(1, "Set %s -> %w\n", "os.arch", s);

  utf8 = getUserName();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("user.name", 9), (w_word)s);
  woempa(1, "Set %s -> %w\n", "user.name", s);

  utf8 = getUserHome();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("user.home", 9), (w_word)s);
  woempa(1, "Set %s -> %w\n", "user.home", s);

  utf8 = getUserDir();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("user.dir", 8), (w_word)s);
  woempa(1, "Set %s -> %w\n", "user.dir", s);

  utf8 = getUserLanguage();
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("user.language", 13), (w_word)s);
  woempa(1, "Set %s -> %w\n", "user.language", s);

  utf8 = "Mika " VERSION_STRING;
  s = utf2String(utf8, strlen(utf8));
  ht_write(prop_hashtable, (w_word)utf2String("java.runtime.name", 17), (w_word)s);
  woempa(1, "Set %s -> %w\n", "java.runtime.name", s);

  enterUnsafeRegion(thread);
  keyArray = allocArrayInstance_1d(JNIEnv2w_thread(env), clazzArrayOf_String, prop_hashtable->occupancy);
  enterSafeRegion(thread);
  fifo = ht_list_keys_no_lock(prop_hashtable);
  i = 0;
  while ((s = (w_string)getFifo(fifo))) {
    woempa(7, "keyArray[%d] = %w\n", i, s);
    setArrayReferenceField(keyArray, getStringInstance(s), i);
    ++i;
  }

  return keyArray;
}