public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: swagiaal@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: swagiaal: created fdebugdump utility.
Date: Fri, 30 May 2008 19:39:00 -0000	[thread overview]
Message-ID: <20080530193944.1681.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  58f40db4bbb762811b00e7f6f4d6ff776fa90e3a (commit)
      from  5aee88eb9df989c6b3fa83f6c2dea8fe1ba7f605 (commit)

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

- Log -----------------------------------------------------------------
commit 58f40db4bbb762811b00e7f6f4d6ff776fa90e3a
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri May 30 15:38:41 2008 -0400

    swagiaal: created fdebugdump utility.
    
    frysk-core/frysk/bindir/ChangeLog
    +2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* fdebugdump.java: New utility.
    +	* TestDebugdump.java: New test.
    +
    
    frysk-core/frysk/dwfl/ChangeLog
    +2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* TestDwfl.java: New test.
    +
    
    frysk-sys/lib/dwfl/ChangeLog
    +2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* DwflModule.java: Added getCuDies().
    +	* cni/DwflModule.cxx: Added get_cu_dies().
    +

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog          |    5 +
 frysk-core/frysk/bindir/TestDebugdump.java |   62 +++++++++++++++
 frysk-core/frysk/bindir/fdebugdump.java    |   75 ++++++++++++++++++
 frysk-core/frysk/bindir/fdebugdump.xml-in  |  113 ++++++++++++++++++++++++++++
 frysk-core/frysk/dwfl/ChangeLog            |    4 +
 frysk-core/frysk/dwfl/TestDwfl.java        |   79 +++++++++++++++++++
 frysk-sys/lib/dwfl/ChangeLog               |    5 +
 frysk-sys/lib/dwfl/DwflModule.java         |    5 +
 frysk-sys/lib/dwfl/TestDwfl.java           |    3 +
 frysk-sys/lib/dwfl/cni/DwflModule.cxx      |   31 ++++++++
 10 files changed, 382 insertions(+), 0 deletions(-)
 create mode 100644 frysk-core/frysk/bindir/TestDebugdump.java
 create mode 100644 frysk-core/frysk/bindir/fdebugdump.java
 create mode 100644 frysk-core/frysk/bindir/fdebugdump.xml-in
 create mode 100644 frysk-core/frysk/dwfl/TestDwfl.java

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 80bb042..6a8823f 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* fdebugdump.java: New utility.
+	* TestDebugdump.java: New test.
+
 2008-05-30  Petr Machata  <pmachata@redhat.com>
 
 	* ftrace.java: Drop more of the PLT special casing.  Use
