How to use the persistence.write_dict_uint32_to_set_of_uint32s function in Persistence

To help you get started, we’ve selected a few Persistence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rmtew / peasauce / python / disassembly_persistence.py View on Github external
elif processor_name == "mips":
            processor_id = loaderlib.constants.PROCESSOR_MIPS
        else:
            logger.error("convert_project_format_3_to_4: unrecognised arch name %s", processor_name)
            return None
        logger.debug("convert_project_format_3_to_4: arch name %s maps to processor id %d", processor_name, processor_id)

        # Write the as yet to be updated header.
        persistence.write_uint16(output_file, hunk_id)
        output_file_length_offset = output_file.tell()
        persistence.write_uint32(output_file, 0)
        output_file_payload_offset = output_file.tell()
        persistence.write_uint16(output_file, SNAPSHOT_HUNK_VERSIONS[SAVEFILE_HUNK_DISASSEMBLY] + 1)

        # Write the payload in the modified format.
        persistence.write_dict_uint32_to_set_of_uint32s(output_file, branch_addresses)
        persistence.write_dict_uint32_to_set_of_uint32s(output_file, reference_addresses)
        persistence.write_dict_uint32_to_string(output_file, symbols_by_address)
        persistence.write_dict_uint32_to_list_of_uint32s(output_file, post_segment_addresses)
        persistence.write_uint32(output_file, flags)
        persistence.write_uint32(output_file, processor_id)

        persistence.write_uint32(output_file, num_blocks)
        output_file_offset = output_file.tell()
        #for block in blocks:
        #    write_SegmentBlock(output_file, block, program_data.dis_constant_pc_offset)
        output_file.write(block_data_string)
        if output_file.tell() - output_file_offset != block_data_length:
            logger.error("convert_project_format_3_to_4: block length mismatch %d != %d", output_file.tell() - output_file_offset, block_data_length)
            return None

        # Update the header length field, then fast forward to the end of the hunk.
github rmtew / peasauce / python / disassembly_persistence.py View on Github external
processor_id = loaderlib.constants.PROCESSOR_MIPS
        else:
            logger.error("convert_project_format_3_to_4: unrecognised arch name %s", processor_name)
            return None
        logger.debug("convert_project_format_3_to_4: arch name %s maps to processor id %d", processor_name, processor_id)

        # Write the as yet to be updated header.
        persistence.write_uint16(output_file, hunk_id)
        output_file_length_offset = output_file.tell()
        persistence.write_uint32(output_file, 0)
        output_file_payload_offset = output_file.tell()
        persistence.write_uint16(output_file, SNAPSHOT_HUNK_VERSIONS[SAVEFILE_HUNK_DISASSEMBLY] + 1)

        # Write the payload in the modified format.
        persistence.write_dict_uint32_to_set_of_uint32s(output_file, branch_addresses)
        persistence.write_dict_uint32_to_set_of_uint32s(output_file, reference_addresses)
        persistence.write_dict_uint32_to_string(output_file, symbols_by_address)
        persistence.write_dict_uint32_to_list_of_uint32s(output_file, post_segment_addresses)
        persistence.write_uint32(output_file, flags)
        persistence.write_uint32(output_file, processor_id)

        persistence.write_uint32(output_file, num_blocks)
        output_file_offset = output_file.tell()
        #for block in blocks:
        #    write_SegmentBlock(output_file, block, program_data.dis_constant_pc_offset)
        output_file.write(block_data_string)
        if output_file.tell() - output_file_offset != block_data_length:
            logger.error("convert_project_format_3_to_4: block length mismatch %d != %d", output_file.tell() - output_file_offset, block_data_length)
            return None

        # Update the header length field, then fast forward to the end of the hunk.
        new_hunk_length = output_file.tell() - output_file_payload_offset
github rmtew / peasauce / python / disassembly_persistence.py View on Github external
def save_disassembly_hunk(f, program_data):
    persistence.write_dict_uint32_to_set_of_uint32s(f, program_data.branch_addresses)
    persistence.write_dict_uint32_to_set_of_uint32s(f, program_data.reference_addresses)
    persistence.write_dict_uint32_to_string(f, program_data.symbols_by_address)
    persistence.write_dict_uint32_to_list_of_uint32s(f, program_data.post_segment_addresses)
    persistence.write_uint32(f, program_data.flags)
    persistence.write_uint32(f, program_data.processor_id)

    persistence.write_uint32(f, len(program_data.blocks))
    for block in program_data.blocks:
        write_SegmentBlock(f, block, program_data.dis_constant_pc_offset)
github rmtew / peasauce / python / disassembly_persistence.py View on Github external
def save_disassembly_hunk(f, program_data):
    persistence.write_dict_uint32_to_set_of_uint32s(f, program_data.branch_addresses)
    persistence.write_dict_uint32_to_set_of_uint32s(f, program_data.reference_addresses)
    persistence.write_dict_uint32_to_string(f, program_data.symbols_by_address)
    persistence.write_dict_uint32_to_list_of_uint32s(f, program_data.post_segment_addresses)
    persistence.write_uint32(f, program_data.flags)
    persistence.write_uint32(f, program_data.processor_id)

    persistence.write_uint32(f, len(program_data.blocks))
    for block in program_data.blocks:
        write_SegmentBlock(f, block, program_data.dis_constant_pc_offset)
github rmtew / peasauce / python / disassembly_persistence.py View on Github external
def save_loader_hunk(f, program_data):
    persistence.write_string(f, program_data.loader_system_name)
    write_segment_list(f, program_data.loader_segments)
    persistence.write_dict_uint32_to_set_of_uint32s(f, program_data.loader_relocated_addresses)
    persistence.write_set_of_uint32s(f, program_data.loader_relocatable_addresses)
    persistence.write_uint16(f, program_data.loader_entrypoint_segment_id)
    persistence.write_uint32(f, program_data.loader_entrypoint_offset)