Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.dex.file

public Class DebugInfoDecoder

extends Object
Class Inheritance
Imports
org.droidparts.dexmaker.dx.dex.code.DalvCode, .DalvInsnList, .LocalList, .PositionList, org.droidparts.dexmaker.dx.rop.cst.CstMethodRef, .CstString, org.droidparts.dexmaker.dx.rop.type.Prototype, .StdTypeList, .Type, org.droidparts.dexmaker.dx.util.ByteArrayByteInput, .ByteInput, .ExceptionWithContext, .Leb128Utils, java.io.IOException, java.util.ArrayList, .List

A decoder for the dex debug info state machine format. This code exists mostly as a reference implementation and test for for the DebugInfoEncoder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DebugInfoDecoder.LocalEntry

An entry in the resulting locals table

private static class
DebugInfoDecoder.PositionEntry

An entry in the resulting postions table

Field Summary

Modifier and TypeField and Description
private int
address

current decoding state: bytecode address

private final int
codesize

size of code block in code units

private final Prototype
desc

method descriptor of method this debug info is for

private final byte[]
encoded

encoded debug info

private final DexFile
file

dex file this debug info will be stored in

private final boolean
isStatic

true if method is static

private final DebugInfoDecoder.LocalEntry[]
lastEntryForReg

indexed by register, the last local variable live in a reg

private int
line

current decoding state: line number

private final ArrayList<DebugInfoDecoder.LocalEntry>
locals

locals decoded

private final ArrayList<DebugInfoDecoder.PositionEntry>
positions

positions decoded

private final int
regSize

register size, in register units, of the register space used by this method

private final int
thisStringIdx

string index of the string "this"

Constructor Summary

AccessConstructor and Description
pack-priv
DebugInfoDecoder(byte[]
encoded debug info
encoded
,
int
size of code block in code units
codesize
,
int
register size, in register units, of the register space used by this method
regSize
,
boolean
true if method is static
isStatic
,
CstMethodRef
method descriptor of method this debug info is for
ref
,
DexFile
dex file this debug info will be stored in
file
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
decode()

Decodes the debug info sequence.

private void
public List<DebugInfoDecoder.LocalEntry>

Returns:

locals list in ascending address order.
getLocals
()

Gets the decoded locals list, in ascending start-address order.

private int

Returns:

register as noted above.
getParamBase
()

Gets the register that begins the method's parameter range (including the 'this' parameter for non-static methods).

public List<DebugInfoDecoder.PositionEntry>

Returns:

positions list in ascending address order.
getPositionList
()

Gets the decoded positions list.

private int

Returns:

index into file's string ids table, -1 means null
readStringIndex
(ByteInput bs)

Reads a string index.

public static void
validateEncode(byte[]
encoded debug info
info
,
DexFile
non-null; file to refer to during decoding
file
,
CstMethodRef
non-null; method whose info is being decoded
ref
,
DalvCode
non-null; original code object that was encoded
code
,
boolean
whether the method is static
isStatic
)

Validates an encoded debug info stream against data used to encode it, throwing an exception if they do not match.

private static void
validateEncode0(byte[] info, int codeSize, int countRegisters, boolean isStatic, CstMethodRef ref, DexFile file, PositionList pl, LocalList ll)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addressback to summary
private int address

current decoding state: bytecode address

codesizeback to summary
private final int codesize

size of code block in code units

descback to summary
private final Prototype desc

method descriptor of method this debug info is for

encodedback to summary
private final byte[] encoded

encoded debug info

fileback to summary
private final DexFile file

dex file this debug info will be stored in

isStaticback to summary
private final boolean isStatic

true if method is static

lastEntryForRegback to summary
private final DebugInfoDecoder.LocalEntry[] lastEntryForReg

indexed by register, the last local variable live in a reg

lineback to summary
private int line

current decoding state: line number

localsback to summary
private final ArrayList<DebugInfoDecoder.LocalEntry> locals

locals decoded

positionsback to summary
private final ArrayList<DebugInfoDecoder.PositionEntry> positions

positions decoded

regSizeback to summary
private final int regSize

register size, in register units, of the register space used by this method

thisStringIdxback to summary
private final int thisStringIdx

string index of the string "this"

Constructor Detail

DebugInfoDecoderback to summary
pack-priv DebugInfoDecoder(byte[] encoded, int codesize, int regSize, boolean isStatic, CstMethodRef ref, DexFile file)

Constructs an instance.

Parameters
encoded:byte[]

encoded debug info

codesize:int

size of code block in code units

regSize:int

register size, in register units, of the register space used by this method

isStatic:boolean

true if method is static

ref:CstMethodRef

method descriptor of method this debug info is for

file:DexFile

dex file this debug info will be stored in

Method Detail

decodeback to summary
public void decode()

Decodes the debug info sequence.

decode0back to summary
private void decode0() throws IOException
getLocalsback to summary
public List<DebugInfoDecoder.LocalEntry> getLocals()

Gets the decoded locals list, in ascending start-address order. Valid after calling decode.

Returns:List<DebugInfoDecoder.LocalEntry>

locals list in ascending address order.

getParamBaseback to summary
private int getParamBase()

Gets the register that begins the method's parameter range (including the 'this' parameter for non-static methods). The range continues until regSize

Returns:int

register as noted above.

getPositionListback to summary
public List<DebugInfoDecoder.PositionEntry> getPositionList()

Gets the decoded positions list. Valid after calling decode.

Returns:List<DebugInfoDecoder.PositionEntry>

positions list in ascending address order.

readStringIndexback to summary
private int readStringIndex(ByteInput bs) throws IOException

Reads a string index. String indicies are offset by 1, and a 0 value in the stream (-1 as returned by this method) means "null"

Returns:int

index into file's string ids table, -1 means null

validateEncodeback to summary
public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic)

