Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Debug problem(VM doesn't return variables for method)
Debug problem [message #710741] Fri, 05 August 2011 11:11 Go to next message
Andrey  is currently offline Andrey Friend
Messages: 4
Registered: April 2011
Junior Member
Using eclipse indigo.
I have a eclipse-based product which uses JDT. Basically this product allows user to make implementation of interface. Then builds it.
Class file is then passed to jar with entry point. That jar loads the class and triggers different callbacks.
Here follows example of client's code:
import java.util.Map;

public class TestImplementor implements SomeBaseInterface{

	@Override
	public void onInitParameters(Map<String, String> params) {
		System.out.println("onInitParameters: ");
		for (int s = 0; s < params.size(); s++) 
		{
			System.out.println(params.keySet().toArray()[s].toString() + ":"
					+ params.values().toArray()[s].toString());
	   	}
		System.out.println();
	}

	@Override
	public void onInit(String data) {
		System.out.println("onInit");
		if (data!=null)
		{
			System.out.println(data);
		}
	}
}


I added via extension point custom ILaunchConfigurationDelegate, which does launching in run/debug mode, which uses JDT:
IVMRunner runner = JavaRuntime.getDefaultVMInstall().getVMRunner(mode);
runner.run(runConfig, launch, monitor);

There are no problems with simple running the code.
But there are problems, when I try to debug client's code.
When code is interrupted for breakpoint in client's code, I can't see variables and expressions are not computed. To be completely accurate - I can see only method input variables and they are called like arg0, arg1.. but no information of local variables.

I start digging - so far I found that when VariableView requests input data - stackframe requests variables from method and method then asks VM, VM will return ABSENT_INFORMATION:
	/**
	 * @see com.sun.jdi.Method#variables()
	 */
	public List variables() throws AbsentInformationException {
		if (isNative() || isAbstract()) {
			throw new AbsentInformationException(JDIMessages.MethodImpl_No_local_variable_information_available_9); 
		}
		
		if (fVariables != null) {
			return fVariables;
		}

		initJdwpRequest();
		try {
			ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
			DataOutputStream outData = new DataOutputStream(outBytes);
			writeWithReferenceType(this, outData);
			
			boolean withGenericSignature= virtualMachineImpl().isJdwpVersionGreaterOrEqual(1, 5);
			int jdwpCommand= withGenericSignature ? JdwpCommandPacket.M_VARIABLE_TABLE_WITH_GENERIC : JdwpCommandPacket.M_VARIABLE_TABLE;
			JdwpReplyPacket replyPacket = requestVM(jdwpCommand, outBytes);
			switch (replyPacket.errorCode()) {
				case JdwpReplyPacket.ABSENT_INFORMATION:
					return inferArguments();
			}
			

So basically VM doesn't return information for method.
Documentation says:
Generally, local variable information is not available for native or abstract methods (that is, their argument name information is not available), thus they will throw this exception.
But this method is not native and not abstract.
So why doesn't VM return information for method?
I would appreciate any help.
Re: Debug problem [message #713981 is a reply to message #710741] Tue, 09 August 2011 14:15 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
You want to make sure that the class files are built with debug information. How is the class file getting built? Is it using Eclipse or javac? If you are using eclipse, make sure that under Project->Properties->Java Compiler, Class file generation has "Add Variable attributes .... " checked. If you are using javac, try passing -g option.
Re: Debug problem [message #714009 is a reply to message #713981] Tue, 09 August 2011 15:24 Go to previous message
Andrey  is currently offline Andrey Friend
Messages: 4
Registered: April 2011
Junior Member
Quote:
You want to make sure that the class files are built with debug information. How is the class file getting built? Is it using Eclipse or javac? If you are using eclipse, make sure that under Project->Properties->Java Compiler, Class file generation has "Add Variable attributes .... " checked. If you are using javac, try passing -g option.

You're absolutely right. I built clas files in a wrong way. I should have thought about this one the first place.
Thank you. I am really grateful.
Previous Topic:(no subject)
Next Topic:No AWT, SWT Wizard in Eclipse Indigo
Goto Forum:
  


Current Time: Tue Apr 16 10:09:40 GMT 2024

Powered by FUDForum. Page generated in 0.21359 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top