diff --git a/frysk-core/frysk/bindir/TestDebugdump.java b/frysk-core/frysk/bindir/TestDebugdump.java
new file mode 100644
index 0000000..f0637ea
--- /dev/null
+++ b/frysk-core/frysk/bindir/TestDebugdump.java
@@ -0,0 +1,62 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2006, 2007, 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
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// 
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+package frysk.bindir;
+
+import frysk.config.Prefix;
+import frysk.testbed.TearDownExpect;
+import frysk.testbed.TestLib;
+
+public class TestDebugdump extends TestLib {
+
+    public void testDebugdump() {
+
+	TearDownExpect e = new TearDownExpect(
+		new String[] {
+			Prefix.binFile("fdebugdump").getAbsolutePath(),
+			Prefix.pkgLibFile("funit-scopes-multi-file")
+				.getAbsolutePath() });
+
+	e.expect("funit-scopes-multi-file-a.c");
+	e.expect("first");
+	e.expect("second");
+	e.expect("funit-scopes-multi-file-b.c");
+    }
+
+}
diff --git a/frysk-core/frysk/bindir/fdebugdump.java b/frysk-core/frysk/bindir/fdebugdump.java
new file mode 100644
index 0000000..6d9f40c
--- /dev/null
+++ b/frysk-core/frysk/bindir/fdebugdump.java
@@ -0,0 +1,75 @@
+package frysk.bindir;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import lib.dwfl.DwarfDie;
+import lib.dwfl.Dwfl;
+import lib.dwfl.DwflModule;
+import frysk.dwfl.DwflCache;
+import frysk.isa.signals.Signal;
+import frysk.proc.Action;
+import frysk.proc.Task;
+import frysk.util.ProcRunUtil;
+import frysk.util.ProcRunUtil.ProcRunObserver;
+import frysk.util.ProcRunUtil.RunUtilOptions;
+import gnu.classpath.tools.getopt.OptionGroup;
+
+public class fdebugdump{
+
+    private static PrintWriter printWriter = new PrintWriter(System.out);
+    
+    public static void main(String[] args) {
+	RunUtilOptions options = new RunUtilOptions();
+	
+	OptionGroup[] customOptions = new OptionGroup[]{};
+	 
+	ProcRunUtil procRunUtil = new ProcRunUtil("fdebugdump", "fdebugdump <exe>", args, procRunObserver, customOptions, options);
+	procRunUtil.start();
+    }
+    
+    private static ProcRunObserver procRunObserver = new ProcRunObserver(){
+
+	public Action updateAttached(Task task) {
+	    Dwfl dwfl = DwflCache.getDwfl(task);
+	    DwflModule[] dwflModules = dwfl.getModules();
+	    for (int i = 0; i < dwflModules.length; i++) {
+		DwflModule module = dwflModules[i];
+		printWriter.println("module: " + module.getName());
+		Iterator iterator = module.getCuDies().iterator();
+		while (iterator.hasNext()) {
+		    DwarfDie die = (DwarfDie) iterator.next();
+		    printDie(die, " ");
+		}
+	    }
+	    return Action.CONTINUE;
+	}
+
+	public void addFailed(Object observable, Throwable w) {}
+
+	public void addedTo(Object observable) {}
+
+	public void deletedFrom(Object observable) {}
+
+	public Action updateForkedOffspring(Task parent, Task offspring) { return Action.CONTINUE; }
+	public Action updateForkedParent(Task parent, Task offspring) { return Action.CONTINUE; }
+	public Action updateExeced(Task task) { return Action.CONTINUE; }
+	public Action updateClonedParent(Task task, Task clone) { return Action.CONTINUE; }
+	public Action updateTerminated(Task task, Signal signal, int value) { return Action.CONTINUE; }
+	public Action updateClonedOffspring(Task parent, Task offspring) { return Action.CONTINUE; }
+	public void existingTask(Task task) {}
+	public void taskAdded(Task task) {}
+	public void taskRemoved(Task task) {}
+	
+    };
+    
+    private static void printDie(DwarfDie die, String indent){
+	printWriter.println(indent + die.getTag() + " " + die.getName());
+	
+	die = die.getChild();
+	while(die != null){
+	    printDie(die, indent+ "  ");
+	    die = die.getSibling();
+	}
+    }
+}
diff --git a/frysk-core/frysk/bindir/fdebugdump.xml-in b/frysk-core/frysk/bindir/fdebugdump.xml-in
new file mode 100644
index 0000000..4052be0
--- /dev/null
+++ b/frysk-core/frysk/bindir/fdebugdump.xml-in
@@ -0,0 +1,113 @@
+<?xml version='1.0'?> <!-- -*- xml -*- -->
+
+<!--
+
+ This file is part of the program FRYSK.
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ FRYSK is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with FRYSK; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ 
+ In addition, as a special exception, Red Hat, Inc. gives You the
+ additional right to link the code of FRYSK with code not covered
+ under the GNU General Public License ("Non-GPL Code") and to
+ distribute linked combinations including the two, subject to the
+ limitations in this paragraph. Non-GPL Code permitted under this
+ exception must only link to the code of FRYSK through those well
+ defined interfaces identified in the file named EXCEPTION found in
+ the source code files (the "Approved Interfaces"). The files of
+ Non-GPL Code may instantiate templates or use macros or inline
+ functions from the Approved Interfaces without causing the
+ resulting work to be covered by the GNU General Public
+ License. Only Red Hat, Inc. may make changes or additions to the
+ list of Approved Interfaces. You must obey the GNU General Public
+ License in all respects for all of the FRYSK code and other code
+ used in conjunction with FRYSK except the Non-GPL Code covered by
+ this exception. If you modify this file, you may extend this
+ exception to your version of the file, but you are not obligated to
+ do so. If you do not wish to provide this exception without
+ modification, you must delete this exception statement from your
+ version and license this file solely under the GPL without
+ exception.
+
+-->
+
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
+ [
+ <!ENTITY stackoptions SYSTEM "@abs_root_srcdir@/frysk-core/frysk/util/stack-options.xml">
+ <!ENTITY standardoptions SYSTEM "@abs_root_srcdir@/frysk-core/frysk/util/standard-options.xml">
+ <!ENTITY version SYSTEM "@abs_root_srcdir@/common/version.in">
+ <!ENTITY command "fdebugdump">
+ <!ENTITY volume "1">
+ ]
+>
+
+<refentry>
+
+  <refentryinfo>
+    <title>Frysk</title>
+    <date>May 2008</date>
+  </refentryinfo>
+  
+  <refmeta>
+    <refentrytitle>&command;</refentrytitle>
+    <manvolnum>&volume;</manvolnum>
+    <refmiscinfo class='source'>Frysk</refmiscinfo>
+    <refmiscinfo class='version'>&version;</refmiscinfo>
+  </refmeta>
+
+  <refnamediv>
+    <refname>fdebugdump</refname>
+    <refpurpose>dumps a hierarchy of the debug info dies</refpurpose>
+  </refnamediv>
+  
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>fdebugrpm</command>
+      <arg choice="req">
+	<replaceable>executable</replaceable>
+      </arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para><function>fdebugdump</function> 
+    runs the given program and dumps a hierarchical view of libraries
+    loaded at attach time.
+    
+    Does not watch for loading of new modules, but that would be a
+    good extension.
+    </para>
+
+  </refsect1>
+  
+  <refsect1>
+    <title>EXAMPLE</title>
+    <screen>&command; ls</screen>
+  </refsect1>
+
+  <refsect1>
+    <title>SEE ALSO</title>
+    <para>frysk(7)</para>
+  </refsect1>
+  
+  <refsect1>
+    <title>BUGS</title>
+    <para>Report bugs to <ulink url="http://sourceware.org/frysk"/></para>
+  </refsect1>
+  
+</refentry>
diff --git a/frysk-core/frysk/dwfl/ChangeLog b/frysk-core/frysk/dwfl/ChangeLog
index 74753ad..eb036cb 100644
--- a/frysk-core/frysk/dwfl/ChangeLog
+++ b/frysk-core/frysk/dwfl/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* TestDwfl.java: New test.
+
 2008-04-17  Andrew Cagney  <cagney@redhat.com>
 
 	* TestElfSectionCache.java: Use frysk.config.Prefix.
