From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12793 invoked by alias); 8 Nov 2007 20:57:39 -0000 Received: (qmail 12742 invoked by uid 367); 8 Nov 2007 20:57:38 -0000 Date: Thu, 08 Nov 2007 20:57:00 -0000 Message-ID: <20071108205738.12727.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Merge branch 'master' of ssh://sourceware.org/git/frysk X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 92e9c47e02ab8b02ccd29dac7763d286d4652353 X-Git-Newrev: d9bd1560c585138ab990d7ad0b65b3d9e6ad8ce1 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: 2007-q4/txt/msg00324.txt.bz2 The branch, master has been updated via d9bd1560c585138ab990d7ad0b65b3d9e6ad8ce1 (commit) via f2f0a6b50c1d6adf0b8cf623ff48d7622db42a27 (commit) from 92e9c47e02ab8b02ccd29dac7763d286d4652353 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit d9bd1560c585138ab990d7ad0b65b3d9e6ad8ce1 Merge: f2f0a6b50c1d6adf0b8cf623ff48d7622db42a27 92e9c47e02ab8b02ccd29dac7763d286d4652353 Author: Andrew Cagney Date: Thu Nov 8 15:56:13 2007 -0500 Merge branch 'master' of ssh://sourceware.org/git/frysk commit f2f0a6b50c1d6adf0b8cf623ff48d7622db42a27 Author: Andrew Cagney Date: Thu Nov 8 15:55:58 2007 -0500 AttachCommand extends ParameterizedCommand; simplify. frysk-core/frysk/hpd/ChangeLog 2007-11-08 Andrew Cagney * CLI.java (doAttach(Task)): Delete. (doAttach(Proc)): Replace doAttach(int,Proc,Task). * RunCommand.java: Update. * AttachCommand.java: Update; extend ParameterizedCommand; delete -task option. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/AttachCommand.java | 101 +++++++++++-------------------- frysk-core/frysk/hpd/CLI.java | 23 +++----- frysk-core/frysk/hpd/ChangeLog | 6 ++ frysk-core/frysk/hpd/RunCommand.java | 14 ++--- 4 files changed, 55 insertions(+), 89 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java index 6271354..b87ec91 100644 --- a/frysk-core/frysk/hpd/AttachCommand.java +++ b/frysk-core/frysk/hpd/AttachCommand.java @@ -39,15 +39,14 @@ package frysk.hpd; -import java.util.Iterator; import frysk.proc.Proc; import frysk.proc.ProcId; -import frysk.proc.Task; import frysk.proc.Manager; import frysk.proc.FindProc; +import java.util.List; + +class AttachCommand extends ParameterizedCommand { -class AttachCommand - extends Command { private class ProcFinder implements FindProc { Proc proc = null; @@ -66,75 +65,47 @@ class AttachCommand } } - private static final String full = "The attach command causes the debugger " - + "to attach to an existing\n" - + "process(es), making it possible to continue the process' " - + "execution under\n" - + "debugger control. The command applies at the process level; all " - + "threads\n" - + "corresponding to the process will be attached by the operation. " - + "It is\n" - + "the user's responsibility to ensure that the process(es) " - + "actually is\n" + "executing the specified executable."; - AttachCommand() { super("attach", "Attach to a running process.", - "attach [executable] pid [-task tid]", full); + "attach ...", + ("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" + + " command applies at the process level; all threads" + + " corresponding to the process will be attached by the" + + " operation. It is the user's responsibility to ensure" + + " that the process(es) actually is executing the specified" + + " executable.")); } - public void interpret(CLI cli, Input cmd) { - int pid = 0; - int tid = 0; - if (cmd.size() == 1 && cmd.parameter(0).equals("-help")) { - cli.printUsage(cmd); - return; - } - - if (cmd.size() < 1) { - cli.printUsage(cmd); - return; - } - - for (int idx = 0; idx < cmd.size(); idx++) { - if (cmd.parameter(idx).equals("-task")) { - idx += 1; - tid = Integer.parseInt(cmd.parameter(idx)); - } else if (cmd.parameter(idx).indexOf('-') == 0) { - cli.printUsage(cmd); - return; - } else if (cmd.parameter(idx).matches("[0-9]+")) - pid = Integer.parseInt(cmd.parameter(idx)); + public void interpret(CLI cli, Input cmd, Object options) { + if (cmd.size() == 0) { + throw new InvalidCommandException("Missing process ID"); } - - ProcFinder findProc = new ProcFinder(); - Manager.host.requestFindProc(new ProcId(pid), findProc); - synchronized (findProc) { - while (!findProc.procSearchFinished) { - try { - findProc.wait(); - } catch (InterruptedException ie) { - findProc.proc = null; + for (int i = 0; i < cmd.size(); i++) { + int pid = Integer.parseInt(cmd.parameter(i)); + ProcFinder findProc = new ProcFinder(); + Manager.host.requestFindProc(new ProcId(pid), findProc); + synchronized (findProc) { + while (!findProc.procSearchFinished) { + try { + findProc.wait(); + } catch (InterruptedException ie) { + findProc.proc = null; + } } } - } - if (findProc.proc == null) { - cli.addMessage("Couldn't find process " + pid, Message.TYPE_ERROR); - return; - } - int procID = cli.idManager.reserveProcID(); - Task task = null; - if (pid == tid || tid == 0) - task = findProc.proc.getMainTask(); - else - for (Iterator i = findProc.proc.getTasks().iterator(); i.hasNext();) { - task = (Task) i.next(); - if (task.getTid() == tid) - break; + if (findProc.proc == null) { + cli.outWriter.print("Couldn't find process "); + cli.outWriter.println(pid); + continue; } - cli.doAttach(pid, findProc.proc, task); - cli.getSteppingEngine().getBreakpointManager() - .manageProcess(findProc.proc); - cli.idManager.manageProc(findProc.proc, procID); + cli.doAttach(findProc.proc); + } + } + int complete(CLI cli, PTSet ptset, String input, int base, + List completions) { + return -1; } } diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java index 70871e3..e077073 100644 --- a/frysk-core/frysk/hpd/CLI.java +++ b/frysk-core/frysk/hpd/CLI.java @@ -132,37 +132,30 @@ public class CLI { /* * Command handlers */ - - public void doAttach(int pid, Proc proc, Task task) { - Proc[] temp = new Proc[1]; - temp[0] = proc; + public void doAttach(Proc proc) { synchronized (this) { attached = -1; attachedLatch = new CountDownLatch(1); } steppingEngine.addProc(proc); - // Wait till we are attached. + // Wait till we are attached. try { attachedLatch.await(); - addMessage("Attached to process " + attached, Message.TYPE_NORMAL); - } - catch (InterruptedException ie) { + outWriter.print("Attached to process "); + outWriter.println(attached); + } catch (InterruptedException ie) { addMessage("Attach interrupted.", Message.TYPE_ERROR); return; - } - finally { + } finally { synchronized (this) { attached = -1; attachedLatch = null; } } + steppingEngine.getBreakpointManager().manageProcess(proc); + idManager.manageProc(proc, idManager.reserveProcID()); } - public void doAttach(Task task) { - Proc proc = task.getProc(); - doAttach(proc.getPid(), proc, task); - } - //private static PrintStream out = null;// = System.out; final PrintWriter outWriter; private Preprocessor prepro; diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 347cd06..9c2e773 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,5 +1,11 @@ 2007-11-08 Andrew Cagney + * CLI.java (doAttach(Task)): Delete. + (doAttach(Proc)): Replace doAttach(int,Proc,Task). + * RunCommand.java: Update. + * AttachCommand.java: Update; extend ParameterizedCommand; delete + -task option. + * TestAliasCommands.java: New file. * AliasCommands.java: New. diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/RunCommand.java index f5e0c6c..d70035a 100644 --- a/frysk-core/frysk/hpd/RunCommand.java +++ b/frysk-core/frysk/hpd/RunCommand.java @@ -116,8 +116,8 @@ class RunCommand extends Command { public void interpret(CLI cli, Input cmd) { if (cmd.size() < 1) { - cli.printUsage(cmd); - return; + // XXX: should default to previous values. + throw new InvalidCommandException("missing program"); } Runner runner = new Runner(cli); Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner); @@ -126,12 +126,8 @@ class RunCommand extends Command { } catch (InterruptedException e) { return; } - // register with SteppingEngine - cli.doAttach(runner.launchedTask); - cli.getSteppingEngine().getBreakpointManager() - .manageProcess(runner.launchedTask.getProc()); - cli.idManager.manageProc(runner.launchedTask.getProc(), - cli.idManager.reserveProcID()); - runner.launchedTask.requestUnblock(runner); + // register with SteppingEngine et.al. + cli.doAttach(runner.launchedTask.getProc()); + runner.launchedTask.requestUnblock(runner); } } hooks/post-receive -- frysk system monitor/debugger