public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add frysk.isa.signals.StandardSignals. Date: Fri, 25 Jan 2008 21:21:00 -0000 [thread overview] Message-ID: <20080125212046.14948.qmail@sourceware.org> (raw) The branch, master has been updated via d8f8d2c80c6c1cc2ebc414a4d52a07b3941fd616 (commit) from fc285e51bf9780171d01de5ad90b344480e2667a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit d8f8d2c80c6c1cc2ebc414a4d52a07b3941fd616 Author: Andrew Cagney <cagney@toil.yyz.redhat.com> Date: Fri Jan 25 16:20:11 2008 -0500 Add frysk.isa.signals.StandardSignals. frysk-core/frysk/isa/signals/ChangeLog 2008-01-25 Andrew Cagney <cagney@redhat.com> * SignalTableFactory.java: Use StandardSignal. * Signal.java (equals(StandardSignal)): New. (Signal(int,StandardSignal)): New. * StandardSignal.java: New. frysk-sys/frysk/sys/ChangeLog 2008-01-25 Andrew Cagney <cagney@redhat.com> * Signal.java-sh: Add the synonyms - POLL, IOT, INFO and CLD - last. * Signal.java-sh (toHostStringFIXME(int)): Delete. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/isa/signals/ChangeLog | 5 + frysk-core/frysk/isa/signals/Signal.java | 8 ++ frysk-core/frysk/isa/signals/SignalTable.java | 35 ++++-- .../frysk/isa/signals/SignalTableFactory.java | 101 ++++++++------- frysk-core/frysk/isa/signals/StandardSignal.java | 133 ++++++++++++++++++++ frysk-core/frysk/isa/signals/TestSignalTable.java | 8 ++ frysk-sys/frysk/sys/ChangeLog | 5 + frysk-sys/frysk/sys/Signal.java-sh | 21 +-- 8 files changed, 246 insertions(+), 70 deletions(-) create mode 100644 frysk-core/frysk/isa/signals/StandardSignal.java First 500 lines of diff: diff --git a/frysk-core/frysk/isa/signals/ChangeLog b/frysk-core/frysk/isa/signals/ChangeLog index 050274b..7729b9d 100644 --- a/frysk-core/frysk/isa/signals/ChangeLog +++ b/frysk-core/frysk/isa/signals/ChangeLog @@ -1,5 +1,10 @@ 2008-01-25 Andrew Cagney <cagney@redhat.com> + * SignalTableFactory.java: Use StandardSignal. + * Signal.java (equals(StandardSignal)): New. + (Signal(int,StandardSignal)): New. + * StandardSignal.java: New. + * TestSignalTable.java: Use frysk.testbed.IsaTestbed. 2008-01-24 Andrew Cagney <cagney@redhat.com> diff --git a/frysk-core/frysk/isa/signals/Signal.java b/frysk-core/frysk/isa/signals/Signal.java index 11d97ae..0892ae3 100644 --- a/frysk-core/frysk/isa/signals/Signal.java +++ b/frysk-core/frysk/isa/signals/Signal.java @@ -46,6 +46,11 @@ public class Signal implements Comparable { private final int value; private final String name; private final String description; + Signal(int value, StandardSignal s) { + this.value = value; + this.name = s.getName(); + this.description = s.getDescription(); + } Signal(int value, String name, String description) { this.value = value; this.name = name; @@ -80,4 +85,7 @@ public class Signal implements Comparable { public int compareTo(Object o) { return ((Signal)o).intValue() - this.intValue(); } + public boolean equals(StandardSignal s) { + return s.equals(this); + } } diff --git a/frysk-core/frysk/isa/signals/SignalTable.java b/frysk-core/frysk/isa/signals/SignalTable.java index a26303f..035535d 100644 --- a/frysk-core/frysk/isa/signals/SignalTable.java +++ b/frysk-core/frysk/isa/signals/SignalTable.java @@ -85,18 +85,35 @@ public class SignalTable { private final Map names = new HashMap(); /** - * Method to make construction of the signals table easier. + * Return the Signal corresponding to the StandardSignal. */ - SignalTable add(int value, String name, String description) { + public Signal get(StandardSignal sig) { + return (Signal)standard.get(sig); + } + private final Map standard = new HashMap(); + + /** + * Add a signal based on a standard signal. + */ + SignalTable add(int value, StandardSignal standardSignal) { searchSignal.key = value; Signal signal = (Signal)signals.get(searchSignal); - if (signal != null) { - names.put(name, signal); // alias - } else { - signal = new Signal(value, name, description); - names.put(signal.getName(), signal); - signals.put(signal, signal); - } + if (signal != null) + throw new NullPointerException("duplicate signal " + value); + signal = new Signal(value, standardSignal); + names.put(signal.getName(), signal); + signals.put(signal, signal); + standard.put(standardSignal, signal); + return this; + } + /** + * Add a synonym for a standard signal. + */ + SignalTable add(String name, StandardSignal standardSignal) { + Signal signal = get(standardSignal); + if (signal == null) + throw new NullPointerException("signal synonym " + name + " not defined"); + names.put(name, signal); return this; } } diff --git a/frysk-core/frysk/isa/signals/SignalTableFactory.java b/frysk-core/frysk/isa/signals/SignalTableFactory.java index e98ddd3..c4e4fc1 100644 --- a/frysk-core/frysk/isa/signals/SignalTableFactory.java +++ b/frysk-core/frysk/isa/signals/SignalTableFactory.java @@ -48,64 +48,59 @@ import frysk.isa.ISA; public class SignalTableFactory { private static class SignalEntry { - private final String name; + private final StandardSignal signal; private final int[] value = new int[3]; - private final String description; - SignalEntry(String name, int a0, int a1, int a2, String description) { - this.name = name; + SignalEntry(int a0, int a1, int a2, StandardSignal signal) { + this.signal = signal; this.value[0] = a0; this.value[1] = a1; this.value[2] = a2; - this.description = description; } - SignalEntry(String name, int a, String description) { - this(name, a, a, a, description); + SignalEntry(int a, StandardSignal signal) { + this(a, a, a, signal); } void put(SignalTable signalTable, int index) { - if (value[index] >= 0) - signalTable.add(value[index], name, description); + if (value[index] >= 0) { + signalTable.add(value[index], signal); + } } } private static final SignalEntry[] linuxSignals = new SignalEntry[] { - new SignalEntry("SIGHUP", 1, "Hangup detected on controlling terminal or death of controlling process"), - new SignalEntry("SIGINT", 2, "Interrupt from keyboard"), - new SignalEntry("SIGQUIT", 3, "Quit from keyboard"), - new SignalEntry("SIGILL", 4, "Illegal Instruction"), - new SignalEntry("SIGABRT", 6, "Abort signal from abort(3)"), - new SignalEntry("SIGFPE", 8, "Floating point exception"), - new SignalEntry("SIGKILL", 9, "Kill signal"), - new SignalEntry("SIGSEGV", 11, "Invalid memory reference"), - new SignalEntry("SIGPIPE", 13, "Broken pipe: write to pipe with no readers"), - new SignalEntry("SIGALRM", 14, "Timer signal from alarm(2)"), - new SignalEntry("SIGTERM", 15, "Termination signal"), - new SignalEntry("SIGUSR1", 30,10,16, "User-defined signal 1"), - new SignalEntry("SIGUSR2", 31,12,17, "User-defined signal 2"), - new SignalEntry("SIGCHLD", 20,17,18, "Child stopped or terminated"), - new SignalEntry("SIGCONT", 19,18,25, "Continue if stopped"), - new SignalEntry("SIGSTOP", 17,19,23, "Stop process"), - new SignalEntry("SIGTSTP", 18,20,24, "Stop typed at tty"), - new SignalEntry("SIGTTIN", 21,21,26, "tty input for background process"), - new SignalEntry("SIGTTOU", 22,22,27, "tty output for background process"), - new SignalEntry("SIGBUS", 10,7,10, "Bus error (bad memory access)"), - new SignalEntry("SIGPOLL", 23,29,22, "IO event (Sys V). Synonym of SIGIO"), - new SignalEntry("SIGPROF", 27,27,29, "Profiling timer expired"), - new SignalEntry("SIGSYS", 12,-1,12, "Bad argument to routine (SVr4)"), - new SignalEntry("SIGTRAP", 5, "Trace/breakpoint trap"), - new SignalEntry("SIGURG", 16,23,21, "Urgent condition on socket (4.2BSD)"), - new SignalEntry("SIGVTALRM", 26,26,28, "Virtual alarm clock (4.2BSD)"), - new SignalEntry("SIGXCPU", 24,24,30, "CPU time limit exceeded (4.2BSD)"), - new SignalEntry("SIGXFSZ", 25,25,31, "File size limit exceeded (4.2BSD)"), - new SignalEntry("SIGIOT", 6, "IOT trap. A synonym for SIGABRT"), - new SignalEntry("SIGEMT", 7,-1,7, ""), - new SignalEntry("SIGSTKFLT", -1,16,-1, "Stack fault on coprocessor (unused)"), - new SignalEntry("SIGIO", 23,29,22, "I/O now possible (4.2BSD)"), - new SignalEntry("SIGCLD", -1,-1,18, "A synonym for SIGCHLD"), - new SignalEntry("SIGPWR", 29,30,19, "Power failure (System V)"), - new SignalEntry("SIGINFO", 29,-1,-1, "synonym for SIGPWR"), - new SignalEntry("SIGLOST", -1,-1,-1, "File lock lost"), - new SignalEntry("SIGWINCH", 28,28,20, "Window resize signal (4.3BSD, Sun)"), - new SignalEntry("SIGSYS", -1,31,-1, "Unused signal (will be SIGSYS)"), + new SignalEntry(1, StandardSignal.HUP), + new SignalEntry(2, StandardSignal.INT), + new SignalEntry(3, StandardSignal.QUIT), + new SignalEntry(4, StandardSignal.ILL), + new SignalEntry(6, StandardSignal.ABRT), + new SignalEntry(8, StandardSignal.FPE), + new SignalEntry(9, StandardSignal.KILL), + new SignalEntry(11, StandardSignal.SEGV), + new SignalEntry(13, StandardSignal.PIPE), + new SignalEntry(14, StandardSignal.ALRM), + new SignalEntry(15, StandardSignal.TERM), + new SignalEntry(30,10,16, StandardSignal.USR1), + new SignalEntry(31,12,17, StandardSignal.USR2), + new SignalEntry(20,17,18, StandardSignal.CHLD), + new SignalEntry(19,18,25, StandardSignal.CONT), + new SignalEntry(17,19,23, StandardSignal.STOP), + new SignalEntry(18,20,24, StandardSignal.TSTP), + new SignalEntry(21,21,26, StandardSignal.TTIN), + new SignalEntry(22,22,27, StandardSignal.TTOU), + new SignalEntry(10,7,10, StandardSignal.BUS), + new SignalEntry(27,27,29, StandardSignal.PROF), + new SignalEntry(12,-1,12, StandardSignal.SYS), + new SignalEntry(5, StandardSignal.TRAP), + new SignalEntry(16,23,21, StandardSignal.URG), + new SignalEntry(26,26,28, StandardSignal.VTALRM), + new SignalEntry(24,24,30, StandardSignal.XCPU), + new SignalEntry(25,25,31, StandardSignal.XFSZ), + new SignalEntry(7,-1,7, StandardSignal.EMT), + new SignalEntry(-1,16,-1, StandardSignal.STKFLT), + new SignalEntry(23,29,22, StandardSignal.IO), + new SignalEntry(29,30,19, StandardSignal.PWR), + new SignalEntry(-1,-1,-1, StandardSignal.LOST), + new SignalEntry(28,28,20, StandardSignal.WINCH), + new SignalEntry(-1,31,-1, StandardSignal.SYS), }; public static final SignalTable ALPHA = new SignalTable(); public static final SignalTable SPARC = ALPHA; @@ -119,6 +114,18 @@ public class SignalTableFactory { linuxSignals[i].put(IA32, 1); linuxSignals[i].put(MIPS, 2); } + ALPHA.add("SIGCLD", StandardSignal.CHLD) + .add("SIGINFO", StandardSignal.PWR) + .add("SIGPOLL", StandardSignal.IO) + .add("SIGIOT", StandardSignal.ABRT); + IA32.add("SIGCLD", StandardSignal.CHLD) + .add("SIGINFO", StandardSignal.PWR) + .add("SIGPOLL", StandardSignal.IO) + .add("SIGIOT", StandardSignal.ABRT); + MIPS.add("SIGCLD", StandardSignal.CHLD) + .add("SIGINFO", StandardSignal.PWR) + .add("SIGPOLL", StandardSignal.IO) + .add("SIGIOT", StandardSignal.ABRT); } private static final ISAMap isaSignals diff --git a/frysk-core/frysk/isa/signals/StandardSignal.java b/frysk-core/frysk/isa/signals/StandardSignal.java new file mode 100644 index 0000000..ecd1fc9 --- /dev/null +++ b/frysk-core/frysk/isa/signals/StandardSignal.java @@ -0,0 +1,133 @@ +// This file is part of the program FRYSK. +// +// Copyright 2008 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 +// the Free Software Foundation; version 2 of the License. +// +// FRYSK is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with FRYSK; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// In addition, as a special exception, Red Hat, Inc. gives You the +// additional right to link the code of FRYSK with code not covered +// under the GNU General Public License ("Non-GPL Code") and to +// distribute linked combinations including the two, subject to the +// limitations in this paragraph. Non-GPL Code permitted under this +// exception must only link to the code of FRYSK through those well +// defined interfaces identified in the file named EXCEPTION found in +// the source code files (the "Approved Interfaces"). The files of +// Non-GPL Code may instantiate templates or use macros or inline +// functions from the Approved Interfaces without causing the +// resulting work to be covered by the GNU General Public +// License. Only Red Hat, Inc. may make changes or additions to the +// list of Approved Interfaces. You must obey the GNU General Public +// License in all respects for all of the FRYSK code and other code +// used in conjunction with FRYSK except the Non-GPL Code covered by +// this exception. If you modify this file, you may extend this +// exception to your version of the file, but you are not obligated to +// do so. If you do not wish to provide this exception without +// modification, you must delete this exception statement from your +// version and license this file solely under the GPL without +// exception. + +package frysk.isa.signals; + +/** + * A standard or well known. Consult the SignalTable to get the + * corresponding ISA specific Signal value. + */ +public class StandardSignal { + private final String name; + private final String description; + private StandardSignal(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public boolean equals(Signal signal) { + return description == signal.getDescription(); + } + + public static final StandardSignal ABRT + = new StandardSignal("SIGABRT", "Abort signal from abort(3)"); + public static final StandardSignal ALRM + = new StandardSignal("SIGALRM", "Timer signal from alarm(2)"); + public static final StandardSignal BUS + = new StandardSignal("SIGBUS", "Bus error (misaligned memory access)"); + public static final StandardSignal CHLD + = new StandardSignal("SIGCHLD", "Child stopped or terminated"); + public static final StandardSignal CONT + = new StandardSignal("SIGCONT", "Continue if stopped"); + public static final StandardSignal EMT + = new StandardSignal("SIGEMT", "Emulation Trap"); + public static final StandardSignal FPE + = new StandardSignal("SIGFPE", "Floating point exception"); + public static final StandardSignal HUP + = new StandardSignal("SIGHUP", "Hangup detected on controlling terminal or death of controlling process"); + public static final StandardSignal ILL + = new StandardSignal("SIGILL", "Illegal Instruction"); + public static final StandardSignal INT + = new StandardSignal("SIGINT", "Interrupt from keyboard"); + public static final StandardSignal IO + = new StandardSignal("SIGIO", "I/O now possible"); + public static final StandardSignal KILL + = new StandardSignal("SIGKILL", "Kill signal"); + public static final StandardSignal LOST + = new StandardSignal("SIGLOST", "File lock lost"); + public static final StandardSignal PIPE + = new StandardSignal("SIGPIPE", "Broken pipe"); + public static final StandardSignal PROF + = new StandardSignal("SIGPROF", "Profiling timer expired"); + public static final StandardSignal PWR + = new StandardSignal("SIGPWR", "Power failure"); + public static final StandardSignal QUIT + = new StandardSignal("SIGQUIT", "Quit from keyboard"); + public static final StandardSignal SEGV + = new StandardSignal("SIGSEGV", "Segmentation fault (invalid memory location)"); + public static final StandardSignal STKFLT + = new StandardSignal("SIGSTKFLT", "Stack fault on coprocessor"); + public static final StandardSignal STOP + = new StandardSignal("SIGSTOP", "Stop process"); + public static final StandardSignal SYS + = new StandardSignal("SIGSYS", "Bad argument to routine"); + public static final StandardSignal TERM + = new StandardSignal("SIGTERM", "Termination signal"); + public static final StandardSignal TRAP + = new StandardSignal("SIGTRAP", "Trace/breakpoint trap"); + public static final StandardSignal TSTP + = new StandardSignal("SIGTSTP", "Stop typed at TTY"); + public static final StandardSignal TTIN + = new StandardSignal("SIGTTIN", "TTY input for background process"); + public static final StandardSignal TTOU + = new StandardSignal("SIGTTOU", "TTY output for background process"); + public static final StandardSignal URG + = new StandardSignal("SIGURG", "Urgent condition on socket"); + public static final StandardSignal USR1 + = new StandardSignal("SIGUSR1", "User-defined signal 1"); + public static final StandardSignal USR2 + = new StandardSignal("SIGUSR2", "User-defined signal 2"); + public static final StandardSignal VTALRM + = new StandardSignal("SIGVTALRM", "Virtual alarm clock"); + public static final StandardSignal WINCH + = new StandardSignal("SIGWINCH", "Window size changed"); + public static final StandardSignal XCPU + = new StandardSignal("SIGXCPU", "CPU time limit exceeded"); + public static final StandardSignal XFSZ + = new StandardSignal("SIGXFSZ", "File size limit exceeded"); + +} diff --git a/frysk-core/frysk/isa/signals/TestSignalTable.java b/frysk-core/frysk/isa/signals/TestSignalTable.java index 03d6bf4..307d99e 100644 --- a/frysk-core/frysk/isa/signals/TestSignalTable.java +++ b/frysk-core/frysk/isa/signals/TestSignalTable.java @@ -63,4 +63,12 @@ public class TestSignalTable extends TestLib { targetSignal.toString()); } } + public void testStandardSignals() { + SignalTable signalTable + = SignalTableFactory.getSignalTable(IsaTestbed.getISA()); + Signal kill = signalTable.get(StandardSignal.KILL); + assertNotNull("kill", kill); + assertEquals("name", "SIGKILL", kill.getName()); + assertEquals("value", 9, kill.intValue()); + } } diff --git a/frysk-sys/frysk/sys/ChangeLog b/frysk-sys/frysk/sys/ChangeLog index eec082d..a29bfbc 100644 --- a/frysk-sys/frysk/sys/ChangeLog +++ b/frysk-sys/frysk/sys/ChangeLog @@ -1,5 +1,10 @@ 2008-01-25 Andrew Cagney <cagney@redhat.com> + * Signal.java-sh: Add the synonyms - POLL, IOT, INFO and CLD - + last. + + * Signal.java-sh (toHostStringFIXME(int)): Delete. + * Signal.java-sh (equals(int)): Delete. * Signal.java-sh (compareTo(Object)): Fix ordering. diff --git a/frysk-sys/frysk/sys/Signal.java-sh b/frysk-sys/frysk/sys/Signal.java-sh index c745b91..f459675 100644 --- a/frysk-sys/frysk/sys/Signal.java-sh +++ b/frysk-sys/frysk/sys/Signal.java-sh @@ -143,17 +143,6 @@ public class Signal implements Comparable { } /** - * Return the <b>host</b> signal as a string. - * - * For frysk what you instead want is a conversion from the - * integer to the <b>target</b>'s string representation. - * See the numbering described in signal(7) for the problems. - */ - public static String toHostStringFIXME(int signal) { - return valueOf(signal).toString(); - } - - /** * Given an integer, return the corresponding <b>host</b> signal. * If the signal is unknown, make one up. * @@ -222,10 +211,14 @@ public class Signal implements Comparable { public static final Signal NONE = signalFactory(0, "SIGNONE"); EOF +# The synonyms are added last so that the real signals take priority. + for sig in \ - hup int_ quit ill abrt fpe kill segv pipe alrm term usr1 usr2 chld cont stop tstp ttin ttou \ - bus poll prof sys trap urg vtalrm xcpu xfsz \ - iot emt stkflt io cld pwr info lost winch unused + hup int_ quit ill abrt fpe kill segv pipe alrm term usr1 usr2 chld cont stop tstp ttin ttou \ + bus prof sys trap urg vtalrm xcpu xfsz \ + emt stkflt io pwr lost winch unused \ + \ + poll iot info cld do SIG=`echo "${sig}" | tr '[a-z]' '[A-Z]' | sed 's/_$//'` echo " private static native int ${sig}();" hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-01-25 21:21 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=20080125212046.14948.qmail@sourceware.org \ --to=cagney@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).