diff --git a/frysk-core/frysk/dwfl/TestDwfl.java b/frysk-core/frysk/dwfl/TestDwfl.java
new file mode 100644
index 0000000..3d56b11
--- /dev/null
+++ b/frysk-core/frysk/dwfl/TestDwfl.java
@@ -0,0 +1,79 @@
+// This file is part of the program FRYSK.
+//
+// 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
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// 
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+package frysk.dwfl;
+
+import java.util.Iterator;
+import java.util.List;
+
+import lib.dwfl.DwarfDie;
+import lib.dwfl.Dwfl;
+import lib.dwfl.DwflModule;
+import frysk.proc.Task;
+import frysk.testbed.DaemonBlockedAtSignal;
+import frysk.testbed.TestLib;
+
+public class TestDwfl
+    extends TestLib
+{
+    public void testGetCuDies(){
+	      Task task = (new DaemonBlockedAtSignal("funit-scopes-multi-file")).getMainTask();
+	      Dwfl dwfl = DwflCache.getDwfl(task);
+	      DwflModule[] modules = dwfl.getModules();
+	      boolean foundit = false;
+	      
+	      for (int i = 0; i < modules.length; i++) {
+		if(modules[i].getName().contains("funit-scopes-multi-file")){
+		    foundit = true;
+		    
+		    List cuDies = modules[i].getCuDies();
+		    assertEquals("Correct number of compilation units", cuDies.size(),2);
+		    
+		    Iterator iterator = cuDies.iterator();
+		    DwarfDie cudie = (DwarfDie) iterator.next();
+		    assertTrue("Correct cu found", cudie.getName().contains("funit-scopes-multi-file-a.c"));
+		    
+		    cudie = (DwarfDie) iterator.next();
+		    assertTrue("Correct cu found", cudie.getName().contains("funit-scopes-multi-file-b.c"));
+		}
+	    }
+	      
+	      assertTrue("Module was found", foundit);
+	  }
+}
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index 29ea8b2..f4180ea 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-30  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* DwflModule.java: Added getCuDies().
+	* cni/DwflModule.cxx: Added get_cu_dies().
+	
 2008-05-26  Andrew Cagney  <cagney@redhat.com>
 
 	* cni/ElfData.cxx (internal_buffer): Delete extern declaration.
