public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [incremental] Patch: FYI: gc-copy job's command-line arguments
@ 2007-10-04 23:12 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2007-10-04 23:12 UTC (permalink / raw)
  To: Gcc Patch List

I'm checking this in on the incremental compiler branch.

We need to allocate the current file name via the GC, so that a
pointer to the file name from a location will keep the string alive.
It seemed simplest to copy all the arguments into GC space and let the
collector sort it out.  (I tried doing this in opts.c but it seemed a
bit nicer to put the code in with the other server bits.)

Tom

ChangeLog:
2007-10-04  Tom Tromey  <tromey@redhat.com>

	* toplev.c (char_p): New typedef.
	(job_arguments): New global.
	(server_callback): GC-copy arguments.

Index: toplev.c
===================================================================
--- toplev.c	(revision 129019)
+++ toplev.c	(working copy)
@@ -387,6 +387,16 @@
 FILE *dump_file = NULL;
 const char *dump_file_name;
 
+
+typedef const char *cchar_p;
+DEF_VEC_P(cchar_p);
+DEF_VEC_ALLOC_P(cchar_p,gc);
+
+/* Saved command-line arguments for the current job.  The server
+   copies these into GC-allocated memory so that file names, etc, are
+   not deleted when the current job completes.  */
+static GTY(()) VEC(cchar_p,gc) *job_arguments;
+
 /* The current working directory of a translation.  It's generally the
    directory from which compilation was initiated, but a preprocessed
    file may specify the original directory in which it was
@@ -2241,9 +2251,14 @@
   if (px)
     {
       int n, result;
+      /* Copy the arguments into GC memory.  */
+      job_arguments = NULL;
       for (n = 0; cc1_argv[n]; ++n)
-	;
-      decode_options (n, (const char **) cc1_argv);
+	{
+	  VEC_safe_push (cchar_p, gc, job_arguments, ggc_strdup (cc1_argv[n]));
+	}
+      VEC_safe_push (cchar_p, gc, job_arguments, NULL);
+      decode_options (n, VEC_address (cchar_p, job_arguments));
 
       flag_unit_at_a_time = 1;
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-04 23:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-04 23:12 [incremental] Patch: FYI: gc-copy job's command-line arguments Tom Tromey

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