public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: rmoseley@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Add "load" command to UI.
Date: Mon, 23 Jun 2008 21:38:00 -0000	[thread overview]
Message-ID: <20080623213847.32178.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  f9e790bb9dea8d3d188cbcc995bc7fed8d42ff0e (commit)
      from  5539327049ca4af57908f6bd0e90196a20378395 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit f9e790bb9dea8d3d188cbcc995bc7fed8d42ff0e
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Mon Jun 23 16:35:31 2008 -0500

    Add "load" command to UI.
    
    * SourceBuffer.java: Call getEntryPoint to get address.
    * SourceWindow.java: Add "load" capability.
    * SourceWindowFactory.java: Add loadExecutable method.
    * DynamicSegment.java: Make getEntryPoint public.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/solib/ChangeLog                   |    5 +
 frysk-core/frysk/solib/DynamicSegment.java         |    4 +-
 frysk-gui/frysk/gui/srcwin/ChangeLog               |    6 +
 frysk-gui/frysk/gui/srcwin/SourceBuffer.java       |   10 ++
 frysk-gui/frysk/gui/srcwin/SourceWindow.java       |  139 +++++++++++++++++---
 .../frysk/gui/srcwin/SourceWindowFactory.java      |   33 ++++--
 6 files changed, 167 insertions(+), 30 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/solib/ChangeLog b/frysk-core/frysk/solib/ChangeLog
index c1f7205..529a5a1 100644
--- a/frysk-core/frysk/solib/ChangeLog
+++ b/frysk-core/frysk/solib/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-23  Rick Moseley  <rmoseley@redhat.com>
+
+	* DynamicSegment.java: Made getEntryPoint public.
+
+
 2008-03-10  Andrew Cagney  <cagney@redhat.com>
 
 	* MemoryMapFactory.java: Update to match MemoryMap.
diff --git a/frysk-core/frysk/solib/DynamicSegment.java b/frysk-core/frysk/solib/DynamicSegment.java
index e773894..d9a98c5 100644
--- a/frysk-core/frysk/solib/DynamicSegment.java
+++ b/frysk-core/frysk/solib/DynamicSegment.java
@@ -51,7 +51,7 @@ import frysk.proc.Auxv;
  * to extract the information are all closed.
  */
 
