public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Simplify corefile task creation (work with latest bash).
Date: Thu, 21 Feb 2008 03:34:00 -0000	[thread overview]
Message-ID: <20080221033453.1070.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  90ee18a041aa5c6d3306ac716d6bda587d0bb7c0 (commit)
      from  caffa28dbf44f934103b9f00eeea11e15ce97581 (commit)

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

- Log -----------------------------------------------------------------
commit 90ee18a041aa5c6d3306ac716d6bda587d0bb7c0
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed Feb 20 22:33:44 2008 -0500

    Simplify corefile task creation (work with latest bash).
    
    frysk-core/frysk/bindir/ChangeLog
    2008-02-20  Andrew Cagney  <cagney@redhat.com>
    
    	* TestFexe.java: Prevent bash execing fexe.
    
    frysk-core/frysk/proc/dead/ChangeLog
    2008-02-20  Andrew Cagney  <cagney@redhat.com>
    
    	* LinuxCoreProc.java (constructAuxv(ElfData)): New.
    	(constructTasks(ElfData,ISA)): Replace sendRefresh.
    
    frysk-sys/frysk/rsl/ChangeLog
    2008-02-20  Andrew Cagney  <cagney@redhat.com>
    
    	* Log.java: Include the TID.PID in the log message.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog             |    4 +
 frysk-core/frysk/bindir/TestFexe.java         |   12 ++-
 frysk-core/frysk/proc/dead/ChangeLog          |    3 +
 frysk-core/frysk/proc/dead/LinuxCoreProc.java |  184 ++++++++++++-------------
 frysk-sys/frysk/rsl/ChangeLog                 |    4 +
 frysk-sys/frysk/rsl/Log.java                  |   20 ++-
 6 files changed, 125 insertions(+), 102 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 5ead415..4c50ee9 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-20  Andrew Cagney  <cagney@redhat.com>
+
+	* TestFexe.java: Prevent bash execing fexe.
+
 2008-02-20  Teresa Thomas  <tthomas@redhat.com>
 
 	* fexe.java: Refactor to use ProcStopUtil.
diff --git a/frysk-core/frysk/bindir/TestFexe.java b/frysk-core/frysk/bindir/TestFexe.java
index 53b6f77..50c5c23 100644
--- a/frysk-core/frysk/bindir/TestFexe.java
+++ b/frysk-core/frysk/bindir/TestFexe.java
@@ -47,7 +47,15 @@ import java.io.File;
 public class TestFexe extends TestLib {
     public void testExeOfPid() {
 	File fexe = Config.getBinFile("fexe");
-	TearDownExpect e = new TearDownExpect(fexe.getAbsolutePath () + " $$");
-	e.expect(fexe + "\r\n");
+	// XXX: Some versions of bash (e.g., bash-3.2-20.fc8.x86_64)
+	// will exec, instead of fork, a program if it is the only
+	// command.  This leads to $$ pointing at the fexe process.
+	// Work around it by forcing bash to execute two commands.
+	TearDownExpect e = new TearDownExpect(new String[] {
+		"/bin/bash",
+		"-c",
+		fexe.getAbsolutePath() + " $$ ; echo \"\""
+	    });
+	e.expect("/bin/bash" + "\r\n");
     }
 }
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index e818f2b..a98393b 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,5 +1,8 @@
 2008-02-20  Andrew Cagney  <cagney@redhat.com>
 
+	* LinuxCoreProc.java (constructAuxv(ElfData)): New.
+	(constructTasks(ElfData,ISA)): Replace sendRefresh.
+
 	* LinuxCoreFactory.java: New file. Code from LinuxCoreHost,
 	LinuxCoreProc, and LinuxCoreTask.
 	
diff --git a/frysk-core/frysk/proc/dead/LinuxCoreProc.java b/frysk-core/frysk/proc/dead/LinuxCoreProc.java
index 4f62d03..2e53c75 100644
--- a/frysk-core/frysk/proc/dead/LinuxCoreProc.java
+++ b/frysk-core/frysk/proc/dead/LinuxCoreProc.java
@@ -55,7 +55,6 @@ import frysk.sys.proc.AuxvBuilder;
 import java.util.Iterator;
 import java.io.File;
 import java.util.ArrayList;
