From 3734708d4840aa98ed8d7fb80e64a46c8b0b5cdf Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 5 Sep 2013 22:38:10 +0200 Subject: [PATCH] kernel/ddb: Fix formatting when printing command tables. FreeBSD's r163134: Fixed formatting of printing of command tables. With the default max output width of 79, only 6 columns of width 12 each fit, but 7 columns were printed. The fix is to pass the width of the next output to db_end_line() and not assume there that this width is always 1. Related unfixed bugs: - 1 character is wasted for a space after the last column - suppression of trailing spaces used to limit the misformatting, but seems to have been lost - in db_examine(), the width of the next output is not known and is still assumed to be 1. Taken-from: FreeBSD --- sys/ddb/db_command.c | 6 +++--- sys/ddb/db_examine.c | 2 +- sys/ddb/db_output.c | 4 ++-- sys/ddb/db_output.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 743a031ecc..d57b14d02b 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -260,13 +260,13 @@ db_cmd_list(struct command *table, struct command **aux_tablep, for (cmd = table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); - db_end_line(); + db_end_line(12); } if (aux_tablep == NULL) return; for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; aux_cmdp++) { db_printf("%-12s", (*aux_cmdp)->name); - db_end_line(); + db_end_line(12); } } @@ -430,7 +430,7 @@ db_help_cmd(void) while (cmd->name != 0) { db_printf("%-12s", cmd->name); - db_end_line(); + db_end_line(12); cmd++; } } diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c index bf47bdb60b..e36aeeba30 100644 --- a/sys/ddb/db_examine.c +++ b/sys/ddb/db_examine.c @@ -179,7 +179,7 @@ db_examine(db_addr_t addr, char *fmt, int count) break; } if (db_print_position() != 0) - db_end_line(); + db_end_line(1); break; } } diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index 600ef44a53..f3188b7d20 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -217,9 +217,9 @@ db_iprintf(const char *fmt,...) * End line if too long. */ void -db_end_line(void) +db_end_line(int field_width) { - if (db_output_position >= db_max_width) + if (db_output_position + field_width > db_max_width) db_printf("\n"); } diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h index aedf95c18f..8edd81c168 100644 --- a/sys/ddb/db_output.h +++ b/sys/ddb/db_output.h @@ -38,7 +38,7 @@ * Printing routines for kernel debugger. */ -void db_end_line (void); +void db_end_line(int); void db_force_whitespace (void); void db_format_hex(char *, size_t, quad_t, int); int db_print_position (void); -- 2.41.0