Add support for setting initial node number through debugging extension.
authorManuel Mohr <manuel.mohr@kit.edu>
Wed, 20 Jun 2012 11:51:15 +0000 (13:51 +0200)
committerManuel Mohr <manuel.mohr@kit.edu>
Wed, 27 Jun 2012 12:02:15 +0000 (14:02 +0200)
This also supports setting the initial node number to "rand", thereby
replacing randnodenr.

ir/debug/debugger.c

index 6ee1608..fb60822 100644 (file)
@@ -583,7 +583,7 @@ static void show_commands(void)
                "setoutfile name file  redirects debug output of module name to file\n"
                "irgname name          prints address and graph number of a method given by its name\n"
                "irgldname ldname      prints address and graph number of a method given by its ldname\n"
-               "randnodenr            randomize initial node number\n"
+               "initialnodenr n|rand  set initial node number to n or random number\n"
                "help                  list all commands\n"
                );
 }
@@ -898,7 +898,7 @@ enum tokens {
        tok_setoutfile,
        tok_showent,
        tok_showtype,
-       tok_randnodenr,
+       tok_initialnodenr,
        tok_identifier,
        tok_number,
        tok_eof,
@@ -924,7 +924,7 @@ static const char *reserved[] = {
        "setoutfile",
        "showent",
        "showtype",
-       "randnodenr",
+       "initialnodenr",
 };
 
 /**
@@ -1221,10 +1221,17 @@ void firm_debug(const char *cmd)
                        irg_name(name);
                        break;
 
-               case tok_randnodenr:
-                       dbg_printf("Randomizing initial node number\n");
-                       srand(time(0));
-                       irp->max_node_nr += rand() % 6666;
+               case tok_initialnodenr:
+                       token = get_token();
+                       if (token == tok_number) {
+                               dbg_printf("Setting initial node number to %u\n", lexer.number);
+                               irp->max_node_nr = lexer.number;
+                       } else if (token == tok_identifier && !strcmp(lexer.s, "rand")) {
+                               dbg_printf("Randomizing initial node number\n");
+                               srand(time(0));
+                               irp->max_node_nr += rand() % 6666;
+                       } else
+                               goto error;
                        break;
 
                case tok_irgldname: