public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: scox@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add -sysroot option to fhpd. Date: Mon, 14 Jan 2008 05:15:00 -0000 [thread overview] Message-ID: <20080114051518.31275.qmail@sourceware.org> (raw) The branch, master has been updated via c02d1bd3109ef0406be508fc08426e75b1b6fe07 (commit) from 16dc92ed18a93d3a0377a3f894534a37a942a0f7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- 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. ----------------------------------------------------------------------- Summary of changes: frysk-core/ChangeLog | 4 + frysk-core/Makefile.am | 10 ++ frysk-core/frysk/bindir/ChangeLog | 4 + frysk-core/frysk/bindir/fhpd.java | 19 ++++- frysk-core/frysk/debuginfo/ChangeLog | 4 + frysk-core/frysk/debuginfo/DebugInfoFrame.java | 8 ++ frysk-core/frysk/dwfl/ChangeLog | 5 + frysk-core/frysk/dwfl/DwflCache.java | 50 +++++++++++- frysk-core/frysk/hpd/ChangeLog | 8 ++ frysk-core/frysk/hpd/DbgVariables.java | 12 ++- frysk-core/frysk/hpd/ListCommand.java | 13 +++- .../{bindir/TestFhd.java => hpd/TestSysRoot.java} | 87 +++++++++----------- frysk-sys/lib/dwfl/ChangeLog | 6 ++ frysk-sys/lib/dwfl/Dwfl.java | 12 ++-- frysk-sys/lib/dwfl/TestDwarfDie.java | 8 +- frysk-sys/lib/dwfl/TestDwfl.java | 20 ++-- frysk-sys/lib/dwfl/cni/Dwfl.cxx | 29 +++++-- 17 files changed, 215 insertions(+), 84 deletions(-) copy frysk-core/frysk/{bindir/TestFhd.java => hpd/TestSysRoot.java} (63%) mode change 100755 => 100644 First 500 lines of diff: diff --git a/frysk-core/ChangeLog b/frysk-core/ChangeLog index b98593d..788a81b 100644 --- a/frysk-core/ChangeLog +++ b/frysk-core/ChangeLog @@ -1,3 +1,7 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * Makefile.am (frysk/pkglibdir/funit-addresses-stripped): New. + 2007-12-03 Andrew Cagney <cagney@redhat.com> * Makefile.am (GEN_CLASSPATH): Add frysk-sys.jar. diff --git a/frysk-core/Makefile.am b/frysk-core/Makefile.am index 903595c..0256692 100644 --- a/frysk-core/Makefile.am +++ b/frysk-core/Makefile.am @@ -110,6 +110,16 @@ frysk_pkglibdir_funit_symbols_stripped_SOURCES = frysk/pkglibdir/funit-symbols-stripped: frysk/pkglibdir/funit-symbols strip -o $@ frysk/pkglibdir/funit-symbols +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 + if DO_ARCH32_TEST pkglib32_PROGRAMS += frysk/pkglibdir/arch32/funit-symbols-nodebug frysk_pkglibdir_arch32_funit_symbols_nodebug_SOURCES = diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index de7680c..60d4c2c 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,7 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * fhpd.java (main): Add sysroot option. + 2008-01-10 Phil Muldoon <pmuldoon@redhat.com> * TestFauxv.java (testAuxvCore): Adjust expect output diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java index 277e604..9123d06 100644 --- a/frysk-core/frysk/bindir/fhpd.java +++ b/frysk-core/frysk/bindir/fhpd.java @@ -63,6 +63,7 @@ public class fhpd static File core; static File exeFile; static boolean noExe = false; + static String sysroot; final static class FhpdCompletor implements Completor { @@ -101,10 +102,10 @@ public class fhpd pid = pids[0].id; } - public void parseCores(CoreExePair[] corePairs) { + public void parseCores(CoreExePair[] corePairs) { core = corePairs[0].coreFile; exeFile = corePairs[0].exeFile; - } + } }; parser.add(new Option("noexe", "Do not attempt to read an"+ " executable for a corefile ") { @@ -118,6 +119,18 @@ public class fhpd } } }); + parser.add(new Option("sysroot", 's', + "Assume the executable is from a sysroot build ", + "SysRoot-Path") { + public void parsed(String sysrootValue) throws OptionException { + try { + sysroot = sysrootValue; + } catch (IllegalArgumentException e) { + throw new OptionException("Invalid sysroot parameter " + + sysrootValue); + } + } + }); parser.setHeader("Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]"); parser.parse(args); @@ -137,6 +150,8 @@ public class fhpd else if (noExe) line +=" -noexe"; } + if (sysroot != null) + line = line + " ; set SYSROOT " + sysroot; } catch (IOException ignore) {} diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 4730e4f..3721f0d 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,7 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * DebugInfoFrame.java (getLine): Consider SYSROOT. + 2008-01-07 Nurdin Premji <npremji@redhat.com> * CompilerVersion: New. 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()); + } + } this.line = new SourceLocation(f, dwflLine.getLineNum(), dwflLine.getColumn()); } diff --git a/frysk-core/frysk/dwfl/ChangeLog b/frysk-core/frysk/dwfl/ChangeLog index 9e9ea65..18ee8f2 100644 --- a/frysk-core/frysk/dwfl/ChangeLog +++ b/frysk-core/frysk/dwfl/ChangeLog @@ -1,3 +1,8 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * DwflCache.java (getSysRoot): New. + (getDwfl): Call it. + 2007-10-18 Rick Moseley <rmoseley@redhat.com> * DwflFactory.java: Check for a null vdso before attempting to diff --git a/frysk-core/frysk/dwfl/DwflCache.java b/frysk-core/frysk/dwfl/DwflCache.java index a9513c4..2788446 100644 --- a/frysk-core/frysk/dwfl/DwflCache.java +++ b/frysk-core/frysk/dwfl/DwflCache.java @@ -39,6 +39,7 @@ package frysk.dwfl; +import frysk.hpd.DbgVariables; import frysk.proc.Task; import java.util.Iterator; import java.util.WeakHashMap; @@ -75,6 +76,52 @@ public class DwflCache */ private static WeakHashMap allDwfls = new WeakHashMap(); +/** + * 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 + * 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. + * XXX: Change to use java.io.File? + * + * @param pathname of executable + * @return a path where elfutils can find program.debug for separate debuginfo. + */ + + private static String getSysRoot(String execPathParm) { + String sysRoot = DbgVariables.getStringValue("SYSROOT"); + if (sysRoot.length() == 0) + return "/usr/lib/debug"; + StringBuffer execPath = new StringBuffer(execPathParm); + StringBuffer relSysRoot = new StringBuffer("/.."); + execPath.replace(0, sysRoot.length(), ""); + int slashidx = execPath.lastIndexOf("/"); + execPath.replace(slashidx, execPath.length(),""); + String nonSysRootPath = new String(execPath.toString()); + slashidx = execPath.lastIndexOf("/"); + while (slashidx >= 0) { + while (execPath.substring(slashidx).compareTo("/..") == 0) { + execPath.replace(slashidx, execPath.length(), ""); + slashidx = execPath.lastIndexOf("/"); + execPath.replace(slashidx, execPath.length(), ""); + slashidx = execPath.lastIndexOf("/"); + } + execPath.replace(slashidx, execPath.length(), ""); + slashidx = execPath.lastIndexOf("/"); + if (slashidx != 0) + relSysRoot.append("/.."); + } + relSysRoot.deleteCharAt(0); + relSysRoot.append("/usr/lib/debug/"); + relSysRoot.append(nonSysRootPath); + return relSysRoot.toString(); + } + /** * return a Dwfl for a {@link frysk.proc.Task}. * @@ -85,9 +132,10 @@ public class DwflCache logger.log(Level.FINE, "entering createDwfl, task: {0}\n", task); // If there is no dwfl for this task create one. + String relativeSysRoot = getSysRoot(task.getProc().getExe()); if (!modMap.containsKey(task)) { logger.log(Level.FINEST, "creating new dwfl for task {0}\n", task); - Dwfl dwfl = new Dwfl(); + Dwfl dwfl = new Dwfl(relativeSysRoot); DwflFactory.updateDwfl(dwfl, task); Mod mod = new Mod(dwfl, task.getMod()); modMap.put(task, mod); diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 5d5f32a..c8458e9 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,11 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * 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. + 2008-01-11 Andrew Cagney <cagney@redhat.com> * CLI.java (nasty(Exception)): Check for diff --git a/frysk-core/frysk/hpd/DbgVariables.java b/frysk-core/frysk/hpd/DbgVariables.java index c115224..23df999 100644 --- a/frysk-core/frysk/hpd/DbgVariables.java +++ b/frysk-core/frysk/hpd/DbgVariables.java @@ -50,7 +50,7 @@ import java.util.List; /** * Debugger variable accessible through the "set" command. */ -class DbgVariables { +public class DbgVariables { public static int VARTYPE_INT = 0; public static int VARTYPE_STRING = 1; public static int VARTYPE_CUSTOM = 2; @@ -99,7 +99,7 @@ class DbgVariables { } } - private final SortedMap vars = new TreeMap(); + private static final SortedMap vars = new TreeMap(); public DbgVariables() { vars.put("MODE", new Value(VARTYPE_CUSTOM, "MULTILEVEL", new String[] {"THREADS", "PROCESSES", "MULTILEVEL"})); @@ -113,6 +113,7 @@ class DbgVariables { vars.put("MAX_LEVELS", new Value(VARTYPE_INT, new Integer(20))); vars.put("MAX_LIST", new Value(VARTYPE_INT, new Integer(20))); vars.put("PROMPT", new Value(VARTYPE_STRING, "(frysk) ")); + vars.put("SYSROOT", new Value(VARTYPE_STRING, "")); vars.put("SOURCE_PATH", new Value(VARTYPE_STRING, "")); vars.put("EXECUTABLE_PATH", new Value(VARTYPE_STRING, "./:" + System.getenv("PATH"))); } @@ -160,8 +161,11 @@ class DbgVariables { return ((Integer)vars.get(var)).intValue(); } - public String getStringValue(String var) { - return (String)vars.get(var); + public static String getStringValue(String var) { + if (vars.size() == 0) + return ""; + else + return (String)((Value)vars.get(var)).value; } public Object getValue(String var) { 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.", @@ -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); diff --git a/frysk-core/frysk/bindir/TestFhd.java b/frysk-core/frysk/hpd/TestSysRoot.java old mode 100755 new mode 100644 similarity index 63% copy from frysk-core/frysk/bindir/TestFhd.java copy to frysk-core/frysk/hpd/TestSysRoot.java index 1cfe4d7..af584f0 --- a/frysk-core/frysk/bindir/TestFhd.java +++ b/frysk-core/frysk/hpd/TestSysRoot.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2006, 2007, Red Hat Inc. +// 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 @@ -37,62 +37,53 @@ // version and license this file solely under the GPL without // exception. -package frysk.bindir; +package frysk.hpd; import frysk.Config; import frysk.expunit.Expect; -import frysk.testbed.TestLib; +import java.io.File; /** - * This performs a "sniff" test of Fstack, confirming basic - * functionality of the command line interface. - * - * For more specific tests see frysk.hpd. + * Test the functionality of the -sysroot option. */ -public class TestFhd - extends TestLib -{ - Expect e; - Expect child; - String prompt = "\\(fhpd\\) "; +public class TestSysRoot extends TestLib { + Expect expect; + public void tearDown () { - if (e != null) - e.close (); - e = null; - if (child != null) - child.close (); - child = null; } - - public void testHpdPid () { - child = new Expect(Config.getPkgLibFile("hpd-c")); - e = new Expect(new String[] { - Config.getBinFile("fhpd").getPath(), - child.getPid().toString() - }); - e.expect(5, "Attached to process.*\n" + prompt); - e.close(); - } - - public void testHpdCommand () { - e = new Expect(new String[] { - Config.getBinFile("fhpd").getPath(), - Config.getPkgLibFile("hpd-c").getPath() - }); - e.expect(5, "Loaded executable file.*" + prompt); - e.close(); - } - - public void testHpdCore () { - e = new Expect(new String[] { - Config.getBinFile("fhpd").getPath(), - Config.getPkgDataFile("test-core-x86").getPath(), - "-noexe" - }); - e.expect(5, "Attached to core file.*"); - e.close(); + + 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() + }); + child.expect(prompt); + child.send("break main\n"); + child.expect(prompt); + child.send("run\n"); + child.expect("Breakpoint"); + child.send("list\n"); + child.expect(".*int main.int argc, char. argv.*"); + child.send("next\n"); + child.expect(prompt); + child.send("next\n"); + child.expect(prompt); + child.send("next\n"); + child.expect(prompt); + child.send("print static_int\n"); + child.expect("22.*" + prompt); + child.send("print volatile_int\n"); + child.expect("33.*" + prompt); + child.send("quit"); + child.close(); } - } diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog index 9be27e5..670e841 100644 --- a/frysk-sys/lib/dwfl/ChangeLog +++ b/frysk-sys/lib/dwfl/ChangeLog @@ -1,3 +1,9 @@ +2008-01-13 Stan Cox <scox@redhat.com> + + * Dwfl.java (Dwfl): Add sysroot parameter. Change all callers. + * cni/Dwfl.cxx (dwflBegin): Add sysroot parameter. Change all callers. + Consider sysroot. + 2007-01-04 Nurdin Premji <npremji@redhat.com> * DwarfDie.java (getProducer): New. (getAttrString): New. diff --git a/frysk-sys/lib/dwfl/Dwfl.java b/frysk-sys/lib/dwfl/Dwfl.java index 23aa7ce..1e34a58 100644 --- a/frysk-sys/lib/dwfl/Dwfl.java +++ b/frysk-sys/lib/dwfl/Dwfl.java @@ -50,12 +50,12 @@ public class Dwfl { protected final DwarfDieFactory factory = DwarfDieFactory.getFactory(); - public Dwfl() { - pointer = dwflBegin(); + public Dwfl(String sysroot) { + pointer = dwflBegin(sysroot); } - Dwfl(int pid) { - pointer = dwflBegin(pid); + Dwfl(int pid, String sysroot) { + pointer = dwflBegin(sysroot, pid); } /** @@ -174,8 +174,8 @@ public class Dwfl { } } - private static native RawData dwflBegin (); - private static native RawData dwflBegin(int pid); + private static native RawData dwflBegin (String s); + private static native RawData dwflBegin(String s, int pid); public native void dwfl_report_begin(); public native void dwfl_report_end(); diff --git a/frysk-sys/lib/dwfl/TestDwarfDie.java b/frysk-sys/lib/dwfl/TestDwarfDie.java index cc5832e..64cb89b 100644 --- a/frysk-sys/lib/dwfl/TestDwarfDie.java +++ b/frysk-sys/lib/dwfl/TestDwarfDie.java @@ -47,7 +47,7 @@ public class TestDwarfDie extends TestCase { public void testHasAttribute() { - Dwfl dwfl = new Dwfl(Pid.get()); + Dwfl dwfl = new Dwfl(Pid.get(), ""); assertNotNull(dwfl); // get CUDIE @@ -65,7 +65,7 @@ public class TestDwarfDie extends TestCase { public void testGetCompilationUnit(){ long pc = LocalMemory.getCodeAddr(); - Dwfl dwfl = new Dwfl(Pid.get()); + Dwfl dwfl = new Dwfl(Pid.get(), ""); hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-01-14 5:15 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=20080114051518.31275.qmail@sourceware.org \ --to=scox@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).