< prev index next >
src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java
Print this page
@@ -98,10 +98,21 @@
@Override
public void breakpointEvent(BreakpointEvent be) {
Thread.yield(); // fetch output
MessageOutput.lnprint("Breakpoint hit:");
+ // Print breakpoint location and prompt if suspend policy is
+ // SUSPEND_NONE or SUSPEND_EVENT_THREAD. In case of SUSPEND_ALL
+ // policy this is handled by vmInterrupted() method.
+ int suspendPolicy = be.request().suspendPolicy();
+ switch (suspendPolicy) {
+ case EventRequest.SUSPEND_EVENT_THREAD:
+ case EventRequest.SUSPEND_NONE:
+ printBreakpointLocation(be);
+ MessageOutput.printPrompt();
+ break;
+ }
}
@Override
public void fieldWatchEvent(WatchpointEvent fwe) {
Field field = fwe.field();
@@ -166,11 +177,10 @@
Method meMethod = me.method();
if (mmm == null || mmm.equals(meMethod)) {
// Either we are not tracing a specific method, or we are
// and we are exitting that method.
-
if (me.request().suspendPolicy() != EventRequest.SUSPEND_NONE) {
// We will be stopping here, so do a newline
MessageOutput.println();
}
if (Env.vm().canGetMethodReturnValues()) {
@@ -225,10 +235,14 @@
MessageOutput.println("location",
new Object [] {threadName,
Commands.locationString(loc)});
}
+ private void printBreakpointLocation(BreakpointEvent be) {
+ printLocationWithSourceLine(be.thread().name(), be.location());
+ }
+
private void printCurrentLocation() {
ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo();
StackFrame frame;
try {
frame = threadInfo.getCurrentFrame();
@@ -237,12 +251,17 @@
return;
}
if (frame == null) {
MessageOutput.println("No frames on the current call stack");
} else {
- Location loc = frame.location();
- printBaseLocation(threadInfo.getThread().name(), loc);
+ printLocationWithSourceLine(threadInfo.getThread().name(), frame.location());
+ }
+ MessageOutput.println();
+ }
+
+ private void printLocationWithSourceLine(String threadName, Location loc) {
+ printBaseLocation(threadName, loc);
// Output the current source line, if possible
if (loc.lineNumber() != -1) {
String line;
try {
line = Env.sourceLine(loc, loc.lineNumber());
@@ -254,12 +273,10 @@
new Object [] {loc.lineNumber(),
line});
}
}
}
- MessageOutput.println();
- }
private void printLocationOfEvent(LocatableEvent theEvent) {
printBaseLocation(theEvent.thread().name(), theEvent.location());
}
< prev index next >