Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2017-01-09 21:18:14 +0000
committerEugene Tarassov2017-01-09 21:18:14 +0000
commit9139b665476795a63f21163846cd23f0ce5616c8 (patch)
tree0c2d43929be63ffcc4c85cf38496690b5769eb97 /agent/tcf/framework/cpudefs.c
parent363b5003088d3afcfa19043ce347d9a9fcfc0a7d (diff)
downloadorg.eclipse.tcf.agent-9139b665476795a63f21163846cd23f0ce5616c8.tar.gz
org.eclipse.tcf.agent-9139b665476795a63f21163846cd23f0ce5616c8.tar.xz
org.eclipse.tcf.agent-9139b665476795a63f21163846cd23f0ce5616c8.zip
TCF Agent: get_regs_PC() and set_regs_PC() are deprecated and replaced with get_PC() and set_PC()
New functions allow better error handling.
Diffstat (limited to 'agent/tcf/framework/cpudefs.c')
-rw-r--r--agent/tcf/framework/cpudefs.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/agent/tcf/framework/cpudefs.c b/agent/tcf/framework/cpudefs.c
index d7b68b9a..30ef7515 100644
--- a/agent/tcf/framework/cpudefs.c
+++ b/agent/tcf/framework/cpudefs.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.
@@ -85,31 +85,54 @@ int write_reg_value(StackFrame * frame, RegisterDefinition * reg_def, uint64_t v
}
ContextAddress get_regs_PC(Context * ctx) {
+ ContextAddress pc = 0;
+ if (get_PC(ctx, &pc) < 0) return 0;
+ return pc;
+}
+
+void set_regs_PC(Context * ctx, ContextAddress pc) {
+ set_PC(ctx, pc);
+}
+
+int get_PC(Context * ctx, ContextAddress * p) {
size_t i;
uint8_t buf[8];
ContextAddress pc = 0;
RegisterDefinition * def = get_PC_definition(ctx);
- if (def == NULL) return 0;
- assert(def->size <= sizeof(buf));
- if (context_read_reg(ctx, def, 0, def->size, buf) < 0) return 0;
+ if (def == NULL) {
+ set_errno(ERR_OTHER, "Cannot read PC: no such register");
+ return -1;
+ }
+ if (def->size > sizeof(buf)) {
+ set_errno(ERR_OTHER, "Cannot read PC: register is too large");
+ return -1;
+ }
+ if (context_read_reg(ctx, def, 0, def->size, buf) < 0) return -1;
for (i = 0; i < def->size; i++) {
pc = pc << 8;
pc |= buf[def->big_endian ? i : def->size - i - 1];
}
- return pc;
+ *p = pc;
+ return 0;
}
-void set_regs_PC(Context * ctx, ContextAddress pc) {
+int set_PC(Context * ctx, ContextAddress pc) {
size_t i;
uint8_t buf[8];
RegisterDefinition * def = get_PC_definition(ctx);
- if (def == NULL) return;
- assert(def->size <= sizeof(buf));
+ if (def == NULL) {
+ set_errno(ERR_OTHER, "Cannot write PC: no such register");
+ return -1;
+ }
+ if (def->size > sizeof(buf)) {
+ set_errno(ERR_OTHER, "Cannot write PC: register is too large");
+ return -1;
+ }
for (i = 0; i < def->size; i++) {
buf[def->big_endian ? def->size - i - 1 : i] = (uint8_t)pc;
pc = pc >> 8;
}
- context_write_reg(ctx, def, 0, def->size, buf);
+ return context_write_reg(ctx, def, 0, def->size, buf);
}
int id2frame(const char * id, Context ** ctx, int * frame) {

Back to the top