[master] e53d920 Add talk-back mechanism so VCC can tell MGR things about the program.

Poul-Henning Kamp phk at FreeBSD.org
Tue Aug 16 11:20:16 CEST 2016


commit e53d920ea176ef34898712b695d8d698364014eb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Aug 16 08:39:37 2016 +0000

    Add talk-back mechanism so VCC can tell MGR things about the program.

diff --git a/include/libvcc.h b/include/libvcc.h
index 1a5125f..78bf5fa 100644
--- a/include/libvcc.h
+++ b/include/libvcc.h
@@ -30,6 +30,8 @@
 
 struct vcc;
 
+#define VCC_INFO_PREFIX	"/* VCC_INFO"
+
 struct vcc *VCC_New(void);
 void VCC_Allow_InlineC(struct vcc *, unsigned);
 void VCC_Builtin_VCL(struct vcc *, const char *);
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 4bcb801..7b9097e 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -35,6 +35,7 @@
 #include <string.h>
 
 #include "vcc_compile.h"
+#include "libvcc.h"
 
 /*--------------------------------------------------------------------*/
 
@@ -253,6 +254,9 @@ parse_return_vcl(struct vcc *tl)
 	}
 	if (sym->eval_priv == NULL) {
 
+		VSB_printf(tl->fi, "%s VCL %.*s */\n",
+		    VCC_INFO_PREFIX, PF(tl->t));
+
 		bprintf(buf, "vgc_vcl_%u", tl->unique++);
 		sym->eval_priv = strdup(buf);
 		AN(sym->eval_priv);
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index b2542a6..7c155fb 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -667,6 +667,9 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
 	vsb = VSB_new_auto();
 	AN(vsb);
 
+	AZ(VSB_finish(tl->fi));
+	VSB_cat(vsb, VSB_data(tl->fi));
+
 	vcl_output_lang_h(vsb);
 
 	EmitCoordinates(tl, vsb);
@@ -725,15 +728,15 @@ VCC_New(void)
 
 	tl->nsources = 0;
 
-	/* General C code */
+	tl->fi = VSB_new_auto();
+	assert(tl->fi != NULL);
+
 	tl->fc = VSB_new_auto();
 	assert(tl->fc != NULL);
 
-	/* Forward decls (.h like) */
 	tl->fh = VSB_new_auto();
 	assert(tl->fh != NULL);
 
-	/* body code of methods */
 	for (i = 0; i < VCL_MET_MAX; i++) {
 		tl->fm[i] = VSB_new_auto();
 		assert(tl->fm[i] != NULL);
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 0186e5e..65e7de7 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -190,6 +190,7 @@ struct vcc {
 	int			hindent;
 	unsigned		cnt;
 
+	struct vsb		*fi;		/* VCC info to MGR */
 	struct vsb		*fc;		/* C-code */
 	struct vsb		*fh;		/* H-code (before C-code) */
 	struct vsb		*fb;		/* Body of current sub



More information about the varnish-commit mailing list