public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/8] Add a C++ wrapper for GCC C plug-in
Date: Wed, 06 Jun 2018 14:34:00 -0000	[thread overview]
Message-ID: <20f5dd67-b19f-f2f9-919e-1c30cf9a8a5d@redhat.com> (raw)
In-Reply-To: <20180503184153.31183-5-keiths@redhat.com>

On 05/03/2018 07:41 PM, Keith Seitz wrote:
> 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.  

It's easier to keep an ABI promise in C anyway, so it's not uncommon
for C++ projects to expose a C plugin interface and then provide wrappers
for multiple languages.  That's how the GCC JIT interface is exported
for example.

> The hope is to isolate GDB from some of this
> should it change in the future.

Not so sure it would be a good idea to change it, IMHO.

> 
> 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 LGTM.

I do wonder whether c_plugin needs to be a pointer though?

Couldn't it be an object directly?  Like:

  context->c_plugin.operation (...);

I see that the next patch switches this to a method named
plugin(), and then I wonder if that method can return a reference
instead of a pointer (because IIUC, you can never have a
NULL plugin).

TBC, even if you agree, I don't think it's worth it to go
over the pain of to redoing the series because of this.
I'd be totally fine with changing it on top of the series.

> @@ -206,22 +197,20 @@ convert_enum (struct compile_c_instance *context, struct type *type)
>  {
>    gcc_type int_type, result;
>    int i;
> -  struct gcc_c_context *ctx = C_CTX (context);
> +  const gcc_c_plugin *plugin = context->c_plugin;
>  
> -  int_type = ctx->c_ops->int_type_v0 (ctx,
> -				      TYPE_UNSIGNED (type),
> -				      TYPE_LENGTH (type));
> +  int_type = plugin->int_type_v0 (TYPE_UNSIGNED (type),
> +					    TYPE_LENGTH (type));

Alignment looks odd here, but maybe it's just in the email client.

Thanks,
Pedro Alves

  reply	other threads:[~2018-06-06 14:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 18:42 [PATCH 0/8] Convert C compile to C++ Keith Seitz
2018-05-03 18:41 ` [PATCH 2/8] Rename symbol_substitution_name Keith Seitz
2018-05-03 18:42 ` [PATCH 1/8] Return unique_xmalloc_ptr for generate_c_for_variable_locations Keith Seitz
2018-05-03 18:42 ` [PATCH 3/8] Move C-related declarations to compile-c.h Keith Seitz
2018-06-06 14:34   ` Pedro Alves
2018-05-03 18:49 ` [PATCH 6/8] Use std::unordered_map instead of htab_t Keith Seitz
2018-06-06 14:35   ` Pedro Alves
2018-07-10 17:05     ` Keith Seitz
2018-07-11 11:21       ` Pedro Alves
2018-08-07 14:57         ` Keith Seitz
2018-08-08 12:29           ` Pedro Alves
2018-08-10 18:18             ` Keith Seitz
2018-05-03 18:49 ` [PATCH 4/8] Add a C++ wrapper for GCC C plug-in Keith Seitz
2018-06-06 14:34   ` Pedro Alves [this message]
2018-07-10 16:58     ` Keith Seitz
2018-05-03 18:50 ` [PATCH 7/8] Move compile_instance to compile.c Keith Seitz
2018-05-03 18:50 ` [PATCH 8/8] Use policies for code generation Keith Seitz
2018-05-03 18:51 ` [PATCH 5/8] Change compile_instance/compile_c_instance into classes Keith Seitz
2018-06-06 14:38 ` [PATCH 0/8] Convert C compile to C++ Pedro Alves
2018-07-10 17:07   ` Keith Seitz
2018-07-11 11:31     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20f5dd67-b19f-f2f9-919e-1c30cf9a8a5d@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).