|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.core.Program
The Program
class represents a complete program of AVR instructions. It stores the actual
instructions and initialized data of the program in one instr4 segment, as well as storing the data space
and eeprom space requirements for the program. It contains a map of labels (strings) to addresses, which
can be either case sensitive (GAS style) or case insensitive (Atmel style).
Instr
,
ControlFlowGraph
,
ProcedureMap
Nested Class Summary | |
class |
Program.DataLabel
The DataLabel class represents a label within the program that refers to the data
segment. |
class |
Program.EEPromLabel
The EEPromLabel class represents a label within the program that refers to the eeprom
segment. |
class |
Program.Location
The Location class represents a location in the program; either named by
a label, or an unnamed integer address. |
class |
Program.ProgramLabel
The ProgramLabel class represents a label within the program that refers to the program
segment. |
Field Summary | |
boolean |
caseSensitive
The caseSensitive field controls whether label searching is case sensitive or not. |
int |
data_end
The data_end field records the address following the highest address in the program with
declared, labelled memory in the data segment. |
int |
data_start
The data_start field records the lowest address of declared, labelled memory in the data
segment. |
int |
eeprom_end
The eeprom_end field records the address following the highest address in the program with
declared, labelled memory in the eeprom segment. |
int |
eeprom_start
The eeprom_start field records the lowest address of declared, labelled memory in the
eeprom segment. |
protected byte[] |
flash_data
The flash_data field stores a reference to the array that contains the raw data (bytes) of the
program segment. |
protected Instr[] |
flash_instrs
The flash_instrs field stores a reference to the array that contains the instruction
representations of the program segment. |
static java.util.Comparator |
LOCATION_COMPARATOR
The LOCATION_COMPARATOR comparator is used in order to sort locations
in the program from lowest address to highest address. |
int |
program_end
The program_end field records the address following the highest address in the program
segment that contains valid code or data. |
int |
program_length
The program_length field records the size of the program (the difference between
program_start and program_end . |
int |
program_start
The program_start field records the lowest address in the program segment that contains
valid code or data. |
Constructor Summary | |
Program(int pstart,
int pend,
int dstart,
int dend,
int estart,
int eend)
The constructor of the Program class builds an internal representation of the program that
is initially empty, but has the given parameters in terms of how big segments are and where they
start. |
Method Summary | |
void |
addIndirectEdge(int callsite,
int target)
The addIndirectEdge adds an indirect edge between a callsite and possible target. |
protected void |
checkAddress(int addr)
The checkAddress() method simply checks an address against the bounds of the program and
throws an error if the address is not within the bounds. |
ControlFlowGraph |
getCFG()
The getCFG() method returns a reference to the control flow graph of the program. |
java.util.List |
getIndirectEdges(int callsite)
The getIndirectEdges returns a list of integers representing the possible target program
locations for a given callsite. |
Program.Location |
getLabel(java.lang.String name)
The getLabel() method searches for a label with a given name within the program, in any
section. |
java.util.HashMap |
getLabels()
|
int |
getNextPC(int pc)
The getNextPC() method computes the program counter value of the next instruction
following the instruction referenced by the given program counter value. |
Program.Location |
getProgramLocation(java.lang.String s)
The getProgramLocation() method will convert the specified string into a program location,
i.e. a location in the program segment.
|
SourceMapping |
getSourceMapping()
|
Program.DataLabel |
newDataLabel(java.lang.String name,
int byteAddress)
The newDataLabel() method creates a label in the data segment with the specified name at
the specified byte address. |
Program.EEPromLabel |
newEEPromLabel(java.lang.String name,
int byteAddress)
The newEEPromLabel() method creates a label in the eeprom segment with the specified name
at the specified byte address. |
Program.ProgramLabel |
newProgramLabel(java.lang.String name,
int byteAddress)
The newProgramLabel() method creates a label in the program segment with the specified
name at the specified byte address. |
Instr |
readInstr(int address)
The readInstr() method reads an instruction from the specified address in the program. |
byte |
readProgramByte(int address)
The readProgramByte() method reads a byte into the program segment at the specified byte
address. |
void |
setSourceMapping(SourceMapping s)
|
void |
writeInstr(Instr i,
int address)
The writeInstr() method is used to write an instruction to the internal representation of
the program at the given address. |
void |
writeProgramByte(byte val,
int byteAddress)
The writeProgramByte() method writes a byte into the program segment at the specified byte
address. |
void |
writeProgramBytes(byte[] val,
int byteAddress)
The writeProgramBytes() method writes an array of bytes into the program segment at the
specified byte address. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.util.Comparator LOCATION_COMPARATOR
LOCATION_COMPARATOR
comparator is used in order to sort locations
in the program from lowest address to highest address.
public final int program_start
program_start
field records the lowest address in the program segment that contains
valid code or data.
public final int program_end
program_end
field records the address following the highest address in the program
segment that contains valid code or data.
public final int program_length
program_length
field records the size of the program (the difference between
program_start
and program_end
.
public final int data_start
data_start
field records the lowest address of declared, labelled memory in the data
segment.
public final int data_end
data_end
field records the address following the highest address in the program with
declared, labelled memory in the data segment.
public final int eeprom_start
eeprom_start
field records the lowest address of declared, labelled memory in the
eeprom segment.
public final int eeprom_end
eeprom_end
field records the address following the highest address in the program with
declared, labelled memory in the eeprom segment.
protected final byte[] flash_data
flash_data
field stores a reference to the array that contains the raw data (bytes) of the
program segment. NO EFFORT IS MADE IN THIS CLASS TO KEEP THIS CONSISTENT WITH THE INSTRUCTION
REPRESENTATIONS.
protected final Instr[] flash_instrs
flash_instrs
field stores a reference to the array that contains the instruction
representations of the program segment. NO EFFORT IS MADE IN THIS CLASS TO KEEP THIS CONSISTENT WITH
THE RAW DATA OF THE PROGRAM SEGMENT.
public boolean caseSensitive
caseSensitive
field controls whether label searching is case sensitive or not. Some
program representations use case sensitive labels, and some do not.
Constructor Detail |
public Program(int pstart, int pend, int dstart, int dend, int estart, int eend)
Program
class builds an internal representation of the program that
is initially empty, but has the given parameters in terms of how big segments are and where they
start.
pstart
- the start of the program segmentpend
- the end of the program segmentdstart
- the start of the data segmentdend
- the end of the data segmentestart
- the start of the eeprom segmenteend
- the end of the eeprom segmentMethod Detail |
public void writeInstr(Instr i, int address)
writeInstr()
method is used to write an instruction to the internal representation of
the program at the given address. No attempt to assemble the instruction machine code is made; thus the
raw data (if any) at that location in the program will not be modified.
i
- the instruction to writeaddress
- the byte address to write the instruction to that must be aligned on a 2-byte boundary.
Avrora.InternalError
- if the address is not within the limits put on the program instance when
it was created.public Instr readInstr(int address)
readInstr()
method reads an instruction from the specified address in the program. No
attempt to disassemble raw data into usable instructions is made, and unaligned accesses will return
null.
address
- the byte address in the program
Instr
instance at that address if that address is valid code from creation of
the Program
instance; null if the instruction is misaligned or only raw data is
present at that location.
Avrora.InternalError
- if the address is not within the limits put on the program instance when
it was created.public byte readProgramByte(int address)
readProgramByte()
method reads a byte into the program segment at the specified byte
address. If the address overlaps with an instruction, no effort is made to get the correct encoded byte
of the instruction.
address
- the program address from which to read the byte
public void writeProgramByte(byte val, int byteAddress)
writeProgramByte()
method writes a byte into the program segment at the specified byte
address. If the address overlaps with an instruction, no effort is made to keep the instruction
representation up to date.
val
- the value to writebyteAddress
- the byte address in the program segment to write the byte value topublic void writeProgramBytes(byte[] val, int byteAddress)
writeProgramBytes()
method writes an array of bytes into the program segment at the
specified byte address. If the range of addresses modified overlaps with any instructions, no effort is
made to keep the instruction representations up to date.
val
- the byte values to writebyteAddress
- the byte address to begin writing the values topublic Program.ProgramLabel newProgramLabel(java.lang.String name, int byteAddress)
newProgramLabel()
method creates a label in the program segment with the specified
name at the specified byte address.
name
- the name of the labelbyteAddress
- the byte address to associate with the label
ProgramLabel
class corresponding to this new labelpublic Program.DataLabel newDataLabel(java.lang.String name, int byteAddress)
newDataLabel()
method creates a label in the data segment with the specified name at
the specified byte address.
name
- the name of the labelbyteAddress
- the byte address to associate with the label
DataLabel
class corresponding to this new labelpublic Program.EEPromLabel newEEPromLabel(java.lang.String name, int byteAddress)
newEEPromLabel()
method creates a label in the eeprom segment with the specified name
at the specified byte address.
name
- the name of the labelbyteAddress
- the byte address to associate with the label
EEPromLabel
class corresponding to this new labelpublic Program.Location getLabel(java.lang.String name)
getLabel()
method searches for a label with a given name within the program, in any
section.
name
- the string name of the label
Label
if the label exists; null otherwisepublic Program.Location getProgramLocation(java.lang.String s)
getProgramLocation()
method will convert the specified string into a program location,
i.e. a location in the program segment.
If the string begins with "0x", then it is considered a hexadecimal address and a location will be
returned that corresponds to that address in the program segment.
Otherwise, the string is considered to be a string and the method will attempt to look for a label with
that name.
s
- the string name to look up in the program segment
Location
representing that location in the program segment if the
string was either a hexadecimal constant or a valid label in the program segment; null otherwiseprotected void checkAddress(int addr)
checkAddress()
method simply checks an address against the bounds of the program and
throws an error if the address is not within the bounds.
addr
- the byte address to check
Avrora.InternalError
- if the address is not within the limits of the program segmentpublic int getNextPC(int pc)
getNextPC()
method computes the program counter value of the next instruction
following the instruction referenced by the given program counter value. Thus, it simply adds the size
of the instruction at the specified pc to the pc. It is useful as a commonly-used utility method.
pc
- the program counter location of the current instruction
public java.util.List getIndirectEdges(int callsite)
getIndirectEdges
returns a list of integers representing the possible target program
locations for a given callsite. This is auxilliary information that is supplied at the command line
which is used for a variety of analysis questions.
callsite
- the program counter location of an indirect branch or call
java.lang.Integer
objects that represent the possible targets of the
call or branch instructionpublic void addIndirectEdge(int callsite, int target)
addIndirectEdge
adds an indirect edge between a callsite and possible target. This is
auxilliary information that is supplied at the command line which is used for a variety of analysis
questions.
callsite
- the program counter location of the call or branch instructiontarget
- the possible target of the call or branch instructionpublic SourceMapping getSourceMapping()
public void setSourceMapping(SourceMapping s)
public ControlFlowGraph getCFG()
getCFG()
method returns a reference to the control flow graph of the program. This is
an instance of ControlFlowGraph
that is constructed lazily--i.e. the first time this
method is called. No effort is made to keep the control flow graph up to date with a changing program
representation; adding instructions or writing bytes into the program segment of the program will not
alter the CFG once it has been constructed.
ControlFlowGraph
instance that represents the control flow
graph for this programpublic java.util.HashMap getLabels()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |