public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Make auxv lookup entry point symbol. Discover auxv platform.
@ 2008-01-09 21:53 pmuldoon
  0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2008-01-09 21:53 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  5b38679c56e39b2360489f692fa78e5469c7a3c1 (commit)
      from  b1e11cbeca590477dd14037e646309ec17ccd8a3 (commit)

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

- Log -----------------------------------------------------------------
commit 5b38679c56e39b2360489f692fa78e5469c7a3c1
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Wed Jan 9 21:52:51 2008 +0000

    Make auxv lookup entry point symbol. Discover auxv platform.
    Rewrite fauxv to block processes. Fix Map/Auxv Command to
    print out multiple sets. Delete Info help command.
    
    2008-01-09  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* fauxv.java (parsePids): Pass in proc object.
    	(parseCores): Ditto.
    	(printAuxv): Take proc. Use it to look up symbol.
    	(PrintAuxvEvent): New.
    	(RichAuxvDump): New.
    
    2008-01-09  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* TestAuxvCommand.java (testAuxVCoreCommand): Pass in proc to
    	BuildAuxv.
    	* MapsCommand.java (interpret): With with multiple processes,
    	over multipe sets.
    	* AuxvCommand.java (interpret): Work with multiple processes,
    	over multipe sets.
    	* InfoCommand.java (Help): Delete internal help
    	command.
    
    2008-01-09  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* AuxvStringBuilder.java (construct): Find symbol for
    	AT_ENTRY. Find string in memory for AT_PLATFORM.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog            |    8 ++
 frysk-core/frysk/bindir/fauxv.java           |  151 +++++++++++++++++---------
 frysk-core/frysk/hpd/AuxvCommand.java        |   73 +++++++++----
 frysk-core/frysk/hpd/ChangeLog               |   11 ++
 frysk-core/frysk/hpd/InfoCommand.java        |   22 ----
 frysk-core/frysk/hpd/MapsCommand.java        |   44 ++++++--
 frysk-core/frysk/hpd/TestAuxvCommand.java    |    2 +-
 frysk-core/frysk/util/AuxvStringBuilder.java |   60 ++++++++--
 frysk-core/frysk/util/ChangeLog              |    5 +
 9 files changed, 257 insertions(+), 119 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 6bda106..40b172f 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-09  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* fauxv.java (parsePids): Pass in proc object.
+	(parseCores): Ditto.
+	(printAuxv): Take proc. Use it to look up symbol.
+	(PrintAuxvEvent): New.
+	(RichAuxvDump): New.
+
 2008-01-07  Andrew Cagney  <cagney@redhat.com>
 
 	* fstep.java: Update; use Host.requestProc(ProcId,FindProc).
diff --git a/frysk-core/frysk/bindir/fauxv.java b/frysk-core/frysk/bindir/fauxv.java
index 8930bb0..d00944f 100644
--- a/frysk-core/frysk/bindir/fauxv.java
+++ b/frysk-core/frysk/bindir/fauxv.java
@@ -39,72 +39,123 @@
 
 package frysk.bindir;
 
-import frysk.util.CommandlineParser;
-import frysk.util.Util;
-import frysk.util.AuxvStringBuilder;
+import java.io.File;
+
+import frysk.event.Event;
+import frysk.proc.Manager;
 import frysk.proc.Proc;
+import frysk.proc.ProcBlockAction;
 import frysk.proc.ProcId;
-import frysk.proc.Auxv;
-import java.io.File;
+import frysk.proc.ProcObserver;
+import frysk.proc.Task;
+import frysk.util.AuxvStringBuilder;
+import frysk.util.CommandlineParser;
 import frysk.util.CoreExePair;
