Difference between revisions of "Interfacing the Debugger"

m
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Compiler]]
 
[[Category:Compiler]]
{{Warning|'''Warning''': Article under development}}
+
[[Category:EiffelDebugger]]
 +
{{UnderConstruction}}
  
==Introduction==
+
====Introduction====
This article discusses issues recently discovered for the following two validity rules:
+
EiffelStudio supports a rich debugging feature set for workbench code. Finalized systems can only be debugged at the C level.
  
8.15.7 Validity: ''Conversion Procedure rule'', Validity code: '''VYCP'''<br>
+
====Requirements on the runtime====
8.15.8 Validity: ''Conversion Query rule'', Validity code: '''VYCQ'''
+
When a program is being debugged it is either executing or communicating with the debug daemon. For the latter it is waiting for commands from the daemon (over an inter process communication mechanism) and executing them. Some of those commands are:
 +
* Proceed to the next breakpoint.
 +
* Proceed to the next breakpoint slot.
 +
* Stop the execution.
 +
* Resume the execution.
 +
* Give information about variables on the stack or heap.
  
==Examples==
+
The runtime thus needs to be able to inspect the C stack and make the transition between the two states executing and communicating.
For the following examples eweasel tests have been created. Their named
+
====Example 1====
+
eweasel test: convert-to-current-type
+
<code>[eiffel,N]
+
class A[G]
+
convert
+
  to_a: {A[G]}
+
feature
+
  to_a: A[G]
+
end
+
</code>
+
The conversion to '''A[G]''' should indeed not be valid because they are conform.
+
  
The only rule that matters in our case is '''VYCQ(3)'''.
+
====An Example====
 +
The translation to workbench code of feature foo will be used throughout the remainder of the text:
  
What VYCQ(3) asks is the following
+
{|border="0" cellpadding="2" cellspacing="0" align="center"
 +
|-valign="top" -halign="center"
 +
|
 +
<eiffel>foo (list: LIST [LIST [ANY]]
 +
    str: STRING): BOOLEAN
 +
  local
 +
      i: INTEGER
 +
  do
 +
      i := 10
 +
      list.first.force (str)
 +
      Result := True
 +
  end</eiffel>
 +
|
 +
<c>/* foo */
 +
EIF_BOOLEAN Fadkw7f (EIF_REFERENCE Current,
 +
                    EIF_REFERENCE arg1,
 +
                    EIF_REFERENCE arg2)
 +
{
 +
  EIF_INTEGER_32 loc1 = (EIF_INTEGER_32) 0;
 +
  EIF_BOOLEAN Result = (EIF_BOOLEAN) 0;
 +
  ...
  
  Is A[ANY] conform to A[G]?
+
  /*Load locals onto the debuggers stack (cop_stack):*/
 +
  RTLU (SK_BOOL, &Result);
 +
  RTLU(SK_REF,&arg1);
 +
  RTLU(SK_REF,&arg2);
 +
  RTLU (SK_REF, &Current);
 +
  RTLU(SK_INT32, &loc1);
 +
  ...
 +
  RTHOOK(1); //Signal debugger, breakpoint slot 1 reached
 +
  loc1 = (EIF_INTEGER_32)((EIF_INTEGER_32) 10L);
 +
  RTHOOK(2);  //Signal debugger, breakpoint slot 2 reached
 +
  tp1 = (FUNCTION_CAST(EIF_REFERENCE, (EIF_REFERENCE))
 +
      RTVF(100, 33, "first", arg1))(arg1);
 +
  RTNHOOK(2); //Signal debugger, nested breakpoint slot
 +
  tp2 = RTCCL(arg2);
 +
  (FUNCTION_CAST(void, (EIF_REFERENCE, EIF_REFERENCE))
 +
      RTVF(100, 39, "force", tp1))(tp1, tp2);
 +
  RTHOOK(3);  //Signal debugger, breakpoint slot 3 reached
 +
  Result = (EIF_BOOLEAN)(EIF_BOOLEAN) 1;
 +
  RTHOOK(4);  //Signal debugger, breakpoint slot 4 reached
 +
  RTLO(5);    //Pop the five locals from the debuggers stack
  
As we answer this question clearly with '''no''', the conversion is valid because all the other rules do not object either.
+
  return Result;
 
+
}</c>
====Example 2====
+
|
eweasel test: convert-to-current-type
+
|}
<code>[eiffel,N]
+
====Inspecting the C stack====
class A[G]
+
====Switching between executing and communicating====
convert
+
In the code example above there are several calls to the macro RTHOOK and RTNHOOK.
  to_a: {A[STRING]}