Validates an encoded debug info stream against data used to encode it, throwing an exception if they do not match. Used to validate the encoder.

Parameters
info:byte[]

encoded debug info

file:DexFile

non-null; file to refer to during decoding

ref:CstMethodRef

non-null; method whose info is being decoded

code:DalvCode

non-null; original code object that was encoded

isStatic:boolean

whether the method is static

validateEncode0back to summary
private static void validateEncode0(byte[] info, int codeSize, int countRegisters, boolean isStatic, CstMethodRef ref, DexFile file, PositionList pl, LocalList ll)
org.droidparts.dexmaker.dx.dex.file back to summary

private Class DebugInfoDecoder.LocalEntry

extends Object
Class Inheritance
  • java.lang.Object
  • org.droidparts.dexmaker.dx.dex.file.DebugInfoDecoder.LocalEntry

An entry in the resulting locals table

Field Summary

Modifier and TypeField and Description
public int
address

address of event

public boolean
isStart

true iff it's a local start

public int
nameIndex

index of name in strings table

public int
reg

register number

public int
signatureIndex

index of type signature in strings table

public int
typeIndex

index of type in types table

Constructor Summary

AccessConstructor and Description
public
LocalEntry(int address, boolean isStart, int reg, int nameIndex, int typeIndex, int signatureIndex)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
public int address

address of event

isStartback to summary
public boolean isStart

true iff it's a local start

nameIndexback to summary
public int nameIndex

index of name in strings table

regback to summary
public int reg

register number

signatureIndexback to summary
public int signatureIndex

index of type signature in strings table

typeIndexback to summary
public int typeIndex

index of type in types table

Constructor Detail

LocalEntryback to summary
public LocalEntry(int address, boolean isStart, int reg, int nameIndex, int typeIndex, int signatureIndex)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

org.droidparts.dexmaker.dx.dex.file back to summary

private Class DebugInfoDecoder.PositionEntry

extends Object
Class Inheritance
  • java.lang.Object
  • org.droidparts.dexmaker.dx.dex.file.DebugInfoDecoder.PositionEntry

An entry in the resulting postions table

Field Summary

Modifier and TypeField and Description
public int
address

bytecode address

public int
line

line number

Constructor Summary

AccessConstructor and Description
public
PositionEntry(int address, int line)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addressback to summary
public int address

bytecode address

lineback to summary
public int line

line number

Constructor Detail

PositionEntryback to summary
public PositionEntry(int address, int line)