xref: /freebsd/usr.bin/kdump/kdump.h (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1988, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #ifndef __KDUMP_H__
33 #define __KDUMP_H__
34 
35 extern bool decimal, fancy, resolv;
36 
37 #define	print_number64(first,i,n,c) do {				\
38 	uint64_t __v;							\
39 									\
40 	if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) {	\
41 		(i)++;							\
42 		(n)--;							\
43 	}								\
44 	if (quad_slots == 2)						\
45 		__v = (uint64_t)(uint32_t)(i)[0] |			\
46 		    ((uint64_t)(uint32_t)(i)[1]) << 32;			\
47 	else								\
48 		__v = (uint64_t)*(i);					\
49 	if (decimal)							\
50 		printf("%c%jd", (c), (intmax_t)__v);			\
51 	else								\
52 		printf("%c%#jx", (c), (uintmax_t)__v);			\
53 	(i) += quad_slots;						\
54 	(n) -= quad_slots;						\
55 	(c) = ',';							\
56 } while (0)
57 
58 #define print_number(i,n,c) do {					\
59 	if (decimal)							\
60 		printf("%c%jd", c, (intmax_t)*i);			\
61 	else								\
62 		printf("%c%#jx", c, (uintmax_t)(u_register_t)*i);	\
63 	i++;								\
64 	n--;								\
65 	c = ',';							\
66 } while (0)
67 
68 void	decode_filemode(int value);
69 void	print_integer_arg(const char *(*decoder)(int), int value);
70 void	print_integer_arg_valid(const char *(*decoder)(int), int value);
71 void	print_mask_arg(bool (*decoder)(FILE *, int, int *), int value);
72 void	print_mask_arg0(bool (*decoder)(FILE *, int, int *), int value);
73 void	print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *),
74 	    uint32_t value);
75 void	print_mask_argul(bool (*decoder)(FILE *, u_long, u_long *),
76 	    u_long value);
77 bool	print_mask_arg_part(bool (*decoder)(FILE *, int, int *),
78 	    int value, int *rem);
79 
80 #ifdef SYSDECODE_HAVE_LINUX
81 bool ktrstruct_linux(const char *name, const char *data, size_t datalen);
82 void ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip,
83     int *resnarg, char *resc);
84 #ifdef __amd64__
85 void ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip,
86     int *resnarg, char *resc);
87 #endif
88 #endif /* SYSDECODE_HAVE_LINUX */
89 
90 #endif /* !__KDUMP_H__ */
91