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: implemented and testted DwarfDie.getDefinition. Date: Mon, 10 Dec 2007 18:19:00 -0000 [thread overview] Message-ID: <20071210181908.30518.qmail@sourceware.org> (raw) The branch, master has been updated via cf5dfede44633c3aae44dfee1959c2a5ea15745f (commit) from b46299979f8206a6b2a34e16cb2fa9ddd9eff862 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit cf5dfede44633c3aae44dfee1959c2a5ea15745f Author: Sami Wagiaalla <swagiaal@redhat.com> Date: Mon Dec 10 13:12:29 2007 -0500 swagiaal: implemented and testted DwarfDie.getDefinition. frysk-core/frysk/scopes/ChangeLog +2007-12-10 Sami Wagiaalla <swagiaal@redhat.com> + + * TestDie.java (testGetDefinition): New test. + frysk-sys/lib/dwfl/ChangeLog +2007-12-10 Sami Wagiaalla <swagiaal@redhat.com> + + * DwarfDie.java (isDeclaration): New function. + (getDefinition): New function. + (toString): Added null check. + (getOriginalDie): Added attribute check. + ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/scopes/ChangeLog | 4 +++ frysk-core/frysk/scopes/TestDie.java | 36 +++++++++++++++++++++++++++ frysk-sys/lib/dwfl/ChangeLog | 7 +++++ frysk-sys/lib/dwfl/DwarfDie.java | 44 +++++++++++++++++++++++++++------ 4 files changed, 83 insertions(+), 8 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog index 24470da..9e8a0c0 100644 --- a/frysk-core/frysk/scopes/ChangeLog +++ b/frysk-core/frysk/scopes/ChangeLog @@ -1,3 +1,7 @@ +2007-12-10 Sami Wagiaalla <swagiaal@redhat.com> + + * TestDie.java (testGetDefinition): New test. + 2007-12-03 Sami Wagiaalla <swagiaal@redhat.com> * TestDie.java (testGetPubnames): New test. diff --git a/frysk-core/frysk/scopes/TestDie.java b/frysk-core/frysk/scopes/TestDie.java index 9ad5a93..8da51c4 100644 --- a/frysk-core/frysk/scopes/TestDie.java +++ b/frysk-core/frysk/scopes/TestDie.java @@ -44,6 +44,7 @@ import java.util.Iterator; import java.util.LinkedList; import lib.dwfl.DwAt; +import lib.dwfl.DwTag; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; import lib.dwfl.DwflModule; @@ -53,6 +54,7 @@ import frysk.debuginfo.DebugInfoStackFactory; import frysk.debuginfo.ObjectDeclarationSearchEngine; import frysk.dwfl.DwflCache; import frysk.proc.Task; +import frysk.stack.Frame; import frysk.stack.StackFactory; import frysk.testbed.DaemonBlockedAtSignal; import frysk.testbed.TestLib; @@ -120,7 +122,41 @@ public class TestDie die = (DwarfDie) iterator.next(); assertEquals("Die name", "static_i", die.getName()); + } + + public void testGetDefinition(){ + + String fileName = "funit-class-static"; + Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask(); + Frame frame = StackFactory.createFrame(task); + long pc = frame.getAdjustedAddress(); + + Dwfl dwfl = DwflCache.getDwfl(task); + DwarfDie cu = dwfl.getCompilationUnit(pc).die; + DwarfDie[] scopes = cu.getScopes(pc); + DwarfDie die = null; + + for (int i = 0; i < scopes.length; i++) { + if(scopes[i].getTag().equals(DwTag.SUBPROGRAM)){ + die = scopes[i]; + break; + } + } + + assertTrue("Die is a definition", + die.hasAttribute(DwAt.SPECIFICATION) || + die.hasAttribute(DwAt.ABSTRACT_ORIGIN)); + + DwarfDie originalDie = die.getOriginalDie(); + + assertTrue("Found declaration die", originalDie.isDeclaration()); + + DwarfDie definitionDie = originalDie.getDefinition(); + + assertNotNull(definitionDie); + assertEquals("dies have the same name ", die.getName(), definitionDie.getName()); + assertEquals("dies have the same modules ", die.getOffset(), definitionDie.getOffset()); } } diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index 9a6434c..b664467 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,3 +1,10 @@ +2007-12-10 Sami Wagiaalla <swagiaal@redhat.com> + + * DwarfDie.java (isDeclaration): New function. + (getDefinition): New function. + (toString): Added null check. + (getOriginalDie): Added attribute check. + 2007-12-07 Sami Wagiaalla <swagiaal@redhat.com> * DwflModule.java (getDieByOffset): New function diff --git a/frysk-sys/lib/dwfl/DwarfDie.java b/frysk-sys/lib/dwfl/DwarfDie.java index 1345417..177ff00 100644 --- a/frysk-sys/lib/dwfl/DwarfDie.java +++ b/frysk-sys/lib/dwfl/DwarfDie.java @@ -40,6 +40,8 @@ package lib.dwfl; import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; abstract public class DwarfDie { @@ -337,8 +339,9 @@ abstract public class DwarfDie { public String toString() { StringBuilder stringBuilder= new StringBuilder(); DwarfDie type = getUltimateType(); - stringBuilder.append(this.getTag() + " Name: " + this.getName()); - stringBuilder.append(" Type: " + type.toString()); + stringBuilder.append("offset 0x"+Long.toHexString(this.getOffset()) +" "+ this.getTag() + " Name: " + this.getName()); + if(type != null) + stringBuilder.append(" Type: " + type.toString()); return stringBuilder.toString(); } @@ -387,13 +390,38 @@ abstract public class DwarfDie { * this function returns the die pointed to by those attributes. */ public DwarfDie getOriginalDie() { - long original_die = get_original_die(this.getPointer()); - DwarfDie die = null; - if (original_die != 0) - die = DwarfDieFactory.getFactory().makeDie(original_die, null); - return die; + if(this.hasAttribute(DwAt.ABSTRACT_ORIGIN) || + this.hasAttribute(DwAt.SPECIFICATION)){ + long original_die = get_original_die(this.getPointer()); + DwarfDie die = null; + if (original_die != 0) + die = DwarfDieFactory.getFactory().makeDie(original_die, this.module); + return die; + } + return null; + } + + public boolean isDeclaration() { + return this.hasAttribute(DwAt.DECLARATION); + } + + public DwarfDie getDefinition() { + // try to find the definition + // try using pubnames + LinkedList pubnames = this.getModule().getPubNames(); + Iterator iterator = pubnames.iterator(); + while (iterator.hasNext()) { + DwarfDie die = (DwarfDie) iterator.next(); + DwarfDie originalDie = die.getOriginalDie(); + if(originalDie != null && originalDie.getModule().getName().equals(this.getModule().getName()) && + originalDie.getOffset() == this.getOffset()){ + return die; + } + } + + return null; } - + abstract public void accept(DieVisitor visitor); public native ArrayList getEntryBreakpoints(); hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2007-12-10 18:19 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=20071210181908.30518.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: linkBe 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).