From 6c5c57e7c1e887ccedbab85f9da5074e691d44a1 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Thu, 5 Jun 2008 14:26:58 -0400 Subject: [PATCH] Replace DwflDieBias with DwflDie DwarfDie. This eliminates the redundant bias field in DwflDieBias - the Die has-a DwflModule and that has-a bias. frysk-core/frysk/debuginfo/ChangeLog 2008-06-05 Andrew Cagney * DebugInfoFrame.java: Use DwflDie. * gen-type-expect-tests.py: Ditto. * TestFrameDebugInfo.java: Ditto. * DebugInfo.java: Ditto. frysk-core/frysk/expr/ChangeLog 2008-06-05 Andrew Cagney * ExprSearchEngine.java: Use DwflDie. frysk-core/frysk/rt/ChangeLog 2008-06-05 Andrew Cagney * FunctionBreakpoint.java: Use DwflDie. frysk-core/frysk/scopes/ChangeLog 2008-06-05 Andrew Cagney * TestDie.java: Use DwflDie. * TestScopeFactory.java: Ditto. frysk-core/frysk/symtab/ChangeLog 2008-06-05 Andrew Cagney * DwflSymbol.java: Use DwflDie. * SymbolFactory.java: Ditto. frysk-sys/lib/dwfl/ChangeLog 2008-06-05 Andrew Cagney * DwflDie.java: Replace DwflDieBias.java; extends DwarfDie. * DwarfDieFactory.java (makeDwflDie(long,DwflModule)): New. * DwarfDie.java: Simplify. * Dwfl.java: Update. * TestDwarfDie.java: Update. * TestDwfl.java: Update. * jni/DwflModule.cxx: Update. * cni/DwflModule.cxx: Update. --- frysk-core/frysk/debuginfo/ChangeLog | 7 +++++ frysk-core/frysk/debuginfo/DebugInfo.java | 8 ++--- .../frysk/debuginfo/DebugInfoFrame.java | 10 +++--- .../frysk/debuginfo/TestFrameDebugInfo.java | 10 +++--- .../frysk/debuginfo/gen-type-expect-tests.py | 8 ++--- frysk-core/frysk/expr/ChangeLog | 4 +++ frysk-core/frysk/expr/ExprSearchEngine.java | 10 +++--- frysk-core/frysk/rt/ChangeLog | 4 +++ frysk-core/frysk/rt/FunctionBreakpoint.java | 14 ++++----- frysk-core/frysk/scopes/ChangeLog | 5 +++ frysk-core/frysk/scopes/TestDie.java | 10 +++--- frysk-core/frysk/scopes/TestScopeFactory.java | 10 +++--- frysk-core/frysk/symtab/ChangeLog | 5 +++ frysk-core/frysk/symtab/DwflSymbol.java | 10 +++--- frysk-core/frysk/symtab/SymbolFactory.java | 16 +++++----- frysk-sys/lib/dwfl/ChangeLog | 9 ++++++ frysk-sys/lib/dwfl/DwarfDie.java | 8 ++--- frysk-sys/lib/dwfl/DwarfDieFactory.java | 5 ++- frysk-sys/lib/dwfl/Dwfl.java | 2 +- .../dwfl/{DwflDieBias.java => DwflDie.java} | 31 ++++++++++--------- frysk-sys/lib/dwfl/DwflModule.java | 6 ++-- frysk-sys/lib/dwfl/TestDwarfDie.java | 24 ++++++-------- frysk-sys/lib/dwfl/TestDwfl.java | 12 +++---- frysk-sys/lib/dwfl/cni/DwflModule.cxx | 6 ++-- frysk-sys/lib/dwfl/jni/DwflModule.cxx | 11 +++---- 25 files changed, 134 insertions(+), 111 deletions(-) rename frysk-sys/lib/dwfl/{DwflDieBias.java => DwflDie.java} (79%) diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index b6a1ad565..7102c0c86 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,10 @@ +2008-06-05 Andrew Cagney + + * DebugInfoFrame.java: Use DwflDie. + * gen-type-expect-tests.py: Ditto. + * TestFrameDebugInfo.java: Ditto. + * DebugInfo.java: Ditto. + 2008-06-02 Sami Wagiaalla * TestFrameDebugInfo.java (testVirtualStackTraceWithLocals): New test. diff --git a/frysk-core/frysk/debuginfo/DebugInfo.java b/frysk-core/frysk/debuginfo/DebugInfo.java index adff272fd..62333143f 100644 --- a/frysk-core/frysk/debuginfo/DebugInfo.java +++ b/frysk-core/frysk/debuginfo/DebugInfo.java @@ -52,7 +52,7 @@ import lib.dwfl.DwarfException; import lib.dwfl.Dwfl; import lib.dwfl.DwTag; import lib.dwfl.DwAt; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import lib.dwfl.Elf; import lib.dwfl.ElfCommand; import java.io.File; @@ -85,14 +85,14 @@ public class DebugInfo { public String what(DebugInfoFrame frame, String sInput) { long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(frame.getTask()); - DwflDieBias bias = dwfl.getCompilationUnit(pc); + DwflDie bias = dwfl.getCompilationUnit(pc); TypeFactory typeFactory = new TypeFactory(frame.getTask().getISA()); if (bias == null) throw new RuntimeException("No symbol table is available."); - DwarfDie die = bias.die; + DwarfDie die = bias; StringBuffer result = new StringBuffer(); - DwarfDie[] allDies = die.getScopes(pc - bias.bias); + DwarfDie[] allDies = die.getScopes(pc - bias.getBias()); DwarfDie varDie = die.getScopeVar(allDies, sInput); if (varDie == null) { varDie = DwarfDie.getDecl(dwarf, sInput); diff --git a/frysk-core/frysk/debuginfo/DebugInfoFrame.java b/frysk-core/frysk/debuginfo/DebugInfoFrame.java index 39305e6ca..02ecdca6a 100644 --- a/frysk-core/frysk/debuginfo/DebugInfoFrame.java +++ b/frysk-core/frysk/debuginfo/DebugInfoFrame.java @@ -45,7 +45,7 @@ import java.util.LinkedList; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.dwfl.DwflCache; import frysk.rt.LineXXX; import frysk.scopes.Function; @@ -87,11 +87,11 @@ public class DebugInfoFrame extends FrameDecorator { if (scope == null) { Dwfl dwfl = DwflCache.getDwfl(this.getTask()); - DwflDieBias bias = dwfl.getCompilationUnit(getAdjustedAddress()); + DwflDie bias = dwfl.getCompilationUnit(getAdjustedAddress()); if (bias != null) { - DwarfDie[] scopes = bias.die.getScopes(getAdjustedAddress()); + DwarfDie[] scopes = bias.getScopes(getAdjustedAddress()); if (scopes.length == 0) { return null; @@ -133,11 +133,11 @@ public class DebugInfoFrame extends FrameDecorator { this.inlinedSubprograms = new LinkedList(); Dwfl dwfl = DwflCache.getDwfl(this.getTask()); - DwflDieBias bias = dwfl.getCompilationUnit(getAdjustedAddress()); + DwflDie bias = dwfl.getCompilationUnit(getAdjustedAddress()); if (bias != null) { - DwarfDie[] scopes = bias.die.getScopes(getAdjustedAddress()); + DwarfDie[] scopes = bias.getScopes(getAdjustedAddress()); if(scopes.length == 0){ return inlinedSubprograms; diff --git a/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java b/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java index 376441610..de6041f7b 100644 --- a/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java +++ b/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java @@ -49,7 +49,7 @@ import javax.naming.NameNotFoundException; import lib.dwfl.DwTag; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.dwfl.DwflCache; import frysk.proc.Task; import frysk.scopes.Function; @@ -183,8 +183,8 @@ public class TestFrameDebugInfo extends TestLib { Frame frame = StackFactory.createFrame(task); Dwfl dwfl = DwflCache.getDwfl(task); - DwflDieBias bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.die.getScopes(frame.getAdjustedAddress() - bias.bias); + DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); assertEquals("number of scopes", 3, scopes.length); @@ -247,8 +247,8 @@ public class TestFrameDebugInfo extends TestLib { Frame frame = StackFactory.createFrame(task); Dwfl dwfl = DwflCache.getDwfl(task); - DwflDieBias bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.die.getScopes(frame.getAdjustedAddress() - bias.bias); + DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); scopes = scopes[0].getScopesDie(); assertEquals("number of scopes", 4, scopes.length); diff --git a/frysk-core/frysk/debuginfo/gen-type-expect-tests.py b/frysk-core/frysk/debuginfo/gen-type-expect-tests.py index 0a3680126..fcccf541c 100644 --- a/frysk-core/frysk/debuginfo/gen-type-expect-tests.py +++ b/frysk-core/frysk/debuginfo/gen-type-expect-tests.py @@ -58,7 +58,7 @@ package frysk.debuginfo; import java.io.*; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.dwfl.DwflCache; import frysk.proc.Task; import frysk.testbed.DaemonBlockedAtSignal; @@ -84,9 +84,9 @@ public class %s extends TestLib { frame = DebugInfoStackFactory.createDebugInfoStackTrace(task); long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(frame.getTask()); - DwflDieBias bias = dwfl.getCompilationUnit(pc); - die = bias.die; - allDies = die.getScopes(pc - bias.bias); + DwflDie bias = dwfl.getCompilationUnit(pc); + die = bias; + allDies = die.getScopes(pc - bias.getBias()); typeFactory = new TypeFactory(frame.getTask().getISA()); this.testName = testName; } diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog index 097137a0a..05854e791 100644 --- a/frysk-core/frysk/expr/ChangeLog +++ b/frysk-core/frysk/expr/ChangeLog @@ -1,3 +1,7 @@ +2008-06-05 Andrew Cagney + + * ExprSearchEngine.java: Use DwflDie. + 2008-06-04 Petr Machata * FQIdentToken.java (processId, threadId, frameNumber): New fields. diff --git a/frysk-core/frysk/expr/ExprSearchEngine.java b/frysk-core/frysk/expr/ExprSearchEngine.java index 7be7f931c..6431a34da 100644 --- a/frysk-core/frysk/expr/ExprSearchEngine.java +++ b/frysk-core/frysk/expr/ExprSearchEngine.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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 @@ -48,7 +48,7 @@ import java.util.List; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.ObjectDeclarationSearchEngine; @@ -106,9 +106,9 @@ public class ExprSearchEngine extends ObjectDeclarationSearchEngine implements E public void complete(String incomplete, List candidates) { long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(frame.getTask()); - DwflDieBias bias = dwfl.getCompilationUnit(pc); - DwarfDie die = bias.die; - DwarfDie[] allDies = die.getScopes(pc - bias.bias); + DwflDie bias = dwfl.getCompilationUnit(pc); + DwarfDie die = bias; + DwarfDie[] allDies = die.getScopes(pc - bias.getBias()); List candidates_p = die.getScopeVarNames(allDies, incomplete); for (Iterator i = candidates_p.iterator(); i.hasNext();) { String sNext = (String) i.next(); diff --git a/frysk-core/frysk/rt/ChangeLog b/frysk-core/frysk/rt/ChangeLog index 0ff22154b..206bab1ce 100644 --- a/frysk-core/frysk/rt/ChangeLog +++ b/frysk-core/frysk/rt/ChangeLog @@ -1,3 +1,7 @@ +2008-06-05 Andrew Cagney + + * FunctionBreakpoint.java: Use DwflDie. + 2008-06-03 Andrew Cagney * FunctionBreakpoint.java: Do not use InlinedSubroutine. diff --git a/frysk-core/frysk/rt/FunctionBreakpoint.java b/frysk-core/frysk/rt/FunctionBreakpoint.java index 70af21d8a..b7141a581 100644 --- a/frysk-core/frysk/rt/FunctionBreakpoint.java +++ b/frysk-core/frysk/rt/FunctionBreakpoint.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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 @@ -46,7 +46,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; import lib.dwfl.DwarfDie; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.proc.Task; import frysk.scopes.ConcreteInlinedFunction; import frysk.scopes.Function; @@ -57,7 +57,7 @@ import frysk.value.ObjectDeclaration; public class FunctionBreakpoint extends SourceBreakpoint { protected final String name; - protected final DwflDieBias die; + protected final DwflDie die; private boolean containsInlineInstances = false; private Function function; @@ -65,7 +65,7 @@ public class FunctionBreakpoint /** * Set a breakpoint based on a DwarfDie or just a name. */ - public FunctionBreakpoint(int id, String name, DwflDieBias die) { + public FunctionBreakpoint(int id, String name, DwflDie die) { super(id); this.name = name; this.die = die; @@ -105,10 +105,10 @@ public class FunctionBreakpoint //XXX: this code should be removed // die is not used any more if (die != null) { - ArrayList entryAddrs = die.getEntryBreakpoints(); + ArrayList entryAddrs = die.getBiasedEntryBreakpoints(); ArrayList inlineDies = null; - if (die.die.isInlineDeclaration()) { - inlineDies = die.die.getInlinedInstances(); + if (die.isInlineDeclaration()) { + inlineDies = die.getInlinedInstances(); } LinkedList addrs; if (entryAddrs == null) diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog index 74ffefd82..cdf45a182 100644 --- a/frysk-core/frysk/scopes/ChangeLog +++ b/frysk-core/frysk/scopes/ChangeLog @@ -1,3 +1,8 @@ +2008-06-05 Andrew Cagney + + * TestDie.java: Use DwflDie. + * TestScopeFactory.java: Ditto. + 2008-06-02 Sami Wagiaalla * Function.java: Now explores referenced dies. diff --git a/frysk-core/frysk/scopes/TestDie.java b/frysk-core/frysk/scopes/TestDie.java index 775d5fb82..44bf505a2 100644 --- a/frysk-core/frysk/scopes/TestDie.java +++ b/frysk-core/frysk/scopes/TestDie.java @@ -45,7 +45,7 @@ import lib.dwfl.DwAt; import lib.dwfl.DwTag; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import lib.dwfl.DwflModule; import frysk.config.Prefix; import frysk.debuginfo.DebugInfoFrame; @@ -112,13 +112,13 @@ public class TestDie assertEquals("Size of pubnames ", 3, pubnames.size()); - DwarfDie die = ((DwflDieBias) iterator.next()).die; + DwarfDie die = (DwflDie) iterator.next(); assertEquals("Die name", "crash", die.getName()); - die = ((DwflDieBias) iterator.next()).die; + die = (DwflDie) iterator.next(); assertEquals("Die name", "main", die.getName()); - die = ((DwflDieBias) iterator.next()).die; + die = (DwflDie) iterator.next(); assertEquals("Die name", "static_i", die.getName()); } @@ -130,7 +130,7 @@ public class TestDie long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(task); - DwarfDie cu = dwfl.getCompilationUnit(pc).die; + DwarfDie cu = dwfl.getCompilationUnit(pc); DwarfDie[] scopes = cu.getScopes(pc); DwarfDie die = null; diff --git a/frysk-core/frysk/scopes/TestScopeFactory.java b/frysk-core/frysk/scopes/TestScopeFactory.java index d10c3749a..df34c1696 100644 --- a/frysk-core/frysk/scopes/TestScopeFactory.java +++ b/frysk-core/frysk/scopes/TestScopeFactory.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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 @@ -41,7 +41,7 @@ package frysk.scopes; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import frysk.debuginfo.TypeFactory; import frysk.dwfl.DwflCache; import frysk.proc.Task; @@ -59,8 +59,8 @@ public class TestScopeFactory Frame frame = StackFactory.createFrame(task); Dwfl dwfl = DwflCache.getDwfl(task); - DwflDieBias bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.die.getScopes(frame.getAdjustedAddress() - bias.bias); + DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); TypeFactory typeFactory = new TypeFactory(frame.getTask().getISA()); @@ -78,7 +78,7 @@ public class TestScopeFactory // test scopes from outer frame frame = frame.getOuter(); - scopes = bias.die.getScopes(frame.getAdjustedAddress() - bias.bias); + scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); Scope scope7 = ScopeFactory.theFactory.getScope(scopes[0], typeFactory); Scope scope8 = ScopeFactory.theFactory.getScope(scopes[0], typeFactory); diff --git a/frysk-core/frysk/symtab/ChangeLog b/frysk-core/frysk/symtab/ChangeLog index 16ebe6f42..ba96d4edd 100644 --- a/frysk-core/frysk/symtab/ChangeLog +++ b/frysk-core/frysk/symtab/ChangeLog @@ -1,3 +1,8 @@ +2008-06-05 Andrew Cagney + + * DwflSymbol.java: Use DwflDie. + * SymbolFactory.java: Ditto. + 2008-05-07 Petr Machata * DwflSymbol.java: The symbol can now be defined or diff --git a/frysk-core/frysk/symtab/DwflSymbol.java b/frysk-core/frysk/symtab/DwflSymbol.java index c31086222..e5931a433 100644 --- a/frysk-core/frysk/symtab/DwflSymbol.java +++ b/frysk-core/frysk/symtab/DwflSymbol.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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 @@ -45,19 +45,19 @@ package frysk.symtab; */ import lib.dwfl.ElfSymbolType; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import lib.dwfl.DwflModule; public class DwflSymbol extends Symbol { - private final DwflDieBias dieBias; + private final DwflDie dieBias; private final DwflModule dwflModule; private final boolean defined; // package private constructor. DwflSymbol(long address, long size, String name, - ElfSymbolType type, DwflDieBias dieBias, DwflModule module, + ElfSymbolType type, DwflDie dieBias, DwflModule module, boolean defined) { super (address, size, name, type); @@ -70,7 +70,7 @@ public class DwflSymbol return this.dwflModule; } - public DwflDieBias getDie() { + public DwflDie getDie() { return this.dieBias; } diff --git a/frysk-core/frysk/symtab/SymbolFactory.java b/frysk-core/frysk/symtab/SymbolFactory.java index e335f3a76..16d5f6645 100644 --- a/frysk-core/frysk/symtab/SymbolFactory.java +++ b/frysk-core/frysk/symtab/SymbolFactory.java @@ -1,7 +1,7 @@ // This file is part of the program FRYSK. // +// Copyright 2007, 2008, Red Hat Inc. // Copyright 2007 Oracle Corporation. -// 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 @@ -54,7 +54,7 @@ import frysk.rsl.LogFactory; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; -import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflDie; import lib.dwfl.DwflModule; import lib.dwfl.SymbolBuilder; @@ -118,8 +118,8 @@ public class SymbolFactory private static Map getPublicTable(final DwflModule module) { final Map dwSymbols = new HashMap(); for (Iterator it = module.getPubNames().iterator(); it.hasNext(); ) { - DwflDieBias dieBias = (DwflDieBias)it.next(); - dwSymbols.put(dieBias.die.getName(), dieBias); + DwflDie dieBias = (DwflDie)it.next(); + dwSymbols.put(dieBias.getName(), dieBias); } return dwSymbols; } @@ -136,8 +136,8 @@ public class SymbolFactory lib.dwfl.ElfSymbolVisibility visibility, boolean defined) { - DwflDieBias dieBias = publicTable == null ? null - : (DwflDieBias)publicTable.get(name); + DwflDie dieBias = publicTable == null ? null + : (DwflDie)publicTable.get(name); int index; if ((index = name.indexOf('@')) != -1) name = name.substring(0, index); @@ -157,8 +157,8 @@ public class SymbolFactory Map.Entry entry = (Map.Entry)it.next(); String name = (String)entry.getKey(); if (!table.containsKey(name)) { - DwflDieBias dieBias = (DwflDieBias)entry.getValue(); - DwarfDie die = dieBias.die; + DwflDie dieBias = (DwflDie)entry.getValue(); + DwarfDie die = dieBias; ArrayList entries = die.getEntryBreakpoints(); if (entries != null) { long addr = ((Long)entries.get(0)).longValue(); diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index 4f85078a5..e6ff38738 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,5 +1,14 @@ 2008-06-05 Andrew Cagney + * DwflDie.java: Replace DwflDieBias.java; extends DwarfDie. + * DwarfDieFactory.java (makeDwflDie(long,DwflModule)): New. + * DwarfDie.java: Simplify. + * Dwfl.java: Update. + * TestDwarfDie.java: Update. + * TestDwfl.java: Update. + * jni/DwflModule.cxx: Update. + * cni/DwflModule.cxx: Update. + * Dwarf.java (Dwarf(long)): Remember that the pointer isn't owned. (finalize()): Check that the pointer is owned. * Dwfl.java (dwfl_addrdie(long)): Delete. diff --git a/frysk-sys/lib/dwfl/DwarfDie.java b/frysk-sys/lib/dwfl/DwarfDie.java index 4fca5ea30..a54556e02 100644 --- a/frysk-sys/lib/dwfl/DwarfDie.java +++ b/frysk-sys/lib/dwfl/DwarfDie.java @@ -50,7 +50,8 @@ public class DwarfDie { private long pointer; private DwarfDie[] scopes; private int scopeIndex; - private DwflModule module; + // XXX: Belongs in DwflDie. + DwflModule module; protected boolean manageDie = false; @@ -444,9 +445,8 @@ public class DwarfDie { // try to find the definition // try using pubnames LinkedList pubnames = this.getModule().getPubNames(); - Iterator iterator = pubnames.iterator(); - while (iterator.hasNext()) { - DwarfDie die = ((DwflDieBias) iterator.next()).die; + for (Iterator i = pubnames.iterator(); i.hasNext(); ) { + DwarfDie die = (DwarfDie) i.next(); DwarfDie originalDie = die.getOriginalDie(); if(originalDie != null && originalDie.getModule().getName().equals(this.getModule().getName()) && originalDie.getOffset() == this.getOffset()){ diff --git a/frysk-sys/lib/dwfl/DwarfDieFactory.java b/frysk-sys/lib/dwfl/DwarfDieFactory.java index 13e7655b0..5dc4e7718 100644 --- a/frysk-sys/lib/dwfl/DwarfDieFactory.java +++ b/frysk-sys/lib/dwfl/DwarfDieFactory.java @@ -61,7 +61,10 @@ public class DwarfDieFactory { * @param module Dwfl object associated with the DIE, if any * @return DwarfDie */ - public DwarfDie makeDie(long pointer, DwflModule module) { + DwarfDie makeDie(long pointer, DwflModule module) { return new DwarfDie(pointer, module); } + DwflDie makeDwflDie(long pointer, DwflModule module) { + return new DwflDie(pointer, module); + } } diff --git a/frysk-sys/lib/dwfl/Dwfl.java b/frysk-sys/lib/dwfl/Dwfl.java index 79a83bacc..ecb1fd2ed 100644 --- a/frysk-sys/lib/dwfl/Dwfl.java +++ b/frysk-sys/lib/dwfl/Dwfl.java @@ -93,7 +93,7 @@ public class Dwfl { return new DwflLine(val, this); } - public DwflDieBias getCompilationUnit (long addr) { + public DwflDie getCompilationUnit (long addr) { DwflModule module = getModule(addr); if (module == null) { return null; diff --git a/frysk-sys/lib/dwfl/DwflDieBias.java b/frysk-sys/lib/dwfl/DwflDie.java similarity index 79% rename from frysk-sys/lib/dwfl/DwflDieBias.java rename to frysk-sys/lib/dwfl/DwflDie.java index 7b9d790b3..7f1eea90d 100644 --- a/frysk-sys/lib/dwfl/DwflDieBias.java +++ b/frysk-sys/lib/dwfl/DwflDie.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, Red Hat Inc. +// Copyright 2005, 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 @@ -42,30 +42,31 @@ package lib.dwfl; import java.util.ArrayList; import java.util.Iterator; -public class DwflDieBias { - public final DwarfDie die; - public final long bias; - - public DwflDieBias(DwarfDie die, long bias) { - this.die = die; - this.bias = bias; +public class DwflDie extends DwarfDie { + DwflDie(long diePointer, DwflModule module) { + // FIXME: A DwarfDie should have no clue about modules. + super(diePointer, module); } - public ArrayList getEntryBreakpoints() { - ArrayList bps = die.getEntryBreakpoints(); + public ArrayList getBiasedEntryBreakpoints() { + ArrayList bps = getEntryBreakpoints(); ArrayList biased = new ArrayList(); for (Iterator it = bps.iterator(); it.hasNext(); ) { Long l = (Long)it.next(); - biased.add(new Long(l.longValue() + bias)); + biased.add(new Long(l.longValue() + module.getBias())); } return biased; } - public long getLowPC () { - return die.getLowPC() + bias; + public long getBias() { + return module.getBias(); + } + + public long getBiasedLowPC () { + return getLowPC() + module.getBias(); } - public long getHighPC () { - return die.getHighPC() + bias; + public long getBiasedHighPC () { + return getHighPC() + module.getBias(); } } diff --git a/frysk-sys/lib/dwfl/DwflModule.java b/frysk-sys/lib/dwfl/DwflModule.java index 0a28094c4..39cb01abe 100644 --- a/frysk-sys/lib/dwfl/DwflModule.java +++ b/frysk-sys/lib/dwfl/DwflModule.java @@ -147,12 +147,10 @@ public class DwflModule { } private native LinkedList get_cu_dies(); - public DwflDieBias getCompilationUnit(long addr) { + public DwflDie getCompilationUnit(long addr) { // Find the die, grab the bias as it flies by. long diePointer = dwflModuleAddrdie(pointer, addr); - DwarfDie die = parent.factory.makeDie(diePointer, this); - // XXX: Should just pass the module. - return new DwflDieBias(die, getBias()); + return parent.factory.makeDwflDie(diePointer, this); } private static native long dwflModuleAddrdie(long pointer, long addr); diff --git a/frysk-sys/lib/dwfl/TestDwarfDie.java b/frysk-sys/lib/dwfl/TestDwarfDie.java index f127e52c5..360827212 100644 --- a/frysk-sys/lib/dwfl/TestDwarfDie.java +++ b/frysk-sys/lib/dwfl/TestDwarfDie.java @@ -50,11 +50,10 @@ public class TestDwarfDie extends TestCase { assertNotNull(dwfl); // get CUDIE - DwflDieBias bias = dwfl.getCompilationUnit(LocalMemory.getCodeAddr()); - assertNotNull(bias); - DwarfDie die = bias.die; - assertEquals("Die has the correct tag", DwTag.COMPILE_UNIT, die - .getTag()); + DwflDie die = dwfl.getCompilationUnit(LocalMemory.getCodeAddr()); + assertNotNull("die", die); + assertEquals("Die has the correct tag", DwTag.COMPILE_UNIT, + die.getTag()); assertTrue("Has name attribute", die.hasAttribute(DwAt.NAME)); assertFalse("Does not have location attribute", die @@ -68,11 +67,8 @@ public class TestDwarfDie extends TestCase { assertNotNull(dwfl); // get CUDIE - DwflDieBias bias = dwfl.getCompilationUnit(pc); - assertNotNull(bias); - - DwarfDie cuDie = bias.die; - assertNotNull(cuDie); + DwflDie cuDie = dwfl.getCompilationUnit(pc); + assertNotNull("cuDie", cuDie); DwarfDie die = cuDie; @@ -90,9 +86,7 @@ public class TestDwarfDie extends TestCase { assertNotNull(dwfl); long addr = LocalMemory.getCodeAddr(); - DwflDieBias dwflDie = dwfl.getCompilationUnit(addr); - assertNotNull("dwflDie", dwflDie); - DwarfDie cuDie = dwflDie.die; + DwarfDie cuDie = dwfl.getCompilationUnit(addr); assertNotNull("cuDie", cuDie); DwarfDie die = cuDie.getScopes(addr)[0]; @@ -108,8 +102,8 @@ public class TestDwarfDie extends TestCase { assertNotNull(dwfl); long addr = LocalMemory.getCodeAddr(); - DwarfDie cuDie = dwfl.getCompilationUnit(addr).die; - assertNotNull(cuDie); + DwflDie cuDie = dwfl.getCompilationUnit(addr); + assertNotNull("cuDie", cuDie); DwarfDie die = cuDie.getScopes(addr)[0]; diff --git a/frysk-sys/lib/dwfl/TestDwfl.java b/frysk-sys/lib/dwfl/TestDwfl.java index e8146b4e7..d04e0e67b 100644 --- a/frysk-sys/lib/dwfl/TestDwfl.java +++ b/frysk-sys/lib/dwfl/TestDwfl.java @@ -148,19 +148,15 @@ public class TestDwfl Dwfl dwfl = DwflTestbed.createFromSelf(); assertNotNull(dwfl); - DwflDieBias bias = dwfl.getCompilationUnit(LocalMemory.getCodeAddr()); - assertNotNull(bias); - - assertEquals(0, bias.bias); - - DwarfDie die = bias.die; - assertNotNull(die); + DwflDie die = dwfl.getCompilationUnit(LocalMemory.getCodeAddr()); + assertNotNull("die", die); + assertEquals("bias", 0, die.getBias()); assertEquals("file", new File(LocalMemory.getCodeFile()).getName(), new File(die.getName()).getName()); - DwarfDie[] allDies = die.getScopes(LocalMemory.getCodeAddr() - bias.bias); + DwarfDie[] allDies = die.getScopes(LocalMemory.getCodeAddr() - die.getBias()); assertNotNull(allDies); String[] names = { diff --git a/frysk-sys/lib/dwfl/cni/DwflModule.cxx b/frysk-sys/lib/dwfl/cni/DwflModule.cxx index 33ea0b4bc..5cd51c41a 100644 --- a/frysk-sys/lib/dwfl/cni/DwflModule.cxx +++ b/frysk-sys/lib/dwfl/cni/DwflModule.cxx @@ -57,7 +57,7 @@ #include "lib/dwfl/ElfSymbolVisibility.h" #include "lib/dwfl/DwarfDieFactory.h" #include "lib/dwfl/Dwfl.h" -#include "lib/dwfl/DwflDieBias.h" +#include "lib/dwfl/DwflDie.h" #include "lib/dwfl/DwException.h" #include "java/util/LinkedList.h" @@ -405,8 +405,8 @@ namespace { throw new lib::dwfl::DwarfException(JvNewStringUTF("failed to get object die")); else { - lib::dwfl::DwarfDie *dwdie = dwfl->factory->makeDie((jlong)die, context->dwflModule); - context->dwflModule->pubNames->add(new lib::dwfl::DwflDieBias(dwdie, context->bias)); + lib::dwfl::DwflDie *dwdie = dwfl->factory->makeDwflDie((jlong)die, context->dwflModule); + context->dwflModule->pubNames->add(dwdie); } return DWARF_CB_OK; diff --git a/frysk-sys/lib/dwfl/jni/DwflModule.cxx b/frysk-sys/lib/dwfl/jni/DwflModule.cxx index 039916c5a..3582efeb3 100644 --- a/frysk-sys/lib/dwfl/jni/DwflModule.cxx +++ b/frysk-sys/lib/dwfl/jni/DwflModule.cxx @@ -361,13 +361,10 @@ each_pubname(Dwarf *dwarf, Dwarf_Global *gl, void* data) { lib::dwfl::DwarfException::ThrowNew(context->env, "failed to get object die"); } else { - lib::dwfl::DwarfDie dwdie = dwfl.GetFactory(context->env) - .makeDie(context->env, (jlong)die, context->dwflModule); - lib::dwfl::DwflDieBias bias = lib::dwfl::DwflDieBias::New(context->env, - dwdie, - context->bias); - context->dwflModule.GetPubNames(context->env) .add(context->env, bias); - bias.DeleteLocalRef(context->env); + lib::dwfl::DwflDie dwdie = dwfl.GetFactory(context->env) + .makeDwflDie(context->env, (jlong)die, context->dwflModule); + context->dwflModule.GetPubNames(context->env).add(context->env, dwdie); + dwdie.DeleteLocalRef(context->env); } return DWARF_CB_OK; -- 2.43.5