+
feature
+
  to_a: A[STRING]
+
end
+
</code>
+
In the case where G is actual type parameter is a subtype of STRING to two types are conform again.
+
 
+
The intresting rule is again '''VYCQ(3)''':
+
 
+
Is A[ANY] conform to A[STRING]?
+
 
+
This question is answered with '''no''' too. Therefore the conversion is valid.
+

Latest revision as of 22:23, 6 May 2007

Construction.png Not Ready for Review: This Page is Under Development!

Introduction

EiffelStudio supports a rich debugging feature set for workbench code. Finalized systems can only be debugged at the C level.

Requirements on the runtime

When a program is being debugged it is either executing or communicating with the debug daemon. For the latter it is waiting for commands from the daemon (over an inter process communication mechanism) and executing them. Some of those commands are:

  • Proceed to the next breakpoint.
  • Proceed to the next breakpoint slot.
  • Stop the execution.
  • Resume the execution.
  • Give information about variables on the stack or heap.

The runtime thus needs to be able to inspect the C stack and make the transition between the two states executing and communicating.

An Example

The translation to workbench code of feature foo will be used throughout the remainder of the text:

foo (list: LIST [LIST [ANY]]
     str: STRING): BOOLEAN
   local
      i: INTEGER
   do
      i := 10
      list.first.force (str)
      Result := True
   end
/* foo */
EIF_BOOLEAN Fadkw7f (EIF_REFERENCE Current, 
                     EIF_REFERENCE arg1, 
                     EIF_REFERENCE arg2)
{
   EIF_INTEGER_32 loc1 = (EIF_INTEGER_32) 0;
   EIF_BOOLEAN Result = (EIF_BOOLEAN) 0;
   ...
 
   /*Load locals onto the debuggers stack (cop_stack):*/
   RTLU (SK_BOOL, &Result); 
   RTLU(SK_REF,&arg1);
   RTLU(SK_REF,&arg2);
   RTLU (SK_REF, &Current);
   RTLU(SK_INT32, &loc1);
   ...
   RTHOOK(1);  //Signal debugger, breakpoint slot 1 reached
   loc1 = (EIF_INTEGER_32)((EIF_INTEGER_32) 10L);
   RTHOOK(2);  //Signal debugger, breakpoint slot 2 reached
   tp1 = (FUNCTION_CAST(EIF_REFERENCE, (EIF_REFERENCE)) 
      RTVF(100, 33, "first", arg1))(arg1);
   RTNHOOK(2); //Signal debugger, nested breakpoint slot
   tp2 = RTCCL(arg2);
   (FUNCTION_CAST(void, (EIF_REFERENCE, EIF_REFERENCE)) 
      RTVF(100, 39, "force", tp1))(tp1, tp2);
   RTHOOK(3);  //Signal debugger, breakpoint slot 3 reached
   Result = (EIF_BOOLEAN)(EIF_BOOLEAN) 1;
   RTHOOK(4);  //Signal debugger, breakpoint slot 4 reached
   RTLO(5);    //Pop the five locals from the debuggers stack
 
   return Result;
}

Inspecting the C stack

Switching between executing and communicating

In the code example above there are several calls to the macro RTHOOK and RTNHOOK.