public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: new ftrace option: pc shows program counter at the time of event
@ 2008-04-02  7:33 pmachata
  0 siblings, 0 replies; only message in thread
From: pmachata @ 2008-04-02  7:33 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  308142e84ff6151b8eff0d37b40aa5634f120981 (commit)
      from  35c524fa916d0a8fa8a68fce1164f7dbd7c3bad3 (commit)

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

- Log -----------------------------------------------------------------
commit 308142e84ff6151b8eff0d37b40aa5634f120981
Author: Petr Machata <pmachata@redhat.com>
Date:   Mon Mar 31 18:12:22 2008 +0200

    new ftrace option: pc shows program counter at the time of event
    
    * addtionally, -i was dropped in favor of -dl, and its description fixed
      ("dl" for dynamic linker works better than "i" for INTERP)

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog     |    5 ++++
 frysk-core/frysk/bindir/ftrace.java   |    7 +++++-
 frysk-core/frysk/ftrace/ChangeLog     |    9 ++++++++
 frysk-core/frysk/ftrace/Ftrace.java   |   11 ++++++++-
 frysk-core/frysk/ftrace/Reporter.java |   35 +++++++++++++++++++++++++++-----
 5 files changed, 58 insertions(+), 9 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index de1ef95..e11cb6d 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -25,6 +25,11 @@
 	* fstack.xml: Use stack-options.xml, standard-options.xml, and
 	version.in.
 
+2008-03-31  Petr Machata  <pmachata@redhat.com>
+
+	* ftrace.java: New option "-pc".
+	Rename option "-i" to "-dl" and fix its description.
+
 2008-03-27  Stan Cox  <scox@redhat.com>
 
 	* fexe.java (executeLive): Also show sysrooted exe path.
diff --git a/frysk-core/frysk/bindir/ftrace.java b/frysk-core/frysk/bindir/ftrace.java
index 6774501..fd759a5 100644
--- a/frysk-core/frysk/bindir/ftrace.java
+++ b/frysk-core/frysk/bindir/ftrace.java
@@ -264,7 +264,12 @@ class ftrace {
 		    tracer.setTraceMmaps();
 		}
 	    });
