Package com.sun.jdi

Examples of com.sun.jdi.Location


   
    BreakpointManager bpm = BreakpointManager.getInstance();
    List<Breakpoint> allBreakpoints = bpm.getAllBreakpoints();
    Breakpoint breakpoint = null;
   
    Location loc = event.location();
    String className = loc.declaringType().name();
    int lineNum = loc.lineNumber();

    for (Breakpoint bp : allBreakpoints) {
      if (bp.getMainClass().equals(className) && bp.getLineNum() == lineNum) {
        breakpoint = bp;
        break;
View Full Code Here


    ReferenceType refType = event.location().declaringType();
    SuspendThreadStack threadStack = SuspendThreadStack.getInstance();
    threadStack.setCurRefType(refType);
    threadStack.setCurThreadRef(threadRef);
   
    Location loc = event.location();
    Debugger debugger = Debugger.getInstance();
    String className = loc.declaringType().name();
    int lineNum = loc.lineNumber();

    CompilerContext ctx = debugger.getCompilerContext();
    String abPath = "None";
    try {
      abPath = ctx.findSourceFile(loc.sourcePath());
    } catch (Throwable e) {
    }
   
    String funcName = "HandleJdiEvent";
    String[] args = {"suspend", abPath, String.valueOf(lineNum), className };
View Full Code Here

    public final static synchronized DroolsStackFrame createCustomFrame(DroolsThread thread,
                                                                        int depth,
                                                                        StackFrame currentFrame) {
        DroolsStackFrame customFrame;
        Location loc = currentFrame.location();
        if ( loc.declaringType().name().equals( "org.drools.base.mvel.MVELDebugHandler" ) && loc.method().name().equals( "onBreak" ) ) {
            customFrame = new MVELStackFrame( thread,
                                              currentFrame,
                                              depth );
        } else {
            customFrame = new DroolsStackFrame( thread,
View Full Code Here

                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           
            Method method = ( Method ) list.get( 0 );
            if (method != null && !method.isNative()) {
                Location location = method.location();
                if (location != null && location.codeIndex() != -1) {
                    req = getEventRequestManager().createBreakpointRequest(location);
                    req.addThreadFilter( ((ClassPrepareEvent) event).thread() );
                    req.setSuspendPolicy( EventRequest.SUSPEND_ALL  );
                } else {
                    throw new IllegalStateException( "MVELDebugHandler.onBreak location cannot be found by JDI" );
View Full Code Here

                ReferenceType classType = ((ClassPrepareEvent)
                        event).referenceType();
                for (Integer line : lineList) {
                    List<Location> locations = classType.locationsOfLine(line);
                    if (!locations.isEmpty()) {
                        Location loc = locations.get(0);
                        BreakpointRequest breakpointRequest =
                            jdb.eventRequestManager.
                            createBreakpointRequest(loc);
                        breakpointRequest.setSuspendPolicy(
                                EventRequest.SUSPEND_ALL);
                        breakpointRequest.enable();
                        jdb.breakpointRegisterMap.put(
                                loc.toString(), breakpointRequest);
                        System.out.println(
                                String.format("Breakpoint set: " + loc));
                    }
                }
            }
            // set the possible deferred method breakpoints
            List<String> methodStrList = deferringMethodBreakpoint.get(className);
            if (methodStrList != null) {
                ReferenceType classType = ((ClassPrepareEvent)
                        event).referenceType();
                for (String methodStr : methodStrList) {
                    String[] params = methodStr.split("|");
                    // Generate the target argument type string list
                    String[] argTypeNames;
                    if (params.length > 1) {
                        argTypeNames = params[1].split(",");
                    } else {
                        argTypeNames = new String[0];
                    }
                    // Get all methods of the class
                    List<Method> methodList = classType.methodsByName(params[0]);
                    Method matchedMethod = null;
                    /*
                     * As the jdb command argument doesn't supply the result
                     * value type, it's impossible to generate a jni signature
                     * for the specified method. I just have to search...
                     */
                    for (Method m : methodList) {
                        List<String> types = m.argumentTypeNames();
                        if (types.size() != argTypeNames.length) {
                            continue;
                        } else {
                            boolean matched = true;
                            for (int i = 0; i < argTypeNames.length; i++) {
                                if (!types.get(i).equals(argTypeNames[i])) {
                                    matched = false;
                                    break;
                                }
                            }
                            if (matched) {
                                matchedMethod = m;
                                break;
                            }
                        }
                    }
                    if (null != matchedMethod) {
                        Location loc = matchedMethod.location();
                        if (null != loc) {
                            BreakpointRequest breakpointRequest =
                                jdb.eventRequestManager.
                                createBreakpointRequest(loc);
                            breakpointRequest.setSuspendPolicy(
                                    EventRequest.SUSPEND_ALL);
                            breakpointRequest.enable();
                            jdb.breakpointRegisterMap.put(
                                    loc.toString(), breakpointRequest);
                            System.out.println(
                                    String.format("Breakpoint set: " + loc));
                        }
                    }
                }
View Full Code Here

                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           
            Method method = ( Method ) list.get( 0 );
            if (method != null && !method.isNative()) {
                Location location = method.location();
                if (location != null && location.codeIndex() != -1) {
                    req = getEventRequestManager().createBreakpointRequest(location);
                    req.addThreadFilter( ((ClassPrepareEvent) event).thread() );
                    req.setSuspendPolicy( EventRequest.SUSPEND_ALL  );
                } else {
                    throw new IllegalStateException( "MVELDebugHandler.onBreak location cannot be found by JDI" );
View Full Code Here

    public final static synchronized DroolsStackFrame createCustomFrame(DroolsThread thread,
                                                                        int depth,
                                                                        StackFrame currentFrame) {
        DroolsStackFrame customFrame;
        Location loc = currentFrame.location();
        if ( loc.declaringType().name().equals( "org.drools.core.base.mvel.MVELDebugHandler" ) && loc.method().name().equals( "onBreak" ) ) {
            customFrame = new MVELStackFrame( thread,
                                              currentFrame,
                                              depth );
        } else {
            customFrame = new DroolsStackFrame( thread,
View Full Code Here

            this.logger = STEP_EVENT_LOGGER;
            return this;
        }
       
        public HandlerResult handle(StepEvent event) throws Exception {
            Location location = event.location();
            if (this.within != null
                    && !this.within.equals(location.sourceName())) {
                return HandlerResult.RESUME;
            }
           
            if (logger != null) {
                logger.log(event);
View Full Code Here

  }
 
  public void run() {
    VirtualMachine vm = communicationClass.virtualMachine();
    try {
      Location interceptIn = ((Method)communicationClass.methodsByName("interceptIn").get(0)).locationOfCodeIndex(2);
      Location interceptOut = ((Method)communicationClass.methodsByName("interceptOut").get(0)).locationOfCodeIndex(2);
      BreakpointRequest req =  vm.eventRequestManager().createBreakpointRequest(interceptIn);
      req.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
      req.setEnabled(true);
      req = vm.eventRequestManager().createBreakpointRequest(interceptOut);
      req.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
      req.setEnabled(true);
      final com.sun.jdi.event.EventQueue q = vm.eventQueue();
      boolean done = false;
      errorStream.println("== Handling I/O events...");
      while (true) {
        final EventSet es;
        if (!done) {
          es = q.remove();
        } else {
          es = q.remove(1000);
          if (es == null) {
            break;
          }
        }
        for (final EventIterator ei = es.eventIterator(); ei.hasNext();) {
          final Event e = ei.nextEvent();
          if (!done && e instanceof BreakpointEvent) {
            final BreakpointEvent be = (BreakpointEvent) e;
            final Location loc = be.location();
            final ThreadReference tr = be.thread()
            if (loc.equals(interceptIn)) {
              LocalVariable result = (LocalVariable) loc.method().variablesByName("result").get(0);
              LocalVariable buffer = (LocalVariable) loc.method().arguments().get(0);
              ArrayReference buf = (ArrayReference) tr.frame(0).getValue(buffer);
              new InputInterceptHandler(tr, buf, result).start();
            } else if (loc.equals(interceptOut)) {
              LocalVariable result = (LocalVariable) loc.method().variablesByName("result").get(0);
              LocalVariable data = (LocalVariable) loc.method().arguments().get(0);
              ArrayReference buf = (ArrayReference) tr.frame(0).getValue(data);
              List values = buf.getValues();
              byte[] temp = new byte[buf.length()];
              for (int i = 0; i < temp.length; i++) {
                temp[i] = ((ByteValue)values.get(i)).byteValue();
View Full Code Here

            if (clazz.name().equals(getTypeName())) {
              // only use line breakpoint when there is an exact match
              Method method = clazz.concreteMethodByName(
                  getMethodName(), getMethodSignature());
              if (method != null && !method.isNative()) {
                Location location = method.location();
                if (location != null && location.codeIndex() != -1) {
                  request = manager
                      .createBreakpointRequest(location);
                }
              }
            }
View Full Code Here

TOP

Related Classes of com.sun.jdi.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.