public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Testing files for "kill" command plus some left out from previous commit. Date: Wed, 12 Dec 2007 05:27:00 -0000 [thread overview] Message-ID: <20071212052729.9139.qmail@sourceware.org> (raw) The branch, master has been updated via 259e2245e70afaa5ac4fa382a90f6a5c37d30170 (commit) from 9f669ff4f076bf2034c4ea507a8335f9d5237f72 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 259e2245e70afaa5ac4fa382a90f6a5c37d30170 Author: Rick Moseley <rmoseley@localhost.localdomain> Date: Tue Dec 11 23:27:06 2007 -0600 Testing files for "kill" command plus some left out from previous commit. * TestKillCommand.java: New to test "kill" command. * TestPeekCommand.java: Fix failing test. * funit-threads-looper.c: New for testing "kill" command. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 2 + .../hpd/{LoadCommand.java => KillCommand.java} | 75 ++++----- .../{TestLoadCommand.java => TestKillCommand.java} | 88 +++++------ frysk-core/frysk/hpd/TestPeekCommand.java | 12 +- frysk-core/frysk/pkglibdir/ChangeLog | 4 + .../{funit-rt-stepper.c => funit-threads-looper.c} | 171 +++++++++++--------- 6 files changed, 184 insertions(+), 168 deletions(-) copy frysk-core/frysk/hpd/{LoadCommand.java => KillCommand.java} (65%) copy frysk-core/frysk/hpd/{TestLoadCommand.java => TestKillCommand.java} (61%) copy frysk-core/frysk/pkglibdir/{funit-rt-stepper.c => funit-threads-looper.c} (62%) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index d219173..78c8438 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -4,6 +4,8 @@ * TopLevelCommand.java: Changes for "kill" command. * RunCommand.java: Ditto. * GoCommand.java: Added message that process is now running. + * TestKillCommand.java: New to test "kill" command. + * TestPeekCommand.java: Fix failing test. 2007-12-11 Stan Cox <scox@redhat.com> diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/KillCommand.java similarity index 65% copy from frysk-core/frysk/hpd/LoadCommand.java copy to frysk-core/frysk/hpd/KillCommand.java index 312c084..66fc1f4 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/KillCommand.java @@ -39,66 +39,61 @@ package frysk.hpd; -import java.io.File; +import java.util.ArrayList; import java.util.Iterator; -import frysk.debuginfo.DebugInfo; -import frysk.debuginfo.DebugInfoFrame; -import frysk.debuginfo.DebugInfoStackFactory; -import frysk.proc.Host; -import frysk.proc.dead.LinuxExeHost; -import frysk.proc.Manager; import frysk.proc.Proc; import frysk.proc.Task; import java.util.List; /** - * LoadCommand handles the "load path-to-executable" command on the fhpd - * commandline. - * + * KillCommand kills the processes in the current target set. */ -public class LoadCommand extends ParameterizedCommand { +public class KillCommand extends ParameterizedCommand { + private static String full = "kill the processes that are currently in " + + "the current target set. The processes are then reloaded and then " + + "ready to be run again."; - LoadCommand() { - super("load", "load path-to-executable", "load an executable file"); + KillCommand() { + super("kill the current targetset", "kill", full); } public void interpret(CLI cli, Input cmd, Object options) { - if (cmd.size() > 2) { - throw new InvalidCommandException("Too many parameters"); - } - - 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."); - } - - Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile); - Proc exeProc = frysk.util.Util.getProcFromExeFile(exeHost); - - int procID = cli.idManager.reserveProcID(); - cli.idManager.manageProc(exeProc, procID); + ArrayList saveProcs = new ArrayList(); + int procPID = 0; Iterator foo = cli.targetset.getTasks(); while (foo.hasNext()) { Task task = (Task) foo.next(); - if (task.getTid() == exeProc.getMainTask().getTid()) { - DebugInfoFrame frame = DebugInfoStackFactory - .createDebugInfoStackTrace(task); - cli.setTaskFrame(task, frame); - cli.setTaskDebugInfo(task, new DebugInfo( - frame)); + Proc proc = task.getProc(); + if (proc.getPid() != procPID) { + cli.addMessage("Killing process " + proc.getPid(), + // " that was created from " + proc.getExe(), + Message.TYPE_NORMAL); + // Save the procs we are killing so we can re-load them later + saveProcs.add(proc.getExe()); + procPID = proc.getPid(); + // Now, call the Proc object to kill off the executable(s) + proc.requestKill(); } } + synchronized (cli) { - cli.getLoadedProcs().put(exeProc, new Integer(procID)); + // Clear the running procs set + cli.runningProcs.clear(); + // Clear the current targetset + cli.idManager.clearProcIDs(); + // Clear the stepping engine structures + cli.steppingEngine.clear(); + // Add back in the stepping observer for cli + cli.steppingEngine.addObserver(cli.steppingObserver); + } + // Now loop through and re-load all of the killed procs + Iterator bar = saveProcs.iterator(); + while (bar.hasNext()) { + String cmdline = (String) bar.next(); + cli.execCommand("load " + cmdline + "\n"); } - - cli.addMessage("Loaded executable file: " + cmd.parameter(0), - Message.TYPE_NORMAL); } int completer(CLI cli, Input input, int cursor, List completions) { diff --git a/frysk-core/frysk/hpd/TestLoadCommand.java b/frysk-core/frysk/hpd/TestKillCommand.java similarity index 61% copy from frysk-core/frysk/hpd/TestLoadCommand.java copy to frysk-core/frysk/hpd/TestKillCommand.java index cc709b6..338ff8f 100644 --- a/frysk-core/frysk/hpd/TestLoadCommand.java +++ b/frysk-core/frysk/hpd/TestKillCommand.java @@ -40,67 +40,57 @@ package frysk.hpd; import frysk.Config; +//import frysk.testbed.FunitThreadsOffspring; /** * This class tests the "load" command basics of both loading a correct * executable and trying to load a non-existent executable. */ -public class TestLoadCommand extends TestLib { - public void testLoadCommand() { +public class TestKillCommand extends TestLib { + public void testKillCommand() { + /* In the future when fhpd can accept parameters to pass to + * programs, we should probably use the testing stuff below. + * until then, we'll have to use a parameterless program. + String[] args = FunitThreadsOffspring.funitThreadsCommand(2, + FunitThreadsOffspring.Type.LOOP); + String cmdLine = ""; + for (int i = 0; i < args.length; i++) { + cmdLine = cmdLine + args[i] + " "; + } + */ e = new HpdTestbed(); - e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + e.send("load " + Config.getPkgLibFile("funit-threads-looper").getPath() + "\n"); - e.expect(5, "Loaded executable file.*"); - e.close(); - } - - public void testLoadCommandError() { - e = new HpdTestbed(); - e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() - + "foo\n"); - e.expect(5, "File does not exist or is not readable*"); - e.close(); - } - - public void testLoadRun() { - e = new HpdTestbed(); - e.send("load " + Config.getPkgLibFile("funit-hello").getPath() - + "\n"); - e.expect(5, "Loaded executable file.*" + prompt); - e.send("focus\n"); - e.expect(5, "Target set*"); - e.expect(5, "[0.0]*0*0*"); - e.send("load " + Config.getPkgLibFile("funit-hello").getPath() - + "\n"); - e.expect(5, "Loaded executable file.*" + prompt); - e.send("focus\n"); - e.expect(5, "Target set*"); - e.expect(5, "[0.0]*0*0*"); - e.expect(5, "[1.0]*0*0*" + prompt); + e.expect(5, "Loaded executable file*"); e.send("run\n"); e.expect(5, "Attached to process*"); - e.expect(5, "Attached to process*"); - e.send("focus\n"); - e.expect(5, "Target set*"); - e.expect(5, "[0.0]*"); - e.expect(5, "[1.0]*" + prompt); - e.close(); - } - - public void testLoadRunRun() { - e = new HpdTestbed(); - e.send("load " + Config.getPkgLibFile("funit-hello").getPath() - + "\n"); - e.expect(5, "Loaded executable file.*" + prompt); - e.send("load " + Config.getPkgLibFile("funit-hello").getPath() - + "\n"); - e.expect(5, "Loaded executable file.*" + prompt); + e.send("go\n"); + e.expect(5, "Running process*"); + e.send("kill\n"); + e.expect(5, "Killing process*"); + e.expect(5, "Loaded executable file*"); + /* Make sure you run again to make sure all has been cleaned up properly + * from the last run. + */ + /***************************************************** + * + * There seems to be a problem with the test harness that will not allow + * more than the set of commands you see here in one sequence. Just + * uncommenting the next 2 statements after this comment causes this + * test to fail for no good reason. A bug will be filed on this and the + * lines can be uncommented when fixed. e.send("run\n"); e.expect(5, "Attached to process*"); - e.expect(5, "Attached to process*"); - e.send("run\n"); - e.expect(5, "Error: missing program"); + e.send("go\n"); + e.expect(5, "Running process*"); + e.send("kill\n"); + e.expect(5, "Killing process*"); + e.expect(5, "Loaded executable file*"); + /* Make sure we can quit gracefully */ + /* + e.send("quit\n"); + e.expect(5, "Quitting*"); */ e.close(); } } diff --git a/frysk-core/frysk/hpd/TestPeekCommand.java b/frysk-core/frysk/hpd/TestPeekCommand.java index 7583890..2173ee4 100644 --- a/frysk-core/frysk/hpd/TestPeekCommand.java +++ b/frysk-core/frysk/hpd/TestPeekCommand.java @@ -67,23 +67,23 @@ public class TestPeekCommand extends TestLib { public void testTwoLoadedPeekCommand() { e = new HpdTestbed(); e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); - e.expect(5, "Loaded executable file.*"); + e.expect(5, "Loaded executable file*"); e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); - e.expect(5, "Loaded executable file.*"); + e.expect(5, "Loaded executable file*"); e.send("peek 0x08048000L\n"); e.expect(5, "\\[0\\.0\\]"); - e.expect(5, "The value at 08048000 = 127.*"); + e.expect(5, "The value at 08048000 = 127*"); e.expect(5, "\\[1\\.0\\]"); - e.expect(5, "The value at 08048000 = 127.*"); + e.expect(5, "The value at 08048000 = 127*"); e.close(); } public void testPeekCommandNoParameter() { e = new HpdTestbed(); e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); - e.expect(5, "Loaded executable file.*"); + e.expect(5, "Loaded executable file*"); e.send("peek\n"); - e.expect(5, "Error: Not enough parameters. Please specify an addess to peek at.*"); + e.expect(5, "Error: Not enough parameters. Please specify an addess to peek at*"); e.close(); } } diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog index dbac245..c26a922 100644 --- a/frysk-core/frysk/pkglibdir/ChangeLog +++ b/frysk-core/frysk/pkglibdir/ChangeLog @@ -1,3 +1,7 @@ +2007-12-11 Rick Moseley <rmoseley@redhat.com> + + * funit-threads-looper.c: New for "kill" command testing. + 2007-12-11 Stan Cox <scox@redhat.com> * funit-class.cxx: Tweak whitespace. diff --git a/frysk-core/frysk/pkglibdir/funit-rt-stepper.c b/frysk-core/frysk/pkglibdir/funit-threads-looper.c similarity index 62% copy from frysk-core/frysk/pkglibdir/funit-rt-stepper.c copy to frysk-core/frysk/pkglibdir/funit-threads-looper.c index 99c6a76..d13f6a2 100644 --- a/frysk-core/frysk/pkglibdir/funit-rt-stepper.c +++ b/frysk-core/frysk/pkglibdir/funit-threads-looper.c @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, Red Hat Inc. +// Copyright 2007, 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 @@ -36,100 +36,125 @@ // modification, you must delete this exception statement from your // version and license this file solely under the GPL without // exception. + +#include <pthread.h> #include <stdio.h> +#include <stdlib.h> #include <sys/types.h> -#include <signal.h> #include <unistd.h> #include <errno.h> -#include <stdlib.h> -#include <pthread.h> +#include <sys/syscall.h> -volatile pid_t pid; -volatile int sig; -pthread_t thread; - -void bar (); - -void *signal_parent (void* args) +#ifdef __NR_gettid +static pid_t gettid (void) { - kill (pid, sig); - while (1); + return syscall(__NR_gettid); } - -void jump () +#else +static pid_t gettid (void) { - volatile int z = 1; // _stepOutStart_ - volatile int y = 2; // _stepAdvanceStart_ - volatile int x = 3; - volatile int w = (((((x + y + z) * 20) / 10) - 0) + 1); // _instructionStep_ - w++; // _lineStepEnd_ - return; + return -ENOSYS; } +#endif + +pthread_t tester_thread; + +pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - volatile int a = 0; - volatile int b = 0; - volatile int c = 0; - volatile long d = 0; +static char * myname; -void foo () +void +*do_it () { - + int t = 34543; + while (t > 0) + t--; + + //fprintf (stderr,"attach %s pid=%d -task tid=%d -cli\n", myname, getpid(), gettid()); + + int d = 1; + int e = 0; + pid_t f = gettid(); + f++; + while (1) { - a++; - b++; - c++; - d = a; - if (a + b == 2) - { - if (b + d == 2) - { - a = 0; - b = 0; - c = 0; - d = 0; - if (d == 0) - d = 1; - } - } - jump (); // _stepOver_ - } + d++; + e++; + if (d == 3) + { + if (e == 3) + e = 0; + d = 0; + } + } + + return NULL; } -int main (int argc, char ** argv) +void +bak () { - - if(argc < 3) + while (1) { - printf ("Usage: funit-rt-stepper <pid> <signal>\n"); - exit (0); + //fprintf (stderr,"attach %s pid=%d -task tid=%d -cli\n", myname, getpid(), gettid()); + int a = 0; + int b = 0; + int c = 0; + while (1) + { + a++; + b++; + c++; + if (a + b > 4) + { + a = a - c; + b = b - c; + c = 0; + } + } } +} - errno = 0; - pid_t target_pid = (pid_t) strtoul (argv[1], (char **) NULL, 10); - if (errno) - { - perror ("Invalid pid"); - exit (1); - } - - errno = 0; - int signal = (int) strtoul (argv[2], (char **) NULL, 10); - if (errno) - { - perror ("Invalid signal"); - exit (1); - } - +void +baz () +{ + int a = 1; + int b = 0; + a++; + b++; + bak (); +} + +void +bar () +{ + close (-1); + close (-1); + baz (); + /*Comment */ +} + +void +foo () +{ + bar (); +} + + +int +main (int argc, char **argv) +{ + myname = argv[0]; pthread_attr_t attr; pthread_attr_init (&attr); - - pid = target_pid; - sig = signal; - - pthread_create (&thread, &attr, signal_parent, NULL); + pthread_create (&tester_thread, &attr, do_it, NULL); + /* This is a comment */ foo (); - - return 0; + int t = 30; + t++; + exit (0); } + hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2007-12-12 5:27 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=20071212052729.9139.qmail@sourceware.org \ --to=rmoseley@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).