diff --git a/frysk-sys/lib/dwfl/DwflModule.java b/frysk-sys/lib/dwfl/DwflModule.java
index 69cdb9a..4e1ab2f 100644
--- a/frysk-sys/lib/dwfl/DwflModule.java
+++ b/frysk-sys/lib/dwfl/DwflModule.java
@@ -136,4 +136,9 @@ public class DwflModule
      * @return path to debuginfo package if found, NULL otherwise 
      */
     public native String getDebuginfo();
+    
+    public LinkedList getCuDies(){
+	return get_cu_dies();
+    }
+    private native LinkedList get_cu_dies();
 }
diff --git a/frysk-sys/lib/dwfl/TestDwfl.java b/frysk-sys/lib/dwfl/TestDwfl.java
index ccd301b..87114d0 100644
--- a/frysk-sys/lib/dwfl/TestDwfl.java
+++ b/frysk-sys/lib/dwfl/TestDwfl.java
@@ -43,9 +43,12 @@ import java.io.File;
 import java.util.Iterator;
 import java.util.List;
 
+import frysk.dwfl.DwflCache;
 import frysk.junit.Runner;
 import frysk.junit.TestCase;
+import frysk.proc.Task;
 import frysk.sys.Pid;
+import frysk.testbed.DaemonBlockedAtSignal;
 import frysk.testbed.LocalMemory;
 
 public class TestDwfl
diff --git a/frysk-sys/lib/dwfl/cni/DwflModule.cxx b/frysk-sys/lib/dwfl/cni/DwflModule.cxx
index c2ea1a1..5a67e59 100644
--- a/frysk-sys/lib/dwfl/cni/DwflModule.cxx
+++ b/frysk-sys/lib/dwfl/cni/DwflModule.cxx
@@ -449,3 +449,34 @@ lib::dwfl::DwflModule::offdie(jlong die, jlong offset){
    
   return dwarfDie;
 }
+
+java::util::LinkedList*
+lib::dwfl::DwflModule::get_cu_dies()
+{
+	
+	java::util::LinkedList* list = new java::util::LinkedList();
+    
+    Dwarf_Die* cu;
+    Dwarf_Die lastcu;
+    Dwarf_Addr bias;
+    
+    cu = dwfl_module_nextcu((::Dwfl_Module*)this->pointer, NULL, &bias);
+    
+    fflush(stdout);
+    while ( cu != NULL){
+  	  
+      Dwarf_Die *die = (Dwarf_Die*)JvMalloc(sizeof(Dwarf_Die));
+  				
+  	  memcpy(die, cu, sizeof(*die));
+  	  lib::dwfl::DwarfDie* cuDie = lib::dwfl::DwarfDieFactory::getFactory()->makeDie((jlong)die, NULL);
+  	  cuDie->setManageDie(true);
+  	  
+  	  list->add(cuDie);
+  	  
+  	  memcpy(&lastcu, cu, sizeof(*cu));
+      cu = dwfl_module_nextcu((::Dwfl_Module*)this->pointer, &lastcu, &bias);
+      
+    }
+	  
+  return list;
+}


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


                 reply	other threads:[~2008-05-30 19:39 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=20080530193944.1681.qmail@sourceware.org \
    --to=swagiaal@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).