From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28322 invoked by alias); 9 Oct 2007 17:08:50 -0000 Received: (qmail 28138 invoked by uid 22791); 9 Oct 2007 17:08:48 -0000 X-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS,TW_DW,URIBL_BLACK X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 09 Oct 2007 17:08:44 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id l99H8eCS013414; Tue, 9 Oct 2007 13:08:40 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l99H8e11007512; Tue, 9 Oct 2007 13:08:40 -0400 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l99H8dvl019282; Tue, 9 Oct 2007 13:08:39 -0400 Message-ID: <470BB52E.9010606@redhat.com> Date: Tue, 09 Oct 2007 17:08:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Mark Wielaard CC: Phil Muldoon , Frysk Hackers Subject: Re: Corefile -arch 32 test failures with breakpoint and stacktrace tests References: <47074377.5040602@redhat.com> <1191840378.3859.20.camel@dijkstra.wildebeest.org> In-Reply-To: <1191840378.3859.20.camel@dijkstra.wildebeest.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00030.txt.bz2 Mark Wielaard wrote: > 2007-10-08 Mark Wielaard > * TestLinuxCore.java (Symbol): New static helper class. > (getFunctionEntryAddress): Use Dwfl directly instead of > constructing Elf and Dwarf objects directly. > > This much code being wired into a test-case scares me. Would a better place for this be frysk.symtab.SymbolFactory; with a test case? > ------------------------------------------------------------------------ > > Index: frysk-core/frysk/proc/dead/ChangeLog > =================================================================== > RCS file: /cvs/frysk/frysk-core/frysk/proc/dead/ChangeLog,v > retrieving revision 1.32 > diff -u -r1.32 ChangeLog > --- frysk-core/frysk/proc/dead/ChangeLog 2 Oct 2007 22:31:50 -0000 1.32 > +++ frysk-core/frysk/proc/dead/ChangeLog 8 Oct 2007 10:44:52 -0000 > @@ -1,3 +1,9 @@ > +2007-10-08 Mark Wielaard > + > + * TestLinuxCore.java (Symbol): New static helper class. > + (getFunctionEntryAddress): Use Dwfl directly instead of > + constructing Elf and Dwarf objects directly. > + > 2007-10-02 Andrew Cagney > > * LinuxProc.java (sendrecISA()): Add. > Index: frysk-core/frysk/proc/dead/TestLinuxCore.java > =================================================================== > RCS file: /cvs/frysk/frysk-core/frysk/proc/dead/TestLinuxCore.java,v > retrieving revision 1.16 > diff -u -r1.16 TestLinuxCore.java > --- frysk-core/frysk/proc/dead/TestLinuxCore.java 10 Aug 2007 18:54:34 -0000 1.16 > +++ frysk-core/frysk/proc/dead/TestLinuxCore.java 8 Oct 2007 10:44:52 -0000 > @@ -45,7 +45,6 @@ > import java.io.File; > import java.io.PrintWriter; > import java.io.StringWriter; > -import java.util.ArrayList; > > import frysk.proc.Action; > import frysk.proc.Isa; > @@ -67,6 +66,7 @@ > import frysk.testbed.LegacyOffspring; > > import lib.dwfl.*; > +import frysk.dwfl.*; > > public class TestLinuxCore > extends TestLib > @@ -387,22 +387,66 @@ > assertEquals(origb, coreb); > } > > + > + // Helper class since there there isn't a get symbol method in Dwfl, > + // so we need to wrap it all in a builder pattern. > + static class Symbol implements SymbolBuilder > + { > + private String name; > + private long address; > + > + private boolean found; > + > + private Symbol() > + { > + // properties get set in public static get() method. > + } > + > + static Symbol get(Dwfl dwfl, String name) > + { > + Symbol sym = new Symbol(); > + sym.name = name; > + DwflModule[] modules = dwfl.getModules(); > + for (int i = 0; i < modules.length && ! sym.found; i++) > + modules[i].getSymbolByName(name, sym); > + > + if (sym.found) > + return sym; > + else > + return null; > + } > + > + String getName() > + { > + return name; > + } > + > + long getAddress() > + { > + return address; > + } > + > + public void symbol(String name, long value, long size, > + int type, int bind, int visibility) > + { > + if (name.equals(this.name)) > + { > + this.address = value; > + this.found = true; > + } > + } > + } > + > /** > - * Returns the address of the requested function through query the > - * Proc Elf and DwarfDie. Asserts that the function has only 1 > - * entry point. > + * Returns the address of the requested function through query Dwfl > + * of the main Task of the given Proc. > */ > private static long getFunctionEntryAddress(Proc proc, String func) > - throws ElfException > { > - Elf elf = new Elf(proc.getExe(), ElfCommand.ELF_C_READ); > - Dwarf dwarf = new Dwarf(elf, DwarfCommand.READ, null); > - DwarfDie die = DwarfDie.getDecl(dwarf, func); > - ArrayList entryAddrs = die.getEntryBreakpoints(); > - > - // We really expect just one entry point. > - assertEquals(entryAddrs.size(), 1); > - return ((Long) entryAddrs.get(0)).longValue(); > + Task task = proc.getMainTask(); > + Dwfl dwfl = DwflCache.getDwfl(task); > + Symbol sym = Symbol.get(dwfl, func); > + return sym.getAddress(); > } > > /** >