public class HexCodeFile extends Object
HexCodeFile ::= Platform Delim HexCode Delim (OptionalSection Delim)* OptionalSection ::= Comment | OperandComment | JumpTable | LookupTable Platform ::= "Platform" ISA WordWidth HexCode ::= "HexCode" StartAddress HexDigits Comment ::= "Comment" Position String OperandComment ::= "OperandComment" Position String JumpTable ::= "JumpTable" Position EntrySize Low High LookupTable ::= "LookupTable" Position NPairs KeySize OffsetSize Position, EntrySize, Low, High, NPairs KeySize OffsetSize ::= int Delim := "<||@"There must be exactly one HexCode and Platform part in a HexCodeFile. The length of HexDigits must be even as each pair of digits represents a single byte.
Below is an example of a valid Code input:
Platform AMD64 64 <||@ HexCode 0 e8000000009090904883ec084889842410d0ffff48893c24e800000000488b3c24488bf0e8000000004883c408c3 <||@ Comment 24 frame-ref-map: +0 {0} at java.lang.String.toLowerCase(String.java:2496) [bci: 1] |0 locals: |stack:0:a stack: |stack:0:a <||@ OperandComment 24 {java.util.Locale.getDefault()} <||@ Comment 36 frame-ref-map: +0 {0} at java.lang.String.toLowerCase(String.java:2496) [bci: 4] |0 locals: |stack:0:a <||@ OperandComment 36 {java.lang.String.toLowerCase(Locale)} lt;||@
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HexCodeFile.Parser
Helper class to parse a string in the format produced by
toString() and
produce a HexCodeFile object. |
Modifier and Type | Field and Description |
---|---|
byte[] |
code |
static String |
COLUMN_END |
static Pattern |
COMMENT |
Map<Integer,List<String>> |
comments
Map from a machine code position to a list of comments for the position.
|
static String |
EMBEDDED_HCF_CLOSE
Delimiter placed after a HexCodeFile when embedded in a string/stream.
|
static String |
EMBEDDED_HCF_OPEN
Delimiter placed before a HexCodeFile when embedded in a string/stream.
|
static Pattern |
HEX_CODE |
String |
isa |
static Pattern |
JUMP_TABLE |
ArrayList<CompilationResult.JumpTable> |
jumpTables |
static Pattern |
LOOKUP_TABLE |
static String |
NEW_LINE |
static Pattern |
OPERAND_COMMENT |
Map<Integer,String> |
operandComments
Map from a machine code position to a comment for the operands of the instruction at the
position.
|
static Pattern |
PLATFORM |
static Pattern |
SECTION |
static String |
SECTION_DELIM |
long |
startAddress |
int |
wordWidth |
Constructor and Description |
---|
HexCodeFile(byte[] code,
long startAddress,
String isa,
int wordWidth) |
Modifier and Type | Method and Description |
---|---|
static void |
addAnnotations(HexCodeFile hcf,
List<CompilationResult.CodeAnnotation> annotations)
Adds any jump tables, lookup tables or code comments from a list of code annotations.
|
void |
addComment(int pos,
String comment)
Adds a comment to the list of comments for a given position.
|
String |
addOperandComment(int pos,
String comment)
Sets an operand comment for a given position.
|
static String |
encodeString(String input)
Modifies a string to mangle any substrings matching
SECTION_DELIM and
COLUMN_END . |
static String |
hexCodeString(byte[] code)
Formats a byte array as a string of hex digits.
|
static HexCodeFile |
parse(String input,
int sourceOffset,
String source,
String sourceName)
Parses a string in the format produced by
toString() to produce a
HexCodeFile object. |
String |
toEmbeddedString() |
String |
toString()
Formats this HexCodeFile as a string that can be parsed with
parse(String, int, String, String) . |
void |
writeTo(OutputStream out) |
public static final String SECTION_DELIM
public static final String COLUMN_END
public static final Pattern OPERAND_COMMENT
public static final Pattern JUMP_TABLE
public static final Pattern LOOKUP_TABLE
public static final String EMBEDDED_HCF_OPEN
public static final String EMBEDDED_HCF_CLOSE
public final Map<Integer,List<String>> comments
public final Map<Integer,String> operandComments
public final byte[] code
public final ArrayList<CompilationResult.JumpTable> jumpTables
public final int wordWidth
public final long startAddress
public HexCodeFile(byte[] code, long startAddress, String isa, int wordWidth)
public static HexCodeFile parse(String input, int sourceOffset, String source, String sourceName)
toString()
to produce a
HexCodeFile
object.public String toString()
parse(String, int, String, String)
.public String toEmbeddedString()
public void writeTo(OutputStream out)
public static String hexCodeString(byte[] code)
public void addComment(int pos, String comment)
public String addOperandComment(int pos, String comment)
pos
public static void addAnnotations(HexCodeFile hcf, List<CompilationResult.CodeAnnotation> annotations)
public static String encodeString(String input)
SECTION_DELIM
and
COLUMN_END
.