public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Re: [SCM]  master: Add -sysroot option to fhpd.
       [not found] <20080114051518.31275.qmail@sourceware.org>
@ 2008-01-14  9:06 ` Mark Wielaard
  2008-01-14 13:17   ` Stan Cox
  2008-01-14 16:50 ` /an/absolute/path/program.debug; Was: " Andrew Cagney
  2008-01-14 17:09 ` Andrew Cagney
  2 siblings, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2008-01-14  9:06 UTC (permalink / raw)
  To: frysk; +Cc: Stan Cox

Hi Stan,

On Mon, 2008-01-14 at 05:15 +0000, scox@sourceware.org wrote:
> commit c02d1bd3109ef0406be508fc08426e75b1b6fe07
> Author: Stan Cox <scox@redhat.com>
> Date:   Mon Jan 14 00:12:57 2008 -0500
> 
>     Add -sysroot option to fhpd.
>     
>     * fhpd.java (main): Add sysroot option.
>     * Makefile.am (frysk/pkglibdir/funit-addresses-stripped): New
>     * DwflCache.java (getSysRoot): New
>     * DbgVariables.java (DbgVariables): Make public.
>     (vars): Make static final.  Add SYSROOT.
>     (getStringValue): Make static.  Return String.
>     * ListCommand.java (interpret): Consider SYSROOT.
>     * TestSysRoot.java: New file.
>     * Dwfl.java (Dwfl): Add sysroot parameter.  Change all callers.
> [...]
> +    public void testHaveSysRoot() {
> +	File testPath = Config.getPkgLibFile("funit-addresses");
> +	System.out.println(Config.getBinFile("fhpd").getAbsolutePath() +
> +		" -sysroot " + testPath.getParent() + "/test-sysroot/ " +
> +	        testPath.getParent() + "/test-sysroot/"
> +			   + testPath.getAbsolutePath());
> +	child = new Expect(new String[] {
> +		Config.getBinFile("fhpd").getAbsolutePath(),
> +		"-sysroot", testPath.getParent() + "/test-sysroot/",
> +	        testPath.getParent() + "/test-sysroot/"
> +		+ testPath.getAbsolutePath()
> +	    });

This test doesn't work for me (and note the System.out.println which
probably shouldn't be there). It gives the following output:

$ ./TestRunner frysk.hpd.TestSysRoot
Running testHaveSysRoot(frysk.hpd.TestSysRoot) .../home/mark/src/frysk-obj/frysk-core/frysk/bindir/fhpd -sysroot /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot/ /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot//home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/funit-addresses
ERROR
  frysk.expunit.EndOfFileException: end-of-file; expecting:  <<\(fhpd\) >>; buffer <<Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]

      -console <LOG=LEVEL,...>    Set the log LOG to level LEVEL. Can set 
                                    multiple logs. The LEVEL can be [ OFF | 
                                    SEVERE | WARNING | INFO | CONFIG | FINE | 
                                    FINER | FINEST | ALL]. Example: -console 
                                    frysk=FINEST
      -log <LOG=LEVEL,...>        Set the log LOG to level LEVEL. Can set 
                                    multiple logs. The LEVEL can be [ OFF | 
                                    SEVERE | WARNING | INFO | CONFIG | FINE | 
                                    FINER | FINEST | ALL]. Example -log 
                                    frysk=FINE
      -verbose                    output verbose logging messages
      -trace <LOG=LEVEL,...>      Set the logger LOG to level LEVEL.
                                    The LEVEL can be [ NONE | FINE | FINEST ].
                                    Example -trace frysk=FINE
      -noexe                      Do not attempt to read an executable for a 
                                    corefile 
  -s, -sysroot SysRoot-Path       Assume the executable is from a sysroot 
                                    build 

Standard options:
  -help       print this help, then exit
  -version    print version number, then exit

Exception in thread "main" java.lang.RuntimeException: command not readable: /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot//home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/funit-addresses
   at frysk.bindir.fhpd$1.parseCommand(fhpd)
   at frysk.util.CommandlineParser.doParse(fhpd)
   at frysk.util.CommandlineParser.parse(fhpd)
   at frysk.bindir.fhpd.main(fhpd)
>>

I assume you have something in your tree that generates
the /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot/
directory. But I couldn't figure out how to properly do that.

Could you take a look? And maybe add some documentation on how a sysroot
dir should look like, how to generate one by hand?

Thanks,

Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [SCM]  master: Add -sysroot option to fhpd.
  2008-01-14  9:06 ` [SCM] master: Add -sysroot option to fhpd Mark Wielaard
@ 2008-01-14 13:17   ` Stan Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Stan Cox @ 2008-01-14 13:17 UTC (permalink / raw)
  To: Frysk List

On Mon, 2008-01-14 at 10:06 +0100, Mark Wielaard wrote:
> Hi Stan,
> 
> On Mon, 2008-01-14 at 05:15 +0000, scox@sourceware.org wrote:
> > commit c02d1bd3109ef0406be508fc08426e75b1b6fe07
> > Author: Stan Cox <scox@redhat.com>
> > Date:   Mon Jan 14 00:12:57 2008 -0500
> > 
> >     Add -sysroot option to fhpd.
> >     
> >     * fhpd.java (main): Add sysroot option.
> >     * Makefile.am (frysk/pkglibdir/funit-addresses-stripped): New
> >     * DwflCache.java (getSysRoot): New
> >     * DbgVariables.java (DbgVariables): Make public.
> >     (vars): Make static final.  Add SYSROOT.
> >     (getStringValue): Make static.  Return String.
> >     * ListCommand.java (interpret): Consider SYSROOT.
> >     * TestSysRoot.java: New file.
> >     * Dwfl.java (Dwfl): Add sysroot parameter.  Change all callers.
> > [...]
> > +    public void testHaveSysRoot() {
> > +	File testPath = Config.getPkgLibFile("funit-addresses");
> > +	System.out.println(Config.getBinFile("fhpd").getAbsolutePath() +
> > +		" -sysroot " + testPath.getParent() + "/test-sysroot/ " +
> > +	        testPath.getParent() + "/test-sysroot/"
> > +			   + testPath.getAbsolutePath());
> > +	child = new Expect(new String[] {
> > +		Config.getBinFile("fhpd").getAbsolutePath(),
> > +		"-sysroot", testPath.getParent() + "/test-sysroot/",
> > +	        testPath.getParent() + "/test-sysroot/"
> > +		+ testPath.getAbsolutePath()
> > +	    });
> 
> This test doesn't work for me (and note the System.out.println which
> probably shouldn't be there). It gives the following output:
> 
> $ ./TestRunner frysk.hpd.TestSysRoot
> Running testHaveSysRoot(frysk.hpd.TestSysRoot) .../home/mark/src/frysk-obj/frysk-core/frysk/bindir/fhpd -sysroot /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot/ /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot//home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/funit-addresses
> ERROR
>   frysk.expunit.EndOfFileException: end-of-file; expecting:  <<\(fhpd\) >>; buffer <<Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]
> 
>       -console <LOG=LEVEL,...>    Set the log LOG to level LEVEL. Can set 
>                                     multiple logs. The LEVEL can be [ OFF | 
>                                     SEVERE | WARNING | INFO | CONFIG | FINE | 
>                                     FINER | FINEST | ALL]. Example: -console 
>                                     frysk=FINEST
>       -log <LOG=LEVEL,...>        Set the log LOG to level LEVEL. Can set 
>                                     multiple logs. The LEVEL can be [ OFF | 
>                                     SEVERE | WARNING | INFO | CONFIG | FINE | 
>                                     FINER | FINEST | ALL]. Example -log 
>                                     frysk=FINE
>       -verbose                    output verbose logging messages
>       -trace <LOG=LEVEL,...>      Set the logger LOG to level LEVEL.
>                                     The LEVEL can be [ NONE | FINE | FINEST ].
>                                     Example -trace frysk=FINE
>       -noexe                      Do not attempt to read an executable for a 
>                                     corefile 
>   -s, -sysroot SysRoot-Path       Assume the executable is from a sysroot 
>                                     build 
> 
> Standard options:
>   -help       print this help, then exit
>   -version    print version number, then exit
> 
> Exception in thread "main" java.lang.RuntimeException: command not readable: /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot//home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/funit-addresses
>    at frysk.bindir.fhpd$1.parseCommand(fhpd)
>    at frysk.util.CommandlineParser.doParse(fhpd)
>    at frysk.util.CommandlineParser.parse(fhpd)
>    at frysk.bindir.fhpd.main(fhpd)
> >>
> 
> I assume you have something in your tree that generates
> the /home/mark/src/frysk-obj/frysk-core/frysk/pkglibdir/test-sysroot/
> directory. But I couldn't figure out how to properly do that.
> 
> Could you take a look? And maybe add some documentation on how a sysroot
> dir should look like, how to generate one by hand?
> 
> Thanks,
> 
> Mark
> 

