note
	description: "Execution recorder"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	date: "$Date: 2017-04-12 13:15:47 +0000 (Wed, 12 Apr 2017) $"
	revision: "$Revision: 100150 $"

class interface
	RT_DBG_EXECUTION_RECORDER

create {RT_EXTENSION}
	make (p: separate RT_DBG_EXECUTION_PARAMETERS)
			-- Creation of Current object
		require
			p_attached: p /= Void

feature -- Access

	callstack_record (dep: INTEGER_32): detachable RT_DBG_CALL_RECORD
			-- Call stack record with depth dep

	callstack_record_by_id (a_id: STRING_8): like callstack_record
			-- Call record for a_id
		require
			a_id_attached: a_id /= Void

	generating_type: TYPE [detachable RT_DBG_EXECUTION_RECORDER]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		ensure -- from ANY
			generating_type_not_void: Result /= Void

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty
	
feature -- Measurement

	is_call_at_depth (a_call: like replayed_call; d: INTEGER_32): BOOLEAN
			-- Call a_call has depth d ?
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))

	frozen is_deep_equal (other: RT_DBG_EXECUTION_RECORDER): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)

	is_equal (other: RT_DBG_EXECUTION_RECORDER): BOOLEAN
			-- Is other attached to an object considered
			-- equal to current object?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			symmetric: Result implies other ~ Current
			consistent: standard_is_equal (other) implies Result

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))

	frozen standard_is_equal (other: RT_DBG_EXECUTION_RECORDER): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
	
feature -- Duplication

	copy (other: RT_DBG_EXECUTION_RECORDER)
			-- Update current object using fields of object attached
			-- to other, so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: Current ~ other

	frozen deep_copy (other: RT_DBG_EXECUTION_RECORDER)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)

	frozen deep_twin: RT_DBG_EXECUTION_RECORDER
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: RT_DBG_EXECUTION_RECORDER)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)

	frozen standard_twin: RT_DBG_EXECUTION_RECORDER
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)

	frozen twin: RT_DBG_EXECUTION_RECORDER
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
	
feature -- Basic operations

	frozen default: detachable RT_DBG_EXECUTION_RECORDER
			-- Default value of object's type
			-- (from ANY)

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		ensure -- from ANY
			instance_free: class

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
	
feature -- Change

	increment_records_count (n: INTEGER_32)
			-- Incremente record_count by n
		ensure
			record_count_positive: record_count >= 0
	
feature -- Constants from eif_debug.h

	Direction_back: INTEGER_32 = 1
			-- previous call

	Direction_forth: INTEGER_32 = 2
			-- next call

	Direction_left: INTEGER_32 = 3
			-- previous instruction

	Direction_right: INTEGER_32 = 4
			-- next intruction
	
feature -- Event

	enter_feature (ref: ANY; cid, fid: INTEGER_32; dep: INTEGER_32)
			-- Enter feature {cid}.fid on object ref, depth is dep
		require
			ref_attached: ref /= Void
			is_not_replaying: not is_replaying
			cid_positive: cid >= 0

	enter_rescue (ref: ANY; cid, fid: INTEGER_32; dep: INTEGER_32)
			-- Enter rescue on object ref, depth is dep
		require
			ref_attached: ref /= Void
			is_not_replaying: not is_replaying

	leave_feature (ref: ANY; cid, fid: INTEGER_32; dep: INTEGER_32)
			-- Leave feature {cid}.fid on object ref, depth is dep
		require
			ref_attached: ref /= Void
			is_not_replaying: not is_replaying

	notify_rt_assign_attribute (a_dep: INTEGER_32; ref: ANY; a_offset: INTEGER_32; a_type: NATURAL_32; a_xpm: INTEGER_32)
			-- Notify variable assignment
			-- a_xpm contains information about expanded, precompiled, melted
		require
			ref_attached: ref /= Void
			is_not_replaying: not is_replaying
			top_call_stack_record_not_void: top_callstack_record /= Void
			valid_xpm_value: valid_xpm_value (a_xpm)

	notify_rt_assign_local (a_dep: INTEGER_32; a_position: INTEGER_32; a_type: NATURAL_32; a_xpm: INTEGER_32)
			-- Notify variable assignment
			-- a_xpm contains information about expanded, precompiled, melted
		require
			is_not_replaying: not is_replaying
			top_call_stack_record_not_void: top_callstack_record /= Void
			valid_xpm_value: valid_xpm_value (a_xpm)

	notify_rt_hook (dep: INTEGER_32; bp_i, bp_ni: INTEGER_32)
			-- Notify RT_HOOK (bp_i) or RTNHOOK (bp_i, bp_ni)
		require
			is_not_replaying: not is_replaying
	
