summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Lerner2012-03-13 21:40:22 (EDT)
committerEugene Tarassov2012-03-26 13:23:53 (EDT)
commitc6474fc26b1888e2197e4bbda8927a1442420cd7 (patch)
tree27e1d3fa95ffb8d0906082014fecc9e753246dae
parente03ef06ec0630c26fec412b27df0e1b491d4addb (diff)
downloadorg.eclipse.tcf.agent-c6474fc26b1888e2197e4bbda8927a1442420cd7.zip
org.eclipse.tcf.agent-c6474fc26b1888e2197e4bbda8927a1442420cd7.tar.gz
org.eclipse.tcf.agent-c6474fc26b1888e2197e4bbda8927a1442420cd7.tar.bz2
linux: Generalize for additional processor architectures
This commit makes 2 changes that enables adding support for new processor types: 1) the next value of the PC to use to continue after trap breakpoint must be adjusted differently depending on the processor architecture. It is not always the (pc-break_size) value where pc is from retrieved registers on all architectures. The code was changed to adjust the pc by a per-architecture defined value 'TRAP_OFFSET' 2) retrieving registers after receiving PTRACE_EVENT_EXIT is not allowed on some architectures and should not be tried on any architecture. Signed-off-by: Dave Lerner <dave.lerner@windriver.com> Signed-off-by: Eugene Tarassov<eugene.tarassov@windriver.com>
-rw-r--r--agent/machine/i386/tcf/regset-mdep.h17
-rw-r--r--agent/machine/i686/tcf/regset-mdep.h17
-rw-r--r--agent/machine/x86_64/tcf/regset-mdep.h17
-rw-r--r--agent/system/GNU/Linux/tcf/context-linux.c20
-rw-r--r--agent/system/GNU/Linux/tcf/regset.h5
5 files changed, 70 insertions, 6 deletions
diff --git a/agent/machine/i386/tcf/regset-mdep.h b/agent/machine/i386/tcf/regset-mdep.h
new file mode 100644
index 0000000..b790e49
--- /dev/null
+++ b/agent/machine/i386/tcf/regset-mdep.h
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/* offset to be applied to the PC after a software trap */
+#define TRAP_OFFSET -1
diff --git a/agent/machine/i686/tcf/regset-mdep.h b/agent/machine/i686/tcf/regset-mdep.h
new file mode 100644
index 0000000..b790e49
--- /dev/null
+++ b/agent/machine/i686/tcf/regset-mdep.h
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/* offset to be applied to the PC after a software trap */
+#define TRAP_OFFSET -1
diff --git a/agent/machine/x86_64/tcf/regset-mdep.h b/agent/machine/x86_64/tcf/regset-mdep.h
new file mode 100644
index 0000000..b790e49
--- /dev/null
+++ b/agent/machine/x86_64/tcf/regset-mdep.h
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/* offset to be applied to the PC after a software trap */
+#define TRAP_OFFSET -1
diff --git a/agent/system/GNU/Linux/tcf/context-linux.c b/agent/system/GNU/Linux/tcf/context-linux.c
index e9da67d..2101ad0 100644
--- a/agent/system/GNU/Linux/tcf/context-linux.c
+++ b/agent/system/GNU/Linux/tcf/context-linux.c
@@ -50,6 +50,17 @@
#include <tcf/services/tcf_elf.h>
#include <system/GNU/Linux/tcf/regset.h>
+#if !defined(TRAP_OFFSET)
+#define TRAP_OFFSET -1
+#endif
+
+#if !defined(PTRACE_GETFPXREGS) && !defined(PT_GETFPXREGS)
+#define PTRACE_GETFPXREGS 18
+#endif
+#if !defined(PTRACE_SETFPXREGS) && !defined(PT_SETFPXREGS)
+#define PTRACE_SETFPXREGS 19
+#endif
+
#if !defined(PTRACE_SETOPTIONS)
#define PTRACE_SETOPTIONS 0x4200
#define PTRACE_GETEVENTMSG 0x4201
@@ -1214,6 +1225,11 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
pc0 = get_regs_PC(ctx);
}
+#if defined(__powerpc__) || defined(__powerpc64__)
+ /* Don't retrieve registers from an exiting process,
+ causes kernel critical messages */
+ if (event != PTRACE_EVENT_EXIT)
+#endif
memset(ext->regs_valid, 0, sizeof(REG_SET));
pc1 = get_regs_PC(ctx);
@@ -1262,9 +1278,9 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
if (signal == SIGTRAP && event == 0 && !syscall) {
size_t break_size = 0;
get_break_instruction(ctx, &break_size);
- ctx->stopped_by_bp = !ext->regs_error && is_breakpoint_address(ctx, pc1 - break_size);
+ ctx->stopped_by_bp = !ext->regs_error && is_breakpoint_address(ctx, pc1 + TRAP_OFFSET);
ext->end_of_step = !ctx->stopped_by_cb && !ctx->stopped_by_bp && ext->pending_step;
- if (ctx->stopped_by_bp) set_regs_PC(ctx, pc1 - break_size);
+ if (ctx->stopped_by_bp) set_regs_PC(ctx, pc1 + TRAP_OFFSET);
}
ext->pending_step = 0;
send_context_stopped_event(ctx);
diff --git a/agent/system/GNU/Linux/tcf/regset.h b/agent/system/GNU/Linux/tcf/regset.h
index ee883d7..0c14c04 100644
--- a/agent/system/GNU/Linux/tcf/regset.h
+++ b/agent/system/GNU/Linux/tcf/regset.h
@@ -20,9 +20,7 @@
#if defined(__linux__)
# include <sys/user.h>
-#if !defined(__i386__) && !defined(__x86_64__)
-# include <tcf/regdefs-mdep.h>
-#else
+# include <tcf/regset-mdep.h>
typedef struct REG_SET {
struct user user;
struct user_fpregs_struct fp;
@@ -33,4 +31,3 @@ typedef struct REG_SET {
#endif
} REG_SET;
#endif
-#endif