From: Sebastian Harl Date: Sun, 7 Oct 2007 21:50:30 +0000 (+0200) Subject: perl plugin: Added "EnableDebugger" config option. X-Git-Tag: collectd-4.2.0~43 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=eca5237ba1652a2517cabf47a355efb193cec5f9;p=collectd.git perl plugin: Added "EnableDebugger" config option. 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 Signed-off-by: Florian Forster --- diff --git a/src/perl.c b/src/perl.c index 0b78defd..3b91e5f4 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); @@ -931,6 +932,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 *));