-        group.add(new Option('i', "don't trace dynamic linker symbols") {
+        group.add(new Option("pc", "show program counter at traced events") {
+		public void parsed(String arg) throws OptionException {
+		    tracer.setShowPC(true);
+		}
+	    });
+        group.add(new Option("dl", "allow tracing of dynamic linker symbols") {
 		public void parsed(String arg) throws OptionException {
 		    allowInterpTracing = true;
 		}
diff --git a/frysk-core/frysk/ftrace/ChangeLog b/frysk-core/frysk/ftrace/ChangeLog
index 27bc300..e0292aa 100644
--- a/frysk-core/frysk/ftrace/ChangeLog
+++ b/frysk-core/frysk/ftrace/ChangeLog
@@ -5,6 +5,15 @@
 	* FtraceController.java: Introduce local loggers, use them.
 	* ObjectFile.java: Likewise.
 
+2008-03-31  Petr Machata  <pmachata@redhat.com>
+
+	* Reporter.java (ctor Reporter): New parameter "showPC"
+	(formatTaskPC): New private function
+	(eventEntry, eventLeave, eventSingle): Call formatTaskPC
+	* Ftrace.java (setShowPC): New function.
+	(ctor Ftrace): Move reporter initialization...
+	(init): ...here
+
 2008-03-31  Andrew Cagney  <cagney@redhat.com>
 	
 	* Ftrace.java (trace(Proc)): Replace trace(String[]).
diff --git a/frysk-core/frysk/ftrace/Ftrace.java b/frysk-core/frysk/ftrace/Ftrace.java
index 80073b5..fe6935d 100644
--- a/frysk-core/frysk/ftrace/Ftrace.java
+++ b/frysk-core/frysk/ftrace/Ftrace.java
@@ -67,7 +67,6 @@ public class Ftrace {
     
     public Ftrace(PrintStackOptions stackPrintOptions) {
 	this.stackPrintOptions = stackPrintOptions;
-	reporter = new Reporter(new PrintWriter(System.out), stackPrintOptions);
     }
 
     // Where to send output.
@@ -84,6 +83,8 @@ public class Ftrace {
     // The number of processes we're tracing.
     int numProcesses;
 
+    private boolean showPC = false;
+
     /**
      * Controller has to be implemented externally.  Each time a
      * mapping changes, it is called for consulation and has a chance
@@ -182,12 +183,18 @@ public class Ftrace {
 	    throw new AssertionError("FtraceController already assigned.");
     }
 
+    public void setShowPC (boolean show) {
+	showPC = show;
+    }
+
     public void setWriter (PrintWriter writer) {
-	this.reporter = new Reporter(writer, stackPrintOptions);
+	this.reporter = new Reporter(writer, stackPrintOptions, showPC);
     }
 
     private void init() {
 	functionObserver = new MyFunctionObserver(reporter, stackTraceSetProvider);
+	if (reporter == null)
+	    setWriter(new PrintWriter(System.out));
     }
 
     public void addProc(Proc proc) {
diff --git a/frysk-core/frysk/ftrace/Reporter.java b/frysk-core/frysk/ftrace/Reporter.java
index 0e3a8a5..4531ab5 100644
--- a/frysk-core/frysk/ftrace/Reporter.java
+++ b/frysk-core/frysk/ftrace/Reporter.java
@@ -53,10 +53,12 @@ class Reporter
     private Task lastTask = null;
     private HashMap levelMap = new HashMap();
     private final PrintStackOptions stackPrintOptions;
+    private final boolean showPC;
 
-    public Reporter(PrintWriter writer, PrintStackOptions stackPrintOptions) {
+    public Reporter(PrintWriter writer, PrintStackOptions stackPrintOptions, boolean show) {
 	this.writer = writer;
 	this.stackPrintOptions = stackPrintOptions;
+	this.showPC = show;
     }
 
     private int getLevel(Task task)
@@ -120,6 +122,21 @@ class Reporter
 	writer.print(")");
     }
 
+    private String formatTaskPC(Task task) {
+	if (!showPC)
+		return "";
+
+	long pc;
+	try {
+	    pc = task.getPC();
+	}
+	catch (RuntimeException exc) {
+	    pc = -1;
+	}
+
+	return "0x" + Long.toHexString(pc) + " ";
+    }
+
     public void eventEntry(Task task, Object item, String eventType,
 			    String eventName, Object[] args)
     {
@@ -130,9 +147,10 @@ class Reporter
 	if (lineOpened())
 	    writer.println('\\');
 
-	writer.print(pidInfo(task) + " "
-			 + spaces + eventType
-			 + " " + eventName);
+	writer.print(pidInfo(task)
+		     + " " + formatTaskPC(task)
+		     + spaces + eventType
+		     + " " + eventName);
 	printArgs(args);
 	writer.flush();
 
@@ -149,7 +167,10 @@ class Reporter
 	    if (lineOpened())
 		writer.println();
 	    String spaces = repeat(' ', level);
-	    writer.print(pidInfo(task) + " " + spaces + eventType + " " + eventName);
+	    writer.print(pidInfo(task)
+			 + " " + formatTaskPC(task)
+			 + spaces + eventType
+			 + " " + eventName);
 	}
 
 	writer.println(" = " + retVal);
@@ -168,7 +189,9 @@ class Reporter
 	int level = this.getLevel(task);
 	if (lineOpened())
 	    writer.println("\\");
-	writer.println(pidInfo(task) + " " + repeat(' ', level) + eventName);
+	writer.println(pidInfo(task)
+		       + " " + formatTaskPC(task)
+		       + repeat(' ', level) + eventName);
 
 	if (args != null)
 	    printArgs(args);


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


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

only message in thread, other threads:[~2008-04-02  7:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-02  7:33 [SCM] master: new ftrace option: pc shows program counter at the time of event pmachata

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