From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18121 invoked by alias); 28 Feb 2008 21:25:50 -0000 Received: (qmail 18095 invoked by uid 9514); 28 Feb 2008 21:25:50 -0000 Date: Thu, 28 Feb 2008 21:25:00 -0000 Message-ID: <20080228212550.18079.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add --segment= dumping strategy. Delete --stackonly dumping strategy. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 1b5a098d45d2565f472285dde9d990b90c33460a X-Git-Newrev: 058aac11987b42390a7a179274227d4735d41f19 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00281.txt.bz2 The branch, master has been updated via 058aac11987b42390a7a179274227d4735d41f19 (commit) from 1b5a098d45d2565f472285dde9d990b90c33460a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 058aac11987b42390a7a179274227d4735d41f19 Author: Phil Muldoon Date: Thu Feb 28 21:24:56 2008 +0000 Add --segment= dumping strategy. Delete --stackonly dumping strategy. 2008-02-28 Phil Muldoon * fcore.xml: Add --segments option. Delete --stackonly option. * fcore.java (addOptions): Delete stack only option. Add segments option. 2008-02-28 Phil Muldoon * TestLinuxElfCorefile.java (constructStackOnlyCore): Delete. (testStackOnlyMap): Delete. (testRegexSelectedMap): New. (giveMeABlockedProc): Delete comments and remove unecessary proc creations. * LinuxElfCorefile.java (setStackOnly): Delete. (buildMap): Add in regex code. Implement selective 2008-02-28 Phil Muldoon * CoredumpAction.java: Remove stack only constructor. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 7 ++ frysk-core/frysk/bindir/fcore.java | 112 +++++++++++--------- frysk-core/frysk/bindir/fcore.xml | 4 +- frysk-core/frysk/isa/corefiles/ChangeLog | 10 ++ .../frysk/isa/corefiles/LinuxElfCorefile.java | 61 ++++++----- .../frysk/isa/corefiles/TestLinuxElfCorefile.java | 76 ++++++-------- frysk-core/frysk/testbed/ChangeLog | 5 + frysk-core/frysk/testbed/CoredumpAction.java | 17 --- 8 files changed, 147 insertions(+), 145 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index c2f4788..2f6f7a1 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,10 @@ +2008-02-28 Phil Muldoon + + * fcore.xml: Add --segments option. Delete + --stackonly option. + * fcore.java (addOptions): Delete stack only option. + Add segments option. + 2008-02-28 Teresa Thomas * fdebugrpm.sh: Show error message if fdebuginfo install diff --git a/frysk-core/frysk/bindir/fcore.java b/frysk-core/frysk/bindir/fcore.java index a6a2239..dc81c90 100644 --- a/frysk-core/frysk/bindir/fcore.java +++ b/frysk-core/frysk/bindir/fcore.java @@ -54,9 +54,11 @@ import gnu.classpath.tools.getopt.OptionException; public class fcore { + private static String matchingRegEx = ""; private static String filename = "core"; private static boolean writeAllMaps = false; - private static boolean stackOnly = false; + + private static int mapOptionCount = 0; protected static final Logger logger = Logger.getLogger("frysk"); /** @@ -79,54 +81,55 @@ public class fcore */ private static void addOptions (ProcStopUtil fcore) { - fcore.addOption(new Option("stackonly", 's', - " Writes only stack segment, and elides all" - + " other maps.") - { - public void parsed (String mapsValue) throws OptionException { - try { - stackOnly = true; - } catch (IllegalArgumentException e) { - throw new OptionException( "Invalid maps parameter " - + mapsValue); - } - - } - }); fcore.addOption(new Option( "allmaps", 'a', " Writes all readable maps. Does not elide" + " or omit any readable map. Caution: could" + " take considerable amount of time to" + " construct core file.") - { - public void parsed (String mapsValue) throws OptionException { - try { - writeAllMaps = true; - stackOnly = false; - } catch (IllegalArgumentException e) { - throw new OptionException("Invalid maps parameter " + mapsValue); + { + public void parsed (String mapsValue) throws OptionException { + try { + writeAllMaps = true; + mapOptionCount++; + } catch (IllegalArgumentException e) { + throw new OptionException("Invalid maps parameter " + mapsValue); + } + } - - } - }); + }); + + fcore.addOption(new Option("segments", 's', + "Define what segments to include via regex.", + "RegEx") { + public void parsed(String regEx) throws OptionException { + try { + mapOptionCount++; + matchingRegEx = regEx; + } catch (IllegalArgumentException e) { + throw new OptionException("Invalid match parameter " + + matchingRegEx); + } + } + }); + + fcore.addOption(new Option( "outputfile", 'o', " Sets the name (not extension) of the core" + " file. Default is core.{pid}. The extension" - + " will always be the pid.", "") - { - public void parsed (String filenameValue) throws OptionException + + " will always be the pid.", "") { - try { + public void parsed (String filenameValue) throws OptionException { + try { filename = filenameValue; + } + catch (IllegalArgumentException e) { + throw new OptionException( "Invalid output filename: " + + filenameValue); + } } - catch (IllegalArgumentException e) { - throw new OptionException( "Invalid output filename: " - + filenameValue); - } - } - }); + }); } /** @@ -136,24 +139,31 @@ public class fcore { public void executeLive(Proc proc) { - Task[] tasks = (Task[]) proc.getTasks().toArray - (new Task[proc.getTasks().size()]); - LinuxElfCorefile coreFile = LinuxElfCorefileFactory. - getCorefile(proc, tasks); + - if (coreFile == null) { - System.err.println ( "Architecture not supported or " - + "LinuxElfCorefileFactory returned null"); - } else { - coreFile.setName(filename); - coreFile.setWriteAllMaps(writeAllMaps); - coreFile.setStackOnly(stackOnly); - - try { - coreFile.constructCorefile(); - } catch (RuntimeException e) { + if (mapOptionCount > 1) + System.err.println("Please either speciy -stackonly,"+ + " -allmaps, or -match for map writing."); + else { + Task[] tasks = (Task[]) proc.getTasks().toArray + (new Task[proc.getTasks().size()]); + LinuxElfCorefile coreFile = LinuxElfCorefileFactory. + getCorefile(proc, tasks); + + if (coreFile == null) { System.err.println ( "Architecture not supported or " - + "LinuxElfCorefileFactory returned null"); + + "LinuxElfCorefileFactory returned null"); + } else { + coreFile.setName(filename); + coreFile.setWriteAllMaps(writeAllMaps); + coreFile.setPatternMatch(matchingRegEx); + + try { + coreFile.constructCorefile(); + } catch (RuntimeException e) { + System.err.println ( "Architecture not supported or " + + "LinuxElfCorefileFactory returned null"); + } } } } diff --git a/frysk-core/frysk/bindir/fcore.xml b/frysk-core/frysk/bindir/fcore.xml index 407db94..0f63fad 100644 --- a/frysk-core/frysk/bindir/fcore.xml +++ b/frysk-core/frysk/bindir/fcore.xml @@ -107,9 +107,9 @@ - + - Writes only the stack segment. Elide all other segments. + Writes only the segments that match the regex specified. Elide all other segments. diff --git a/frysk-core/frysk/isa/corefiles/ChangeLog b/frysk-core/frysk/isa/corefiles/ChangeLog index 0cd6d0f..790d374 100644 --- a/frysk-core/frysk/isa/corefiles/ChangeLog +++ b/frysk-core/frysk/isa/corefiles/ChangeLog @@ -1,5 +1,15 @@ 2008-02-28 Phil Muldoon + * TestLinuxElfCorefile.java (constructStackOnlyCore): Delete. + (testStackOnlyMap): Delete. + (testRegexSelectedMap): New. + (giveMeABlockedProc): Delete comments and remove unecessary + proc creations. + + * LinuxElfCorefile.java (setStackOnly): Delete. + (buildMap): Add in regex code. Implement selective + segment code. + * TestLinuxElfCorefile.java: Move and rename from frysk/testbed/TestCoredumpAction.java. diff --git a/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java b/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java index 9999d52..dd6c686 100644 --- a/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java +++ b/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java @@ -57,12 +57,15 @@ import frysk.proc.Task; import frysk.sys.StatelessFile; import frysk.sys.proc.MapsBuilder; import java.io.File; +import java.util.regex.Pattern; +import java.util.regex.Matcher; public abstract class LinuxElfCorefile { long elfSectionOffset = 0; String coreName = "core"; + String regex = ""; Proc process = null; @@ -70,7 +73,7 @@ public abstract class LinuxElfCorefile { boolean writeAllMaps = false; - boolean stackOnly = true; + boolean regexMatch = false; Elf linuxElfCorefileImage = null; @@ -101,19 +104,11 @@ public abstract class LinuxElfCorefile { } - /** - * - * Defines whether to write only the stack segment and elide all others. - * - * @param maps - True if attempt to write all maps, false to follow - * map writing convention. - * - */ - - public void setStackOnly(boolean stackOnly) { - this.stackOnly = stackOnly; + public void setPatternMatch(String regex) { + this.regex = regex; + if (!this.regex.equals("")) + this.regexMatch = true; } - /** * * Set the name of the corefile to be constructed. This should be @@ -466,10 +461,13 @@ public abstract class LinuxElfCorefile { Dwfl dwfl = null; Elf elf; + Pattern pattern; CoreMapsBuilder() { dwfl = DwflCache.getDwfl(process.getMainTask()); + if (regexMatch) + pattern = Pattern.compile(regex); } public void buildBuffer(final byte[] maps) { @@ -495,9 +493,19 @@ public abstract class LinuxElfCorefile { pathnameLength); String sfilename = new String(filename); + if (writeAllMaps) { writeMap = true; + } + + + if (regexMatch) { + Matcher match = pattern.matcher(sfilename); + if (match.find()) { + writeMap = true; + } } else { + // Should the map be written? if (inode == 0) writeMap = true; @@ -511,25 +519,18 @@ public abstract class LinuxElfCorefile { writeMap = true; if (shared) writeMap = true; - } - - if (!writeMap) { - DwflModule module = null; - if (dwfl != null) { - module = dwfl.getModule(addressLow); - if (module != null) - if (module.getElf() == null) - writeMap = true; - } - } + - if (stackOnly) { - if (sfilename.equals("[stack]") || sfilename.equals("[vdso]")) - writeMap = true; - else - writeMap = false; + if (!writeMap) { + DwflModule module = null; + if (dwfl != null) { + module = dwfl.getModule(addressLow); + if (module != null) + if (module.getElf() == null) + writeMap = true; + } + } } - // Get empty progam segment header corresponding to this entry. // PT_NOTE's program header entry takes the index: 0. So we should diff --git a/frysk-core/frysk/isa/corefiles/TestLinuxElfCorefile.java b/frysk-core/frysk/isa/corefiles/TestLinuxElfCorefile.java index 247cb82..5b93010 100644 --- a/frysk-core/frysk/isa/corefiles/TestLinuxElfCorefile.java +++ b/frysk-core/frysk/isa/corefiles/TestLinuxElfCorefile.java @@ -57,13 +57,15 @@ import frysk.proc.Auxv; import frysk.proc.Manager; import frysk.proc.MemoryMap; import frysk.proc.Proc; +import frysk.proc.Task; import frysk.proc.ProcBlockAction; import frysk.proc.dead.LinuxCoreFactory; import frysk.testbed.DaemonBlockedAtEntry; import frysk.testbed.SlaveOffspring; import frysk.testbed.TestLib; import frysk.testbed.CoredumpAction; - +import frysk.isa.corefiles.LinuxElfCorefile; + import frysk.isa.corefiles.LinuxElfCorefileFactory; public class TestLinuxElfCorefile extends TestLib { @@ -223,20 +225,22 @@ public class TestLinuxElfCorefile } - public void testStackOnlyMap () + public void testRegexSelectedMap () { - Proc ackProc = giveMeAProc(); - MemoryMap stackMap = null; + Proc ackProc = giveMeABlockedProc(); + MemoryMap stackMap = null, vdsoMap = null; MemoryMap coreMap = null; + // Create a corefile from process - String coreFileName = constructStackOnlyCore(ackProc); - File testCore = new File(coreFileName); - - assertTrue("Checking core file " + coreFileName + " exists.", - testCore.exists()); + LinuxElfCorefile core = + LinuxElfCorefileFactory.getCorefile(ackProc, + (Task[])ackProc.getTasks().toArray(new Task[0])); + + core.setPatternMatch("stack|vdso"); + core.constructCorefile(); // Model the corefile, and get the Process. - Proc coreProc = LinuxCoreFactory.createProc(testCore, + Proc coreProc = LinuxCoreFactory.createProc(new File(core.getConstructedFileName()), new File(ackProc.getExe())); assertNotNull("Checking core file process", coreProc); @@ -244,18 +248,28 @@ public class TestLinuxElfCorefile MemoryMap[] liveMaps = ackProc.getMaps(); for(int i=0; i + + * CoredumpAction.java: Remove stack only + constructor. + 2008-02-28 Teresa Thomas * CorefileFactory.java: Remove redundant import. diff --git a/frysk-core/frysk/testbed/CoredumpAction.java b/frysk-core/frysk/testbed/CoredumpAction.java index 6a26ca5..36683a7 100644 --- a/frysk-core/frysk/testbed/CoredumpAction.java +++ b/frysk-core/frysk/testbed/CoredumpAction.java @@ -72,8 +72,6 @@ public class CoredumpAction implements ProcObserver.ProcAction { private boolean writeAllMaps = false; - private boolean stackOnly = false; - private LinuxElfCorefile coreFile; int taskArraySize = 1; @@ -101,20 +99,6 @@ public class CoredumpAction implements ProcObserver.ProcAction { Manager.eventLoop.add(new InterruptEvent(proc)); } - /** hooks/post-receive -- frysk system monitor/debugger