1.\" $NetBSD: crashme.9,v 1.2 2019/01/09 09:48:44 wiz Exp $ 2.\" 3.\" Copyright (c) 2019 Matthew R. Green 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. The name of the author may not be used to endorse or promote products 15.\" derived from this software without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd January 7, 2019 30.Dt CRASHME 9 31.Os 32.Sh NAME 33.Nm crashme , 34.Nm crashme_add , 35.Nm crashme_remove 36.Nd in-kernel testing of crash handling 37.Sh SYNOPSIS 38.In sys/crashme.h 39.Ft int 40.Fn crashme_add "crashme_node *cn" 41.Ft int 42.Fn crashme_remove "crashme_node *cn" 43.Sh DESCRIPTION 44The 45.Nm 46functions provide access to dynamically add and remove crashme nodes. 47These nodes are simply named callbacks that are expected to cause the 48system to crash. 49.Pp 50The crashme functionality is only available in kernels with the 51.Xr options 4 52.Dv DEBUG 53option set. 54.Pp 55Each crashme node is maintained in a 56.Vt crashme_node 57structure which has the following public members: 58.Bd -literal 59typedef int (*crashme_fn)(int); 60 61typedef struct crashme_node { 62 const char *cn_name; 63 const char *cn_longname; 64 crashme_fn cn_fn; 65} crashme_node; 66.Ed 67.Pp 68The 69caller must fill in the 70.Fa cn_name , 71.Fa cn_longname , 72and 73.Fa cn_fn 74members. 75.Pp 76The 77.Ar flags 78parameter is passed from sysctl. 79The return value is 0 upon success or non zero for failure. 80.Sh SYSCTL SUPPORT 81The following 82.Xr sysctl 8 83variables are provided by the 84.Nm 85subsystem: 86.Bl -tag -width "123456" -offset indent 87.It Ic debug.crashme_enable 88Must be set to 1 for any 89.Nm 90node to be executed. 91.It Ic debug.crashme.panic 92Basic panic node. 93.It Ic debug.crashme.null_deref 94Dereference 95.Dv NULL 96node. 97.El 98.Sh SEE ALSO 99.Xr options 4 , 100.Xr panic 9 101.Sh HISTORY 102The 103.Nm 104driver appeared in 105.Nx 9.0 . 106.Sh AUTHORS 107.An Matthew R. Green 108