9. The Ajanta Debugger



All the java files whether they are system defined or application specific can use Debug features in their program to selectively enable or disable certain Debug statements in their programs at run time.

Overview of Debug statements and Debug file

1. Format of Debug statement:

        Debug("server.AgentServer.run", " run method being executed");

Debug statements takes two string parameters:
          -  first parameters is the name of the flag
          -  second parameter is the message to be printed
If the flag is set at the runtime then it will print the given message on standard
output . To include Debug statements in your files import ajanta.util.Debug  in
your java files.

2. Naming convention for flags:

Flags names are hierarchical in nature.
               PackageName.FileName.FunctionName
               i.e. server.AgentServer.run

3. Debug file and its conventions

Each user maintains a file named .ajanta/servers/Debug which conatins all the flags name which has to be enabled.  The flag entries in the files are also in hierarchical order. A sample Debug file is shown below

*********************************************************
Package = server
Class = AgentServer
#-------------------------------------------------------
#method names for this class
#-------------------------------------------------------

#AgentServer
getAgentCurrentServer
recall
retract
terminate
report
deleteDDEntry

#Class = AgentEnv
launch
registerResource
waitForResource
getResource
mapURNtoURL
createRMIProxy

#------------------------------------------------------------
#Package = agent
#Class = Agent
Agent
arrive
agentExit
start
colocate
#------------------------------------------------------------

The order of flag entries in the files are
  Packege Name
         Package = Server
  Class  Name ( or file name )
         Class = AgentServer
   Names of all the functions which has Debug Statements
           getAgentCurrentServer
              recall

Some of the flags that are enabled in the above Debug files are
             server.AgentServer.getAgentCurrentServer
             server.AgentServer.recall
             server.AgentServer.retract

'# ' is used to disable any flag .
If  it is used before function name then all the Debug statements in that function are disabled.
If it is used before  "Class = ClassName"   then all the Debug statements in that file are
disabled.
If it is used before  "Package = PackageName"   then all the Debug statements in that package
are disabled.

How to use the debugger?

Step 1:
To use the debugger first of all comment out all those flags that you do not need  by using '#' and
enter all the flags that you want to be enabled in the Debug file if they are not present. If they are
commented out by "#" then just remove them. You may have to remove "#" from Class and
Package statements appropriately.
 

 Step 2:
 Execute following commands
  1.  cd  .ajanta/servers
  2.   java ajanta.util.Debug

  It will print out all the flags that are being enabled.

Step 3:
    Enter 4 to exit and store all the enabled fllags in DebugHashTable file which will be used by
    all  the classes.
 

Currently option 1,2 and 3 need to be refined and for the time being just ignore them. Their working
should be of the nature described below.

 The process started in Step 2 above will allow one to set and reset a flage at run time. Option 1 and 2
 ask a user to enter Package name, File or Class Name and Function name and it enables or disables
  corresponding flag.
 

The following two files are needed to run the ajanta debugger:
1. .ajanta/servers/Debug
2. .ajanta/servers/DebugHashTable

Please comment out the module (class) or method to disable debug messages for that m
odule or method.

Run
> java ajanta.util.Debug

An example session
***************************************************************
tahmed@newton (~/.ajanta/servers) % java ajanta.util.Debug
WriteHashtable:Wrote the hash table950638319000
Command 1. set  2. reset  3. readflag 4. exit  :

***************************************************************

This can be used interactively to set or unset debug modules.

NOTE: Know bugs:
The module need to have the above two files



 GO  TO- Top of this page Previous Chapter   Next  Chapter    Table of Contents of this Guide