+import frysk.util.Util;
 
 public class fauxv {
-    
+
+    static Proc proc = null;
+
     public static void main (String[] args) {
 	// Parse command line. Check pid provided.
-	
+
 	CommandlineParser parser = new CommandlineParser("fauxv") {
-		
-		public void parseCores (CoreExePair[] corePairs) {
-		    for (int i = 0; i < corePairs.length; i++) {
-			File coreFile = corePairs[i].coreFile;
-			File exeFile = corePairs[i].exeFile;
-			Proc proc;
-			
-			if (exeFile == null)
-			    proc = Util.getProcFromCoreFile(coreFile);
-			else
-			    proc = Util.getProcFromCoreFile(coreFile, exeFile);
-			printAuxv(proc.getAuxv());
-		    }
-		    
+
+	    public void parseCores (CoreExePair[] corePairs) {
+		for (int i = 0; i < corePairs.length; i++) {
+		    File coreFile = corePairs[i].coreFile;
+		    File exeFile = corePairs[i].exeFile;
+		    if (exeFile == null)
+			proc = Util.getProcFromCoreFile(coreFile);
+		    else
+			proc = Util.getProcFromCoreFile(coreFile, exeFile);
+		    PrintAuxvEvent auxvPrint = new PrintAuxvEvent(proc);
+		    auxvPrint.execute();
 		    System.exit(0);
 		}
-		
-		public void parsePids (ProcId[] pids) {
-		    for (int i= 0; i< pids.length; i++) {
-			ProcId id = pids[i];
-			Proc proc = Util.getProcFromPid(id);
-			printAuxv(proc.getAuxv());
-		    }
+	    }
+
+	    public void parsePids (ProcId[] pids) {
+		for (int i= 0; i< pids.length; i++) {
+		    ProcId id = pids[i];
+		    proc = Util.getProcFromPid(id);
+		    new ProcBlockAction(proc, new RichAuxvDump(proc));
+		    Manager.eventLoop.run();
 		    System.exit(0);
 		}
-		
-		private void printAuxv(Auxv[] auxv)
-		{
-		    
-		    class BuildAuxv extends AuxvStringBuilder {
-			
-			public StringBuffer auxvData = new StringBuffer();
-			public void buildLine(String type, String desc, String value) {
-			    auxvData.append(type+" (" + desc+") : " + value+"\n");
-			}
-		    }
-		    
-		    BuildAuxv buildAuxv = new BuildAuxv();
-		    buildAuxv.construct(auxv);
-		    
-		    System.out.println(buildAuxv.auxvData.toString());
-		}
-		
-	    };
-	
-	parser.setHeader("Usage: fauxv <PID>  || fmaps <COREFILE> [<EXEFILE>]");
+	    }
+
+
+	};
+
+
+	parser.setHeader("Usage: fauxv <PID>  || fauxv <COREFILE> [<EXEFILE>]");
 	parser.parse(args);
-	
+
 	//If we got here, we didn't find a pid.
 	System.err.println("Error: No PID or COREFILE.");
 	parser.printHelp();
 	System.exit(1);
+    }   
+
+    private static class PrintAuxvEvent implements Event
+    {
+
+	private Proc proc = null;
+	public PrintAuxvEvent(Proc proc)
+	{
+	    this.proc = proc;
+	}
+	public void execute() {
+	    class BuildAuxv extends AuxvStringBuilder {
+
+		public StringBuffer auxvData = new StringBuffer();
+		public void buildLine(String type, String desc, String value) {
+		    auxvData.append(type+" (" + desc+") : " + value+"\n");
+		}
+	    }	
+
+	    BuildAuxv buildAuxv = new BuildAuxv();
+	    buildAuxv.construct(proc.getAuxv(), proc);
+
+	    System.out.print(buildAuxv.auxvData.toString());
+
+	    System.exit(0);
+	}
+
+
+    }
+
+
+
+    private static class RichAuxvDump implements ProcObserver.ProcAction {
+
+	private Proc proc;
+
+
+	public RichAuxvDump(Proc proc)
+	{
+	    this.proc = proc;
+	}
+
+	public void allExistingTasksCompleted() {
+	    Manager.eventLoop.add(new PrintAuxvEvent(this.proc));
+	}
+
+	public void taskAddFailed(Object task, Throwable w) {
+	}
+
+	public void existingTask(Task task) {
+	}
+
+	public void addFailed(Object observable, Throwable w) {
+	}
+
+	public void addedTo(Object observable) {
+	}
+
+	public void deletedFrom(Object observable) {
+	}
     }
 }
diff --git a/frysk-core/frysk/hpd/AuxvCommand.java b/frysk-core/frysk/hpd/AuxvCommand.java
index 5f59145..5d03b04 100644
--- a/frysk-core/frysk/hpd/AuxvCommand.java
+++ b/frysk-core/frysk/hpd/AuxvCommand.java
@@ -39,8 +39,10 @@
 
 package frysk.hpd;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+
 import frysk.proc.Auxv;
 import frysk.proc.Proc;
 import frysk.util.AuxvStringBuilder;
@@ -63,39 +65,62 @@ public class AuxvCommand extends ParameterizedCommand {
   }
   
   void interpret(CLI cli, Input cmd, Object options) {
+    
+    int processCount = 0;
+    HashMap procList = new HashMap();
     PTSet ptset = cli.getCommandPTSet(cmd);
     Iterator taskDataIterator = ptset.getTaskData();
+
     if (taskDataIterator.hasNext() == false) {
-      cli.addMessage("Cannot find main task. Cannot print out auxv", Message.TYPE_ERROR);
-      return;
+	cli.addMessage("Cannot find main task. Cannot print out auxv", 
+			Message.TYPE_ERROR);
+	return;
     }
-    Proc mainProc = ((TaskData) taskDataIterator.next()).getTask().getProc();
-    Auxv[] liveAux = mainProc.getAuxv();
 
-    if (liveAux == null) {
-	cli.addMessage("No Auxv data to print for this process",
-		       Message.TYPE_WARNING);
-	
-	return;
+    
+    while (taskDataIterator.hasNext()) {
+	Proc proc = ((TaskData) taskDataIterator.next()).getTask().getProc();
+	if (!procList.containsValue(proc)) {
+	    procList.put(proc,proc);
+	    processCount++;
+	}
     }
-    class BuildAuxv extends AuxvStringBuilder {
-      
-      public StringBuffer auxvData = new StringBuffer();
-      public void buildLine(String type, String desc, String value) {
-	if (verbose)
-	  auxvData.append(type+" (" + desc+") : " + value+"\n");
-	else
-	  auxvData.append(type+" : " + value+"\n");	
-      }
+
+    Iterator procIterator = procList.values().iterator();
+
+    while (procIterator.hasNext()) {
+	Proc mainProc = ((Proc)procIterator.next());
+	
+	Auxv[] liveAux = mainProc.getAuxv();
+	
+	if (liveAux == null) {
+	    cli.addMessage("No Auxv data to print for this process",
+		    Message.TYPE_WARNING);
+
+	    continue;
+	}
+	
+	class BuildAuxv extends AuxvStringBuilder {
+
+	    public StringBuffer auxvData = new StringBuffer();
+	    public void buildLine(String type, String desc, String value) {
+		if (verbose)
+		    auxvData.append(type+" (" + desc+") : " + value+"\n");
+		else		    
+		    auxvData.append(type+" : " + value+"\n");	
+	    }
+	}
+
+	BuildAuxv buildAuxv = new BuildAuxv();
+	buildAuxv.construct(liveAux, mainProc);
+	if (processCount > 1)
+	    cli.outWriter.println("For process: " + mainProc.getPid()+"\n");
+	cli.outWriter.print(buildAuxv.auxvData.toString());
     }
-    
-    BuildAuxv buildAuxv = new BuildAuxv();
-    buildAuxv.construct(liveAux);
-    
-    cli.outWriter.println(buildAuxv.auxvData.toString());
   }
   
-  int completer(CLI cli, Input input, int cursor, List completions) {
+
+int completer(CLI cli, Input input, int cursor, List completions) {
     return -1;
   }  
 }
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index d00e10f..7379999 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,14 @@
+2008-01-09  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* TestAuxvCommand.java (testAuxVCoreCommand): Pass in proc to
+	BuildAuxv.
+	* MapsCommand.java (interpret): With with multiple processes,
+	over multipe sets.
+	* AuxvCommand.java (interpret): Work with multiple processes,
+	over multipe sets.
+	* InfoCommand.java (Help): Delete internal help
+	command.
+
 2008-01-08  Andrew Cagney  <cagney@redhat.com>
 
 	* CoreCommand.java (getProc(LinuxCoreHost)): Delete; use
diff --git a/frysk-core/frysk/hpd/InfoCommand.java b/frysk-core/frysk/hpd/InfoCommand.java
index d8529cd..df3b083 100644
--- a/frysk-core/frysk/hpd/InfoCommand.java
+++ b/frysk-core/frysk/hpd/InfoCommand.java
@@ -38,36 +38,14 @@
 // exception.
 package frysk.hpd;
 
-import java.util.List;
 
 public class InfoCommand extends MultiLevelCommand {
     
-    private class Help extends Command {
-    	Help() {
-    	    super("Display this help message.", "help [command]",
-    		  "Display help (possibly for a command.)");
-    	}
-    	
-    	public void interpret(CLI cli, Input cmd) {
-    	    InfoCommand.this.help(cli, cmd);
-    	}
-    	
-    	/**
-    	 * Complete the line, throw problem back at the top level
-    	 * command.
-    	 */
-    	int complete(CLI cli, Input buffer, int cursor, List candidates) {
-    	    return InfoCommand.this.complete(cli, buffer, cursor,
-					     candidates);
-    	}
-    }
-    
     
     InfoCommand() {
 	super("info command", "info <subcommand>", 
 	      "The info command displays useful information about " +
 	      "various system and process level systems.");
-        add(new Help(), "help");
     	add(new RegsCommand(),"regs");
     	add(new DebuginfoCommand(),"debuginfo");
     	add(new MapsCommand(),"maps");
diff --git a/frysk-core/frysk/hpd/MapsCommand.java b/frysk-core/frysk/hpd/MapsCommand.java
index 278c9dc..833a6da 100644
--- a/frysk-core/frysk/hpd/MapsCommand.java
+++ b/frysk-core/frysk/hpd/MapsCommand.java
@@ -39,6 +39,7 @@
 
 package frysk.hpd;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import frysk.proc.MemoryMap;
@@ -55,23 +56,46 @@ public class MapsCommand extends ParameterizedCommand {
   }
   
   void interpret(CLI cli, Input cmd, Object options) {
+
+    int processCount = 0;
+    HashMap procList = new HashMap();  
     PTSet ptset = cli.getCommandPTSet(cmd);
+    
     Iterator taskDataIterator = ptset.getTaskData();
     if (taskDataIterator.hasNext() == false)  {
-      cli.addMessage("Cannot find main task. Cannot print out process maps.", Message.TYPE_ERROR);
+      cli.addMessage("Cannot find main task. Cannot print out process maps.", 
+	      	Message.TYPE_ERROR);
       return;
     }
-    Proc mainProc = ((TaskData) taskDataIterator.next()).getTask().getProc();
-    MemoryMap[] maps = mainProc.getMaps();
+    
+    while (taskDataIterator.hasNext()) {
+	Proc proc = ((TaskData) taskDataIterator.next()).getTask().getProc();
+	if (!procList.containsValue(proc)) {
+	    procList.put(proc,proc);
+	    processCount++;
+	}
+    }
+    
+    Iterator procIterator = procList.values().iterator();
 
-    if (maps == null) {
-	cli.addMessage("No maps data to print for this process", 
-		       Message.TYPE_WARNING);
-	return;
+    while (procIterator.hasNext()) {
+	Proc mainProc = ((Proc)procIterator.next());
+
+	MemoryMap[] maps = mainProc.getMaps();
+
+	if (maps == null) {
+	    cli.addMessage("No maps data to print for this process", 
+		    Message.TYPE_WARNING);
+	    continue;
+	}
+
+	if (processCount > 1)
+	    cli.outWriter.println("For process: " + mainProc.getPid()+"\n");
+
+	for (int i=0; i<maps.length; i++)
+	    cli.outWriter.println(maps[i].toString());
+	}
     }
-    for (int i=0; i<maps.length; i++)
-    	cli.outWriter.println(maps[i].toString());
-  }
   
   int completer(CLI cli, Input input, int cursor, List completions) {
     return -1;
diff --git a/frysk-core/frysk/hpd/TestAuxvCommand.java b/frysk-core/frysk/hpd/TestAuxvCommand.java
index 8434d36..f0863e5 100644
--- a/frysk-core/frysk/hpd/TestAuxvCommand.java
+++ b/frysk-core/frysk/hpd/TestAuxvCommand.java
@@ -68,7 +68,7 @@ public class TestAuxvCommand extends TestLib {
     }
     
     BuildAuxv buildAuxv = new BuildAuxv();
-    buildAuxv.construct(liveAuxv);
+    buildAuxv.construct(liveAuxv, proc);
     
     
     e = new HpdTestbed();
diff --git a/frysk-core/frysk/util/AuxvStringBuilder.java b/frysk-core/frysk/util/AuxvStringBuilder.java
index 02ce064..69d0ceb 100644
--- a/frysk-core/frysk/util/AuxvStringBuilder.java
+++ b/frysk-core/frysk/util/AuxvStringBuilder.java
@@ -38,8 +38,12 @@
 // exception.
 package frysk.util;
 
+import inua.eio.ByteBuffer;
 import inua.elf.AT;
 import frysk.proc.Auxv;
+import frysk.proc.Proc;
+import frysk.symtab.Symbol;
+import frysk.symtab.SymbolFactory;
 
 
 public abstract class AuxvStringBuilder
@@ -47,24 +51,56 @@ public abstract class AuxvStringBuilder
   protected AuxvStringBuilder() {
   }
   
-  public final void construct (Auxv[] rawAuxv) {
+  public final void construct (Auxv[] rawAuxv, Proc mainProc) {
     String  value;
+
     for (int i=0; i < rawAuxv.length; i++) {
-      switch (rawAuxv[i].type) {
-      case 33:
-      case 16:
-      case 3:
-      case 9:
+	switch (rawAuxv[i].type) {
+	case 33:
+	case 16:
+	case 3:
+	    value = "0x"+Long.toHexString(rawAuxv[i].val);
+	    break;
+	case 9:
+	    Symbol symbol = SymbolFactory.getSymbol(mainProc.getMainTask(), 
+		    rawAuxv[i].val);
+	    value = symbol.getName()+" (0x" +
+	    Long.toHexString(rawAuxv[i].val)+")";
+	    break;
 	case 15: 
-	  value = "0x"+Long.toHexString(rawAuxv[i].val);
-	  break;
-      default: 
-	value = ""+rawAuxv[i].val;
-      }    		  
-      buildLine(AT.toString(rawAuxv[i].type), AT.toPrintString(rawAuxv[i].type), value);
+	    value = getMemoryString(rawAuxv[i].val, mainProc);
+	    break;
+	default: 
+	    value = ""+rawAuxv[i].val;
+	}    		  
+	buildLine(AT.toString(rawAuxv[i].type), AT.toPrintString(rawAuxv[i].type), value);
     }
   }
   
   abstract public void buildLine(String type, String desc, String value);
+  
+  private String getMemoryString(long address, Proc mainProc) {


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


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

only message in thread, other threads:[~2008-01-09 21:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-09 21:53 [SCM] master: Make auxv lookup entry point symbol. Discover auxv platform pmuldoon

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