public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: pmuldoon@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM] master: Adds fmaps command
Date: Mon, 10 Dec 2007 14:49:00 -0000 [thread overview]
Message-ID: <20071210144944.4051.qmail@sourceware.org> (raw)
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 <pmuldoon@redhat.com>
Date: Mon Dec 10 14:49:33 2007 +0000
Adds fmaps command
2007-12-10 Phil Muldoon <pmuldoon@redhat.com>
* 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 <pmuldoon@redhat.com>
+
+ * fmaps.java: New.
+ * fmaps.xml: New.
+ * TestFmaps.java: New.
+
2007-11-30 Petr Machata <pmachata@redhat.com>
* 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<maps.length; i++)
+ System.out.println(maps[i].toString());
}
- if (offset == -1)
- throw new RuntimeException("Cannot find memory in exe file");
-
- StatelessFile temp = new StatelessFile(new File(line.name));
- temp.pread(offset, buffer,0,1);
-
- return buffer[0];
- }
-
- protected void poke(long caret, int val) {
- throw new RuntimeException("Cannot poke into Executable. File bug.");
- }
-
+ };
+
+ parser.setHeader("Usage: fmaps <PID> || fmaps <COREFILE> [<EXEFILE>]");
+ 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 @@
<!-- http://docbook.sourceforge.net/snapshots/xsl/manpages/README -->
-<refentry id="fstack">
+<refentry id="fmaps">
<refentryinfo>
- <title>fstack</title>
- <date>September 20 2006</date>
+ <title>fmaps</title>
+ <date>December 10 2007</date>
</refentryinfo>
<refmeta>
- <refentrytitle>fstack</refentrytitle>
+ <refentrytitle>fmaps</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
- <refname>fstack</refname>
- <refpurpose>Runs the frysk stack trace utility</refpurpose>
+ <refname>fmaps</refname>
+ <refpurpose>Prints out a process or a corefile's maps.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
- <command>fstack</command>
- <arg choice="opt">
+ <command>fmaps</command>
+ <arg choice="opt">
<option>--console <replaceable>LOG=LEVEL,...</replaceable></option>
</arg>
<arg choice="opt">
<option>--log <replaceable>LOG=LEVEL,...</replaceable></option>
</arg>
- <arg rep="repeat" choice="plain">
- <replaceable>pids</replaceable>
+ <arg rep="repeat" choice="plain">
+ <replaceable>pids corefile</replaceable>
</arg>
- <!-- arg choice="opt">
- <option>-list of options</option>
- </arg -->
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
- <para><function>fstack</function> Runs the frysk stack tracing utility.</para>
+ <para><function>fmaps</function> Executes the frysk map dump utility.</para>
- <para>fstack is a small utility that uses the frysk engine to display a process stack in a similar manner to pstack. </para>
+ <para>fmaps is a utility that prints out a process or a corefile's maps. </para>
<variablelist>
- <varlistentry>
+ <varlistentry>
<term><option>--console <replaceable>LOG=LEVEL,...</replaceable></option></term>
<listitem>
<para> Enable logging to the console and at the specified
@@ -103,7 +100,7 @@
<listitem>
<para> Specify the file logging level. The log level can be: [ OFF | SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST].</para>
</listitem>
- </varlistentry>
+ </varlistentry>
</variablelist>
</refsect1>
@@ -129,7 +126,7 @@
<refsect1>
<title>EXAMPLE</title>
- <screen>fstack pid [...]</screen>
+ <screen>fcore pid [...]</screen>
</refsect1>
<!-- refsect1>
@@ -144,7 +141,7 @@
<refsect1>
<title>SEE ALSO</title>
- <para>funit(8) fcatch(1) fstack(1) fstep(1) ftrace(1)</para>
+ <para>fexe(1) funit(8) fcatch(1) fhpd(1) fstack(1) fstep(1) ftrace(1)</para>
</refsect1>
<!-- refsect1>
@@ -164,8 +161,8 @@
<refsect1>
<title>BUGS</title>
- <para>Report bugs to <ulink url="http:/sources.redhat.com/frysk">
- http://sources.redhat.com/frysk/ </ulink>. </para>
+ <para>Report bugs to <ulink url="http://sources.redhat.com/frysk">
+ http://sources.redhat.com/frysk </ulink></para>
</refsect1>
<!-- refsect1>
hooks/post-receive
--
frysk system monitor/debugger
reply other threads:[~2007-12-10 14:49 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=20071210144944.4051.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: 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).