The Source for Java Technology Collaboration
User: Password:



Mark Lam's Blog

Tools Archives


CVM's VM Inspector

Posted by mlam on July 31, 2007 at 11:59 PM | Permalink | Comments (1)

In a previous blog entry, I showed you a map of CVM. If you are a VM engineer (or someone who is doing a port of the VM), and need to do some debugging, navigating all that data structures can be pretty daunting. How do the CVM engineers do it?

History
Since the very early days, CVM was built with a bunch of utility functions that allows us to dump certain information about certain commonly used VM data structures. For example, 2 very popular examples of these are:

1. CVMconsolePrintf(), and
2. CVMdumpStack()

CVMconsolePrintf() is just like printf except that it adds some nice formating options like %O, %C, %M, %F, that prints the details of a CVMObject *, CVMClassBlock *, CVMMethodBlock *, and CVMFieldBlock * respectively. There is more, but this gives you the idea. CVMdumpStack() is used to dump the contents of the Java stack. The CVM engineers would call these utility functions from the gdb command prompt at runtime to get live information about the state of the VM and its data structures.

However, there is a problem with using these utility functions. That is, you will need to be careful how you use them. For example, if you use CVMconsolePrintf("%C", ...) with a pointer that is a CVMClassBlock *, then you may inadvertantly cause a segfault that will crash the VM. And this would mean that you could lose all the debugging state of the bug that you have spent hours or days to reproduce.

Can't we just get the VM utilities to just do all the careful checks for us automatically so that we don't make a foll of ourselves by calling the wrong call at the wrong time?

the VM Inspector
Why, yes we can ...

Continue Reading...



CDC and JVMTI

Posted by mlam on July 30, 2007 at 10:45 PM | Permalink | Comments (8)

In a comment in a previous blog entry, a friend asked a question about using the JVMTM Tools Interface (JVMTI) with JavaME CDC ...

... I am considering to use JVMTI instead of JVMPI. However, I have one concern that does JVMTI applicable to CDC 1.1(HI)? As you know, CDC 1.1 is based on JavaSE 1.4, but JVMTI is based on JavaSE 1.5.

Kind regards
Byungseon Shin

Here's what I think ...

Continue Reading...



Async Thread Dumps on CVM

Posted by mlam on June 22, 2007 at 01:45 AM | Permalink | Comments (4)

There are times in the course of your development effort when your application just seems to hang forever. At those times, you wish you had some way of knowing where the hang is occurring. If you're running on JavaSE, chances are you'll have a lot of advanced tools that makes life easy for you. But if you're running on an embedded device, suddenly, your options are now severely limited. For the phoneME Advanced VM (CVM), there's a way to get help on this even when there is not advance debugging support on your device.

What I'll be showing here is an old trick to get an asynchronous dump of the stacks of all the threads that are currently alive in the VM. First of all, you need to know that this is a hack i.e. it's not good and clean code. That's why I haven't already committed it to the source repository, and won't be doing so. The reason it is a hack will be explained below later under Why this is a Hack!!!. But even though it is a hack, it is useful when you need it. Many of my colleagues as well as customers have often asked me for the code patch for this hack to help with debugging the hangs in their applications. I figure you might find it helpful too.

So, here it is ...

Continue Reading...





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds