org.ow2.asmdex.structureWriter
Class DebugInfoItem

java.lang.Object
  extended by org.ow2.asmdex.structureWriter.DebugInfoItem

public class DebugInfoItem
extends java.lang.Object

This Class represents the debug_info_item structure of one code_item. It also holds the method to write to a byte array the debug bytecode. NOTE : - Epilogue : Not encoded, as I don't know how it is handled (I never saw it encoded). - Source file : Not encoded. It would require a new event from AsmDex, not very important.

Author:
Julien Névo

Constructor Summary
DebugInfoItem(ConstantPool constantPool)
          Constructor of the Debug Info Item.
 
Method Summary
 boolean areSymbolicIndexesUsed()
          Indicates if at least one index is encoded in the debug code.
 void closeDebugInfoItem()
          Closes the debug_info_item by adding a End_Sequence opcode.
 void free()
          Frees all the structures (list of debug instructions...) so that they don't consume memory.
 ByteVector getDebugInfoItemCode()
          Returns the bytecode of the Debug Info Item, still using symbolic indexes.
 void initializeDebugInfoItem(java.lang.String[] parameters, CodeItem codeItem, java.util.List<LocalVariable> localVariables)
          Initializes the debug_info_item vector by creating its header.
 ByteVector mapResolvedIndexes(ByteVector in, int offsetInputBuffer)
          Parses the debug bytecode and maps the resolved indexes (Strings, Types) from the symbolic ones.
 void parseDebugInformation(Instruction instruction, int address)
          Parses the Debug Information that an Instruction to be encoded contains (or not), and fills the debug_code_item accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugInfoItem

public DebugInfoItem(ConstantPool constantPool)
Constructor of the Debug Info Item.

Parameters:
constantPool - the Constant Pool of the Application.
Method Detail

free

public void free()
Frees all the structures (list of debug instructions...) so that they don't consume memory. This should be done after having generated the bytecode, once the method has been parsed and its end visited.


initializeDebugInfoItem

public void initializeDebugInfoItem(java.lang.String[] parameters,
                                    CodeItem codeItem,
                                    java.util.List<LocalVariable> localVariables)
Initializes the debug_info_item vector by creating its header. It is not useable as-is though, but it can only be when the whole application has been parsed, as it encodes the parameters index from its symbolic index. It will have to be parsed again later.

Parameters:
parameters - the parameters of the Method, or null.
codeItem - the Code Item the Debug Info item is related to.
localVariables - the Local Variables of the current Method.

parseDebugInformation

public void parseDebugInformation(Instruction instruction,
                                  int address)
Parses the Debug Information that an Instruction to be encoded contains (or not), and fills the debug_code_item accordingly. This one is however not encoded for now in the Dex file.

Parameters:
instruction - the Instruction to be encoded.
address - address in bytes of the Instruction from the beginning of the byte code itself.

closeDebugInfoItem

public void closeDebugInfoItem()
Closes the debug_info_item by adding a End_Sequence opcode.


mapResolvedIndexes

public ByteVector mapResolvedIndexes(ByteVector in,
                                     int offsetInputBuffer)
Parses the debug bytecode and maps the resolved indexes (Strings, Types) from the symbolic ones. The mapping between the two, done through two tables in the Constant Pool, must have been performed before.

Parameters:
in - input buffer to parse.
offsetInputBuffer - offset inside the input buffer from where to start the parsing.
Returns:
the parsed and modified debug bytecode.

getDebugInfoItemCode

public ByteVector getDebugInfoItemCode()
Returns the bytecode of the Debug Info Item, still using symbolic indexes. The method bytecode must have been generated first.

Returns:
the bytecode of the Debug Info Item, still using symbolic indexes.

areSymbolicIndexesUsed

public boolean areSymbolicIndexesUsed()
Indicates if at least one index is encoded in the debug code. We use it to optimize the mapping with the resolved indexes : it doesn't need do be done if no index was found.

Returns:
true if at least one index is encoded in the debug code.