Class MemoryBlockUtils


  • public class MemoryBlockUtils
    extends java.lang.Object
    Convenience methods for creating memory blocks.
    • Constructor Detail

      • MemoryBlockUtils

        public MemoryBlockUtils()
    • Method Detail

      • createUninitializedBlock

        public static MemoryBlock createUninitializedBlock​(Program program,
                                                           boolean isOverlay,
                                                           java.lang.String name,
                                                           Address start,
                                                           long length,
                                                           java.lang.String comment,
                                                           java.lang.String source,
                                                           boolean r,
                                                           boolean w,
                                                           boolean x,
                                                           MessageLog log)
        Creates a new uninitialized memory block.
        Parameters:
        program - the program in which to create the block.
        isOverlay - if true, the block will be created in a new overlay space for that block
        name - the name of the new block.
        start - the starting address of the new block.
        length - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a MessageLog for appending error messages
        Returns:
        the newly created block or null if the operation failed.
      • createInitializedBlock

        public static MemoryBlock createInitializedBlock​(Program program,
                                                         boolean isOverlay,
                                                         java.lang.String name,
                                                         Address start,
                                                         long length,
                                                         java.lang.String comment,
                                                         java.lang.String source,
                                                         boolean r,
                                                         boolean w,
                                                         boolean x,
                                                         MessageLog log)
        Create a new initialized memory block. Initialized to all zeros.
        Parameters:
        program - the program in which to create the block.
        isOverlay - if true, the block will be created in a new overlay space for that block
        name - the name of the new block.
        start - the starting address of the new block.
        is - source of the data used to fill the block or null for zero initialization.
        length - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a MessageLog for appending error messages
        Returns:
        the newly created block or null if the operation failed.
      • createBitMappedBlock

        public static MemoryBlock createBitMappedBlock​(Program program,
                                                       java.lang.String name,
                                                       Address start,
                                                       Address base,
                                                       int length,
                                                       java.lang.String comment,
                                                       java.lang.String source,
                                                       boolean r,
                                                       boolean w,
                                                       boolean x,
                                                       MessageLog log)
        Creates a new bit mapped memory block. (A bit mapped block is a block where each byte value is either 1 or 0 and the value is taken from a bit in a byte at some other address in memory)
        Parameters:
        program - the program in which to create the block.
        name - the name of the new block.
        start - the starting address of the new block.
        base - the address of the region in memory to map to.
        length - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a StringBuffer for appending error messages
        Returns:
        the new created block
      • createByteMappedBlock

        public static MemoryBlock createByteMappedBlock​(Program program,
                                                        java.lang.String name,
                                                        Address start,
                                                        Address base,
                                                        int length,
                                                        java.lang.String comment,
                                                        java.lang.String source,
                                                        boolean r,
                                                        boolean w,
                                                        boolean x,
                                                        MessageLog log)
        Creates a new byte mapped memory block. (A byte mapped block is a block where each byte value is taken from a byte at some other address in memory)
        Parameters:
        program - the program in which to create the block.
        name - the name of the new block.
        start - the starting address of the new block.
        base - the address of the region in memory to map to.
        length - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a MessageLog for appending error messages
        Returns:
        the new created block
      • createInitializedBlock

        public static MemoryBlock createInitializedBlock​(Program program,
                                                         boolean isOverlay,
                                                         java.lang.String name,
                                                         Address start,
                                                         FileBytes fileBytes,
                                                         long offset,
                                                         long length,
                                                         java.lang.String comment,
                                                         java.lang.String source,
                                                         boolean r,
                                                         boolean w,
                                                         boolean x,
                                                         MessageLog log)
                                                  throws AddressOverflowException
        Creates a new initialized block in memory using the bytes from a FileBytes object. If there is a conflict when creating this block (some other block occupies at least some of the addresses that would be occupied by the new block), then an attempt will be made to create the new block in an overlay.
        Parameters:
        program - the program in which to create the block.
        isOverlay - if true, the block will be created in a new overlay space for that block
        name - the name of the new block.
        start - the starting address of the new block.
        fileBytes - the FileBytes object that supplies the bytes for this block.
        offset - the offset into the FileBytes object where the bytes for this block reside.
        length - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a MessageLog for appending error messages
        Returns:
        the new created block
        Throws:
        AddressOverflowException - if the address
      • createInitializedBlock

        public static MemoryBlock createInitializedBlock​(Program program,
                                                         boolean isOverlay,
                                                         java.lang.String name,
                                                         Address start,
                                                         java.io.InputStream dataInput,
                                                         long dataLength,
                                                         java.lang.String comment,
                                                         java.lang.String source,
                                                         boolean r,
                                                         boolean w,
                                                         boolean x,
                                                         MessageLog log,
                                                         TaskMonitor monitor)
                                                  throws AddressOverflowException
        Creates a new initialized block in memory using the bytes from the given input stream. If there is a conflict when creating this block (some other block occupies at least some of the addresses that would be occupied by the new block), then an attempt will be made to create the new block in an overlay.
        Parameters:
        program - the program in which to create the block.
        isOverlay - if true, the block will be created in a new overlay space for that block
        name - the name of the new block.
        start - the starting address of the new block.
        dataInput - the InputStream object that supplies the bytes for this block.
        dataLength - the length of the new block
        comment - the comment text to associate with the new block.
        source - the source of the block (This field is not well defined - currently another comment)
        r - the read permission for the new block.
        w - the write permission for the new block.
        x - the execute permission for the new block.
        log - a MessageLog for appending error messages
        monitor - the monitor for canceling this potentially long running operation.
        Returns:
        the new created block
        Throws:
        AddressOverflowException - if the address
      • adjustFragment

        public static void adjustFragment​(Program program,
                                          Address address,
                                          java.lang.String name)
        Adjusts the name of the fragment at the given address to the given name.
        Parameters:
        program - the program whose fragment is to be renamed.
        address - the address of the fragment to be renamed.
        name - the new name for the fragment.
      • createFileBytes

        public static FileBytes createFileBytes​(Program program,
                                                ByteProvider provider,
                                                TaskMonitor monitor)
                                         throws java.io.IOException,
                                                CancelledException
        Creates a new FileBytes object using all the bytes from a ByteProvider
        Parameters:
        program - the program in which to create a new FileBytes object
        provider - the ByteProvider from which to get the bytes.
        monitor - the monitor for canceling this potentially long running operation.
        Returns:
        the newly created FileBytes object.
        Throws:
        java.io.IOException - if an IOException occurred.
        CancelledException
      • createFileBytes

        public static FileBytes createFileBytes​(Program program,
                                                ByteProvider provider,
                                                long offset,
                                                long length,
                                                TaskMonitor monitor)
                                         throws java.io.IOException,
                                                CancelledException
        Creates a new FileBytes object using a portion of the bytes from a ByteProvider
        Parameters:
        program - the program in which to create a new FileBytes object
        provider - the ByteProvider from which to get the bytes.
        offset - the offset into the ByteProvider from which to start loading bytes.
        length - the number of bytes to load
        monitor - the monitor for canceling this potentially long running operation.
        Returns:
        the newly created FileBytes object.
        Throws:
        java.io.IOException - if an IOException occurred.
        CancelledException - if the user cancelled the operation