public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Add standard stack options to ftrace.
@ 2008-03-20 18:15 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-03-20 18:15 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  da8a31567d75f21e3121fe38a83c5b67a973cbd0 (commit)
       via  b0409fdecf510519197134a3882b77b36d20c8ac (commit)
       via  24af95f8a668915bb4e9b48563640f36c076c975 (commit)
      from  0b1b747862f21b846d25ce05a2d9d823ca6683e4 (commit)

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

- Log -----------------------------------------------------------------
commit da8a31567d75f21e3121fe38a83c5b67a973cbd0
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Mar 20 14:14:21 2008 -0400

    Add standard stack options to ftrace.
    
    frysk-core/frysk/bindir/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* TestFtrace.java: Use -follow.
    	* ftrace.java: Use StackPrintUtil.  Replace '-c' with -f/-follow -
    	follow children.
    
    frysk-core/frysk/ftrace/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* Ftrace.java (Ftrace(PrintStackOptions)): New constructor.
    	* Reporter.java (Reporter(PrintWriter,PrintStackOptions)): Add
    	stackPrintOptions parameter; use.
    	(generateStackTrace(Task)): Use StackPrintUtil.
    
    frysk-core/frysk/util/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* StackPrintUtil.java (options(PrintStackOptions)): Drop -p; keeps
    	clashing with -p PID.

commit b0409fdecf510519197134a3882b77b36d20c8ac
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Mar 20 11:40:51 2008 -0400

    Move stack option parsing and printing to StackPrintUtil.
    
    frysk-core/frysk/bindir/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* fstack.java: Use StackPrintFactory to create standard options
    	and print the stack.
    	* ferror.java: Ditto.
    
    frysk-core/frysk/util/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* FCatch.java (options()): New; use StackPrintUtil.
    	* StackPrintUtil.java: New file.

