public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Patch review
@ 2007-06-05 16:43 Sami Wagiaalla
  2007-06-05 17:28 ` Stan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Sami Wagiaalla @ 2007-06-05 16:43 UTC (permalink / raw)
  To: Stan Cox, frysk

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

Stan,

Please take a look at the attached patch.

Here is what it does:
- Create a new class called Variable to store the static information 
corresponding to a c variable.
- Store the information that was previously stored as arrays in 
Scope.java to be stored in a LinkedList of Variable objects.
- Make Subprogram extend Scope so that it can own variables as well as 
LexicalBlock.

The test-suit passes.

If this patch is okay next would be to look at the information stored in 
Variable (we can probably get rid of the dies stored there), and make 
Variable, and Scope self constructing (ie given a die they figure out 
their contents).

Cheers!
  Sami

[-- Attachment #2: cvsdiff --]
[-- Type: text/plain, Size: 11882 bytes --]

? cvsdiff
Index: frysk-core/frysk/debuginfo/DebugInfo.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/debuginfo/DebugInfo.java,v
retrieving revision 1.6
diff -u -r1.6 DebugInfo.java
--- frysk-core/frysk/debuginfo/DebugInfo.java	4 Jun 2007 14:22:48 -0000	1.6
+++ frysk-core/frysk/debuginfo/DebugInfo.java	5 Jun 2007 14:25:38 -0000
@@ -64,6 +64,7 @@
 import frysk.rt.Frame;
 import frysk.rt.LexicalBlock;
 import frysk.rt.Subprogram;
+import frysk.rt.Variable;
 import frysk.dwfl.DwflFactory;
 import frysk.expr.CppParser;
 import frysk.expr.CppLexer;
@@ -493,18 +494,14 @@
            nParms += 1;
            parm = parm.getSibling();
          }
-       block.setVariables(nParms);
-       Value vars[] = block.getVariables();
-       block.setVariableDies(nParms);
-       DwarfDie dies[] = block.getVariableDies();
-       block.setTypeDies(nParms);
-       DwarfDie types[] = block.getTypeDies();
+
        parm = firstVar;
        nParms = 0;
        while (parm != null)
          {
-           vars[nParms] = debugInfoEvaluator[0].getValue(parm);
-           if (vars[nParms] == null)
+           Variable variable = new Variable();
+           variable.setVariable(debugInfoEvaluator[0].getValue(parm));
+           if (variable.getVariable() == null)
              {
                int tag = parm.getTag();
                switch (tag)
@@ -516,11 +513,11 @@
                  case DwTagEncodings.DW_TAG_structure_type_:
                  case DwTagEncodings.DW_TAG_subrange_type_:
                  case DwTagEncodings.DW_TAG_typedef_:
-                   types[nParms] = parm;
+                   variable.setTypeDie(parm);
                }
              }
            else
-             dies[nParms] = parm;
+             variable.setVariableDie(parm);
            parm = parm.getSibling();
            nParms += 1;
          }
@@ -535,20 +532,31 @@
              System.out.println(parameter.getText());
            }
            LexicalBlock b = subPr.getBlock();
-           Value v[] = b.getVariables();
+           LinkedList variables =  b.getVariables();
+//           Value v[] = b.getVariables();
            System.out.println("Variables");
-           for (int j = 0; j < v.length; j++)
-             if (v[j] != null)
-               System.out.println(v[j].getText());
-           DwarfDie d[] = b.getVariableDies();
-           for (int j = 0; j < d.length; j++)
-             if (d[j] != null)
-               System.out.println(d[j].getName());
-           DwarfDie t[] = b.getTypeDies();
-           System.out.println("Types");
-           for (int j = 0; j < t.length; j++)
-             if (t[j] != null)
-               System.out.println(t[j].getName());
+           
+           iterator = b.getVariables().iterator();
+           while (iterator.hasNext())
+            {
+              Variable variable = (Variable) iterator.next();
+              System.out.println(variable.getVariable().getText());
+            }
+           
+           iterator = b.getVariables().iterator();
+           while (iterator.hasNext())
+            {
+              Variable variable = (Variable) iterator.next();
+              System.out.println(variable.getVariableDie().getName());
+            }
+           
+           iterator = b.getVariables().iterator();
+           while (iterator.hasNext())
+            {
+              Variable variable = (Variable) iterator.next();
+              System.out.println(variable.getTypeDie().getName());
+            }
+           
          }
        
        return subPr;
Index: frysk-core/frysk/debuginfo/DebugInfoEvaluator.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/debuginfo/DebugInfoEvaluator.java,v
retrieving revision 1.3
diff -u -r1.3 DebugInfoEvaluator.java
--- frysk-core/frysk/debuginfo/DebugInfoEvaluator.java	4 Jun 2007 14:22:48 -0000	1.3
+++ frysk-core/frysk/debuginfo/DebugInfoEvaluator.java	5 Jun 2007 14:25:38 -0000
@@ -44,26 +44,20 @@
 import inua.eio.ByteOrder;
 
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
-import java.lang.Integer;
 
 import lib.dw.BaseTypes;
+import lib.dw.DwAtEncodings;
 import lib.dw.DwException;
+import lib.dw.DwOpEncodings;
+import lib.dw.DwTagEncodings;
 import lib.dw.DwarfDie;
 import lib.dw.Dwfl;
 import lib.dw.DwflDieBias;
-import lib.dw.DwOpEncodings;
-import lib.dw.DwAtEncodings;
-import lib.dw.DwTagEncodings;
 import frysk.dwfl.DwflFactory;
 import frysk.expr.CppSymTab;
-import frysk.value.ArithmeticType;
-import frysk.value.ArrayType;
-import frysk.value.ClassType;
-import frysk.value.EnumType;
-import frysk.value.PointerType;
-import frysk.value.Type;
-import frysk.value.Value;
 import frysk.proc.Isa;
 import frysk.proc.Task;
 import frysk.proc.ptrace.AddressSpaceByteBuffer;
@@ -71,8 +65,16 @@
 import frysk.rt.LexicalBlock;
 import frysk.rt.StackFactory;
 import frysk.rt.Subprogram;
+import frysk.rt.Variable;
 import frysk.sys.Errno;
 import frysk.sys.Ptrace.AddressSpace;
+import frysk.value.ArithmeticType;
+import frysk.value.ArrayType;
+import frysk.value.ClassType;
+import frysk.value.EnumType;
+import frysk.value.PointerType;
+import frysk.value.Type;
+import frysk.value.Value;
 
 class DebugInfoEvaluator
     implements CppSymTab
@@ -498,17 +500,18 @@
     DwarfDie die = bias.die;
 
     LexicalBlock b = subprogram.getBlock();
-    Value vars[] = b.getVariables();
-    DwarfDie varDies[] = b.getVariableDies();
+    LinkedList variables = b.getVariables();
+//    Value vars[] = b.getVariables();
+//    DwarfDie varDies[] = b.getVariableDies();
     DwarfDie varDie;
-    for (int j = 0; j < vars.length; j++)
-      if (vars[j] != null && vars[j].getText().compareTo(s) == 0)
-        {
-          allDies = die.getScopes(pc - bias.bias);
-          varDies[j].setScopes(allDies);
-          return varDies[j];
-        }
-          
+    Iterator iterator = variables.iterator();
+    while(iterator.hasNext()){
+      Variable variable = (Variable) iterator.next();
+      if(variable.getVariable().getText().equals(s)){
+        return variable.getVariableDie();
+      }
+    }
+
     allDies = die.getScopes(pc - bias.bias);
     varDie = die.getScopeVar(allDies, s);
     // Do we have something above didn't find, e.g. DW_TAG_enumerator?
Index: frysk-core/frysk/rt/Scope.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/Scope.java,v
retrieving revision 1.1
diff -u -r1.1 Scope.java
--- frysk-core/frysk/rt/Scope.java	4 Jun 2007 15:23:57 -0000	1.1
+++ frysk-core/frysk/rt/Scope.java	5 Jun 2007 14:25:38 -0000
@@ -39,9 +39,9 @@
 
 package frysk.rt;
 
+import java.util.LinkedList;
+
 import lib.dw.DwarfDie;
-import frysk.value.Type;
-import frysk.value.Value;
 
 /**
  * A class to represent a Scope.
@@ -63,40 +63,19 @@
  */
 public class Scope
 {
-  LexicalBlock outer;
-  Value[] variables;
-  DwarfDie[] variableDies;
-  Type[] types;
-  DwarfDie[] typeDies;
-
-  public Value[] getVariables ()
-  {
-    return variables;
-  }
-
-  public void setVariables (int n)
-  {
-    this.variables = new Value[n];
+  LinkedList variables;
+  Scope outer;
+  
+  Scope(DwarfDie die){
+    this.variables = new LinkedList();
+  }
+  
+  Scope(){
+    this.variables = new LinkedList();
+  }
+  
+  public LinkedList getVariables(){
+    return this.variables;
   }
-
-  public DwarfDie[] getVariableDies ()
-  {
-    return variableDies;
-  }
-
-  public void setVariableDies (int n)
-  {
-    this.variableDies = new DwarfDie[n];
-  }
-
-  public DwarfDie[] getTypeDies ()
-  {
-    return typeDies;
-  }
-
-  public void setTypeDies (int n)
-  {
-    this.typeDies = new DwarfDie[n];
-  }
-
+  
 }
Index: frysk-core/frysk/rt/Subprogram.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/Subprogram.java,v
retrieving revision 1.6
diff -u -r1.6 Subprogram.java
--- frysk-core/frysk/rt/Subprogram.java	4 Jun 2007 20:24:41 -0000	1.6
+++ frysk-core/frysk/rt/Subprogram.java	5 Jun 2007 14:25:38 -0000
@@ -51,7 +51,7 @@
 import frysk.debuginfo.DebugInfo;
 import frysk.value.Value;
 
-public class Subprogram
+public class Subprogram extends Scope
 {
   // Language language;
     Subprogram outer;
Index: frysk-core/frysk/rt/Variable.java
===================================================================
RCS file: frysk-core/frysk/rt/Variable.java
diff -N frysk-core/frysk/rt/Variable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ frysk-core/frysk/rt/Variable.java	5 Jun 2007 14:25:38 -0000
@@ -0,0 +1,95 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2007, Red Hat Inc.
+//
+// FRYSK is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// 
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+
+package frysk.rt;
+
+import lib.dw.DwarfDie;
+import frysk.value.Type;
+import frysk.value.Value;
+
+/**
+ * This class contains the static information corresponding to a language variable.
+ * Given a frame it is possible to get a Value corresponding to this Variable
+ */
+public class Variable
+{
+
+  private Value variable;
+  private DwarfDie variableDie;
+  private Type type;
+  private DwarfDie typeDie;
+  
+  public void setVariable (Value variable)
+  {
+    this.variable = variable;
+  }
+  public Value getVariable ()
+  {
+    return variable;
+  }
+  public void setVariableDie (DwarfDie variableDie)
+  {
+    this.variableDie = variableDie;
+  }
+  public DwarfDie getVariableDie ()
+  {
+    return variableDie;
+  }
+  public void setType (Type type)
+  {
+    this.type = type;
+  }
+  public Type getType ()
+  {
+    return type;
+  }
+  public void setTypeDie (DwarfDie typeDie)
+  {
+    this.typeDie = typeDie;
+  }
+  public DwarfDie getTypeDie ()
+  {
+    return typeDie;
+  }
+
+  public Value getValue(Frame frame){
+    return null;
+  }
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch review
  2007-06-05 16:43 Patch review Sami Wagiaalla
@ 2007-06-05 17:28 ` Stan Cox
  2007-06-05 19:11   ` Sami Wagiaalla
  2007-06-06 13:06   ` Sami Wagiaalla
  0 siblings, 2 replies; 4+ messages in thread
