use of com.sun.jdi.LocalVariable in project jdk8u_jdk by JetBrains.
the class LambdaStepTest method runTests.
/********** test core **********/
protected void runTests() throws Exception {
// ## Normal instance method
BreakpointEvent bpe = startTo("LambdaStepTestTarg", "instanceTest", "()V");
ThreadReference thread = bpe.thread();
// step over allocation
StepEvent se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into test();
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
StackFrame frame = se.thread().frame(0);
LocalVariable lv = frame.visibleVariableByName("from");
System.out.println(lv);
StringReference sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("test")) {
throw new Exception("Unexpected variable value in instanceTest: " + sr.value());
}
// ## Lambda method
bpe = resumeTo("LambdaStepTestTarg", "lambdaTest", "()V");
thread = bpe.thread();
// step over allocation
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into run() of the lambda
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
frame = se.thread().frame(0);
lv = frame.visibleVariableByName("from");
System.out.println(lv);
sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("lambda")) {
throw new Exception("Unexpected variable value in lambdaTest: " + sr.value());
}
// ## Default method
bpe = resumeTo("LambdaStepTestTarg", "defaultTest", "()V");
thread = bpe.thread();
// step over allocation
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// step into defaultMethod()
se = stepIntoLine(thread);
System.out.println(se.thread().frame(0));
// step over variable initialization
se = stepOverLine(thread);
System.out.println(se.thread().frame(0));
// get value of variable "from"
frame = se.thread().frame(0);
lv = frame.visibleVariableByName("from");
System.out.println(lv);
sr = (StringReference) frame.getValue(lv);
if (!sr.value().equals("default")) {
throw new Exception("Unexpected variable value in lambdaTest: " + sr.value());
}
/*
* resume the target listening for events
*/
listenUntilVMDisconnect();
}
use of com.sun.jdi.LocalVariable in project che by eclipse.
the class JdiStackFrameImpl method getLocalVariables.
@Override
public JdiLocalVariable[] getLocalVariables() throws DebuggerException {
if (localVariables == null) {
try {
List<LocalVariable> targetVariables = stackFrame.visibleVariables();
localVariables = new JdiLocalVariable[targetVariables.size()];
int i = 0;
for (LocalVariable var : targetVariables) {
localVariables[i++] = new JdiLocalVariableImpl(stackFrame, var);
}
} catch (AbsentInformationException e) {
throw new DebuggerAbsentInformationException(e.getMessage(), e);
} catch (InvalidStackFrameException | NativeMethodException e) {
throw new DebuggerException(e.getMessage(), e);
}
}
return localVariables;
}
use of com.sun.jdi.LocalVariable in project che by eclipse.
the class Evaluator method getLocalVariable.
public ExpressionValue getLocalVariable(String text) {
ExpressionValue value = null;
try {
StackFrame frame = thread.frame(0);
LocalVariable var = frame.visibleVariableByName(text);
if (var != null) {
value = new LocalValue(thread, var);
}
} catch (IncompatibleThreadStateException | AbsentInformationException | InvalidStackFrameException | NativeMethodException e) {
throw new ExpressionException(e.getMessage(), e);
}
LOG.debug("GET local variable {} {} ", text, value);
return value;
}
use of com.sun.jdi.LocalVariable in project otertool by wuntee.
the class Testing method printBreakpointData.
public static void printBreakpointData(BreakpointEvent e) throws IncompatibleThreadStateException, AbsentInformationException {
System.out.println(e.location());
System.out.println("Line number: " + e.location().lineNumber());
System.out.println("Code index: " + e.location().codeIndex());
try {
System.out.println("SourceName: " + e.location().sourceName());
} catch (AbsentInformationException e1) {
System.out.println("SourceName: UNAVAILABLE");
}
System.out.println("Declaration type: " + e.location().declaringType());
System.out.println("Method: " + e.location().method());
System.out.println("Stack frames:");
for (StackFrame sf : e.thread().frames()) {
System.out.println("\t" + sf.toString());
System.out.println("\t Visible Variables:");
for (LocalVariable lv : sf.visibleVariables()) {
System.out.println("\t\t--");
System.out.println("\t\tName: " + lv.name());
System.out.println("\t\tType: " + lv.typeName());
Value lvValue = sf.getValue(lv);
if (lvValue != null) {
System.out.println("\t\tValue: " + lvValue);
System.out.println("\t\tValue Type:" + lvValue.type());
System.out.println("\t\ttoString: " + lv);
}
}
System.out.println("\t Argument Values:");
for (Value lv : sf.getArgumentValues()) {
System.out.println("\t\t--");
System.out.println("\t\t" + lv.toString());
}
}
}
Aggregations