public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: scox@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Make -sysroot library aware. Date: Mon, 07 Apr 2008 21:53:00 -0000 [thread overview] Message-ID: <20080407215359.6296.qmail@sourceware.org> (raw) The branch, master has been updated via 5f4e88713844da0810ba5d1eeaea572f7b5d9c2a (commit) from 604692fe42c10ea3c73c082e42ca7f10c32b9c24 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 5f4e88713844da0810ba5d1eeaea572f7b5d9c2a Author: Stan Cox <scox@redhat.com> Date: Mon Apr 7 17:47:19 2008 -0400 Make -sysroot library aware. * Host.java (requestCreateAttachedProc): Add libs parameter. Change derived classes. * LinuxPtraceHost.java (requestCreateAttachedProc): Add libs parameter. * SysRoot.java (getLibPathViaSysRoot): New. * Fork.java (spawn): Add libs parameter. (ptrace): Likewise. * cni/Fork.cxx (spawn): New parameter libs. Use execve if we have libs. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/ChangeLog | 5 +++++ frysk-core/frysk/proc/Host.java | 19 ++++++++++++------- frysk-core/frysk/proc/dead/DeadHost.java | 2 +- frysk-core/frysk/proc/dummy/DummyHost.java | 2 +- frysk-core/frysk/proc/live/ChangeLog | 4 ++++ frysk-core/frysk/proc/live/LinuxPtraceHost.java | 3 ++- frysk-core/frysk/sysroot/ChangeLog | 4 ++++ frysk-core/frysk/sysroot/SysRoot.java | 19 +++++++++++++++++++ frysk-sys/frysk/sys/ChangeLog | 6 ++++++ frysk-sys/frysk/sys/Fork.java | 17 +++++++++-------- frysk-sys/frysk/sys/cni/Fork.cxx | 22 +++++++++++++++++----- 11 files changed, 80 insertions(+), 23 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index f7e059d..ffcdbbf 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,3 +1,8 @@ +2008-04-07 Stan Cox <scox@redhat.com> + + * Host.java (requestCreateAttachedProc): Add libs parameter. Change + derived classes. + 2008-04-02 Phil Muldoon <pmuldoon@redhat.com> * Task.java (requestAddWatchObserver): Add writeOnly flag. (requestDeleteWatchObserver): Ditto. diff --git a/frysk-core/frysk/proc/Host.java b/frysk-core/frysk/proc/Host.java index 612162a..dda263c 100644 --- a/frysk-core/frysk/proc/Host.java +++ b/frysk-core/frysk/proc/Host.java @@ -42,6 +42,8 @@ package frysk.proc; import java.io.File; import java.util.Collection; import frysk.rsl.Log; +import frysk.sysroot.SysRoot; +import frysk.sysroot.SysRootFile; /** * A host machine. @@ -78,29 +80,30 @@ public abstract class Host implements Comparable { * Tell the host to create a running child process. * * Unlike other requests, this operation is bound to an explicit - * call-back. Doing this means that the requestor has a robust - * way of receiving an acknolwedge of the operation. Without this + * call-back. Doing this means that the requester has a robust + * way of receiving an acknowledge of the operation. Without this * there would be no reliable way to bind to the newly created * process - frysk's state machine could easily detach before the - * requestor had an oportunity to add an attached observer. + * requester had an opportunity to add an attached observer. */ public abstract void requestCreateAttachedProc(File exe, String stdin, String stdout, String stderr, String[] args, + String libs, TaskAttachedObserverXXX attachedObserver); /** * Request that a new attached and running process(with stdin, * stdout, and stderr are shared with this process) be created. */ public void requestCreateAttachedProc(String stdin, String stdout, - String stderr, String[] args, + String stderr, String[] args, TaskAttachedObserverXXX attachedObserver) { fine.log(this, "requestCreateAttachedProc", args, "observer", attachedObserver); requestCreateAttachedProc(new File(args[0]), stdin, stdout, stderr, - args, attachedObserver); + args, "", attachedObserver); } /** * Request that a new attached and running process(with stdin, @@ -111,7 +114,7 @@ public abstract class Host implements Comparable { fine.log(this, "requestCreateAttachedProc", args, "observer", attachedObserver); requestCreateAttachedProc(new File(args[0]), null, null, null, - args, attachedObserver); + args, "", attachedObserver); } /** * Request that a new attached and running process based on @@ -121,9 +124,11 @@ public abstract class Host implements Comparable { TaskAttachedObserverXXX attachedObserver) { fine.log(this, "requestCreateAttachedProc template", template, "observer", attachedObserver); - requestCreateAttachedProc(new File(template.getExeFile().getSysRootedPath()), + SysRootFile sysRootFile = template.getExeFile(); + requestCreateAttachedProc(new File(sysRootFile.getSysRootedPath()), null, null, null, template.getCmdLine(), + new SysRoot(sysRootFile.getSysRoot()).getLibPathViaSysRoot(), attachedObserver); } diff --git a/frysk-core/frysk/proc/dead/DeadHost.java b/frysk-core/frysk/proc/dead/DeadHost.java index 08a5baf..9d2075b 100644 --- a/frysk-core/frysk/proc/dead/DeadHost.java +++ b/frysk-core/frysk/proc/dead/DeadHost.java @@ -59,7 +59,7 @@ import java.io.File; abstract class DeadHost extends Host { public void requestCreateAttachedProc(File exe, String in, String out, String err, - String[] args, + String[] args, String libs, TaskAttachedObserverXXX attached) { throw new RuntimeException("requestCreateAttachedProc"); } diff --git a/frysk-core/frysk/proc/dummy/DummyHost.java b/frysk-core/frysk/proc/dummy/DummyHost.java index d6fcf63..5afb229 100644 --- a/frysk-core/frysk/proc/dummy/DummyHost.java +++ b/frysk-core/frysk/proc/dummy/DummyHost.java @@ -58,7 +58,7 @@ public class DummyHost extends Host { public void requestCreateAttachedProc(File exe, String stdin, String stdout, - String stderr, String[] args, + String stderr, String[] args, String libs, TaskAttachedObserverXXX attached) { throw new RuntimeException("requestCreateAttachedProc"); } diff --git a/frysk-core/frysk/proc/live/ChangeLog b/frysk-core/frysk/proc/live/ChangeLog index 84dc832..edbc1ad 100644 --- a/frysk-core/frysk/proc/live/ChangeLog +++ b/frysk-core/frysk/proc/live/ChangeLog @@ -1,3 +1,7 @@ +2008-04-07 Stan Cox <scox@redhat.com> + + * LinuxPtraceHost.java (requestCreateAttachedProc): Add libs parameter. + 2008-04-07 Phil Muldoon <pmuldoon@redhat.com> * LinuxPtraceTaskState.java (Stepping.handleTrappedEvent): Reset diff --git a/frysk-core/frysk/proc/live/LinuxPtraceHost.java b/frysk-core/frysk/proc/live/LinuxPtraceHost.java index b51449e..d5bdb52 100644 --- a/frysk-core/frysk/proc/live/LinuxPtraceHost.java +++ b/frysk-core/frysk/proc/live/LinuxPtraceHost.java @@ -262,6 +262,7 @@ public class LinuxPtraceHost extends LiveHost { final String stdout, final String stderr, final String[] args, + final String libs, final TaskAttachedObserverXXX attachedObserver) { fine.log(this, "requestCreateAttachedProc"); Manager.eventLoop.add(new Event() { @@ -270,7 +271,7 @@ public class LinuxPtraceHost extends LiveHost { "execute - requestCreateAttachedProc", exe); ProcessIdentifier pid - = Fork.ptrace(exe, stdin, stdout, stderr, args); + = Fork.ptrace(exe, stdin, stdout, stderr, args, libs); // See if the Host knows about this task. ProcessIdentifier myTid = Tid.get(); LinuxPtraceTask myTask = getTask(myTid); diff --git a/frysk-core/frysk/sysroot/ChangeLog b/frysk-core/frysk/sysroot/ChangeLog index 520a545..0a21d10 100644 --- a/frysk-core/frysk/sysroot/ChangeLog +++ b/frysk-core/frysk/sysroot/ChangeLog @@ -1,3 +1,7 @@ +2008-04-07 Stan Cox <scox@redhat.com> + + * SysRoot.java (getLibPathViaSysRoot): New. + 2008-03-31 Stan Cox <scox@redhat.com> * SysRootFile.java (getSysRootedPath): New. diff --git a/frysk-core/frysk/sysroot/SysRoot.java b/frysk-core/frysk/sysroot/SysRoot.java index 8ba22a5..19437aa 100644 --- a/frysk-core/frysk/sysroot/SysRoot.java +++ b/frysk-core/frysk/sysroot/SysRoot.java @@ -94,6 +94,25 @@ public class SysRoot { else return new SysRootFile(sysRoot, f); } + + /** + * return a pathname of an executable. + * + * @return this executable's library pathname, in the special + * root directory. + */ + public String getLibPathViaSysRoot () { + String libraryPath = ""; + if (! sysRoot.equals("/")) { + if (new File(sysRoot, "/lib").exists()) + libraryPath += sysRoot + "/lib:"; + if (new File(sysRoot, "/usr/lib").exists()) + libraryPath += sysRoot + "/usr/lib"; + } + + return libraryPath; + } + private File findExe(String pathVar, String arg0) { if (pathVar == null) { diff --git a/frysk-sys/frysk/sys/ChangeLog b/frysk-sys/frysk/sys/ChangeLog index 5893ffd..d792726 100644 --- a/frysk-sys/frysk/sys/ChangeLog +++ b/frysk-sys/frysk/sys/ChangeLog @@ -1,3 +1,9 @@ +2008-04-07 Stan Cox <scox@redhat.com> + + * Fork.java (spawn): Add libs parameter. + (ptrace): Likewise. + * cni/Fork.cxx (spawn): New parameter libs. Use execve if we have libs. + 2008-04-07 Petr Machata <pmachata@redhat.com> * cni/Wait.cxx (processStatus): Normalize status to boolean in diff --git a/frysk-sys/frysk/sys/Fork.java b/frysk-sys/frysk/sys/Fork.java index 1a89f47..e82b506 100644 --- a/frysk-sys/frysk/sys/Fork.java +++ b/frysk-sys/frysk/sys/Fork.java @@ -42,7 +42,7 @@ package frysk.sys; import java.io.File; /** - * Create a child process (using fork) that immediatly performs some + * Create a child process (using fork) that immediately performs some * sort of exec. */ @@ -53,9 +53,10 @@ public final class Fork { private static native ProcessIdentifier spawn(File exe, String in, String out, String err, - String[] args, int trace); + String[] args, + String libs, int trace); private static ProcessIdentifier spawn(String[] args, int trace) { - return spawn(new File(args[0]), null, null, null, args, trace); + return spawn(new File(args[0]), null, null, null, args, "", trace); } /** @@ -66,7 +67,7 @@ public final class Fork { public static ProcessIdentifier exec(File exe, String in, String out, String err, String[] args) { - return spawn(exe, in, out, err, args, NO_TRACE); + return spawn(exe, in, out, err, args, "", NO_TRACE); } /** * Create a child process running EXE with arguments ARGS[0..]. @@ -75,7 +76,7 @@ public final class Fork { */ public static ProcessIdentifier exec(String in, String out, String err, String[] args) { - return spawn(new File(args[0]), in, out, err, args, NO_TRACE); + return spawn(new File(args[0]), in, out, err, args, "", NO_TRACE); } /** * Create a child process running ARGS[0] with arguments @@ -93,8 +94,8 @@ public final class Fork { */ public static ProcessIdentifier ptrace(File exe, String in, String out, - String err, String[] args) { - return spawn(exe, in, out, err, args, PTRACE); + String err, String[] args, String libs) { + return spawn(exe, in, out, err, args, libs, PTRACE); } /** * Create a child process running ARGS[0] with arguments @@ -113,7 +114,7 @@ public final class Fork { public static ProcessIdentifier utrace(File exe, String in, String out, String err, String[] args) { - return spawn(exe, in, out, err, args, UTRACE); + return spawn(exe, in, out, err, args, "", UTRACE); } /** * Create a child process running ARGS[0] with arguments diff --git a/frysk-sys/frysk/sys/cni/Fork.cxx b/frysk-sys/frysk/sys/cni/Fork.cxx index b745ed7..c8b639e 100644 --- a/frysk-sys/frysk/sys/cni/Fork.cxx +++ b/frysk-sys/frysk/sys/cni/Fork.cxx @@ -73,7 +73,7 @@ reopen (jstring file, const char *mode, FILE *stream) int spawn(java::io::File* exe, jstring in, jstring out, jstring err, - jstringArray args, jint trace) + jstringArray args, jstring libs, jint trace) { // Convert args into argv, argc, filename. char *filename = ALLOCA_STRING(exe->getPath()); @@ -120,7 +120,19 @@ spawn(java::io::File* exe, jstring in, jstring out, jstring err, case frysk::sys::Fork::NO_TRACE: break; } - ::execv (filename, argv); + if (libs->length() > 0) + { + char *libs_str = (char *) alloca (libs->length() + 1); + JvGetStringUTFRegion (libs, 0, libs->length (), libs_str); + libs_str[libs->length()] = '\0'; + static char* libenv; + if (asprintf (&libenv, "LD_LIBRARY_PATH=%s", libs_str) < 0) + ::perror ("asprintf"); + char * const env[] = {libenv, (char*)0}; + ::execve (filename, argv, env); + } + else + ::execv (filename, argv); // This should not happen. ::perror ("execvp"); ::_exit (errno); @@ -130,8 +142,8 @@ spawn(java::io::File* exe, jstring in, jstring out, jstring err, frysk::sys::ProcessIdentifier* frysk::sys::Fork::spawn(java::io::File* exe, jstring in, jstring out, jstring err, - jstringArray args, jint trace) { - int pid = ::spawn(exe, in, out, err, args, trace); + jstringArray args, jstring libs, jint trace) { + int pid = ::spawn(exe, in, out, err, args, libs, trace); return frysk::sys::ProcessIdentifierFactory::create(pid); } @@ -148,7 +160,7 @@ frysk::sys::Fork::daemon (java::io::File* exe, jstring in, jstring out, // process id ends up in PID. if (v == 0) { - pid = ::spawn(exe, in, out, err, args, frysk::sys::Fork::NO_TRACE); + pid = ::spawn(exe, in, out, err, args, JvNewStringUTF (""), frysk::sys::Fork::NO_TRACE); _exit (0); } hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-04-07 21:53 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=20080407215359.6296.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).