From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4105 invoked by alias); 10 Dec 2007 14:49:49 -0000 Received: (qmail 4066 invoked by uid 9514); 10 Dec 2007 14:49:44 -0000 Date: Mon, 10 Dec 2007 14:49:00 -0000 Message-ID: <20071210144944.4051.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Adds fmaps command X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 898a3b520202dc904f4dbd2863380842bcf0e727 X-Git-Newrev: 4684fc99d954edfb96985ac678d4c1e8b45a8a2c 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: 2007-q4/txt/msg00551.txt.bz2 The branch, master has been updated via 4684fc99d954edfb96985ac678d4c1e8b45a8a2c (commit) from 898a3b520202dc904f4dbd2863380842bcf0e727 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 4684fc99d954edfb96985ac678d4c1e8b45a8a2c Author: Phil Muldoon Date: Mon Dec 10 14:49:33 2007 +0000 Adds fmaps command 2007-12-10 Phil Muldoon * fmaps.java: New. * fmaps.xml: New. * TestFmaps.java: New. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 6 ++ .../frysk/bindir/{TestFexe.java => TestFmaps.java} | 47 +++++++--- .../dead/ExeByteBuffer.java => bindir/fmaps.java} | 94 ++++++++++---------- frysk-core/frysk/bindir/{fstack.xml => fmaps.xml} | 41 ++++----- 4 files changed, 106 insertions(+), 82 deletions(-) copy frysk-core/frysk/bindir/{TestFexe.java => TestFmaps.java} (65%) copy frysk-core/frysk/{proc/dead/ExeByteBuffer.java => bindir/fmaps.java} (61%) copy frysk-core/frysk/bindir/{fstack.xml => fmaps.xml} (82%) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index c9fcddd..8e19593 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,9 @@ +2007-12-10 Phil Muldoon + + * fmaps.java: New. + * fmaps.xml: New. + * TestFmaps.java: New. + 2007-11-30 Petr Machata * ftrace.xml: Updated. diff --git a/frysk-core/frysk/bindir/TestFexe.java b/frysk-core/frysk/bindir/TestFmaps.java similarity index 65% copy from frysk-core/frysk/bindir/TestFexe.java copy to frysk-core/frysk/bindir/TestFmaps.java index adb9a70..c4dc03e 100644 --- a/frysk-core/frysk/bindir/TestFexe.java +++ b/frysk-core/frysk/bindir/TestFmaps.java @@ -43,21 +43,40 @@ import frysk.junit.TestCase; import frysk.expunit.Expect; import frysk.Config; import java.io.File; +import frysk.testbed.TearDownExpect; +import frysk.testbed.CoreFileAtSignal; -public class TestFexe - extends TestCase +public class TestFmaps + extends TestCase { - Expect e; - public void tearDown () { - if (e != null) - e.close (); - e = null; + + /** + * Start fmaps with both a core file and an executable; avoids + * problems with Linux's bone-head COREFILE format storing only + * the first 50 characters of the executable. + */ + private Expect fmaps(String program, String[] args) { + File coreExe = Config.getPkgLibFile(program); + File coreFile = CoreFileAtSignal.constructCore(coreExe); + String[] argv = new String[args.length + 3]; + int argc = 0; + argv[argc++] = Config.getBinFile("fmaps").getAbsolutePath(); + argv[argc++] = coreFile.getAbsolutePath(); + argv[argc++] = coreExe.getAbsolutePath(); + for (int i = 0; i < args.length; i++) { + argv[argc + i] = args[i]; } - - public void testExeOfPid() { - File fexe = Config.getBinFile("fexe"); - e = new Expect(fexe.getAbsolutePath () + " $$"); - e.expect(fexe + "\r\n"); - } - + Expect e = new Expect(argv); + TearDownExpect.add(e); + return e; + } + + // Basic sniff test, are we getting output that looks like a map? + // getMaps is tested in the frysk-core/proc namespalce + public void testExeOfPid() { + Expect e = fmaps("funit-stack-outlined", new String[0]); + e.expect("frysk/pkglibdir/funit-stack-outlined"); + e.expect("ld-"); + e.expect("libc"); + } } diff --git a/frysk-core/frysk/proc/dead/ExeByteBuffer.java b/frysk-core/frysk/bindir/fmaps.java similarity index 61% copy from frysk-core/frysk/proc/dead/ExeByteBuffer.java copy to frysk-core/frysk/bindir/fmaps.java index cde7b8d..82766e6 100644 --- a/frysk-core/frysk/proc/dead/ExeByteBuffer.java +++ b/frysk-core/frysk/bindir/fmaps.java @@ -37,60 +37,62 @@ // version and license this file solely under the GPL without // exception. -package frysk.proc.dead; +package frysk.bindir; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; - -import frysk.sys.StatelessFile; +import frysk.util.CommandlineParser; +import frysk.util.Util; +import frysk.proc.Proc; +import frysk.proc.ProcId; import frysk.proc.MemoryMap; +import java.io.File; +import frysk.util.CoreExePair; -import inua.eio.ByteBuffer; - -public class ExeByteBuffer extends ByteBuffer { - - ArrayList metaData = new ArrayList(); +public class fmaps { + + public static void main (String[] args) { + // Parse command line. Check pid provided. - protected ExeByteBuffer(long lowWater, long highWater) { - super(lowWater, highWater); - } - - public ExeByteBuffer(ArrayList metaData) - { - super(0,-1); + CommandlineParser parser = new CommandlineParser("fexe") { - this.metaData = metaData; - } - - protected int peek(long caret) { + public void parseCores (CoreExePair[] corePairs) { + for (int i = 0; i < corePairs.length; i++) { + File coreFile = corePairs[i].coreFile; + File exeFile = corePairs[i].exeFile; + Proc proc; + + if (exeFile == null) + proc = Util.getProcFromCoreFile(coreFile); + else + proc = Util.getProcFromCoreFile(coreFile, exeFile); + printMaps(proc.getMaps()); + } + + System.exit(0); + } - Iterator i = metaData.iterator(); - MemoryMap line = null; - long offset = -1; - byte[] buffer = new byte[1]; + public void parsePids (ProcId[] pids) { + for (int i= 0; i< pids.length; i++) { + ProcId id = pids[i]; + Proc proc = Util.getProcFromPid(id); + printMaps(proc.getMaps()); + } + System.exit(0); + } - while (i.hasNext()) + private void printMaps(MemoryMap[] maps) { - line = ((MemoryMap)i.next()); - if ((caret >= line.addressLow) && (caret<= line.addressHigh)) - { - offset = line.offset + (caret - line.addressLow); - break; - } + for(int i=0; i || fmaps []"); + parser.parse(args); + + //If we got here, we didn't find a pid. + System.err.println("Error: No PID or COREFILE."); + parser.printHelp(); + System.exit(1); + } } diff --git a/frysk-core/frysk/bindir/fstack.xml b/frysk-core/frysk/bindir/fmaps.xml similarity index 82% copy from frysk-core/frysk/bindir/fstack.xml copy to frysk-core/frysk/bindir/fmaps.xml index e4eb9f5..ec08dad 100644 --- a/frysk-core/frysk/bindir/fstack.xml +++ b/frysk-core/frysk/bindir/fmaps.xml @@ -4,7 +4,7 @@ This file is part of the program FRYSK. - Copyright 2006, Red Hat Inc. + Copyright 2007, 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 @@ -48,50 +48,47 @@ - + - fstack - September 20 2006 + fmaps + December 10 2007 - fstack + fmaps 1 - fstack - Runs the frysk stack trace utility + fmaps + Prints out a process or a corefile's maps. - fstack - + fmaps + - - pids + + pids corefile - DESCRIPTION - fstack Runs the frysk stack tracing utility. + fmaps Executes the frysk map dump utility. - fstack is a small utility that uses the frysk engine to display a process stack in a similar manner to pstack. + fmaps is a utility that prints out a process or a corefile's maps. - + Enable logging to the console and at the specified @@ -103,7 +100,7 @@ Specify the file logging level. The log level can be: [ OFF | SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST]. - + @@ -129,7 +126,7 @@ EXAMPLE - fstack pid [...] + fcore pid [...]