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

feature -- Optimization properties

	record_count: INTEGER_32
			-- Number of field records.

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

	flatten_when_closing: BOOLEAN
			-- Option: flatten record when closing

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

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

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

	bottom_callstack_record: detachable like callstack_record
			-- Bottom (or root) callstack record.
	
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
	
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_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

	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)
	
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_precompiled (a_xpm: INTEGER_32): BOOLEAN
			-- Does a_xpm say is precompiled ?

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

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

	replay (dir: INTEGER_32; nb: 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

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

	replayed_call_details: detachable STRING_8
			-- Details for replayed_call
		require
			is_replaying: 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
	
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 -- Replay operation

	is_replaying: BOOLEAN
			-- Is replaying

	last_replay_operation_failed: BOOLEAN
			-- Does last replay operation failed ?

	replayed_call: detachable RT_DBG_CALL_RECORD
			-- Current replayed call stack record

	replay_stack_not_empty: BOOLEAN
			-- Is replay_stack non empty?

	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_back
			-- Replay execution back
		require
			is_replaying: is_replaying
			replayed_call_attached: replayed_call /= Void
		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_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_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

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

	increment_records_count (n: INTEGER_32)
			-- Incremente record_count by n
		ensure
			record_count_positive: record_count >= 0
	
feature -- Measurement

	is_call_at_depth (a_call: like replayed_call; d: INTEGER_32): BOOLEAN
			-- Call a_call has depth d ?
	
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