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.proc.Signal. Date: Wed, 23 Jan 2008 23:35:00 -0000 [thread overview] Message-ID: <20080123233538.1031.qmail@sourceware.org> (raw) The branch, master has been updated via 8b0f64ec1067a878c3b33b3d912aa8d6280cf200 (commit) from 676f01bb93ede4110acaab1912da55e382d33120 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 8b0f64ec1067a878c3b33b3d912aa8d6280cf200 Author: Andrew Cagney <cagney@toil.yyz.redhat.com> Date: Wed Jan 23 18:35:06 2008 -0500 Add frysk.proc.Signal. frysk-core/frysk/proc/ChangeLog 2008-01-23 Andrew Cagney <cagney@redhat.com> * TestSignalTable.java: New. * Task.java (getSignalTable()): New. (signalTable()): New. * LinuxSignals.java: New file. * SignalTable.java: New file. * Signal.java: New file. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/ChangeLog | 9 ++ frysk-core/frysk/proc/LinuxSignals.java | 134 ++++++++++++++++++++ .../frysk/{isa/Register.java => proc/Signal.java} | 51 +++++--- .../proc/{Observation.java => SignalTable.java} | 93 +++++++------- frysk-core/frysk/proc/Task.java | 14 ++ .../TestSignalTable.java} | 44 ++++---- 6 files changed, 260 insertions(+), 85 deletions(-) create mode 100644 frysk-core/frysk/proc/LinuxSignals.java copy frysk-core/frysk/{isa/Register.java => proc/Signal.java} (71%) copy frysk-core/frysk/proc/{Observation.java => SignalTable.java} (59%) copy frysk-core/frysk/{dwfl/TestElfSectionCache.java => proc/TestSignalTable.java} (72%) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index 2eca8d0..0697561 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,3 +1,12 @@ +2008-01-23 Andrew Cagney <cagney@redhat.com> + + * TestSignalTable.java: New. + * Task.java (getSignalTable()): New. + (signalTable()): New. + * LinuxSignals.java: New file. + * SignalTable.java: New file. + * Signal.java: New file. + 2008-01-18 Andrew Cagney <cagney@redhat.com> * Task.java (toString()): Print the state. diff --git a/frysk-core/frysk/proc/LinuxSignals.java b/frysk-core/frysk/proc/LinuxSignals.java new file mode 100644 index 0000000..4f1cb42 --- /dev/null +++ b/frysk-core/frysk/proc/LinuxSignals.java @@ -0,0 +1,134 @@ +// 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.proc; + +import frysk.isa.ISAMap; +import frysk.isa.ISA; + +/** + * Table of signals for for each known ISA. + */ + +class LinuxSignals { + private static class SignalEntry { + private final String name; + 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; + 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); + } + void put(SignalTable signalTable, int index) { + if (value[index] >= 0) + signalTable.add(value[index], name, description); + } + } + 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)"), + }; + public static final SignalTable ALPHA = new SignalTable(); + public static final SignalTable SPARC = ALPHA; + public static final SignalTable IA32 = new SignalTable(); + public static final SignalTable PPC = IA32; + public static final SignalTable SH = IA32; + public static final SignalTable MIPS = new SignalTable(); + static { + for (int i = 0; i < linuxSignals.length; i++) { + linuxSignals[i].put(ALPHA, 0); + linuxSignals[i].put(IA32, 1); + linuxSignals[i].put(MIPS, 2); + } + } + + private static final ISAMap isaSignals + = new ISAMap("signals") + .put(ISA.IA32, IA32) + .put(ISA.X8664, IA32) + .put(ISA.PPC32BE, IA32) + .put(ISA.PPC64BE, IA32); + + static SignalTable getSignalTable(ISA isa) { + return (SignalTable) isaSignals.get(isa); + } +} diff --git a/frysk-core/frysk/isa/Register.java b/frysk-core/frysk/proc/Signal.java similarity index 71% copy from frysk-core/frysk/isa/Register.java copy to frysk-core/frysk/proc/Signal.java index 27a1bd4..7989cab 100644 --- a/frysk-core/frysk/isa/Register.java +++ b/frysk-core/frysk/proc/Signal.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// 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 @@ -37,28 +37,47 @@ // version and license this file solely under the GPL without // exception. -package frysk.isa; +package frysk.proc; -import frysk.value.Type; - -public class Register { - - public Register(String name, Type type) { +/** + * A target signal. + */ +public class Signal implements Comparable { + private final int value; + private final String name; + private final String description; + Signal(int value, String name, String description) { + this.value = value; this.name = name; - this.type = type; + this.description = description; + } + Signal(int value) { + this(value, "SIG" + value, "Unknown signal " + value); + } + /** + * Return the signal as a string of the form NAME(VALUE). + */ + public String toString() { + return name + "(" + value + ")"; } - - private final String name; public String getName() { return name; } - - private final Type type; - public Type getType() { - return type; + public String getDescription() { + return description; + } + public int intValue() { + return value; } - public String toString() { - return "[Register: " + name + " type: " + type + "]"; + public int hashCode() { + return intValue(); + } + public boolean equals(Object o) { + return ((o instanceof Signal) + && (((Signal)o).intValue() == this.intValue())); + } + public int compareTo(Object o) { + return ((Signal)o).intValue() - this.intValue(); } } diff --git a/frysk-core/frysk/proc/Observation.java b/frysk-core/frysk/proc/SignalTable.java similarity index 59% copy from frysk-core/frysk/proc/Observation.java copy to frysk-core/frysk/proc/SignalTable.java index 4ce1a12..8c4dac9 100644 --- a/frysk-core/frysk/proc/Observation.java +++ b/frysk-core/frysk/proc/SignalTable.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, 2006, 2007, Red Hat Inc. +// 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 @@ -39,65 +39,64 @@ package frysk.proc; -import frysk.event.Event; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.HashMap; /** - * The binding between an Observer and its Observable. + * A target signal factory. */ -public abstract class Observation - implements Event -{ - protected final Observable observable; - protected final Observer observer; +public class SignalTable { /** - * Create a new Observer binding. + * Return the Signal corresponding to value. Always returns + * something, even when it has to be made up. */ - protected Observation (Observable observable, Observer observer) - { - this.observable = observable; - this.observer = observer; - } - /** - * Returns true if the Object's Observable:Observer binding is - * identical to this one. - */ - public boolean equals (Object o) - { - if (o instanceof Observation) { - Observation rhs = (Observation) o; - return (this.observable == rhs.observable - && this.observer == rhs.observer); + public Signal get(int sig) { + synchronized (searchSignal) { + searchSignal.key = sig; + Signal signal = (Signal)signals.get(searchSignal); + if (signal == null) { + signal = new Signal(sig); + signals.put(signal, signal); + } + return signal; } - else - return false; } - /** - * A somewhat arbitrary hash code. - */ - public int hashCode () - { - return (observable.hashCode () + observer.hashCode ()); + private final Map signals = new WeakHashMap(); + private static class SearchSignal extends Signal { + SearchSignal() { + super(-1); + } + int key; + public int intValue() { + return key; + } } + private final SearchSignal searchSignal = new SearchSignal(); + /** - * Tell the observer that the add is failing with w. + * Return the Signal corresponding to name; can return NULL if the + * name is unknown. */ - public void fail (Throwable w) - { - observable.fail (observer, w); + public Signal get(String sig) { + return (Signal)names.get(sig); } + private final Map names = new HashMap(); + /** - * Handle the addition of the Observer to the Observable. - */ - public abstract void handleAdd (); - /** - * Handle the deletion of the Observer from the Observable. + * Method to make construction of the signals table easier. */ - public abstract void handleDelete (); - - public String toString() - { - return ("Observation[observable:" + observable - + "observer:" + observer + "]"); + SignalTable add(int value, String name, String description) { + 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); + } + return this; } } diff --git a/frysk-core/frysk/proc/Task.java b/frysk-core/frysk/proc/Task.java index 4fe05ad..bb478d4 100644 --- a/frysk-core/frysk/proc/Task.java +++ b/frysk-core/frysk/proc/Task.java @@ -337,5 +337,19 @@ public abstract class Task { public void clearIsa() { syscallTable = null; + signalTable = null; } + + + /** + * Return a table of known (and unknown) signals for this ISA. + */ + public SignalTable getSignalTable() { + if (signalTable == null) { + signalTable = LinuxSignals.getSignalTable(getISA()); + } + return signalTable; + } + private SignalTable signalTable; + } diff --git a/frysk-core/frysk/dwfl/TestElfSectionCache.java b/frysk-core/frysk/proc/TestSignalTable.java similarity index 72% copy from frysk-core/frysk/dwfl/TestElfSectionCache.java copy to frysk-core/frysk/proc/TestSignalTable.java index e0b7355..afe26e4 100644 --- a/frysk-core/frysk/dwfl/TestElfSectionCache.java +++ b/frysk-core/frysk/proc/TestSignalTable.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2008, Red Hat Inc. +// 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 @@ -37,30 +37,30 @@ // version and license this file solely under the GPL without // exception. -package frysk.dwfl; +package frysk.proc; -import lib.dwfl.ElfSectionHeader; -import frysk.Config; -import frysk.proc.Task; import frysk.testbed.DaemonBlockedAtEntry; import frysk.testbed.TestLib; -public class TestElfSectionCache extends TestLib { - - public void testGetSectionHeader() { - - DaemonBlockedAtEntry dbae = new DaemonBlockedAtEntry(Config.getPkgLibFile("funit-libcall")); - Task task = dbae.getMainTask(); - - long addr = task.getPC(); - ElfSectionCache e = new ElfSectionCache(task); - - ElfSectionHeader plt = e.getSectionHeader(".plt", addr); - - assertTrue("Section not null", (plt != null)); - assertTrue("Section name not null", (plt.name != null)); - assertTrue("Section addr not zero", (plt.addr != 0)); - assertTrue("Section offset not zero", (plt.offset != 0)); - } +/** + * A target signal factory. + */ +public class TestSignalTable extends TestLib { + public void testSignalTable() { + DaemonBlockedAtEntry daemon = new DaemonBlockedAtEntry("funit-slave"); + frysk.sys.Signal[] hostSignals + = frysk.sys.Signal.getHostSignalSet().toArray(); + SignalTable signalTable = LinuxSignals.getSignalTable(daemon.getMainTask().getISA()); + for (int i = 0; i < hostSignals.length; i++) { + frysk.sys.Signal hostSignal = hostSignals[i]; + if (hostSignal.toString().startsWith("SIGRT")) + // Real-time signals are really messed up. + break; + Signal targetSignal = signalTable.get(hostSignal.intValue()); + assertEquals("signal " + hostSignal.intValue(), + hostSignal.toString(), + targetSignal.toString()); + } + } } hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-01-23 23:35 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=20080123233538.1031.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).