aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile/compile-c-symbols.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2018-08-10 10:45:36 -0700
committerKeith Seitz <keiths@redhat.com>2018-08-10 11:14:25 -0700
commit18cdc6d8f8e8b55e84783e0a2b5a80b41a0e917b (patch)
tree4cb360c4b831deaaa79333ebc6b3a28a634465bc /gdb/compile/compile-c-symbols.c
parentb7dc48b4a8006abb552c5e7d22f9841c86f2537d (diff)
downloadgdb-18cdc6d8f8e8b55e84783e0a2b5a80b41a0e917b.zip
gdb-18cdc6d8f8e8b55e84783e0a2b5a80b41a0e917b.tar.gz
gdb-18cdc6d8f8e8b55e84783e0a2b5a80b41a0e917b.tar.bz2
Add a C++ wrapper for GCC C plug-in
This patch introduces a new class which wraps the GCC C compile plug-in. It is a little unfortunate that this all happened in between the time that GCC moved to C++ and GDB moved to C++, leaving us with an ABI promise to support a C-like interface. The hope is to isolate GDB from some of this should it change in the future. Broadly, what this does is replace calls like: C_CTX (context)->c_ops->operation (C_CTX (context), ...); with calls that now look like: context->c_plugin->operation (...); This API will be further refined in following patches when struct compile_instance/compile_c_instance are changed into classes. gdb/ChangeLog: * Makefile.in (HFILES_NO_SRCDIR): Add compile/gcc-c-plugin.h. * compile/compile-c-types.c: Define GCC_METHODN macros and include gcc-c-fe.def to define C plugin. (delete_instance): Delete `c_plugin'. (new_compile_instance): Initialize `c_plugin'. * compile/compile-c.h: Include gcc_c_plugin.h. (struct compile_c_instance) <c_plugin>: New member. * gcc-c-plugin.h: New file. Update all callers with API change.
Diffstat (limited to 'gdb/compile/compile-c-symbols.c')
-rw-r--r--gdb/compile/compile-c-symbols.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index c82e008..abd8298 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -161,9 +161,8 @@ convert_one_symbol (struct compile_c_instance *context,
if (SYMBOL_DOMAIN (sym.symbol) == STRUCT_DOMAIN)
{
/* Binding a tag, so we don't need to build a decl. */
- C_CTX (context)->c_ops->tagbind (C_CTX (context),
- SYMBOL_NATURAL_NAME (sym.symbol),
- sym_type, filename, line);
+ context->c_plugin->tagbind (SYMBOL_NATURAL_NAME (sym.symbol),
+ sym_type, filename, line);
}
else
{
@@ -196,9 +195,8 @@ convert_one_symbol (struct compile_c_instance *context,
/* Already handled by convert_enum. */
return;
}
- C_CTX (context)->c_ops->build_constant
- (C_CTX (context),
- sym_type, SYMBOL_NATURAL_NAME (sym.symbol),
+ context->c_plugin->build_constant
+ (sym_type, SYMBOL_NATURAL_NAME (sym.symbol),
SYMBOL_VALUE (sym.symbol),
filename, line);
return;
@@ -285,15 +283,14 @@ convert_one_symbol (struct compile_c_instance *context,
if (context->base.scope != COMPILE_I_RAW_SCOPE
|| symbol_name == NULL)
{
- decl = C_CTX (context)->c_ops->build_decl
- (C_CTX (context),
- SYMBOL_NATURAL_NAME (sym.symbol),
+ decl = context->c_plugin->build_decl
+ (SYMBOL_NATURAL_NAME (sym.symbol),
kind,
sym_type,
symbol_name.get (), addr,
filename, line);
- C_CTX (context)->c_ops->bind (C_CTX (context), decl, is_global);
+ context->c_plugin->bind (decl, is_global);
}
}
}
@@ -402,11 +399,10 @@ convert_symbol_bmsym (struct compile_c_instance *context,
}
sym_type = convert_type (context, type);
- decl = C_CTX (context)->c_ops->build_decl (C_CTX (context),
- MSYMBOL_NATURAL_NAME (msym),
- kind, sym_type, NULL, addr,
- NULL, 0);
- C_CTX (context)->c_ops->bind (C_CTX (context), decl, 1 /* is_global */);
+ decl = context->c_plugin->build_decl (MSYMBOL_NATURAL_NAME (msym),
+ kind, sym_type, NULL, addr,
+ NULL, 0);
+ context->c_plugin->bind (decl, 1 /* is_global */);
}
/* See compile-internal.h. */
@@ -463,7 +459,7 @@ gcc_convert_symbol (void *datum,
CATCH (e, RETURN_MASK_ALL)
{
- C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+ context->c_plugin->error (e.message);
}
END_CATCH
@@ -525,7 +521,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
CATCH (e, RETURN_MASK_ERROR)
{
- C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+ context->c_plugin->error (e.message);
}
END_CATCH