| 351 | } |
| 352 | |
| 353 | static void |
| 354 | db_command(struct command **last_cmdp, struct command_table *cmd_table, |
| 355 | int dopager) |
| 356 | { |
| 357 | struct command *cmd = NULL; |
| 358 | int t; |
| 359 | char modif[TOK_STRING_SIZE]; |
| 360 | db_expr_t addr, count; |
| 361 | bool have_addr = false; |
| 362 | int result; |
| 363 | |
| 364 | t = db_read_token(); |
| 365 | if (t == tEOL) { |
| 366 | /* empty line repeats last command, at 'next' */ |
| 367 | cmd = *last_cmdp; |
| 368 | addr = (db_expr_t)db_next; |
| 369 | have_addr = false; |
| 370 | count = 1; |
| 371 | modif[0] = '\0'; |
| 372 | } |
| 373 | else if (t == tEXCL) { |
| 374 | db_fncall((db_expr_t)0, (bool)false, (db_expr_t)0, (char *)0); |
| 375 | return; |
| 376 | } |
| 377 | else if (t != tIDENT) { |
| 378 | db_printf("Unrecognized input; use \"help\" " |
| 379 | "to list available commands\n"); |
| 380 | db_flush_lex(); |
| 381 | return; |
| 382 | } |
| 383 | else { |
| 384 | /* |
| 385 | * Search for command |
| 386 | */ |
| 387 | while (cmd_table) { |
| 388 | result = db_cmd_search(db_tok_string, |
| 389 | cmd_table, |
| 390 | &cmd); |
| 391 | switch (result) { |
| 392 | case CMD_NONE: |
| 393 | db_printf("No such command; use \"help\" " |
| 394 | "to list available commands\n"); |
| 395 | db_flush_lex(); |
| 396 | return; |
| 397 | case CMD_AMBIGUOUS: |
| 398 | db_printf("Ambiguous\n"); |
| 399 | db_flush_lex(); |
| 400 | return; |
| 401 | case CMD_HELP: |
| 402 | if (cmd_table == &db_cmd_table) { |
| 403 | db_printf("This is ddb(4), the kernel debugger; " |
| 404 | "see https://man.FreeBSD.org/ddb/4 for help.\n"); |
| 405 | db_printf("Use \"bt\" for backtrace, \"dump\" for " |
| 406 | "kernel core dump, \"reset\" to reboot.\n"); |
| 407 | db_printf("Available commands:\n"); |
| 408 | } |
| 409 | db_cmd_list(cmd_table); |
| 410 | db_flush_lex(); |
no test coverage detected