< 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)  {


 151             MessageOutput.lnprint("Method entered:");
 152         } else {
 153             // We aren't stopping, show the name
 154             MessageOutput.print("Method entered:");
 155             printLocationOfEvent(me);
 156         }
 157     }
 158 
 159     @Override
 160     public boolean methodExitEvent(MethodExitEvent me) {
 161         Thread.yield();  // fetch output
 162         /*
 163          * These can be very numerous, so be as efficient as possible.
 164          */
 165         Method mmm = Env.atExitMethod();
 166         Method meMethod = me.method();
 167 
 168         if (mmm == null || mmm.equals(meMethod)) {
 169             // Either we are not tracing a specific method, or we are
 170             // and we are exitting that method.
 171 
 172             if (me.request().suspendPolicy() != EventRequest.SUSPEND_NONE) {
 173                 // We will be stopping here, so do a newline
 174                 MessageOutput.println();
 175             }
 176             if (Env.vm().canGetMethodReturnValues()) {
 177                 MessageOutput.print("Method exitedValue:", me.returnValue() + "");
 178             } else {
 179                 MessageOutput.print("Method exited:");
 180             }
 181 
 182             if (me.request().suspendPolicy() == EventRequest.SUSPEND_NONE) {
 183                 // We won't be stopping here, so show the method name
 184                 printLocationOfEvent(me);
 185 
 186             }
 187 
 188             // In case we want to have a one shot trace exit some day, this
 189             // code disables the request so we don't hit it again.
 190             if (false) {
 191                 // This is a one shot deal; we don't want to stop


 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)  {


 162             MessageOutput.lnprint("Method entered:");
 163         } else {
 164             // We aren't stopping, show the name
 165             MessageOutput.print("Method entered:");
 166             printLocationOfEvent(me);
 167         }
 168     }
 169 
 170     @Override
 171     public boolean methodExitEvent(MethodExitEvent me) {
 172         Thread.yield();  // fetch output
 173         /*
 174          * These can be very numerous, so be as efficient as possible.
 175          */
 176         Method mmm = Env.atExitMethod();
 177         Method meMethod = me.method();
 178 
 179         if (mmm == null || mmm.equals(meMethod)) {
 180             // Either we are not tracing a specific method, or we are
 181             // and we are exitting that method.

 182             if (me.request().suspendPolicy() != EventRequest.SUSPEND_NONE) {
 183                 // We will be stopping here, so do a newline
 184                 MessageOutput.println();
 185             }
 186             if (Env.vm().canGetMethodReturnValues()) {
 187                 MessageOutput.print("Method exitedValue:", me.returnValue() + "");
 188             } else {
 189                 MessageOutput.print("Method exited:");
 190             }
 191 
 192             if (me.request().suspendPolicy() == EventRequest.SUSPEND_NONE) {
 193                 // We won't be stopping here, so show the method name
 194                 printLocationOfEvent(me);
 195 
 196             }
 197 
 198             // In case we want to have a one shot trace exit some day, this
 199             // code disables the request so we don't hit it again.
 200             if (false) {
 201                 // This is a one shot deal; we don't want to stop


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


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


< prev index next >