public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@redhat.com>
To: Mark Wielaard <mark@klomp.org>
Cc: Phil Muldoon <pmuldoon@redhat.com>, Frysk Hackers <frysk@sourceware.org>
Subject: Re: Corefile -arch 32 test failures with breakpoint and stacktrace  	tests
Date: Tue, 09 Oct 2007 17:08:00 -0000	[thread overview]
Message-ID: <470BB52E.9010606@redhat.com> (raw)
In-Reply-To: <1191840378.3859.20.camel@dijkstra.wildebeest.org>

Mark Wielaard wrote:
> 2007-10-08 Mark Wielaard <mwielaard@redhat.com>
>         * 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  <mwielaard@redhat.com>
> +
> +	* TestLinuxCore.java (Symbol): New static helper class.
> +	(getFunctionEntryAddress): Use Dwfl directly instead of
> +	constructing Elf and Dwarf objects directly.
> +	
>  2007-10-02  Andrew Cagney  <cagney@redhat.com>
>  
>  	* 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();
>    }
>  
>    /**
>   

  reply	other threads:[~2007-10-09 17:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-06  8:12 Phil Muldoon
2007-10-08 10:46 ` Mark Wielaard
2007-10-09 17:08   ` Andrew Cagney [this message]
2007-10-09 17:30     ` dl symbol search path; Was: " Andrew Cagney
2007-10-16  2:39       ` Roland McGrath

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=470BB52E.9010606@redhat.com \
    --to=cagney@redhat.com \
    --cc=frysk@sourceware.org \
    --cc=mark@klomp.org \
    --cc=pmuldoon@redhat.com \
    /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: link
Be 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).