note description: "Call record" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date: 2018-11-14 14:54:22 +0000 (Wed, 14 Nov 2018) $" revision: "$Revision: 102461 $" class RT_DBG_CALL_RECORD create make feature {NONE} -- Initialization default_create -- Process instances of classes with no creation clause. -- (Default: do nothing.) -- (from ANY) do end make (rec: like recorder; ref: ANY; cid, fid: INTEGER_32; dep: INTEGER_32) -- Make as call {cid}.fid for object ref and depth dep require rec_attached: rec /= Void ref_attached: ref /= Void do recorder := rec class_type_id := cid feature_rout_id := fid depth := dep object := ref is_expanded := object_is_expanded (ref) last_position := [0, 0] rt_information_available := True create steps.make (3) end recorder: RT_DBG_EXECUTION_RECORDER -- Associated recorder. feature -- Access generating_type: TYPE [detachable RT_DBG_CALL_RECORD] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) external "built_in" ensure -- from ANY generating_type_not_void: Result /= Void end generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) external "built_in" ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty end feature {NONE} -- Access Bit_type: INTEGER_32 = 8 -- This type is obsolete and is not used anymore. -- (from REFLECTOR_CONSTANTS) Boolean_type: INTEGER_32 = 3 -- Abstract type ID for predefined type BOOLEAN. -- (from REFLECTOR_CONSTANTS) Character_32_type: INTEGER_32 = 12 -- Abstract type ID for predefined type CHARACTER_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Wide_character_type. -- (from REFLECTOR_CONSTANTS) Character_8_type: INTEGER_32 = 2 -- Abstract type ID for predefined type CHARACTER_8. -- Was declared in REFLECTOR_CONSTANTS as synonym of Character_type. -- (from REFLECTOR_CONSTANTS) Character_type: INTEGER_32 = 2 -- Abstract type ID for predefined type CHARACTER_8. -- Was declared in REFLECTOR_CONSTANTS as synonym of Character_8_type. -- (from REFLECTOR_CONSTANTS) Double_type: INTEGER_32 = 6 -- Abstract type ID for predefined type REAL_64. -- Was declared in REFLECTOR_CONSTANTS as synonym of Real_64_type. -- (from REFLECTOR_CONSTANTS) Expanded_type: INTEGER_32 = 7 -- Abstract type ID for a non-predefined expanded type. -- (from REFLECTOR_CONSTANTS) Integer_16_type: INTEGER_32 = 10 -- Abstract type ID for predefined type INTEGER_16. -- (from REFLECTOR_CONSTANTS) Integer_32_type: INTEGER_32 = 4 -- Abstract type ID for predefined type INTEGER_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Integer_type. -- (from REFLECTOR_CONSTANTS) Integer_64_type: INTEGER_32 = 11 -- Abstract type ID for predefined type INTEGER_64. -- (from REFLECTOR_CONSTANTS) Integer_8_type: INTEGER_32 = 9 -- Abstract type ID for predefined type INTEGER_8. -- (from REFLECTOR_CONSTANTS) Integer_type: INTEGER_32 = 4 -- Abstract type ID for predefined type INTEGER_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Integer_32_type. -- (from REFLECTOR_CONSTANTS) Max_predefined_type: INTEGER_32 = 16 -- (from REFLECTOR_CONSTANTS) Min_predefined_type: INTEGER_32 = -2 -- (from REFLECTOR_CONSTANTS) Natural_16_type: INTEGER_32 = 14 -- Abstract type ID for predefined type NATURAL_16. -- (from REFLECTOR_CONSTANTS) Natural_32_type: INTEGER_32 = 15 -- Abstract type ID for predefined type NATURAL_32. -- (from REFLECTOR_CONSTANTS) Natural_64_type: INTEGER_32 = 16 -- Abstract type ID for predefined type NATURAL_64. -- (from REFLECTOR_CONSTANTS) Natural_8_type: INTEGER_32 = 13 -- Abstract type ID for predefined type NATURAL_8. -- (from REFLECTOR_CONSTANTS) None_type: INTEGER_32 = -2 -- Type ID representation for NONE. -- (from REFLECTOR_CONSTANTS) Pointer_type: INTEGER_32 = 0 -- Abstract type ID for predefined type POINTER. -- (from REFLECTOR_CONSTANTS) Real_32_type: INTEGER_32 = 5 -- Abstract type ID for predefined type REAL_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Real_type. -- (from REFLECTOR_CONSTANTS) Real_64_type: INTEGER_32 = 6 -- Abstract type ID for predefined type REAL_64. -- Was declared in REFLECTOR_CONSTANTS as synonym of Double_type. -- (from REFLECTOR_CONSTANTS) Real_type: INTEGER_32 = 5 -- Abstract type ID for predefined type REAL_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Real_32_type. -- (from REFLECTOR_CONSTANTS) Reference_type: INTEGER_32 = 1 -- Abstract type ID for a reference type. -- (from REFLECTOR_CONSTANTS) Wide_character_type: INTEGER_32 = 12 -- Abstract type ID for predefined type CHARACTER_32. -- Was declared in REFLECTOR_CONSTANTS as synonym of Character_32_type. -- (from REFLECTOR_CONSTANTS) 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) do if a = Void then Result := b = Void else Result := b /= Void and then a.is_deep_equal (b) end 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) end 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) do if a = Void then Result := b = Void else Result := b /= Void and then a.is_equal (b) end 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)) end frozen is_deep_equal (other: RT_DBG_CALL_RECORD): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" 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) end is_equal (other: RT_DBG_CALL_RECORD): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void external "built_in" ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result end 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) do if a = Void then Result := b = Void else Result := b /= Void and then a.standard_is_equal (b) end 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)) end frozen standard_is_equal (other: RT_DBG_CALL_RECORD): 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 external "built_in" ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) end feature {RT_DBG_EXECUTION_RECORDER, RT_DBG_CALL_RECORD} -- Status report has_call_record (c: like Current): BOOLEAN -- Is c contained by call_records ? require c_attached: c /= Void do Result := attached call_records as crecs and then crecs.has (c) end is_last_call_record (c: like Current): BOOLEAN -- Is c the last call record of Current? require c_attached: c /= Void do Result := attached call_records as crecs and then not crecs.is_empty and then crecs.last = c end parent_has_call_record (c: like Current): BOOLEAN -- Is c contained by parent? require c_attached: c /= Void do Result := attached parent as p and then p.has_call_record (c) end 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 external "built_in" end 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 external "built_in" ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) end feature -- Duplication frozen clone (other: detachable ANY): like other obsolete "Use `twin' instead. [2017-05-31]" -- Void if other is void; otherwise new object -- equal to other -- -- For non-void other, clone calls copy; -- to change copying/cloning semantics, redefine copy. -- (from ANY) do if other /= Void then Result := other.twin end ensure -- from ANY instance_free: class equal: Result ~ other end copy (other: RT_DBG_CALL_RECORD) -- 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) external "built_in" ensure -- from ANY is_equal: Current ~ other end frozen deep_clone (other: detachable ANY): like other obsolete "Use `deep_twin' instead. [2017-05-31]" -- Void if other is void: otherwise, new object structure -- recursively duplicated from the one attached to other -- (from ANY) do if other /= Void then Result := other.deep_twin end ensure -- from ANY instance_free: class deep_equal: deep_equal (other, Result) end frozen deep_copy (other: RT_DBG_CALL_RECORD) -- Effect equivalent to that of: -- copy (other . deep_twin) -- (from ANY) require -- from ANY other_not_void: other /= Void do copy (other.deep_twin) ensure -- from ANY deep_equal: deep_equal (Current, other) end frozen deep_twin: RT_DBG_CALL_RECORD -- New object structure recursively duplicated from Current. -- (from ANY) external "built_in" ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) end frozen standard_clone (other: detachable ANY): like other obsolete "Use `standard_twin' instead. [2017-05-31]" -- Void if other is void; otherwise new object -- field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) do if other /= Void then Result := other.standard_twin end ensure -- from ANY instance_free: class equal: standard_equal (Result, other) end frozen standard_copy (other: RT_DBG_CALL_RECORD) -- 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) external "built_in" ensure -- from ANY is_standard_equal: standard_is_equal (other) end frozen standard_twin: RT_DBG_CALL_RECORD -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) external "built_in" ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) end frozen twin: RT_DBG_CALL_RECORD -- New object equal to Current -- twin calls copy; to change copying/twinning semantics, redefine copy. -- (from ANY) external "built_in" ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current end feature -- Basic operations frozen as_attached: attached RT_DBG_CALL_RECORD obsolete "Remove calls to this feature. [2017-05-31]" -- Attached version of Current. -- (Can be used during transitional period to convert -- non-void-safe classes to void-safe ones.) -- (from ANY) do Result := Current end frozen default: detachable RT_DBG_CALL_RECORD -- Default value of object's type -- (from ANY) do end frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.default for -- some p of type POINTER.) -- (from ANY) do ensure -- from ANY instance_free: class end default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) do end frozen do_nothing -- Execute a null action. -- (from ANY) do ensure -- from ANY instance_free: class end feature {NONE} -- Implementation Reflected_object: REFLECTED_REFERENCE_OBJECT -- To enable object introspection. -- (from RT_DBG_INTERNAL) once create Result.make (Current) end Reflector: REFLECTOR -- To enable type discovery -- (from RT_DBG_INTERNAL) once create Result end feature {NONE} -- Access local frozen c_stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32): detachable ANY -- Object value referenced at off offset of object -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH return (EIF_REFERENCE) rt_dbg_stack_value((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (uint32)$a_rt_type); #else return NULL; #endif ]" end feature -- Change register_position (a_line, a_nested: INTEGER_32) -- Set last position require a_line_valid: a_line > 0 a_nested_valid: a_nested >= 0 do last_position.line := a_line last_position.nested := a_nested debug ("rt_dbg_record") dtrace_indent (depth) dtrace ("BP_INFO (" + a_line.out + ", " + a_nested.out + ")%N") end end set_breakable_info (v: like breakable_info) -- Set breakable_info do breakable_info := v end wipe_out_value_records -- Wipe out value records local n: INTEGER_32 vs: like value_records do vs := value_records if vs /= Void then n := n + vs.count value_records := Void end if object /= Void then n := n + 1 object := Void end recorder.increment_records_count (- n) end feature {RT_DBG_EXECUTION_RECORDER, RT_DBG_CALL_RECORD} -- Change add_call_record (c: like Current) -- Add call record c to Current's sub call records require c_attached: c /= Void record_parented_to_current: c.parent = Current not_flat: not is_flat is_ready_to_add_call_record: is_ready_to_add_call_record local crecs: like call_records do if attached call_records as ot_crecs then crecs := ot_crecs else create crecs.make (5) call_records := crecs end crecs.force (c) crecs.finish crecs.move (1) register_call_step if depth = 0 then depth := c.depth - 1 end ensure in_records: attached call_records as cr and then cr.has (c) and then cr.after end add_value_record (v: RT_DBG_VALUE_RECORD) -- Add value record require v_attached: v /= Void is_not_flat: not is_flat is_ready_to_add_value_record: is_ready_to_add_value_record local l_value_records: like value_records do l_value_records := value_records if l_value_records = Void then create l_value_records.make (5) value_records := l_value_records end v.set_breakable_info (last_position.twin) l_value_records.force (v) l_value_records.finish l_value_records.move (1) register_value_step recorder.increment_records_count (1) ensure in_records: attached value_records as vr and then vr.has (v) and then vr.after end attach_to (p: like Current) -- Attach Current call record to parent call record c require p_attached: p /= Void not_in_parent_records: not parent_has_call_record (p) do parent := p p.add_call_record (Current) set_breakable_info (p.last_position.twin) ensure in_parent_records: attached parent as ot_p and then attached {like call_records} ot_p.call_records as cr and then cr.has (Current) end close -- Close current call -- It will discard useless records, and flatten sub calls' records. require is_not_closed: not is_closed call_records_closed: call_records_closed do if recorder.flatten_when_closing then flatten_value_records optimize_flat_value_records end rt_information_available := False is_closed := True ensure is_closed: is_closed end close_call_records -- Close sub calls require is_not_closed: not is_closed local c: like Current do if attached call_records as l_calls then across l_calls.new_cursor.reversed as i loop c := i.item if not c.is_closed then c.deep_close end end end ensure call_records_closed: call_records_closed end deep_close -- Close current call and call_records entries require is_not_closed: not is_closed do close_call_records close ensure call_records_closed: call_records_closed is_closed: is_closed end deep_close_until (r: like Current) -- Close Current, and all parent calls until call r require r_attached: r /= Void r_not_current: r /= Current is_not_closed: not is_closed local n: detachable like Current do from deep_close n := parent until n = Void or n = r loop n.deep_close n := n.parent end end flatten_value_records -- Flatten value records structure require not_flat: not is_flat do debug ("rt_dbg_optimization") dtrace_indent (depth) dtrace ("flatten_value_records (depth=" + depth.out + ") -start-%N") end if value_records = Void then create value_records.make (0) end if attached value_records as vals then get_value_records_flattened_into (vals) end if not recorder.keep_calls_records then call_records := Void end is_flat := True debug ("rt_dbg_optimization") dtrace_indent (depth) dtrace ("flatten_value_records (depth=" + depth.out + ") -end-%N") end ensure is_flat: is_flat flat_value_records_not_void: value_records /= Void no_records: not recorder.keep_calls_records implies call_records = Void end get_value_records_flattened_into (vals: attached like value_records) -- Flatten record rec require vals_attached: vals /= Void rec_not_flat_if_current: is_flat implies value_records /= vals local vrecs: like value_records v: RT_DBG_VALUE_RECORD c: CURSOR n: INTEGER_32 do vrecs := value_records if is_flat then check value_records_not_void_if_flat: vrecs /= Void then c := vrecs.cursor vals.append (vrecs) vrecs.go_to (c) n := vrecs.count end else if vrecs /= Void then if vrecs = vals then from vals.start until vals.after loop v := vals.item if v = Void or else v.is_local_record then vals.remove n := n - 1 else vals.forth end end else c := vrecs.cursor from vrecs.start until vrecs.after loop v := vrecs.item if v /= Void and then not v.is_local_record then vals.extend (v) n := n + 1 end vrecs.forth end vrecs.go_to (c) end end if attached call_records as crecs then c := crecs.cursor from crecs.start until crecs.after loop debug ("rt_dbg_warning") if not crecs.item_for_iteration.is_flat then print ("Rec not flat !!!! %N") end end crecs.item_for_iteration.get_value_records_flattened_into (vals) crecs.forth end crecs.go_to (c) end end if vals = value_records then object := Void n := n - 1 else wipe_out_value_records end recorder.increment_records_count (n) ensure flat_value_records_has_no_local: not flat_value_records_has_local end optimize_flat_value_records -- Optimize the flatten records to discard useless records require is_flat: is_flat local ot: ARRAYED_LIST [ANY] ort: ARRAY [detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD]] orcds: detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD] rec: RT_DBG_VALUE_RECORD o: detachable ANY oi: INTEGER_32 b: BOOLEAN n: INTEGER_32 retried: BOOLEAN do if not retried and then attached value_records as vals then n := 0 if vals.count > 1 then from create ot.make (10) create ort.make_filled (Void, 1, ot.capacity - 1) vals.start until vals.after loop rec := vals.item_for_iteration check is_not_local_record: not rec.is_local_record end if attached rec.associated_object as rec_obj then if o /= rec_obj then o := rec_obj ot.search (o) if not ot.exhausted then oi := ot.index orcds := ort.item (oi) else ot.force (o) ot.finish oi := ot.index create orcds.make (10) ort.force (orcds, oi) end end check oi_positive: oi > 0 o_attached: o /= Void orcds_attached: orcds /= Void then end if orcds.is_empty then orcds.force (rec) else from b := False orcds.finish until orcds.before or b loop b := orcds.item_for_iteration.position = rec.position orcds.back end if not b then orcds.force (rec) else n := n + 1 end end end vals.forth end vals.wipe_out from ot.start oi := ot.index until ot.after loop oi := ot.index o := ot.item_for_iteration orcds := ort.item (oi) if orcds /= Void then from orcds.start until orcds.after loop vals.force (orcds.item_for_iteration) orcds.forth end end ot.forth end end debug ("rt_dbg_optimization") dtrace_indent (depth) dtrace ("optimize_flat_value_records (depth=" + depth.out + "): to " + vals.count.out + " (-" + n.out + ")%N") end recorder.increment_records_count (- n) end rescue dtrace ("Error: optimize_flat_field_records : rescued%N") retried := True retry end record_fields -- Records fields of target object require object_not_void: object /= Void is_not_flat: not is_flat local rs: like value_records do if not is_expanded then if attached object as o then rs := object_records (o) end value_records := rs end debug ("rt_dbg_record") if attached {like value_records} rs as ot_rs then dtrace_indent (depth) dtrace ("record_fields -> " + ot_rs.count.out + " value(s).%N") ot_rs.do_all (agent (r: RT_DBG_VALUE_RECORD) require r_attached: r /= Void do dtrace (" -> " + r.position.out + ") " + r.to_string + "%N") end) else dtrace_indent (depth) dtrace ("record_fields -> None.%N") end end end remove_parent -- Unattach from parent call record do parent := Void end feature {NONE} -- Change field set_field_at (off: INTEGER_32; a_type: NATURAL_32; value: detachable ANY; object: ANY) -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL object_attached: object /= Void local a_eif_type: INTEGER_32 do debug ("rt_dbg_internal") print ("set_field_at (" + off.out + ", " + a_type.out + ", value, " + object.generator + ") %N") end a_eif_type := eif_type (a_type) inspect a_eif_type when Boolean_type then if attached {BOOLEAN} value as bool then {ISE_RUNTIME}.set_boolean_field_at (off, $object.to_pointer, 0, bool) end when Character_8_type then if attached {CHARACTER_8} value as c8 then {ISE_RUNTIME}.set_character_8_field_at (off, $object.to_pointer, 0, c8) end when Character_32_type then if attached {CHARACTER_32} value as c32 then {ISE_RUNTIME}.set_character_32_field_at (off, $object.to_pointer, 0, c32) end when Natural_8_type then if attached {NATURAL_8} value as n8 then {ISE_RUNTIME}.set_natural_8_field_at (off, $object.to_pointer, 0, n8) end when Natural_16_type then if attached {NATURAL_16} value as n16 then {ISE_RUNTIME}.set_natural_16_field_at (off, $object.to_pointer, 0, n16) end when Natural_32_type then if attached {NATURAL_32} value as n32 then {ISE_RUNTIME}.set_natural_32_field_at (off, $object.to_pointer, 0, n32) end when Natural_64_type then if attached {NATURAL_64} value as n64 then {ISE_RUNTIME}.set_natural_64_field_at (off, $object.to_pointer, 0, n64) end when Integer_8_type then if attached {INTEGER_8} value as i8 then {ISE_RUNTIME}.set_integer_8_field_at (off, $object.to_pointer, 0, i8) end when Integer_16_type then if attached {INTEGER_16} value as i16 then {ISE_RUNTIME}.set_integer_16_field_at (off, $object.to_pointer, 0, i16) end when Integer_32_type then if attached {INTEGER_32} value as i32 then {ISE_RUNTIME}.set_integer_32_field_at (off, $object.to_pointer, 0, i32) end when Integer_64_type then if attached {INTEGER_64} value as i64 then {ISE_RUNTIME}.set_integer_64_field_at (off, $object.to_pointer, 0, i64) end when Real_32_type then if attached {REAL_32} value as r32 then {ISE_RUNTIME}.set_real_32_field_at (off, $object.to_pointer, 0, r32) end when Real_64_type then if attached {REAL_64} value as r64 then {ISE_RUNTIME}.set_real_64_field_at (off, $object.to_pointer, 0, r64) end when Pointer_type then if attached {POINTER} value as ptr then {ISE_RUNTIME}.set_pointer_field_at (off, $object.to_pointer, 0, ptr) end when Reference_type then {ISE_RUNTIME}.set_reference_field_at (off, $object.to_pointer, 0, value) else end end feature {NONE} -- Change local frozen c_set_boolean_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_bool: BOOLEAN): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_BOOL; a_val.it_bool = (EIF_BOOLEAN) $a_bool; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_character_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ch32: CHARACTER_32): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_WCHAR; a_val.it_c4 = (EIF_WIDE_CHAR) $a_ch32; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_character_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ch8: CHARACTER_8): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_CHAR; a_val.it_c1 = (EIF_CHARACTER) $a_ch8; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_integer_16_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i16: INTEGER_16): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_INT16; a_val.it_i2 = (EIF_INTEGER_16) $a_i16; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_integer_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i32: INTEGER_32): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_INT32; a_val.it_i4 = (EIF_INTEGER_32) $a_i32; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_integer_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i64: INTEGER_64): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_INT64; a_val.it_i8 = (EIF_INTEGER_64) $a_i64; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_integer_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i8: INTEGER_8): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_INT8; a_val.it_i1 = (EIF_INTEGER_8) $a_i8; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_natural_16_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n16: NATURAL_16): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_UINT16; a_val.it_n2 = (EIF_NATURAL_16) $a_n16; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_natural_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n32: NATURAL_32): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_UINT32; a_val.it_n4 = (EIF_NATURAL_32) $a_n32; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_natural_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n64: NATURAL_64): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_UINT64; a_val.it_n8 = (EIF_NATURAL_64) $a_n64; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_natural_8_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_n8: NATURAL_8): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_UINT8; a_val.it_n1 = (EIF_NATURAL_8) $a_n8; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_pointer_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_p: POINTER): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_POINTER; a_val.it_p = (EIF_POINTER) $a_p; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_real_32_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i32: REAL_32): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_REAL32; a_val.it_r4 = (EIF_REAL_32) $a_i32; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_real_64_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_i64: REAL_64): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_REAL64; a_val.it_r8 = (EIF_REAL_64) $a_i64; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_reference_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_ref: POINTER): INTEGER_32 -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL a_ref_not_null: a_ref /= default_pointer external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_REF; a_val.it_ref = (EIF_REFERENCE) &($a_ref); return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end frozen c_set_void_stack_value (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32): INTEGER_32 -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_TYPED_VALUE a_val; a_val.type = SK_VOID; a_val.it_ref = (char*) 0; return rt_dbg_set_stack_value ((uint32)$dep, (uint32)$a_loc_type, (uint32)$pos, (EIF_TYPED_VALUE*) &a_val); #else return 0; #endif ]" end Rt_dlt_argument: INTEGER_32 = 0 -- DLT=DebugLocalType, the type is an argument of a function -- (from RT_DBG_INTERNAL) Rt_dlt_localvar: INTEGER_32 = 1 -- DLT=DebugLocalType, the type is a local variable inside a function -- (from RT_DBG_INTERNAL) Rt_dlt_result: INTEGER_32 = 2 -- DLT=DebugLocalType, the type is the Result of the current feature -- (from RT_DBG_INTERNAL) set_stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32; value: detachable ANY): INTEGER_32 -- Set stack value at position pos on stack of depth dep with value -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL a_loc_type_valid: a_loc_type = Rt_dlt_localvar or a_loc_type = Rt_dlt_argument or a_loc_type = Rt_dlt_result local a_eif_type: INTEGER_32 do debug ("rt_dbg_internal") print ("set_stack_value_at (dep=" + dep.out + ", loc_type=" + a_loc_type.out + ", pos=" + pos.out + ", type=0x" + a_rt_type.to_hex_string + ", value=") if value = Void then print ("Void) %N") else print (value.generating_type.name + ": " + value.out + ") %N") end end a_eif_type := eif_type (a_rt_type) inspect a_eif_type when Boolean_type then if attached {BOOLEAN} value as bool then Result := c_set_boolean_stack_value (dep, a_loc_type, pos, bool) end when Character_8_type then if attached {CHARACTER_8} value as c8 then Result := c_set_character_8_stack_value (dep, a_loc_type, pos, c8) end when Character_32_type then if attached {CHARACTER_32} value as c32 then Result := c_set_character_32_stack_value (dep, a_loc_type, pos, c32) end when Natural_8_type then if attached {NATURAL_8} value as n8 then Result := c_set_natural_8_stack_value (dep, a_loc_type, pos, n8) end when Natural_16_type then if attached {NATURAL_16} value as n16 then Result := c_set_natural_16_stack_value (dep, a_loc_type, pos, n16) end when Natural_32_type then if attached {NATURAL_32} value as n32 then Result := c_set_natural_32_stack_value (dep, a_loc_type, pos, n32) end when Natural_64_type then if attached {NATURAL_64} value as n64 then Result := c_set_natural_64_stack_value (dep, a_loc_type, pos, n64) end when Integer_8_type then if attached {INTEGER_8} value as i8 then Result := c_set_integer_8_stack_value (dep, a_loc_type, pos, i8) end when Integer_16_type then if attached {INTEGER_16} value as i16 then Result := c_set_integer_16_stack_value (dep, a_loc_type, pos, i16) end when Integer_32_type then if attached {INTEGER_32} value as i32 then Result := c_set_integer_32_stack_value (dep, a_loc_type, pos, i32) end when Integer_64_type then if attached {INTEGER_64} value as i64 then Result := c_set_integer_64_stack_value (dep, a_loc_type, pos, i64) end when Real_32_type then if attached {REAL_32} value as r32 then Result := c_set_real_32_stack_value (dep, a_loc_type, pos, r32) end when Real_64_type then if attached {REAL_64} value as r64 then Result := c_set_real_64_stack_value (dep, a_loc_type, pos, r64) end when Pointer_type then if attached {POINTER} value as ptr then Result := c_set_pointer_stack_value (dep, a_loc_type, pos, ptr) end when Reference_type then if value /= Void then Result := c_set_reference_stack_value (dep, a_loc_type, pos, $value.to_pointer) else Result := c_set_void_stack_value (dep, a_loc_type, pos) end else Result := 2 end debug ("rt_dbg_internal") print ("set_stack_value_at (dep=" + dep.out + ", loc_type=" + a_loc_type.out + ", pos=" + pos.out + ", ...) -> " + Result.out + " %N") print ("set_stack_value_at: check modification -> ") if attached stack_value_at (dep, a_loc_type, pos, a_rt_type) as a then print (a.generating_type.name + ": " + a.out + "%N") else print (" Void %N") end end end feature {NONE} -- External implementation frozen c_eif_type (a_field_type: NATURAL_32): INTEGER_32 -- EIF_ type related to a_field_type -- (from RT_DBG_INTERNAL) external "C inline use %"eif_internal.h%"" alias "ei_eif_type((uint32) $a_field_type)" end frozen c_object_is_expanded (object: POINTER): BOOLEAN -- (from RT_DBG_INTERNAL) external "C inline use %"eif_eiffel.h%"" alias "eif_is_expanded(HEADER($object)->ov_flags)" end frozen c_rt_dynamic_type (object: POINTER): INTEGER_32 -- Dynamic type of object. -- (from RT_DBG_INTERNAL) external "C macro signature (EIF_REFERENCE): EIF_INTEGER use %"eif_macros.h%"" alias "Dtype" end frozen c_rt_field_type (i: INTEGER_32; a_type_id: INTEGER_32): NATURAL_32 -- RT field type related to i on a_type_id -- (from RT_DBG_INTERNAL) external "C inline use %"eif_internal.h%"" alias "System(To_dtype($a_type_id)).cn_types[$i]" end feature {NONE} -- Factory frozen object_attribute_record (off: INTEGER_32; t: NATURAL_32; obj: ANY): detachable RT_DBG_VALUE_RECORD -- Record for attribute of type t at offset o on object obj -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj_attached: obj /= Void local ft: INTEGER_32 l_reflected_object: REFLECTED_REFERENCE_OBJECT do ft := eif_type (t) inspect ft when Boolean_type then create {RT_DBG_ATTRIBUTE_RECORD [BOOLEAN]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.boolean_field_at (off, $obj.to_pointer, 0)) when Character_8_type then create {RT_DBG_ATTRIBUTE_RECORD [CHARACTER_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.character_8_field_at (off, $obj.to_pointer, 0)) when Character_32_type then create {RT_DBG_ATTRIBUTE_RECORD [CHARACTER_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.character_32_field_at (off, $obj.to_pointer, 0)) when Integer_8_type then create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_8_field_at (off, $obj.to_pointer, 0)) when Integer_16_type then create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_16]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_16_field_at (off, $obj.to_pointer, 0)) when Integer_32_type then create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_32_field_at (off, $obj.to_pointer, 0)) when Integer_64_type then create {RT_DBG_ATTRIBUTE_RECORD [INTEGER_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.integer_64_field_at (off, $obj.to_pointer, 0)) when Natural_8_type then create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_8]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0)) when Natural_16_type then create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_16]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_16_field_at (off, $obj.to_pointer, 0)) when Natural_32_type then create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0).to_natural_32) when Natural_64_type then create {RT_DBG_ATTRIBUTE_RECORD [NATURAL_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.natural_8_field_at (off, $obj.to_pointer, 0).to_natural_64) when Real_32_type then create {RT_DBG_ATTRIBUTE_RECORD [REAL_32]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.real_32_field_at (off, $obj.to_pointer, 0)) when Real_64_type then create {RT_DBG_ATTRIBUTE_RECORD [REAL_64]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.real_64_field_at (off, $obj.to_pointer, 0)) when Pointer_type then create {RT_DBG_ATTRIBUTE_RECORD [POINTER]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.pointer_field_at (off, $obj.to_pointer, 0)) when Reference_type then create {RT_DBG_ATTRIBUTE_RECORD [ANY]} Result.make (obj, off, ft, t, {ISE_RUNTIME}.reference_field_at (off, $obj.to_pointer, 0)) when Expanded_type then create l_reflected_object.make_for_expanded_field_at (obj, off) create {RT_DBG_ATTRIBUTE_RECORD [ANY]} Result.make (obj, off, ft, t, l_reflected_object.object) else end end frozen object_local_record (dep: INTEGER_32; pos: INTEGER_32; t: NATURAL_32): detachable RT_DBG_VALUE_RECORD -- Local or Result value record. -- (from RT_DBG_INTERNAL) local ft: INTEGER_32 do ft := eif_type (t) inspect ft when Boolean_type then create {RT_DBG_LOCAL_RECORD [BOOLEAN]} Result.make (dep, pos, ft, t) when Character_8_type then create {RT_DBG_LOCAL_RECORD [CHARACTER_8]} Result.make (dep, pos, ft, t) when Character_32_type then create {RT_DBG_LOCAL_RECORD [CHARACTER_32]} Result.make (dep, pos, ft, t) when Natural_8_type then create {RT_DBG_LOCAL_RECORD [NATURAL_8]} Result.make (dep, pos, ft, t) when Natural_16_type then create {RT_DBG_LOCAL_RECORD [NATURAL_16]} Result.make (dep, pos, ft, t) when Natural_32_type then create {RT_DBG_LOCAL_RECORD [NATURAL_32]} Result.make (dep, pos, ft, t) when Natural_64_type then create {RT_DBG_LOCAL_RECORD [NATURAL_64]} Result.make (dep, pos, ft, t) when Integer_8_type then create {RT_DBG_LOCAL_RECORD [INTEGER_8]} Result.make (dep, pos, ft, t) when Integer_16_type then create {RT_DBG_LOCAL_RECORD [INTEGER_16]} Result.make (dep, pos, ft, t) when Integer_32_type then create {RT_DBG_LOCAL_RECORD [INTEGER_32]} Result.make (dep, pos, ft, t) when Integer_64_type then create {RT_DBG_LOCAL_RECORD [INTEGER_64]} Result.make (dep, pos, ft, t) when Real_32_type then create {RT_DBG_LOCAL_RECORD [REAL_32]} Result.make (dep, pos, ft, t) when Real_64_type then create {RT_DBG_LOCAL_RECORD [REAL_64]} Result.make (dep, pos, ft, t) when Pointer_type then create {RT_DBG_LOCAL_RECORD [POINTER]} Result.make (dep, pos, ft, t) when Reference_type then create {RT_DBG_LOCAL_RECORD [ANY]} Result.make (dep, pos, ft, t) when Expanded_type then create {RT_DBG_LOCAL_RECORD [ANY]} Result.make (dep, pos, ft, t) when None_type then else end if Result /= Void then Result.get_value end end frozen object_record (i: INTEGER_32; obj: ANY): detachable RT_DBG_VALUE_RECORD -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj_attached: obj /= Void local ft: INTEGER_32 l_reflected_object: like Reflected_object do l_reflected_object := Reflected_object l_reflected_object.set_object (obj) ft := l_reflected_object.field_type (i) Result := object_attribute_record (l_reflected_object.field_offset (i), c_rt_field_type (i, ft), obj) inspect ft when Integer_8_type then create {RT_DBG_FIELD_RECORD [INTEGER_8]} Result.make (obj, i, ft, l_reflected_object.integer_8_field (i)) when Integer_16_type then create {RT_DBG_FIELD_RECORD [INTEGER_16]} Result.make (obj, i, ft, l_reflected_object.integer_16_field (i)) when Integer_32_type then create {RT_DBG_FIELD_RECORD [INTEGER_32]} Result.make (obj, i, ft, l_reflected_object.integer_32_field (i)) when Integer_64_type then create {RT_DBG_FIELD_RECORD [INTEGER_64]} Result.make (obj, i, ft, l_reflected_object.integer_64_field (i)) when Natural_8_type then create {RT_DBG_FIELD_RECORD [NATURAL_8]} Result.make (obj, i, ft, l_reflected_object.natural_8_field (i)) when Natural_16_type then create {RT_DBG_FIELD_RECORD [NATURAL_16]} Result.make (obj, i, ft, l_reflected_object.natural_16_field (i)) when Natural_32_type then create {RT_DBG_FIELD_RECORD [NATURAL_32]} Result.make (obj, i, ft, l_reflected_object.natural_32_field (i)) when Natural_64_type then create {RT_DBG_FIELD_RECORD [NATURAL_64]} Result.make (obj, i, ft, l_reflected_object.natural_64_field (i)) when Pointer_type then create {RT_DBG_FIELD_RECORD [POINTER]} Result.make (obj, i, ft, l_reflected_object.pointer_field (i)) when Reference_type then create {RT_DBG_FIELD_RECORD [detachable ANY]} Result.make (obj, i, ft, l_reflected_object.reference_field (i)) when Expanded_type then create {RT_DBG_FIELD_RECORD [detachable ANY]} Result.make (obj, i, ft, l_reflected_object.field (i)) when Boolean_type then create {RT_DBG_FIELD_RECORD [BOOLEAN]} Result.make (obj, i, ft, l_reflected_object.boolean_field (i)) when Real_32_type then create {RT_DBG_FIELD_RECORD [REAL_32]} Result.make (obj, i, ft, l_reflected_object.real_32_field (i)) when Real_64_type then create {RT_DBG_FIELD_RECORD [REAL_64]} Result.make (obj, i, ft, l_reflected_object.real_64_field (i)) when Character_8_type then create {RT_DBG_FIELD_RECORD [CHARACTER_8]} Result.make (obj, i, ft, l_reflected_object.character_8_field (i)) when Character_32_type then create {RT_DBG_FIELD_RECORD [CHARACTER_32]} Result.make (obj, i, ft, l_reflected_object.character_32_field (i)) else end end feature -- Measure last_position: TUPLE [line: INTEGER_32; nested: INTEGER_32] -- Last position rt_information_available: BOOLEAN -- Is Runtime information available for this call ? same_object_type (ref: detachable ANY): BOOLEAN -- Is ref representing the same value as object ? do if attached ref then Result := attached object as o and then o.same_type (ref) else Result := object = Void end end feature {NONE} -- Object access frozen eif_type (a_field_type: NATURAL_32): INTEGER_32 -- EIF_ type from field type a_field_type -- (from RT_DBG_INTERNAL) do Result := c_eif_type (a_field_type) end frozen field_at (off: INTEGER_32; a_field_type: NATURAL_32; object: ANY): detachable ANY -- Object attached at offset off field of object -- (directly or through a reference) -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL object_not_void: object /= Void index_large_enough: off >= 1 local t: INTEGER_32 do t := eif_type (a_field_type) inspect t when Boolean_type then Result := {ISE_RUNTIME}.boolean_field_at (off, $object.to_pointer, 0) when Character_8_type then Result := {ISE_RUNTIME}.character_8_field_at (off, $object.to_pointer, 0) when Character_32_type then Result := {ISE_RUNTIME}.character_32_field_at (off, $object.to_pointer, 0) when Natural_8_type then Result := {ISE_RUNTIME}.natural_8_field_at (off, $object.to_pointer, 0) when Natural_16_type then Result := {ISE_RUNTIME}.natural_16_field_at (off, $object.to_pointer, 0) when Natural_32_type then Result := {ISE_RUNTIME}.natural_32_field_at (off, $object.to_pointer, 0) when Natural_64_type then Result := {ISE_RUNTIME}.natural_64_field_at (off, $object.to_pointer, 0) when Integer_8_type then Result := {ISE_RUNTIME}.integer_8_field_at (off, $object.to_pointer, 0) when Integer_16_type then Result := {ISE_RUNTIME}.integer_16_field_at (off, $object.to_pointer, 0) when Integer_32_type then Result := {ISE_RUNTIME}.integer_32_field_at (off, $object.to_pointer, 0) when Integer_64_type then Result := {ISE_RUNTIME}.integer_64_field_at (off, $object.to_pointer, 0) when Real_32_type then Result := {ISE_RUNTIME}.real_32_field_at (off, $object.to_pointer, 0) when Real_64_type then Result := {ISE_RUNTIME}.real_64_field_at (off, $object.to_pointer, 0) when Pointer_type then Result := {ISE_RUNTIME}.pointer_field_at (off, $object.to_pointer, 0) when Reference_type then Result := {ISE_RUNTIME}.reference_field_at (off, $object.to_pointer, 0) else end end frozen field_index_at (off: INTEGER_32; obj: ANY): INTEGER_32 -- Field name at offset off on obj -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj /= Void local n: INTEGER_32 l_reflected_object: like Reflected_object do from l_reflected_object := Reflected_object l_reflected_object.set_object (obj) n := l_reflected_object.field_count until n = 0 or Result > 0 loop if off = l_reflected_object.field_offset (n) then Result := n end n := n - 1 end end frozen field_name_at (off: INTEGER_32; obj: ANY): detachable STRING_8 -- Field name at offset off on obj -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj /= Void local i: INTEGER_32 do i := field_index_at (off, obj) if i > 0 then Reflected_object.set_object (obj) Result := Reflected_object.field_name (i) end end frozen object_field_count (obj: ANY): INTEGER_32 -- Field_count on obj -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj_attached: obj /= Void do Reflected_object.set_object (obj) Result := Reflected_object.field_count end frozen object_is_expanded (object: ANY): BOOLEAN -- Is object an expanded value ? -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL object_not_void: object /= Void do Result := c_object_is_expanded ($object.to_pointer) end frozen object_records (obj: ANY): detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD] -- List of field records on obj -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL obj_attached: obj /= Void local i, cnb: INTEGER_32 l_records: like object_records do cnb := object_field_count (obj) if cnb > 0 then create l_records.make (cnb) from i := 1 until i > cnb loop if attached {like object_record} object_record (i, obj) as r then l_records.extend (r) end i := i + 1 end Result := l_records end end frozen rt_dynamic_type (object: ANY): INTEGER_32 -- Dynamic type of object -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL object_not_void: object /= Void do Result := c_rt_dynamic_type ($object.to_pointer) ensure -- from RT_DBG_INTERNAL rt_dynamic_type_nonnegative: Result >= 0 end frozen stack_value_at (dep: INTEGER_32; a_loc_type: INTEGER_32; pos: INTEGER_32; a_rt_type: NATURAL_32): detachable ANY -- Object attached at offset off field of object -- (directly or through a reference) -- (from RT_DBG_INTERNAL) require -- from RT_DBG_INTERNAL index_large_enough: pos >= 1 do debug ("rt_dbg_internal") print ("%Nstack_value_at (" + dep.out + ", " + pos.out + ", 0x" + a_rt_type.to_hex_string + ")%N") end Result := c_stack_value_at (dep, a_loc_type, pos, a_rt_type) debug ("rt_dbg_internal") print ("stack_value_at -> ") if Result /= Void then print (Result.generating_type.name + " = " + Result.out) else print ("Void Result") end print ("%N") end end feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) once create Result Result.set_output_default ensure -- from ANY instance_free: class io_not_void: Result /= Void end out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) do Result := tagged_out ensure -- from ANY out_not_void: Result /= Void end print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) do if o /= Void then Io.put_string (o.out) end ensure -- from ANY instance_free: class end frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) external "built_in" ensure -- from ANY tagged_out_not_void: Result /= Void end feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) once create Result ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void end feature -- Properties breakable_info: detachable TUPLE [line: INTEGER_32; nested: INTEGER_32] -- Breakable info when call occurred. call_records: detachable ARRAYED_LIST [like Current] -- Sub call records. class_type_id: INTEGER_32 -- Related written class type id. depth: INTEGER_32 -- Call stack depth of Current's call dynamic_class_type_id: INTEGER_32 -- Related dynamic class type id. do if attached {ANY} object as o then Result := rt_dynamic_type (o) end end feature_rout_id: INTEGER_32 -- Related feature routine id. flat_value_records_has_local: BOOLEAN -- Does value_records has local values ? require is_flat: is_flat do if attached value_records as vals then Result := across vals as c some c.item.is_local_record end end end object: detachable ANY -- Target object. parent: detachable like Current -- Parent's call record. steps: ARRAYED_LIST [BOOLEAN] -- Steps data value_records: detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD] -- Recorded values (assignment...) feature {RT_DBG_EXECUTION_RECORDER, RT_DBG_CALL_RECORD} -- Query associated_replayable_call: detachable like Current -- Associated replayable call do if rt_information_available then Result := Current elseif attached parent as p then Result := p.associated_replayable_call end ensure result_not_void: Result /= Void and then Result.rt_information_available end available_calls_to_bottom: INTEGER_32 -- Number of available calls to reach the bottom record. do if attached parent as p then Result := p.available_calls_to_bottom end Result := Result + 1 end bottom: like Current -- Bottom's call record. do Result := Current if attached parent as p then Result := p.bottom end ensure result_attached: Result /= Void end call_by_id (a_id: STRING_8): detachable like Current require a_id_not_empty: a_id.count > 0 local p: INTEGER_32 i: INTEGER_32 r: like Current sub_id: detachable STRING_8 do debug ("rt_dbg_replay") dtrace_indent (depth) dtrace ("call_by_id (" + a_id + ")%N") end p := a_id.index_of ('.', 1) if p > 0 then sub_id := a_id.substring (p + 1, a_id.count) i := a_id.substring (1, p - 1).to_integer_32 else i := a_id.to_integer_32 end if attached call_records as crecs and then crecs.valid_index (i) then r := crecs.i_th (i) if sub_id = Void then Result := r else Result := r.call_by_id (sub_id) end end debug ("rt_dbg_replay") dtrace_indent (depth) dtrace ("call_by_id (" + a_id + ") -> Result=") if Result = Void then dtrace ("Void") else dtrace (Result.to_string (0)) end dtrace ("%N") end end is_ready_to_add_call_record: BOOLEAN -- Is Current's structures in valid context to add call record? do Result := attached call_records as crecs implies crecs.after end is_ready_to_add_value_record: BOOLEAN -- Is Current's structures in valid context to add value record? do Result := attached value_records as vrecs implies vrecs.after end record_count_but (c: detachable like Current): INTEGER_32 -- Number of records contained by Current and sub calls -- apart from the records contained by c (and sub calls) local r: like Current p: CURSOR do if is_flat then if attached value_records as ffr then Result := ffr.count end else if attached value_records as vrs then Result := vrs.count end if attached call_records as crs then p := crs.cursor from crs.start until crs.after loop r := crs.item_for_iteration if r /= c then Result := Result + r.record_count_but (Void) end crs.forth end crs.go_to (p) end end if object /= Void then Result := Result + 1 end end to_string (a_level: INTEGER_32): STRING_8 -- String representation of Current local subs: detachable STRING_8 at_subs: STRING_8 l_steps: like steps i: INTEGER_32 val_cursor: detachable CURSOR call_cursor: detachable CURSOR c, v: INTEGER_32 l_calls: like call_records l_values: like value_records do create Result.make (5) Result.append_character ('[') Result.append_integer (depth) Result.append_character ('.') Result.append_integer (dynamic_class_type_id) Result.append_character ('.') Result.append_integer (class_type_id) Result.append_character ('.') Result.append_integer (feature_rout_id) Result.append_character ('.') if attached breakable_info as bi then Result.append_integer (bi.line) Result.append_character ('.') Result.append_integer (bi.nested) else Result.append_integer (0) Result.append_character ('.') Result.append_integer (0) end if is_replaying and then attached replayed_position as rbi then Result.append_character ('.') Result.append_integer (rbi.line) Result.append_character ('.') Result.append_integer (rbi.nested) end Result.append_character ('%T') if is_flat then Result.append_character ('#') end if not rt_information_available then Result.append_character ('?') end l_values := value_records l_calls := call_records c := 0 v := 0 if a_level = 0 then if l_calls /= Void then c := l_calls.count end else l_steps := steps if l_steps.count > 0 and then attached {CURSOR} l_steps.cursor as steps_cursor then create at_subs.make_empty subs := at_subs from if l_values /= Void then val_cursor := l_values.cursor l_values.start end if l_calls /= Void then call_cursor := l_calls.cursor l_calls.start end i := l_steps.index l_steps.start until l_steps.after loop if l_steps.item then v := v + 1 else if l_calls = Void then else if l_steps.index = i then at_subs.append_character ('!') end at_subs.append_string (l_calls.item.to_string (a_level - 1)) l_calls.move (1) end c := c + 1 end l_steps.forth end if l_values /= Void and then val_cursor /= Void then l_values.go_to (val_cursor) check v = l_values.count end end if l_calls /= Void and then call_cursor /= Void then l_calls.go_to (call_cursor) check c = l_calls.count end end l_steps.go_to (steps_cursor) end end if c > 0 then Result.append_character ('+') Result.append_integer (c) Result.append_character ('(') if subs /= Void then Result.append_string (subs) end Result.append_character (')') end Result.append_character (']') end feature {NONE} -- 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 local chgs: like changes_between c, v: CURSOR r: detachable like changes_between do if csr1.is_flat then r := csr1.value_records end if r /= Void then Result := r else create Result.make (30) if attached csr1.value_records as vrecs then v := vrecs.cursor Result.append (vrecs) vrecs.go_to (v) end if attached csr1.call_records as crecs then c := crecs.cursor from crecs.start until crecs.after or crecs.item_for_iteration = csr2 loop chgs := changes_between (crecs.item_for_iteration, csr2) if chgs /= Void then Result.append (chgs) end crecs.forth end crecs.go_to (c) end end ensure -- from RT_DBG_COMMON result_not_void: Result /= Void end feature {NONE} -- Retrieval frozen internal_correct_mismatch -- Called from runtime to perform a proper dynamic dispatch on correct_mismatch -- from MISMATCH_CORRECTOR. -- (from ANY) local l_msg: STRING_8 l_exc: EXCEPTIONS do if attached {MISMATCH_CORRECTOR} Current as l_corrector then l_corrector.correct_mismatch else create l_msg.make_from_string ("Mismatch: ") create l_exc l_msg.append (generating_type.name) l_exc.raise_retrieval_exception (l_msg) end end feature -- Status call_records_closed: BOOLEAN -- Is call_records entries closed? require is_not_closed: not is_closed do if attached call_records as l_calls then Result := across l_calls.new_cursor.reversed as c all c.item.is_closed end else Result := True end end is_closed: BOOLEAN -- Is Current record closed ? is_expanded: BOOLEAN -- Is object an expanded value ? is_flat: BOOLEAN -- Is Current record flat ? feature {RT_DBG_EXECUTION_RECORDER} -- Steps is_replaying: BOOLEAN -- Is currently replaying ? do Result := recorder.is_replaying end left_step: detachable ARRAYED_LIST [RT_DBG_VALUE_RECORD] -- Record between current and previous step require is_replaying: is_replaying local l_steps: like steps do l_steps := steps debug ("rt_dbg_replay") debug_display_steps end l_steps.move (-1) debug ("rt_dbg_replay") dtrace_indent (depth) dtrace ("left_step -> ") dtrace ("[" + l_steps.index.out + "/" + l_steps.count.out + "]: ") end if not l_steps.before then if l_steps.item then check value_records_attached: value_records /= Void end if attached value_records as vrecs then vrecs.move (-1) create Result.make (1) check value_records_not_before: not vrecs.before end Result.force (vrecs.item) debug ("rt_dbg_replay") dtrace ("VALUE ") dtrace (vrecs.index.out + "/" + vrecs.count.out) end end else check call_records_attached: call_records /= Void end if attached call_records as crecs then crecs.move (-1) debug ("rt_dbg_replay") dtrace ("CALL ") dtrace (crecs.index.out + "/" + crecs.count.out) end check call_records_not_before: not crecs.before end Result := changes_between (crecs.item, Void) end end end debug ("rt_dbg_replay") if Result = Void then dtrace ("=> Void %N") else dtrace ("=> " + Result.count.out + " %N") end end ensure value_records_cursor_valid: attached value_records as vrecs2 implies not vrecs2.before call_records_cursor_valid: attached call_records as crecs2 implies not crecs2.before steps_before_implies_record_first: steps.before implies ((not attached value_records as vrecs3 or else vrecs3.isfirst) and (not attached call_records as crecs3 or else crecs3.isfirst)) end replayed_position: like last_position -- Replayed position require is_replaying: is_replaying local l_steps: like steps rpos: detachable like last_position do l_steps := steps if l_steps.after then rpos := last_position elseif l_steps.before then rpos := [0, 0] else if l_steps.item then check value_records_attached: value_records /= Void end if attached value_records as vrecs then rpos := vrecs.item.breakable_info end else check call_records_attached: call_records /= Void end if attached call_records as crecs then rpos := crecs.item.breakable_info end end end if attached {like replayed_position} rpos as ot_rpos then Result := ot_rpos else Result := [0, 0] end end replayed_position_is_first: BOOLEAN -- Replayed position is first require is_replaying: is_replaying do Result := steps.isfirst or steps.before end revert_left_step -- Revert previous left step require is_replaying: is_replaying steps_not_after: not steps.after local l_steps: like steps do l_steps := steps debug ("rt_dbg_replay") dtrace_indent (depth) dtrace ("revert_left_step -start-%N") debug_display_steps end if l_steps.before then l_steps.move (1) else if not l_steps.after then if l_steps.item then check value_records_attached: value_records /= Void end if attached value_records as vrecs then check not vrecs.after end vrecs.move (1) end else check call_records_attached: call_records /= Void end if attached call_records as crecs then check not crecs.after end crecs.move (1) end end end l_steps.move (1) end debug ("rt_dbg_replay") dtrace_indent (depth) dtrace ("revert_left_step -end-%N") end ensure steps.after implies (attached call_records as crecs2 implies crecs2.after) and (attached value_records as vrecs2 implies vrecs2.after) end feature {NONE} -- Steps implementation register_call_step -- Register a call step require not_is_flat: not is_flat do debug ("rt_dbg_record") dtrace_indent (depth) dtrace (depth.out + " -> register_call_step @" + last_position.line.out + " %N") end register_step (False) ensure steps_is_after: steps.after end register_step (b: BOOLEAN) -- Register a step require not_is_flat: not is_flat local l_steps: like steps do l_steps := steps l_steps.force (b) l_steps.finish l_steps.move (1) ensure steps_is_after: steps.after end register_value_step -- Register a value step require not_is_flat: not is_flat do debug ("rt_dbg_record") dtrace_indent (depth) dtrace (depth.out + " -> register_value_step @" + last_position.line.out + " %N") end register_step (True) ensure steps_is_after: steps.after end feature {NONE} -- Testing c_rt_set_is_inside_rt_eiffel_code (v: INTEGER_32) -- (from RT_DBG_INTERNAL) external "C inline use %"eif_debug.h%"" alias "[ #ifdef WORKBENCH EIF_GET_CONTEXT; is_inside_rt_eiffel_code = $v; #endif ]" end test_locals (dep: INTEGER_32; loc_pos: INTEGER_32; val: ANY; a_rt_type: NATURAL_32) -- (from RT_DBG_INTERNAL) local s: STRING_8 retried: BOOLEAN do if not retried then c_rt_set_is_inside_rt_eiffel_code (1) s := "----------------------------------%N" s.append ("Loc #" + loc_pos.out + "(stack depth=" + dep.out + ")") if val /= Void then s.append (": should be " + val.generating_type.name) end s.append ("%N") print (s) s.append (" -> ") if attached stack_value_at (dep, Rt_dlt_localvar, loc_pos, a_rt_type) as a then s.append (a.generating_type.name + "=" + a.out) else s.append ("Void object") end s.append ("%N") print (s) c_rt_set_is_inside_rt_eiffel_code (0) else print ("Rescued%N") c_rt_set_is_inside_rt_eiffel_code (0) end rescue retried := True retry end test_set_local (dep: INTEGER_32; loc_pos: INTEGER_32; val: ANY; a_rt_type: NATURAL_32) -- (from RT_DBG_INTERNAL) local s: STRING_8 r: INTEGER_32 retried: BOOLEAN do if not retried then c_rt_set_is_inside_rt_eiffel_code (1) s := "----------------------------------%N" s.append ("SetLoc #" + loc_pos.out + "(stack depth=" + dep.out + ")") if val /= Void then s.append (": value " + val.generating_type.name) else s.append (": value Void") end s.append ("%N") print (s) r := set_stack_value_at (dep, Rt_dlt_localvar, loc_pos, a_rt_type, val) s.append (" -> ") s.append ("Result = " + r.out) s.append ("%N") print (s) c_rt_set_is_inside_rt_eiffel_code (0) else print ("Rescued%N") c_rt_set_is_inside_rt_eiffel_code (0) end rescue retried := True retry end feature {NONE} -- 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 do Io.Error.put_string (m) end dtrace_indent (n: INTEGER_32) -- note: might be removed with 6.2 -- (from RT_EXTENSION_COMMON) do Io.Error.put_string (create {STRING_8}.make_filled (' ', 2 * n)) end feature -- debug debug_display_steps -- Display steps for debugging purpose. local l_steps: like steps i: INTEGER_32 v, c: INTEGER_32 val_cursor: detachable CURSOR call_cursor: detachable CURSOR l_values: like value_records l_calls: like call_records do l_steps := steps l_values := value_records l_calls := call_records if attached {CURSOR} l_steps.cursor as steps_cursor then from i := l_steps.index v := 0 c := 0 l_steps.start print ("steps: " + i.out + " out of " + l_steps.count.out + "%N") if l_values /= Void then val_cursor := l_values.cursor print ("%Tvalues: " + l_values.index.out + " out of " + l_values.count.out + "%N") l_values.start else print ("%Tvalues: None %N") end if l_calls /= Void then call_cursor := l_calls.cursor print ("%Tcalls: " + l_calls.index.out + " out of " + l_calls.count.out + "%N") l_calls.start else print ("%Tcalls: None %N") end until l_steps.after loop print ("%T" + l_steps.index.out + "=") if l_steps.item then v := v + 1 print ("VALUE#" + v.out + ": ") if l_values = Void then print ("None") else print (l_values.item.to_string) l_values.move (1) end else c := c + 1 print ("CALL#" + c.out + ": ") if l_calls = Void then print ("None") else print (l_calls.item.to_string (0)) l_calls.move (1) end end if i = l_steps.index then print (" <- ") end print ("%N") l_steps.forth end if l_values /= Void and val_cursor /= Void then l_values.go_to (val_cursor) end if l_calls /= Void and then call_cursor /= Void then l_calls.go_to (call_cursor) end l_steps.go_to (steps_cursor) end end debug_output: STRING_8 -- Debug output as string representation. local tn: STRING_8 do tn := Reflector.type_name_of_type (class_type_id) if attached object as o and then attached {STRING_8} o.generating_type as otn then if tn = Void then tn := otn elseif otn /~ tn then tn := otn + " from " + tn end end if tn = Void then tn := "_" end Result := "{" + tn + "}." Result.append (feature_rout_id.out + " <" + depth.out + ">") if attached breakable_info as bi then Result.append_character (' ') Result.append_character ('(') Result.append_integer (bi.line) Result.append_character (',') Result.append_integer (bi.nested) Result.append_character (')') Result.append_character (' ') end if is_flat then Result.append_character ('&') end if attached object as obj and then rt_dynamic_type (obj) /= class_type_id then Result.append_string (" -> ERROR Dtype(obj):" + rt_dynamic_type (obj).out + " /= " + class_type_id.out) end ensure -- from DEBUG_OUTPUT result_not_void: Result /= Void end invariant recorder_attached: recorder /= Void steps_attached: steps /= Void last_position_attached: last_position /= Void non_empty_call_records: attached call_records as crecs implies not crecs.is_empty value_records_not_void_if_flat: is_flat implies value_records /= Void -- 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-2018, 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_CALL_RECORD
Generated by ISE EiffelStudio