:py:mod:`cozy.terminal_state`
=============================

.. py:module:: cozy.terminal_state


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   cozy.terminal_state.TerminalState
   cozy.terminal_state.DeadendedState
   cozy.terminal_state.AssertFailedState
   cozy.terminal_state.ErrorState




.. py:class:: TerminalState(state: angr.SimState, state_id: int, state_type_str: str)


   Stores information pertaining specifically to a single SimState.

   :ivar SimState state: The state we are storing information about.
   :ivar int state_id: The index of this particular state in the corresponding list in RunResult. Note that errored states have separate state_ids from deadended states. Therefore a particular input state here is uniquely identified by the pair (state_id, state_tag), not just state_id by itself.
   :ivar str state_type_str: A string representation of the state's type

   .. py:property:: std_out
      :type: bytes

      The data that has been written to stdout when the program is in this state.

      :getter: The data written to stdout
      :type: bytes


   .. py:property:: std_err
      :type: bytes

      The data that has been written to stderr when the program is in this state.

      :getter: The data written to stderr
      :type: bytes


   .. py:property:: virtual_prints
      :type: list[tuple[cozy.directive.VirtualPrint, claripy.ast.Base]]

      Returns the output of the virtual prints that occurred while reaching this state.

      :getter: A list of VirtualPrint directives, along with the values they produced.
      :type: list[tuple[VirtualPrint, claripy.ast.Base]]


   .. py:property:: mem_writes
      :type: portion.IntervalDict

      The memory writes that occurred while reaching this state.

      :getter: An interval dictionary, with the keys being ranges and the values being tuple[int, frozenset[int]]. The first element of the tuple is a unique placeholder, the second element of the tuple are the possible instruction pointer values that wrote to this memory.
      :type: P.IntervalDict


   .. py:method:: concrete_examples(args: any, num_examples=3) -> list[cozy.concrete.TerminalStateInput]

      Concretizes the arguments used to put the program in this singleton state.

      :param any args: The input arguments to concretize. This argument may be a Python datastructure, the concretizer will make a deep copy with claripy symbolic variables replaced with concrete values.
      :param int num_examples: The maximum number of concrete examples to generate for this singleton state.
      :return: A list of concrete inputs that satisfies the constraints attached to the state.
      :rtype: list[TerminalStateInput]



.. py:class:: DeadendedState(state: angr.SimState, state_id: int)


   Bases: :py:obj:`TerminalState`

   This class is used to indicate that execution terminated normally in the contained state.

   Constructor for DeadendedState

   :ivar SimState state: The state that terminated normally.
   :ivar int state_id: The identifer of the state, determined by its position in the list :py:obj:`cozy.project.RunResult.deadended`


.. py:class:: AssertFailedState(assertion: cozy.directive.Assert, cond: claripy.ast.bool, failure_state: angr.SimState, state_id: int)


   Bases: :py:obj:`TerminalState`

   This class is used to indicate that execution failed due to an :py:class:`~cozy.directive.Assert` being satisfiable.

   :ivar Assert assertion: The assertion that was triggered.
   :ivar claripy.ast.bool cond: The condition that caused the assertion to trigger

   Constructor for AssertFailedState

   :param Assert assertion: The assertion that was triggered.
   :param claripy.ast.bool: The condition which if falsified will trigger the assertion.
   :param SimState failure_state: The state that was created to test the assertion.
   :param int state_id: The identifier of the state, determined by its position in the list :py:obj:`cozy.project.RunResult.asserts_failed`


.. py:class:: ErrorState(error_record: angr.sim_manager.ErrorRecord, state_id: int)


   Bases: :py:obj:`TerminalState`

   This class is used to indicate a state that resulted in an error (either my an execution error or :py:class:`~cozy.directive.ErrorDirective`).

   :ivar SimError error: The error that was thrown.
   :ivar traceback: The traceback attached to the error.

   Constructor for ErrorState

   :param ErrorRecord error_record: The error thrown for this state.
   :param int state_id: The identifier of the state, determined by it's position in the list :py:obj:`cozy.project.RunResult.errored`


