* gdbint.texinfo (Formatting): Mention some formatting guidelines
[deliverable/binutils-gdb.git] / gdb / opencl-lang.c
index 088d49af32c28e6d2c23bbb1ff6a7899a0b508bc..169ee6bfa7cd4b51a60fd2558adb92bd84fe88ac 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 */
@@ -1075,27 +1116,27 @@ build_opencl_types (struct gdbarch *gdbarch)
     = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
 
 /* Helper macro to create strings.  */
-#define STRINGIFY(S) #S
+#define OCL_STRING(S) #S
 /* This macro allocates and assigns the type struct pointers
    for the vector types.  */
 #define BUILD_OCL_VTYPES(TYPE)\
   builtin_opencl_type->builtin_##TYPE##2\
     = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
-  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = OCL_STRING(TYPE ## 2);\
   builtin_opencl_type->builtin_##TYPE##3\
     = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
-  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = OCL_STRING(TYPE ## 3);\
   TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
     = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
   builtin_opencl_type->builtin_##TYPE##4\
     = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
-  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = OCL_STRING(TYPE ## 4);\
   builtin_opencl_type->builtin_##TYPE##8\
     = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
-  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = OCL_STRING(TYPE ## 8);\
   builtin_opencl_type->builtin_##TYPE##16\
     = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
-  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = OCL_STRING(TYPE ## 16)
 
   builtin_opencl_type->builtin_char
     = arch_integer_type (gdbarch, 8, 0, "char");
This page took 0.024641 seconds and 4 git commands to generate.