aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@iki.fi>2009-04-07 09:57:11 +0300
committerRiku Voipio <riku.voipio@nokia.com>2009-06-16 16:56:28 +0300
commitedf8e2af1453ce56c72b2f25a745e3734177a05d (patch)
tree367df4d32d3d75137076cd38738199d4d5b27901 /linux-user/main.c
parent88a8c98455cc28ef27f92fd0c6845cedf86d21fc (diff)
linux-user: implemented ELF coredump support for ARM target
When target process is killed with signal (such signal that should dump core) a coredump file is created. This file is similar than coredump generated by Linux (there are few exceptions though). Riku Voipio: added support for rlimit Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 4832d3f860..7eabd0c22f 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <sys/syscall.h>
#include "qemu.h"
#include "qemu-common.h"
@@ -2319,6 +2320,27 @@ static void usage(void)
THREAD CPUState *thread_env;
+void task_settid(TaskState *ts)
+{
+ if (ts->ts_tid == 0) {
+#ifdef USE_NPTL
+ ts->ts_tid = (pid_t)syscall(SYS_gettid);
+#else
+ /* when no threads are used, tid becomes pid */
+ ts->ts_tid = getpid();
+#endif
+ }
+}
+
+void stop_all_tasks(void)
+{
+ /*
+ * We trust that when using NPTL, start_exclusive()
+ * handles thread stopping correctly.
+ */
+ start_exclusive();
+}
+
/* Assumes contents are already zeroed. */
void init_task_state(TaskState *ts)
{
@@ -2338,6 +2360,7 @@ int main(int argc, char **argv, char **envp)
const char *cpu_model;
struct target_pt_regs regs1, *regs = &regs1;
struct image_info info1, *info = &info1;
+ struct linux_binprm bprm;
TaskState ts1, *ts = &ts1;
CPUState *env;
int optind;
@@ -2467,6 +2490,8 @@ int main(int argc, char **argv, char **envp)
/* Zero out image_info */
memset(info, 0, sizeof(struct image_info));
+ memset(&bprm, 0, sizeof (bprm));
+
/* Scan interp_prefix dir for replacement files. */
init_paths(interp_prefix);
@@ -2543,7 +2568,16 @@ int main(int argc, char **argv, char **envp)
}
target_argv[target_argc] = NULL;
- if (loader_exec(filename, target_argv, target_environ, regs, info) != 0) {
+ memset(ts, 0, sizeof(TaskState));
+ init_task_state(ts);
+ /* build Task State */
+ ts->info = info;
+ ts->bprm = &bprm;
+ env->opaque = ts;
+ task_settid(ts);
+
+ if (loader_exec(filename, target_argv, target_environ, regs,
+ info, &bprm) != 0) {
printf("Error loading %s\n", filename);
_exit(1);
}
@@ -2579,12 +2613,6 @@ int main(int argc, char **argv, char **envp)
syscall_init();
signal_init();
- /* build Task State */
- memset(ts, 0, sizeof(TaskState));
- init_task_state(ts);
- ts->info = info;
- env->opaque = ts;
-
#if defined(TARGET_I386)
cpu_x86_set_cpl(env, 3);