That sysroot directory was supposed to be created but meanwhile can be
created (and tested) via:  frysk/pkglibdir/funit-addresses-stripped;
./TestRunner frysk.hpd.TestSysRoot
That test is a little baroque.  It relies on the build process to build
a frysk-core/frysk/pkglibdir/test-sysroot directory, which simulates
building with mock and installing via a sysroot.  Then TestSysRoot tests
finding the debug and source via testing with fhpd.

What is currently there:
Added -sysroot option to fhpd.  This option sets the SYSROOT debug
variable in DbgVariables.java.  Finding the debuginfo in a sysroot is a
little tricky.   Given: /sys/root/dir/usr/bin/program
and  /sys/root/dir/usr/lib/debug/usr/bin/program.debug
Elfutils can be given an absolute or relative path to look for
program.debug.  It will look in: 
1. /sys/root/dir/usr/bin/program.debug 
2. /sys/root/dir/usr/bin/a/relative/path/program.debug 
3. /an/absolute/path/sys/root/dir/usr/bin/program.debug
It will not look in /an/absolute/path/program.debug, otherwise it could
be given /sys/root/dir/usr/lib/debug/usr/bin.  Therefore DwflCache.java
generates a relative path that has the same effect.  ListCommand.java
considers SYSROOT when looking for program.c.

What is not there yet:
The -sysroot option has not been added to fstack or other fhpd requests
yet and -sysroot needs to be added to the documentation.  The bare
minimum was done to get DbgVariables.java to support accessing variable
values not just by sysroot, but other uses as well.  More extensive
testing of sysroot needs to be done by TestSysRoot.java.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* /an/absolute/path/program.debug; Was: [SCM]  master: Add -sysroot  option to fhpd.
       [not found] <20080114051518.31275.qmail@sourceware.org>
  2008-01-14  9:06 ` [SCM] master: Add -sysroot option to fhpd Mark Wielaard
@ 2008-01-14 16:50 ` Andrew Cagney
  2008-01-14 20:27   ` Stan Cox
  2008-01-14 17:09 ` Andrew Cagney
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2008-01-14 16:50 UTC (permalink / raw)
  To: Stan Cox; +Cc: frysk

