Re: CVS commit: src/sys/ddb
On 2020/06/01 9:36, Kamil Rytarowski wrote: If you can find a use-case today in DDB for an exclusive allocator. I have it ready and tested. I intended to use it in ddb for one project, but that project is still unfinished. Good to know! I will ask you when I want it! Thanks, rin
Re: CVS commit: src/sys/ddb
On 01.06.2020 02:31, Rin Okuyama wrote: > On 2020/06/01 9:23, Kamil Rytarowski wrote: >> I wrote a tiny malloc (libc-style) implementation over a small static >> storage (could be over stack or preallocated on the heap) without any >> external dependencies. >> >> Would it be useful for you? > > At the moment, we need buffers only in db_show_callout(), and static > buffers are enough there, IMO. > > However, in future, if we want to add new features that require dynamic > buffer allocation, we need to implement exclusive allocator for DDB. > > Thanks, > rin If you can find a use-case today in DDB for an exclusive allocator. I have it ready and tested. I intended to use it in ddb for one project, but that project is still unfinished. signature.asc Description: OpenPGP digital signature
Re: CVS commit: src/sys/ddb
On 2020/06/01 9:23, Kamil Rytarowski wrote: I wrote a tiny malloc (libc-style) implementation over a small static storage (could be over stack or preallocated on the heap) without any external dependencies. Would it be useful for you? At the moment, we need buffers only in db_show_callout(), and static buffers are enough there, IMO. However, in future, if we want to add new features that require dynamic buffer allocation, we need to implement exclusive allocator for DDB. Thanks, rin
Re: CVS commit: src/sys/ddb
I wrote a tiny malloc (libc-style) implementation over a small static storage (could be over stack or preallocated on the heap) without any external dependencies. Would it be useful for you? On 01.06.2020 01:34, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Sun May 31 23:34:34 UTC 2020 > > Modified Files: > src/sys/ddb: db_kernel.c > > Log Message: > Switch from kmem_intr_alloc(sz, KM_NOSLEEP) to kmem_alloc(sz, KM_SLEEP). > > Clearly document these functions are *not* for DDB session, but for > permanent data storage when initializing DDB. > > > To generate a diff of this commit: > cvs rdiff -u -r1.3 -r1.4 src/sys/ddb/db_kernel.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. > > > Modified files: > > Index: src/sys/ddb/db_kernel.c > diff -u src/sys/ddb/db_kernel.c:1.3 src/sys/ddb/db_kernel.c:1.4 > --- src/sys/ddb/db_kernel.c:1.3 Sun May 31 09:42:46 2020 > +++ src/sys/ddb/db_kernel.c Sun May 31 23:34:34 2020 > @@ -1,4 +1,4 @@ > -/* $NetBSD: db_kernel.c,v 1.3 2020/05/31 09:42:46 rin Exp $*/ > +/* $NetBSD: db_kernel.c,v 1.4 2020/05/31 23:34:34 rin Exp $*/ > > /*- > * Copyright (c) 2009 The NetBSD Foundation, Inc. > @@ -30,7 +30,7 @@ > */ > > #include > -__KERNEL_RCSID(0, "$NetBSD: db_kernel.c,v 1.3 2020/05/31 09:42:46 rin Exp > $"); > +__KERNEL_RCSID(0, "$NetBSD: db_kernel.c,v 1.4 2020/05/31 23:34:34 rin Exp > $"); > > #include > #include > @@ -39,28 +39,33 @@ __KERNEL_RCSID(0, "$NetBSD: db_kernel.c, > > /* > * XXX > - * DDB can be running in the interrupt context, e.g., when activated from > - * console. Therefore, we use kmem_intr_alloc(9) and friends here to avoid > - * assertion failure. > + * These routines are *not* intended for a DDB session: > + * > + * - It disturbes on-going debugged kernel datastructures. > + * > + * - DDB can be running in the interrupt context, e.g., when activated from > + * console. This results in assertion failures in the allocator. > + * > + * Use these only for permanent data storage when initializing DDB. > */ > > void * > db_alloc(size_t sz) > { > > - return kmem_intr_alloc(sz, KM_NOSLEEP); > + return kmem_alloc(sz, KM_SLEEP); > } > > void * > db_zalloc(size_t sz) > { > > - return kmem_intr_zalloc(sz, KM_NOSLEEP); > + return kmem_zalloc(sz, KM_SLEEP); > } > > void > db_free(void *p, size_t sz) > { > > - kmem_intr_free(p, sz); > + kmem_free(p, sz); > } > signature.asc Description: OpenPGP digital signature
CVS commit: src/sys/ddb
Module Name:src Committed By: ad Date: Fri Nov 22 23:01:49 UTC 2019 Modified Files: src/sys/ddb: db_lex.c Log Message: Fix crash(8). Will revisit. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_lex.c diff -u src/sys/ddb/db_lex.c:1.24 src/sys/ddb/db_lex.c:1.25 --- src/sys/ddb/db_lex.c:1.24 Wed Oct 2 09:36:30 2019 +++ src/sys/ddb/db_lex.c Fri Nov 22 23:01:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_lex.c,v 1.24 2019/10/02 09:36:30 rin Exp $ */ +/* $NetBSD: db_lex.c,v 1.25 2019/11/22 23:01:49 ad Exp $ */ /* * Mach Operating System @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.24 2019/10/02 09:36:30 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.25 2019/11/22 23:01:49 ad Exp $"); #include #include @@ -62,11 +62,18 @@ db_read_line(void) { int i; +#ifdef _KERNEL + /* + * crash(8) prints the prompt using libedit. That's why we used to + * print it in db_readline(). But now people are using db_read_line() + * for general purpose input, so.. + */ #ifdef MULTIPROCESSOR db_printf("db{%ld}> ", (long)cpu_number()); #else db_printf("db> "); #endif +#endif i = db_readline(db_line, sizeof(db_line)); if (i == 0) return (0); /* EOI */
CVS commit: src/sys/ddb
Module Name:src Committed By: ad Date: Fri Nov 22 23:01:49 UTC 2019 Modified Files: src/sys/ddb: db_lex.c Log Message: Fix crash(8). Will revisit. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: rin Date: Wed Oct 2 09:36:30 UTC 2019 Modified Files: src/sys/ddb: db_lex.c Log Message: Simplify logic to get rid of implicit dependence on order of ASCII codes of upper and lower cases ('a' > 'A'). Found by the lgtm bot. No functional changes intended. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_lex.c diff -u src/sys/ddb/db_lex.c:1.23 src/sys/ddb/db_lex.c:1.24 --- src/sys/ddb/db_lex.c:1.23 Sun Sep 29 02:00:22 2019 +++ src/sys/ddb/db_lex.c Wed Oct 2 09:36:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_lex.c,v 1.23 2019/09/29 02:00:22 uwe Exp $ */ +/* $NetBSD: db_lex.c,v 1.24 2019/10/02 09:36:30 rin Exp $ */ /* * Mach Operating System @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.23 2019/09/29 02:00:22 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.24 2019/10/02 09:36:30 rin Exp $"); #include #include @@ -210,14 +210,14 @@ db_lex(void) 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') + else if (r == 16) { +if (c >= 'A' && c <= 'F') digit = c - 'A' + 10; - } - else +else if (c >= 'a' && c <= 'f') + digit = c - 'a' + 10; +else + break; + } else break; db_tok_number = db_tok_number * r + digit; c = db_read_char();
CVS commit: src/sys/ddb
Module Name:src Committed By: rin Date: Wed Oct 2 09:36:30 UTC 2019 Modified Files: src/sys/ddb: db_lex.c Log Message: Simplify logic to get rid of implicit dependence on order of ASCII codes of upper and lower cases ('a' > 'A'). Found by the lgtm bot. No functional changes intended. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:49:59 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - don't hide local static variable in the middle of other local variable definitions. While here, get rid of the alignment of variable names. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:49:59 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - don't hide local static variable in the middle of other local variable definitions. While here, get rid of the alignment of variable names. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.163 src/sys/ddb/db_command.c:1.164 --- src/sys/ddb/db_command.c:1.163 Sun Sep 29 02:42:12 2019 +++ src/sys/ddb/db_command.c Sun Sep 29 02:49:59 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.163 2019/09/29 02:42:12 uwe Exp $ */ +/* $NetBSD: db_command.c,v 1.164 2019/09/29 02:49:59 uwe Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.163 2019/09/29 02:42:12 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.164 2019/09/29 02:49:59 uwe Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -820,13 +820,13 @@ db_read_command(void) static void db_command(const struct db_command **last_cmdp) { - const struct db_command *command; static db_expr_t last_count = 0; - db_expr_t addr, count; - bool have_addr; - char modif[TOK_STRING_SIZE]; - int t; + int t; + const struct db_command *command; + db_expr_t addr, count; + bool have_addr; + char modif[TOK_STRING_SIZE]; command = NULL; have_addr = false;
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:42:12 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - make setting have_addr more clear. Don't set it to false that it's already initialized to. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.162 src/sys/ddb/db_command.c:1.163 --- src/sys/ddb/db_command.c:1.162 Sun Sep 29 02:35:39 2019 +++ src/sys/ddb/db_command.c Sun Sep 29 02:42:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.162 2019/09/29 02:35:39 uwe Exp $ */ +/* $NetBSD: db_command.c,v 1.163 2019/09/29 02:42:12 uwe Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.162 2019/09/29 02:35:39 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.163 2019/09/29 02:42:12 uwe Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -823,12 +823,13 @@ db_command(const struct db_command **las const struct db_command *command; static db_expr_t last_count = 0; db_expr_t addr, count; + bool have_addr; char modif[TOK_STRING_SIZE]; - + int t; - bool have_addr = false; command = NULL; + have_addr = false; count = -1; t = db_read_token(); @@ -851,7 +852,6 @@ db_command(const struct db_command **las } } else count = last_count; - have_addr = false; modif[0] = '\0'; db_skip_to_eol(); @@ -898,7 +898,6 @@ db_command(const struct db_command **las have_addr = true; } else { addr = (db_expr_t) db_dot; -have_addr = false; } t = db_read_token();
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:42:12 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - make setting have_addr more clear. Don't set it to false that it's already initialized to. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:35:39 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - make sure count is always initialized. To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:35:39 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: db_command - make sure count is always initialized. To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.161 src/sys/ddb/db_command.c:1.162 --- src/sys/ddb/db_command.c:1.161 Sun Sep 22 12:57:34 2019 +++ src/sys/ddb/db_command.c Sun Sep 29 02:35:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $ */ +/* $NetBSD: db_command.c,v 1.162 2019/09/29 02:35:39 uwe Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.162 2019/09/29 02:35:39 uwe Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -829,7 +829,8 @@ db_command(const struct db_command **las bool have_addr = false; command = NULL; - + count = -1; + t = db_read_token(); if ((t == tEOL) || (t == tCOMMA)) { /* @@ -909,7 +910,6 @@ db_command(const struct db_command **las } } else { db_unread_token(t); -count = -1; } if ((command->flag & CS_MORE) == 0) { db_skip_to_eol();
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:00:22 UTC 2019 Modified Files: src/sys/ddb: db_input.c db_lex.c Log Message: Print db> prompt in db_read_line(), not db_readline(). The former is what DDB repl calls. The latter performs the actual input so let other code use it without the unwanted db> prompt. It's already used by ACPI (and AcpiOsWaitCommandReady supplies its own prompt). I also use it for my uncommitted Forth scripting for DDB. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ddb/db_input.c cvs rdiff -u -r1.22 -r1.23 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Sun Sep 29 02:00:22 UTC 2019 Modified Files: src/sys/ddb: db_input.c db_lex.c Log Message: Print db> prompt in db_read_line(), not db_readline(). The former is what DDB repl calls. The latter performs the actual input so let other code use it without the unwanted db> prompt. It's already used by ACPI (and AcpiOsWaitCommandReady supplies its own prompt). I also use it for my uncommitted Forth scripting for DDB. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ddb/db_input.c cvs rdiff -u -r1.22 -r1.23 src/sys/ddb/db_lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_input.c diff -u src/sys/ddb/db_input.c:1.26 src/sys/ddb/db_input.c:1.27 --- src/sys/ddb/db_input.c:1.26 Tue Aug 31 07:48:23 2010 +++ src/sys/ddb/db_input.c Sun Sep 29 02:00:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_input.c,v 1.26 2010/08/31 07:48:23 enami Exp $ */ +/* $NetBSD: db_input.c,v 1.27 2019/09/29 02:00:22 uwe Exp $ */ /* * Mach Operating System @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_input.c,v 1.26 2010/08/31 07:48:23 enami Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_input.c,v 1.27 2019/09/29 02:00:22 uwe Exp $"); #ifdef _KERNEL_OPT #include "opt_ddbparam.h" @@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_input.c,v #include #include -#include #include @@ -352,11 +351,6 @@ int db_readline(char *lstart, int lsize) { -# ifdef MULTIPROCESSOR - db_printf("db{%ld}> ", (long)cpu_number()); -# else - db_printf("db> "); -# endif db_force_whitespace(); /* synch output position */ db_lbuf_start = lstart; Index: src/sys/ddb/db_lex.c diff -u src/sys/ddb/db_lex.c:1.22 src/sys/ddb/db_lex.c:1.23 --- src/sys/ddb/db_lex.c:1.22 Thu May 26 15:34:14 2011 +++ src/sys/ddb/db_lex.c Sun Sep 29 02:00:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_lex.c,v 1.22 2011/05/26 15:34:14 joerg Exp $ */ +/* $NetBSD: db_lex.c,v 1.23 2019/09/29 02:00:22 uwe Exp $ */ /* * Mach Operating System @@ -34,10 +34,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.22 2011/05/26 15:34:14 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.23 2019/09/29 02:00:22 uwe Exp $"); #include #include +#include #include @@ -61,6 +62,11 @@ db_read_line(void) { int i; +#ifdef MULTIPROCESSOR + db_printf("db{%ld}> ", (long)cpu_number()); +#else + db_printf("db> "); +#endif i = db_readline(db_line, sizeof(db_line)); if (i == 0) return (0); /* EOI */
CVS commit: src/sys/ddb
Module Name:src Committed By: mrg Date: Sun Sep 22 12:57:34 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: fix "show kernhist". set addr = 0 if we don't have_addr and avoid using random garbage in addr. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: mrg Date: Sun Sep 22 12:57:34 UTC 2019 Modified Files: src/sys/ddb: db_command.c Log Message: fix "show kernhist". set addr = 0 if we don't have_addr and avoid using random garbage in addr. To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.160 src/sys/ddb/db_command.c:1.161 --- src/sys/ddb/db_command.c:1.160 Mon Sep 17 01:49:54 2018 +++ src/sys/ddb/db_command.c Sun Sep 22 12:57:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.160 2018/09/17 01:49:54 kre Exp $ */ +/* $NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.160 2018/09/17 01:49:54 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.161 2019/09/22 12:57:34 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -1241,6 +1241,8 @@ db_kernhist_print_cmd(db_expr_t addr, bo db_expr_t count, const char *modif) { + if (!have_addr) + addr = 0; kernhist_print((void *)(uintptr_t)addr, count, modif, db_printf); } #endif
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Thu Sep 12 18:43:02 UTC 2019 Modified Files: src/sys/ddb: db_output.c Log Message: db_putchar - check if we need to wrap at $maxwidth after whitespace. That fixes orphaned first character in something like: |Stopped in ... longsymbol+0xf00: | |i |nsn To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/ddb/db_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: uwe Date: Thu Sep 12 18:43:02 UTC 2019 Modified Files: src/sys/ddb: db_output.c Log Message: db_putchar - check if we need to wrap at $maxwidth after whitespace. That fixes orphaned first character in something like: |Stopped in ... longsymbol+0xf00: | |i |nsn To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/ddb/db_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_output.c diff -u src/sys/ddb/db_output.c:1.34 src/sys/ddb/db_output.c:1.35 --- src/sys/ddb/db_output.c:1.34 Sun Sep 16 23:18:55 2018 +++ src/sys/ddb/db_output.c Thu Sep 12 18:43:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_output.c,v 1.34 2018/09/16 23:18:55 mrg Exp $ */ +/* $NetBSD: db_output.c,v 1.35 2019/09/12 18:43:02 uwe Exp $ */ /* * Mach Operating System @@ -35,7 +35,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.34 2018/09/16 23:18:55 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.35 2019/09/12 18:43:02 uwe Exp $"); #include #include @@ -103,6 +103,24 @@ db_force_whitespace(void) db_last_non_space = db_output_position; } + +/* + * End the current line if we it exceeds $maxwidth + */ +static void +db_check_wrap(void) +{ + + if (db_max_width >= DB_MIN_MAX_WIDTH + && db_output_position >= db_max_width) { + cnputc('\n'); + db_output_position = 0; + db_last_non_space = 0; + db_output_line++; + } +} + + static void db_more(void) { @@ -148,16 +166,10 @@ db_putchar(int c) * Use tabs if possible. */ db_force_whitespace(); + db_check_wrap(); cnputc(c); db_output_position++; - if (db_max_width >= DB_MIN_MAX_WIDTH - && db_output_position >= db_max_width) { - /* auto new line */ - cnputc('\n'); - db_output_position = 0; - db_last_non_space = 0; - db_output_line++; - } + db_check_wrap(); db_last_non_space = db_output_position; } else if (c == '\n') { /* Return */
CVS commit: src/sys/ddb
Module Name:src Committed By: ryo Date: Thu Sep 12 17:09:00 UTC 2019 Modified Files: src/sys/ddb: db_access.c Log Message: db_get_qvalue() with size=8 on 64bit arch returns incorrect value. fixed. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/ddb/db_access.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: ryo Date: Thu Sep 12 17:09:00 UTC 2019 Modified Files: src/sys/ddb: db_access.c Log Message: db_get_qvalue() with size=8 on 64bit arch returns incorrect value. fixed. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/ddb/db_access.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_access.c diff -u src/sys/ddb/db_access.c:1.25 src/sys/ddb/db_access.c:1.26 --- src/sys/ddb/db_access.c:1.25 Thu Sep 12 09:20:23 2019 +++ src/sys/ddb/db_access.c Thu Sep 12 17:09:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $ */ +/* $NetBSD: db_access.c,v 1.26 2019/09/12 17:09:00 ryo Exp $ */ /* * Mach Operating System @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.26 2019/09/12 17:09:00 ryo Exp $"); #if defined(_KERNEL_OPT) #include "opt_kgdb.h" @@ -87,7 +87,7 @@ db_get_qvalue(db_addr_t addr, size_t siz { uint64_t data; - if (sizeof(db_expr_t) >= sizeof(quad_t) || size <= sizeof(db_expr_t)) { + if (size < sizeof(uint64_t)) { if (is_signed) return db_get_value(addr, size, true); return (uint32_t)db_get_value(addr, size, false);
CVS commit: src/sys/ddb
Module Name:src Committed By: ryo Date: Thu Sep 12 09:20:23 UTC 2019 Modified Files: src/sys/ddb: db_access.c db_access.h db_examine.c Log Message: changes of r1.39 was incomplete. only "examin/m" could handle 'q'. added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_access.c cvs rdiff -u -r1.13 -r1.14 src/sys/ddb/db_access.h cvs rdiff -u -r1.39 -r1.40 src/sys/ddb/db_examine.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_access.c diff -u src/sys/ddb/db_access.c:1.24 src/sys/ddb/db_access.c:1.25 --- src/sys/ddb/db_access.c:1.24 Fri Aug 23 14:48:50 2019 +++ src/sys/ddb/db_access.c Thu Sep 12 09:20:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $ */ +/* $NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $ */ /* * Mach Operating System @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.25 2019/09/12 09:20:23 ryo Exp $"); #if defined(_KERNEL_OPT) #include "opt_kgdb.h" @@ -82,6 +82,26 @@ db_get_value(db_addr_t addr, size_t size return (value); } +quad_t +db_get_qvalue(db_addr_t addr, size_t size, bool is_signed) +{ + uint64_t data; + + if (sizeof(db_expr_t) >= sizeof(quad_t) || size <= sizeof(db_expr_t)) { + if (is_signed) + return db_get_value(addr, size, true); + return (uint32_t)db_get_value(addr, size, false); + } + + if (size != sizeof(data)) { + db_error("unnsupported size\n"); + /*NOTREACHED*/ + } + + db_read_bytes(addr, sizeof(data), (char *)); + return data; +} + void db_put_value(db_addr_t addr, size_t size, db_expr_t value) { Index: src/sys/ddb/db_access.h diff -u src/sys/ddb/db_access.h:1.13 src/sys/ddb/db_access.h:1.14 --- src/sys/ddb/db_access.h:1.13 Sat Mar 7 22:02:17 2009 +++ src/sys/ddb/db_access.h Thu Sep 12 09:20:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_access.h,v 1.13 2009/03/07 22:02:17 ad Exp $ */ +/* $NetBSD: db_access.h,v 1.14 2019/09/12 09:20:23 ryo Exp $ */ /* * Mach Operating System @@ -33,6 +33,7 @@ * Data access functions for debugger. */ db_expr_t db_get_value(db_addr_t, size_t, bool); +quad_t db_get_qvalue(db_addr_t, size_t, bool); void db_put_value(db_addr_t, size_t, db_expr_t); void db_read_bytes(db_addr_t, size_t, char *); Index: src/sys/ddb/db_examine.c diff -u src/sys/ddb/db_examine.c:1.39 src/sys/ddb/db_examine.c:1.40 --- src/sys/ddb/db_examine.c:1.39 Tue Sep 10 09:32:05 2019 +++ src/sys/ddb/db_examine.c Thu Sep 12 09:20:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_examine.c,v 1.39 2019/09/10 09:32:05 ryo Exp $ */ +/* $NetBSD: db_examine.c,v 1.40 2019/09/12 09:20:23 ryo Exp $ */ /* * Mach Operating System @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_examine.c,v 1.39 2019/09/10 09:32:05 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_examine.c,v 1.40 2019/09/12 09:20:23 ryo Exp $"); #include #include @@ -70,7 +70,7 @@ static void db_examine(db_addr_t addr, char *fmt, int count) { int i, c; - db_expr_t value; + quad_t value; int size; int width; int bytes; @@ -103,7 +103,7 @@ db_examine(db_addr_t addr, char *fmt, in break; case 'q': /* quad-word */ size = 8; -width = 16; +width = 24; break; case 'L': /* implementation maximum */ size = sizeof value; @@ -114,27 +114,27 @@ db_examine(db_addr_t addr, char *fmt, in break; case 'p': size = sizeof(void *); -value = db_get_value(addr, size, true); +value = db_get_value(addr, size, false); addr += size; db_printf("= 0x%lx ", (long)value); db_printsym((db_addr_t)value, DB_STGY_ANY, db_printf); db_printf("\n"); break; case 'r': /* signed, current radix */ -value = db_get_value(addr, size, true); +value = db_get_qvalue(addr, size, true); addr += size; db_format_radix(tbuf, 24, value, false); db_printf("%-*s", width, tbuf); break; case 'x': /* unsigned hex */ -value = db_get_value(addr, size, false); +value = db_get_qvalue(addr, size, false); addr += size; -db_printf("%-*" DDB_EXPR_FMT "x", width, value); +db_printf("%-*" PRIx64, width, value); break; case 'm': /* hex dump */ /* * Print off in chunks of size. Try to print 16 - * bytes at a time into 4 columns. This + * bytes at a time into 16/size columns. This * loops modify's count extra times in order * to get the nicely formatted lines. */ @@ -152,7 +152,7 @@ db_examine(db_addr_t addr, char *fmt, in 1, false); #endif db_printf( - "%02" DDB_EXPR_FMT "x", + "%02" PRIx64, value); bytes++; if (!(bytes % size)) @@ -174,25 +174,25 @@ db_examine(db_addr_t addr, char *fmt, in
CVS commit: src/sys/ddb
Module Name:src Committed By: ryo Date: Thu Sep 12 09:20:23 UTC 2019 Modified Files: src/sys/ddb: db_access.c db_access.h db_examine.c Log Message: changes of r1.39 was incomplete. only "examin/m" could handle 'q'. added support 'r','x','z','d','u', and 'o' with 'q' modifier on 32bit arch. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_access.c cvs rdiff -u -r1.13 -r1.14 src/sys/ddb/db_access.h cvs rdiff -u -r1.39 -r1.40 src/sys/ddb/db_examine.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: kamil Date: Fri Aug 23 14:48:51 UTC 2019 Modified Files: src/sys/ddb: db_access.c Log Message: Avoids signedness bit shift in db_get_value() Appease UBSan. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/ddb/db_access.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_access.c diff -u src/sys/ddb/db_access.c:1.23 src/sys/ddb/db_access.c:1.24 --- src/sys/ddb/db_access.c:1.23 Sun Feb 4 09:17:54 2018 +++ src/sys/ddb/db_access.c Fri Aug 23 14:48:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_access.c,v 1.23 2018/02/04 09:17:54 mrg Exp $ */ +/* $NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $ */ /* * Mach Operating System @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.23 2018/02/04 09:17:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_access.c,v 1.24 2019/08/23 14:48:50 kamil Exp $"); #if defined(_KERNEL_OPT) #include "opt_kgdb.h" @@ -59,18 +59,21 @@ db_expr_t db_get_value(db_addr_t addr, size_t size, bool is_signed) { char data[sizeof(db_expr_t)] __aligned(sizeof(db_expr_t)); + uintmax_t uvalue; db_expr_t value; size_t i; db_read_bytes(addr, size, data); - value = 0; + uvalue = 0; #if BYTE_ORDER == LITTLE_ENDIAN for (i = size; i-- > 0;) #else /* BYTE_ORDER == BIG_ENDIAN */ for (i = 0; i < size; i++) #endif /* BYTE_ORDER */ - value = (value << 8) + (data[i] & 0xFF); + uvalue = (uvalue << 8) + (data[i] & 0xFF); + + value = (db_expr_t)uvalue; if (size < sizeof(db_expr_t) && is_signed && (value & ((db_expr_t)1 << (8*size - 1 {
CVS commit: src/sys/ddb
Module Name:src Committed By: kamil Date: Fri Aug 23 14:48:51 UTC 2019 Modified Files: src/sys/ddb: db_access.c Log Message: Avoids signedness bit shift in db_get_value() Appease UBSan. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/ddb/db_access.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: mrg Date: Sun Jun 2 06:09:17 UTC 2019 Modified Files: src/sys/ddb: db_interface.h Log Message: add two db_stack_print_trace frontends that emit to the system log or the user's terminal. kind of wrong to be called db_*() when they'll typically be used outside of ddb itself, but db_stacktrace() itself is no different. fix this by making the stack trace support separate from ddb? To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/ddb/db_interface.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: mrg Date: Sun Jun 2 06:09:17 UTC 2019 Modified Files: src/sys/ddb: db_interface.h Log Message: add two db_stack_print_trace frontends that emit to the system log or the user's terminal. kind of wrong to be called db_*() when they'll typically be used outside of ddb itself, but db_stacktrace() itself is no different. fix this by making the stack trace support separate from ddb? To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/ddb/db_interface.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_interface.h diff -u src/sys/ddb/db_interface.h:1.36 src/sys/ddb/db_interface.h:1.37 --- src/sys/ddb/db_interface.h:1.36 Sun Mar 4 07:14:50 2018 +++ src/sys/ddb/db_interface.h Sun Jun 2 06:09:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.h,v 1.36 2018/03/04 07:14:50 mlelstv Exp $ */ +/* $NetBSD: db_interface.h,v 1.37 2019/06/02 06:09:17 mrg Exp $ */ /*- * Copyright (c) 1995 The NetBSD Foundation, Inc. @@ -84,4 +84,12 @@ void db_show_disk(db_expr_t, bool, db_e db_stack_trace_print((db_expr_t)(intptr_t)__builtin_frame_address(0), \ true, 65535, "", printf) +#define db_ustacktrace() \ +db_stack_trace_print((db_expr_t)(intptr_t)__builtin_frame_address(0), \ + true, 65535, "", uprintf) + +#define db_lstacktrace() \ +db_stack_trace_print((db_expr_t)(intptr_t)__builtin_frame_address(0), \ + true, 65535, "", addlog) + #endif /* _DDB_DB_INTERFACE_H_ */
re: CVS commit: src/sys/ddb
"Robert Elz" writes: > Module Name: src > Committed By: kre > Date: Mon Sep 17 01:49:54 UTC 2018 > > Modified Files: > src/sys/ddb: db_command.c > > Log Message: > When this file is used when not building the kernel (eg: /usr/sbin/crash) > make cnpollc() go away. thanks.
Re: CVS commit: src/sys/ddb
Please make sure to update the options(4) and ddb(4) man pages... On Sat, 17 Feb 2018, Sevan Janiyan wrote: Module Name:src Committed By: sevan Date: Sat Feb 17 00:41:09 UTC 2018 Modified Files: src/sys/ddb: db_panic.c db_variables.c ddbvar.h Log Message: Opt to print a backtrace on panic by default with the intention of improving bug reports. Instead of relying on ddb.onpanic=2, introduce a new sysctl called dumpstack to handle this. via channeled through on tech-kern[1] [1] https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023103.html To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ddb/db_panic.c cvs rdiff -u -r1.45 -r1.46 src/sys/ddb/db_variables.c cvs rdiff -u -r1.12 -r1.13 src/sys/ddb/ddbvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. !DSPAM:5a877a2b294491653810109! +--+--++ | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com | | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org | +--+--++
Re: CVS commit: src/sys/ddb
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi Matthew, On 04/02/2018 10:17, matthew green wrote: > Module Name: src Committed By: mrg Date: Sun Feb 4 > 09:17:54 UTC > 2018 > > Modified Files: src/sys/ddb: db_access.c > > Log Message: avoid leftshift of an unsigned value Did you really mean "a signed value" instead? Cheers, - -- khorben -BEGIN PGP SIGNATURE- iQJHBAEBCAAxFiEEjPEp1wC4bxBrX8svMDjL25iGlwMFAlp4QjsTHGtob3JiZW5A ZGVmb3JhLm9yZwAKCRAwOMvbmIaXAzlZEACn+oBbwFad9HHZLls6S/vDW9/Wact2 uluVVU04z5cCHTvCk3/JrrzsTC4WouFxs9/TCxEo0MNnYhtVJYLFun7DS77e/RKk WUzRUEwqGShr16XZlOUqqQU8NmP7G+N6lALG2Zmi38QQCWuvXf9oqVmd8RWuke6o YpcSJbsiEAQTGsfTygKTW1urpZOg7yYxbo0kvrDs73EiGc91bN7s3OkJDRInN9k/ aAxxUovvvIycPejsF8FNdJBv9eSjGqE6yQQjyB7jTcXr/HqUy3IN7ahcBpqda7fr 4zFTENC47t3WbuFgfjiwihplxNS5wbiUgAtrLTp7qNC875iH4sFYody/HxvXmJ36 xiIrBbWusYEelNoiGhhPS8pzDhD8EUkgF0klhfql5vZ5uy5NLjzRvI8I+D7/Zj8g +t8GajfJSa8IHCXPu6QWqw9Pyx6EsxlJAeaPJA+HMFBuTGBWyTWmHFSLLdLfDxTO QQmb2pcj2o3U5ECqQYpvRCJ3Ltto+QOmHCTKlG+PRHXTYfP/RQeCLeMZ9LxsAPhe 9Ht6qcpMGwEDUcyiORXaByDPztEx8w6h6ZauVgt0+Kg7nnF1Nnog8nwMfuZB7cLT LjKcz6Xh9mmdg88hJWWYl1ybah7Ku02HF7jJte8X9UdJEazGkRBpqRAD/In06qDx 4vl2/zpbZrDpWw== =Y54J -END PGP SIGNATURE-
re: CVS commit: src/sys/ddb
> Modified Files: > src/sys/ddb: db_interface.h > > Log Message: > add a simple stacktrace macro thanks! this is always annoying to do. .mrg.
Re: CVS commit: src/sys/ddb
On Sat, Jan 05, 2013 at 22:23:55 -0500, Christos Zoulas wrote: Module Name: src Committed By: christos Date: Sun Jan 6 03:23:55 UTC 2013 Modified Files: src/sys/ddb: db_command.c db_interface.h db_xxx.c Log Message: Add show dmesg that prints the contents of the message buffer. What's wrong with dmesg [count] that has been there for ages? -uwe
Re: CVS commit: src/sys/ddb
Thor Lancelot Simon wrote: Module Name: src Committed By: tls Date: Mon Aug 30 19:23:26 UTC 2010 Modified Files: src/sys/ddb: db_input.c Was there any particular reason for removing the lint directives in this change? Eg: - } while (/*CONSTCOND*/ 0) +} while (0) Cheers, Simon.
Re: CVS commit: src/sys/ddb
On Wed, Sep 01, 2010 at 06:01:23AM +1000, Simon Burge wrote: Thor Lancelot Simon wrote: Module Name:src Committed By: tls Date: Mon Aug 30 19:23:26 UTC 2010 Modified Files: src/sys/ddb: db_input.c Was there any particular reason for removing the lint directives in this change? Eg: - } while (/*CONSTCOND*/ 0) +} while (0) No. Thor
CVS commit: src/sys/ddb
Module Name:src Committed By: tron Date: Tue Feb 2 09:04:14 UTC 2010 Modified Files: src/sys/ddb: db_user.h db_write_cmd.c Log Message: Include ctype.h in the central place which deals with building the kernel debugger as a userland program. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ddb/db_user.h cvs rdiff -u -r1.25 -r1.26 src/sys/ddb/db_write_cmd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ddb
Module Name:src Committed By: tron Date: Mon Feb 1 09:56:58 UTC 2010 Modified Files: src/sys/ddb: db_write_cmd.c Log Message: Include ctype.h if we are not building a kernel to fix the build of crash(8). To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/ddb/db_write_cmd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.