Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2017-01-09 16:33:02 -0500
committerEugene Tarassov2017-01-09 16:33:02 -0500
commit74bbaf553d1f05dfc790f6fc8c810555ca06392f (patch)
treec5c6e3c0c2702bcb67b0dcb12e9d55b9ffc8c39f
parentb27e8148d29b3edd1a7f72de1fe75ae97ed6a0f1 (diff)
downloadorg.eclipse.tcf.agent-74bbaf553d1f05dfc790f6fc8c810555ca06392f.tar.gz
org.eclipse.tcf.agent-74bbaf553d1f05dfc790f6fc8c810555ca06392f.tar.xz
org.eclipse.tcf.agent-74bbaf553d1f05dfc790f6fc8c810555ca06392f.zip
TCF Agent: removed unneeded/unwanted definitions of TRAP_OFFSET
-rw-r--r--agent/machine/i386/tcf/regset-mdep.h5
-rw-r--r--agent/machine/i686/tcf/regset-mdep.h5
-rw-r--r--agent/machine/powerpc/tcf/regset-mdep.h5
-rw-r--r--agent/machine/x86_64/tcf/regset-mdep.h5
-rw-r--r--agent/system/Darwin/tcf/context-darwin.c22
-rw-r--r--agent/system/FreeBSD/tcf/context-freebsd.c22
-rw-r--r--agent/system/GNU/Linux/tcf/context-linux.c25
7 files changed, 43 insertions, 46 deletions
diff --git a/agent/machine/i386/tcf/regset-mdep.h b/agent/machine/i386/tcf/regset-mdep.h
index a602ea16..78fecda0 100644
--- a/agent/machine/i386/tcf/regset-mdep.h
+++ b/agent/machine/i386/tcf/regset-mdep.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2017 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.
@@ -13,8 +13,5 @@
* Wind River Systems - initial API and implementation
*******************************************************************************/
-/* offset to be applied to the PC after a software trap */
-#define TRAP_OFFSET -1
-
/* additional CPU registers */
#define MDEP_OtherRegisters struct user_fpxregs_struct
diff --git a/agent/machine/i686/tcf/regset-mdep.h b/agent/machine/i686/tcf/regset-mdep.h
index a602ea16..78fecda0 100644
--- a/agent/machine/i686/tcf/regset-mdep.h
+++ b/agent/machine/i686/tcf/regset-mdep.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2017 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.
@@ -13,8 +13,5 @@
* Wind River Systems - initial API and implementation
*******************************************************************************/
-/* offset to be applied to the PC after a software trap */
-#define TRAP_OFFSET -1
-
/* additional CPU registers */
#define MDEP_OtherRegisters struct user_fpxregs_struct
diff --git a/agent/machine/powerpc/tcf/regset-mdep.h b/agent/machine/powerpc/tcf/regset-mdep.h
index db9d365a..ed43cfab 100644
--- a/agent/machine/powerpc/tcf/regset-mdep.h
+++ b/agent/machine/powerpc/tcf/regset-mdep.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Stanislav Yakovlev.
+ * Copyright (c) 2013, 2017 Stanislav Yakovlev 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.
@@ -12,6 +12,3 @@
* Contributors:
* Stanislav Yakovlev - initial API and implementation
*******************************************************************************/
-
-/* offset to be applied to the PC after a software trap */
-#define TRAP_OFFSET 4
diff --git a/agent/machine/x86_64/tcf/regset-mdep.h b/agent/machine/x86_64/tcf/regset-mdep.h
index 249c6585..2cf760d4 100644
--- a/agent/machine/x86_64/tcf/regset-mdep.h
+++ b/agent/machine/x86_64/tcf/regset-mdep.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2017 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.
@@ -13,9 +13,6 @@
* Wind River Systems - initial API and implementation
*******************************************************************************/
-/* offset to be applied to the PC after a software trap */
-#define TRAP_OFFSET -1
-
#if defined(__i386__)
/* Building 32-bit agent on a 64-bit machine */
/* additional CPU registers */
diff --git a/agent/system/Darwin/tcf/context-darwin.c b/agent/system/Darwin/tcf/context-darwin.c
index a91b59cf..8f8ac9e7 100644
--- a/agent/system/Darwin/tcf/context-darwin.c
+++ b/agent/system/Darwin/tcf/context-darwin.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2017 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.
@@ -623,23 +623,18 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
ctx->stopped_by_exception = stopped_by_exception;
ctx->stopped = 1;
+ get_PC(ctx, &pc0);
if (EXT(ctx)->regs_error) {
release_error_report(EXT(ctx)->regs_error);
EXT(ctx)->regs_error = NULL;
}
- else {
- pc0 = get_regs_PC(ctx);
- }
-
if (thread_get_state(EXT(ctx)->pid, x86_THREAD_STATE32, EXT(ctx)->regs, &state_count) != KERN_SUCCESS) {
assert(errno != 0);
EXT(ctx)->regs_error = get_error_report(errno);
trace(LOG_ALWAYS, "error: thread_get_state failed; id %s, error %d %s",
ctx->id, errno, errno_to_str(errno));
}
- else {
- pc1 = get_regs_PC(ctx);
- }
+ get_PC(ctx, &pc1);
if (!EXT(ctx)->syscall_enter || EXT(ctx)->regs_error || pc0 != pc1) {
EXT(ctx)->syscall_enter = 0;
@@ -650,11 +645,18 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
trace(LOG_EVENTS, "event: pid %d stopped at PC = %#lx", pid, pc1);
if (signal == SIGTRAP && event == 0 && !syscall) {
+#ifdef TRAP_OFFSET
+ offs = -(TRAP_OFFSET);
+#else
size_t break_size = 0;
get_break_instruction(ctx, &break_size);
- ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - break_size);
+ offs = break_size;
+#endif
+ ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - offs);
+ if (offs != 0 && ctx->stopped_by_bp && set_PC(ctx, pc1 - offs) < 0) {
+ trace(LOG_ALWAYS, "Cannot adjust PC after breakpoint: %s", errno_to_str(errno));
+ }
EXT(ctx)->end_of_step = !ctx->stopped_by_bp && EXT(ctx)->pending_step;
- if (ctx->stopped_by_bp) set_regs_PC(ctx, pc1 - break_size);
}
EXT(ctx)->pending_step = 0;
send_context_stopped_event(ctx);
diff --git a/agent/system/FreeBSD/tcf/context-freebsd.c b/agent/system/FreeBSD/tcf/context-freebsd.c
index ad20560d..f0858f28 100644
--- a/agent/system/FreeBSD/tcf/context-freebsd.c
+++ b/agent/system/FreeBSD/tcf/context-freebsd.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2017 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.
@@ -613,14 +613,11 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
ctx->stopped_by_exception = stopped_by_exception;
ctx->stopped = 1;
+ get_PC(ctx, &pc0);
if (EXT(ctx)->regs_error) {
release_error_report(EXT(ctx)->regs_error);
EXT(ctx)->regs_error = NULL;
}
- else {
- pc0 = get_regs_PC(ctx);
- }
-
if (ptrace(PTRACE_GETREGS, EXT(ctx)->pid, 0, (int)EXT(ctx)->regs) < 0) {
assert(errno != 0);
if (errno == ESRCH) {
@@ -639,18 +636,23 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
trace(LOG_ALWAYS, "error: ptrace(PTRACE_GETREGS) failed; id %s, error %d %s",
ctx->id, errno, errno_to_str(errno));
}
- else {
- pc1 = get_regs_PC(ctx);
- }
+ get_PC(ctx, &pc1);
trace(LOG_EVENTS, "event: pid %d stopped at PC = %#lx", pid, pc1);
if (signal == SIGTRAP && event == 0 && !syscall) {
+#ifdef TRAP_OFFSET
+ offs = -(TRAP_OFFSET);
+#else
size_t break_size = 0;
get_break_instruction(ctx, &break_size);
- ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - break_size);
+ offs = break_size;
+#endif
+ ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - offs);
+ if (offs != 0 && ctx->stopped_by_bp && set_PC(ctx, pc1 - offs) < 0) {
+ trace(LOG_ALWAYS, "Cannot adjust PC after breakpoint: %s", errno_to_str(errno));
+ }
EXT(ctx)->end_of_step = !ctx->stopped_by_bp && EXT(ctx)->pending_step;
- if (ctx->stopped_by_bp) set_regs_PC(ctx, pc1 - break_size);
}
EXT(ctx)->pending_step = 0;
send_context_stopped_event(ctx);
diff --git a/agent/system/GNU/Linux/tcf/context-linux.c b/agent/system/GNU/Linux/tcf/context-linux.c
index 9fa76cca..786461fe 100644
--- a/agent/system/GNU/Linux/tcf/context-linux.c
+++ b/agent/system/GNU/Linux/tcf/context-linux.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2017 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.
@@ -59,10 +59,6 @@
#include <tcf/framework/context-mux.h>
#endif
-#if !defined(TRAP_OFFSET)
-#define TRAP_OFFSET -1
-#endif
-
#if !defined(PTRACE_SETOPTIONS)
#define PTRACE_SETOPTIONS (enum __ptrace_request)0x4200
#define PTRACE_GETEVENTMSG (enum __ptrace_request)0x4201
@@ -1565,7 +1561,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
ctx->stopped_by_exception = stopped_by_exception;
ctx->stopped = 1;
- pc0 = get_regs_PC(ctx);
+ get_PC(ctx, &pc0);
#if defined(__powerpc__) || defined(__powerpc64__)
/* Don't retrieve registers from an exiting process,
@@ -1573,7 +1569,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
if (event != PTRACE_EVENT_EXIT)
#endif
memset(ext->regs_valid, 0, sizeof(REG_SET));
- pc1 = get_regs_PC(ctx);
+ get_PC(ctx, &pc1);
if (syscall) {
if (!ext->syscall_enter) {
@@ -1620,9 +1616,18 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
cpu_bp_on_suspend(ctx, &cb_found);
if (signal == SIGTRAP && event == 0 && !syscall) {
- ctx->stopped_by_bp = is_breakpoint_address(ctx, pc1 + TRAP_OFFSET);
- if (ctx->stopped_by_bp) set_regs_PC(ctx, pc1 + TRAP_OFFSET);
- else ctx->stopped_by_bp = is_breakpoint_address(ctx, pc1);
+ int offs = 0;
+#ifdef TRAP_OFFSET
+ offs = -(TRAP_OFFSET);
+#else
+ size_t break_size = 0;
+ get_break_instruction(ctx, &break_size);
+ offs = break_size;
+#endif
+ ctx->stopped_by_bp = is_breakpoint_address(ctx, pc1 - offs);
+ if (offs != 0 && ctx->stopped_by_bp && set_PC(ctx, pc1 - offs) < 0) {
+ trace(LOG_ALWAYS, "Cannot adjust PC after breakpoint: %s", errno_to_str(errno));
+ }
ext->end_of_step = !ctx->stopped_by_cb && !ctx->stopped_by_bp && ext->pending_step;
}
ext->pending_step = 0;

Back to the top