aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-20 23:06:10 -0400
committerMike Frysinger <vapier@gentoo.org>2021-06-23 20:05:14 -0400
commitd394a6efed4723b86f8e4f09fc23f6d03a7ad835 (patch)
tree6fd21636c50bf4f62d608cfb975da8707158d360 /sim
parent02ddf7223daa1dac8ba532dfd31d5d4d1870e6f4 (diff)
downloadgdb-d394a6efed4723b86f8e4f09fc23f6d03a7ad835.zip
gdb-d394a6efed4723b86f8e4f09fc23f6d03a7ad835.tar.gz
gdb-d394a6efed4723b86f8e4f09fc23f6d03a7ad835.tar.bz2
sim: callback: add a kill interface
This will make it easier to emulate the syscall. If the kill target is the sim itself, don't do anything. This forces the higher layers to make a decision as to how to handle this event: like halting the overall engine process.
Diffstat (limited to 'sim')
-rw-r--r--sim/common/ChangeLog6
-rw-r--r--sim/common/callback.c11
-rw-r--r--sim/common/syscall.c18
3 files changed, 35 insertions, 0 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index bb1a967..c32e747 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,11 @@
2021-06-23 Mike Frysinger <vapier@gentoo.org>
+ * callback.c (os_kill): New function.
+ (default_callback): Add os_kill.
+ * syscall.c (cb_syscall): Handle CB_SYS_kill.
+
+2021-06-23 Mike Frysinger <vapier@gentoo.org>
+
* Make-common.in (srcdir): Change to abs_srcdir.
2021-06-22 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/common/callback.c b/sim/common/callback.c
index 06d76b4..c0ace6e 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -570,6 +570,16 @@ os_getpid (host_callback *p)
}
static int
+os_kill (host_callback *p, int pid, int signum)
+{
+ int result;
+
+ result = kill (pid, signum);
+ p->last_errno = errno;
+ return result;
+}
+
+static int
os_pipe (host_callback *p, int *filedes)
{
int i;
@@ -752,6 +762,7 @@ host_callback default_callback =
os_truncate,
os_getpid,
+ os_kill,
os_pipe,
os_pipe_empty,
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index 7ef34b9..6efddcf 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -583,6 +583,24 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc)
result = (*cb->getpid) (cb);
break;
+ case CB_SYS_kill:
+ /* If killing self, leave it to the caller to process so it can send the
+ signal to the engine. */
+ if (sc->arg1 == (*cb->getpid) (cb))
+ {
+ result = -1;
+ errcode = ENOSYS;
+ }
+ else
+ {
+ int signum = cb_target_to_host_signal (cb, sc->arg2);
+
+ result = (*cb->kill) (cb, sc->arg1, signum);
+ cb->last_errno = errno;
+ goto ErrorFinish;
+ }
+ break;
+
case CB_SYS_time :
{
/* FIXME: May wish to change CB_SYS_time to something else.