From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1726 invoked by alias); 30 May 2008 19:39:45 -0000 Received: (qmail 1696 invoked by uid 9561); 30 May 2008 19:39:44 -0000 Date: Fri, 30 May 2008 19:39:00 -0000 Message-ID: <20080530193944.1681.qmail@sourceware.org> From: swagiaal@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: swagiaal: created fdebugdump utility. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5aee88eb9df989c6b3fa83f6c2dea8fe1ba7f605 X-Git-Newrev: 58f40db4bbb762811b00e7f6f4d6ff776fa90e3a 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-q2/txt/msg00310.txt.bz2 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 Date: Fri May 30 15:38:41 2008 -0400 swagiaal: created fdebugdump utility. frysk-core/frysk/bindir/ChangeLog +2008-05-30 Sami Wagiaalla + + * fdebugdump.java: New utility. + * TestDebugdump.java: New test. + frysk-core/frysk/dwfl/ChangeLog +2008-05-30 Sami Wagiaalla + + * TestDwfl.java: New test. + frysk-sys/lib/dwfl/ChangeLog +2008-05-30 Sami Wagiaalla + + * 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 + + * fdebugdump.java: New utility. + * TestDebugdump.java: New test. + 2008-05-30 Petr Machata * 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 ", 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 @@ + + + + + + + + + + ] +> + + + + + Frysk + May 2008 + + + + &command; + &volume; + Frysk + &version; + + + + fdebugdump + dumps a hierarchy of the debug info dies + + + + + fdebugrpm + + executable + + + + + + DESCRIPTION + + fdebugdump + 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. + + + + + + EXAMPLE + &command; ls + + + + SEE ALSO + frysk(7) + + + + BUGS + Report bugs to + + + 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 + + * TestDwfl.java: New test. + 2008-04-17 Andrew Cagney * 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 + + * DwflModule.java: Added getCuDies(). + * cni/DwflModule.cxx: Added get_cu_dies(). + 2008-05-26 Andrew Cagney * 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