commit 24af95f8a668915bb4e9b48563640f36c076c975
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Mar 20 11:40:13 2008 -0400

    Add missing (C).

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog                  |   10 ++
 frysk-core/frysk/bindir/TestFtrace.java            |    2 +-
 frysk-core/frysk/bindir/ferror.java                |  133 ++++++++++++-------
 frysk-core/frysk/bindir/fstack.java                |  112 ++--------------
 frysk-core/frysk/bindir/ftrace.java                |   13 ++-
 frysk-core/frysk/debuginfo/PrintStackOptions.java  |   40 ++++++-
 frysk-core/frysk/ftrace/ChangeLog                  |    7 +
 frysk-core/frysk/ftrace/Ftrace.java                |   15 ++-
 frysk-core/frysk/ftrace/Reporter.java              |   18 +--
 frysk-core/frysk/util/ChangeLog                    |    8 +
 frysk-core/frysk/util/FCatch.java                  |   19 ++-
 .../fstack.java => util/StackPrintUtil.java}       |  140 +++++++-------------
 12 files changed, 249 insertions(+), 268 deletions(-)
 copy frysk-core/frysk/{bindir/fstack.java => util/StackPrintUtil.java} (62%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 92ebce5..e440ad8 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-20  Andrew Cagney  <cagney@redhat.com>
+
+	* TestFtrace.java: Use -follow.
+	* ftrace.java: Use StackPrintUtil.  Replace '-c' with -f/-follow -
+	follow children.
+
+	* fstack.java: Use StackPrintUtil to create standard options
+	and print the stack.
+	* ferror.java: Ditto.
+
 2008-03-19  Phil Muldoon  <pmuldoon@redhat.com>
 	    Andrew Cagney  <cagney@redhat.com>
 
diff --git a/frysk-core/frysk/bindir/TestFtrace.java b/frysk-core/frysk/bindir/TestFtrace.java
index 2573df7..63a9643 100644
--- a/frysk-core/frysk/bindir/TestFtrace.java
+++ b/frysk-core/frysk/bindir/TestFtrace.java
@@ -91,7 +91,7 @@ public class TestFtrace extends TestLib {
         TearDownExpect e = new TearDownExpect(new String[] {
 		Config.getBinFile("ftrace").getAbsolutePath(),
 		"-sys=",
-		"-c",
+		"-follow",
 		""+task.getProc().getPid()
 	    });
 	e.expect(""+task.getProc().getPid()+"."+ task.getTid() + " * syscall * rt_sigsuspend");
diff --git a/frysk-core/frysk/bindir/ferror.java b/frysk-core/frysk/bindir/ferror.java
index 99b7a4a..f79b8c2 100644
--- a/frysk-core/frysk/bindir/ferror.java
+++ b/frysk-core/frysk/bindir/ferror.java
@@ -1,6 +1,44 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2007, 2008, 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.bindir;
 
-import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.debuginfo.PrintStackOptions;
 import frysk.isa.syscalls.Syscall;
 import frysk.proc.Action;
@@ -13,11 +51,14 @@ import gnu.classpath.tools.getopt.OptionGroup;
 import gnu.classpath.tools.getopt.OptionException;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
+import frysk.util.StackPrintUtil;
 
 import java.io.PrintWriter;
 
 public class ferror {
     
+    private static final PrintStackOptions stackPrintOptions
+	= new PrintStackOptions();
     private static final PrintWriter printWriter = new PrintWriter(System.out);
     private static Pattern writePattern;
     private static OptionGroup[] options() {
@@ -28,11 +69,18 @@ public class ferror {
 		    writePattern = Pattern.compile(argument);
 		}  
 	    });
-	return new OptionGroup[] { group };
-		  
+	return new OptionGroup[] {
+	    group,
+	    StackPrintUtil.options(stackPrintOptions)
+	};
     }
     
     public static void main(String[] args) {
+	stackPrintOptions.setPrintFullpath(false);
+	stackPrintOptions.setPrintParameters(true);
+	stackPrintOptions.setPrintVirtualFrames(true);
+	stackPrintOptions.setPrintLibrary(true);
+
 	ProcRunUtil procRunningUtil = 
 	    new ProcRunUtil("ferror",
 			    "ferror -e \"<error string>\" -- <executbale|PID> [ARGS]",
@@ -44,52 +92,43 @@ public class ferror {
     }
 
     
-    static Syscalls syscallObserver = new Syscalls(){
+    static Syscalls syscallObserver = new Syscalls() {
 
-      public Action updateSyscallExit (Task task)
-      {
-        return Action.CONTINUE;
-      }
+	    public Action updateSyscallExit (Task task) {
+		return Action.CONTINUE;
+	    }
 
-      public void addFailed (Object observable, Throwable w){}
-      public void addedTo (Object observable){
-	  Task task = (Task) observable;
-	  printWriter.println("Tracing " + task.getProc().getPid() + "." + task.getTid());
-	  printWriter.flush();
-      }
-      public void deletedFrom (Object observable){}
+	    public void addFailed (Object observable, Throwable w){}
+	    public void addedTo (Object observable){
+		Task task = (Task) observable;
+		printWriter.println("Tracing " + task.getProc().getPid() + "." + task.getTid());
+		printWriter.flush();
+	    }
+	    public void deletedFrom (Object observable){}
 
-      public Action updateSyscallEnter(Task task, Syscall syscall) {
-  	if(syscall.getName().equals("write")){
-  	        long address = syscall.getArguments(task, 2);
-  	        long length = syscall.getArguments(task, 3);
-  	      
-  	        StringBuffer x = new StringBuffer ();
-  	        task.getMemory().get (address, length, x);
-  	        String xString = new String(x);
-  	        
-		Matcher match = writePattern.matcher(xString);
-		if (match.find()) {
-		   printWriter.println("Process is trying to output: " +
-				       xString + 
-				       " which matches pattern: " + 
-				       writePattern.pattern());
+	    public Action updateSyscallEnter(Task task, Syscall syscall) {
+		if (syscall.getName().equals("write")){
+		    long address = syscall.getArguments(task, 2);
+		    long length = syscall.getArguments(task, 3);
 		    
-  	          printWriter.println("Stack trace:\n");
-  	          PrintStackOptions options = new PrintStackOptions();
-
-  	          options.setPrintFullpath(false);
-  	          options.setPrintParameters(true);
-  	          options.setPrintVirtualFrames(true);
-  	          options.setPrintLibrary(true);
-
-  	          DebugInfoStackFactory.printTaskStackTrace(printWriter, task, options);
-  	          
-  	        }
-  	        
-  	      }
-  	      return Action.CONTINUE;
-      }
-      
-    };
+		    StringBuffer x = new StringBuffer ();
+		    task.getMemory().get (address, length, x);
+		    String xString = new String(x);
+		    
+		    Matcher match = writePattern.matcher(xString);
+		    if (match.find()) {
+			printWriter.println("Process is trying to output: " +
+					    xString + 
+					    " which matches pattern: " + 
+					    writePattern.pattern());
+			
+			printWriter.println("Stack trace:\n");
+			StackPrintUtil.print(task, stackPrintOptions,
+					     printWriter);
+		    }
+		    
+		}
+		return Action.CONTINUE;
+	    }
+	};
 }
diff --git a/frysk-core/frysk/bindir/fstack.java b/frysk-core/frysk/bindir/fstack.java
index 4ad3c82..a59bd43 100644
--- a/frysk-core/frysk/bindir/fstack.java
+++ b/frysk-core/frysk/bindir/fstack.java
@@ -41,26 +41,22 @@ package frysk.bindir;
 
 import java.io.PrintWriter;
 import java.util.Iterator;
-import java.util.StringTokenizer;
 import java.util.TreeMap;
-
-import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.debuginfo.PrintStackOptions;
 import frysk.event.Event;
 import frysk.event.ProcEvent;
 import frysk.proc.Proc;
 import frysk.proc.Task;
 import frysk.rsl.Log;
-import frysk.stack.StackFactory;
 import frysk.util.ProcStopUtil;
-import gnu.classpath.tools.getopt.Option;
+import frysk.util.StackPrintUtil;
 import gnu.classpath.tools.getopt.OptionGroup;
-import gnu.classpath.tools.getopt.OptionException;
 
 public final class fstack {
 
   private static PrintWriter printWriter = new PrintWriter(System.out);  
-  static PrintStackOptions options = new PrintStackOptions();
+    private static PrintStackOptions stackPrintOptions
+	= new PrintStackOptions();
   private static final Log fine = Log.fine(fstack.class);
   
     public static void main(String[] args) {
@@ -103,20 +99,9 @@ public final class fstack {
       for (int i=0; i<tasks.length; i++)
           sortedTasks.put(new Integer(tasks[i].getTid()), tasks[i]);
 
-      Iterator iter = sortedTasks.values().iterator();
-      while (iter.hasNext())
-      {
-          Task task =  (Task) iter.next();
-
-          if(options.elfOnly()){
-              StackFactory.printTaskStackTrace(printWriter,task,options);
-          }else{
-              if(options.printVirtualFrames()){
-                  DebugInfoStackFactory.printVirtualTaskStackTrace(printWriter,task,options);
-              }else{
-                  DebugInfoStackFactory.printTaskStackTrace(printWriter,task,options);
-              }
-          }
+      for (Iterator i = sortedTasks.values().iterator(); i.hasNext(); ) {
+          Task task = (Task) i.next();
+	  StackPrintUtil.print(task, stackPrintOptions, printWriter);
           printWriter.println();
       }
   }
@@ -125,87 +110,8 @@ public final class fstack {
      * Create the default option group.
      */
     private static OptionGroup[] options() {
-	OptionGroup group = new OptionGroup("fstack options");
-	group.add(new Option("number-of-frames", 'n', "number of frames to print. Use -n 0 or" +
-			     " -n all to print all frames.", "<number of frames>") {
-		public void parsed(String arg) throws OptionException {
-		    if(arg.equals("all")){
-			options.setNumberOfFrames(0);
-		    }else{
-			options.setNumberOfFrames(Integer.parseInt(arg));
-			return;
-		    }
-		}
-	    });
-	group.add(new Option("fullpath", 'f', "print full path." +
-			     "-f prints full path") {
-		public void parsed(String arg) throws OptionException {
-		    options.setPrintFullpath(true);
-		}
-	    });
-	group.add(new Option("all", 'a', "print all information that can currently be retrieved" +
-			     "about the stack\n" +
-			     "this is equivalent to -p functions,params,scopes,fullpath") {
-		public void parsed(String argument) throws OptionException {
-		    options.setElfOnly(false);
-		    options.setPrintParameters(true);
-		    options.setPrintScopes(true);
-		    options.setPrintFullpath(true);
-		}
-	    });
-	group.add(new Option("virtual",
-			     'v',
-			     "Includes virtual frames in the stack trace.\n" +
-			     "Virtual frames are artificial frames corresponding" +
-			     " to calls to inlined functions") {
-		public void parsed(String argument) throws OptionException {
-		    options.setPrintVirtualFrames(true);
-		    options.setElfOnly(false);
-		}
-	    });
-	group.add(new Option("common", 'c', "print commonly used debug information:" +
-			     "this is equivalent to fstack -v -p functions,params,fullpath") {
-		public void parsed(String argument) throws OptionException {
-		    options.setElfOnly(false);
-		    options.setPrintParameters(true);
-		    options.setPrintScopes(false);
-		    options.setPrintFullpath(true);
-		    options.setPrintVirtualFrames(true);
-		}
-	    });
-	group.add(new Option("print", 'p', "itmes to print. Possible items:\n" +
-			     "functions : print function names using debug information\n" +
-			     "scopes : print variables declared in each scope within the " +
-			     "function.\n" +
-			     "params : print function parameters\n" +
-			     "fullpath : print full executbale path" , "[item],...") {
-		public void parsed(String arg) throws OptionException {
-		    options.setElfOnly(true);
-		    options.setPrintParameters(false);
-		    options.setPrintScopes(false);
-		    options.setPrintFullpath(false);
-		    options.setPrintVirtualFrames(false);
-		    StringTokenizer st = new StringTokenizer(arg, ",");
-		    while (st.hasMoreTokens()) {
-			String name = st.nextToken();
-			if (name.equals("functions")) {
-			    options.setElfOnly(false);
-			} else if (name.equals("params")) {
-			    options.setElfOnly(false);
-			    options.setPrintParameters(true);
-			} else if (name.equals("scopes")) {
-			    options.setElfOnly(false);
-			    options.setPrintScopes(true);
-			} else if (name.equals("fullpath")) {
-			    options.setElfOnly(false);
-			    options.setPrintFullpath(true);
-			} else {
-			    throw new OptionException
-				("unknown print parameter: " + name);
-			}
-		    }
-		}
-	    });
-	return new OptionGroup[] { group };
+	return new OptionGroup[] {
+	    StackPrintUtil.options(stackPrintOptions)
+	};
     }
 }
diff --git a/frysk-core/frysk/bindir/ftrace.java b/frysk-core/frysk/bindir/ftrace.java
index 18a396c..2efb84d 100644
--- a/frysk-core/frysk/bindir/ftrace.java
+++ b/frysk-core/frysk/bindir/ftrace.java
@@ -39,6 +39,8 @@
 
 package frysk.bindir;
 
+import frysk.debuginfo.PrintStackOptions;
+import frysk.util.StackPrintUtil;
 import inua.util.PrintWriter;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -83,7 +85,9 @@ class ftrace {
     private final FtraceController controller = new FtraceController();
     private boolean allowInterpTracing = false;
 
-    private Ftrace tracer = new Ftrace();
+    private final PrintStackOptions stackPrintOptions
+	= new PrintStackOptions();
+    private final Ftrace tracer = new Ftrace(stackPrintOptions);
 
     private List parseSymbolRules(String arg) {
 	String[] strs = arg.split(",", -1);
@@ -237,7 +241,7 @@ class ftrace {
                 }
 		}
 	    });
-        group.add(new Option('c', "trace children as well") {
+        group.add(new Option("follow", 'f', "follow children as well") {
 		public void parsed(String arg0) throws OptionException {
 		    tracer.setTraceChildren();
 		}
@@ -295,7 +299,10 @@ class ftrace {
 		    controller.stackTraceEverything();
 		}
 	    });
-	return new OptionGroup[] { group };
+	return new OptionGroup[] {
+	    group,
+	    StackPrintUtil.options(stackPrintOptions)
+	};
     }
 
     public void run(String[] args) {
diff --git a/frysk-core/frysk/debuginfo/PrintStackOptions.java b/frysk-core/frysk/debuginfo/PrintStackOptions.java
index c6d9606..02ebf8c 100644
--- a/frysk-core/frysk/debuginfo/PrintStackOptions.java
+++ b/frysk-core/frysk/debuginfo/PrintStackOptions.java
@@ -1,5 +1,43 @@
-package frysk.debuginfo;
+// This file is part of the program FRYSK.
+//
+// Copyright 2007, 2008, 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.debuginfo;
 
 public class PrintStackOptions {
 
diff --git a/frysk-core/frysk/ftrace/ChangeLog b/frysk-core/frysk/ftrace/ChangeLog
index bdb812a..c612c4c 100644
--- a/frysk-core/frysk/ftrace/ChangeLog
+++ b/frysk-core/frysk/ftrace/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-20  Andrew Cagney  <cagney@redhat.com>
+
+	* Ftrace.java (Ftrace(PrintStackOptions)): New constructor.
+	* Reporter.java (Reporter(PrintWriter,PrintStackOptions)): Add
+	stackPrintOptions parameter; use.
+	(generateStackTrace(Task)): Use StackPrintUtil.
+
 2008-03-17  Andrew Cagney  <cagney@redhat.com>
 
 	* Ftrace.java: Update; using TaskAttachedObserverXXX.
diff --git a/frysk-core/frysk/ftrace/Ftrace.java b/frysk-core/frysk/ftrace/Ftrace.java
index 6f8d002..8bfd5ee 100644
--- a/frysk-core/frysk/ftrace/Ftrace.java
+++ b/frysk-core/frysk/ftrace/Ftrace.java
@@ -55,9 +55,16 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Iterator;
 import frysk.proc.TaskAttachedObserverXXX;
+import frysk.debuginfo.PrintStackOptions;
+
+public class Ftrace {
+    private final PrintStackOptions stackPrintOptions;
+    
+    public Ftrace(PrintStackOptions stackPrintOptions) {
+	this.stackPrintOptions = stackPrintOptions;
+	reporter = new Reporter(new PrintWriter(System.out), stackPrintOptions);
+    }
 
-public class Ftrace
-{
     // Where to send output.
     Reporter reporter;
 
@@ -171,12 +178,10 @@ public class Ftrace
     }
 
     public void setWriter (PrintWriter writer) {
-	this.reporter = new Reporter(writer);
+	this.reporter = new Reporter(writer, stackPrintOptions);
     }
 
     private void init() {
-	if (reporter == null)
-	    reporter = new Reporter(new PrintWriter(System.out));
 	functionObserver = new MyFunctionObserver(reporter, stackTraceSetProvider);
     }
 


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


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

only message in thread, other threads:[~2008-03-20 18:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-20 18:15 [SCM] master: Add standard stack options to ftrace cagney

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