public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: scox@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Move SysRoot handling to SysRoot.java Date: Thu, 13 Mar 2008 20:58:00 -0000 [thread overview] Message-ID: <20080313205839.28767.qmail@sourceware.org> (raw) The branch, master has been updated via a28055c9c794f88affdb578448e727d0c6c440e8 (commit) from 7db59f35b3cae9f519920db4132c6bc31a43af78 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit a28055c9c794f88affdb578448e727d0c6c440e8 Author: Stan Cox <scox@redhat.com> Date: Thu Mar 13 15:34:09 2008 -0400 Move SysRoot handling to SysRoot.java * SysRootFile.java: New. * SysRoot.java: Renamed from Sysroot.java. Changed to use SysRootFile. * TestSysRoot.java: Renamed from TestSysroot.java. Changed to use SysRootFile. * SysRootCache.java: Renamed from SysrootCache.java. Change all callers. * LinuxExeFactory.java (findExe): Move to SysRoot.findExe. (createProc): Use it. * DebugInfoFrame.java (getLine): Use SysRoot. * ListCommand.java (interpret): Use SysRoot. * TestFstack.java (getCanonicalAbsRootSrcDir): New. Use instead of Config.getRootSrcDir. * CommandlineParser.java (parseSysRoot): Make private. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 5 + frysk-core/frysk/bindir/TestFstack.java | 15 ++- frysk-core/frysk/debuginfo/ChangeLog | 4 + frysk-core/frysk/debuginfo/DebugInfoFrame.java | 18 +-- frysk-core/frysk/dwfl/DwflCache.java | 4 +- frysk-core/frysk/hpd/AttachCommand.java | 4 +- frysk-core/frysk/hpd/ChangeLog | 4 + frysk-core/frysk/hpd/CoreCommand.java | 4 +- frysk-core/frysk/hpd/ListCommand.java | 21 +++- frysk-core/frysk/hpd/LoadCommand.java | 5 +- frysk-core/frysk/proc/dead/ChangeLog | 5 + frysk-core/frysk/proc/dead/LinuxExeFactory.java | 30 +---- frysk-core/frysk/sysroot/ChangeLog | 7 + .../frysk/sysroot/{Sysroot.java => SysRoot.java} | 91 ++++----------- .../{SysrootCache.java => SysRootCache.java} | 32 +++--- .../SysRootFile.java} | 63 ++++++----- frysk-core/frysk/sysroot/TestSysRoot.java | 127 ++++++++++++++++++++ frysk-core/frysk/sysroot/TestSysroot.java | 94 --------------- frysk-core/frysk/util/ChangeLog | 4 + frysk-core/frysk/util/CommandlineParser.java | 8 +- 20 files changed, 278 insertions(+), 267 deletions(-) rename frysk-core/frysk/sysroot/{Sysroot.java => SysRoot.java} (56%) rename frysk-core/frysk/sysroot/{SysrootCache.java => SysRootCache.java} (78%) copy frysk-core/frysk/{scopes/SourceLocation.java => sysroot/SysRootFile.java} (68%) create mode 100644 frysk-core/frysk/sysroot/TestSysRoot.java delete mode 100644 frysk-core/frysk/sysroot/TestSysroot.java First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index bc181d9..d36b218 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,8 @@ +2008-03-13 Stan Cox <scox@redhat.com> + + * TestFstack.java (getCanonicalAbsRootSrcDir): New. Use instead of + Config.getRootSrcDir. + 2008-03-13 Teresa Thomas <tthomas@redhat.com> * fstack.java: Refactor to use ProcStopUtil. diff --git a/frysk-core/frysk/bindir/TestFstack.java b/frysk-core/frysk/bindir/TestFstack.java index 4be77db..8896b93 100644 --- a/frysk-core/frysk/bindir/TestFstack.java +++ b/frysk-core/frysk/bindir/TestFstack.java @@ -40,6 +40,7 @@ package frysk.bindir; import java.io.File; +import java.io.IOException; import frysk.config.Config; import frysk.testbed.CorefileFactory; @@ -71,6 +72,14 @@ public class TestFstack extends TestLib { return new TearDownExpect(argv); } + private String getCanonicalAbsRootSrcDir () { + try { + return new File(Config.getAbsRootSrcDir()).getCanonicalPath(); + } catch (IOException e) { + return Config.getAbsRootSrcDir(); + } + } + public void testBackTrace () { TearDownExpect e = fstack("funit-stack-outlined", new String[0]); // Just look for main. @@ -102,7 +111,7 @@ public class TestFstack extends TestLib { public void testBackTraceWithFullpath () { TearDownExpect e = fstack("funit-stack-outlined", new String[] { "--print", "fullpath" }); - e.expect (Config.getRootSrcDir() + e.expect (getCanonicalAbsRootSrcDir() + ".*" + "funit-stack-outlined" + ".c#"); @@ -112,7 +121,7 @@ public class TestFstack extends TestLib { TearDownExpect e = fstack("funit-stack-outlined", new String[] { "-a" }); e.expect("\\#0 .* in third\\(int arg3\\)" - + ".*" + Config.getRootSrcDir() + + ".*" + getCanonicalAbsRootSrcDir() + ".*" + "funit-stack-outlined" + "\\.c#" + ".*int var3.*"); e.expect("\\#1"); @@ -122,7 +131,7 @@ public class TestFstack extends TestLib { TearDownExpect e = fstack("funit-stack-outlined", new String[] { "-c" }); e.expect("\\#0 .* in third\\(int arg3\\)" - + ".*" + Config.getRootSrcDir() + + ".*" + getCanonicalAbsRootSrcDir() + ".*" + "funit-stack-outlined" + "\\.c#"); e.expect("\\#1"); } diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog index 76b9ebe..d673d45 100644 --- a/frysk-core/frysk/debuginfo/ChangeLog +++ b/frysk-core/frysk/debuginfo/ChangeLog @@ -1,3 +1,7 @@ +2008-03-13 Stan Cox <scox@redhat.com> + + * DebugInfoFrame.java (getLine): Use SysRoot. + 2008-03-13 Sami Wagiaalla <swagiaal@redhat.com> * ObjectDeclarationNotFoundException.java: Renamed. diff --git a/frysk-core/frysk/debuginfo/DebugInfoFrame.java b/frysk-core/frysk/debuginfo/DebugInfoFrame.java index b99cfba..6136d6f 100644 --- a/frysk-core/frysk/debuginfo/DebugInfoFrame.java +++ b/frysk-core/frysk/debuginfo/DebugInfoFrame.java @@ -56,7 +56,8 @@ import frysk.scopes.Subprogram; import frysk.scopes.Subroutine; import frysk.stack.Frame; import frysk.stack.FrameDecorator; -import frysk.sysroot.SysrootCache; +import frysk.sysroot.SysRoot; +import frysk.sysroot.SysRootCache; public class DebugInfoFrame extends FrameDecorator { @@ -169,6 +170,7 @@ public class DebugInfoFrame extends FrameDecorator { public SourceLocation getLine() { if (this.line == null) { Dwfl dwfl = DwflCache.getDwfl(this.getTask()); + SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(this.getTask())); // The innermost frame and frames which were // interrupted during execution use their PC to get // the line in source. All other frames have their PC @@ -176,17 +178,9 @@ public class DebugInfoFrame extends FrameDecorator { // be decremented by one. DwflLine dwflLine = dwfl.getSourceLine(getAdjustedAddress()); if (dwflLine != null) { - File sysroot = SysrootCache.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(sysroot, dwflLine.getCompilationDir()); - f = new File(parent, dwflLine.getSourceFile()); - } - else - f = new File(sysroot, f.getPath()); + File f = sysRoot.getSourcePathViaSysRoot + (new File(dwflLine.getCompilationDir()), + new File(dwflLine.getSourceFile())).getSysRootedFile(); this.line = new SourceLocation(f, dwflLine.getLineNum(), dwflLine.getColumn()); } diff --git a/frysk-core/frysk/dwfl/DwflCache.java b/frysk-core/frysk/dwfl/DwflCache.java index 0b40ecf..b9366e4 100644 --- a/frysk-core/frysk/dwfl/DwflCache.java +++ b/frysk-core/frysk/dwfl/DwflCache.java @@ -45,7 +45,7 @@ import java.io.IOException; import java.util.Iterator; import java.util.WeakHashMap; import frysk.rsl.Log; -import frysk.sysroot.SysrootCache; +import frysk.sysroot.SysRootCache; import lib.dwfl.Dwfl; /** @@ -130,7 +130,7 @@ public class DwflCache { // If there is no dwfl for this task create one. if (!modMap.containsKey(task)) { fine.log("creating new dwfl for task", task); - File sysrootFile = (File)SysrootCache.getSysroot(task); + File sysrootFile = (File)SysRootCache.getSysRoot(task); File relativeSysroot = getRelativeSysRoot(task.getProc().getExe(), sysrootFile); Dwfl dwfl = new Dwfl(relativeSysroot.getPath()); DwflFactory.updateDwfl(dwfl, task); diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java index 94fb335..f96c887 100644 --- a/frysk-core/frysk/hpd/AttachCommand.java +++ b/frysk-core/frysk/hpd/AttachCommand.java @@ -39,7 +39,7 @@ package frysk.hpd; -import frysk.sysroot.SysrootCache; +import frysk.sysroot.SysRootCache; import frysk.proc.Proc; import frysk.proc.Manager; import frysk.proc.FindProc; @@ -126,7 +126,7 @@ public class AttachCommand extends ParameterizedCommand { } public static void attach(Proc proc, CLI cli, String sysroot) { - SysrootCache.setSysroot(proc.getMainTask(), sysroot); + SysRootCache.setSysroot(proc.getMainTask(), sysroot); cli.doAttach(proc, false); } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 406d23d..37bb0ab 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,7 @@ +2008-03-13 Stan Cox <scox@redhat.com> + + * ListCommand.java (interpret): Use SysRoot. + 2008-03-13 Rick Moseley <rmoseley@redhat.com> * CLI.java: Synchronize message adding when type specified. diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java index 74b6535..909ff31 100644 --- a/frysk-core/frysk/hpd/CoreCommand.java +++ b/frysk-core/frysk/hpd/CoreCommand.java @@ -46,7 +46,7 @@ import java.util.List; import frysk.debuginfo.DebugInfo; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; -import frysk.sysroot.SysrootCache; +import frysk.sysroot.SysRootCache; import frysk.proc.Task; import frysk.proc.dead.LinuxCoreFactory; import java.io.IOException; @@ -136,7 +136,7 @@ public class CoreCommand extends ParameterizedCommand { .createVirtualStackTrace(task); cli.setTaskFrame(task, frame); cli.setTaskDebugInfo(task, new DebugInfo(frame)); - SysrootCache.setSysroot(task, sysroot); + SysRootCache.setSysroot(task, sysroot); } // Finally, done. synchronized (cli) { diff --git a/frysk-core/frysk/hpd/ListCommand.java b/frysk-core/frysk/hpd/ListCommand.java index 4779098..d4e417e 100644 --- a/frysk-core/frysk/hpd/ListCommand.java +++ b/frysk-core/frysk/hpd/ListCommand.java @@ -50,9 +50,12 @@ import frysk.scopes.SourceLocation; import java.util.Iterator; import lib.dwfl.DwarfDie; import lib.dwfl.DwTag; +import lib.dwfl.DwflLine; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfo; -import frysk.sysroot.SysrootCache; +import frysk.dwfl.DwflCache; +import frysk.sysroot.SysRoot; +import frysk.sysroot.SysRootCache; import frysk.proc.Task; /** @@ -121,11 +124,17 @@ class ListCommand extends ParameterizedCommand { .getSymbolDie(cmd.parameter(0)); } if (funcDie.getTag().hashCode() == DwTag.SUBPROGRAM_) { - line = (int)funcDie.getDeclLine(); - File sysroot = SysrootCache.getSysroot(frame.getTask()); - file = funcDie.getDeclFile(); - if (file.isAbsolute()) - file = new File(sysroot.getPath(), file.getPath()); + DwflLine dwflLine = DwflCache.getDwfl(frame.getTask()) + .getSourceLine(frame.getAdjustedAddress()); + if (dwflLine != null) { + SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(frame.getTask())); + file = sysRoot.getSourcePathViaSysRoot + (new File(dwflLine.getCompilationDir()), + funcDie.getDeclFile()).getSysRootedFile(); + } + else + file = funcDie.getDeclFile(); + line = (int)funcDie.getDeclLine(); } else { cli.addMessage("function " + cmd.parameter(0) + " not found.", diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index 73fe7f4..0cb3998 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -45,7 +45,7 @@ import frysk.proc.dead.LinuxExeFactory; import frysk.debuginfo.DebugInfo; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; -import frysk.sysroot.SysrootCache; +import frysk.sysroot.SysRootCache; import frysk.proc.Proc; import frysk.proc.Task; import java.util.List; @@ -107,9 +107,11 @@ public class LoadCommand extends ParameterizedCommand { } Proc exeProc; if (o.executable != null) { + SysRootCache.setSysroot(o.executable, o.sysroot); exeProc = LinuxExeFactory.createProc (new File(o.executable), cmd.stringArrayValue()); } else { + SysRootCache.setSysroot(cmd.stringArrayValue()[0], o.sysroot); exeProc = LinuxExeFactory.createProc(cmd.stringArrayValue()); } @@ -137,7 +139,6 @@ public class LoadCommand extends ParameterizedCommand { .createDebugInfoStackTrace(task); cli.setTaskFrame(task, frame); cli.setTaskDebugInfo(task, new DebugInfo(frame)); - SysrootCache.setSysroot(task, sysroot); } } synchronized (cli) { diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog index 7d058c2..edab625 100644 --- a/frysk-core/frysk/proc/dead/ChangeLog +++ b/frysk-core/frysk/proc/dead/ChangeLog @@ -1,3 +1,8 @@ +2008-03-13 Stan Cox <scox@redhat.com> + + * LinuxExeFactory.java (findExe): Move to SysRoot.findExe. + (createProc): Use it. + 2008-03-11 Andrew Cagney <cagney@redhat.com> * CorefileByteBuffer.java: Use LogFactory. diff --git a/frysk-core/frysk/proc/dead/LinuxExeFactory.java b/frysk-core/frysk/proc/dead/LinuxExeFactory.java index 1e7c45f..ece01d8 100644 --- a/frysk-core/frysk/proc/dead/LinuxExeFactory.java +++ b/frysk-core/frysk/proc/dead/LinuxExeFactory.java @@ -48,6 +48,8 @@ import lib.dwfl.ElfEHeader; import frysk.proc.MemoryMap; import frysk.rsl.Log; import frysk.solib.SOLibMapBuilder; +import frysk.sysroot.SysRoot; +import frysk.sysroot.SysRootCache; public class LinuxExeFactory { private static final Log fine = Log.fine(LinuxExeFactory.class); @@ -87,33 +89,9 @@ public class LinuxExeFactory { } } - private static File findExe(String arg0) { - if (arg0.startsWith("/")) { - return new File(arg0); - } - - String pathVar = System.getenv("PATH"); - if (pathVar == null) { - return new File(arg0); - } - - String[] path = pathVar.split(":"); - if (path == null) { - return new File(arg0); - } - fine.log("createProc $PATH", path); - - for (int i = 0; i < path.length; i++) { - File file = new File(path[i], arg0); - if (file.exists()) { - return file; - } - } - return new File(arg0); // punt - } - public static DeadProc createProc(String[] args) { - File exe = findExe(args[0]); + SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(args[0])); + File exe = sysRoot.getPathViaSysRoot(args[0]).getSysRootedFile(); fine.log("createProc exe", exe); return createProc(exe, args); } diff --git a/frysk-core/frysk/sysroot/ChangeLog b/frysk-core/frysk/sysroot/ChangeLog index 7e54e33..7eaa3a5 100644 --- a/frysk-core/frysk/sysroot/ChangeLog +++ b/frysk-core/frysk/sysroot/ChangeLog @@ -1,3 +1,10 @@ +2008-03-13 Stan Cox <scox@redhat.com> + + * SysRootFile.java: New. + * SysRoot.java: Renamed from Sysroot.java. Changed to use SysRootFile. + * TestSysRoot.java: Renamed from TestSysroot.java. Changed to use SysRootFile. + * SysRootCache.java: Renamed from SysrootCache.java. Change all callers. + 2008-03-11 Stan Cox <scox@redhat.com> * SysrootCache.java: New file. diff --git a/frysk-core/frysk/sysroot/Sysroot.java b/frysk-core/frysk/sysroot/SysRoot.java similarity index 56% rename from frysk-core/frysk/sysroot/Sysroot.java rename to frysk-core/frysk/sysroot/SysRoot.java index f731d05..8843728 100644 --- a/frysk-core/frysk/sysroot/Sysroot.java +++ b/frysk-core/frysk/sysroot/SysRoot.java @@ -40,36 +40,16 @@ package frysk.sysroot; import java.io.File; -import java.io.IOException; /** - * Map from a Task's executable to its sysroot special root directory. + * Map from a Task's executable to its special root directory. */ -public class Sysroot { - File sysrootFile; +public class SysRoot { + private File sysRoot; - public Sysroot (File path) { - sysrootFile = path; - } - - /** - * return a pathname of an executable. - * - * @param pathname - * is the executable. - * @return this executable's pathname, searched for on $PATH - */ - public File getPathViaDefaultRoot (String pathname) { - String pathVar = System.getenv("PATH"); - return findExe(pathVar, "/", pathname); - } - - /** - * return a pathname of an executable. Used only for testing. - */ - File getPathViaDefaultRoot (String pathname, String pathVar) { - return findExe(pathVar, "/", pathname); + public SysRoot (File path) { + sysRoot = path; } /** @@ -80,39 +60,16 @@ public class Sysroot { * @return this executable's pathname, searched for on $PATH in the special * root directory. */ - public File getPathViaSysroot (String pathname) { + public SysRootFile getPathViaSysRoot (String pathname) { String pathVar = System.getenv("PATH"); - return findExe(pathVar, sysrootFile.getPath(), pathname); + return new SysRootFile(sysRoot, findExe(pathVar, pathname)); } /** - * return a pathname of an executable in a sysroot. Used only for testing. - */ - File getPathViaSysroot (String pathname, String pathVar) { - return findExe(pathVar, sysrootFile.getPath(), pathname); - } - - /** - * return a pathname of an executable's source. - * - * @param pathname - * is the executable's compilation directory. - * @param file - * this executable's source name. - * @return the pathname of the executable's source. + * return a pathname of an executable in a system root. Used only for testing. */ - public File getSourcePathViaDefaultRoot (File compilationDir, File f) { - try { - if (! f.isAbsolute()) { - // The file refers to a path relative to the - // compilation directory, so prepend that directory path. - return new File(compilationDir.getPath(), f.getPath()).getCanonicalFile(); - } - else - return new File(f.getPath()).getCanonicalFile(); - } catch (IOException e) { - return f; - } + SysRootFile getPathViaSysRoot (String pathname, String pathVar) { + return new SysRootFile(sysRoot, findExe(pathVar, pathname)); } /** @@ -125,22 +82,16 @@ public class Sysroot { * @return the pathname of the executable's source searched for in the * special root directory. */ - public File getSourcePathViaSysroot (File compilationDir, File f) { - try { - if (! f.isAbsolute()) { - // The file refers to a path relative to the - // compilation directory, so prepend that directory path. - File parent = new File(sysrootFile.getPath(), compilationDir.getPath()); - return new File(parent, f.getPath()).getCanonicalFile(); - } - else - return new File(sysrootFile.getPath(), f.getPath()).getCanonicalFile(); - } catch (IOException e) { - return f; - } + public SysRootFile getSourcePathViaSysRoot (File compilationDir, File f) { + if (! f.isAbsolute()) + // The file refers to a path relative to the + // compilation directory, so prepend that directory path. + return new SysRootFile(sysRoot, new File(compilationDir, f.getPath())); + else + return new SysRootFile(sysRoot, f); } - private static File findExe(String pathVar, String sysrootFile, String arg0) { + private File findExe(String pathVar, String arg0) { if (pathVar == null) { return new File(arg0); } @@ -155,11 +106,11 @@ public class Sysroot { } for (int i = 0; i < path.length; i++) { - File file = new File(new File(sysrootFile, path[i]), arg0); + File file = new File(new File(sysRoot.getPath(), path[i]), arg0); if (file.exists()) { - return file; + return new File(path[i], arg0); } } - return new File(arg0); // punt + return new File(arg0); } } diff --git a/frysk-core/frysk/sysroot/SysrootCache.java b/frysk-core/frysk/sysroot/SysRootCache.java similarity index 78% rename from frysk-core/frysk/sysroot/SysrootCache.java rename to frysk-core/frysk/sysroot/SysRootCache.java index 665bcb2..1057198 100644 --- a/frysk-core/frysk/sysroot/SysrootCache.java +++ b/frysk-core/frysk/sysroot/SysRootCache.java @@ -44,41 +44,41 @@ import java.util.WeakHashMap; import frysk.proc.Task; hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-03-13 20:58 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=20080313205839.28767.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).