public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Set -stackonly option in corefiles. Date: Tue, 19 Feb 2008 13:56:00 -0000 [thread overview] Message-ID: <20080219135639.30380.qmail@sourceware.org> (raw) The branch, master has been updated via 764c4238327cee1cd0bb5f682d7cef444e14e0f9 (commit) from 17fb5b9b3faefee0f4190a7f3de42feaba15f16b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 764c4238327cee1cd0bb5f682d7cef444e14e0f9 Author: Phil Muldoon <pmuldoon@redhat.com> Date: Tue Feb 19 13:56:28 2008 +0000 Set -stackonly option in corefiles. 2008-02-19 Phil Muldoon <pmuldoon@redhat.com> * CoredumpAction.java: Add stacjOnly parameter. * TestCoredumpAction.java (testStackOnlyMap): New. 2008-02-19 Phil Muldoon <pmuldoon@redhat.com> * fcore.xml: Add -stack option. * fcore.java (dumpPids): Add stackOnly parameter. (addOptions): Ditto. 2008-02-19 Phil Muldoon <pmuldoon@redhat.com> * LinuxElfCorefile.java (buildMap): Add stackOnly logic test. (setStackOnly): New. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 6 ++ frysk-core/frysk/bindir/fcore.java | 28 ++++++- frysk-core/frysk/bindir/fcore.xml | 11 ++- frysk-core/frysk/isa/corefiles/ChangeLog | 6 ++ .../frysk/isa/corefiles/LinuxElfCorefile.java | 25 ++++++ frysk-core/frysk/util/ChangeLog | 6 ++ frysk-core/frysk/util/CoredumpAction.java | 9 ++- frysk-core/frysk/util/TestCoredumpAction.java | 91 +++++++++++++++++++- 8 files changed, 174 insertions(+), 8 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 5fb4cf3..a35ab8d 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,9 @@ +2008-02-19 Phil Muldoon <pmuldoon@redhat.com> + + * fcore.xml: Add -stack option. + * fcore.java (dumpPids): Add stackOnly parameter. + (addOptions): Ditto. + 2008-02-15 Sami Wagiaalla <swagiaal@redhat.com> * fstack.java: Added printing of virtual frames to -c. diff --git a/frysk-core/frysk/bindir/fcore.java b/frysk-core/frysk/bindir/fcore.java index 0a41bff..6a92ba4 100644 --- a/frysk-core/frysk/bindir/fcore.java +++ b/frysk-core/frysk/bindir/fcore.java @@ -60,6 +60,8 @@ public class fcore private static boolean writeAllMaps = false; + private static boolean stackOnly = false; + private static CoredumpAction stacker; protected static final Logger logger = Logger.getLogger("frysk"); @@ -90,7 +92,8 @@ public class fcore public static void dumpPid(Proc proc) { stacker = new CoredumpAction(proc, filename, new AbandonCoreEvent(proc), - writeAllMaps); + writeAllMaps, + stackOnly); new ProcBlockAction(proc, stacker); Manager.eventLoop.run(); } @@ -116,7 +119,7 @@ public class fcore addOptions(parser); - parser.setHeader("Usage: fcore [-a] [-o filename] [-c level] [-l level] <pids>"); + parser.setHeader("Usage: fcore [-a] [-stack] [-o filename] [-c level] [-l level] <pids>"); parser.parse(args); @@ -134,6 +137,25 @@ public class fcore private static void addOptions (CommandlineParser parser) { + parser.add(new Option("stack", '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); + } + + } + }); + parser.add(new Option("allmaps", 'a', " Writes all readable maps. Does not elide" + " or omit any readable map. Caution: could" @@ -145,7 +167,7 @@ public class fcore try { writeAllMaps = true; - + stackOnly = false; } catch (IllegalArgumentException e) { diff --git a/frysk-core/frysk/bindir/fcore.xml b/frysk-core/frysk/bindir/fcore.xml index 619c8ff..04ca062 100644 --- a/frysk-core/frysk/bindir/fcore.xml +++ b/frysk-core/frysk/bindir/fcore.xml @@ -4,7 +4,7 @@ This file is part of the program FRYSK. - Copyright 2006, Red Hat Inc. + Copyright 2006, 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 @@ -72,6 +72,9 @@ <option>-a </option> </arg> <arg choice="opt"> + <option>-s </option> + </arg> + <arg choice="opt"> <option>-o <replaceable>filename</replaceable></option> </arg> <arg choice="opt"> @@ -104,6 +107,12 @@ </listitem> </varlistentry> <varlistentry> + <term><option>-s, -stack</option></term> + <listitem> + <para> Writes only the stack segment. Elide all other segments. </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>-o <replaceable>output-file</replaceable></option></term> <listitem> <para> Specifies the name of the core file. Default is core. diff --git a/frysk-core/frysk/isa/corefiles/ChangeLog b/frysk-core/frysk/isa/corefiles/ChangeLog index 1ba5a85..f7308cd 100644 --- a/frysk-core/frysk/isa/corefiles/ChangeLog +++ b/frysk-core/frysk/isa/corefiles/ChangeLog @@ -1,3 +1,9 @@ +2008-02-19 Phil Muldoon <pmuldoon@redhat.com> + + * LinuxElfCorefile.java (buildMap): Add stackOnly + logic test. + (setStackOnly): New. + 2008-02-15 Phil Muldoon <pmuldoon@redhat.com> * PPC64LinuxElfCorefile.java (writeNotePrpsinfo): Fix diff --git a/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java b/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java index 4eb8d03..1bda4b3 100644 --- a/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java +++ b/frysk-core/frysk/isa/corefiles/LinuxElfCorefile.java @@ -71,6 +71,8 @@ public abstract class LinuxElfCorefile { Task[] blockedTasks; boolean writeAllMaps = false; + + boolean stackOnly = true; Elf linuxElfCorefileImage = null; @@ -100,6 +102,20 @@ public abstract class LinuxElfCorefile { this.writeAllMaps = maps; } + + /** + * + * 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; + } + /** * * Set the name of the corefile to be constructed. This should be @@ -540,6 +556,15 @@ public abstract class LinuxElfCorefile { writeMap = true; } } + + if (stackOnly) { + if (sfilename.equals("[stack]")) + writeMap = true; + else + writeMap = false; + } + + // Get empty progam segment header corresponding to this entry. // PT_NOTE's program header entry takes the index: 0. So we should // begin from 1. diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog index 00da2d8..763b1ec 100644 --- a/frysk-core/frysk/util/ChangeLog +++ b/frysk-core/frysk/util/ChangeLog @@ -1,3 +1,9 @@ +2008-02-19 Phil Muldoon <pmuldoon@redhat.com> + + * CoredumpAction.java: Add stacjOnly parameter. + * TestCoredumpAction.java (testStackOnlyMap): New. + + 2008-02-14 Andrew Cagney <cagney@redhat.com> * CommandlineParser.java (parsePids(Proc[])): Replace diff --git a/frysk-core/frysk/util/CoredumpAction.java b/frysk-core/frysk/util/CoredumpAction.java index 5ae0aa6..b17ca81 100644 --- a/frysk-core/frysk/util/CoredumpAction.java +++ b/frysk-core/frysk/util/CoredumpAction.java @@ -72,6 +72,8 @@ public class CoredumpAction implements ProcObserver.ProcAction { private boolean writeAllMaps = false; + private boolean stackOnly = false; + private LinuxElfCorefile coreFile; int taskArraySize = 1; @@ -107,11 +109,11 @@ public class CoredumpAction implements ProcObserver.ProcAction { * @param writeAllMaps - Should all maps be written. */ public CoredumpAction(Proc proc, String filename, Event theEvent, - boolean writeAllMaps) { + boolean writeAllMaps, boolean stackOnly) { this(proc, theEvent, writeAllMaps); this.filename = filename; - + this.stackOnly = stackOnly; } /* (non-Javadoc) @@ -154,7 +156,8 @@ public class CoredumpAction implements ProcObserver.ProcAction { } else { coreFile.setName(this.filename); - coreFile.setWriteAllMaps(writeAllMaps); + coreFile.setWriteAllMaps(this.writeAllMaps); + coreFile.setStackOnly(this.stackOnly); try { coreFile.constructCorefile(); diff --git a/frysk-core/frysk/util/TestCoredumpAction.java b/frysk-core/frysk/util/TestCoredumpAction.java index d97bf55..8cf78d4 100644 --- a/frysk-core/frysk/util/TestCoredumpAction.java +++ b/frysk-core/frysk/util/TestCoredumpAction.java @@ -51,6 +51,7 @@ import lib.dwfl.ElfEMachine; import lib.dwfl.ElfException; import lib.dwfl.ElfFileException; import lib.dwfl.ElfKind; +import lib.dwfl.ElfPHeader; import frysk.event.Event; import frysk.event.RequestStopEvent; import frysk.isa.ISA; @@ -232,7 +233,70 @@ public class TestCoredumpAction testCore.delete(); } -/** + + public void testStackOnlyMap () + { + Proc ackProc = giveMeAProc(); + MemoryMap stackMap = 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()); + + // Model the corefile, and get the Process. + LinuxCoreHost lcoreHost = new LinuxCoreHost(Manager.eventLoop, + testCore,new File(ackProc.getExe())); + + assertNotNull("Checking core file Host", lcoreHost); + + // Get corefile process + Proc coreProc = lcoreHost.getSoleProcFIXME(); + assertNotNull("Checking core file process", coreProc); + + MemoryMap[] coreMaps = coreProc.getMaps(); + MemoryMap[] liveMaps = ackProc.getMaps(); + + for(int i=0; i<liveMaps.length; i++) { + if (liveMaps[i].name.equals("[stack]")) { + stackMap = liveMaps[i]; + break; + } + } + + assertNotNull("Cannot find stack in live process", stackMap); + int mapNo = findLowAddress(stackMap.addressLow, coreMaps); + coreMap = coreMaps[mapNo]; + assertNotNull("Cannot find stack in core process", coreMap); + + Elf testElf = null; + try { + testElf = new Elf (coreFileName, + ElfCommand.ELF_C_READ); + } catch(Exception e) { + fail("Cannot open elf file"+coreFileName); + } + + ElfEHeader header = testElf.getEHeader(); + int count = header.phnum; + int segCount = 0; + + for (int i = 0; i < count; i++) + { + ElfPHeader pheader = testElf.getPHeader(i); + assertNotNull(pheader); + if(pheader.filesz > 0) + segCount++; + } + testElf.close(); + + assertEquals("stack only corefile segCount +stack +notes != 2",segCount,2); + } + + + /** * Given a Proc object, generate a core file from that given proc. * * @param ackProc - proc object to generate core from. @@ -256,6 +320,31 @@ public class TestCoredumpAction return coreDump.getConstructedFileName(); } + /** + * Given a Proc object, generate a core file from that given proc. + * + * @param ackProc - proc object to generate core from. + * @return - name of constructed core file. + */ + private String constructStackOnlyCore (final Proc ackProc) + { + + CoredumpAction coreDump = null; + coreDump = new CoredumpAction(ackProc, "core", + new Event() { + public void execute () { + ackProc. + requestAbandonAndRunEvent( + new RequestStopEvent( + Manager.eventLoop)); + } + }, false, true); + + new ProcBlockAction(ackProc, coreDump); + assertRunUntilStop("Running event loop for core file"); + return coreDump.getConstructedFileName(); + } + /** * Generate a process suitable for attaching to (ie detached when returned). hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-02-19 13:56 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=20080219135639.30380.qmail@sourceware.org \ --to=pmuldoon@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: linkBe 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).