-import frysk.proc.Task;
 import frysk.proc.Auxv;
 import frysk.proc.MemoryMap;
 import frysk.isa.ISA;
@@ -64,7 +63,6 @@ import frysk.rsl.Log;
 
 public class LinuxCoreProc extends DeadProc {
   
-    private ElfData elfData = null;
     private ElfPrpsinfo elfProc = null;
     private CorefileByteBuffer memory = null;
     private File corefileBackEnd = null;
@@ -77,12 +75,12 @@ public class LinuxCoreProc extends DeadProc {
     private static final Log fine = Log.fine(LinuxCoreProc.class);
 
 
-    public LinuxCoreProc(ElfData data, LinuxCoreHost host, int pid) {
+    public LinuxCoreProc(ElfData noteSection, LinuxCoreHost host, int pid) {
 	super(host, null, pid);
-	this.elfData = data;
-	this.elfProc = ElfPrpsinfo.decode(elfData);
+	this.elfProc = ElfPrpsinfo.decode(noteSection);
 	this.corefileBackEnd = host.coreFile;
-	fine.log(this, "LinuxCoreProc elfData", data, "host", host, "pid", pid);
+	fine.log(this, "LinuxCoreProc noteSection", noteSection,
+		 "host", host, "pid", pid);
 
 	// Executable is null (non-specified), find the executable
 	// as it is written in the corefile. 
@@ -93,8 +91,75 @@ public class LinuxCoreProc extends DeadProc {
 	
 	}
 	this.exefileBackEnd = host.exeFile;
+	this.auxv = constructAuxv(noteSection);
+	constructTasks(noteSection);
     }	
 
+    public void sendRefresh() {
+	// Do nothing; already done.
+    }
+
+    /**
+     * Find and create the core tasks.
+     */
+    private void constructTasks(ElfData noteSection) {
+ 	ISA isa = ElfMap.getISA(noteSection.getParent().getEHeader());
+	ElfPrstatus elfTasks[] = null;
+	ElfPrFPRegSet elfFPRegs[] = null;
+	ElfPrXFPRegSet elfXFPRegs[] = null;
+	int fpCount = 0;
+
+	// Decode both task and floating point registers
+	elfTasks = ElfPrstatus.decode(noteSection);
+	elfFPRegs = ElfPrFPRegSet.decode(noteSection);
+	elfXFPRegs = ElfPrXFPRegSet.decode(noteSection);
+    
+	// Two methods of whether Floating Point note data exists.
+	// In userland generated core-dumps there is no way to test
+	// if floating point data operations have actually occurred, so
+	// programs like fcore/gcore will always write NT_FPREGSET note data
+	// per thread regardless. On kernel generated corefiles, the
+	// kernel micro-optimizes whether NT_FPREGSET note data is written
+	// per thread by analyzing to see if that thread has performed
+	// Floating Point operations. If it has, it will write
+	// NT_FPREGSET, and if it hasn't it won't.
+
+	// Account for both these scenarios, here.
+    
+	if (elfFPRegs.length == elfTasks.length) {
+	    // The number of NT_FPREGSET note objects is equal to the
+	    // the number of NT_PRSTATUS note objects, then no do not
+	    // account for mismatch.
+	    for (int i=0; i<elfTasks.length; i++) {
+		// xfpregsets accompany fp registers on a 1:1 basis
+		// but only on some architectures.
+		ElfPrXFPRegSet xregSet = null;
+		if (elfXFPRegs.length > 0)
+		    xregSet = elfXFPRegs[i];
+		new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i], elfFPRegs[i],
+				  xregSet, isa);
+	    }
+	} else {
+	    // Otherwise add only NT_FPREGSET data if pr_fpvalid is >
+	    // 0. This value is not reliable on userland kernels (gdb
+	    // always sets it to 0) so if we are here, this is a
+	    // micro-optimized kernel where that flag is set
+	    // correctly.
+	    for (int i=0; i<elfTasks.length; i++) {
+		if (elfTasks[i].getPrFPValid() > 0) {
+		    // xfpregsets accompany fp registers on a 1:1
+		    // basis but only on some architectures.
+		    ElfPrXFPRegSet xregSet = null;
+		    if (elfXFPRegs.length > 0)
+			xregSet = elfXFPRegs[fpCount];
+		    new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i], elfFPRegs[fpCount], xregSet, isa);
+		    fpCount++;
+		} else
+		    new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i],  null, null, isa);
+	    }
+	}
+    }
+
     public String getCommand() {
 	fine.log(this,"getCommand()", elfProc.getPrFname());
 	return elfProc.getPrFname();
@@ -160,73 +225,6 @@ public class LinuxCoreProc extends DeadProc {
 	return memory;
     }
 
-    public void sendRefresh() {
-	// Find tasks. Refresh is a misnomer here as 
-	// Corefiles will never spawn new tasks beyond the
-	// original refresh, or will lose them. 
-
-	ElfPrstatus elfTasks[] = null;
-	ElfPrFPRegSet elfFPRegs[] = null;
-	ElfPrXFPRegSet elfXFPRegs[] = null;
-	int fpCount = 0;
-
-	// Decode both task and floating point registers
-	elfTasks = ElfPrstatus.decode(elfData);
-	elfFPRegs = ElfPrFPRegSet.decode(elfData);
-	elfXFPRegs = ElfPrXFPRegSet.decode(elfData);
-    
-	ISA isa = ElfMap.getISA(elfData.getParent().getEHeader());
-
-	// Two methods of whether Floating Point note data exists.
-	// In userland generated core-dumps there is no way to test
-	// if floating point data operations have actually occurred, so
-	// programs like fcore/gcore will always write NT_FPREGSET note data
-	// per thread regardless. On kernel generated corefiles, the
-	// kernel micro-optimizes whether NT_FPREGSET note data is written
-	// per thread by analyzing to see if that thread has performed
-	// Floating Point operations. If it has, it will write
-	// NT_FPREGSET, and if it hasn't it won't.
-
-	// Account for both these scenarios, here.
-    
-	Task newTask = null;
-    
-	// If the number of NT_FPREGSET note objects is equal to the
-	// the number of NT_PRSTATUS note objects, then no do not account
-	// for mismatch. 
-	if (elfFPRegs.length == elfTasks.length)
-	    for (int i=0; i<elfTasks.length; i++) {
-		// xfpregsets accompany fp registers on a 1:1  basis
-		// but only on some architectures.
-		ElfPrXFPRegSet xregSet = null;
-		if (elfXFPRegs.length > 0)
-		    xregSet = elfXFPRegs[i];
-		newTask = new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i], elfFPRegs[i], xregSet, isa);
-	    } else {
-	    // Otherwise add only NT_FPREGSET data if pr_fpvalid is > 0. This
-	    // value is not reliable on userland kernels (gdb always sets it
-	    // to 0) so if we are here, this is a micro-optimized kernel where
-	    // that flag is set correctly.
-	    for (int i=0; i<elfTasks.length; i++) {
-	    
-		if (elfTasks[i].getPrFPValid() > 0) {
-
-		    // xfpregsets accompany fp registers on a 1:1  basis
-		    // but only on some architectures.
-		    ElfPrXFPRegSet xregSet = null;
-		    if (elfXFPRegs.length > 0)
-			xregSet = elfXFPRegs[fpCount];
-		    newTask = new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i], elfFPRegs[fpCount], xregSet, isa);
-		    fpCount++;
-		} else
-		    newTask = new LinuxCoreTask(LinuxCoreProc.this, elfTasks[i],  null, null, isa);
-	    
-	    }
-	}
-	newTask.getClass();
-    }
-
-
     private MemoryMap[] memoryMaps;
     public MemoryMap[] getMaps () {
 	fine.log(this,"getMaps()");
@@ -267,31 +265,29 @@ public class LinuxCoreProc extends DeadProc {
 	return memoryMaps;
     }
 
-    private Auxv[] auxv;
     public Auxv[] getAuxv() {
+	return auxv;
+    }
+    private Auxv[] auxv;
 
+    private Auxv[] constructAuxv(ElfData noteSection) {
 	fine.log(this,"getAuxv()", Log.CALLER);
-
-	if (auxv == null) {
-	    fine.log(this,"Auxv is null, building");
-	    final ElfPrAuxv prAuxv =  ElfPrAuxv.decode(elfData);
-	    class BuildAuxv extends AuxvBuilder {
-		Auxv[] vec;
-		public void buildBuffer (byte[] auxv) {
-		}
-		public void buildDimensions (int wordSize, boolean bigEndian,
-					     int length) {
-		    vec = new Auxv[length];
-		}
-		public void buildAuxiliary (int index, int type, long val) {
-		    vec[index] = new Auxv (type, val);
-		}
+	final ElfPrAuxv prAuxv =  ElfPrAuxv.decode(noteSection);
+	class BuildAuxv extends AuxvBuilder {
+	    Auxv[] vec;
+	    public void buildBuffer (byte[] auxv) {
 	    }
-	    BuildAuxv auxv = new BuildAuxv ();
-	    auxv.construct (prAuxv.getAuxvBuffer());
-	    this.auxv = auxv.vec;
-	} else {fine.log(this,"Returning cached Auxv");}
-	return auxv;
+	    public void buildDimensions (int wordSize, boolean bigEndian,
+					 int length) {
+		vec = new Auxv[length];
+	    }
+	    public void buildAuxiliary (int index, int type, long val) {
+		vec[index] = new Auxv (type, val);
+	    }
+	}
+	BuildAuxv auxv = new BuildAuxv ();
+	auxv.construct (prAuxv.getAuxvBuffer());
+	return auxv.vec;
     }
 
     /**
diff --git a/frysk-sys/frysk/rsl/ChangeLog b/frysk-sys/frysk/rsl/ChangeLog
index 27e24e2..73b33c2 100644
--- a/frysk-sys/frysk/rsl/ChangeLog
+++ b/frysk-sys/frysk/rsl/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-20  Andrew Cagney  <cagney@redhat.com>
+
+	* Log.java: Include the TID.PID in the log message.
+
 2008-02-15  Andrew Cagney  <cagney@redhat.com>
 
 	* Log.java: Add more log methods and boolean support.
diff --git a/frysk-sys/frysk/rsl/Log.java b/frysk-sys/frysk/rsl/Log.java
index 5e6f677..0a3e3eb 100644
--- a/frysk-sys/frysk/rsl/Log.java
+++ b/frysk-sys/frysk/rsl/Log.java
@@ -39,6 +39,8 @@
 
 package frysk.rsl;
 
+import frysk.sys.Tid;
+import frysk.sys.Pid;
 import inua.util.PrintWriter;
 import java.io.PrintStream;
 import java.text.MessageFormat;
@@ -129,7 +131,7 @@ public final class Log {
 
     private static final long startTime = System.currentTimeMillis();
 
-    private void prefixTime() {
+    private void prefixTimeAndPid() {
 	long time = System.currentTimeMillis() - startTime;
 	long millis = time % 1000;
 	time = time / 1000;
@@ -140,8 +142,10 @@ public final class Log {
 	long hrs = time % 24;
 	time = time / 24;
 	long days = time;
-	out.print(days);
-	out.print(' ');
+	if (days > 0) {
+	    out.print(days);
+	    out.print(' ');
+	}
 	out.print(2, '0', hrs);
 	out.print(':');
 	out.print(2, '0', mins);
@@ -150,17 +154,21 @@ public final class Log {
 	out.print('.');
 	out.print(3, '0', millis);
 	out.print(' ');
+	out.print(Pid.get());
+	out.print('.');
+	out.print(Tid.get());
+	out.print(' ');
     }
 
     private void prefix() {
-	prefixTime();
+	prefixTimeAndPid();
 	out.print(path);
 	out.print(":");
     }
 
     private void prefix(Object o) {
-	prefixTime();
-	out.print(" [");
+	prefixTimeAndPid();
+	out.print("[");
 	out.print(o.toString());
 	out.print("]:");
     }


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


                 reply	other threads:[~2008-02-21  3:34 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=20080221033453.1070.qmail@sourceware.org \
    --to=cagney@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).