scox@sourceware.org wrote:
> +/**
> + * Given: a mock generated /sys/root/dir/usr/bin/program 
> + *			   /sys/root/dir/usr/lib/debug/usr/bin/program.debug
> + * Elfutils can be given an absolute or relative path to look for program.debug.
> + * It will look in: 
> + * 1. /sys/root/dir/usr/bin/program.debug 
> + * 2. /sys/root/dir/usr/bin/a/relative/path/program.debug 
> + * 3. /an/absolute/path/sys/root/dir/usr/bin/program.debug
>   
I'm not sure I follow this one.
> + * It would be helpful if it also looked in /an/absolute/path/program.debug 
> + * so it could be given /sys/root/dir/usr/lib/debug/usr/bin.  Lacking that we
> + * need to generate a relative path that has the same effect.
>   
The sysroot, by defining the top-level of the debug-info tree, provides 
a consistent root for locating both:
  -> the debug info
  -> the source code
directory search paths are different, so, I think, would want to be 
manipulated using a separate command; and their interaction with sysroot 
would need to be carefully considered.  For instance, given $SYSROOT, 
should it search $SYSROOT/$DEBUGPATH?

> + * XXX: Change to use java.io.File?
>   

Yes, definitely.

Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [SCM]  master: Add -sysroot option to fhpd.
       [not found] <20080114051518.31275.qmail@sourceware.org>
  2008-01-14  9:06 ` [SCM] master: Add -sysroot option to fhpd Mark Wielaard
  2008-01-14 16:50 ` /an/absolute/path/program.debug; Was: " Andrew Cagney
@ 2008-01-14 17:09 ` Andrew Cagney
  2008-01-14 20:33   ` Stan Cox
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2008-01-14 17:09 UTC (permalink / raw)
  To: Stan Cox; +Cc: frysk

Stan,

A few things caught my eye:

scox@sourceware.org wrote:
> +frysk/pkglibdir/funit-addresses-stripped: frysk/pkglibdir/funit-addresses
> +	strip -o $@ frysk/pkglibdir/funit-addresses
> +	mkdir -p `pwd`/frysk/pkglibdir/test-sysroot/`pwd`/frysk/pkglibdir
> +	cp -r `pwd`/frysk/pkglibdir/funit-addresses `pwd`/frysk/pkglibdir/test-sysroot/`pwd`/frysk/pkglibdir
> +	mkdir -p `pwd`/frysk/pkglibdir/test-sysroot/$(realpath $(srcdir))/frysk/pkglibdir
> +	cp -r $(realpath $(srcdir))/frysk/pkglibdir/funit-addresses.c `pwd`/frysk/pkglibdir/test-sysroot/$(realpath $(srcdir))/frysk/pkglibdir
> +	mkdir -p `pwd`/frysk/pkglibdir/test-sysroot/usr/lib/debug/`pwd`/frysk/pkglibdir/
> +	eu-strip --remove-comment -f `pwd`/frysk/pkglibdir/test-sysroot/usr/lib/debug/`pwd`/frysk/pkglibdir/funit-addresses.debug \
> +	`pwd`/frysk/pkglibdir/test-sysroot/`pwd`/frysk/pkglibdir/funit-addresses
>   

Right on; it needs to construct what looks like an installed sysroot so 
that we're testing against how things will appear in a live system.  Two 
extra things to consider though: how to get this data installed; and now 
to have it also built 32-bit.

> diff --git a/frysk-core/frysk/debuginfo/DebugInfoFrame.java b/frysk-core/frysk/debuginfo/DebugInfoFrame.java
> index 8f2229e..f1d8682 100644
> --- a/frysk-core/frysk/debuginfo/DebugInfoFrame.java
> +++ b/frysk-core/frysk/debuginfo/DebugInfoFrame.java
> @@ -48,6 +48,7 @@ import lib.dwfl.Dwfl;
>  import lib.dwfl.DwflDieBias;
>  import lib.dwfl.DwflLine;
>  import frysk.dwfl.DwflCache;
> +import frysk.hpd.DbgVariables;
>  import frysk.rt.LineXXX;
>  import frysk.scopes.SourceLocation;
>  import frysk.scopes.Scope;
> @@ -183,6 +184,13 @@ public class DebugInfoFrame extends FrameDecorator {
>    		    File parent = new File(dwflLine.getCompilationDir());
>    		    f = new File(parent, dwflLine.getSourceFile());
>  		}
> +		else {
> +		    String sysroot = DbgVariables.getStringValue("SYSROOT");
> +		    if (sysroot.length() > 0) {
> +			File parent = new File(sysroot);
> +			f = new File(parent, dwflLine.getSourceFile());
> +		    }
> +		}
>   
I'm not so sure about DebugInfoFrame using hpd to obtain a sysroot; and 
can this be coded to just assume that there's a sysroot ("/" by default)?

Given that the underlying Dwfl knows its sysroot, would it be both 
simpler and more consistent to use that, and to do so internally?  It 
would also remove the need to constantly need to remember to add code 
like the below:

> diff --git a/frysk-core/frysk/hpd/ListCommand.java b/frysk-core/frysk/hpd/ListCommand.java
> index 7b9c4ce..0161144 100644
> --- a/frysk-core/frysk/hpd/ListCommand.java
> +++ b/frysk-core/frysk/hpd/ListCommand.java
> @@ -120,7 +120,13 @@ class ListCommand extends ParameterizedCommand {
>                          }
>  			if (funcDie.getTag().hashCode() == DwTag.SUBPROGRAM_) {
>  			    line = (int)funcDie.getDeclLine();
> -			    file = funcDie.getDeclFile();
> +			    String sysRoot = DbgVariables.getStringValue("SYSROOT");
> +			    if (sysRoot.length() > 0) {
> +				File parent = new File(sysRoot);
> +				file = new File(parent, funcDie.getDeclFile().getName());
> +			    }
> +			    else
> +				file = funcDie.getDeclFile();
>  			}
>  			else {
>  			    cli.addMessage("function " + cmd.parameter(0) + " not found.",
>   

and

> @@ -146,6 +152,11 @@ class ListCommand extends ParameterizedCommand {
>              if (file == null) {
>                  if (frame.getLine() != SourceLocation.UNKNOWN) {
>                      file = (frame.getLine()).getFile();
> +		    String sysRoot = DbgVariables.getStringValue("SYSROOT");
> +		    if (sysRoot.length() > 0) {
> +		      File parent = new File(sysRoot);
> +		      file = new File(parent, file.getAbsolutePath());
> +		    }
>                      if (file == null) {
>                          cli.addMessage("No symbol table is available.",
>                                         Message.TYPE_NORMAL);
>   

where ever a source-file is needed.

Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: /an/absolute/path/program.debug; Was: [SCM]  master: Add  -sysroot option to fhpd.
  2008-01-14 16:50 ` /an/absolute/path/program.debug; Was: " Andrew Cagney
@ 2008-01-14 20:27   ` Stan Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Stan Cox @ 2008-01-14 20:27 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: frysk

Here is a more explicit example using a mock generated tree for ed and
which.  So if elfutils is given the path
.debug:/accu/sysroot/usr/lib/debug then it will look in:  
/accu/sysroot/usr/bin/which.debug (looks in dir of executable)
/accu/sysroot/usr/bin/.debug/which.debug (relative: looks in dir of
 executable + relative dir + which.debug)
/accu/sysroot/usr/lib/debug/accu/sysroot/usr/bin/which.debug
 (absolute: looks in absolute + executable dir + which.debug)
So what the code does is use a relative dir e.g. ../../usr/lib/debug/
so one gets
/accu/sysroot/usr/bin/../../usr/lib/debug/usr/bin/which.debug
(executable dir + relative dir + executable dir + which.debug)

/accu/sysroot/bin:
./  ../  ed*

/accu/sysroot/usr/bin:
./  ../  which*

/accu/sysroot/usr/lib/debug/bin:
./  ../  ed.debug*

/accu/sysroot/usr/lib/debug/usr/bin:
./  ../  which.debug*

/accu/sysroot/usr/src/debug/ed-0.5:
./   buf.c	    carg_parser.h  glbl.c  main.c	re.c
../  carg_parser.c  ed.h	   io.c    main_loop.c	signal.c

/accu/sysroot/usr/src/debug/which-2.16:
./  ../  bash.c  getopt.h  tilde/  which.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [SCM]  master: Add -sysroot option to fhpd.
  2008-01-14 17:09 ` Andrew Cagney
@ 2008-01-14 20:33   ` Stan Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Stan Cox @ 2008-01-14 20:33 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Frysk List


> Right on; it needs to construct what looks like an installed sysroot so 
> that we're testing against how things will appear in a live system.  Two 
> extra things to consider though: how to get this data installed; and now 
> to have it also built 32-bit.

I'm on this one now.

> can this be coded to just assume that there's a sysroot ("/" by default)?
> 
> Given that the underlying Dwfl knows its sysroot, would it be both 
> simpler and more consistent to use that, and to do so internally?  

Say, that is a clever idea; I'll look into that.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-01-14 20:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080114051518.31275.qmail@sourceware.org>
2008-01-14  9:06 ` [SCM] master: Add -sysroot option to fhpd Mark Wielaard
2008-01-14 13:17   ` Stan Cox
2008-01-14 16:50 ` /an/absolute/path/program.debug; Was: " Andrew Cagney
2008-01-14 20:27   ` Stan Cox
2008-01-14 17:09 ` Andrew Cagney
2008-01-14 20:33   ` Stan Cox

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).