public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Trevor Saunders <tsaunders@mozilla.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 5/5] add libcc1
Date: Fri, 20 Jun 2014 15:34:00 -0000	[thread overview]
Message-ID: <87vbrv8uje.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20140620031058.GA12633@tsaunders-iceball.corp.tor1.mozilla.com>	(Trevor Saunders's message of "Thu, 19 Jun 2014 23:10:58 -0400")

>>>>> "Trevor" == Trevor Saunders <tsaunders@mozilla.com> writes:

Trevor> I'm curious, what is the reason you choose not to write this in C++11 or
Trevor> later?  Its distributed with gcc, so the only case where you aren't
Trevor> building with the in tree compiler and libraries is when your cross
Trevor> compiling gcc, and it doesn't seem particularly important to support
Trevor> building the plugin or library in that configuration.  So istm you could
Trevor> go all the way and assume you are being built with trunk gcc and
Trevor> libraries.

The plugin has to be ABI compatible with GCC itself, and my
understanding was that C++11 and "however GCC is built" are not
necessarily compatible.

Switching to C++11 would be an improvement -- variadic templates would
simplify the RPC code (with a complicated caveat).  So if it is possible
I am interested.

Trevor> I'm going to use this as an excuse to bring up something I've wanted to
Trevor> discuss for a while.

Trevor> So can we add C++ stuff to libiberty and allow building
Trevor> libiberty without it for binutils / gdb, or can we do something
Trevor> else to avoid this kind of stuff?

One way would be to just make a new top-level directory for a new
library.

Trevor> This question also arises in the case of templating splay_tree, and I
Trevor> imagine if gdb switches to C++ some day they'll want to reuse vec.h.

While I would like that to happen, I think the odds are very long now.

>> +    connection (int fd)
>> +      : m_fd (fd),
>> +	m_aux_fd (-1),
>> +	m_callbacks ()

Trevor>  Personally I'd leave that to the compiler to write, but I guess there's
Trevor>  something to be said for being explicit.

I can't recall if I did this in response to a warning or if it was just
because I wanted to be explicit.

I'm inclined to leave it, but I suppose only out of inertia.

>> +  void print (const char *buf)

Trevor> explicitly mark it as virtual?

Good idea, done.

>> +// This is a wrapper function that is called by the RPC system and
>> +// that then forwards the call to the library user.  Note that the
>> +// return value is not used; the type cannot be 'void' due to
>> +// limitations in our simple RPC.
>> +gcc_address

Trevor> looks like this one probably is used?

Thanks, fixed.

>> +  char **argv = new (std::nothrow) char *[self->args.size () + 1];

Trevor> What's the point of making this no throw? you don't null check it so
Trevor> you'll crash anyway afaict.

Thanks.  I changed it to do a NULL check.  It's nothrow because nothing
in libcc1 or gdb is prepared for a C++ exception.  While I like
exceptions (gdb uses its own longjmp-based exception system
extensively), my understanding is that they aren't currently used in
gcc.

>> +cc1_plugin::status
>> +cc1_plugin::unmarshall (connection *conn, char **result)
>> +{
>> +  unsigned long long len;
>> +
>> +  if (!conn->require ('s'))
>> +    return FAIL;
>> +  if (!conn->get (&len, sizeof (len)))
>> +    return FAIL;
>> +
>> +  if (len == -1ULL)
>> +    {
>> +      *result = NULL;
>> +      return OK;
>> +    }
>> +
>> +  char *str = new (std::nothrow) char[len + 1];

Trevor> It'd be really nice if the type of the out arg forced the caller to deal
Trevor> with deleting the string like unique_ptr<char>, it would be even nicer
Trevor> if you could stick a random buffer in a std::string, but I guess you
Trevor> can't :(

Yeah, it's all quite simplistic.  I suppose it could be upgraded, there
just didn't seem to be a need.

Trevor> Also where does this array get deleted?

The unmarshalling methods are generally called via argument_wrappers.
An example is in connection.cc:

		// Use an argument_wrapper here to simplify management
		// of the string's lifetime.
		argument_wrapper<char *> method_name;

		if (!method_name.unmarshall (this))
		  return FAIL;

Then in rpc.hh:

  // Specialization for string types.
  template<>
  class argument_wrapper<const char *>
  {
  public:
    argument_wrapper () : m_object (NULL) { }
    ~argument_wrapper ()
    {
      delete[] m_object;
    }

Tom

  reply	other threads:[~2014-06-20 15:34 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 15:26 [PATCH 0/5] let gdb reuse gcc'c C compiler Tom Tromey
2014-05-16 15:26 ` [PATCH 1/5] export finish_bitfield_layout from stor-layout Tom Tromey
2014-05-16 18:27   ` Jeff Law
2014-05-16 15:27 ` [PATCH 4/5] add gcc/gdb interface files Tom Tromey
2014-05-22 12:52   ` Jeff Law
2014-05-22 13:16     ` Jakub Jelinek
2014-05-22 15:13       ` Jeff Law
2014-06-04 20:39       ` Tom Tromey
2014-06-05 19:23         ` Jeff Law
2014-06-05 19:30           ` Jakub Jelinek
2014-06-06  1:54             ` Tom Tromey
2014-06-06  5:35               ` Jakub Jelinek
2014-06-09 17:09               ` Jeff Law
2014-06-19 20:45                 ` Tom Tromey
2014-05-16 15:27 ` [PATCH 2/5] c_diagnostic_ignored_function hack Tom Tromey
2014-05-16 16:05   ` Joseph S. Myers
2014-06-19 20:46     ` Tom Tromey
2014-05-16 18:33   ` Jeff Law
2014-05-16 18:42     ` Tom Tromey
2014-05-16 15:27 ` [PATCH 3/5] introduce the binding oracle Tom Tromey
2014-05-16 19:12   ` Jeff Law
2014-06-05 15:31     ` Tom Tromey
2014-06-19 20:43     ` Tom Tromey
2014-05-16 16:29 ` [PATCH 0/5] let gdb reuse gcc'c C compiler Mike Stump
2014-05-16 18:48 ` [PATCH 5/5] add libcc1 Tom Tromey
2014-05-16 20:29   ` Joseph S. Myers
2014-05-16 21:03     ` Tom Tromey
2014-06-18 21:07     ` Tom Tromey
2014-06-19 20:47     ` Tom Tromey
2014-05-16 21:36   ` Mike Stump
2014-05-16 22:17   ` Mike Stump
2014-06-05 19:34     ` Tom Tromey
2014-06-05 21:35       ` Mike Stump
2014-06-19 20:52   ` Tom Tromey
2014-06-19 21:45     ` Jakub Jelinek
2014-06-19 22:22       ` Tom Tromey
2014-06-20  3:11     ` Trevor Saunders
2014-06-20 15:34       ` Tom Tromey [this message]
2014-06-23 19:09         ` Jeff Law
2014-06-24  3:13           ` Trevor Saunders
2014-06-24 17:12             ` Tom Tromey
2014-06-24 18:10               ` Trevor Saunders
2014-07-18 19:00     ` Tom Tromey
2014-07-31  4:49     ` Jeff Law
2014-07-31  8:15       ` Richard Biener
2014-07-31 10:53         ` Trevor Saunders
2014-07-31 11:28           ` Richard Biener
2014-07-31 15:08             ` Joseph S. Myers
2014-07-31 19:20         ` Tom Tromey
2014-07-31 19:21           ` Jakub Jelinek
2014-07-31 19:51           ` Trevor Saunders
2014-07-31 20:07             ` Tom Tromey
2014-08-01  2:18               ` Trevor Saunders
2014-07-31 21:14       ` Mike Stump
2014-08-04 14:23         ` Tom Tromey
2014-08-05 19:34       ` Tom Tromey
2014-08-08 12:15         ` [PATCH 5/5] add libcc1 [gcc-5/changes.html] Jan Kratochvil
2014-08-31 15:12           ` Gerald Pfeifer
2014-09-14 15:07             ` Manuel López-Ibáñez
2014-09-17 14:14               ` Jan Kratochvil
2014-10-09  9:07       ` [PATCH 5/5] add libcc1 Phil Muldoon
2014-10-09  9:12         ` Jakub Jelinek
2014-10-09  9:18         ` Phil Muldoon
2014-10-10 22:31         ` Jeff Law
2014-10-24  7:43           ` Phil Muldoon
2014-10-24  7:53             ` Jakub Jelinek
2014-10-24 16:47             ` Jeff Law
2014-10-27 20:03               ` Phil Muldoon
2014-10-28 13:29                 ` Joseph S. Myers
2014-10-28 18:00                   ` Phil Muldoon
2014-10-29  3:32                     ` Joseph S. Myers
2014-10-29 10:29                     ` Jakub Jelinek
2014-10-29 10:45                       ` Paolo Bonzini
2014-10-29 10:58                         ` Jakub Jelinek
2014-10-29 10:59                           ` Paolo Bonzini
2014-10-29 11:03                             ` Jakub Jelinek
2014-10-29 15:00                               ` Paolo Bonzini
2014-10-29 11:10                             ` Phil Muldoon
2014-10-29 11:42                             ` Phil Muldoon
2014-10-30  5:37                       ` Jeff Law
2014-06-19 20:42 ` [PATCH 0/5] let gdb reuse gcc'c C compiler Tom Tromey
2014-07-30 16:28   ` Tom Tromey
2014-10-28  3:19 [PATCH 5/5] add libcc1 Dominique Dhumieres
2014-10-28  8:36 ` Jakub Jelinek
2014-10-28  8:46   ` Phil Muldoon
2014-10-28  8:50     ` Christophe Lyon
2014-10-28  9:09     ` Jakub Jelinek
2014-10-28  8:43 Uros Bizjak
2014-10-28  8:55 ` Phil Muldoon
2014-10-28  9:21   ` Uros Bizjak
2014-10-28  9:36 ` Jakub Jelinek
2014-10-28  9:58   ` Uros Bizjak
2014-10-28 10:51     ` Phil Muldoon
2014-10-28 10:56       ` Uros Bizjak
2014-10-28 11:16         ` Phil Muldoon
2014-10-28 11:53         ` Phil Muldoon
2014-10-28 12:24           ` Jakub Jelinek
2014-10-30  5:16             ` Jeff Law
2014-10-30  8:50             ` Thomas Schwinge
2014-10-30  8:56               ` Jakub Jelinek
2014-10-30 10:43                 ` Thomas Schwinge

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=87vbrv8uje.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tsaunders@mozilla.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).