public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix bug 4614, 4619 and 4870
@ 2007-09-30  1:10 Zhao Shujing
  0 siblings, 0 replies; only message in thread
From: Zhao Shujing @ 2007-09-30  1:10 UTC (permalink / raw)
  To: Frysk Mailing List; +Cc: Andrew Cagney

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

Hi

This bug is to fix 4614, 4619 and 4870.
Here is what it does:
- Change the top confuse text "current program counter" to segment
combox box. Users can choose the segment from the combo box to display
and adjust the offset by spin button. Some segment is too long to
display, it's be handled the by the following rule.
- If the specified startAddress is too smaller that the lastKnownFrom
value, and the UI can't handle some many data, it would be set to
display about 50 instructions at disassembly window and 20 rows at
memory window from the startAddress. 
- It would be handled by the same way if the user only changed the
endAddress.
- Add warning dialogs when the address can't be accessed and when the
symbol is not in current context. The warning messages are as same as
these of gdb.

[-- Attachment #2: dismem0929.patch --]
[-- Type: text/x-patch, Size: 41413 bytes --]

? memory/MemoryWindow.java0921
Index: disassembler/DisassemblyWindow.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/disassembler/DisassemblyWindow.java,v
retrieving revision 1.32
diff -u -r1.32 DisassemblyWindow.java
--- disassembler/DisassemblyWindow.java	21 Sep 2007 07:00:43 -0000	1.32
+++ disassembler/DisassemblyWindow.java	29 Sep 2007 08:34:42 -0000
@@ -58,7 +58,6 @@
 import org.gnu.gtk.DataColumnObject;
 import org.gnu.gtk.DataColumnString;
 import org.gnu.gtk.Entry;
-import org.gnu.gtk.Label;
 import org.gnu.gtk.ListStore;
 import org.gnu.gtk.SpinButton;
 import org.gnu.gtk.TreeIter;
@@ -68,6 +67,8 @@
 import org.gnu.gtk.Window;
 import org.gnu.gtk.event.ButtonEvent;
 import org.gnu.gtk.event.ButtonListener;
+import org.gnu.gtk.event.ComboBoxEvent;
+import org.gnu.gtk.event.ComboBoxListener;
 import org.gnu.gtk.event.EntryEvent;
 import org.gnu.gtk.event.EntryListener;
 import org.gnu.gtk.event.LifeCycleEvent;
@@ -76,8 +77,12 @@
 import org.gnu.gtk.event.SpinListener;
 
 import frysk.gui.common.IconManager;
+import frysk.gui.dialogs.WarnDialog;
 import frysk.gui.prefs.PreferenceManager;
+import frysk.gui.monitor.GuiObject;
+import frysk.gui.monitor.ObservableLinkedList;
 import frysk.gui.monitor.Saveable;
+import frysk.gui.monitor.SimpleComboBox;
 import frysk.proc.Proc;
 import frysk.proc.Task;
 import frysk.stepping.TaskStepEngine;
@@ -129,10 +134,6 @@
 
   private SpinButton toSpin;
 
-  private Label pcLabelDec;
-
-  private Label pcLabelHex;
-  
   private Entry fromBox;
     
   private Entry toBox;
@@ -143,7 +144,7 @@
 
   private double lastKnownTo;
   
-  private int numInstructions;
+  private int numInstructions = 50;
   
   private long pcOffset = 0;
   
@@ -163,6 +164,14 @@
   
   private MemoryMap[] mmaps;
   
+  private SimpleComboBox segmentCombo;
+  
+  private ObservableLinkedList segmentList;
+  
+  private int segmentIndex = 0;
+  
+  private int row = numInstructions*3;
+  
   /**
    * The DisassmblyWindow, given a Task, will disassemble the instructions
    * and parameters for that task in memory and display them, as well as their
@@ -180,9 +189,10 @@
     this.toSpin = (SpinButton) this.glade.getWidget("toSpin");
     this.fromBox = (Entry) this.glade.getWidget("fromBox");
     this.toBox = (Entry) this.glade.getWidget ("toBox");
-    this.pcLabelDec = (Label) this.glade.getWidget("PCLabelDec");
-    this.pcLabelHex = (Label) this.glade.getWidget("PCLabelHex");
+    this.segmentCombo = new SimpleComboBox(
+	    (this.glade.getWidget("segmentCombo")).getHandle());
     this.model = new ListStore(cols);
+    this.segmentList = new ObservableLinkedList();
     
     this.lock = new LockObserver();
     this.DW_active = true;
@@ -273,7 +283,23 @@
     this.disassemblerView = (TreeView) this.glade.getWidget("disassemblerView");
 
     this.mmaps = this.myTask.getProc().getMaps();
+    
+    for (int i = 0; i < this.mmaps.length; i++)
+    {
+	GuiObject segment = new GuiObject(Long.toHexString(mmaps[i].addressLow)
+		+ " - " + Long.toHexString(mmaps[i].addressHigh), "");
+	segmentList.add(i, segment);
+	if (mmaps[i].addressLow <= pc_inc && pc_inc < mmaps[i].addressHigh)
+	    this.segmentIndex = i;
+    }
+    
+    this.segmentCombo.watchLinkedList(segmentList);
+    
+    this.segmentCombo.setSelectedObject((GuiObject) segmentList.get(segmentIndex));
 
+    this.segmentCombo.setActive(segmentIndex + 1);
+    this.segmentCombo.showAll();
+    
     this.diss = new Disassembler(myTask.getMemory());
     this.fromSpin.setRange(0.0, highestAddress);
     this.fromSpin.setValue((double) pc_inc);
@@ -281,9 +307,7 @@
     this.lastKnownFrom = pc_inc;
     this.toSpin.setRange(0.0, highestAddress);
     //this.toSpin.setValue((double) end);
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
-
+    
     setUpColumns();
 
     disassemblerView.setAlternateRowColor(true);
@@ -326,6 +350,26 @@
     
     ((Button) this.glade.getWidget("formatButton")).hideAll();
     
+    segmentCombo.addListener(new ComboBoxListener()
+    {
+	public void comboBoxEvent (ComboBoxEvent arg0)
+	{
+	    if(arg0.isOfType(ComboBoxEvent.Type.CHANGED))
+	    {
+		if (segmentList.indexOf(segmentCombo.getSelectedObject()) == -1)
+		    return;
+		int temp = segmentList.indexOf(segmentCombo.getSelectedObject());
+		long startAddress = mmaps[temp].addressLow;
+		long endAddress = mmaps[temp].addressHigh;
+		if (endAddress - startAddress > row)
+		    handleSegment (startAddress, startAddress+20*8);
+		else
+		    handleSegment (startAddress, endAddress);
+		segmentIndex = temp;		
+	    }
+	}
+    });
+    
     this.fromSpin.addListener(new SpinListener()
     {
       public void spinEvent (SpinEvent arg0)
@@ -343,7 +387,13 @@
         	if (addressAccessible((long)value))
         	    handleFromSpin(value);
         	else
+        	{        	
         	    fromSpin.setValue(lastKnownFrom);
+        	    WarnDialog dialog = new WarnDialog(
+        		    " No function contains specified address");
+        	    dialog.showAll();
+        	    dialog.run();
+        	}
             }
         }
       }
@@ -366,7 +416,13 @@
         	if (addressAccessible((long)value))
         	    handleToSpin(value);
         	else
-        	    toSpin.setValue(lastKnownTo);      	
+        	{
+        	    toSpin.setValue(lastKnownTo);
+        	    WarnDialog dialog = new WarnDialog(
+        		    " No function contains specified address");
+        	    dialog.showAll();
+        	    dialog.run();
+        	}
             }
         }          
       }
@@ -390,7 +446,13 @@
                 {
                   double d = (double) Long.parseLong(str, 16);
                   if (!addressAccessible((long)d))
-            	  fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+                  {
+                      fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+        	      WarnDialog dialog = new WarnDialog(
+        		      " No function contains specified address");
+        	      dialog.showAll();
+        	      dialog.run();
+                  }
                   else
                   {
                       if (d > lastKnownTo)
@@ -401,8 +463,14 @@
                     	  fromSpin.setValue(lastKnownTo);
                       }
                       else
-                          fromSpin.setValue(d);
+                      {
+                	  if ( (d < lastKnownFrom) && (lastKnownFrom - d > row*8))
+                              handleSegment((long)d, (long)(d + row));
+                          else
+                              fromSpin.setValue(d);
+                      }
                   }
+                     
                 }
                 catch (NumberFormatException nfe)
                 {
@@ -416,7 +484,11 @@
         	    handleSymbol(str);
         	}
         	catch (RuntimeException e){
-        	    fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));        	    
+        	    fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+        	    WarnDialog dialog = new WarnDialog(
+        		    " No Symbol \"" + str + "\" in current context");
+        	    dialog.showAll();
+        	    dialog.run();
         	}       
             }
           }
@@ -440,7 +512,13 @@
                   {
                     double d = (double) Long.parseLong(str, 16);
                     if (!(addressAccessible((long)d)))
-                        toBox.setText("0x" + Long.toHexString((long) lastKnownTo));
+                    {
+                	toBox.setText("0x" + Long.toHexString((long) lastKnownTo));
+                	WarnDialog dialog = new WarnDialog(
+                		" No function contains specified address");
+                	dialog.showAll();
+                	dialog.run();
+                    }
                     else 
                     {
                         if (d < lastKnownFrom) 
@@ -451,7 +529,12 @@
                         	toSpin.setValue(lastKnownFrom);
                         }
                         else
-                            toSpin.setValue(d);
+                        {
+                            if ((d > lastKnownTo) && (d - lastKnownTo > row))                            
+                        	handleSegment((long)(d - row), (long)d);
+                            else
+                        	toSpin.setValue(d);
+                        }
                     }
                   }
                   catch (NumberFormatException nfe)
@@ -466,7 +549,11 @@
           	    handleSymbol(str);
           	}
           	catch (RuntimeException e){
-          	    toBox.setText("0x" + Long.toHexString((long) lastKnownTo));        	    
+          	    toBox.setText("0x" + Long.toHexString((long) lastKnownTo));
+          	    WarnDialog dialog = new WarnDialog(
+          		    " No Symbol \"" + str + "\" in current context");
+          	    dialog.showAll();
+          	    dialog.run();
           	}       
               }
           }
@@ -495,8 +582,6 @@
     this.lastKnownFrom = pc_inc;
     this.toSpin.setRange(0.0, highestAddress);
     // this.toSpin.setValue((double) end);
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
     
     this.model.clear();
     this.model.appendRow();
@@ -580,7 +665,7 @@
   {
       for (int i=0; i< this.mmaps.length; i++)
 	  if (mmaps[i].addressLow <= address && address < mmaps[i].addressHigh)
-	      return true;
+	      return true;	  
       return false;
   }
 
@@ -589,8 +674,6 @@
     this.refreshLock = true;
     long pc_inc = 0;
     pc_inc = myTask.getIsa().pc(myTask);
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
     
     this.lastKnownFrom = pc_inc;
     this.fromSpin.setValue((double) pc_inc);
@@ -788,6 +871,7 @@
   private void desensitize ()
   {
     this.disassemblerView.setSensitive(false);
+    this.segmentCombo.setSensitive(false);
     this.fromSpin.setSensitive(false);
     this.toSpin.setSensitive(false);
     this.fromBox.setSensitive(false);
@@ -797,6 +881,7 @@
   private void resensitize ()
   {
     this.disassemblerView.setSensitive(true);
+    this.segmentCombo.setSensitive(true);
     this.fromSpin.setSensitive(true);
     this.toSpin.setSensitive(true);
     this.fromBox.setSensitive(true);
@@ -942,38 +1027,48 @@
       long startAddress = ((Long)addressList.getFirst()).longValue();
       Symbol symbol = SymbolFactory.getSymbol(this.myTask, startAddress);
       long endAddress = symbol.getAddress() + symbol.getSize();
-            
-      List instructionsList
-	= diss.disassembleInstructionsStartEnd((long)startAddress, (long)endAddress);
-      Iterator li = instructionsList.listIterator(0);
-      int insnum = 1;
-      Instruction ins = (Instruction)li.next();
-      this.lastKnownFrom = (double)ins.address;
-      while (li.hasNext()){
-	  ins = (Instruction)li.next();
-	  insnum++;
-      }
-      this.lastKnownTo = (double)ins.address;
-
-      TreeIter iter = this.model.getFirstIter();
-      while (insnum < numInstructions)
-      {
-	  this.model.removeRow(iter);
-	  this.lastPath.previous();
-	  numInstructions--;	  
-      }
-      while(insnum > numInstructions)
-      {
-	  this.model.appendRow();
-	  this.lastPath.next();
-	  numInstructions++;	  
-      }
-
-      refreshList();
-      fromBox.setText("0x" + Long.toHexString((long)lastKnownFrom));
-      fromSpin.setValue(lastKnownFrom);
+      handleSegment(startAddress, endAddress);      
+  }
+  
+  /**
+   * Display the whole segment
+   * @param startAddress
+   * @param endAddress
+   */
+  private synchronized void handleSegment(long startAddress, long endAddress)
+  {
+      	List instructionsList
+    	= diss.disassembleInstructionsStartEnd((long)startAddress, (long)endAddress);
+        Iterator li = instructionsList.listIterator(0);
+        int insnum = 1;
+        Instruction ins = (Instruction)li.next();
+        this.lastKnownFrom = (double)ins.address;
+        while (li.hasNext()){
+    	  ins = (Instruction)li.next();
+    	  insnum++;
+        }
+        this.lastKnownTo = (double)ins.address;
+    
+        TreeIter iter = this.model.getFirstIter();
+        while (insnum < numInstructions)
+        {
+    	  this.model.removeRow(iter);
+    	  this.lastPath.previous();
+    	  numInstructions--;	  
+        }
+        while(insnum > numInstructions)
+        {
+    	  this.model.appendRow();
+    	  this.lastPath.next();
+    	  numInstructions++;	  
+        }
+    
+        refreshList();
+        fromBox.setText("0x" + Long.toHexString((long)lastKnownFrom));
+        fromSpin.setValue(lastKnownFrom);
   }
 
+
   /****************************************************************************
    * Save and Load
    ***************************************************************************/
Index: gladedir/disassemblywindow.glade
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/gladedir/disassemblywindow.glade,v
retrieving revision 1.3
diff -u -r1.3 disassemblywindow.glade
--- gladedir/disassemblywindow.glade	15 Jun 2007 12:28:11 -0000	1.3
+++ gladedir/disassemblywindow.glade	29 Sep 2007 08:34:42 -0000
@@ -179,7 +179,7 @@
 	  <child>
 	    <widget class="GtkLabel" id="PCLabel">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Current program counter - </property>
+	      <property name="label" translatable="yes">Segment:</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -202,109 +202,38 @@
 	  </child>
 
 	  <child>
-	    <widget class="GtkHBox" id="hbox17">
+	    <widget class="GtkAlignment" id="alignment17">
 	      <property name="visible">True</property>
-	      <property name="homogeneous">False</property>
-	      <property name="spacing">0</property>
-
-	      <child>
-		<widget class="GtkLabel" id="PCHexLabel">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Hexadecimal: </property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">12</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkLabel" id="PCLabelHex">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes"></property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xscale">1</property>
+	      <property name="yscale">1</property>
+	      <property name="top_padding">0</property>
+	      <property name="bottom_padding">0</property>
+	      <property name="left_padding">0</property>
+	      <property name="right_padding">0</property>
 
 	      <child>
-		<widget class="GtkLabel" id="PCDecLabel">
+		<widget class="GtkAlignment" id="alignment18">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Decimal: </property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">12</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
+		  <property name="xalign">0</property>
+		  <property name="yalign">1</property>
+		  <property name="xscale">0.10000000149</property>
+		  <property name="yscale">0</property>
+		  <property name="top_padding">0</property>
+		  <property name="bottom_padding">0</property>
+		  <property name="left_padding">0</property>
+		  <property name="right_padding">0</property>
 
-	      <child>
-		<widget class="GtkLabel" id="PCLabelDec">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes"></property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
+		  <child>
+		    <widget class="GtkComboBox" id="segmentCombo">
+		      <property name="border_width">1</property>
+		      <property name="visible">True</property>
+		      <property name="add_tearoffs">False</property>
+		      <property name="focus_on_click">True</property>
+		    </widget>
+		  </child>
 		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
 	      </child>
 	    </widget>
 	    <packing>
@@ -777,4 +706,101 @@
   </child>
 </widget>
 
+<widget class="GtkWindow" id="Warning!">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Warning!</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+
+  <child>
+    <widget class="GtkVBox" id="vbox11">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child>
+	<widget class="GtkAlignment" id="alignment20">
+	  <property name="visible">True</property>
+	  <property name="xalign">0.5</property>
+	  <property name="yalign">0.5</property>
+	  <property name="xscale">0.5</property>
+	  <property name="yscale">0.5</property>
+	  <property name="top_padding">0</property>
+	  <property name="bottom_padding">0</property>
+	  <property name="left_padding">0</property>
+	  <property name="right_padding">0</property>
+
+	  <child>
+	    <widget class="GtkLabel" id="label21">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">No function contains specifed address.</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">False</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkAlignment" id="alignment19">
+	  <property name="visible">True</property>
+	  <property name="xalign">0.5</property>
+	  <property name="yalign">0.5</property>
+	  <property name="xscale">0</property>
+	  <property name="yscale">0</property>
+	  <property name="top_padding">0</property>
+	  <property name="bottom_padding">0</property>
+	  <property name="left_padding">0</property>
+	  <property name="right_padding">0</property>
+
+	  <child>
+	    <widget class="GtkButton" id="button1">
+	      <property name="width_request">69</property>
+	      <property name="height_request">38</property>
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="has_focus">True</property>
+	      <property name="label" translatable="yes">Close</property>
+	      <property name="use_underline">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
Index: gladedir/memorywindow.glade
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/gladedir/memorywindow.glade,v
retrieving revision 1.4
diff -u -r1.4 memorywindow.glade
--- gladedir/memorywindow.glade	26 Sep 2007 06:29:42 -0000	1.4
+++ gladedir/memorywindow.glade	29 Sep 2007 08:34:42 -0000
@@ -177,9 +177,9 @@
 	  <property name="spacing">0</property>
 
 	  <child>
-	    <widget class="GtkLabel" id="PCLabel">
+	    <widget class="GtkLabel" id="SegmentLabel">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Current program counter - </property>
+	      <property name="label" translatable="yes">Segment:</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -208,31 +208,6 @@
 	      <property name="spacing">0</property>
 
 	      <child>
-		<widget class="GtkLabel" id="PCHexLabel">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Hexadecimal: </property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">12</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
-		</widget>
-		<packing>
-		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
-		</packing>
-	      </child>
-
-	      <child>
 		<widget class="GtkLabel" id="PCLabelHex">
 		  <property name="visible">True</property>
 		  <property name="label" translatable="yes"></property>
@@ -258,27 +233,43 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkLabel" id="PCDecLabel">
+		<widget class="GtkHBox" id="hbox19">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Decimal: </property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">12</property>
-		  <property name="ypad">0</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">0</property>
+
+		  <child>
+		    <widget class="GtkAlignment" id="alignment17">
+		      <property name="visible">True</property>
+		      <property name="xalign">0</property>
+		      <property name="yalign">1</property>
+		      <property name="xscale">0.10000000149</property>
+		      <property name="yscale">0</property>
+		      <property name="top_padding">0</property>
+		      <property name="bottom_padding">0</property>
+		      <property name="left_padding">0</property>
+		      <property name="right_padding">0</property>
+
+		      <child>
+			<widget class="GtkComboBox" id="segmentCombo">
+			  <property name="border_width">1</property>
+			  <property name="visible">True</property>
+			  <property name="add_tearoffs">False</property>
+			  <property name="focus_on_click">True</property>
+			</widget>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">True</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="padding">0</property>
-		  <property name="expand">False</property>
-		  <property name="fill">False</property>
+		  <property name="expand">True</property>
+		  <property name="fill">True</property>
 		</packing>
 	      </child>
 
Index: memory/MemoryWindow.java
===================================================================
RCS file: /cvs/frysk/frysk-gui/frysk/gui/memory/MemoryWindow.java,v
retrieving revision 1.48
diff -u -r1.48 MemoryWindow.java
--- memory/MemoryWindow.java	26 Sep 2007 06:29:42 -0000	1.48
+++ memory/MemoryWindow.java	29 Sep 2007 08:34:43 -0000
@@ -60,7 +60,6 @@
 import org.gnu.gtk.DataColumnObject;
 import org.gnu.gtk.DataColumnString;
 import org.gnu.gtk.Entry;
-import org.gnu.gtk.Label;
 import org.gnu.gtk.ListStore;
 import org.gnu.gtk.SpinButton;
 import org.gnu.gtk.TreeIter;
@@ -80,6 +79,7 @@
 import org.gnu.gtk.event.SpinListener;
 
 import frysk.gui.common.IconManager;
+import frysk.gui.dialogs.WarnDialog;
 import frysk.gui.prefs.PreferenceManager;
 import frysk.gui.monitor.GuiObject;
 import frysk.gui.monitor.ObservableLinkedList;
@@ -159,9 +159,9 @@
 
   private SpinButton toSpin;
 
-  private Label pcLabelDec;
+  //private Label pcLabelDec;
 
-  private Label pcLabelHex;
+  //private Label pcLabelHex;
   
   private Entry fromBox;
   
@@ -169,6 +169,8 @@
 
   private SimpleComboBox bitsCombo;
 
+  private SimpleComboBox segmentCombo;
+  
   private GuiObject eight;
 
   private GuiObject sixteen;
@@ -178,6 +180,8 @@
   private GuiObject sixtyfour;
 
   private ObservableLinkedList bitsList;
+  
+  private ObservableLinkedList segmentList;
 
   private ListStore model;
 
@@ -200,6 +204,10 @@
   private boolean closed = false;
   
   private MemoryMap[] mmaps;
+  
+  private int segmentIndex = 0;
+  
+  private int row = 20;
 
   /**
    * The MemoryWindow displays the information stored at various locations in
@@ -221,12 +229,15 @@
     this.toSpin = (SpinButton) this.glade.getWidget("toSpin");
     this.fromBox = (Entry) this.glade.getWidget("fromBox");
     this.toBox = (Entry) this.glade.getWidget("toBox");
-    this.pcLabelDec = (Label) this.glade.getWidget("PCLabelDec");
-    this.pcLabelHex = (Label) this.glade.getWidget("PCLabelHex");
+    //this.pcLabelDec = (Label) this.glade.getWidget("PCLabelDec");
+    //this.pcLabelHex = (Label) this.glade.getWidget("PCLabelHex");
     this.bitsCombo = new SimpleComboBox(
                                         (this.glade.getWidget("bitsCombo")).getHandle());
+    this.segmentCombo = new SimpleComboBox(
+            (this.glade.getWidget("segmentCombo")).getHandle());
     this.model = new ListStore(cols);
     this.bitsList = new ObservableLinkedList();
+    this.segmentList = new ObservableLinkedList();
 
     this.setIcon(IconManager.windowIcon);
     this.lock = new LockObserver();
@@ -314,7 +325,7 @@
     
     this.diss = new Disassembler(myTask.getMemory());
     pc_inc = myTask.getIsa().pc(myTask);
-    long end = pc_inc + 20*8;
+    long end = pc_inc + row*8;
     this.setTitle(this.getTitle() + " - " + this.myTask.getProc().getCommand()
                   + " " + this.myTask.getName());
 
@@ -332,12 +343,29 @@
     this.bitsCombo.setSelectedObject((GuiObject) bitsList.get(currentFormat));
 
     this.bitsCombo.setActive(currentFormat + 1);
+    
+    for (int i = 0; i < this.mmaps.length; i++)
+    {
+	GuiObject segment = new GuiObject(Long.toHexString(mmaps[i].addressLow)
+		+ " - " + Long.toHexString(mmaps[i].addressHigh), "");
+	segmentList.add(i, segment);
+	if (mmaps[i].addressLow <= pc_inc && pc_inc < mmaps[i].addressHigh)
+	    this.segmentIndex = i;
+    }
+    
+    this.segmentCombo.watchLinkedList(segmentList);
+    
+    this.segmentCombo.setSelectedObject((GuiObject) segmentList.get(segmentIndex));
+
+    this.segmentCombo.setActive(segmentIndex + 1);
+    
 
     this.memoryView = (TreeView) this.glade.getWidget("memoryView");
     FontDescription fontDesc = new FontDescription("monospace 10");
     memoryView.setFont(fontDesc);
 
     this.bitsCombo.showAll();
+    this.segmentCombo.showAll();
     this.diss = new Disassembler(myTask.getMemory());
     this.fromSpin.setRange(0.0, highestAddress);
     this.fromSpin.setValue((double) pc_inc);
@@ -345,8 +373,8 @@
     this.toSpin.setValue((double) end);
     this.fromBox.setText("0x" + Long.toHexString(pc_inc));
     this.toBox.setText("0x" + Long.toHexString(end));
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
+    //this.pcLabelDec.setText("" + pc_inc);
+    //this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
 
     TreeViewColumn col = new TreeViewColumn();
     col.setTitle("Location");
@@ -435,6 +463,27 @@
           }
       }
     });
+    
+    segmentCombo.addListener(new ComboBoxListener()
+    {
+	public void comboBoxEvent (ComboBoxEvent arg0)
+	{
+	    if(arg0.isOfType(ComboBoxEvent.Type.CHANGED))
+	    {
+		if (segmentList.indexOf(segmentCombo.getSelectedObject()) == -1)
+		    return;
+		int temp = segmentList.indexOf(segmentCombo.getSelectedObject());
+		long startAddress = mmaps[temp].addressLow;
+		long endAddress = mmaps[temp].addressHigh;
+		if (endAddress - startAddress > row*8)
+		    handleSegment (startAddress, startAddress+20*8);
+		else
+		    handleSegment (startAddress, endAddress);
+		segmentIndex = temp;
+		recalculate();
+	    }
+	}
+    });
 
     ((Button) this.glade.getWidget("closeButton")).addListener(new ButtonListener()
     {
@@ -475,7 +524,14 @@
         	if (addressAccessible((long)value))
         	    handleFromSpin(value);
         	else
+        	{
         	    fromSpin.setValue(lastKnownFrom);
+        	    WarnDialog dialog = new WarnDialog(
+        		    "Cannot access memory at address 0x" + Long.toHexString((long)value));
+        	    dialog.showAll();
+        	    dialog.run();
+        	}
+
             }
         }
       }
@@ -498,7 +554,13 @@
         	if (addressAccessible((long)value))
         	    handleToSpin(value);
         	else
-        	    toSpin.setValue(lastKnownTo);      	
+        	{
+        	    toSpin.setValue(lastKnownTo);
+        	    WarnDialog dialog = new WarnDialog(
+        		    "Cannot access memory at address 0x" + Long.toHexString((long)value));
+        	    dialog.showAll();
+        	    dialog.run();
+        	}
             }
         } 
       }
@@ -521,7 +583,13 @@
                 {
                   double d = (double) Long.parseLong(str, 16);
                   if (!addressAccessible((long)d))
-            	  fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+                  {
+                      fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+          	      WarnDialog dialog = new WarnDialog(
+        		      "Cannot access memory at address 0x" + Long.toHexString((long)d));
+        	      dialog.showAll();
+        	      dialog.run();
+                  }
                   else
                   {
                       if (d > lastKnownTo)
@@ -532,7 +600,12 @@
                     	  fromSpin.setValue(lastKnownTo);
                       }
                       else
-                          fromSpin.setValue(d);
+                      {
+                          if ( (d < lastKnownFrom) && (lastKnownFrom - d > row*8))
+                              handleSegment((long)d, (long)(d + row*8));
+                          else
+                              fromSpin.setValue(d);                          
+                      }
                   }
                 }
                 catch (NumberFormatException nfe)
@@ -547,7 +620,11 @@
         	    handleSymbol(str);
         	}
         	catch (RuntimeException e){
-        	    fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));        	    
+        	    fromBox.setText("0x" + Long.toHexString((long) lastKnownFrom));
+        	    WarnDialog dialog = new WarnDialog(
+        		    " No Symbol \"" + str + "\" in current context");
+        	    dialog.showAll();
+        	    dialog.run();
         	}       
             }
           }
@@ -571,7 +648,13 @@
                   {
                     double d = (double) Long.parseLong(str, 16);
                     if (!(addressAccessible((long)d)))
+                    {
                         toBox.setText("0x" + Long.toHexString((long) lastKnownTo));
+                        WarnDialog dialog = new WarnDialog(
+          		      "Cannot access memory at address 0x" + Long.toHexString((long)d));
+          	      	dialog.showAll();
+          	      	dialog.run();
+                    }          	      	
                     else 
                     {
                         if (d < lastKnownFrom) 
@@ -582,7 +665,12 @@
                         	toSpin.setValue(lastKnownFrom);
                         }
                         else
-                            toSpin.setValue(d);
+                        {
+                            if ((d > lastKnownTo) && (d - lastKnownTo > row*8))                            
+                        	handleSegment((long)(d - row*8), (long)d);
+                            else
+                        	toSpin.setValue(d);
+                        }
                     }
                   }
                   catch (NumberFormatException nfe)
@@ -597,7 +685,11 @@
           	    handleSymbol(str);
           	}
           	catch (RuntimeException e){
-          	    toBox.setText("0x" + Long.toHexString((long) lastKnownTo));        	    
+          	    toBox.setText("0x" + Long.toHexString((long) lastKnownTo));
+        	    WarnDialog dialog = new WarnDialog(
+        		    " No Symbol \"" + str + "\" in current context");
+        	    dialog.showAll();
+        	    dialog.run();
           	}       
               }
           }
@@ -632,7 +724,7 @@
     this.diss = new Disassembler(myTask.getMemory());
 
     pc_inc = myTask.getIsa().pc(myTask);
-    long end = pc_inc + 20;
+    long end = pc_inc + row*8;
     this.setTitle(this.getTitle() + " - " + this.myTask.getProc().getCommand()
                   + " " + this.myTask.getName());
     this.model.clear();
@@ -640,8 +732,8 @@
     this.fromSpin.setValue((double) pc_inc);
     this.toSpin.setRange(0.0, highestAddress);
     this.toSpin.setValue((double) end);
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
+    //this.pcLabelDec.setText("" + pc_inc);
+    //this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
 
     recalculate();
     this.refreshLock = false;
@@ -677,8 +769,8 @@
     this.refreshLock = true;
     long pc_inc = 0;
     pc_inc = myTask.getIsa().pc(myTask);
-    this.pcLabelDec.setText("" + pc_inc);
-    this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
+    //this.pcLabelDec.setText("" + pc_inc);
+    //this.pcLabelHex.setText("0x" + Long.toHexString(pc_inc));
     
     long diff = (long) this.toSpin.getValue() - (long) this.fromSpin.getValue();
 
@@ -961,6 +1053,7 @@
   {
     this.memoryView.setSensitive(false);
     this.bitsCombo.setSensitive(false);
+    this.segmentCombo.setSensitive(false);
     this.fromSpin.setSensitive(false);
     this.toSpin.setSensitive(false);
     this.fromBox.setSensitive(false);
@@ -971,6 +1064,7 @@
   {
     this.memoryView.setSensitive(true);
     this.bitsCombo.setSensitive(true);
+    this.segmentCombo.setSensitive(true);
     this.fromSpin.setSensitive(true);
     this.toSpin.setSensitive(true);
     this.fromBox.setSensitive(true);
@@ -1124,36 +1218,46 @@
       long startAddress = ((Long)addressList.getFirst()).longValue();
       Symbol symbol = SymbolFactory.getSymbol(this.myTask, startAddress);
       long endAddress = symbol.getAddress() + symbol.getSize();
-      long size = (endAddress - startAddress)/8 + 1;
-      long modelSize = ((long)lastKnownTo - (long)lastKnownFrom)/8 + 1;
-      TreeIter iter = this.model.getFirstIter();      
-      while (size < modelSize)
-      {
+      handleSegment(startAddress, endAddress);
+  }
+  
+ /**
+  * Display the whole segment
+  * @param startAddress
+  * @param endAddress
+  */
+ private synchronized void handleSegment(long startAddress, long endAddress)
+ {
+     long size = (endAddress - startAddress)/8 + 1;
+     long modelSize = ((long)lastKnownTo - (long)lastKnownFrom)/8 + 1;
+     TreeIter iter = this.model.getFirstIter();      
+     while (size < modelSize)
+     {
 	  this.model.removeRow(iter);
 	  this.lastPath.previous();
 	  modelSize--;	  
-      }
-      while(size > modelSize)
-      {
+     }
+     while(size > modelSize)
+     {
 	  this.model.appendRow();
 	  this.lastPath.next();
 	  modelSize++;	  
-      }
-      this.lastKnownFrom = (double)startAddress;
-      this.lastKnownTo = (double)(double)(startAddress+(long)(endAddress-startAddress)/8*8);
-      iter = this.model.getFirstIter();
-      this.lastPath = iter.getPath();
-      for(int i = 0; i <= lastKnownTo-lastKnownFrom; i=i+8)
-      {
+     }
+     this.lastKnownFrom = (double)startAddress;
+     this.lastKnownTo = (double)(double)(startAddress+(long)(endAddress-startAddress)/8*8);
+     iter = this.model.getFirstIter();
+     this.lastPath = iter.getPath();
+     for(int i = 0; i <= lastKnownTo-lastKnownFrom; i=i+8)
+     {
 	  rowAppend((long)(i+startAddress), iter);
 	  iter = iter.getNextIter();
-      }
-      refreshList();
-      fromBox.setText("0x" + Long.toHexString((long)lastKnownFrom));
-      fromSpin.setValue(lastKnownFrom);
-      toBox.setText("0x" + Long.toHexString((long)lastKnownTo));
-      toSpin.setValue(lastKnownTo);
-  }
+     }
+     refreshList();
+     fromBox.setText("0x" + Long.toHexString((long)lastKnownFrom));
+     fromSpin.setValue(lastKnownFrom);
+     toBox.setText("0x" + Long.toHexString((long)lastKnownTo));
+     toSpin.setValue(lastKnownTo);
+ }
 
   /****************************************************************************
    * Save and Load

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-30  1:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-30  1:10 [patch] Fix bug 4614, 4619 and 4870 Zhao Shujing

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).