feature -- Helpers

	valid_xpm_value (a_xpm: INTEGER_32): BOOLEAN
			-- Is a_xpm a valid xpm value ?

	xpm_to_is_expanded (a_xpm: INTEGER_32): BOOLEAN
			-- Does a_xpm say is expanded ?

	xpm_to_is_melted (a_xpm: INTEGER_32): BOOLEAN
			-- Does a_xpm say is melted ?

	xpm_to_is_precompiled (a_xpm: INTEGER_32): BOOLEAN
			-- Does a_xpm say is precompiled ?
	
feature -- Monitoring

	monitor_record_count
			-- Monitor if record_count is not over max_record_count
			-- if max_record_count is 0, then no limit
	
feature -- Optimization properties

	flatten_when_closing: BOOLEAN
			-- Option: flatten record when closing

	keep_calls_records: BOOLEAN
			-- Option: keep calls record even when flattening calls

	maximum_record_count: INTEGER_32
			-- Maximum number of records.
			-- 0 stands for no limit.

	record_count: INTEGER_32
			-- Number of field records.

	recording_values: BOOLEAN
			-- Option: record values ?
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		ensure -- from ANY
			out_not_void: Result /= Void

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
	
feature -- Properties

	bottom_callstack_record: detachable like callstack_record
			-- Bottom (or root) callstack record.

	top_callstack_record: detachable like callstack_record
			-- Current top callstack record.
	
feature -- Query

	changes_between (csr1: RT_DBG_CALL_RECORD; csr2: detachable RT_DBG_CALL_RECORD): ARRAYED_LIST [RT_DBG_VALUE_RECORD]
			-- Return records from r1 to -beginning-of- r2.
			-- (from RT_DBG_COMMON)
		require -- from RT_DBG_COMMON
			csr1_not_void: csr1 /= Void
		ensure -- from RT_DBG_COMMON
			result_not_void: Result /= Void
	
feature -- Replay

	activate_replay (b: BOOLEAN)
			-- Activate or deactive replay mode according to b
		ensure
			b_set: b and is_replaying

	callstack_record_details (a_id: STRING_8; nb: INTEGER_32): detachable STRING_8
			-- Details for callstack identified by a_id
			-- get information for nb levels.
		require
			a_id_attached: a_id /= Void
			is_replaying: is_replaying

	replay (dir: INTEGER_32; nb: INTEGER_32)
			-- Replay execution nb steps in direction dir

	replay_query (dir: INTEGER_32): INTEGER_32
			-- Replay execution nb steps in direction dir

	replay_to_point (a_id: STRING_8): BOOLEAN
			-- Replay execution to point identified by a_id
		require
			a_id_attached: a_id /= Void

	replayed_call_details: detachable STRING_8
			-- Details for replayed_call
		require
			is_replaying: is_replaying
	
feature -- Replay operation

	is_replaying: BOOLEAN
			-- Is replaying

	last_replay_operation_failed: BOOLEAN
			-- Does last replay operation failed ?

	replay_back
			-- Replay execution back
		require
			is_replaying: is_replaying
			replayed_call_attached: replayed_call /= Void
		ensure
			replayed_call_attached: replayed_call /= Void

	replay_forth
			-- Replay execution forth
		require
			is_replaying: is_replaying
			replayed_call_not_void: replayed_call /= Void
			replay_stack_not_empty: replay_stack_not_empty
		ensure
			replayed_call_attached: replayed_call /= Void

	replay_left
			-- Replay left (up in the current call stack element)
		require
			is_replaying: is_replaying
			replayed_call_attached: replayed_call /= Void
		ensure
			replayed_call_attached: replayed_call /= Void

	replay_left_to_first
			-- Replay execution left as many times as needed to be at the entry of the feature

	replay_right
			-- Replay right (down in the current call stack element)
		require
			is_replaying: is_replaying
			replayed_call_not_void: replayed_call /= Void
			replay_stack_not_empty: replay_stack_not_empty
		ensure
			replayed_call_attached: replayed_call /= Void

	replay_stack: detachable LINKED_LIST [TUPLE [call_record: RT_DBG_CALL_RECORD; chgs: detachable ARRAYED_LIST [TUPLE [record: RT_DBG_VALUE_RECORD; backup: RT_DBG_VALUE_RECORD]]]]
			-- Replay operation stacks.
			-- useful to "revert" the replay steps.

	replay_stack_not_empty: BOOLEAN
			-- Is replay_stack non empty?

	replayed_call: detachable RT_DBG_CALL_RECORD
			-- Current replayed call stack record

	revert_replay_stack
			-- Revert remaining replay stack
		require
			is_replaying: is_replaying
	
feature -- Trace

	dtrace (m: STRING_8)
			-- note: might be be removed with 6.2	
			-- (from RT_EXTENSION_COMMON)
		require -- from RT_EXTENSION_COMMON
			m_attached: m /= Void

	dtrace_indent (n: INTEGER_32)
			-- note: might be removed with 6.2
			-- (from RT_EXTENSION_COMMON)
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

note
	library: "EiffelBase: Library of reusable components for Eiffel."
	copyright: "Copyright (c) 1984-2017, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class RT_DBG_EXECUTION_RECORDER

Generated by ISE EiffelStudio