From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29077 invoked by alias); 6 Jun 2008 15:51:09 -0000 Received: (qmail 29048 invoked by uid 367); 6 Jun 2008 15:51:09 -0000 Date: Fri, 06 Jun 2008 15:51:00 -0000 Message-ID: <20080606155109.29032.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Let DwflDie.getScopes() adjust for module bias. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 320da5218a7124bc55ab876d80f49b38a256ca9b X-Git-Newrev: 0b84d1552a760ccbf0df4e6caa2948cc2a952012 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/msg00345.txt.bz2 The branch, master has been updated via 0b84d1552a760ccbf0df4e6caa2948cc2a952012 (commit) via 42be08bed42a905c6c905f5a7ab585e2d29d5b8c (commit) from 320da5218a7124bc55ab876d80f49b38a256ca9b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 0b84d1552a760ccbf0df4e6caa2948cc2a952012 Author: Andrew Cagney Date: Fri Jun 6 11:45:21 2008 -0400 Let DwflDie.getScopes() adjust for module bias. Instead of trying to remember to write something like DwflDie.getScopes(address - DwflDie.getBias()), DwflDie handles this directly. Looking over the code, there were a number of places that were forgetting to adjust the bias (e.g.., lib.dwfl). frysk-core/frysk/debuginfo/ChangeLog 2008-06-06 Andrew Cagney * DebugInfo.java: Let DwflDie adjust for bias. * TestFrameDebugInfo.java: Ditto. * gen-type-expect-tests.py: Ditto. frysk-core/frysk/expr/ChangeLog 2008-06-06 Andrew Cagney * ExprSearchEngine.java: Let DwflDie adjust for module bias. frysk-core/frysk/scopes/ChangeLog 2008-06-06 Andrew Cagney * TestScopeFactory.java: Let DwflDie adjust for bias. frysk-sys/lib/dwfl/ChangeLog 2008-06-06 Andrew Cagney * DwflDie.java (getScopes()): New. (getBias()): Delete. * TestDwfl.java: Let DwflDie adjust for bias. commit 42be08bed42a905c6c905f5a7ab585e2d29d5b8c Author: Andrew Cagney Date: Fri Jun 6 10:17:52 2008 -0400 Minor cleanup to DwarfDie. frysk-sys/lib/dwfl/ChangeLog 2008-06-06 Andrew Cagney * DwflDie.java (getLowPC, getHighPC): Drop bias in name. * DwarfDie.java (getDwfl()): Delete. (getPointer()): Delete. * jni/DwarfDie.cxx: Update. * cni/DwarfDie.cxx: Update. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/debuginfo/ChangeLog | 6 ++ frysk-core/frysk/debuginfo/DebugInfo.java | 6 +- frysk-core/frysk/debuginfo/TestFrameDebugInfo.java | 4 +- .../frysk/debuginfo/gen-type-expect-tests.py | 11 +-- frysk-core/frysk/expr/ChangeLog | 4 + frysk-core/frysk/expr/ExprSearchEngine.java | 5 +- frysk-core/frysk/scopes/ChangeLog | 4 + frysk-core/frysk/scopes/TestScopeFactory.java | 4 +- frysk-sys/lib/dwfl/ChangeLog | 12 +++ frysk-sys/lib/dwfl/DwarfDie.java | 82 ++++++++----------- frysk-sys/lib/dwfl/DwflDie.java | 12 ++-- frysk-sys/lib/dwfl/TestDwfl.java | 2 +- frysk-sys/lib/dwfl/cni/DwarfDie.cxx | 40 ++++------ frysk-sys/lib/dwfl/jni/DwarfDie.cxx | 27 ++++--- 14 files changed, 112 insertions(+), 107 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 7102c0c..f74532f 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,9 @@ +2008-06-06 Andrew Cagney + + * DebugInfo.java: Let DwflDie adjust for bias. + * TestFrameDebugInfo.java: Ditto. + * gen-type-expect-tests.py: Ditto. + 2008-06-05 Andrew Cagney * DebugInfoFrame.java: Use DwflDie. diff --git a/frysk-core/frysk/debuginfo/DebugInfo.java b/frysk-core/frysk/debuginfo/DebugInfo.java index 6233314..f4889fb 100644 --- a/frysk-core/frysk/debuginfo/DebugInfo.java +++ b/frysk-core/frysk/debuginfo/DebugInfo.java @@ -89,11 +89,9 @@ public class DebugInfo { TypeFactory typeFactory = new TypeFactory(frame.getTask().getISA()); if (bias == null) throw new RuntimeException("No symbol table is available."); - DwarfDie die = bias; StringBuffer result = new StringBuffer(); - - DwarfDie[] allDies = die.getScopes(pc - bias.getBias()); - DwarfDie varDie = die.getScopeVar(allDies, sInput); + DwarfDie[] allDies = bias.getScopes(pc); + DwarfDie varDie = bias.getScopeVar(allDies, sInput); if (varDie == null) { varDie = DwarfDie.getDecl(dwarf, sInput); if (varDie == null) diff --git a/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java b/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java index de6041f..439218f 100644 --- a/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java +++ b/frysk-core/frysk/debuginfo/TestFrameDebugInfo.java @@ -184,7 +184,7 @@ public class TestFrameDebugInfo extends TestLib { Dwfl dwfl = DwflCache.getDwfl(task); DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress()); assertEquals("number of scopes", 3, scopes.length); @@ -248,7 +248,7 @@ public class TestFrameDebugInfo extends TestLib { Dwfl dwfl = DwflCache.getDwfl(task); DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress()); 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 fcccf54..c8513c4 100644 --- a/frysk-core/frysk/debuginfo/gen-type-expect-tests.py +++ b/frysk-core/frysk/debuginfo/gen-type-expect-tests.py @@ -74,7 +74,7 @@ public class %s extends TestLib { private class TypeTestbed { DebugInfoFrame frame; Task task; - DwarfDie die; + DwflDie biasDie; DwarfDie[] allDies; TypeFactory typeFactory; String testName; @@ -84,9 +84,8 @@ public class %s extends TestLib { frame = DebugInfoStackFactory.createDebugInfoStackTrace(task); long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(frame.getTask()); - DwflDie bias = dwfl.getCompilationUnit(pc); - die = bias; - allDies = die.getScopes(pc - bias.getBias()); + biasDie = dwfl.getCompilationUnit(pc); + allDies = biasDie.getScopes(pc); typeFactory = new TypeFactory(frame.getTask().getISA()); this.testName = testName; } @@ -96,7 +95,7 @@ public class %s extends TestLib { void checkType(String symbol, String expected) { Type varType; - DwarfDie varDie = die.getScopeVar(allDies, symbol); + DwarfDie varDie = biasDie.getScopeVar(allDies, symbol); if (varDie == null) System.out.println("Error: Cannot find " + symbol); assertNotNull(varDie); @@ -115,7 +114,7 @@ public class %s extends TestLib { if (expected.indexOf("&") >= 0 || symbol.indexOf("ptr") >= 0 || expected.length() == 0) return; - DwarfDie varDie = die.getScopeVar(allDies, symbol); + DwarfDie varDie = biasDie.getScopeVar(allDies, symbol); if (varDie == null) System.out.println("Error: Cannot find " + symbol); assertNotNull(varDie); diff --git a/frysk-core/frysk/expr/ChangeLog b/frysk-core/frysk/expr/ChangeLog index 05854e7..d07e970 100644 --- a/frysk-core/frysk/expr/ChangeLog +++ b/frysk-core/frysk/expr/ChangeLog @@ -1,3 +1,7 @@ +2008-06-06 Andrew Cagney + + * ExprSearchEngine.java: Let DwflDie adjust for module bias. + 2008-06-05 Andrew Cagney * ExprSearchEngine.java: Use DwflDie. diff --git a/frysk-core/frysk/expr/ExprSearchEngine.java b/frysk-core/frysk/expr/ExprSearchEngine.java index 6431a34..3bb85a6 100644 --- a/frysk-core/frysk/expr/ExprSearchEngine.java +++ b/frysk-core/frysk/expr/ExprSearchEngine.java @@ -107,9 +107,8 @@ public class ExprSearchEngine extends ObjectDeclarationSearchEngine implements E long pc = frame.getAdjustedAddress(); Dwfl dwfl = DwflCache.getDwfl(frame.getTask()); DwflDie bias = dwfl.getCompilationUnit(pc); - DwarfDie die = bias; - DwarfDie[] allDies = die.getScopes(pc - bias.getBias()); - List candidates_p = die.getScopeVarNames(allDies, incomplete); + DwarfDie[] allDies = bias.getScopes(pc); + List candidates_p = bias.getScopeVarNames(allDies, incomplete); for (Iterator i = candidates_p.iterator(); i.hasNext();) { String sNext = (String) i.next(); candidates.add(sNext); diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog index cdf45a1..670e7f5 100644 --- a/frysk-core/frysk/scopes/ChangeLog +++ b/frysk-core/frysk/scopes/ChangeLog @@ -1,3 +1,7 @@ +2008-06-06 Andrew Cagney + + * TestScopeFactory.java: Let DwflDie adjust for bias. + 2008-06-05 Andrew Cagney * TestDie.java: Use DwflDie. diff --git a/frysk-core/frysk/scopes/TestScopeFactory.java b/frysk-core/frysk/scopes/TestScopeFactory.java index df34c16..065e2ab 100644 --- a/frysk-core/frysk/scopes/TestScopeFactory.java +++ b/frysk-core/frysk/scopes/TestScopeFactory.java @@ -60,7 +60,7 @@ public class TestScopeFactory Dwfl dwfl = DwflCache.getDwfl(task); DwflDie bias = dwfl.getCompilationUnit(frame.getAdjustedAddress()); - DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); + DwarfDie[] scopes = bias.getScopes(frame.getAdjustedAddress()); TypeFactory typeFactory = new TypeFactory(frame.getTask().getISA()); @@ -78,7 +78,7 @@ public class TestScopeFactory // test scopes from outer frame frame = frame.getOuter(); - scopes = bias.getScopes(frame.getAdjustedAddress() - bias.getBias()); + scopes = bias.getScopes(frame.getAdjustedAddress()); Scope scope7 = ScopeFactory.theFactory.getScope(scopes[0], typeFactory); Scope scope8 = ScopeFactory.theFactory.getScope(scopes[0], typeFactory); diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index bb39b95..4559519 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,3 +1,15 @@ +2008-06-06 Andrew Cagney + + * DwflDie.java (getScopes()): New. + (getBias()): Delete. + * TestDwfl.java: Let DwflDie adjust for bias. + + * DwflDie.java (getLowPC, getHighPC): Drop bias in name. + * DwarfDie.java (getDwfl()): Delete. + (getPointer()): Delete. + * jni/DwarfDie.cxx: Update. + * cni/DwarfDie.cxx: Update. + 2008-06-05 Andrew Cagney * TestDwfl.java (testGetModules()): Allow for JNI. diff --git a/frysk-sys/lib/dwfl/DwarfDie.java b/frysk-sys/lib/dwfl/DwarfDie.java index a54556e..dda1671 100644 --- a/frysk-sys/lib/dwfl/DwarfDie.java +++ b/frysk-sys/lib/dwfl/DwarfDie.java @@ -63,7 +63,7 @@ public class DwarfDie { protected DwflModule getModule(){ return module; } - + protected DwarfDie getCompilationUnit(){ if(this.getTag().equals(DwTag.COMPILE_UNIT)){ @@ -77,21 +77,28 @@ public class DwarfDie { return scopes[scopes.length -1]; } - protected Dwfl getDwfl () { - return this.module.getParent(); - } - public long getHighPC () { - return get_highpc(); + return dwarf_highpc(pointer); } + private static native long dwarf_highpc(long pointer); public long getLowPC () { - return get_lowpc(); + return dwarf_lowpc(pointer); } + private static native long dwarf_lowpc(long pointer); + + /** + * @return entry pc or low pc if this die + */ + public long getEntryPc(){ + return dwarf_entrypc(pointer); + } + private static native long dwarf_entrypc(long pointer); public String getName () { - return get_diename(); + return dwarf_diename(pointer); } + private static native String dwarf_diename(long pointer); public String getProducer () { return getCompilationUnit().getAttrString(DwAt.PRODUCER); @@ -100,7 +107,7 @@ public class DwarfDie { public File getDeclFile() { File file = null; try{ - file = new File(get_decl_file(this.getPointer())); + file = new File(get_decl_file(pointer)); }catch (DwAttributeNotFoundException e) { if(isDefinitionOnly()){ file = getOriginalDie().getDeclFile(); @@ -113,7 +120,7 @@ public class DwarfDie { int line = -1; try{ - line = get_decl_line(this.getPointer()); + line = get_decl_line(pointer); }catch (DwAttributeNotFoundException e) { if(isDefinitionOnly()){ line = getOriginalDie().getDeclLine(); @@ -123,7 +130,7 @@ public class DwarfDie { } public int getDeclColumn() { - return get_decl_column(this.getPointer()); + return get_decl_column(pointer); } public void setScopes(DwarfDie[] scopes) { @@ -181,7 +188,7 @@ public class DwarfDie { long[] vals = new long[scopes.length]; long[] die_and_scope = new long[2]; for(int i = 0; i < scopes.length; i++) - vals[i] = scopes[i].getPointer(); + vals[i] = scopes[i].pointer; DwarfDie die = null; long val = get_scopevar(die_and_scope, vals, variable); @@ -204,7 +211,7 @@ public class DwarfDie { varNames = new ArrayList(); long[] vals = new long[scopes.length]; for(int i = 0; i < scopes.length; i++) - vals[i] = scopes[i].getPointer(); + vals[i] = scopes[i].pointer; get_scopevar_names(vals, variable); return varNames; @@ -243,7 +250,7 @@ public class DwarfDie { public List getAddr() { DwarfOps = new ArrayList(); - get_addr(this.getPointer(), 0); + get_addr(pointer, 0); return DwarfOps; } @@ -262,22 +269,22 @@ public class DwarfDie { } private DwarfDie getType(boolean followTypeDef) { DwarfDie die = null; - long type = get_type(this.getPointer(), followTypeDef); + long type = get_type(pointer, followTypeDef); if (type != 0) die = DwarfDieFactory.getFactory().makeDie(type, this.module); return die; } public boolean getAttrBoolean(DwAt attr) { - return get_attr_boolean(this.getPointer(), attr.hashCode()); + return get_attr_boolean(pointer, attr.hashCode()); } public String getAttrString(DwAt attr) { - return get_attr_string(this.getPointer(), attr.hashCode()); + return get_attr_string(pointer, attr.hashCode()); } public DwTag getTag() { - return DwTag.valueOf(get_tag(this.getPointer())); + return DwTag.valueOf(get_tag(pointer)); } @@ -285,21 +292,21 @@ public class DwarfDie { * @return The upper bound for this subrange die. */ public int getAttrConstant(DwAt attr) { - return get_attr_constant(this.getPointer(), attr.hashCode()); + return get_attr_constant(pointer, attr.hashCode()); } /** * @return The offset for this die. */ public long getOffset() { - return get_offset(this.getPointer()); + return get_offset(pointer); } /** * @return The child for the current die. */ public DwarfDie getChild() { - long child = get_child(this.getPointer()); + long child = get_child(pointer); DwarfDie die = null; if (child != 0) die = DwarfDieFactory.getFactory().makeDie(child, this.module); @@ -310,17 +317,13 @@ public class DwarfDie { * @return The sibling for the current die. */ public DwarfDie getSibling() { - long sibling = get_sibling(this.getPointer()); + long sibling = get_sibling(pointer); DwarfDie die = null; if (sibling != 0) die = DwarfDieFactory.getFactory().makeDie(sibling, this.module); return die; } - protected long getPointer() { - return this.pointer; - } - /** * @param pc Program Counter * @return DW_AT_frame_base for current die. @@ -330,7 +333,7 @@ public class DwarfDie { DwarfOps = new ArrayList(); for (int i = this.scopeIndex; i < this.scopes.length; i++) { - get_framebase(this.getPointer(), this.scopes[i].pointer, pc); + get_framebase(pointer, this.scopes[i].pointer, pc); if (DwarfOps.size() != 0) break; } @@ -344,12 +347,12 @@ public class DwarfDie { */ public List getFormData(long pc) { DwarfOps = new ArrayList(); - get_addr(this.getPointer(), pc); + get_addr(pointer, pc); return DwarfOps; } public long getDataMemberLocation() { - return get_data_member_location(this.getPointer()); + return get_data_member_location(pointer); } /** @@ -361,7 +364,7 @@ public class DwarfDie { } public boolean hasAttribute(DwAt attr){ - return hasattr(getPointer(), attr.hashCode()); + return hasattr(pointer, attr.hashCode()); } public String toString() { @@ -403,7 +406,7 @@ public class DwarfDie { * @return die */ public static DwarfDie getDeclCU(DwarfDie[] scopes, String sym) { - long result = get_decl_cu (scopes[0].getPointer(), sym); + long result = get_decl_cu (scopes[0].pointer, sym); DwarfDie die = null; if (result > 0) { die = DwarfDieFactory.getFactory().makeDie(result, null); @@ -420,7 +423,7 @@ public class DwarfDie { public DwarfDie getOriginalDie() { if(this.hasAttribute(DwAt.ABSTRACT_ORIGIN) || this.hasAttribute(DwAt.SPECIFICATION)){ - long original_die = get_original_die(this.getPointer()); + long original_die = get_original_die(pointer); DwarfDie die = null; if (original_die != 0) die = DwarfDieFactory.getFactory().makeDie(original_die, this.module); @@ -457,27 +460,12 @@ public class DwarfDie { return null; } - /** - * @return entry pc or low pc if this die - */ - public long getEntryPc(){ - return get_entrypc(); - } - public native ArrayList getEntryBreakpoints(); public native boolean isInlineDeclaration(); public native ArrayList getInlinedInstances(); - private native long get_lowpc (); - - private native long get_highpc (); - - protected native long get_entrypc(); - - private native String get_diename (); - private native String get_decl_file (long var_die); private native int get_decl_line (long var_die); diff --git a/frysk-sys/lib/dwfl/DwflDie.java b/frysk-sys/lib/dwfl/DwflDie.java index 7f1eea9..e4764ef 100644 --- a/frysk-sys/lib/dwfl/DwflDie.java +++ b/frysk-sys/lib/dwfl/DwflDie.java @@ -58,15 +58,15 @@ public class DwflDie extends DwarfDie { return biased; } - public long getBias() { - return module.getBias(); + public long getLowPC () { + return super.getLowPC() + module.getBias(); } - public long getBiasedLowPC () { - return getLowPC() + module.getBias(); + public long getHighPC () { + return super.getHighPC() + module.getBias(); } - public long getBiasedHighPC () { - return getHighPC() + module.getBias(); + public DwarfDie[] getScopes(long addr) { + return super.getScopes(addr - module.getBias()); } } diff --git a/frysk-sys/lib/dwfl/TestDwfl.java b/frysk-sys/lib/dwfl/TestDwfl.java index 1e3392b..d8076d2 100644 --- a/frysk-sys/lib/dwfl/TestDwfl.java +++ b/frysk-sys/lib/dwfl/TestDwfl.java @@ -156,7 +156,7 @@ public class TestDwfl extends TestCase { new File(die.getName()).getName()); DwarfDie[] allDies - = die.getScopes(LocalMemory.getCodeAddr() - die.getBias()); + = die.getScopes(LocalMemory.getCodeAddr()); assertNotNull("allDies", allDies); String[] names = { LocalMemory.getCodeName(), diff --git a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx index 5b82f52..c562d2e 100644 --- a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx +++ b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx @@ -53,42 +53,36 @@ #include "lib/dwfl/DwException.h" -#define DWARF_DIE_POINTER (Dwarf_Die *) this->pointer +#define DWARF_DIE_POINTER ((Dwarf_Die *) pointer) jlong -lib::dwfl::DwarfDie::get_lowpc() -{ - Dwarf_Addr lowpc; - ::dwarf_lowpc(DWARF_DIE_POINTER, &lowpc); - return (jlong) lowpc; +lib::dwfl::DwarfDie::dwarf_lowpc(jlong pointer) { + Dwarf_Addr lowpc; + ::dwarf_lowpc(DWARF_DIE_POINTER, &lowpc); + return (jlong) lowpc; } jlong -lib::dwfl::DwarfDie::get_highpc() -{ - Dwarf_Addr highpc; - ::dwarf_highpc(DWARF_DIE_POINTER, &highpc); - return (jlong) highpc; hooks/post-receive -- frysk system monitor/debugger