-class DynamicSegment {
+public class DynamicSegment {
     private static final Log fine = Log.fine(DynamicSegment.class);
 
     final long addr;
@@ -99,7 +99,7 @@ class DynamicSegment {
      * Helper function to locate and report the backing Executables
      * entry point
      */
-    private static long getEntryPoint(Elf exeElf) {
+    public static long getEntryPoint(Elf exeElf) {
 	fine.log("getEntryPoint", exeElf);
 	ElfEHeader eHeader = exeElf.getEHeader();
 	if (eHeader == null)
diff --git a/frysk-gui/frysk/gui/srcwin/ChangeLog b/frysk-gui/frysk/gui/srcwin/ChangeLog
index 1c0eb0d..fe5f98f 100644
--- a/frysk-gui/frysk/gui/srcwin/ChangeLog
+++ b/frysk-gui/frysk/gui/srcwin/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-23  Rick Moseley  <rmoseley@redhat.com>
+
+	* SourceBuffer.java: Call getEntryPoint to get address.
+	* SourceWindow.java: Add "load" capability.
+	* SourceWindowFactory.java: Add loadExecutable method.
+
 2008-06-10  Andrew Cagney  <cagney@redhat.com>
 
 	* CurrentStackView.java (STACK_OPTIONS): New.  Pass to
diff --git a/frysk-gui/frysk/gui/srcwin/SourceBuffer.java b/frysk-gui/frysk/gui/srcwin/SourceBuffer.java
index 0957b49..5950415 100644
--- a/frysk-gui/frysk/gui/srcwin/SourceBuffer.java
+++ b/frysk-gui/frysk/gui/srcwin/SourceBuffer.java
@@ -50,6 +50,8 @@ import java.util.List;
 
 import lib.dwfl.Disassembler;
 import lib.dwfl.Instruction;
+import lib.dwfl.Elf;
+import lib.dwfl.ElfCommand;
 
 import org.gnu.gdk.Color;
 import org.gnu.glib.JGException;
@@ -80,6 +82,7 @@ import frysk.gui.srcwin.prefs.SyntaxPreference.SyntaxPreferenceListener;
 import frysk.proc.Task;
 import frysk.rt.LineXXX;
 import frysk.scopes.SourceLocation;
+import frysk.solib.DynamicSegment;
 import frysk.value.Value;
 
 /**
@@ -850,10 +853,17 @@ public class SourceBuffer extends TextBuffer {
                                              task.getMemory());
 
 	long address = frame.getAddress();
+	// If the address is 0, use the entry point as the address to disassemble
+	if (address == 0) {
+	    Elf elf = new Elf(task.getProc().getExeFile().getFile(), 
+		    ElfCommand.ELF_C_READ);
+	    address = DynamicSegment.getEntryPoint(elf);
+	}
 
 	this.deleteText(this.getStartIter(), this.getEndIter());
 
 	List instructionsList = diss.disassembleInstructions(address, 40);
+
 	Iterator iter = instructionsList.iterator();
 
 	while (iter.hasNext()) {
diff --git a/frysk-gui/frysk/gui/srcwin/SourceWindow.java b/frysk-gui/frysk/gui/srcwin/SourceWindow.java
index dfc8124..06a7a9e 100644
--- a/frysk-gui/frysk/gui/srcwin/SourceWindow.java
+++ b/frysk-gui/frysk/gui/srcwin/SourceWindow.java
@@ -167,6 +167,8 @@ public class SourceWindow extends Window {
     private Action close;
 
     private Action open_core;
+    
+    private Action open_load;
 
     private Action open_executable;
 
@@ -580,7 +582,7 @@ public class SourceWindow extends Window {
     /**
          * Populates the stack browser window
          * 
-         * @param frames An array of DebugInfoFrames used to popuate information
+         * @param frames An array of DebugInfoFrames used to populate information
          * inside the stack frame window.
          */
     public void populateStackBrowser(DebugInfoFrame[][] frames) {
@@ -886,7 +888,8 @@ public class SourceWindow extends Window {
 	Proc[] newSwProc = new Proc[numProcs];
 
 	DOMFactory.clearDOMSourceMap(this.swProc[this.current]);
-	this.steppingEngine.detachProc(this.swProc[this.current], kill);
+	if (this.swProc[this.current].getPid() != 0)
+	    this.steppingEngine.detachProc(this.swProc[this.current], kill);
 
 	int j = 0;
 	for (int i = 0; i < oldSize; i++) {
@@ -916,7 +919,7 @@ public class SourceWindow extends Window {
     /***********************************************************************
          * Getters and Setters
          **********************************************************************/
-
+    
     public Proc getSwProc() {
 	if (this.swProc.length > 0)
 	    return this.swProc[this.current];
@@ -986,7 +989,7 @@ public class SourceWindow extends Window {
 	this.open_core = new Action("open", "Examine core file...",
 		"Examine core file", GtkStockItem.OPEN.getString());
 	this.open_core.setAccelGroup(ag);
-	this.open_core.setAccelPath("<sourceWin>/File/Examine core file...");
+	this.open_core.setAccelPath("<sourceWin>/Processes/Examine core file...");
 	this.open_core.addListener(new org.gnu.gtk.event.ActionListener() {
 	    public void actionEvent(ActionEvent action) {
 		// SourceWindow.this.glade.getWidget(SOURCE_WINDOW).destroy();
@@ -1023,7 +1026,7 @@ public class SourceWindow extends Window {
                         // to
 		    // select a file name
 		    public void fileActivated(FileChooserEvent event) {
-			examineCoreFile(chooser.getFilename());
+			examineCoreFile();
 		    }
 		});
 		setDefaultIcon(IconManager.windowIcon);
@@ -1036,15 +1039,84 @@ public class SourceWindow extends Window {
 		// The OK button was clicked, go open a source window for this
                 // core file
 		else if (response == ResponseType.OK.getValue()) {
-		    examineCoreFile(chooser.getFilename());
+		    examineCoreFile();
 		    chooser.destroy();
 		}
 	    }
 	});
-	AccelMap.changeEntry("<sourceWin>/File/Examine core file...",
+	AccelMap.changeEntry("<sourceWin>/Processes/Examine core file...",
 		KeyValue.o, ModifierType.CONTROL_MASK, true);
 	this.open_core.connectAccelerator();
+	
+	// Load executable action
+	this.open_load = new Action("Load an executable",
+		"Load a process...", "Load a process from a file",
+		GtkStockItem.OPEN.getString());
+	this.open_load.setAccelGroup(ag);
+	this.open_load
+		.setAccelPath("<sourceWin>/Processes/Load a process...");
+	this.open_load.addListener(new ActionListener() {
+	    public void actionEvent(ActionEvent action) {
+		try {
+		    glade_fc = new LibGlade(Prefix.gladeFile(FILECHOOSER_GLADE).getAbsolutePath(), null);
+		    fc = (FileChooserDialog) glade_fc
+			    .getWidget("frysk_filechooserdialog");
+		    fc.addListener(new LifeCycleListener() {
+			public void lifeCycleEvent(LifeCycleEvent event) {
+			}
+
+			public boolean lifeCycleQuery(LifeCycleEvent event) {
+			    if (event.isOfType(LifeCycleEvent.Type.DELETE)
+				    || event
+					    .isOfType(LifeCycleEvent.Type.DESTROY))
+				fc.destroy();
+			    return false;
+			}
+		    });
 
+		    fc.addListener(new FileChooserListener() {
+			public void currentFolderChanged(FileChooserEvent event) {
+			}
+
+			public void selectionChanged(FileChooserEvent event) {
+			}
+
+			public void updatePreview(FileChooserEvent event) {
+			}
+
+			// This method is called when the "Enter" key is pressed
+                        // to
+			// select a file name in the chooser
+			public void fileActivated(FileChooserEvent event) {
+			    loadExecutableFile();
+			}
+		    });
+		    fc.setIcon(IconManager.windowIcon);
+		    fc.setDefaultResponse(FileChooserEvent.Type.FILE_ACTIVATED
+			    .getID());
+		    fc.setCurrentFolder(System.getProperty("user.home"));
+		    CheckButton term_activate = (CheckButton) glade_fc
+			.getWidget("term_activate");
+		    term_activate.setSensitive(false);
+		    gtk_widget_set_size_request(fc.getHandle(), 300, 600);
+		    int response = fc.open();
+		    // "OK" key has been clicked
+		    if (response == ResponseType.OK.getValue())
+			loadExecutableFile();
+		    // "Cancel" key has been clicked
+		    if (response == ResponseType.CANCEL.getValue())
+			fc.destroy();
+		} catch (Exception e) {
+		    throw new RuntimeException(e);
+		}
+	    }
+	});
+	
+	AccelMap.changeEntry("<sourceWin>/Processes/Load executable file...",
+		KeyValue.l, ModifierType.CONTROL_MASK, true);
+	this.open_load.connectAccelerator();
+
+	
 	// Close action
 	this.close = new Action("close", "Close", "Close Window",
 		GtkStockItem.CLOSE.getString());
@@ -1345,9 +1417,11 @@ public class SourceWindow extends Window {
 		    fc.setDefaultResponse(FileChooserEvent.Type.FILE_ACTIVATED
 			    .getID());
 		    fc.setCurrentFolder(System.getProperty("user.home"));
-		    gtk_widget_set_size_request(fc.getHandle(), 300, 300);
+		    CheckButton term_activate = (CheckButton) glade_fc
+			.getWidget("term_activate");
+		    term_activate.setSensitive(false);
+		    gtk_widget_set_size_request(fc.getHandle(), 300, 1000);
 		    int response = fc.open();
-		    gtk_widget_set_size_request(fc.getHandle(), 300, 300);
 		    // "OK" key has been clicked
 		    if (response == ResponseType.OK.getValue())
 			activateProc();
@@ -1570,17 +1644,41 @@ public class SourceWindow extends Window {
     }
 
     /**
-         * This method will activate a window to allow the user to exemaine a
+         * This method will activate a window to allow the user to examine a
          * core file
          * 
          * @param filename -
          *                String containing the path to the core file
          * 
          */
-    private void examineCoreFile(String filename) {
+    private void examineCoreFile() {
+	Entry task_options = (Entry) glade_fc.getWidget("task_options");
+	String task_opt = task_options.getText();
+	String filename = fc.getFilename();
+	fc.destroy();
+	String[] stds = { "/dev/null", "/dev/null", "/dev/null" };
+	addProc(filename, "", task_opt, stds[0], stds[1], stds[2]);
 	SourceWindowFactory.attachToCore(new File(filename));
-	this.destroy();
     }
+    
+    /**
+     * This method will activate a window to allow the user to load an
+     * executable file
+     * 
+     * @param filename -
+     *                String containing the path to the executable file
+     * 
+     */
+    private void loadExecutableFile() {
+	Entry task_options = (Entry) glade_fc.getWidget("task_options");
+	String task_opt = task_options.getText();
+	String filename = fc.getFilename();
+	fc.destroy();
+	String[] stds = { "/dev/null", "/dev/null", "/dev/null" };
+	addProc(filename, "", task_opt, stds[0], stds[1], stds[2]);
+	SourceWindowFactory.loadExecutable(new File(filename), null);
+	//this.destroy();
+}
 
     /**
          * Creates the toolbar menus with initialized Actions.
@@ -1589,11 +1687,14 @@ public class SourceWindow extends Window {
 	// File menu
 	MenuItem menu = new MenuItem("File", true);
 
-	// MenuItem mi = (MenuItem) this.open_core.createMenuItem();
+	/* MenuItem mi = (MenuItem) this.open_core.createMenuItem();
+	Menu tmp = new Menu();
+	tmp.append(mi);
+	mi = (MenuItem) this.open_load.createMenuItem();
+	tmp.append(mi);
+	mi = new MenuItem(); // Separator
+	tmp.append(mi); */
 	Menu tmp = new Menu();
-	// tmp.append(mi);
-	// mi = new MenuItem(); // Separator
-	// tmp.append(mi);
 	MenuItem mi = (MenuItem) this.close.createMenuItem();
 	tmp.append(mi);
 
@@ -1686,14 +1787,16 @@ public class SourceWindow extends Window {
 
 	menu = new MenuItem("Processes", false);
 	tmp = new Menu();
-	mi = (MenuItem) this.open_executable.createMenuItem();
+	mi = (MenuItem) this.attach_proc.createMenuItem();
 	tmp.append(mi);
 	mi = new MenuItem(); // Separator
 	tmp.append(mi);
-	mi = (MenuItem) this.attach_proc.createMenuItem();
+	mi = (MenuItem) this.open_executable.createMenuItem();
 	tmp.append(mi);
 	mi = (MenuItem) this.open_core.createMenuItem();
 	tmp.append(mi);
+	mi = (MenuItem) this.open_load.createMenuItem();
+	tmp.append(mi);
 
 	menu.setSubmenu(tmp);
 	((MenuBar) this.glade.getWidget("menubar")).append(menu);
diff --git a/frysk-gui/frysk/gui/srcwin/SourceWindowFactory.java b/frysk-gui/frysk/gui/srcwin/SourceWindowFactory.java
index e662bb7..652ee6c 100644
--- a/frysk-gui/frysk/gui/srcwin/SourceWindowFactory.java
+++ b/frysk-gui/frysk/gui/srcwin/SourceWindowFactory.java
@@ -51,6 +51,7 @@ import org.gnu.gtk.event.LifeCycleListener;
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
 import frysk.proc.dead.LinuxCoreFactory;
+import frysk.proc.dead.LinuxExeFactory;
 import frysk.config.Prefix;
 import frysk.proc.TaskAttachedObserverXXX;
 import frysk.debuginfo.DebugInfoFrame;
@@ -140,16 +141,28 @@ public class SourceWindowFactory
     public static void attachToCore(File coreFile) {
 	Proc proc = LinuxCoreFactory.createProc(coreFile);
 
-    LinkedList tasks = proc.getTasks();
-    DebugInfoFrame[] framez = new DebugInfoFrame[tasks.size()];
-    Iterator iter = tasks.iterator();
-    for (int i = 0; iter.hasNext(); i++)
-      {
-        Task task = (Task) iter.next();
-        framez[i] = DebugInfoStackFactory.createDebugInfoStackTrace(task);
-      }
-    createSourceWindow(framez);
-  }
+	LinkedList tasks = proc.getTasks();
+	DebugInfoFrame[] framez = new DebugInfoFrame[tasks.size()];
+	Iterator iter = tasks.iterator();
+	for (int i = 0; iter.hasNext(); i++) {
+	    Task task = (Task) iter.next();
+	    framez[i] = DebugInfoStackFactory.createDebugInfoStackTrace(task);
+	}
+	createSourceWindow(framez);
+    }
+    
+    public static void loadExecutable(File exeFile, String[] args) {
+	Proc proc = LinuxExeFactory.createProc(exeFile, args);
+
+	LinkedList tasks = proc.getTasks();
+	DebugInfoFrame[] framez = new DebugInfoFrame[tasks.size()];
+	Iterator iter = tasks.iterator();
+	for (int i = 0; iter.hasNext(); i++) {
+	    Task task = (Task) iter.next();
+	    framez[i] = DebugInfoStackFactory.createDebugInfoStackTrace(task);
+	}
+	createSourceWindow(framez);
+    }
   
   public static AttachedObserver startNewProc(String file, String env_variables, String options,
                                                String stdin, String stdout, String stderr)


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-06-23 21:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080623213847.32178.qmail@sourceware.org \
    --to=rmoseley@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).