1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
<!-- ##### SECTION Title ##### -->
Code Disassembly
<!-- ##### SECTION Short_Description ##### -->
Functions for code disassembly.
<!-- ##### SECTION Long_Description ##### -->
<para>
Credits
Information for the instructions was obtained from
<ulink url="http://mrl.nyu.edu/~meyer/jvmref/ref-Java.html"/>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### MACRO OP_LENGTH_UNPREDICTABLE ##### -->
<para>
The length of the operands is unpredictable.
</para>
<!-- ##### ENUM OperandType ##### -->
<para>
Operand types.
</para>
@OP_TYPE_NONE: No operand.
@OP_TYPE_BYTE: The operand is a signed byte.
@OP_TYPE_UNSIGNED_BYTE: The operand is an unsigned byte.
@OP_TYPE_BYTE_ARRAY_TYPE: The operand is an unsigned byte representing a
primitive array type. Possible values are listed in the ArrayType enum.
You can also use the jclass_code_array_name() function to get a string with
the name.
@OP_TYPE_BYTE_CONSTANT_INDEX: The operand is an unsigned byte index in the constant
pool for a constant.
@OP_TYPE_UNSIGNED_BYTE_USELESS: The operand is an unsigned byte which is useless.
See the documentation for the invokeinterface instruction to see what I mean.
@OP_TYPE_SHORT: The operand is a signed short integer.
@OP_TYPE_UNSIGNED_SHORT: The operand is an unsigned short integer.
@OP_TYPE_SHORT_OFFSET: The operand is a short offset from the pc of the instruction.
@OP_TYPE_SHORT_CLASS_INDEX: The operand is a short integer which is the index
of a class in the constant pool.
@OP_TYPE_SHORT_METHOD_INDEX: The operand is a short integer which is the index
of a method in the constant pool.
@OP_TYPE_SHORT_FIELD_INDEX: The operand is a short integer which is the index
of a field in the constant pool.
@OP_TYPE_SHORT_CONSTANT_INDEX: The operand is a short integer which is the
index of a constant in the constant pool.
@OP_TYPE_INT: The operand is a 32-bit signed integer.
@OP_TYPE_INT_OFFSET: The operand is a signed integer offset from the pc of th instruction.
@OP_TYPE_INSTRUCTION: The operand is an instruction (See wide instruction).
@OP_TYPE_TABLESWITCH: The operand is a tableswitch.
It is always aligned at a 4-byte boundary.
The "page" or whatever you want to call it starts at the first byte of the code.
@OP_TYPE_LOOKUPSWITCH: The operand is a lookupswitch.
It is always aligned at a 4-byte boundary.
@OP_TYPE_ERROR: Some kind of error occured.
<!-- ##### ENUM ArrayType ##### -->
<para>
Primitive array type values. This enumeration is used in the newarray instruction
to indicate the type of the primitive array. The operand is OP_TYPE_BYTE_ARRAY_TYPE.
</para>
@ARRAY_TYPE_BOOLEAN: boolean array.
@ARRAY_TYPE_CHAR: char array.
@ARRAY_TYPE_FLOAT: float array.
@ARRAY_TYPE_DOUBLE: double array.
@ARRAY_TYPE_BYTE: byte array.
@ARRAY_TYPE_SHORT: short array.
@ARRAY_TYPE_INT: int array.
@ARRAY_TYPE_LONG: long array.
<!-- ##### STRUCT TableSwitchOperand ##### -->
<para>
Operand for the tableswitch instruction.
</para>
@num_pairs:
@default_target:
@low_value:
@target:
<!-- ##### STRUCT LookupSwitchOperand ##### -->
<para>
Operand for the lookupswitch instruction.
</para>
@num_pairs:
@default_target:
@value:
@target:
<!-- ##### MACRO MAX_LEGAL_OPCODE ##### -->
<para>
The maximum legal opcode for an instruction.
</para>
<!-- ##### FUNCTION jclass_code_instruction_name ##### -->
<para>
</para>
@opcode:
@Returns:
<!-- ##### FUNCTION jclass_code_instruction_ops ##### -->
<para>
</para>
@opcode:
@Returns:
<!-- ##### FUNCTION jclass_code_instruction_ops_length ##### -->
<para>
</para>
@opcode:
@Returns:
<!-- ##### FUNCTION jclass_code_instruction_op_type ##### -->
<para>
</para>
@opcode:
@operand_number:
@is_wide:
@Returns:
<!-- ##### FUNCTION jclass_code_read_byte ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_ubyte ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_short ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_ushort ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_int ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_tableswitch ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_read_lookupswitch ##### -->
<para>
</para>
@code:
@pc:
@Returns:
<!-- ##### FUNCTION jclass_code_lookupswitch_operand_free ##### -->
<para>
</para>
@operand:
<!-- ##### FUNCTION jclass_code_tableswitch_operand_free ##### -->
<para>
</para>
@operand:
<!-- ##### MACRO JCLASS_CODE_ALIGN_PC ##### -->
<para>
Aligns the PC at a 4-byte boundary.
Useful for tableswitch and lookupswitch.
</para>
<example>
<title>Read a tableswitch operand</title>
<programlisting>
<![CDATA[
pc = JCLASS_CODE_ALIGN_PC(pc);
/* get default target offset */
default_target = jclass_code_read_int(code->code, &pc);
/* low */
low = jclass_code_read_int(code->code, &pc);
/* high */
high = jclass_code_read_int(code->code, &pc);
/* store the targets in an array */
target = (uint32*) malloc(sizeof(uint32) * ((high - low) + 1));
for(count = 0; count < (high - low) + 1; count++)
target[count] = instruction_pc + jclass_code_read_int(code->code, &pc);
]]>
</programlisting>
</example>
@pc: The current pc.
<!-- ##### FUNCTION jclass_code_array_name ##### -->
<para>
</para>
@array_number:
@Returns:
|