allow building GDB with Python support on MinGW
[deliverable/binutils-gdb.git] / gdb / opencl-lang.c
index 088d49af32c28e6d2c23bbb1ff6a7899a0b508bc..bfc863ede92b56a75f4ca34ce9f3b3a0985f0a63 100644 (file)
@@ -1,5 +1,5 @@
 /* OpenCL language support for GDB, the GNU debugger.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
 
    Contributed by Ken Werner <ken.werner@de.ibm.com>.
 
@@ -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
   };
@@ -786,7 +825,8 @@ evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
             Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
          int oldpos = *pos;
 
-         arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+         arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+                                 EVAL_AVOID_SIDE_EFFECTS);
          *pos = oldpos;
          type1 = check_typedef (value_type (arg1));
          type2 = check_typedef (value_type (arg2));
@@ -1055,7 +1095,8 @@ const struct language_defn opencl_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   NULL,                                /* Language specific symbol demangler */
-  NULL,                                /* Language specific class_name_from_physname */
+  NULL,                                /* Language specific
+                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
This page took 0.024483 seconds and 4 git commands to generate.