From nobody Mon Jul 18 22:06:51 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lmwzc1kWLz1GpLp; Mon, 18 Jul 2022 22:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lmwzc030yz3xvp; Mon, 18 Jul 2022 22:06:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658182012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rvza/c4dMZMppk0NQUpnfjuj3F65BP+5IKr1kZeWZjM=; b=vXkihhaDnaWSRjJpcKKzhTISuPfnl95nFX4bbhK88Xnole44yeMCuA0DbZ3ZzNrqwFb7nG T+ohjLBCgBI/NXiEQ4WTcbyeVhTrMxvwEtQjxdmrqH2Gn/Pzs309uIXi0lbuZ4AogZtvS4 D1adG6mi/vnNzLI+es4n07TtLNvAjcQaOx2uHvl14UKMZFa6nzZN3srTNFw5Haj9iXwEQm xnUD/yfKLnLFq4CWeZTqsbub1pJqZahxUBctPJp2VWueja8WMf6vcRT98BvD7shW6dNa3d YkcQ7ON3k8dpbFwlMbBZd3CZI9Z2RjTEWqvv3NYtTEvp91Ym7QEM4maKqu2GJw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lmwzb5gbPzv4l; Mon, 18 Jul 2022 22:06:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26IM6pM0048111; Mon, 18 Jul 2022 22:06:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26IM6pEu048110; Mon, 18 Jul 2022 22:06:51 GMT (envelope-from git) Date: Mon, 18 Jul 2022 22:06:51 GMT Message-Id: <202207182206.26IM6pEu048110@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Allan Jude Subject: git: bb61cba751b3 - main - ddb: add the DB_CMD_MEMSAFE flag for commands List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: allanjude X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bb61cba751b3b1620d14af987a4025974b4b1b2e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658182012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rvza/c4dMZMppk0NQUpnfjuj3F65BP+5IKr1kZeWZjM=; b=DtIVsONkURCR2ghUj5PLPiILXzKY4zhm9ihKFGtQHcfw/glch1PoCAiMEJsmbEL8/XLT9e NRelNyfn0ptBFamr0TNfGthsni29GUNM8vC2TcicY+4K5ROVylO+rhuGe+XONg6f7XsomJ rHJ8Lw1wZEce5bgMpHhPogAUty8WxyEGh4BHfHv9jabkeY+q9uzbN3R401dmqr7Bgioozg 7EX7I3JpR7ccKG00+WTsdapUcA6/K4VYN2BgN7hG0KDBVXLD86YXVcE8t+F2BxZ97jt1S5 mP7jY63iK5fN2oXS4X3bdB7QD4CRNjgtnWvLK5bUcGyWxSO1lyChgbtrISJVcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658182012; a=rsa-sha256; cv=none; b=YJalP9tiMytiv00UoDc7/F7qCvQ///OYPcksqOiTZp/YOuXbrbyyKOc0ROPxuYKyKviryh xY3plsZbATz8lIHFjZJ3wf2W07zgd+NwEUngjF1Xl5zR/izn7uIF30j8KBZbdK9wmXTw7o cop2qVZaqlHXjVRedl0hyp9AxN9B3kM3sl8ZRNl9DqB8/N2xUKCWtWeUAJB8LhXsbqsup4 394zRD1GwXUeflVvi6fkkjhH+A0m+cNCizHSV95KyBhVVtB6U3jKLdg8uPQZp9tDZHRdlW gaF3GE5U3Lz0882tJItLXvBIZEcTNChQWtKSIyPbPV8EqGX1H3wXxmwt/lRWqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by allanjude: URL: https://cgit.FreeBSD.org/src/commit/?id=bb61cba751b3b1620d14af987a4025974b4b1b2e commit bb61cba751b3b1620d14af987a4025974b4b1b2e Author: Mitchell Horne AuthorDate: 2022-07-18 20:04:24 +0000 Commit: Allan Jude CommitDate: 2022-07-18 22:06:04 +0000 ddb: add the DB_CMD_MEMSAFE flag for commands This flag value can be used to indicate if a command has the property of being "memory safe". In this instance, memory safe means that the command does not allow/enable reads or writes of arbitrary memory, regardless of the arguments passed to it. For example, 'backtrace' is considered a memory-safe command since its output is deterministic, while 'show vnode' is not, since it requires a memory address as an argument and will print the contents beginning at that location. Apply the flag to the "show all" command macros. It is expected that commands added to this table will always exhibit this property. Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35581 --- sys/ddb/ddb.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index 4e63907a6ed0..dce4e80ac117 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -110,13 +110,15 @@ typedef void db_cmdfcn_t(db_expr_t addr, bool have_addr, db_expr_t count, * Command table entry. */ struct db_command { - char * name; /* command name */ + char *name; /* command name */ db_cmdfcn_t *fcn; /* function to call */ - int flag; /* extra info: */ + int flag; #define CS_OWN 0x1 /* non-standard syntax */ #define CS_MORE 0x2 /* standard syntax, but may have other words * at end */ #define CS_SET_DOT 0x100 /* set dot after command */ +#define DB_CMD_MEMSAFE 0x1000 /* Command does not allow reads or writes to + * arbitrary memory. */ struct db_command_table *more; /* another level of command */ LIST_ENTRY(db_command) next; /* next entry in the command table */ }; @@ -180,10 +182,12 @@ _func(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) _DB_SET(_show, alias_name, func_name, db_show_table, flags, NULL) #define DB_SHOW_ALIAS(alias_name, func_name) \ DB_SHOW_ALIAS_FLAGS(alias_name, func_name, 0) -#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ - _DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, 0, NULL) -#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \ - _DB_SET(_show_all, alias_name, func_name, db_show_all_table, 0, NULL) +#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \ + _DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, \ + DB_CMD_MEMSAFE, NULL) +#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \ + _DB_SET(_show_all, alias_name, func_name, db_show_all_table, \ + DB_CMD_MEMSAFE, NULL) extern db_expr_t db_maxoff; extern int db_indent;