hdt: Adding more debug traces in cli
authorErwan Velu <erwanaliasr1@gmail.com>
Sun, 27 May 2012 06:27:49 +0000 (08:27 +0200)
committerErwan Velu <erwanaliasr1@gmail.com>
Sun, 27 May 2012 06:27:49 +0000 (08:27 +0200)
Adding more debug traces in the cli management to ease debugging &
feature adding.

com32/hdt/hdt-cli.c

index 330f93c..85bd13f 100644 (file)
@@ -365,14 +365,14 @@ static void parse_command_line(char *line, char **command, char **module,
            *command = malloc((token_len + 1) * sizeof(char));
            strlcpy(*command, pch, token_len);
            (*command)[token_len] = '\0';
-           dprintf("CLI DEBUG: command = %s\n", *command);
+           dprintf("CLI DEBUG parse: command = %s\n", *command);
            args_pos += args_len;
        } else if (token_found == 1) {
            /* Module */
            *module = malloc((token_len + 1) * sizeof(char));
            strlcpy(*module, pch, token_len);
            (*module)[token_len] = '\0';
-           dprintf("CLI DEBUG: module  = %s\n", *module);
+           dprintf("CLI DEBUG parse: module  = %s\n", *module);
            args_pos += args_len;
        } else
            (*argc)++;
@@ -380,7 +380,7 @@ static void parse_command_line(char *line, char **command, char **module,
        token_found++;
        pch = pch_next;
     }
-    dprintf("CLI DEBUG: argc    = %d\n", *argc);
+    dprintf("CLI DEBUG parse: argc    = %d\n", *argc);
 
     /* Skip arguments handling if none is supplied */
     if (!*argc)
@@ -390,7 +390,7 @@ static void parse_command_line(char *line, char **command, char **module,
     *argv = malloc(*argc * sizeof(char *));
     pch = strtok(line + args_pos, CLI_SPACE);
     while (pch != NULL) {
-       dprintf("CLI DEBUG: argv[%d] = %s\n", argc_iter, pch);
+       dprintf("CLI DEBUG parse: argv[%d] = %s\n", argc_iter, pch);
        argv[argc_iter] = malloc(sizeof(pch) * sizeof(char));
        strlcpy(argv[argc_iter], pch, sizeof(pch));
        argc_iter++;
@@ -585,6 +585,7 @@ static void autocomplete(char *line)
 
     parse_command_line(line, &command, &module, &argc, argv);
 
+    dprintf("CLI DEBUG autocomplete: before checking args\n");
     /* If the user specified arguments, there is nothing we can complete */
     if (argc != 0)
        goto out;
@@ -673,7 +674,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
         *    hdt> set mode dmi
         */
        if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
-           dprintf("CLI DEBUG: %s command detected\n", CLI_SHOW);
+           dprintf("CLI DEBUG exec: %s command detected\n", CLI_SHOW);
            /* Look first for a 'show' callback in the current mode */
            find_cli_callback_descr(module, current_mode->show_modules,
                                    &current_module);
@@ -681,6 +682,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
            if (current_module != NULL)
                current_module->exec(argc, argv, hardware);
            else {
+               dprintf("CLI DEBUG exec: Looking for callback\n");
                /* Look now for a 'show' callback in the hdt mode */
                find_cli_callback_descr(module, hdt_mode.show_modules,
                                        &current_module);
@@ -691,7 +693,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
                    printf("unknown module: '%s'\n", module);
            }
        } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) {
-           dprintf("CLI DEBUG: %s command detected\n", CLI_SET);
+           dprintf("CLI DEBUG exec : %s command detected\n", CLI_SET);
            /* Look now for a 'set' callback in the hdt mode */
            find_cli_callback_descr(module, current_mode->set_modules,
                                    &current_module);