< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java

Print this page




  83     @Override
  84     public void threadStartEvent(ThreadStartEvent e)  {
  85     }
  86 
  87     @Override
  88     public void threadDeathEvent(ThreadDeathEvent e)  {
  89     }
  90 
  91     @Override
  92     public void classPrepareEvent(ClassPrepareEvent e)  {
  93     }
  94 
  95     @Override
  96     public void classUnloadEvent(ClassUnloadEvent e)  {
  97     }
  98 
  99     @Override
 100     public void breakpointEvent(BreakpointEvent be)  {
 101         Thread.yield();  // fetch output
 102         MessageOutput.lnprint("Breakpoint hit:");











 103     }
 104 
 105     @Override
 106     public void fieldWatchEvent(WatchpointEvent fwe)  {
 107         Field field = fwe.field();
 108         ObjectReference obj = fwe.object();
 109         Thread.yield();  // fetch output
 110 
 111         if (fwe instanceof ModificationWatchpointEvent) {
 112             MessageOutput.lnprint("Field access encountered before after",
 113                                   new Object [] {field,
 114                                                  fwe.valueCurrent(),
 115                                                  ((ModificationWatchpointEvent)fwe).valueToBe()});
 116         } else {
 117             MessageOutput.lnprint("Field access encountered", field.toString());
 118         }
 119     }
 120 
 121     @Override
 122     public void stepEvent(StepEvent se)  {


 210         Thread.yield();  // fetch output
 211         printCurrentLocation();
 212         for (String cmd : monitorCommands) {
 213             StringTokenizer t = new StringTokenizer(cmd);
 214             t.nextToken();  // get rid of monitor number
 215             executeCommand(t);
 216         }
 217         MessageOutput.printPrompt();
 218     }
 219 
 220     @Override
 221     public void receivedEvent(Event event) {
 222     }
 223 
 224     private void printBaseLocation(String threadName, Location loc) {
 225         MessageOutput.println("location",
 226                               new Object [] {threadName,
 227                                              Commands.locationString(loc)});
 228     }
 229 




 230     private void printCurrentLocation() {
 231         ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo();
 232         StackFrame frame;
 233         try {
 234             frame = threadInfo.getCurrentFrame();
 235         } catch (IncompatibleThreadStateException exc) {
 236             MessageOutput.println("<location unavailable>");
 237             return;
 238         }
 239         if (frame == null) {
 240             MessageOutput.println("No frames on the current call stack");
 241         } else {
 242             Location loc = frame.location();
 243             printBaseLocation(threadInfo.getThread().name(), loc);





 244             // Output the current source line, if possible
 245             if (loc.lineNumber() != -1) {
 246                 String line;
 247                 try {
 248                     line = Env.sourceLine(loc, loc.lineNumber());
 249                 } catch (java.io.IOException e) {
 250                     line = null;
 251                 }
 252                 if (line != null) {
 253                     MessageOutput.println("source line number and line",
 254                                           new Object [] {loc.lineNumber(),
 255                                                          line});
 256                 }
 257             }
 258         }
 259         MessageOutput.println();
 260     }
 261 
 262     private void printLocationOfEvent(LocatableEvent theEvent) {
 263         printBaseLocation(theEvent.thread().name(), theEvent.location());
 264     }
 265 
 266     void help() {
 267         MessageOutput.println("zz help text");
 268     }
 269 
 270     private static final String[][] commandList = {
 271         /*
 272          * NOTE: this list must be kept sorted in ascending ASCII
 273          *       order by element [0].  Ref: isCommand() below.
 274          *
 275          *Command      OK when        OK when
 276          * name      disconnected?   readonly?
 277          *------------------------------------
 278          */
 279         {"!!",           "n",         "y"},
 280         {"?",            "y",         "y"},




  83     @Override
  84     public void threadStartEvent(ThreadStartEvent e)  {
  85     }
  86 
  87     @Override
  88     public void threadDeathEvent(ThreadDeathEvent e)  {
  89     }
  90 
  91     @Override
  92     public void classPrepareEvent(ClassPrepareEvent e)  {
  93     }
  94 
  95     @Override
  96     public void classUnloadEvent(ClassUnloadEvent e)  {
  97     }
  98 
  99     @Override
 100     public void breakpointEvent(BreakpointEvent be)  {
 101         Thread.yield();  // fetch output
 102         MessageOutput.lnprint("Breakpoint hit:");
 103         // Print breakpoint location and prompt if suspend policy is
 104         // SUSPEND_NONE or SUSPEND_EVENT_THREAD. In case of SUSPEND_ALL
 105         // policy this is handled by vmInterrupted() method.
 106         int suspendPolicy = be.request().suspendPolicy();
 107         switch (suspendPolicy) {
 108             case EventRequest.SUSPEND_EVENT_THREAD:
 109             case EventRequest.SUSPEND_NONE:
 110                 printBreakpointLocation(be);
 111                 MessageOutput.printPrompt();
 112                 break;
 113         }
 114     }
 115 
 116     @Override
 117     public void fieldWatchEvent(WatchpointEvent fwe)  {
 118         Field field = fwe.field();
 119         ObjectReference obj = fwe.object();
 120         Thread.yield();  // fetch output
 121 
 122         if (fwe instanceof ModificationWatchpointEvent) {
 123             MessageOutput.lnprint("Field access encountered before after",
 124                                   new Object [] {field,
 125                                                  fwe.valueCurrent(),
 126                                                  ((ModificationWatchpointEvent)fwe).valueToBe()});
 127         } else {
 128             MessageOutput.lnprint("Field access encountered", field.toString());
 129         }
 130     }
 131 
 132     @Override
 133     public void stepEvent(StepEvent se)  {


 221         Thread.yield();  // fetch output
 222         printCurrentLocation();
 223         for (String cmd : monitorCommands) {
 224             StringTokenizer t = new StringTokenizer(cmd);
 225             t.nextToken();  // get rid of monitor number
 226             executeCommand(t);
 227         }
 228         MessageOutput.printPrompt();
 229     }
 230 
 231     @Override
 232     public void receivedEvent(Event event) {
 233     }
 234 
 235     private void printBaseLocation(String threadName, Location loc) {
 236         MessageOutput.println("location",
 237                               new Object [] {threadName,
 238                                              Commands.locationString(loc)});
 239     }
 240 
 241     private void printBreakpointLocation(BreakpointEvent be) {
 242         printLocationWithSourceLine(be.thread().name(), be.location());
 243     }
 244 
 245     private void printCurrentLocation() {
 246         ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo();
 247         StackFrame frame;
 248         try {
 249             frame = threadInfo.getCurrentFrame();
 250         } catch (IncompatibleThreadStateException exc) {
 251             MessageOutput.println("<location unavailable>");
 252             return;
 253         }
 254         if (frame == null) {
 255             MessageOutput.println("No frames on the current call stack");
 256         } else {
 257             printLocationWithSourceLine(threadInfo.getThread().name(), frame.location());
 258         }
 259         MessageOutput.println();
 260     }
 261 
 262     private void printLocationWithSourceLine(String threadName, Location loc) {
 263         printBaseLocation(threadName, loc);
 264         // Output the current source line, if possible
 265         if (loc.lineNumber() != -1) {
 266             String line;
 267             try {
 268                 line = Env.sourceLine(loc, loc.lineNumber());
 269             } catch (java.io.IOException e) {
 270                 line = null;
 271             }
 272             if (line != null) {
 273                 MessageOutput.println("source line number and line",
 274                                            new Object [] {loc.lineNumber(),
 275                                                           line});
 276             }
 277         }
 278     }


 279 
 280     private void printLocationOfEvent(LocatableEvent theEvent) {
 281         printBaseLocation(theEvent.thread().name(), theEvent.location());
 282     }
 283 
 284     void help() {
 285         MessageOutput.println("zz help text");
 286     }
 287 
 288     private static final String[][] commandList = {
 289         /*
 290          * NOTE: this list must be kept sorted in ascending ASCII
 291          *       order by element [0].  Ref: isCommand() below.
 292          *
 293          *Command      OK when        OK when
 294          * name      disconnected?   readonly?
 295          *------------------------------------
 296          */
 297         {"!!",           "n",         "y"},
 298         {"?",            "y",         "y"},


< prev index next >