Using RemoteConsole for debugging

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Using RemoteConsole for debugging

Postby otzengulasch » Wed Feb 08, 2012 12:34 am

Hi,

I would like to use the Consoleviewer to trace the exceptions thrown from the software on the brick.
I have managed to use the console via a RConsole.openUSB(..) statement, but as far as I understand it, I can only use this to print stuff from within the program.
What I really want is to have the console display the exception thrown, and the location in the source code where it occured.
I have read the debugging tutorial, especially this part:
Code: Select all
..this time -od to create the debug information and -gr to add the remote console debug code to the program.

and I have compiled my program, linked it with the specified commands and uploaded it. Upon starting, I instantly get an error (an exception?) and the 'error sound'.
The LCD reads:
Code: Select all
Exception: 115
FExec
at:  530(15)
...

(if the following lines are of importance, Ill copy them here).

Any hint what I am doing wrong? Do I have to do anything with the debug file that is created by the "-od" option?

On a side note: Is it possible in eclipse to tell the run configuration that compiles/links/uploads with which parameters to run the linker?

Thanks for any comments! :)
otzengulasch
New User
 
Posts: 3
Joined: Tue Feb 07, 2012 11:06 am

Re: Using RemoteConsole for debugging

Postby gloomyandy » Wed Feb 08, 2012 12:45 am

That exception means the program file was invalid. Possible reasons are:
1. The program did not link properly
2. You have uploaded the wrong file (is it zero length)
3. You linked it with a linker that is not compatible with the version of leJOS you have installed
4. There was some sort of error with the upload

Are you using the command line tools to do this? What happens if you use the same tools but don't specify the various debug options? Are you getting any warnings or errors from the linker?

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3633
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Using RemoteConsole for debugging

Postby otzengulasch » Wed Feb 08, 2012 1:04 am

Thanks for your reply!

I am using the command line tools for this. I usually use the eclipse plugin to compile/link/upload, and that works fine.
It seems there is a problem with the created file since I cant open the debug file with the debug tool either.
I suspect it has something todo with the file containing two classes, and I don't know how to specify them correctly in the linker.

Two things I have trouble with:
1. As I understand it, I have to execute the linker from the 'src' folder and then specify the fully qualified classname, eg. my.package.ClassName, right?
2. I don't know how to correctly specify the second class which is in the same java file (An implementation of a MoveListener).

I have just tested with a simple program, and that seems to work well. However, I still only get the 'nxj-specific' exception-locations - Is there a way to directly display the location of the exception in the source code by using the nxjconsole?
otzengulasch
New User
 
Posts: 3
Joined: Tue Feb 07, 2012 11:06 am

Re: Using RemoteConsole for debugging

Postby Xfel » Wed Feb 08, 2012 6:48 am

If you are talking about nxjlink, you don't need to specify all classes. You should only name the main classes. Any other class will be read from the dependencies. I think the eclipse plugin sould have an option for rconsole debugging, but I am not sure where it is (Most probably in the "Run Configurations" dialog).

I think should check out the org.lejos.example project. It is shipped with an ant buildfile, which you can use for your project, too. The buildfile also contains targets for automated rconsole debugging. If you are familiar with ant, this is the best solution.
Xfel
New User
 
Posts: 11
Joined: Mon Jan 30, 2012 3:29 pm

Re: Using RemoteConsole for debugging

Postby skoehler » Wed Feb 08, 2012 9:34 am

Xfel wrote:If you are talking about nxjlink, you don't need to specify all classes. You should only name the main classes. Any other class will be read from the dependencies. I think the eclipse plugin sould have an option for rconsole debugging, but I am not sure where it is (Most probably in the "Run Configurations" dialog).


http://lejos.sourceforge.net/nxt/nxj/tu ... clipse.htm
That option to launch nxjconsole after the upload is not yet implemented.
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: Using RemoteConsole for debugging

Postby gloomyandy » Wed Feb 08, 2012 10:07 am

Hi Sven,
but does the option correctly enable all of the linker settings? If so I assume you can then run the console (with the correct command line), manually adn get the correct exception decode?

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3633
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Using RemoteConsole for debugging

Postby skoehler » Wed Feb 08, 2012 11:13 am

gloomyandy wrote:Hi Sven,
but does the option correctly enable all of the linker settings? If so I assume you can then run the console (with the correct command line), manually adn get the correct exception decode?


The other options work and are correctly passed to the linker. Just actually launching nxjconsole isn't implemented.
skoehler
leJOS Team Member
 
Posts: 1350
Joined: Thu Oct 30, 2008 4:54 pm

Re: Using RemoteConsole for debugging

Postby otzengulasch » Wed Feb 08, 2012 1:46 pm

Xfel wrote:I think should check out the org.lejos.example project. It is shipped with an ant buildfile, which you can use for your project, too. The buildfile also contains targets for automated rconsole debugging. If you are familiar with ant, this is the best solution.

That was a great hint! :)
I basically extended the buildfile with this target:

Code: Select all
<target name="debugurunconsole" depends="debugdeleteclassfiles" description="Start the console with debugfile after upload">
      <echo message="Debug information begins here:"/>
      <echo message="=================================:"/>
      <sleep seconds="2"/>
      <java classname="lejos.pc.tools.NXJConsole" fork="true" failonerror="true">
         <sysproperty key="nxj.home" file="${nxj.home}"/>
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="-u" />
         <arg value="-di" />
         <arg file="${output.nxd}" />
      </java>
   </target>


Which will start the NXJConsole with the debugfile. In eclipse you can even click on the location at which the exception occured in the cource code.
otzengulasch
New User
 
Posts: 3
Joined: Tue Feb 07, 2012 11:06 am


Return to NXJ Software

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 4 guests

more stuff