FAQs about Software Tools JEMBuilder and Charade

Discussion regarding tools such as JEMBuilder/Charade/JDEBUG etc.

FAQs about Software Tools JEMBuilder and Charade

Postby admin » Sun Nov 05, 2006 7:21 am

Why do I get CharadeOutputStream timeouts?

When I run my program I get:

vm.0 breakpoint: [CharadeOutputStream timeout]


Pressing backtrace shows the following method as the one that caused the exception:

com\ajile\jem\CharadeOutputStream.write(I)V

A: Once the CharadeOutputStream's buffer fills up on the target, the thread sending data is blocked waiting for Charade to get around to emptying the data from the OutputStream. If Charade does not service the buffer within 5 seconds, an IOException is thrown.

Sending System.out & System.err to Charade is done at a fairly low rate. Often limited to 512 characters per second. This depends on many variables including speed of the receiving PC. If you run into charadeOutputStream timeouts do one of the following:

* Redirect System.out to the serial port. This is easily done by adding the serial driver. And checking the redirect checkbox in the serial driver page.
* Reduce the amount of data you are sending out system.out.
Last edited by admin on Mon Nov 06, 2006 10:28 pm, edited 3 times in total.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:22 am

What does "no Stack Trace" mean?

Q:
When my program gets an exception, the Charade console prints the exception name and the text "no Stack Trace". If I catch the exception and invoke printStackTrace() on the exception, I get "no Stack Trace". Is there any way to get a stack trace out of the target?

A:
Ok two things are going on here:

* First the "no stack track", when JemBuilder creates the build.bin file it strips out information like method names and class names. This is done to produce the smallest build possible. In the future, options will exist allowing builds to retain this information. However without this information the target JVM can not provide a stack trace. In the next release(3.16) Charade will be able to detect this condition and display the stack trace information.
* The second part involves detecting exceptions. When an exception is created by user code and thrown the invokeThrowObject() method is invoked. When the runtime generates an exception such as a "null pointer execption" the invokeThrowID() method is invoked. You can set breakpoints on these methods. When the methods are reached enter "bt" (backtrace) in Charade to view the call stack and see the method that generated the execption. Depending on user code you may have to step though many of these breakpoints before getting to the particular one generating the "no stack trace" message.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:23 am

What is RTS_Exception.invokeThrowID?

RTS_Exception.invokeThrowID is the method called when the JEM detects a VM error . The purpose of invokeThrowID is to create a exception object which is then passed on to invokeThrowObject. invokeThrowObject then searches for the appropriate exception handler and transfers control to the handler. The following list enumerates the possible conditions that invokeThrowID handles:

* (0) ArithmeticException
* (1) ArrayIndexOutOfBounds
* (2) ArrayStore
* (3) ClassCast
* (4) IllegalArgument
* (5) IllegalMonitorState
* (6) InterruptedException
* (7) NegativeArraySize
* (8) NullPointer
* (9) OutOfMemory
* (10)SecurityException
* (11) InternalError

To determine which condition invokeThrowID is handling examine the stack value at "+2" in the stack window. Or the user can single step and watch which exception object is created.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:24 am

When I run my program Charade stops in TS_Exception.invokeThrowObject. What is this?

InvokeThrowObject is the runtime method called when an exception is thrown in user code. Often people set a breakpoint in InvokeThrowObject to know when the user program is throwing exceptions. If throwing exceptions is normal behavior for your program you can just press "Run" to continue executing the program. Also you can remove the break point by: using the "delete break" command. You will need to supply the break point number reported by Charade when the break point was hit.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:26 am

When I run my program, I end up in invokeThrowID with an illegalMonitorState

When I run my program, I end up in invokeThrowID with an illegalMonitorState. When you try to do a synchronization operation such as notify,notifyAll or wait, Java attempts to get the lock on the object. If the operations are not performed inside of synchronize block, a illegalMonitorState is thrown.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:26 am

Why do I end up in InvokeThrowObject twice when an exception is thrown
Symption, I throw an exception and I hit the breakpoint in invokeThrowObject twice.


The exception is being rethrown. If the method has a finally block this is happening by default. the exception is being re-raised immediately after the finally block completes.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:27 am

How do I track down who generated an exception?

By default the setup script in Charade sets two breakpoints. One on internal exceptions being generated (InvokeThrowId) and one on exceptions being thrown (InvokeThrowObject). You can use the "br" show all the breakpoints currently set in Charade.

To determine who generated the exception you can do the following:

* You can do a backtrace command to show your call stack.
* Also look at the process stack window, you should see what exception was generated as parameter +2 in the stack window.
* You can bring up the exception in the object viewer and examine the detailed message of the exception as well.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:29 am

I want to set a break point on my method my.foo(). How do I find the address of the foo() method?

To set a break point on a method, enter the command "br my.foo" This will insert a software breakpoint at the start of the method.

If you are debugging a program in flash you will not be able to use this method. Since software breakpoints are intrusive. Instead use the show map my.foo command in Charade. This will yeild the address of the method header. You will then be able to set a Code breakpoint on the method. Take the address of the method and add 0x0c to it to get the address of the first instruction in the method and enter the command "br [method address + 0x0c] code" in Charade.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:29 am

When I try to set a breakpoint, Charade tells me: "cannot enable breakpoint". What is going on?

The JEM only supports two code/data breakpoints. Try clearing a break point or setting a software breakpoint.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:29 am

How do I break on an exception being thrown?

When an exception is thrown, the JEM calls a runtime method called com/ajile/jem/RTS_Exception.invokeThrowObject. To break on exceptions set a breakpoint at the start of this method. For example in Charade do a "br invokethrowobject"
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:30 am

Break points don't seem to be working

Hardware breakpoints on the JEM2 are not always reliable. Software breakpoints are reliable. To use a software breakpoint append a "sw" at the end of break command. For example "br #1234 sw" will set a software break point at address 0x1234. Symbolic breakpoints are software break points by default. For example: "br invokeThrowObject" will set a software breakpoint. Software breakpoints are intrusive. They act by inserting a "breakpoint" byte code. For this reason software breakpoints can not be used if you are running out of flash memory.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:30 am

When I reload my program my breakpoints disappear.

Software breakpoints are intrusive. To set a breakpoint Charade actually inserts a breakpoint byte code at the specified location. When a program is loaded it may overwrite the breakpoint byte code. Charade will detect this and remove the breakpoint from its list of breakpoints. This is necessary since the break point may no longer be at a valid location.
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:31 am

Why do I get a parse error when I try to set a break point?

Charade expects break points to be hex numbers. To that end they must be preceded by a "#" or a "0x". For example: "br #41b5" or "break 0x41b5"
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:31 am

How do I set a breakpoint in a constructor?

To set a breakpoint in the constructor for class "foo", enter the command "br foo.init" in Charade. This will set a breakpoint on the first constructor in class foo. If you need to set the breakpoint in a different constructor you will have to supply additional signature information after the "init"
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Postby admin » Sun Nov 05, 2006 7:31 am

Code data breakpoints don't work

Code data breakpoints watch for the address on the JEM's address bus. The bus is 32 bit bus. If you set the code data breakpoint on a non word aligned address (i.e. the low two bits contain data) The JEM breakpoint hardware will never see that address on the bus. Therefore the system will never stop.
Options:

* You can instead use the PC breakpoints, these watch for the program count to reach a specific address. These breakpoints to "skid" a few instructions.
* Use SW breakpoints mask off the low two bits of the address before setting the code data breakpoint
admin
Site Admin
 
Posts: 80
Joined: Sat Oct 28, 2006 6:14 am

Next

Return to Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron