aboutsummaryrefslogtreecommitdiff
path: root/gdb/opencl-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/opencl-lang.c')
-rw-r--r--gdb/opencl-lang.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 088d49a..ef0214c 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -327,6 +327,43 @@ lval_func_check_any_valid (const struct value *v)
return 0;
}
+/* Return nonzero if bits in V from OFFSET and LENGTH represent a
+ synthetic pointer. */
+
+static int
+lval_func_check_synthetic_pointer (const struct value *v,
+ int offset, int length)
+{
+ struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+ /* Size of the target type in bits. */
+ int elsize =
+ TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+ int startrest = offset % elsize;
+ int start = offset / elsize;
+ int endrest = (offset + length) % elsize;
+ int end = (offset + length) / elsize;
+ int i;
+
+ if (endrest)
+ end++;
+
+ if (end > c->n)
+ return 0;
+
+ for (i = start; i < end; i++)
+ {
+ int startoffset = (i == start) ? startrest : 0;
+ int length = (i == end) ? endrest : elsize;
+
+ if (!value_bits_synthetic_pointer (c->val,
+ c->indices[i] * elsize + startoffset,
+ length))
+ return 0;
+ }
+
+ return 1;
+}
+
static void *
lval_func_copy_closure (const struct value *v)
{
@@ -358,6 +395,8 @@ static struct lval_funcs opencl_value_funcs =
lval_func_write,
lval_func_check_validity,
lval_func_check_any_valid,
+ NULL,
+ lval_func_check_synthetic_pointer,
lval_func_copy_closure,
lval_func_free_closure
};