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: Added support for [file#]name lookup Date: Fri, 09 May 2008 20:02:00 -0000 [thread overview] Message-ID: <20080509200250.5708.qmail@sourceware.org> (raw) The branch, master has been updated via 88dee672fef4050c808116f20e45765bf5c231d8 (commit) from 3a67b7fb24ac50fc6ad63b2672084c5691526fb6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 88dee672fef4050c808116f20e45765bf5c231d8 Author: Sami Wagiaalla <swagiaal@redhat.com> Date: Fri May 9 15:08:40 2008 -0400 swagiaal: Added support for [file#]name lookup frysk-core/ChangeLog +2008-05-09 Sami Wagiaalla <swagiaal@toner.yyz.redhat.com> + + * Makefile.am: Corred rule for compiling + funit-scopes-multi-file + frysk-core/frysk/debuginfo/ChangeLog +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * ObjectDeclarationSearchEngine.java (getObject): Added support + for [file#]name lookup + * TestObjectDeclarationSearchEngineTopDown.java + (testGetObjectHashFileHashSymbol): enabled test. + frysk-core/frysk/scopes/ChangeLog +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * Scope.java (getDeclaredObjectByNameRecursive): Added + support for recursive search. + frysk-sys/lib/dwfl/ChangeLog +2008-05-09 Sami Wagiaalla <swagiaal@toner.yyz.redhat.com> + + * cni/Dwarf.cxx (Dwarf::get_cu_by_name): New. + +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * Dwarf.java (getCUByName): New. + ----------------------------------------------------------------------- Summary of changes: frysk-core/ChangeLog | 5 ++ frysk-core/Makefile.am | 7 ++- frysk-core/frysk/debuginfo/ChangeLog | 7 +++ .../debuginfo/ObjectDeclarationSearchEngine.java | 56 +++++++++++++++----- .../TestObjectDeclarationSearchEngineTopDown.java | 10 ++-- frysk-core/frysk/scopes/ChangeLog | 5 ++ frysk-core/frysk/scopes/Scope.java | 46 +++++++++++++++- frysk-sys/lib/dwfl/ChangeLog | 8 +++ frysk-sys/lib/dwfl/Dwarf.java | 19 ++++++- frysk-sys/lib/dwfl/cni/Dwarf.cxx | 45 +++++++++++++++- 10 files changed, 181 insertions(+), 27 deletions(-) First 500 lines of diff: diff --git a/frysk-core/ChangeLog b/frysk-core/ChangeLog index c038034..9e44b4a 100644 --- a/frysk-core/ChangeLog +++ b/frysk-core/ChangeLog @@ -1,3 +1,8 @@ +2008-05-09 Sami Wagiaalla <swagiaal@toner.yyz.redhat.com> + + * Makefile.am: Corred rule for compiling + funit-scopes-multi-file + 2008-05-02 Rick Moseley <rmoseley@redhat.com> * Makefile.am: Remove CDTParser. diff --git a/frysk-core/Makefile.am b/frysk-core/Makefile.am index 7894a50..6c41855 100644 --- a/frysk-core/Makefile.am +++ b/frysk-core/Makefile.am @@ -323,8 +323,9 @@ frysk/pkglibdir/FunitSimpleInterfaceTest: # The following links two files into one executable -frysk_pkglibdir_funit_scopes_multi_file_a_LINK = $(LINK) $(srcdir)/frysk/pkglibdir/funit-scopes-multi-file-b.c -DNO_MAIN -frysk_pkglibdir_funit_scopes_multi_file_b_LINK = $(LINK) $(srcdir)/frysk/pkglibdir/funit-scopes-multi-file-b.c -DNO_MAIN - +pkglib_PROGRAMS += frysk/pkglibdir/funit-scopes-multi-file +frysk_pkglibdir_funit_scopes_multi_file_SOURCES = +frysk/pkglibdir/funit-scopes-multi-file: + gcc -g $(srcdir)/frysk/pkglibdir/funit-scopes-multi-file-a.c $(srcdir)/frysk/pkglibdir/funit-scopes-multi-file-b.c -o frysk/pkglibdir/funit-scopes-multi-file diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 9b5432c..f444ac0 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,10 @@ +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * ObjectDeclarationSearchEngine.java (getObject): Added support + for [file#]name lookup + * TestObjectDeclarationSearchEngineTopDown.java + (testGetObjectHashFileHashSymbol): enabled test. + 2008-04-30 Stan Cox <scox@redhat.com> * TypeFactory.java (getGccStructOrClassType): Set dieHash. diff --git a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java b/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java index 0f172e7..0efe281 100644 --- a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java +++ b/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java @@ -92,33 +92,63 @@ public class ObjectDeclarationSearchEngine implements ExprSymTab{ * should be modified to * - use frysk search ({@link ObjectDeclarationSearchEngine}) * - handle # syntax - * ... + * ... + * handles: + * [file#]name + * */ public ObjectDeclaration getObject(String name) { - ObjectDeclaration result; + ObjectDeclaration result = null; + + DwarfDie cu; + String symbol; Elf elf = new Elf(new File(task.getProc().getExeFile().getSysRootedPath()), ElfCommand.ELF_C_READ); Dwarf dwarf = new Dwarf(elf, DwarfCommand.READ, null); - - DwarfDie resultDie = DwarfDie.getDecl(dwarf, name); TypeFactory typeFactory = new TypeFactory(task.getISA()); - if (resultDie == null) - throw new ObjectDeclarationNotFoundException(name); + String[] names = name.split("#"); + if(names.length == 2){ + LinkedList cuDies = dwarf.getCUByName(names[0]); + + if(cuDies.size() == 0){ + throw new ObjectDeclarationNotFoundException(names[0]); + }else{ + //XXX: modify this to use the entire list. + cu = (DwarfDie) cuDies.getFirst(); + } + + symbol = names[1]; + + Scope scope = ScopeFactory.theFactory.getScope(cu, typeFactory); + result = scope.getDeclaredObjectByNameRecursive(symbol); + } - try { - result = (ObjectDeclaration) ScopeFactory.theFactory.getScope(resultDie, typeFactory); - } catch (IllegalArgumentException e) { - try { - result = new Variable(resultDie); - } catch (Exception e2) { + if (names.length == 1) { + DwarfDie resultDie = DwarfDie.getDecl(dwarf, name); + + if (resultDie == null) throw new ObjectDeclarationNotFoundException(name); + + try { + result = (ObjectDeclaration) ScopeFactory.theFactory.getScope( + resultDie, typeFactory); + } catch (IllegalArgumentException e) { + try { + result = new Variable(resultDie); + } catch (Exception e2) { + throw new ObjectDeclarationNotFoundException(name); + } } } - return (ObjectDeclaration)result; + if (result == null) { + throw new ObjectDeclarationNotFoundException(name); + } + + return result; } /** diff --git a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngineTopDown.java b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngineTopDown.java index 7ac0c05..8764737 100644 --- a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngineTopDown.java +++ b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngineTopDown.java @@ -72,12 +72,10 @@ public class TestObjectDeclarationSearchEngineTopDown extends TestLib { } public void testGetObjectHashFileHashSymbol() { - if (unresolved(6459)) { - return; - } - String objectName = "#funit-scopes-multi-file-b.c#first"; + + String objectName = "funit-scopes-multi-file-b.c#first"; String objectToken = "*this*"; - String fileName = "funit-scopes-multi-file-a"; + String fileName = "funit-scopes-multi-file"; File srcPath = getSrc("funit-scopes-multi-file-b.c"); verifyObjectFound(objectName, objectToken, fileName, srcPath); @@ -98,7 +96,7 @@ public class TestObjectDeclarationSearchEngineTopDown extends TestLib { .getObject(objectName); assertNotNull("Variable found", objectDeclaration); - assertEquals("Correct name", objectName, objectDeclaration.getName()); + assertTrue("Correct name", objectName.endsWith(objectDeclaration.getName())); assertEquals("Found the correct variable on the correct line ", objectLine, objectDeclaration.getSourceLocation().getLine()); diff --git a/frysk-core/frysk/scopes/ChangeLog b/frysk-core/frysk/scopes/ChangeLog index 7903933..2cfcdfb 100644 --- a/frysk-core/frysk/scopes/ChangeLog +++ b/frysk-core/frysk/scopes/ChangeLog @@ -1,3 +1,8 @@ +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * Scope.java (getDeclaredObjectByNameRecursive): Added + support for recursive search. + 2008-04-22 Sami Wagiaalla <swagiaal@redhat.com> * Scope.java: Now looks at NameScopes as well diff --git a/frysk-core/frysk/scopes/Scope.java b/frysk-core/frysk/scopes/Scope.java index d7afa2e..a3e993b 100644 --- a/frysk-core/frysk/scopes/Scope.java +++ b/frysk-core/frysk/scopes/Scope.java @@ -86,7 +86,6 @@ public class Scope public Scope(DwarfDie die, TypeFactory typeFactory){ this.die = die; - this.scopes = new LinkedList(); this.typeFactory = typeFactory; this.sourceLocation = SourceLocationFactory.getSourceLocation(die); } @@ -105,7 +104,22 @@ public class Scope } public LinkedList getScopes(){ - return this.scopes; + + if (this.scopes == null) { + this.scopes = new LinkedList(); + DwarfDie die = this.die.getChild(); + + while (die != null) { + try{ + Scope scope = ScopeFactory.theFactory.getScope(die, typeFactory); + this.scopes.add(scope); + } catch (IllegalArgumentException e) { + // not a scope + } + die = die.getSibling(); + } + } + return scopes; } protected DwarfDie getDie(){ @@ -195,6 +209,7 @@ public class Scope } public ObjectDeclaration getDeclaredObjectByName(String name){ + ObjectDeclaration objectDeclaration = null; Iterator iterator = this.getObjectDeclarations().iterator(); @@ -219,6 +234,33 @@ public class Scope return null; } + /** + * Searches child scopes for the given name + * @param name + * @return + */ + public ObjectDeclaration getDeclaredObjectByNameRecursive(String name){ + + ObjectDeclaration objectDeclaration = this.getDeclaredObjectByName(name); + + if(objectDeclaration != null){ + return objectDeclaration; + } + + Iterator iterator = this.getScopes().iterator(); + while (iterator.hasNext()) { + Scope scope = (Scope) iterator.next(); + objectDeclaration = scope.getDeclaredObjectByNameRecursive(name); + + if(objectDeclaration != null){ + return objectDeclaration; + } + } + + + return null; + } + public void toPrint(DebugInfoFrame frame, PrintWriter writer, String indentString){ Iterator iterator = this.getVariables().iterator(); diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index b3d4c99..8b97a0f 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,3 +1,11 @@ +2008-05-09 Sami Wagiaalla <swagiaal@toner.yyz.redhat.com> + + * cni/Dwarf.cxx (Dwarf::get_cu_by_name): New. + +2008-05-09 Sami Wagiaalla <swagiaal@redhat.com> + + * Dwarf.java (getCUByName): New. + 2008-05-07 Andrew Cagney <cagney@redhat.com> * jni/DwarfDie.cxx: Include jni.hxx. diff --git a/frysk-sys/lib/dwfl/Dwarf.java b/frysk-sys/lib/dwfl/Dwarf.java index 1727439..b3a8ba5 100644 --- a/frysk-sys/lib/dwfl/Dwarf.java +++ b/frysk-sys/lib/dwfl/Dwarf.java @@ -39,10 +39,10 @@ package lib.dwfl; -import lib.dwfl.Elf; -import lib.dwfl.ElfSection; import gnu.gcj.RawData; +import java.util.LinkedList; + public class Dwarf { private long pointer; @@ -94,9 +94,24 @@ public class Dwarf { public String[] getSourceFiles(){ return get_source_files(); } + + /** + * Returns a list of compilation units matching + * the given name. + * If a full path is give only one cu is likely + * to be returned. + * + * @param name + * @return + */ + public LinkedList getCUByName(String name){ + return this.get_cu_by_name(name); + } + protected native void dwarf_begin_elf(RawData elf, int command, long section); protected native void dwarf_begin(String file, int command); protected native String[] get_source_files(); + protected native LinkedList get_cu_by_name(String name); protected native int dwarf_end(); // protected native long[] dwarf_get_functions(); // protected native long dwarf_addrdie(long addr); diff --git a/frysk-sys/lib/dwfl/cni/Dwarf.cxx b/frysk-sys/lib/dwfl/cni/Dwarf.cxx index 4f26966..e8892ab 100644 --- a/frysk-sys/lib/dwfl/cni/Dwarf.cxx +++ b/frysk-sys/lib/dwfl/cni/Dwarf.cxx @@ -41,8 +41,15 @@ #include <fcntl.h> #include <gcj/cni.h> #include <libdw.h> +#include <stdio.h> #include "lib/dwfl/Dwarf.h" +#include "lib/dwfl/DwarfDie.h" +#include "lib/dwfl/DwarfDieFactory.h" + +#include <java/lang/String.h> +#include <java/util/LinkedList.h> +#include <java/lang/Long.h> #define DWARF_POINTER (::Dwarf *) this->pointer @@ -67,6 +74,43 @@ lib::dwfl::Dwarf::dwarf_begin(jstring file, jint command){ this->pointer = (jlong) ::dwarf_begin(fd, (::Dwarf_Cmd) command); } + +java::util::LinkedList* +lib::dwfl::Dwarf::get_cu_by_name(java::lang::String* name) +{ + + java::util::LinkedList* list = new java::util::LinkedList(); + + Dwarf_Off offset = 0; + Dwarf_Off old_offset; + Dwarf_Die cudie_mem; + size_t hsize; + + while (dwarf_nextcu ((::Dwarf *)this->pointer, old_offset = offset, &offset, + &hsize, NULL, NULL, NULL) == 0) + { + + Dwarf_Die *cudie = dwarf_offdie ((::Dwarf *)this->pointer, old_offset + hsize, &cudie_mem); + const char *die_name = dwarf_diename (cudie); + java::lang::String* die_name_string = JvNewStringLatin1 (die_name); + + if(die_name_string->endsWith(name)){ + + Dwarf_Die *die = (Dwarf_Die*)JvMalloc(sizeof(Dwarf_Die)); + + memcpy(die, cudie, sizeof(*die)); + lib::dwfl::DwarfDie* cuDie = lib::dwfl::DwarfDieFactory::getFactory()->makeDie((jlong)die, NULL); + cuDie->setManageDie(true); + + list->add(cuDie); + } + + } + + return list; +} + + JArray<jstring>* lib::dwfl::Dwarf::get_source_files() { @@ -125,7 +169,6 @@ lib::dwfl::Dwarf::get_source_files() return jfiles; } - jint lib::dwfl::Dwarf::dwarf_end(){ return ::dwarf_end(DWARF_POINTER); hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-05-09 20:02 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=20080509200250.5708.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).