diff options
Diffstat (limited to 'sys/ddb')
-rw-r--r-- | sys/ddb/db_break.c | 14 | ||||
-rw-r--r-- | sys/ddb/db_command.c | 367 | ||||
-rw-r--r-- | sys/ddb/db_ctf.c | 12 | ||||
-rw-r--r-- | sys/ddb/db_elf.c | 4 | ||||
-rw-r--r-- | sys/ddb/db_expr.c | 174 | ||||
-rw-r--r-- | sys/ddb/db_hangman.c | 47 | ||||
-rw-r--r-- | sys/ddb/db_input.c | 116 | ||||
-rw-r--r-- | sys/ddb/db_lex.c | 219 | ||||
-rw-r--r-- | sys/ddb/db_output.c | 106 | ||||
-rw-r--r-- | sys/ddb/db_run.c | 90 | ||||
-rw-r--r-- | sys/ddb/db_sym.c | 10 | ||||
-rw-r--r-- | sys/ddb/db_var.h | 4 | ||||
-rw-r--r-- | sys/ddb/db_variables.c | 52 | ||||
-rw-r--r-- | sys/ddb/db_watch.c | 22 |
14 files changed, 600 insertions, 637 deletions
diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c index 13eaaedb94d..dfe2f3af912 100644 --- a/sys/ddb/db_break.c +++ b/sys/ddb/db_break.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_break.c,v 1.21 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_break.c,v 1.22 2020/10/15 03:13:59 deraadt Exp $ */ /* $NetBSD: db_break.c,v 1.7 1996/03/30 22:30:03 christos Exp $ */ /* @@ -61,12 +61,12 @@ db_breakpoint_alloc(void) db_breakpoint_t bkpt; if ((bkpt = db_free_breakpoints) != 0) { - db_free_breakpoints = bkpt->link; - return (bkpt); + db_free_breakpoints = bkpt->link; + return (bkpt); } if (db_next_free_breakpoint == &db_break_table[NBREAKPOINTS]) { - db_printf("All breakpoints used.\n"); - return (0); + db_printf("All breakpoints used.\n"); + return (0); } bkpt = db_next_free_breakpoint; db_next_free_breakpoint++; @@ -195,8 +195,8 @@ db_set_temp_breakpoint(vaddr_t addr) bkpt = db_breakpoint_alloc(); if (bkpt == 0) { - db_printf("Too many breakpoints.\n"); - return (0); + db_printf("Too many breakpoints.\n"); + return (0); } bkpt->address = addr; diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 7a87ce889ac..685e46cf4bd 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.88 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_command.c,v 1.89 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -127,7 +127,7 @@ db_skip_to_eol(void) { int t; do { - t = db_read_token(); + t = db_read_token(); } while (t != tEOL); } @@ -149,34 +149,29 @@ db_cmd_search(char *name, struct db_command *table, struct db_command **cmdp) int result = CMD_NONE; for (cmd = table; cmd->name != 0; cmd++) { - char *lp; - char *rp; - int c; - - lp = name; - rp = cmd->name; - while ((c = *lp) == *rp) { - if (c == 0) { - /* complete match */ - *cmdp = cmd; - return (CMD_UNIQUE); - } - lp++; - rp++; - } - if (c == 0) { - /* end of name, not end of command - - partial match */ - if (result == CMD_FOUND) { - result = CMD_AMBIGUOUS; - /* but keep looking for a full match - - this lets us match single letters */ + char *lp = name, *rp = cmd->name; + int c; + + while ((c = *lp) == *rp) { + if (c == 0) { + /* complete match */ + *cmdp = cmd; + return (CMD_UNIQUE); + } + lp++; + rp++; } - else { - *cmdp = cmd; - result = CMD_FOUND; + if (c == 0) { + /* end of name, not end of command - partial match */ + if (result == CMD_FOUND) { + result = CMD_AMBIGUOUS; + /* but keep looking for a full match - + this lets us match single letters */ + } else { + *cmdp = cmd; + result = CMD_FOUND; + } } - } } return (result); } @@ -187,8 +182,8 @@ db_cmd_list(struct db_command *table) struct db_command *cmd; for (cmd = table; cmd->name != 0; cmd++) { - db_printf("%-12s", cmd->name); - db_end_line(12); + db_printf("%-12s", cmd->name); + db_end_line(12); } } @@ -202,124 +197,109 @@ db_command(struct db_command **last_cmdp, struct db_command *cmd_table) t = db_read_token(); if (t == tEOL) { - /* empty line repeats last command, at 'next' */ - cmd = *last_cmdp; - addr = (db_expr_t)db_next; - have_addr = 0; - count = 1; - modif[0] = '\0'; - } - else if (t == tEXCL) { - db_fncall(0, 0, 0, NULL); - return; - } - else if (t != tIDENT) { - db_printf("?\n"); - db_flush_lex(); - return; - } - else { - /* - * Search for command - */ - while (cmd_table) { - result = db_cmd_search(db_tok_string, - cmd_table, - &cmd); - switch (result) { - case CMD_NONE: - db_printf("No such command\n"); - db_flush_lex(); - return; - case CMD_AMBIGUOUS: - db_printf("Ambiguous\n"); - db_flush_lex(); - return; - default: - break; - } - if ((cmd_table = cmd->more) != 0) { - t = db_read_token(); - if (t != tIDENT) { - db_cmd_list(cmd_table); - db_flush_lex(); - return; - } - } - } - - if ((cmd->flag & CS_OWN) == 0) { - /* - * Standard syntax: - * command [/modifier] [addr] [,count] - */ - t = db_read_token(); - if (t == tSLASH) { - t = db_read_token(); - if (t != tIDENT) { - db_printf("Bad modifier\n"); - db_flush_lex(); - return; - } - db_strlcpy(modif, db_tok_string, sizeof(modif)); - } - else { - db_unread_token(t); - modif[0] = '\0'; + /* empty line repeats last command, at 'next' */ + cmd = *last_cmdp; + addr = (db_expr_t)db_next; + have_addr = 0; + count = 1; + modif[0] = '\0'; + } else if (t == tEXCL) { + db_fncall(0, 0, 0, NULL); + return; + } else if (t != tIDENT) { + db_printf("?\n"); + db_flush_lex(); + return; + } else { + /* Search for command */ + while (cmd_table) { + result = db_cmd_search(db_tok_string, + cmd_table, &cmd); + switch (result) { + case CMD_NONE: + db_printf("No such command\n"); + db_flush_lex(); + return; + case CMD_AMBIGUOUS: + db_printf("Ambiguous\n"); + db_flush_lex(); + return; + default: + break; + } + if ((cmd_table = cmd->more) != 0) { + t = db_read_token(); + if (t != tIDENT) { + db_cmd_list(cmd_table); + db_flush_lex(); + return; + } + } } - if (db_expression(&addr)) { - db_dot = (vaddr_t) addr; - db_last_addr = db_dot; - have_addr = 1; - } - else { - addr = (db_expr_t) db_dot; - have_addr = 0; - } - t = db_read_token(); - if (t == tCOMMA) { - if (!db_expression(&count)) { - db_printf("Count missing\n"); - db_flush_lex(); - return; - } - } - else { - db_unread_token(t); - count = -1; + if ((cmd->flag & CS_OWN) == 0) { + /* + * Standard syntax: + * command [/modifier] [addr] [,count] + */ + t = db_read_token(); + if (t == tSLASH) { + t = db_read_token(); + if (t != tIDENT) { + db_printf("Bad modifier\n"); + db_flush_lex(); + return; + } + db_strlcpy(modif, db_tok_string, sizeof(modif)); + } else { + db_unread_token(t); + modif[0] = '\0'; + } + + if (db_expression(&addr)) { + db_dot = (vaddr_t) addr; + db_last_addr = db_dot; + have_addr = 1; + } else { + addr = (db_expr_t) db_dot; + have_addr = 0; + } + t = db_read_token(); + if (t == tCOMMA) { + if (!db_expression(&count)) { + db_printf("Count missing\n"); + db_flush_lex(); + return; + } + } else { + db_unread_token(t); + count = -1; + } + if ((cmd->flag & CS_MORE) == 0) + db_skip_to_eol(); } - if ((cmd->flag & CS_MORE) == 0) { - db_skip_to_eol(); - } - } } *last_cmdp = cmd; if (cmd != 0) { - /* - * Execute the command. - */ - (*cmd->fcn)(addr, have_addr, count, modif); - - if (cmd->flag & CS_SET_DOT) { - /* - * If command changes dot, set dot to - * previous address displayed (if 'ed' style). - */ - if (db_ed_style) { - db_dot = db_prev; + /* Execute the command. */ + (*cmd->fcn)(addr, have_addr, count, modif); + + if (cmd->flag & CS_SET_DOT) { + /* + * If command changes dot, set dot to + * previous address displayed (if 'ed' style). + */ + if (db_ed_style) + db_dot = db_prev; + else + db_dot = db_next; } - else { - db_dot = db_next; - } - } - else { + } else { /* * If command does not change dot, * set 'next' location to be the same. */ db_next = db_dot; - } } } @@ -339,12 +319,12 @@ db_buf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_map_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - int full = 0; + int full = 0; - if (modif[0] == 'f') - full = 1; + if (modif[0] == 'f') + full = 1; - uvm_map_printit((struct vm_map *) addr, full, db_printf); + uvm_map_printit((struct vm_map *) addr, full, db_printf); } /*ARGSUSED*/ @@ -423,10 +403,10 @@ db_show_all_bufs(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_object_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - int full = 0; + int full = 0; - if (modif[0] == 'f') - full = 1; + if (modif[0] == 'f') + full = 1; uvm_object_printit((struct uvm_object *) addr, full, db_printf); } @@ -435,10 +415,10 @@ db_object_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_page_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - int full = 0; + int full = 0; - if (modif[0] == 'f') - full = 1; + if (modif[0] == 'f') + full = 1; uvm_page_printit((struct vm_page *) addr, full, db_printf); } @@ -557,13 +537,13 @@ struct db_command db_show_all_cmds[] = { #ifdef WITNESS { "locks", db_witness_list_all, 0, NULL }, #endif - { NULL, NULL, 0, NULL } + { NULL, NULL, 0, NULL } }; struct db_command db_show_cmds[] = { { "all", NULL, 0, db_show_all_cmds }, { "bcstats", db_bcstats_print_cmd, 0, NULL }, - { "breaks", db_listbreak_cmd, 0, NULL }, + { "breaks", db_listbreak_cmd, 0, NULL }, { "buf", db_buf_print_cmd, 0, NULL }, { "extents", db_extent_print_cmd, 0, NULL }, #ifdef WITNESS @@ -587,7 +567,7 @@ struct db_command db_show_cmds[] = { { "struct", db_ctf_show_struct, CS_OWN, NULL }, { "uvmexp", db_uvmexp_print_cmd, 0, NULL }, { "vnode", db_vnode_print_cmd, 0, NULL }, - { "watches", db_listwatch_cmd, 0, NULL }, + { "watches", db_listwatch_cmd, 0, NULL }, #ifdef WITNESS { "witness", db_witness_display, 0, NULL }, #endif @@ -607,14 +587,14 @@ struct db_command db_boot_cmds[] = { struct db_command db_command_table[] = { #ifdef DB_MACHINE_COMMANDS /* this must be the first entry, if it exists */ - { "machine", NULL, 0, NULL}, + { "machine", NULL, 0, NULL}, #endif { "kill", db_kill_cmd, 0, NULL }, { "print", db_print_cmd, 0, NULL }, { "p", db_print_cmd, 0, 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 }, + { "examine", db_examine_cmd, CS_SET_DOT, NULL }, + { "x", db_examine_cmd, CS_SET_DOT, NULL }, { "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL }, { "set", db_set_cmd, CS_OWN, NULL }, { "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL }, @@ -641,17 +621,17 @@ struct db_command db_command_table[] = { { "help", db_help_cmd, 0, NULL }, { "hangman", db_hangman, 0, NULL }, { "dmesg", db_dmesg_cmd, 0, NULL }, - { NULL, NULL, 0, NULL } + { NULL, NULL, 0, NULL } }; #ifdef DB_MACHINE_COMMANDS /* this function should be called to install the machine dependent commands. It should be called before the debugger is enabled */ -void db_machine_commands_install(struct db_command *ptr) +void +db_machine_commands_install(struct db_command *ptr) { - db_command_table[0].more = ptr; - return; + db_command_table[0].more = ptr; } #endif @@ -731,45 +711,44 @@ db_fncall(db_expr_t addr, int have_addr, db_expr_t count, char *modif) char tmpfmt[28]; if (!db_expression(&fn_addr)) { - db_printf("Bad function\n"); - db_flush_lex(); - return; + db_printf("Bad function\n"); + db_flush_lex(); + return; } func = (db_expr_t (*)(db_expr_t, ...)) fn_addr; t = db_read_token(); if (t == tLPAREN) { - if (db_expression(&args[0])) { - nargs++; - while ((t = db_read_token()) == tCOMMA) { - if (nargs == MAXARGS) { - db_printf("Too many arguments\n"); - db_flush_lex(); - return; - } - if (!db_expression(&args[nargs])) { - db_printf("Argument missing\n"); + if (db_expression(&args[0])) { + nargs++; + while ((t = db_read_token()) == tCOMMA) { + if (nargs == MAXARGS) { + db_printf("Too many arguments\n"); + db_flush_lex(); + return; + } + if (!db_expression(&args[nargs])) { + db_printf("Argument missing\n"); + db_flush_lex(); + return; + } + nargs++; + } + db_unread_token(t); + } + if (db_read_token() != tRPAREN) { + db_printf("?\n"); db_flush_lex(); return; - } - nargs++; } - db_unread_token(t); - } - if (db_read_token() != tRPAREN) { - db_printf("?\n"); - db_flush_lex(); - return; - } } db_skip_to_eol(); - while (nargs < MAXARGS) { - args[nargs++] = 0; - } + while (nargs < MAXARGS) + args[nargs++] = 0; retval = (*func)(args[0], args[1], args[2], args[3], args[4], - args[5], args[6], args[7], args[8], args[9]); + args[5], args[6], args[7], args[8], args[9]); db_printf("%s\n", db_format(tmpfmt, sizeof tmpfmt, retval, DB_FORMAT_N, 1, 0)); } @@ -855,17 +834,19 @@ db_show_regs(db_expr_t addr, int have_addr, db_expr_t count, char *modif) char tmpfmt[28]; for (regp = db_regs; regp < db_eregs; regp++) { - db_read_variable(regp, &value); - db_printf("%-12s%s", regp->name, db_format(tmpfmt, sizeof tmpfmt, - (long)value, DB_FORMAT_N, 1, sizeof(long) * 3)); - db_find_xtrn_sym_and_offset((vaddr_t)value, &name, &offset); - if (name != 0 && offset <= db_maxoff && offset != value) { - db_printf("\t%s", name); - if (offset != 0) - db_printf("+%s", db_format(tmpfmt, sizeof tmpfmt, - (long)offset, DB_FORMAT_R, 1, 0)); - } - db_printf("\n"); + db_read_variable(regp, &value); + db_printf("%-12s%s", regp->name, + db_format(tmpfmt, sizeof tmpfmt, + (long)value, DB_FORMAT_N, 1, sizeof(long) * 3)); + db_find_xtrn_sym_and_offset((vaddr_t)value, &name, &offset); + if (name != 0 && offset <= db_maxoff && offset != value) { + db_printf("\t%s", name); + if (offset != 0) + db_printf("+%s", + db_format(tmpfmt, sizeof tmpfmt, + (long)offset, DB_FORMAT_R, 1, 0)); + } + db_printf("\n"); } db_print_loc_and_inst(PC_REGS(&ddb_regs)); } diff --git a/sys/ddb/db_ctf.c b/sys/ddb/db_ctf.c index 8b17fbd0b34..7b844f87756 100644 --- a/sys/ddb/db_ctf.c +++ b/sys/ddb/db_ctf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_ctf.c,v 1.29 2019/11/12 07:34:43 mpi Exp $ */ +/* $OpenBSD: db_ctf.c,v 1.30 2020/10/15 03:14:00 deraadt Exp $ */ /* * Copyright (c) 2016-2017 Martin Pieuchot @@ -40,13 +40,13 @@ extern db_symtab_t db_symtab; struct ddb_ctf { - struct ctf_header *cth; + struct ctf_header *cth; const char *rawctf; /* raw .SUNW_ctf section */ - size_t rawctflen; /* raw .SUNW_ctf section size */ - const char *data; /* decompressed CTF data */ + size_t rawctflen; /* raw .SUNW_ctf section size */ + const char *data; /* decompressed CTF data */ size_t dlen; /* decompressed CTF data size */ char *strtab; /* ELF string table */ - uint32_t ctf_found; + uint32_t ctf_found; }; struct ddb_ctf db_ctf; @@ -588,7 +588,7 @@ db_ctf_pprint_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } if ((ctt = db_ctf_type_by_symbol(st)) == NULL) { - modif[0] = '\0'; + modif[0] = '\0'; db_print_cmd(addr, 0, 0, modif); db_flush_lex(); return; diff --git a/sys/ddb/db_elf.c b/sys/ddb/db_elf.c index 2ac4087089e..0a7a43a41ac 100644 --- a/sys/ddb/db_elf.c +++ b/sys/ddb/db_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_elf.c,v 1.30 2020/05/26 21:35:43 gkoehler Exp $ */ +/* $OpenBSD: db_elf.c,v 1.31 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_elf.c,v 1.13 2000/07/07 21:55:18 jhawk Exp $ */ /*- @@ -435,7 +435,7 @@ db_symbol_by_name(char *name, db_expr_t *valuep) sym = db_elf_sym_lookup(name); if (sym == NULL) - return (NULL); + return (NULL); db_symbol_values(sym, &name, valuep); return (sym); } diff --git a/sys/ddb/db_expr.c b/sys/ddb/db_expr.c index 820b91b022c..bd9099ae352 100644 --- a/sys/ddb/db_expr.c +++ b/sys/ddb/db_expr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_expr.c,v 1.17 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_expr.c,v 1.18 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_expr.c,v 1.5 1996/02/05 01:56:58 christos Exp $ */ /* @@ -54,48 +54,48 @@ db_term(db_expr_t *valuep) t = db_read_token(); if (t == tIDENT) { - if (db_symbol_by_name(db_tok_string, valuep) == NULL) { - db_error("Symbol not found\n"); - /*NOTREACHED*/ - } - return 1; + if (db_symbol_by_name(db_tok_string, valuep) == NULL) { + db_error("Symbol not found\n"); + /*NOTREACHED*/ + } + return 1; } if (t == tNUMBER) { - *valuep = db_tok_number; - return 1; + *valuep = db_tok_number; + return 1; } if (t == tDOT) { - *valuep = (db_expr_t)db_dot; - return 1; + *valuep = (db_expr_t)db_dot; + return 1; } if (t == tDOTDOT) { - *valuep = (db_expr_t)db_prev; - return 1; + *valuep = (db_expr_t)db_prev; + return 1; } if (t == tPLUS) { - *valuep = (db_expr_t) db_next; - return 1; + *valuep = (db_expr_t) db_next; + return 1; } if (t == tDITTO) { - *valuep = (db_expr_t)db_last_addr; - return 1; + *valuep = (db_expr_t)db_last_addr; + return 1; } if (t == tDOLLAR) { - if (!db_get_variable(valuep)) - return 0; - return 1; + if (!db_get_variable(valuep)) + return 0; + return 1; } if (t == tLPAREN) { - if (!db_expression(valuep)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - t = db_read_token(); - if (t != tRPAREN) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - return 1; + if (!db_expression(valuep)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + t = db_read_token(); + if (t != tRPAREN) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + return 1; } db_unread_token(t); return 0; @@ -108,21 +108,21 @@ db_unary(db_expr_t *valuep) t = db_read_token(); if (t == tMINUS) { - if (!db_unary(valuep)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - *valuep = -*valuep; - return 1; + if (!db_unary(valuep)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + *valuep = -*valuep; + return 1; } if (t == tSTAR) { - /* indirection */ - if (!db_unary(valuep)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - *valuep = db_get_value((vaddr_t)*valuep, sizeof(vaddr_t), 0); - return 1; + /* indirection */ + if (!db_unary(valuep)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + *valuep = db_get_value((vaddr_t)*valuep, sizeof(vaddr_t), 0); + return 1; } db_unread_token(t); return (db_term(valuep)); @@ -135,29 +135,29 @@ db_mult_expr(db_expr_t *valuep) int t; if (!db_unary(&lhs)) - return 0; + return 0; t = db_read_token(); while (t == tSTAR || t == tSLASH || t == tPCT || t == tHASH) { - if (!db_term(&rhs)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - if (t == tSTAR) - lhs *= rhs; - else { - if (rhs == 0) { - db_error("Divide by 0\n"); - /*NOTREACHED*/ + if (!db_term(&rhs)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ } - if (t == tSLASH) - lhs /= rhs; - else if (t == tPCT) - lhs %= rhs; - else - lhs = ((lhs+rhs-1)/rhs)*rhs; - } - t = db_read_token(); + if (t == tSTAR) + lhs *= rhs; + else { + if (rhs == 0) { + db_error("Divide by 0\n"); + /*NOTREACHED*/ + } + if (t == tSLASH) + lhs /= rhs; + else if (t == tPCT) + lhs %= rhs; + else + lhs = ((lhs+rhs-1)/rhs)*rhs; + } + t = db_read_token(); } db_unread_token(t); *valuep = lhs; @@ -171,19 +171,19 @@ db_add_expr(db_expr_t *valuep) int t; if (!db_mult_expr(&lhs)) - return 0; + return 0; t = db_read_token(); while (t == tPLUS || t == tMINUS) { - if (!db_mult_expr(&rhs)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - if (t == tPLUS) - lhs += rhs; - else - lhs -= rhs; - t = db_read_token(); + if (!db_mult_expr(&rhs)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + if (t == tPLUS) + lhs += rhs; + else + lhs -= rhs; + t = db_read_token(); } db_unread_token(t); *valuep = lhs; @@ -197,25 +197,25 @@ db_shift_expr(db_expr_t *valuep) int t; if (!db_add_expr(&lhs)) - return 0; + return 0; t = db_read_token(); while (t == tSHIFT_L || t == tSHIFT_R) { - if (!db_add_expr(&rhs)) { - db_error("Syntax error\n"); - /*NOTREACHED*/ - } - if (rhs < 0) { - db_error("Negative shift amount\n"); - /*NOTREACHED*/ - } - if (t == tSHIFT_L) - lhs <<= rhs; - else { - /* Shift right is unsigned */ - lhs = (unsigned) lhs >> rhs; - } - t = db_read_token(); + if (!db_add_expr(&rhs)) { + db_error("Syntax error\n"); + /*NOTREACHED*/ + } + if (rhs < 0) { + db_error("Negative shift amount\n"); + /*NOTREACHED*/ + } + if (t == tSHIFT_L) + lhs <<= rhs; + else { + /* Shift right is unsigned */ + lhs = (unsigned) lhs >> rhs; + } + t = db_read_token(); } db_unread_token(t); *valuep = lhs; diff --git a/sys/ddb/db_hangman.c b/sys/ddb/db_hangman.c index 69cfc3bf236..e73bd032f1a 100644 --- a/sys/ddb/db_hangman.c +++ b/sys/ddb/db_hangman.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_hangman.c,v 1.37 2017/05/30 15:39:05 mpi Exp $ */ +/* $OpenBSD: db_hangman.c,v 1.38 2020/10/15 03:14:00 deraadt Exp $ */ /* * Copyright (c) 1996 Theo de Raadt, Michael Shalayeff @@ -156,7 +156,7 @@ db_hangman(db_expr_t addr, int haddr, db_expr_t count, char *modif) size_t tries; size_t len; struct _abc sabc[1]; - int skill; + int skill, c; if (modif[0] != 's' || (skill = modif[1] - '0') > 9U) skill = 3; @@ -174,30 +174,25 @@ db_hangman(db_expr_t addr, int haddr, db_expr_t count, char *modif) db_plays++; } - - { - int c; - - db_hang(tries, word, sabc); - c = cngetc(); - c = TOLOWER(c); - - if (ISLOWALPHA(c) && ABC_ISCLR(c)) { - char *p; - size_t n; - - /* strchr(word,c) */ - for (n = 0, p = word; *p ; p++) - if (TOLOWER(*p) == c) - n++; - - if (n) { - ABC_SETRIGHT(c); - len -= n; - } else { - ABC_SETWRONG(c); - tries--; - } + db_hang(tries, word, sabc); + c = cngetc(); + c = TOLOWER(c); + + if (ISLOWALPHA(c) && ABC_ISCLR(c)) { + char *p; + size_t n; + + /* strchr(word,c) */ + for (n = 0, p = word; *p ; p++) + if (TOLOWER(*p) == c) + n++; + + if (n) { + ABC_SETRIGHT(c); + len -= n; + } else { + ABC_SETWRONG(c); + tries--; } } diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c index d68595a92c8..5135d47d182 100644 --- a/sys/ddb/db_input.c +++ b/sys/ddb/db_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_input.c,v 1.18 2019/11/06 07:30:08 mpi Exp $ */ +/* $OpenBSD: db_input.c,v 1.19 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_input.c,v 1.7 1996/02/05 01:57:02 christos Exp $ */ /* @@ -79,14 +79,14 @@ void db_putstring(char *s, int count) { while (--count >= 0) - cnputc(*s++); + cnputc(*s++); } void db_putnchars(int c, int count) { while (--count >= 0) - cnputc(c); + cnputc(c); } /* @@ -100,12 +100,12 @@ db_delete(int n, int bwd) char *p; if (bwd) { - db_lc -= n; - db_putnchars(BACKUP, n); + db_lc -= n; + db_putnchars(BACKUP, n); } for (p = db_lc; p < db_le-n; p++) { - *p = *(p+n); - cnputc(*p); + *p = *(p+n); + cnputc(*p); } db_putnchars(BLANK, n); db_putnchars(BACKUP, db_le - db_lc); @@ -142,73 +142,73 @@ int db_inputchar(int c) { switch (c) { - case CTRL('b'): + case CTRL('b'): /* back up one character */ if (db_lc > db_lbuf_start) { - cnputc(BACKUP); - db_lc--; + cnputc(BACKUP); + db_lc--; } break; - case CTRL('f'): + case CTRL('f'): /* forward one character */ if (db_lc < db_le) { - cnputc(*db_lc); - db_lc++; + cnputc(*db_lc); + db_lc++; } break; - case CTRL('a'): + case CTRL('a'): /* beginning of line */ while (db_lc > db_lbuf_start) { - cnputc(BACKUP); - db_lc--; + cnputc(BACKUP); + db_lc--; } break; - case CTRL('e'): + case CTRL('e'): /* end of line */ while (db_lc < db_le) { - cnputc(*db_lc); - db_lc++; + cnputc(*db_lc); + db_lc++; } break; - case CTRL('w'): + case CTRL('w'): /* erase word back */ while (db_lc > db_lbuf_start && db_lc[-1] != BLANK) - db_delete(1, DEL_BWD); + db_delete(1, DEL_BWD); break; - case CTRL('h'): - case 0177: + case CTRL('h'): + case 0177: /* erase previous character */ if (db_lc > db_lbuf_start) - db_delete(1, DEL_BWD); + db_delete(1, DEL_BWD); break; - case CTRL('d'): + case CTRL('d'): /* erase next character */ if (db_lc < db_le) - db_delete(1, DEL_FWD); + db_delete(1, DEL_FWD); break; - case CTRL('k'): + case CTRL('k'): /* delete to end of line */ if (db_lc < db_le) - db_delete(db_le - db_lc, DEL_FWD); + db_delete(db_le - db_lc, DEL_FWD); break; - case CTRL('u'): + case CTRL('u'): /* delete line */ - db_delete_line(); + db_delete_line(); break; - case CTRL('t'): + case CTRL('t'): /* twiddle last 2 characters */ if (db_lc >= db_lbuf_start + 2) { - c = db_lc[-2]; - db_lc[-2] = db_lc[-1]; - db_lc[-1] = c; - cnputc(BACKUP); - cnputc(BACKUP); - cnputc(db_lc[-2]); - cnputc(db_lc[-1]); + c = db_lc[-2]; + db_lc[-2] = db_lc[-1]; + db_lc[-1] = c; + cnputc(BACKUP); + cnputc(BACKUP); + cnputc(db_lc[-2]); + cnputc(db_lc[-1]); } break; #if DB_HISTORY_SIZE != 0 - case CTRL('p'): + case CTRL('p'): DEC_DB_CURR(); while (db_history_curr != db_history_last) { DEC_DB_CURR(); @@ -222,7 +222,8 @@ db_inputchar(int c) } else { char *p; INC_DB_CURR(); - for (p = db_history_curr, db_le = db_lbuf_start;*p; ) { + for (p = db_history_curr, + db_le = db_lbuf_start;*p; ) { *db_le++ = *p++; if (p == db_history + db_history_size) p = db_history; @@ -231,7 +232,7 @@ db_inputchar(int c) } db_putstring(db_lbuf_start, db_le - db_lbuf_start); break; - case CTRL('n'): + case CTRL('n'): while (db_history_curr != db_history_last) { if (*db_history_curr == '\0') break; @@ -254,15 +255,15 @@ db_inputchar(int c) } break; #endif - case CTRL('r'): + case CTRL('r'): db_putstring("^R\n", 3); if (db_le > db_lbuf_start) { db_putstring(db_lbuf_start, db_le - db_lbuf_start); db_putnchars(BACKUP, db_le - db_lc); } break; - case '\n': - case '\r': + case '\n': + case '\r': #if DB_HISTORY_SIZE != 0 /* * Check whether current line is the same @@ -276,7 +277,7 @@ db_inputchar(int c) * Is it the same? */ for (pp = db_history_prev, pc = db_lbuf_start; - pc != db_le && *pp; ) { + pc != db_le && *pp; ) { if (*pp != *pc) break; if (++pp == db_history + db_history_size) @@ -309,20 +310,19 @@ db_inputchar(int c) #endif *db_le++ = c; return 1; - default: + default: if (db_le == db_lbuf_end) { - cnputc('\007'); - } - else if (c >= ' ' && c <= '~') { - char *p; + cnputc('\007'); + } else if (c >= ' ' && c <= '~') { + char *p; - for (p = db_le; p > db_lc; p--) - *p = *(p-1); - *db_lc++ = c; - db_le++; - cnputc(c); - db_putstring(db_lc, db_le - db_lc); - db_putnchars(BACKUP, db_le - db_lc); + for (p = db_le; p > db_lc; p--) + *p = *(p-1); + *db_lc++ = c; + db_le++; + cnputc(c); + db_putstring(db_lc, db_le - db_lc); + db_putnchars(BACKUP, db_le - db_lc); } break; } @@ -340,7 +340,7 @@ db_readline(char *lstart, int lsize) db_le = lstart; while (!db_inputchar(cngetc())) - continue; + continue; db_putchar('\n'); /* synch output position */ diff --git a/sys/ddb/db_lex.c b/sys/ddb/db_lex.c index eee0e0b5190..61a9a6274d8 100644 --- a/sys/ddb/db_lex.c +++ b/sys/ddb/db_lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_lex.c,v 1.14 2016/04/19 12:23:25 mpi Exp $ */ +/* $OpenBSD: db_lex.c,v 1.15 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_lex.c,v 1.8 1996/02/05 01:57:05 christos Exp $ */ /* @@ -61,7 +61,7 @@ db_read_line(void) i = db_readline(db_line, sizeof(db_line)); if (i == 0) - return (0); /* EOI */ + return (0); /* EOI */ db_lp = db_line; db_endlp = db_lp + i; return (i); @@ -82,13 +82,12 @@ db_read_char(void) int c; if (db_look_char != 0) { - c = db_look_char; - db_look_char = 0; - } - else if (db_lp >= db_endlp) - c = -1; + c = db_look_char; + db_look_char = 0; + } else if (db_lp >= db_endlp) + c = -1; else - c = *db_lp++; + c = *db_lp++; return (c); } @@ -112,11 +111,10 @@ db_read_token(void) int t; if (db_look_token) { - t = db_look_token; - db_look_token = 0; - } - else - t = db_lex(); + t = db_look_token; + db_look_token = 0; + } else + t = db_lex(); return (t); } @@ -135,150 +133,145 @@ db_lex(void) c = db_read_char(); while (c <= ' ' || c > '~') { - if (c == '\n' || c == -1) - return (tEOL); - c = db_read_char(); + if (c == '\n' || c == -1) + return (tEOL); + c = db_read_char(); } if (c >= '0' && c <= '9') { - /* number */ - int r, digit = 0; + /* number */ + int r, digit = 0; - if (c > '0') - r = db_radix; - else { - c = db_read_char(); - if (c == 'O' || c == 'o') - r = 8; - else if (c == 'T' || c == 't') - r = 10; - else if (c == 'X' || c == 'x') - r = 16; + if (c > '0') + r = db_radix; else { - r = db_radix; - db_unread_char(c); + c = db_read_char(); + if (c == 'O' || c == 'o') + r = 8; + else if (c == 'T' || c == 't') + r = 10; + else if (c == 'X' || c == 'x') + r = 16; + else { + r = db_radix; + db_unread_char(c); + } + c = db_read_char(); } - c = db_read_char(); - } - db_tok_number = 0; - for (;;) { - if (c >= '0' && c <= ((r == 8) ? '7' : '9')) - digit = c - '0'; - else if (r == 16 && ((c >= 'A' && c <= 'F') || - (c >= 'a' && c <= 'f'))) { - if (c >= 'a') - digit = c - 'a' + 10; - else if (c >= 'A') - digit = c - 'A' + 10; + db_tok_number = 0; + for (;;) { + if (c >= '0' && c <= ((r == 8) ? '7' : '9')) + digit = c - '0'; + else if (r == 16 && ((c >= 'A' && c <= 'F') || + (c >= 'a' && c <= 'f'))) { + if (c >= 'a') + digit = c - 'a' + 10; + else if (c >= 'A') + digit = c - 'A' + 10; + } else + break; + db_tok_number = db_tok_number * r + digit; + c = db_read_char(); } - else - break; - db_tok_number = db_tok_number * r + digit; - c = db_read_char(); - } - if ((c >= '0' && c <= '9') || - (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c == '_')) - { - db_error("Bad character in number\n"); - /*NOTREACHED*/ - } - db_unread_char(c); - return (tNUMBER); + if ((c >= '0' && c <= '9') || + (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || + (c == '_')) { + db_error("Bad character in number\n"); + /*NOTREACHED*/ + } + db_unread_char(c); + return (tNUMBER); } if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || - c == '_' || c == '\\') - { - /* string */ - char *cp; + c == '_' || c == '\\') { + /* string */ + char *cp; - cp = db_tok_string; - if (c == '\\') { - c = db_read_char(); - if (c == '\n' || c == -1) { - db_error("Bad escape\n"); - /*NOTREACHED*/ - } - } - *cp++ = c; - while (1) { - c = db_read_char(); - if ((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9') || - c == '_' || c == '\\' || c == ':') - { - if (c == '\\') { + cp = db_tok_string; + if (c == '\\') { c = db_read_char(); if (c == '\n' || c == -1) { - db_error("Bad escape\n"); - /*NOTREACHED*/ + db_error("Bad escape\n"); + /*NOTREACHED*/ } - } - *cp++ = c; - if (cp == db_tok_string+sizeof(db_tok_string)) { - db_error("String too long\n"); - /*NOTREACHED*/ - } - continue; } - else { - *cp = '\0'; - break; + *cp++ = c; + while (1) { + c = db_read_char(); + if ((c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9') || + c == '_' || c == '\\' || c == ':') { + if (c == '\\') { + c = db_read_char(); + if (c == '\n' || c == -1) { + db_error("Bad escape\n"); + /*NOTREACHED*/ + } + } + *cp++ = c; + if (cp == db_tok_string+sizeof(db_tok_string)) { + db_error("String too long\n"); + /*NOTREACHED*/ + } + continue; + } else { + *cp = '\0'; + break; + } } - } - db_unread_char(c); - return (tIDENT); + db_unread_char(c); + return (tIDENT); } switch (c) { - case '+': + case '+': return (tPLUS); - case '-': + case '-': return (tMINUS); - case '.': + case '.': c = db_read_char(); if (c == '.') - return (tDOTDOT); + return (tDOTDOT); db_unread_char(c); return (tDOT); - case '*': + case '*': return (tSTAR); - case '/': + case '/': return (tSLASH); - case '=': + case '=': return (tEQ); - case '%': + case '%': return (tPCT); - case '#': + case '#': return (tHASH); - case '(': + case '(': return (tLPAREN); - case ')': + case ')': return (tRPAREN); - case ',': + case ',': return (tCOMMA); - case '"': + case '"': return (tDITTO); - case '$': + case '$': return (tDOLLAR); - case '!': + case '!': return (tEXCL); - case '<': + case '<': c = db_read_char(); if (c == '<') - return (tSHIFT_L); + return (tSHIFT_L); db_unread_char(c); break; - case '>': + case '>': c = db_read_char(); if (c == '>') - return (tSHIFT_R); + return (tSHIFT_R); db_unread_char(c); break; - case -1: + case -1: return (tEOF); } db_printf("Bad character\n"); diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index e92c8041450..77fd0e34944 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_output.c,v 1.34 2020/01/20 15:58:23 visa Exp $ */ +/* $OpenBSD: db_output.c,v 1.35 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_output.c,v 1.13 1996/04/01 17:27:14 christos Exp $ */ /* @@ -90,17 +90,16 @@ db_force_whitespace(void) last_print = db_last_non_space; while (last_print < db_output_position) { - next_tab = NEXT_TAB(last_print); - if (next_tab <= db_output_position) { - while (last_print < next_tab) { /* DON'T send a tab!!! */ + next_tab = NEXT_TAB(last_print); + if (next_tab <= db_output_position) { + while (last_print < next_tab) { /* DON'T send a tab!!! */ + cnputc(' '); + last_print++; + } + } else { cnputc(' '); last_print++; } - } - else { - cnputc(' '); - last_print++; - } } db_last_non_space = db_output_position; } @@ -112,26 +111,26 @@ db_more(void) int quit_output = 0; for (p = "--db_more--"; *p; p++) - cnputc(*p); + cnputc(*p); switch(cngetc()) { case ' ': - db_output_line = 0; - break; + db_output_line = 0; + break; case 'q': case CTRL('c'): - db_output_line = 0; - quit_output = 1; - break; + db_output_line = 0; + quit_output = 1; + break; default: - db_output_line--; - break; + db_output_line--; + break; } p = "\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"; while (*p) - cnputc(*p++); + cnputc(*p++); if (quit_output) { - db_error(0); - /* NOTREACHED */ + db_error(0); + /* NOTREACHED */ } } @@ -142,45 +141,41 @@ void db_putchar(int c) { if (db_max_line >= DB_MIN_MAX_LINE && db_output_line >= db_max_line-1) - db_more(); + db_more(); if (c > ' ' && c <= '~') { - /* - * Printing character. - * If we have spaces to print, print them first. - * Use tabs if possible. - */ - db_force_whitespace(); - cnputc(c); - db_output_position++; - if (db_max_width >= DB_MIN_MAX_WIDTH - && db_output_position >= db_max_width-1) { - /* auto new line */ - cnputc('\n'); + /* + * Printing character. + * If we have spaces to print, print them first. + * Use tabs if possible. + */ + db_force_whitespace(); + cnputc(c); + db_output_position++; + if (db_max_width >= DB_MIN_MAX_WIDTH && + db_output_position >= db_max_width-1) { + /* auto new line */ + cnputc('\n'); + db_output_position = 0; + db_last_non_space = 0; + db_output_line++; + } + db_last_non_space = db_output_position; + } else if (c == '\n') { + /* Return */ + cnputc(c); db_output_position = 0; db_last_non_space = 0; db_output_line++; - } - db_last_non_space = db_output_position; - } - else if (c == '\n') { - /* Return */ - cnputc(c); - db_output_position = 0; - db_last_non_space = 0; - db_output_line++; - } - else if (c == '\t') { - /* assume tabs every 8 positions */ - db_output_position = NEXT_TAB(db_output_position); - } - else if (c == ' ') { - /* space */ - db_output_position++; - } - else if (c == '\007') { - /* bell */ - cnputc(c); + } else if (c == '\t') { + /* assume tabs every 8 positions */ + db_output_position = NEXT_TAB(db_output_position); + } else if (c == ' ') { + /* space */ + db_output_position++; + } else if (c == '\007') { + /* bell */ + cnputc(c); } /* other characters are assumed non-printing */ } @@ -201,7 +196,7 @@ void db_end_line(int space) { if (db_output_position >= db_max_width - space) - db_printf("\n"); + db_printf("\n"); } char * @@ -223,7 +218,6 @@ db_format(char *buf, size_t bufsize, long val, int format, int alt, int width) fmt++; snprintf(buf, bufsize, fmt, width, val); - return (buf); } diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c index 0d546ed5c20..8fd6be122d0 100644 --- a/sys/ddb/db_run.c +++ b/sys/ddb/db_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_run.c,v 1.29 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_run.c,v 1.30 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_run.c,v 1.8 1996/02/05 01:57:12 christos Exp $ */ /* @@ -137,37 +137,37 @@ db_stop_at_pc(db_regs_t *regs, int *is_breakpoint) } } if (db_run_mode == STEP_RETURN) { - db_expr_t ins = db_get_value(pc, sizeof(int), 0); - - /* continue until matching return */ - - if (!inst_trap_return(ins) && - (!inst_return(ins) || --db_call_depth != 0)) { - if (db_sstep_print) { - if (inst_call(ins) || inst_return(ins)) { - int i; - - db_printf("[after %6d] ", db_inst_count); - for (i = db_call_depth; --i > 0; ) - db_printf(" "); - db_print_loc_and_inst(pc); - db_printf("\n"); - } + db_expr_t ins = db_get_value(pc, sizeof(int), 0); + + /* continue until matching return */ + + if (!inst_trap_return(ins) && + (!inst_return(ins) || --db_call_depth != 0)) { + if (db_sstep_print) { + if (inst_call(ins) || inst_return(ins)) { + int i; + + db_printf("[after %6d] ", db_inst_count); + for (i = db_call_depth; --i > 0; ) + db_printf(" "); + db_print_loc_and_inst(pc); + db_printf("\n"); + } + } + if (inst_call(ins)) + db_call_depth++; + return 0; /* continue */ } - if (inst_call(ins)) - db_call_depth++; - return 0; /* continue */ - } } if (db_run_mode == STEP_CALLT) { - db_expr_t ins = db_get_value(pc, sizeof(int), 0); + db_expr_t ins = db_get_value(pc, sizeof(int), 0); - /* continue until call or return */ + /* continue until call or return */ - if (!inst_call(ins) && !inst_return(ins) && - !inst_trap_return(ins)) { - return 0; /* continue */ - } + if (!inst_call(ins) && !inst_return(ins) && + !inst_trap_return(ins)) { + return 0; /* continue */ + } } db_run_mode = STEP_NONE; return 1; @@ -218,8 +218,8 @@ void db_single_step(db_regs_t *regs) { if (db_run_mode == STEP_CONTINUE) { - db_run_mode = STEP_INVISIBLE; - db_set_single_step(regs); + db_run_mode = STEP_INVISIBLE; + db_set_single_step(regs); } } @@ -231,10 +231,10 @@ db_single_step_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) int print = 0; if (count == -1) - count = 1; + count = 1; if (modif[0] == 'p') - print = 1; + print = 1; db_run_mode = STEP_ONCE; db_loop_count = count; @@ -253,7 +253,7 @@ db_trace_until_call_cmd(db_expr_t addr, int have_addr, db_expr_t count, int print = 0; if (modif[0] == 'p') - print = 1; + print = 1; db_run_mode = STEP_CALLT; db_sstep_print = print; @@ -270,7 +270,7 @@ db_trace_until_matching_cmd(db_expr_t addr, int have_addr, db_expr_t count, int print = 0; if (modif[0] == 'p') - print = 1; + print = 1; db_run_mode = STEP_RETURN; db_call_depth = 1; @@ -286,9 +286,9 @@ void db_continue_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { if (modif[0] == 'c') - db_run_mode = STEP_COUNT; + db_run_mode = STEP_COUNT; else - db_run_mode = STEP_CONTINUE; + db_run_mode = STEP_CONTINUE; db_inst_count = 0; db_cmd_loop_done = 1; @@ -340,13 +340,13 @@ db_set_single_step(db_regs_t *regs) */ inst = db_get_value(pc, sizeof(int), 0); if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) { - brpc = branch_taken(inst, pc, getreg_val, regs); - if (brpc != pc) { /* self-branches are hopeless */ - db_taken_bkpt = db_set_temp_breakpoint(brpc); - } + brpc = branch_taken(inst, pc, getreg_val, regs); + if (brpc != pc) { /* self-branches are hopeless */ + db_taken_bkpt = db_set_temp_breakpoint(brpc); + } #if 0 - /* XXX this seems like a true bug, no? */ - pc = next_instr_address(pc, 1); + /* XXX this seems like a true bug, no? */ + pc = next_instr_address(pc, 1); #endif } #endif /*SOFTWARE_SSTEP_EMUL*/ @@ -358,12 +358,12 @@ void db_clear_single_step(db_regs_t *regs) { if (db_taken_bkpt != 0) { - db_delete_temp_breakpoint(db_taken_bkpt); - db_taken_bkpt = 0; + db_delete_temp_breakpoint(db_taken_bkpt); + db_taken_bkpt = 0; } if (db_not_taken_bkpt != 0) { - db_delete_temp_breakpoint(db_not_taken_bkpt); - db_not_taken_bkpt = 0; + db_delete_temp_breakpoint(db_not_taken_bkpt); + db_not_taken_bkpt = 0; } } diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index 00d363f5b7f..c8ebce83fec 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_sym.c,v 1.54 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_sym.c,v 1.55 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_sym.c,v 1.24 2000/08/11 22:50:47 tv Exp $ */ /* @@ -85,9 +85,9 @@ int db_eqname(char *src, char *dst, int c) { if (!strcmp(src, dst)) - return (1); + return (1); if (src[0] == c) - return (!strcmp(src+1,dst)); + return (!strcmp(src+1,dst)); return (0); } @@ -139,10 +139,10 @@ db_printsym(db_expr_t off, db_strategy_t strategy, int (*pr)(const char *, ...)) { db_expr_t d; - char *filename; + char *filename; char *name; db_expr_t value; - int linenum; + int linenum; Elf_Sym *cursym; char buf[DB_FORMAT_BUF_SIZE]; diff --git a/sys/ddb/db_var.h b/sys/ddb/db_var.h index cfb76a81bbd..a947db6bb39 100644 --- a/sys/ddb/db_var.h +++ b/sys/ddb/db_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_var.h,v 1.13 2019/07/20 23:06:51 mpi Exp $ */ +/* $OpenBSD: db_var.h,v 1.14 2020/10/15 03:14:00 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff. All rights reserved. @@ -70,7 +70,7 @@ extern int db_log; extern int db_profile; int ddb_sysctl(int *, u_int, void *, size_t *, void *, size_t, - struct proc *); + struct proc *); #endif #endif /* _DDB_DB_VAR_H_ */ diff --git a/sys/ddb/db_variables.c b/sys/ddb/db_variables.c index 40c921f9255..933a9091543 100644 --- a/sys/ddb/db_variables.c +++ b/sys/ddb/db_variables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_variables.c,v 1.20 2019/02/15 18:34:59 anton Exp $ */ +/* $OpenBSD: db_variables.c,v 1.21 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_variables.c,v 1.8 1996/02/05 01:57:19 christos Exp $ */ /* @@ -57,18 +57,18 @@ db_find_variable(struct db_variable **varp) t = db_read_token(); if (t == tIDENT) { - for (vp = db_vars; vp < db_evars; vp++) { - if (!strcmp(db_tok_string, vp->name)) { - *varp = vp; - return (1); + for (vp = db_vars; vp < db_evars; vp++) { + if (!strcmp(db_tok_string, vp->name)) { + *varp = vp; + return (1); + } } - } - for (vp = db_regs; vp < db_eregs; vp++) { - if (!strcmp(db_tok_string, vp->name)) { - *varp = vp; - return (1); + for (vp = db_regs; vp < db_eregs; vp++) { + if (!strcmp(db_tok_string, vp->name)) { + *varp = vp; + return (1); + } } - } } db_error("Unknown variable\n"); /*NOTREACHED*/ @@ -81,7 +81,7 @@ db_get_variable(db_expr_t *valuep) struct db_variable *vp; if (!db_find_variable(&vp)) - return (0); + return (0); db_read_variable(vp, valuep); @@ -94,7 +94,7 @@ db_set_variable(db_expr_t value) struct db_variable *vp; if (!db_find_variable(&vp)) - return (0); + return (0); db_write_variable(vp, &value); @@ -108,9 +108,9 @@ db_read_variable(struct db_variable *vp, db_expr_t *valuep) int (*func)(struct db_variable *, db_expr_t *, int) = vp->fcn; if (func == FCN_NULL) - *valuep = *(vp->valuep); + *valuep = *(vp->valuep); else - (*func)(vp, valuep, DB_VAR_GET); + (*func)(vp, valuep, DB_VAR_GET); } void @@ -119,9 +119,9 @@ db_write_variable(struct db_variable *vp, db_expr_t *valuep) int (*func)(struct db_variable *, db_expr_t *, int) = vp->fcn; if (func == FCN_NULL) - *(vp->valuep) = *valuep; + *(vp->valuep) = *valuep; else - (*func)(vp, valuep, DB_VAR_SET); + (*func)(vp, valuep, DB_VAR_SET); } /*ARGSUSED*/ @@ -134,25 +134,25 @@ db_set_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) t = db_read_token(); if (t != tDOLLAR) { - db_error("Unknown variable\n"); - /*NOTREACHED*/ + db_error("Unknown variable\n"); + /*NOTREACHED*/ } if (!db_find_variable(&vp)) { - db_error("Unknown variable\n"); - /*NOTREACHED*/ + db_error("Unknown variable\n"); + /*NOTREACHED*/ } t = db_read_token(); if (t != tEQ) - db_unread_token(t); + db_unread_token(t); if (!db_expression(&value)) { - db_error("No value\n"); - /*NOTREACHED*/ + db_error("No value\n"); + /*NOTREACHED*/ } if (db_read_token() != tEOL) { - db_error("?\n"); - /*NOTREACHED*/ + db_error("?\n"); + /*NOTREACHED*/ } db_write_variable(vp, &value); diff --git a/sys/ddb/db_watch.c b/sys/ddb/db_watch.c index ee63fd166d5..cae2307f7d9 100644 --- a/sys/ddb/db_watch.c +++ b/sys/ddb/db_watch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_watch.c,v 1.17 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_watch.c,v 1.18 2020/10/15 03:14:00 deraadt Exp $ */ /* $NetBSD: db_watch.c,v 1.9 1996/03/30 22:30:12 christos Exp $ */ /* @@ -62,12 +62,12 @@ db_watchpoint_alloc(void) db_watchpoint_t watch; if ((watch = db_free_watchpoints) != 0) { - db_free_watchpoints = watch->link; - return (watch); + db_free_watchpoints = watch->link; + return (watch); } if (db_next_free_watchpoint == &db_watch_table[NWATCHPOINTS]) { - db_printf("All watchpoints used.\n"); - return (0); + db_printf("All watchpoints used.\n"); + return (0); } watch = db_next_free_watchpoint; db_next_free_watchpoint++; @@ -119,7 +119,7 @@ db_delete_watchpoint(vaddr_t addr) db_watchpoint_t *prev; for (prev = &db_watchpoint_list; (watch = *prev) != 0; - prev = &watch->link) + prev = &watch->link) if (watch->loaddr <= addr && addr < watch->hiaddr) { *prev = watch->link; db_watchpoint_free(watch); @@ -135,8 +135,8 @@ db_list_watchpoints(void) db_watchpoint_t watch; if (db_watchpoint_list == 0) { - db_printf("No watchpoints set\n"); - return; + db_printf("No watchpoints set\n"); + return; } db_printf(" Address Size\n"); @@ -158,13 +158,13 @@ db_deletewatch_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_watchpoint_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { - vsize_t size; + vsize_t size; db_expr_t value; if (db_expression(&value)) - size = (vsize_t) value; + size = (vsize_t) value; else - size = 4; + size = 4; db_skip_to_eol(); db_set_watchpoint(addr, size); |