From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15147 invoked by alias); 19 Mar 2008 20:58:57 -0000 Received: (qmail 15120 invoked by uid 9561); 19 Mar 2008 20:58:57 -0000 Date: Wed, 19 Mar 2008 20:58:00 -0000 Message-ID: <20080319205857.15105.qmail@sourceware.org> From: swagiaal@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: swagiaal: fix failing tests, added test for fstep PID. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: bb46ac6e3f62e6ec77509f6d563453a3e7df405f X-Git-Newrev: d68d98617fe1c1510220319e72e5516166db285e Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00409.txt.bz2 The branch, master has been updated via d68d98617fe1c1510220319e72e5516166db285e (commit) from bb46ac6e3f62e6ec77509f6d563453a3e7df405f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit d68d98617fe1c1510220319e72e5516166db285e Author: Sami Wagiaalla Date: Wed Mar 19 16:58:35 2008 -0400 swagiaal: fix failing tests, added test for fstep PID. frysk-core/frysk/bindir/ChangeLog +2008-03-19 Sami Wagiaalla + + * TestFstep.java: New Test. + * fstep.java: fixed PID support. + removed -p options (supported through command line parser) + frysk-core/frysk/util/ChangeLog +2008-03-19 Sami Wagiaalla + + * ProcRunUtil.java: keeps a set of known tasks. + ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 8 +++++- frysk-core/frysk/bindir/TestFstep.java | 19 +++++++++++++ frysk-core/frysk/bindir/fstep.java | 47 +++++++++++++++---------------- frysk-core/frysk/util/ChangeLog | 4 +++ frysk-core/frysk/util/ProcRunUtil.java | 33 ++++++++++++---------- 5 files changed, 71 insertions(+), 40 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index d9cf717..e428c8c 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,7 +1,13 @@ +2008-03-19 Sami Wagiaalla + + * TestFstep.java: New Test. + * fstep.java: fixed PID support. + removed -p options (supported through command line parser) + 2008-03-19 Sami Wagiaalla * fstep.java: Now uses ProcRunUtil. - + 2008-03-17 Andrew Cagney * fstep.java: Update; using TaskAttachedObserverXXX. diff --git a/frysk-core/frysk/bindir/TestFstep.java b/frysk-core/frysk/bindir/TestFstep.java index 3fe638f..d4ba152 100644 --- a/frysk-core/frysk/bindir/TestFstep.java +++ b/frysk-core/frysk/bindir/TestFstep.java @@ -43,6 +43,8 @@ package frysk.bindir; import frysk.config.Config; import java.io.File; import frysk.expunit.Regex; +import frysk.proc.Task; +import frysk.testbed.SlaveOffspring; import frysk.testbed.TestLib; import frysk.testbed.TearDownExpect; import lib.dwfl.Elf; @@ -75,4 +77,21 @@ public class TestFstep extends TestLib { e.close(); } } + + public void testFstepAcceptsPIDArgument() { + + // Create an unattached child process. + SlaveOffspring child = SlaveOffspring.createChild(); + Task task = child.findTaskUsingRefresh(true); + + String command = Config.getBinFile("fstep").getAbsolutePath(); + String argument = "" + task.getProc().getPid(); + TearDownExpect expect = new TearDownExpect(new String[] { + command, argument + }); + + expect.expect(""+task.getProc().getPid()); + + } + } diff --git a/frysk-core/frysk/bindir/fstep.java b/frysk-core/frysk/bindir/fstep.java index 44b9a83..0376110 100644 --- a/frysk-core/frysk/bindir/fstep.java +++ b/frysk-core/frysk/bindir/fstep.java @@ -51,8 +51,10 @@ import frysk.isa.signals.Signal; import frysk.proc.Action; import frysk.proc.Auxv; import frysk.proc.Manager; +import frysk.proc.Proc; import frysk.proc.Task; import frysk.proc.TaskObserver; +import frysk.util.CommandlineParser; import frysk.util.ProcRunUtil; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; @@ -80,6 +82,8 @@ public class fstep implements ProcRunUtil.NewTaskObserver, // The process id to trace static int pid; + private static String[] command; + // Tasks being observed mapped to the total number of steps. private static final HashMap tasks = new HashMap(); @@ -87,7 +91,22 @@ public class fstep implements ProcRunUtil.NewTaskObserver, { sample = 0; instrs = 1; + + //XXX: parser is only needed because fstep uses fstep.command + // to figure out wether the loaded code should be skipped + // or not. + final CommandlineParser parser = new CommandlineParser("fstep") + { + //XXX: this is needed so parser doesnt thin that pids are not supported + public void parsePids(Proc[] procs) { + } + public void parseCommand(Proc command) { + fstep.command = command.getCmdLine(); + } + }; + parser.parse(args); + Option sampleOption = new Option("sample", 's', "how often to print the current instruction", "samples") @@ -128,29 +147,9 @@ public class fstep implements ProcRunUtil.NewTaskObserver, } }; - Option pidOptions = new Option("pid", 'p', - "the running process to step", - "pid") - { - public void parsed(String argument) throws OptionException - { - try - { - pid = Integer.parseInt(argument); - } - catch (NumberFormatException nfe) - { - OptionException ex; - ex = new OptionException("pid must be a number"); - ex.initCause(nfe); - throw ex; - } - } - }; - final fstep step = new fstep(); - Option[] options = new Option[]{sampleOption, instructionsOption, pidOptions}; + Option[] options = new Option[]{sampleOption, instructionsOption}; ProcRunUtil procRunUtil = new ProcRunUtil("fstep", "fstep [OPTIONS]", args, step , options, ProcRunUtil.DEFAULT); procRunUtil.start(); @@ -205,8 +204,8 @@ public class fstep implements ProcRunUtil.NewTaskObserver, // then we want to start stepping at the actual start of the // process (and not inside the dynamic linker). long startAddress = 0; -// if (command != null && command.length != 0) -// { + if (command != null && command.length != 0) + { Auxv[] auxv = task.getProc().getAuxv (); for (int i = 0; i < auxv.length; i++) { @@ -216,7 +215,7 @@ public class fstep implements ProcRunUtil.NewTaskObserver, break; } } -// } + } // System.out.println("fstep.updateAttached() startAddress 0x" + Long.toHexString(startAddress)); diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog index 66884f6..c98bf8f 100644 --- a/frysk-core/frysk/util/ChangeLog +++ b/frysk-core/frysk/util/ChangeLog @@ -1,3 +1,7 @@ +2008-03-19 Sami Wagiaalla + + * ProcRunUtil.java: keeps a set of known tasks. + 2008-03-19 Sami Wagiaalla * ProcRunUtil.java: remove observationAdded()/Realized(). diff --git a/frysk-core/frysk/util/ProcRunUtil.java b/frysk-core/frysk/util/ProcRunUtil.java index f46db8d..a82c83b 100644 --- a/frysk-core/frysk/util/ProcRunUtil.java +++ b/frysk-core/frysk/util/ProcRunUtil.java @@ -68,6 +68,8 @@ import gnu.classpath.tools.getopt.Option; */ public class ProcRunUtil { + private final HashSet knownTasks = new HashSet(); + ForkedObserver forkedObserver = new ForkedObserver(); AttachedObserver attachedObserver = new AttachedObserver(); @@ -129,20 +131,24 @@ public class ProcRunUtil { } private void addObservers(Task task) { - - for (int i = 0; i < observers.length; i++) { - this.addTaskObserver(observers[i], task); - } - if(options.followForks){ - this.addTaskObserver(forkedObserver, task); + if (knownTasks.add(task)) { + + if(newTaskObserver != null){ + newTaskObserver.notifyNewTask(task); + } + + for (int i = 0; i < observers.length; i++) { + this.addTaskObserver(observers[i], task); + } + if (options.followForks) { + this.addTaskObserver(forkedObserver, task); + } } } class ForkedObserver implements TaskObserver.Forked { public Action updateForkedOffspring(Task parent, Task offspring) { - newTaskObserver.notifyNewTask(offspring); addObservers(offspring.getProc()); - offspring.requestUnblock(this); return Action.BLOCK; } @@ -164,8 +170,7 @@ public class ProcRunUtil { private Set procs = new HashSet(); public synchronized Action updateAttached(Task task) { - newTaskObserver.notifyNewTask(task); - + Proc proc = task.getProc(); if (!procs.contains(proc)) { procs.add(proc); @@ -188,10 +193,9 @@ public class ProcRunUtil { ProcObserver.ProcTasks tasksObserver = new ProcObserver.ProcTasks() { - int taskCount = 0; + public void existingTask (Task task) { - taskCount++; addObservers(task); if (task == task.getProc().getMainTask()) { @@ -204,14 +208,13 @@ public class ProcRunUtil { public void taskAdded (Task task) { - taskCount++; addObservers(task); } public void taskRemoved (Task task) { - taskCount--; - if(taskCount == 0){ + knownTasks.remove(task); + if(knownTasks.size() == 0){ Manager.eventLoop.requestStop(); } } hooks/post-receive -- frysk system monitor/debugger