From: Stan Cox @ 2007-06-05 17:28 UTC (permalink / raw)
  To: Sami Wagiaalla; +Cc: Frysk List

Might be able to punt on having Type in class Variable as
variable.getType() gives that, since a Value is a Type and a Location.  
Is Variable intended to be a Value plus the corresponding DwarfDie?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch review
  2007-06-05 17:28 ` Stan Cox
@ 2007-06-05 19:11   ` Sami Wagiaalla
  2007-06-06 13:06   ` Sami Wagiaalla
  1 sibling, 0 replies; 4+ messages in thread
From: Sami Wagiaalla @ 2007-06-05 19:11 UTC (permalink / raw)
  To: Stan Cox; +Cc: Frysk List

Stan Cox wrote:
> Might be able to punt on having Type in class Variable as
> variable.getType() gives that, since a Value is a Type and a Location.  
> Is Variable intended to be a Value plus the corresponding DwarfDie?
>   
The idea about variable is to keep the static information about a c 
variable so that there is no ambiguity about what variable i am talking 
about, and all that needs to be done is look a the value of the location 
tag associated with that variable when Frame is available.

But I am having second thoughts, lets forget about the class Variable. I 
can write my code to use Value objects. Lets leave Variable until it is 
unavoidable. So the relevant changes from the previous patch is just 
replacing the multiple arrays with a linked list of Value objects.

Sami

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch review
  2007-06-05 17:28 ` Stan Cox
  2007-06-05 19:11   ` Sami Wagiaalla
@ 2007-06-06 13:06   ` Sami Wagiaalla
  1 sibling, 0 replies; 4+ messages in thread
From: Sami Wagiaalla @ 2007-06-06 13:06 UTC (permalink / raw)
  To: Stan Cox; +Cc: Frysk List


> Is Variable intended to be a Value plus the corresponding DwarfDie?
>   
Yes. Scope.java stores the Values and the Dies so group them together 
and put then in a Variable class.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-05 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-05 16:43 Patch review Sami Wagiaalla
2007-06-05 17:28 ` Stan Cox
2007-06-05 19:11   ` Sami Wagiaalla
2007-06-06 13:06   ` Sami Wagiaalla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).