perl plugin: Added "EnableDebugger" config option.
authorSebastian Harl <sh@tokkee.org>
Sun, 7 Oct 2007 21:50:30 +0000 (23:50 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 9 Oct 2007 16:03:43 +0000 (18:03 +0200)
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@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/perl.c

index 0b78def..3b91e5f 100644 (file)
@@ -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 *));