On Wed, May 09, 2018 at 10:23:41AM +0200, Martin Pieuchot wrote: > On 09/05/18(Wed) 07:48, Artturi Alm wrote: > > On Tue, May 08, 2018 at 01:44:39AM +0300, Artturi Alm wrote: > > > No bug are irrelevant to fix. But working with you is hard, really > hard. You never explain what the problem is. Reading your email is > an exercise in frustration because you can do some good work but you > fail to communicate. > > > > (manual "copypaste"): > > > nc2k4hp# sysctl ddb.trigger=1 > > > Stopped at db_enter+0x4: popl %ebp > > > ddb{0}> print/x "eax = " $eax "\necx = " $ecx "\n" > > > 3 > > > ddb{0}> c > > > ddb.trigger: 0 -> 1 > > > > > > so, for reasons yet unknown to me, p[rint] doesn't seem to work at all > > > like described in the man page, tested on i386. > > What do no work? What does the man page describe? Do you expect us to > read the man page, then look at your mail again, then try to understand > what is not working? >
For example, print/x "eax = " $eax "\necx = " $ecx "\n" will print something like this: eax = xxxxxx ecx = yyyyyy Now I did install 5.0 into a VM, and there the result for above example would of have been just "Ambiguous", and I'm guessing now that this has not been working as in the example since import. My fix is limited to producing output just like in the example, but input requires more, as it needs escapes for everything not a-z,A-Z,0-9. > > > Should it work? I hope it would. > > What should work? Why do you hope? Maybe the manpage should be fixed? > Multiple [addr] arguments to p[rint], including support for strings, and i hope so because i would find it useful while testing/writing/porting drivers. Maybe, I do like "show struct", and have more than just the filtering diff for it, but it doesn't really work for the ad hoc usecases p[rint] seems so excellent for. > > Does feel like waste of time to go any further fixing this, if this is > > yet another bug too irrelevant for anyone to ack for, so _any_ input > > here would be great. > > Like I said, no bug are irrelevant but if the one finding the bug, you > in that case, is not willing to properly explain the problem, then > better not send an email at all ;) Will try in the future. haven't tested the diff below yet, but compared to previous, it should have working /modifierS. -Artturi diff --git sys/ddb/db_command.c sys/ddb/db_command.c index a275023dc58..27cda0ba641 100644 --- sys/ddb/db_command.c +++ sys/ddb/db_command.c @@ -612,8 +612,8 @@ struct db_command db_command_table[] = { { "machine", NULL, 0, NULL}, #endif { "kill", db_kill_cmd, 0, NULL }, - { "print", db_print_cmd, 0, NULL }, - { "p", db_print_cmd, 0, NULL }, + { "print", db_print_cmd, CS_OWN, NULL }, + { "p", db_print_cmd, CS_OWN, NULL }, { "pprint", db_ctf_pprint_cmd, CS_OWN, NULL }, { "examine", db_examine_cmd, CS_SET_DOT, NULL }, { "x", db_examine_cmd, CS_SET_DOT, NULL }, diff --git sys/ddb/db_examine.c sys/ddb/db_examine.c index d8fec8219f1..e8b1912b937 100644 --- sys/ddb/db_examine.c +++ sys/ddb/db_examine.c @@ -238,19 +238,68 @@ db_examine(db_addr_t addr, char *fmt, int count) /* * Print value. */ -char db_print_format = 'x'; +char db_print_format[TOK_STRING_SIZE] = "x"; /*ARGSUSED*/ void db_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { db_expr_t value; + char tmptok[TOK_STRING_SIZE]; char tmpfmt[28]; + char *s; + int i, m, t; - if (modif[0] != '\0') - db_print_format = modif[0]; + /* check for modifier */ + t = db_read_token(); + if (t == tSLASH) { + t = db_read_token(); + if (t != tIDENT) { + db_printf("\nBad modifier\n"); + db_flush_lex(); + return; + } + db_strlcpy(db_print_format, db_tok_string, + sizeof(db_print_format)); + + t = db_read_token(); + } + +_inp_loop: + if (t == tDITTO) { + t = db_read_token(); + db_strlcpy(tmptok, db_tok_string, sizeof(tmptok)); + t = db_read_token(); + if (t != tDITTO) { + db_printf("\nBad string, missing \"\n"); + db_flush_lex(); + return; + } + s = db_tok_string; + for (i = 0; i < TOK_STRING_SIZE && s[i] != '\0'; i++) { + if (i < (TOK_STRING_SIZE - 1) && s[i] == '\\') { + switch (s[++i]) { + case 'n': + db_putchar('\n'); + continue; + case 't': + db_putchar('\t'); + continue; + } + } + db_putchar(s[i]); + } + goto _next_token; + } else + db_unread_token(t); + + if (db_expression(&addr)) { + db_dot = (db_addr_t) addr; + db_last_addr = db_dot; + } else + addr = (db_expr_t) db_dot; - switch (db_print_format) { + switch (db_print_format[m]) { case 'a': db_printsym((db_addr_t)addr, DB_STGY_ANY, db_printf); break; @@ -282,6 +331,15 @@ db_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) db_printf("\\%03o", (int)value); break; } + + if (db_print_format[m + 1] != '\0') + m++; + +_next_token: + t = db_read_token(); + if (t != tEOL) + goto _inp_loop; + db_printf("\n"); }