Ejemplo n.º 1
0
void 
VMEvent::event_request_clear(PacketInputStream *in, 
                   PacketOutputStream *out)
{
  jbyte eventType = in->read_byte();
  jint eventID = in->read_int();
  VMEvent::Raw ep;
  
#ifdef AZZERT
  if (TraceDebugger) {
    tty->print_cr("Event Clear");
  }
#endif

  eventType = 0;      /* satisfy GCC */
  VMEventStream es;

  while(!es.at_end()) {
    ep = es.next();
    if (ep().event_id() == eventID) {
      clear_event_request(&ep);
    }
  }
  out->send_packet();
}
Ejemplo n.º 2
0
ReturnOop VMEvent::get_event_request(DebuggerEvent *d_event,
    int &event_count, jbyte &suspend_policy)
{
  VMEventStream es;

  UsingFastOops fast_oops;

  VMEvent::Fast ep, epp;
  VMEventModifier::Fast em;
  bool matched;

  jbyte kind = d_event->event_kind();

  event_count = 0;
  suspend_policy = 0;
  ep = es.next_by_kind(kind);
  while(!ep.is_null()) {
    bool should_delete = false;
    // check modifiers
#if ENABLE_ISOLATES
    // Check to see what task this event was requested on
    if (ep().task_id() != -1 &&
        (Thread::current()->task_id() != ep().task_id())) {
      ep = es.next_by_kind(kind);
      continue;
    }
#endif
    em = ep().mods();
    // we need to check the modifiers to see if we send this event
    matched = true;
    do {
      if (em.is_null()) {
        break;
      }
      if (!em().match(d_event, &should_delete)) {
        matched = false;
        break;
      }
      em = em().next();
    } while(em.not_null());
    if (matched) {
      // Found a matching event, join it to the list of events to send
      ep().set_send_next(&epp);
      epp = ep;
      event_count++;
      if (ep().suspend_policy() > suspend_policy) {
        suspend_policy = ep().suspend_policy();
      }
    }
    if (should_delete) {
      clear_event_request(&ep);
    }
    ep = es.next_by_kind(kind);
  }
  return epp;
}
Ejemplo n.º 3
0
void
VMEvent::clear_all_breakpoints(Transport *t)
{

  VMEventStream es;
  UsingFastOops fast_oops;

  VMEvent::Fast ep;

  ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT, t->task_id());
  while (!ep.is_null()) {
    clear_event_request(&ep);
    ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT, t->task_id());
  }
}
Ejemplo n.º 4
0
void
VMEvent::clear_all_events(Transport *t)
{

  VMEventStream es;
  UsingFastOops fast_oops;

  VMEvent::Fast ep;

  ep = es.next_by_task(t->task_id());
  while (!ep.is_null()) {
    clear_event_request(&ep);
    ep = es.next_by_task(t->task_id());
  }
}
Ejemplo n.º 5
0
void LocationModifier::find_and_set_rom_method_id(Method *debug_rom_method) {

  VMEventStream es;

  VMEvent::Raw ep;
  LocationModifier::Raw  mod;
  Method::Raw dm;
  ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
  while(!ep.is_null()) {
    mod = VMEvent::get_modifier(&ep,
        JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
    if (!mod.is_null()) {
      dm = mod().rom_debug_method();
      if (!dm.is_null() && dm.obj() == debug_rom_method->obj()) {
        set_method_id(mod().method_id());
        break;
      }
    }
    ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
  }
}
Ejemplo n.º 6
0
ReturnOop LocationModifier::get_dup_rom_method(Method *in_rom_method) {
 
  VMEventStream es;

  VMEvent::Raw ep;
  LocationModifier::Raw  mod;
  Method::Raw sm;
  ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
  while(!ep.is_null()) {
    mod = VMEvent::get_modifier(&ep,
        JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
    if (!mod.is_null()) {
      sm = mod().method();
      if (!sm.is_null() && sm.obj() == in_rom_method->obj()) {
        return mod().rom_debug_method();
      }
    }
    ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
  }
  return NULL;
}
Ejemplo n.º 7
0
  address get_rom_debug_method(Thread *thread, OopDesc *md) {
    (void)thread; // always passed from interpreter but not used here.
    VMEventStream es;

    Method::Raw m = md;
    VMEvent::Raw ep;
    LocationModifier::Raw  mod;

    ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
    while(!ep.is_null()) {
      mod = VMEvent::get_modifier(&ep,
               JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
      if (!mod.is_null() &&
          mod().method_id() == JavaDebugger::get_method_id(&m)) {
        Method::Raw dm = mod().rom_debug_method();
        if (!dm.is_null()) {
          return (address)((char *)dm.obj());
        }
      }
      ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
   }
    return (address)md;
  }
Ejemplo n.º 8
0
ReturnOop VMEvent::find_breakpoint_event(int class_id, jlong method_id,
                                         jlong offset, int task_id)
{
  // May be called during GC via GenerateStackMap::run().

  VMEventStream es;
  VMEvent::Raw ep;
  LocationModifier::Raw  loc;

  while (!es.at_end()) {
    ep = es.next_by_kind(JDWP_EventKind_BREAKPOINT);
    if (ep.is_null()) {
      return NULL;
    }
#if ENABLE_ISOLATES
    // If task_id == -1 && ep.task_id == -1 then we don't care
    // which task this is we check the event otherwise we skip it
    if (task_id != -1 && ep().task_id() != -1 &&
        (ep().task_id() != task_id)) {
      continue;
    }
#else
    (void)task_id;
#endif
    loc = get_modifier(&ep,
        JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
    if (loc.not_null()) {
      if (loc().clazz_id() == class_id &&
          loc().method_id() == method_id && 
          loc().offset() == offset) {
        return ep;
      }
    }
  }
  return (ReturnOop)NULL;
}
Ejemplo n.º 9
0
void
VMEvent::clear_impossible_to_compile(LocationModifier *mod, VMEvent *ep)
{
  UsingFastOops fast_oops;

  // If we are using the compiler then we should reset the
  // impossible_to_compile flag for this method (and potentially one frame
  // up if it's a single step).
  // We also check the previous state of the method, if it was
  // "impossible_to_compile" we don't reset the flag.

  InstanceClass::Fast clazz;
  Method::Fast method, callerMethod;
  LocationModifier::Fast thisMod;

  Method::Fast m = mod->method();
  //  if (!m().has_compiled_code()) {
    // if method does not have compiled code then just return
  //    return;
  //  }
  if (m.is_null()) {
    // Method was removed.  Most likely it was a <clinit> method
    return;
  }
  VMEvent::Fast epm;
  VMEventStream es;
  bool found_one = false;
  while (!es.at_end()) {
    epm = es.next();
    if ((epm().event_kind() == JDWP_EventKind_BREAKPOINT ||
         epm().event_kind() == JDWP_EventKind_SINGLE_STEP) &&
        (ep == NULL || !epm.equals(ep))) {
      thisMod = get_modifier(&epm,
         JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
      if (thisMod.not_null()) {
        method = thisMod().method();
        if (method.equals(&m)) {
          // another breakpoint in this method, keep impossible_to_compile set
          found_one = true;
          break;
        }
      }
    }
  }
  if (!found_one) {
    // we must have looped through the whole list and not found another
    // breakpoint in this method so clear the impossible_to_compile flag
    if (mod->rom_debug_method() != NULL) {
      // This method is in ROM, let's check all method pointers on the java
      // stack to see if any of them point to this rom_debug_method.
      // We may be called as a result of JVM::cleanup(). Thread doesn't have
      // a stack in that case.
      Thread *thread = Thread::current();
      if (thread->last_java_fp() != NULL && thread->last_java_sp() != NULL) {
        Frame fr(Thread::current());
        while (true) {
          if (fr.is_entry_frame()) {
            EntryFrame e = fr.as_EntryFrame();
            if (e.is_first_frame()) {
              break;
            }
            e.caller_is(fr);
          } else if (fr.is_java_frame()) {
            JavaFrame jf = fr.as_JavaFrame();
            if (jf.method() == mod->rom_debug_method()) {
              MethodDesc *md = (MethodDesc *)mod->method();
              // fix up the stored bcp in this frame
              int bci = jf.bci_with_flags();
              jf.set_raw_method(md);
              Method::Raw m = jf.method();
              jf.set_raw_bcp((address)(bci + m().code_base()));
            }
            jf.caller_is(fr);
          }
        }
      }
    }
    // We also check the previous state of the method, if it was
    // "impossible_to_compile" we don't reset the flag.
    if (mod->compile_state() == true) {
      // Method was compilable so set entry to default
      m().set_default_entry(false);
    } else {
      if (ep->event_kind() == JDWP_EventKind_BREAKPOINT) {
        // May have been a special native method like String.charAt.
        // Just replace the entry with what we had saved earlier
        GUARANTEE(!ObjectHeap::contains((OopDesc*)mod->saved_method_entry()),
                  "ROM method entry is in heap");
        m().variable_part()->set_execution_entry(mod->saved_method_entry());
      }
    }
  }
}
Ejemplo n.º 10
0
ReturnOop VMEvent::find_event(jbyte kind) {
  VMEventStream es;

  return es.next_by_kind(kind);
}