aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2017-02-21 13:32:57 -0800
committerKeith Seitz <keiths@redhat.com>2017-02-21 13:32:57 -0800
commitc292163732f0123e448c15906aadb651fd676474 (patch)
tree251a0fc0ee1c6c892d49d836259f5e4ee2ddc23f
parent60118de9f17bc6c9b4ad5b0a7fe7aa2aa764d283 (diff)
downloadgdb-c292163732f0123e448c15906aadb651fd676474.zip
gdb-c292163732f0123e448c15906aadb651fd676474.tar.gz
gdb-c292163732f0123e448c15906aadb651fd676474.tar.bz2
Introduce libcc1 version 1.
-rw-r--r--gdb/compile/compile-c-types.c40
-rw-r--r--include/gcc-c-fe.def35
-rw-r--r--include/gcc-c-interface.h21
-rw-r--r--include/gcc-interface.h14
4 files changed, 82 insertions, 28 deletions
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 22aee78..5ce4cde 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -206,9 +206,15 @@ convert_enum (struct compile_c_instance *context, struct type *type)
int i;
struct gcc_c_context *ctx = C_CTX (context);
- int_type = ctx->c_ops->int_type (ctx,
- TYPE_UNSIGNED (type),
- TYPE_LENGTH (type));
+ if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+ int_type = ctx->c_ops->int_type (ctx,
+ TYPE_UNSIGNED (type),
+ TYPE_LENGTH (type),
+ NULL);
+ else
+ int_type = ctx->c_ops->int_type_v0 (ctx,
+ TYPE_UNSIGNED (type),
+ TYPE_LENGTH (type));
result = ctx->c_ops->build_enum_type (ctx, int_type);
for (i = 0; i < TYPE_NFIELDS (type); ++i)
@@ -256,9 +262,22 @@ convert_func (struct compile_c_instance *context, struct type *type)
static gcc_type
convert_int (struct compile_c_instance *context, struct type *type)
{
- return C_CTX (context)->c_ops->int_type (C_CTX (context),
- TYPE_UNSIGNED (type),
- TYPE_LENGTH (type));
+ if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+ {
+ if (TYPE_NOSIGN (type))
+ {
+ gdb_assert (TYPE_LENGTH (type) == 1);
+ return C_CTX (context)->c_ops->char_type (C_CTX (context));
+ }
+ return C_CTX (context)->c_ops->int_type (C_CTX (context),
+ TYPE_UNSIGNED (type),
+ TYPE_LENGTH (type),
+ TYPE_NAME (type));
+ }
+ else
+ return C_CTX (context)->c_ops->int_type_v0 (C_CTX (context),
+ TYPE_UNSIGNED (type),
+ TYPE_LENGTH (type));
}
/* Convert a floating-point type to its gcc representation. */
@@ -266,8 +285,13 @@ convert_int (struct compile_c_instance *context, struct type *type)
static gcc_type
convert_float (struct compile_c_instance *context, struct type *type)
{
- return C_CTX (context)->c_ops->float_type (C_CTX (context),
- TYPE_LENGTH (type));
+ if (C_CTX (context)->c_ops->c_version >= GCC_C_FE_VERSION_1)
+ return C_CTX (context)->c_ops->float_type (C_CTX (context),
+ TYPE_LENGTH (type),
+ TYPE_NAME (type));
+ else
+ return C_CTX (context)->c_ops->float_type_v0 (C_CTX (context),
+ TYPE_LENGTH (type));
}
/* Convert the 'void' type to its gcc representation. */
diff --git a/include/gcc-c-fe.def b/include/gcc-c-fe.def
index 09998ba..acf1940 100644
--- a/include/gcc-c-fe.def
+++ b/include/gcc-c-fe.def
@@ -125,16 +125,18 @@ GCC_METHOD3 (gcc_type, build_function_type,
const struct gcc_type_array *, /* Argument ARGUMENT_TYPES. */
int /* bool */) /* Argument IS_VARARGS. */
-/* Return an integer type with the given properties. */
+/* Return an integer type with the given properties.
+ Deprecated in v1, use int_type instead. */
-GCC_METHOD2 (gcc_type, int_type,
+GCC_METHOD2 (gcc_type, int_type_v0,
int /* bool */, /* Argument IS_UNSIGNED. */
unsigned long) /* Argument SIZE_IN_BYTES. */
-/* Return a floating point type with the given properties. */
+/* Return a floating point type with the given properties.
+ Deprecated in v1, use float_type instead. */
-GCC_METHOD1 (gcc_type, float_type,
- unsigned long) /* Argument SIZE_IN_BYTES. */
+GCC_METHOD1 (gcc_type, float_type_v0,
+ unsigned long) /* Argument SIZE_IN_BYTES. */
/* Return the 'void' type. */
@@ -195,3 +197,26 @@ GCC_METHOD5 (int /* bool */, build_constant,
GCC_METHOD1 (gcc_type, error,
const char *) /* Argument MESSAGE. */
+
+/* Return an integer type with the given properties. If BUILTIN_NAME
+ is non-NULL, it must name a builtin integral type with the given
+ signedness and size, and that is the type that will be returned. */
+
+GCC_METHOD3 (gcc_type, int_type,
+ int /* bool */, /* Argument IS_UNSIGNED. */
+ unsigned long, /* Argument SIZE_IN_BYTES. */
+ const char *) /* Argument BUILTIN_NAME. */
+
+/* Return the 'char' type, a distinct type from both 'signed char' and
+ 'unsigned char' returned by int_type. */
+
+GCC_METHOD0 (gcc_type, char_type)
+
+/* Return a floating point type with the given properties. If BUILTIN_NAME
+ is non-NULL, it must name a builtin integral type with the given
+ signedness and size, and that is the type that will be returned. */
+
+GCC_METHOD2 (gcc_type, float_type,
+ unsigned long, /* Argument SIZE_IN_BYTES. */
+ const char *) /* Argument BUILTIN_NAME. */
+
diff --git a/include/gcc-c-interface.h b/include/gcc-c-interface.h
index 00ccbfb..e048c86 100644
--- a/include/gcc-c-interface.h
+++ b/include/gcc-c-interface.h
@@ -41,7 +41,11 @@ struct gcc_c_context;
enum gcc_c_api_version
{
- GCC_C_FE_VERSION_0 = 0
+ GCC_C_FE_VERSION_0 = 0,
+
+ /* Added char_type. Added new version of int_type and float_type,
+ deprecated int_type_v0 and float_type_v0. */
+ GCC_C_FE_VERSION_1 = 1
};
/* Qualifiers. */
@@ -111,19 +115,6 @@ typedef gcc_address gcc_c_symbol_address_function (void *datum,
struct gcc_c_context *ctxt,
const char *identifier);
-/* An array of types used for creating a function type. */
-
-struct gcc_type_array
-{
- /* Number of elements. */
-
- int n_elements;
-
- /* The elements. */
-
- gcc_type *elements;
-};
-
/* The vtable used by the C front end. */
struct gcc_c_fe_vtable
@@ -146,7 +137,7 @@ struct gcc_c_fe_vtable
provides the declaration.
DATUM is an arbitrary piece of data that is passed back verbatim
- to the callbakcs in requests. */
+ to the callbacks in requests. */
void (*set_callbacks) (struct gcc_c_context *self,
gcc_c_oracle_function *binding_oracle,
diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index e3ffd18..1dc3498 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -169,6 +169,20 @@ struct gcc_base_context
const struct gcc_base_vtable *ops;
};
+/* An array of types used for creating function types in multiple
+ languages. */
+
+struct gcc_type_array
+{
+ /* Number of elements. */
+
+ int n_elements;
+
+ /* The elements. */
+
+ gcc_type *elements;
+};
+
/* The name of the dummy wrapper function generated by gdb. */
#define GCC_FE_WRAPPER_FUNCTION "_gdb_expr"