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 a -sysroot request option. Keep a per process sysroot. Date: Thu, 24 Jan 2008 22:13:00 -0000 [thread overview] Message-ID: <20080124221350.26753.qmail@sourceware.org> (raw) The branch, master has been updated via 731d52ca58b0f4fff40f44af122e7e7cd700d9b4 (commit) from b1204beec55a35ac0c18d37519cd55c70bd33fb8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 731d52ca58b0f4fff40f44af122e7e7cd700d9b4 Author: Stan Cox <scox@redhat.com> Date: Thu Jan 24 16:31:00 2008 -0500 Add a -sysroot request option. Keep a per process sysroot. * fhpd.java (main): Pass sysroot to request via -sysroot option. * DebugInfoFrame.java (getLine): Get sysroot via DwflCache.getSysroot. * DwflCache.java (Mod.sysroot): New. (sysrootMap): New. (getRelativeSysRoot): Change to use java.io.File. (getDwfl): Set Mod.sysroot. (setSysroot): New. (getSysroot): New. * AttachCommand.java (Options): New. Add -sysroot option. (interpret): Set sysroot. * CoreCommand.java: Likewise. * LoadCommand.java: Likewise. * ListCommand.java (interpret): Remove sysroot reference except for "list function". * DbgVariables.java (DbgVariables): Remove SYSROOT. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 4 + frysk-core/frysk/bindir/fhpd.java | 2 +- frysk-core/frysk/debuginfo/ChangeLog | 6 ++- frysk-core/frysk/debuginfo/DebugInfoFrame.java | 13 +--- frysk-core/frysk/dwfl/ChangeLog | 9 +++ frysk-core/frysk/dwfl/DwflCache.java | 84 +++++++++++++++--------- frysk-core/frysk/hpd/AttachCommand.java | 20 +++++- frysk-core/frysk/hpd/ChangeLog | 10 +++ frysk-core/frysk/hpd/CoreCommand.java | 21 +++++- frysk-core/frysk/hpd/DbgVariables.java | 3 +- frysk-core/frysk/hpd/ListCommand.java | 17 ++---- frysk-core/frysk/hpd/LoadCommand.java | 44 +++++++++---- frysk-core/frysk/hpd/StartCommand.java | 4 +- 13 files changed, 160 insertions(+), 77 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 09d1036..a2f3f7a 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,7 @@ +2008-01-24 Stan Cox <scox@redhat.com> + + * fhpd.java (main): Pass sysroot to request via -sysroot option. + 2008-01-24 Andrew Cagney <cagney@redhat.com> * TestFmaps.java: Update; CoreFileAtSignal renamed to diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java index 9123d06..f42aab1 100644 --- a/frysk-core/frysk/bindir/fhpd.java +++ b/frysk-core/frysk/bindir/fhpd.java @@ -151,7 +151,7 @@ public class fhpd line +=" -noexe"; } if (sysroot != null) - line = line + " ; set SYSROOT " + sysroot; + line = line + " -sysroot " + sysroot; } catch (IOException ignore) {} diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index b2320e3..44c27b3 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,10 +1,14 @@ +2008-01-24 Stan Cox <scox@redhat.com> + + * DebugInfoFrame.java (getLine): Get sysroot via DwflCache.getSysroot. + 2008-01-24 Andrew Cagney <cagney@redhat.com> * DwarfRegisterMapFactory.java: Update; Register moved to frysk.isa.registers. * LocationExpression.java: Ditto. * ObjectDeclarationSearchEngine.java: Ditto. - * RegisterPiece.java: Ditt. + * RegisterPiece.java: Ditto. 2008-01-23 Andrew Cagney <cagney@redhat.com> diff --git a/frysk-core/frysk/debuginfo/DebugInfoFrame.java b/frysk-core/frysk/debuginfo/DebugInfoFrame.java index f1d8682..1cd2430 100644 --- a/frysk-core/frysk/debuginfo/DebugInfoFrame.java +++ b/frysk-core/frysk/debuginfo/DebugInfoFrame.java @@ -48,7 +48,6 @@ 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; @@ -176,21 +175,17 @@ public class DebugInfoFrame extends FrameDecorator { // be decremented by one. DwflLine dwflLine = dwfl.getSourceLine(getAdjustedAddress()); if (dwflLine != null) { + File sysroot = DwflCache.getSysroot(this.getTask()); File f = new File(dwflLine.getSourceFile()); if (! f.isAbsolute()) { // The file refers to a path relative to the // compilation directory; so prepend the path to // that directory in front of it. - File parent = new File(dwflLine.getCompilationDir()); + File parent = new File(sysroot, 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()); - } - } + else + f = new File(sysroot, f.getPath()); this.line = new SourceLocation(f, dwflLine.getLineNum(), dwflLine.getColumn()); } diff --git a/frysk-core/frysk/dwfl/ChangeLog b/frysk-core/frysk/dwfl/ChangeLog index 37c57c7..c3c1e1f 100644 --- a/frysk-core/frysk/dwfl/ChangeLog +++ b/frysk-core/frysk/dwfl/ChangeLog @@ -1,3 +1,12 @@ +2008-01-24 Stan Cox <scox@redhat.com> + + * DwflCache.java (Mod.sysroot): New. + (sysrootMap): New. + (getRelativeSysRoot): Change to use java.io.File. + (getDwfl): Set Mod.sysroot. + (setSysroot): New. + (getSysroot): New. + 2008-01-18 Phil Muldoon <pmuldoon@redhat.com> * DwflFactory.java (updateDwfl): Do not overrun map diff --git a/frysk-core/frysk/dwfl/DwflCache.java b/frysk-core/frysk/dwfl/DwflCache.java index 2788446..433e366 100644 --- a/frysk-core/frysk/dwfl/DwflCache.java +++ b/frysk-core/frysk/dwfl/DwflCache.java @@ -39,8 +39,9 @@ package frysk.dwfl; -import frysk.hpd.DbgVariables; import frysk.proc.Task; + +import java.io.File; import java.util.Iterator; import java.util.WeakHashMap; import java.util.logging.Level; @@ -60,9 +61,11 @@ public class DwflCache static private class Mod { final Dwfl dwfl; int count; - Mod(Dwfl dwfl, int count) { + File sysroot; + Mod(Dwfl dwfl, int count, File sysroot) { this.dwfl = dwfl; this.count = count; + this.sysroot = sysroot; } } @@ -72,6 +75,11 @@ public class DwflCache private static WeakHashMap modMap = new WeakHashMap(); /** + * Map from a Task's executable to its sysroot. + */ + private static WeakHashMap sysrootMap = new WeakHashMap(); + + /** * Cache of all Dwfl objects. */ private static WeakHashMap allDwfls = new WeakHashMap(); @@ -87,39 +95,26 @@ public class DwflCache * 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("/.."); + private static File getRelativeSysRoot(String execPathParm, File sysroot) { + if (sysroot.getPath().equals("/")) + return new File("/usr/lib/debug"); + + File execFile = new File(execPathParm); + File parent = new File(execFile.getParent()); + StringBuffer relativePath = new StringBuffer(""); + StringBuffer exePath = new StringBuffer(""); + while (! parent.getPath().equals(sysroot.getPath())) { + exePath.insert(0, "/" + parent.getName()); + relativePath.append("../"); + parent = new File(parent.getParent()); } - relSysRoot.deleteCharAt(0); - relSysRoot.append("/usr/lib/debug/"); - relSysRoot.append(nonSysRootPath); - return relSysRoot.toString(); + File debugFile = new File(relativePath + "/usr/lib/debug/" + exePath); + return debugFile; } /** @@ -132,12 +127,16 @@ 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(relativeSysRoot); + String sysroot = (String)sysrootMap.get(task.getProc().getCommand()); + if (sysroot == null) + sysroot = "/"; + File sysrootFile = new File(sysroot); + File relativeSysroot = getRelativeSysRoot(task.getProc().getExe(), sysrootFile); + Dwfl dwfl = new Dwfl(relativeSysroot.getPath()); DwflFactory.updateDwfl(dwfl, task); - Mod mod = new Mod(dwfl, task.getMod()); + Mod mod = new Mod(dwfl, task.getMod(), sysrootFile); modMap.put(task, mod); // For cleanup, also save dwfl using Mod as a key (just need a @@ -158,6 +157,27 @@ public class DwflCache return mod.dwfl; } + /** + * set the sysroot corresponding to a {@link frysk.proc.Task}. + * + * @param task is the task. + * @param sysroot is this task's sysroot. + */ + public static void setSysroot(Task task, String sysroot) { + sysrootMap.put(task.getProc().getCommand(), sysroot); + } + + /** + * return a sysroot File for a {@link frysk.proc.Task}. + * + * @param task is the task. + * @return the sysroot file. + */ + public static File getSysroot(Task task) { + Mod mod = (Mod) modMap.get(task); + return mod.sysroot; + } + public static void clear() { modMap.clear(); for (Iterator i = allDwfls.values().iterator(); i.hasNext();) { diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java index ce960e6..8556e5b 100644 --- a/frysk-core/frysk/hpd/AttachCommand.java +++ b/frysk-core/frysk/hpd/AttachCommand.java @@ -39,6 +39,7 @@ package frysk.hpd; +import frysk.dwfl.DwflCache; import frysk.proc.Proc; import frysk.proc.ProcId; import frysk.proc.Manager; @@ -67,7 +68,7 @@ class AttachCommand extends ParameterizedCommand { AttachCommand() { super("Attach to a running process.", - "attach <pid> ...", + "attach <pid> ... [ -sysroot Path ]", ("The attach command causes the debugger to attach to an" + " existing process(es), making it possible to continue" + " the process' execution under debugger control. The" @@ -76,9 +77,25 @@ class AttachCommand extends ParameterizedCommand { + " operation. It is the user's responsibility to ensure" + " that the process(es) actually is executing the specified" + " executable.")); + add(new CommandOption("sysroot", "pathname to use as a sysroot", + "Pathname") { + void parse(String args, Object options) { + ((Options)options).sysroot = args; + } + }); } + + private static class Options { + String sysroot = "/"; + } + Object options() { + return new Options(); + } + public void interpret(CLI cli, Input cmd, Object options) { + Options o = (Options)options; + if (cmd.size() == 0) { throw new InvalidCommandException("Missing process ID"); } @@ -100,6 +117,7 @@ class AttachCommand extends ParameterizedCommand { cli.outWriter.println(pid); continue; } + DwflCache.setSysroot(findProc.proc.getMainTask(), o.sysroot); cli.doAttach(findProc.proc); } } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index e0e7292..db01d4f 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,13 @@ +2008-01-24 Stan Cox <scox@redhat.com> + + * AttachCommand.java (Options): New. Add -sysroot option. + (interpret): Set sysroot. + * CoreCommand.java: Likewise. + * LoadCommand.java: Likewise. + * ListCommand.java (interpret): Remove sysroot reference except for + "list function". + * DbgVariables.java (DbgVariables): Remove SYSROOT. + 2008-01-24 Rick Moseley <rmoseley@redhat.com> * StartRun.java: Print command line for start/run. diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java index 20ccbc5..37ca2c1 100644 --- a/frysk-core/frysk/hpd/CoreCommand.java +++ b/frysk-core/frysk/hpd/CoreCommand.java @@ -46,6 +46,7 @@ import java.util.List; import frysk.debuginfo.DebugInfo; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; +import frysk.dwfl.DwflCache; import frysk.proc.Manager; import frysk.proc.Proc; import frysk.proc.Task; @@ -60,19 +61,32 @@ public class CoreCommand extends ParameterizedCommand { boolean noExeOption = false; CoreCommand() { - super("Load a Corefile.", "core <core-file> [ <executable> ] [ -noexe ]", - "Opens, loads and models corefile."); + super("Load a Corefile.", "core <core-file> [ <executable> ] [ -noexe ]" + + "[ -sysroot Path ]", "Opens, loads and models corefile."); add(new CommandOption("noexe", "Do not attempt to load executable ") { void parse(String argument, Object options) { noExeOption = true; } }); + add(new CommandOption("sysroot", "pathname to use as a sysroot", + "Pathname") { + void parse(String args, Object options) { + ((Options)options).sysroot = args; + } + }); + } + private static class Options { + String sysroot = "/"; + } + Object options() { + return new Options(); } void interpret(CLI cli, Input cmd, Object options) { - + Options o = (Options)options; + Proc coreProc; LinuxCoreHost coreHost = null; @@ -128,6 +142,7 @@ public class CoreCommand extends ParameterizedCommand { .createVirtualStackTrace(task); cli.setTaskFrame(task, frame); cli.setTaskDebugInfo(task, new DebugInfo(frame)); + DwflCache.setSysroot(task, o.sysroot); } // Finally, done. diff --git a/frysk-core/frysk/hpd/DbgVariables.java b/frysk-core/frysk/hpd/DbgVariables.java index 23df999..9516abc 100644 --- a/frysk-core/frysk/hpd/DbgVariables.java +++ b/frysk-core/frysk/hpd/DbgVariables.java @@ -113,7 +113,6 @@ public 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"))); } @@ -161,7 +160,7 @@ public class DbgVariables { return ((Integer)vars.get(var)).intValue(); } - public static String getStringValue(String var) { + public String getStringValue(String var) { if (vars.size() == 0) return ""; else diff --git a/frysk-core/frysk/hpd/ListCommand.java b/frysk-core/frysk/hpd/ListCommand.java index 13c10aa..72a4e24 100644 --- a/frysk-core/frysk/hpd/ListCommand.java +++ b/frysk-core/frysk/hpd/ListCommand.java @@ -52,6 +52,7 @@ import lib.dwfl.DwarfDie; import lib.dwfl.DwTag; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfo; +import frysk.dwfl.DwflCache; import frysk.proc.Task; /** @@ -120,13 +121,10 @@ class ListCommand extends ParameterizedCommand { } if (funcDie.getTag().hashCode() == DwTag.SUBPROGRAM_) { line = (int)funcDie.getDeclLine(); - 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(); + File sysroot = DwflCache.getSysroot(frame.getTask()); + file = funcDie.getDeclFile(); + if (file.isAbsolute()) + file = new File(sysroot.getPath(), file.getPath()); } else { cli.addMessage("function " + cmd.parameter(0) + " not found.", @@ -152,11 +150,6 @@ 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/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index 0d2bb30..f2ff5ae 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -44,6 +44,7 @@ import java.util.Iterator; import frysk.debuginfo.DebugInfo; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; +import frysk.dwfl.DwflCache; import frysk.proc.Host; import frysk.proc.dead.LinuxExeHost; import frysk.proc.Manager; @@ -54,43 +55,58 @@ import java.util.List; /** * LoadCommand handles the "load path-to-executable" command on the fhpd * commandline. - * + * */ public class LoadCommand extends ParameterizedCommand { LoadCommand() { super("load", - "load path-to-executable", + "load path-to-executable [ -sysroot Path ]", "The load command lets the user examine information about" + " an executable file without actually running it. An" - + " executble must be loaded with this command before it" + + " executable must be loaded with this command before it" + " can be run with either the 'start' or 'run' command." + " No arguments are entered here, they are passed to the" + " process via the 'start'/'run' commands."); + add(new CommandOption("sysroot", "pathname to use as a sysroot", + "Pathname") { + void parse(String args, Object options) { + ((Options)options).sysroot = args; + } + }); + } + + private static class Options { + String sysroot = "/"; + } + Object options() { + return new Options(); } public void interpret(CLI cli, Input cmd, Object options) { + Options o = (Options)options; + if (cmd.size() > 2) { throw new InvalidCommandException("Too many parameters"); } else if (cmd.size() < 1) { - throw new InvalidCommandException("missing arguments"); - } - + throw new InvalidCommandException("missing arguments"); + } + File executableFile = new File(cmd.parameter(0)); if (!executableFile.exists() || !executableFile.canRead() || !executableFile.isFile()) { throw new InvalidCommandException - ("File does not exist or is not readable or is not a file."); hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-01-24 22:13 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=20080124221350.26753.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).