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 search elf symbol table. Date: Mon, 07 Apr 2008 20:51:00 -0000 [thread overview] Message-ID: <20080407205107.22050.qmail@sourceware.org> (raw) The branch, master has been updated via 604692fe42c10ea3c73c082e42ca7f10c32b9c24 (commit) from 8f6e462c52d0f9acc6061680a5d5fb635f1d717b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 604692fe42c10ea3c73c082e42ca7f10c32b9c24 Author: Sami Wagiaalla <swagiaal@redhat.com> Date: Mon Apr 7 16:48:40 2008 -0400 swagiaal: added support for search elf symbol table. frysk-core/frysk/debuginfo/ChangeLog +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * ObjectDeclarationSearchEngine.java: Now searches binary (elf) symbol table. + frysk-core/frysk/pkglibdir/ChangeLog +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * funit-elf-symbols.S: New test file. + frysk-core/frysk/symtab/ChangeLog +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * SymbolObjectDeclaration.java: New class. + ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/debuginfo/ChangeLog | 4 + .../debuginfo/ObjectDeclarationSearchEngine.java | 78 +++++++++++--- .../TestObjectDeclarationSearchEngine.java | 55 ++++++++++- frysk-core/frysk/pkglibdir/ChangeLog | 4 + frysk-core/frysk/pkglibdir/funit-elf-symbols.S | 57 ++++++++++ frysk-core/frysk/symtab/ChangeLog | 4 + .../frysk/symtab/SymbolObjectDeclaration.java | 108 ++++++++++++++++++++ 7 files changed, 293 insertions(+), 17 deletions(-) create mode 100644 frysk-core/frysk/pkglibdir/funit-elf-symbols.S create mode 100644 frysk-core/frysk/symtab/SymbolObjectDeclaration.java First 500 lines of diff: diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 0078178..23e57ac 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,7 @@ +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * ObjectDeclarationSearchEngine.java: Now searches binary (elf) symbol table. + 2008-04-04 Sami Wagiaalla <swagiaal@redhat.com> * ObjectDeclarationSearchEngine.java: Removed getValue(). diff --git a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java b/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java index 70225c4..7d35392 100644 --- a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java +++ b/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java @@ -49,6 +49,8 @@ import java.util.List; import lib.dwfl.DwarfDie; import lib.dwfl.Dwfl; import lib.dwfl.DwflDieBias; +import lib.dwfl.DwflModule; +import lib.dwfl.SymbolBuilder; import frysk.dwfl.DwflCache; import frysk.expr.ExprSymTab; import frysk.isa.registers.Register; @@ -56,6 +58,7 @@ import frysk.isa.registers.Registers; import frysk.isa.registers.RegistersFactory; import frysk.proc.Task; import frysk.scopes.Scope; +import frysk.symtab.SymbolObjectDeclaration; import frysk.value.ObjectDeclaration; import frysk.value.Value; @@ -88,10 +91,50 @@ public class ObjectDeclarationSearchEngine implements ExprSymTab{ } scope = scope.getOuter(); } + + return getObjectUsingBinaryInfo(name); + } + + public ObjectDeclaration getObjectUsingBinaryInfo(String name){ + Dwfl dwfl = DwflCache.getDwfl(task); + + DwflModule module = dwfl.getModule(this.frame.getAdjustedAddress()); + + if(module == null){ + throw new RuntimeException("Module could not be found for this process"); + } + final String objectName = name; + + class Builder implements SymbolBuilder { + ObjectDeclaration objectDeclaration = null; + + public void symbol(String name, long value, long size, + lib.dwfl.ElfSymbolType type, + lib.dwfl.ElfSymbolBinding bind, + lib.dwfl.ElfSymbolVisibility visibility) + { + if(name.equals(objectName)){ + objectDeclaration = new SymbolObjectDeclaration(name, type, value, size); + } + } + } + Builder builder = new Builder(); + + //Search module containing current pc first + module.getSymbolByName(name, builder); + if(builder.objectDeclaration != null ) return builder.objectDeclaration; + + //Still now found... now search all modules + //XXX: should this restrect to objects with global visibility ?? + DwflModule[] modules = dwfl.getModules(); + for (int i = 0; i < modules.length; i++){ + modules[i].getSymbolByName(name, builder); + if(builder.objectDeclaration != null ) return builder.objectDeclaration; + } throw new ObjectDeclarationNotFoundException(name); } - + public Value getValue(String s) { if (s.charAt(0) == '$') { Registers regs = RegistersFactory.getRegisters(frame.getTask() @@ -110,21 +153,6 @@ public class ObjectDeclarationSearchEngine implements ExprSymTab{ return objectDeclaration.getValue(frame); } - public ByteOrder order() - { - return task.getISA().order(); - } - - public ByteBuffer taskMemory() - { - return task.getMemory(); - } - - public int getWordSize() - { - return task.getISA().wordSize(); - } - /** * XXX: Who knows if this works; it is certainly not implemented * correctly as it should use the ObjectDeclaration. @@ -141,4 +169,22 @@ public class ObjectDeclarationSearchEngine implements ExprSymTab{ candidates.add(sNext); } } + + + public ByteOrder order() + { + return task.getISA().order(); + } + + public ByteBuffer taskMemory() + { + return task.getMemory(); + } + + public int getWordSize() + { + return task.getISA().wordSize(); + } + + } diff --git a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java index a5cdf43..b7e93eb 100644 --- a/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java +++ b/frysk-core/frysk/debuginfo/TestObjectDeclarationSearchEngine.java @@ -43,11 +43,11 @@ import java.io.File; import frysk.config.Config; import frysk.proc.Task; +import frysk.scopes.Variable; import frysk.testbed.DaemonBlockedAtSignal; import frysk.testbed.TestLib; import frysk.testbed.TestfileTokenScanner; import frysk.value.ObjectDeclaration; -import frysk.scopes.Variable; /** * Tests @link CppVariableSearchEngine. @@ -137,6 +137,16 @@ public class TestObjectDeclarationSearchEngine extends TestLib{ } + public void testFindFirstElfSymbols(){ + String variableName = "first"; + String fileName = "funit-elf-symbols"; + String valueString = "{12,34,56,78}"; + + verifyVariableByValue(variableName, valueString, fileName); + + } + + /** * Runs the given executable until it sigfaults then searches for the * variable with the given name from that point. Then it verifies that @@ -183,4 +193,47 @@ public class TestObjectDeclarationSearchEngine extends TestLib{ } + /** + * This function should only be used when it is not possible to use + * verifyVariable, since it relies on the expression evaluation code + * and the type system. + * + * Runs the given executable until it sigfaults then searches for the + * variable with the given name from that point. Then it verifies that + * variable has the expected value. + * + * @param variableName + * Name of the variable to search for. + * @param variableToken + * a token string from the source file that is found on + * the same line as the variable. + * @param fileName + * name of the test file. + * @param execPath + * path to the executable to be run. + */ + private void verifyVariableByValue(String variableName, + String valueString, + String fileName){ + + Task task = (new DaemonBlockedAtSignal(fileName)).getMainTask(); + DebugInfoFrame frame = DebugInfoStackFactory.createVirtualStackTrace(task); + assertNotNull("frame object created", frame); + objectDeclarationSearchEngine = new ObjectDeclarationSearchEngine(frame); + ObjectDeclaration objectDeclaration = (ObjectDeclaration) objectDeclarationSearchEngine.getVariable(variableName); + + assertNotNull("Variable found", objectDeclaration); + assertEquals("Correct name", variableName, objectDeclaration.getName() ); + assertEquals("Variable value", valueString, objectDeclaration.getValue(frame).toPrint()); + + //Negative test: + try { + objectDeclaration = (Variable) objectDeclarationSearchEngine.getVariable("NOT"+variableName); + assertTrue("Exception was not thrown", false); + } catch (ObjectDeclarationNotFoundException e) { + // exception was thrown + } + + +} } diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog index 76d0c30..4d27f70 100644 --- a/frysk-core/frysk/pkglibdir/ChangeLog +++ b/frysk-core/frysk/pkglibdir/ChangeLog @@ -1,3 +1,7 @@ +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * funit-elf-symbols.S: New test file. + 2008-04-07 Mark Wielaard <mwielaard@redhat.com> * funit-loop-signal.c: New test. diff --git a/frysk-core/frysk/pkglibdir/funit-elf-symbols.S b/frysk-core/frysk/pkglibdir/funit-elf-symbols.S new file mode 100644 index 0000000..c76203a --- /dev/null +++ b/frysk-core/frysk/pkglibdir/funit-elf-symbols.S @@ -0,0 +1,57 @@ +// This file is part of the program FRYSK. +// +// Copyright 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. + +#include "frysk-asm.h" + +WORD(first, 0x4E38220C)// 12345678 + +FUNCTION_BEGIN(main,0) +MAIN_PROLOGUE(0) + +// crash +LOAD_IMMED_WORD (REG0, 0) +STORE_WORD (REG0, REG0) + +// End. And exit +MAIN_EPILOGUE(0) +FUNCTION_RETURN(main,0) +FUNCTION_END(main,0) + + + diff --git a/frysk-core/frysk/symtab/ChangeLog b/frysk-core/frysk/symtab/ChangeLog index e75e2e6..1d78580 100644 --- a/frysk-core/frysk/symtab/ChangeLog +++ b/frysk-core/frysk/symtab/ChangeLog @@ -1,3 +1,7 @@ +2008-04-07 Sami Wagiaalla <swagiaal@redhat.com> + + * SymbolObjectDeclaration.java: New class. + 2008-04-06 Petr Machata <pmachata@redhat.com> * PLTEntry.java: New file. diff --git a/frysk-core/frysk/symtab/SymbolObjectDeclaration.java b/frysk-core/frysk/symtab/SymbolObjectDeclaration.java new file mode 100644 index 0000000..b85ba48 --- /dev/null +++ b/frysk-core/frysk/symtab/SymbolObjectDeclaration.java @@ -0,0 +1,108 @@ +// 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.symtab; + +import java.util.ArrayList; + +import lib.dwfl.ElfSymbolType; +import frysk.debuginfo.DebugInfoFrame; +import frysk.debuginfo.PieceLocation; +import frysk.isa.ISA; +import frysk.scopes.SourceLocation; +import frysk.value.ArrayType; +import frysk.value.FunctionType; +import frysk.value.Location; +import frysk.value.ObjectDeclaration; +import frysk.value.StandardTypes; +import frysk.value.Type; +import frysk.value.Value; +import frysk.value.VoidType; + +/** + * XXX: This will be folded into symtab.symbol + */ +public class SymbolObjectDeclaration extends ObjectDeclaration { + + private String name; + private long address; + private long size; + private ElfSymbolType elfType; + private Type type; + + public SymbolObjectDeclaration(String name, ElfSymbolType elfType, long address, long size){ + this.name = name; + this.address = address; + this.size = size; + this.elfType = elfType; + } + + public String getName() { + return name; + } + + public SourceLocation getSourceLocation() { + return SourceLocation.UNKNOWN; + } + + public Type getType(ISA isa) { + + if(this.type != null){ + return this.type; + } + + if(this.elfType == ElfSymbolType.ELF_STT_FUNC){ + this.type = new FunctionType(this.name, new VoidType()); + }else{ + // treat all other types as array lists + // if any special handling is needed add an if statement. + ArrayList dims = new ArrayList(); + dims.add(new Integer((int) (size-1))); + this.type = new ArrayType(StandardTypes.uint8_t(isa.order()), (int) size, dims); + } + + return this.type; + } + + public Value getValue(DebugInfoFrame frame) { + Location location = PieceLocation.createSimpleLoc(address, size, frame.getTask().getMemory()); + return new Value(this.getType(frame.getTask().getISA()), location); + } + +} hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-04-07 20:51 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=20080407205107.22050.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).