PhoneMEAdvancedCVMSH < Mobileandembedded < TWiki

TWiki . Mobileandembedded . PhoneMEAdvancedCVMSH

The VM Inspector and cvmsh

Useful links

After you've read the content below, these other links provide more info on using the VM Inspector and cvmsh

What is the VM Inspector?

The VM Inspector is just a collection of utilities that already existed in the CVM for other purposes, plus some wrappers around some of them to make them safe to call from Java code. It also include some other additional useful utilities that aren't normally available in a production VM build.

To use the VM inspector utilities, build CVM with CVM_INSPECTOR=true. CVM_INSPECTOR is set to true by default when you build with CVM_DEBUG=true, but you can also enable it in a non-debug build without having to pull in all the other debug code in the system.

After you have built CVM as specified above, you can now use the VM Inspector utilities in a number of ways:

  1. Start CVM in a gdb session, and call some of the inspector functions from the gdb command prompt.
  2. Call them from modified VM code. For a list of the available functions, check out src/share/javavm/include/inspector.h in the phoneME Advanced VM codebase.
  3. Use cvmsh as a shell on the target device/machine and issue commands interactively.
  4. Run cvmsh in server mode, and connect to it using the cvmclient application.

With option 1 and 2, you will need to be careful as to when and how you use these functions. You will be essentially writing and/or changing the flow of VM code. If you don't do this correctly, you can destabilize the VM instance that you are running. This may result in crashes, hangs, or unpredictable failures. The easier thing to do would be to go with option 3 or 4 which interfaces the VM Inspector through the cvmsh application.

What is cvmsh?

cvmsh is a simple shell program written in the Java programming language that is intended to help with diagnostics and inspection of VM internals when running applications. In one regard, it is a poor man's debugger/profiler. It is useful for things like:

cvmsh can be used by application developers or class library developers who want to see what happens in terms of the VM state when Java code is executed. Because cvmsh is a Java program, it's purpose is not for debugging bugs that crashes the VM. Note that cvmsh itself relies on the VM working correctly.

Why use cvmsh?

One advantage of using cvmsh instead of calling the inspector or other CVM utility functions directly from gdb is that it is a lot more user friendly. User friendly in the sense that it is very difficult for you to accidentally crash the VM from cvmsh. It isn't user friendly in terms of presenting you with a fancy GUI with nice graphics. Currently, it's a low tech text based only tool i.e. a "poor man's debugger/profiler".

How to use cvmsh?

Here is a quick summary user's manual on cvmsh:
  1. Building cvmsh
    To build cvmsh, build CVM with CVM_INSPECTOR=true added to the make command line. CVM_INSPECTOR is true by default for CVM_DEBUG=true builds. However, it is possible to build CVM with CVM_INSPECTOR=true independent of whether CVM_DEBUG=true or not.

    The CVM_INSPECTOR=true option will add inspector code (Java and native) into the CVM binary (and possibly JAR files). One of these classes will be the sun.misc.VMInspector. This class is intended for private use only.

    cvmsh will be built into testclasses.zip.

  2. How to run cvmsh?
    cvmsh only works with CVM because it relies on APIs in sun.misc.VMInspector. It will not run with other VMs. At the OS command prompt, run:
    > cvm -cp testclasses.zip cvmsh

  3. How to use cvmsh?
    cvmsh launches into a command prompt: '>' At the command prompt, you can enter these commands:

Disclaimer

The VM Inspector code is just a collection of utilities that can be used to browse VM data structures and inspect the state of the VM. It is by no means exhaustive in functionality, and is not guaranteed to be bug free either. This is because it isn't an official product feature. Therefore, it has not undergone rigorous testing of an official release process. However, it can still be quite useful for debugging and profiling work in the absence of more advanced tools.

-- Main.mlam - 19 Sep 2007

----- Revision r3 - 08 Dec 2008 - 22:23:40 - ChrisPlummer