[collectd] [PATCH] perl plugin: Added "EnableDebugger" config option.

Sebastian Harl sh at tokkee.org
Sun Oct 7 23:50:30 CEST 2007


This config option will pass control to the Perl debugger after the
interpreter has been initialized. This is exactly the same as invoking perl
with the "-d" command line switch.

Just as with perl's "-d" command line option you can supply an alternative
debugger. Pass the package name as an argument to the "EnableDebugger" option

See perldebug(1) for more details.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/perl.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/perl.c b/src/perl.c
index c85d288..b90ec98 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -86,6 +86,7 @@ static const char *config_keys[] =
 {
 	"LoadPlugin",
 	"BaseName",
+	"EnableDebugger",
 	"IncludeDir"
 };
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
@@ -929,6 +930,26 @@ static int perl_config (const char *key, const char *value)
 		strncpy (base_name, value, sizeof (base_name));
 		base_name[sizeof (base_name) - 1] = '\0';
 	}
+	else if (0 == strcasecmp (key, "EnableDebugger")) {
+		perl_argv = (char **)realloc (perl_argv,
+				(++perl_argc + 1) * sizeof (char *));
+
+		if (NULL == perl_argv) {
+			log_err ("perl_config: Not enough memory.");
+			exit (3);
+		}
+
+		if ('\0' == value[0]) {
+			perl_argv[perl_argc - 1] = "-d";
+		}
+		else {
+			perl_argv[perl_argc - 1] = (char *)smalloc (strlen (value) + 4);
+			sstrncpy (perl_argv[perl_argc - 1], "-d:", 4);
+			sstrncpy (perl_argv[perl_argc - 1] + 3, value, strlen (value) + 1);
+		}
+
+		perl_argv[perl_argc] = NULL;
+	}
 	else if (0 == strcasecmp (key, "IncludeDir")) {
 		perl_argv = (char **)realloc (perl_argv,
 				(++perl_argc + 1) * sizeof (char *));
-- 
1.5.3.3.131.g34c6d-dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071007/6be5f085/attachment.pgp 


More information about the collectd mailing list