Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157468441
D35356.id107232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D35356.id107232.diff
View Options
diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h
new file mode 100644
--- /dev/null
+++ b/usr.bin/kdump/kdump.h
@@ -0,0 +1,79 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __KDUMP_H__
+#define __KDUMP_H__
+
+extern bool decimal, fancy, resolv;
+
+#define print_number64(first,i,n,c) do { \
+ uint64_t __v; \
+ \
+ if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \
+ (i)++; \
+ (n)--; \
+ } \
+ if (quad_slots == 2) \
+ __v = (uint64_t)(uint32_t)(i)[0] | \
+ ((uint64_t)(uint32_t)(i)[1]) << 32; \
+ else \
+ __v = (uint64_t)*(i); \
+ if (decimal) \
+ printf("%c%jd", (c), (intmax_t)__v); \
+ else \
+ printf("%c%#jx", (c), (uintmax_t)__v); \
+ (i) += quad_slots; \
+ (n) -= quad_slots; \
+ (c) = ','; \
+} while (0)
+
+#define print_number(i,n,c) do { \
+ if (decimal) \
+ printf("%c%jd", c, (intmax_t)*i); \
+ else \
+ printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \
+ i++; \
+ n--; \
+ c = ','; \
+} while (0)
+
+void print_integer_arg(const char *(*decoder)(int), int value);
+void print_integer_arg_valid(const char *(*decoder)(int), int value);
+void print_mask_arg(bool (*decoder)(FILE *, int, int *), int value);
+void print_mask_arg0(bool (*decoder)(FILE *, int, int *), int value);
+void print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *),
+ uint32_t value);
+void print_mask_argul(bool (*decoder)(FILE *, u_long, u_long *),
+ u_long value);
+bool print_mask_arg_part(bool (*decoder)(FILE *, int, int *),
+ int value, int *rem);
+
+#endif /* !__KDUMP_H__ */
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -90,6 +90,7 @@
#include <unistd.h>
#include <vis.h>
#include "ktrace.h"
+#include "kdump.h"
#ifdef WITH_CASPER
#include <libcasper.h>
@@ -130,8 +131,8 @@
#define TIMESTAMP_ELAPSED 0x2
#define TIMESTAMP_RELATIVE 0x4
-static bool abiflag, decimal, fancy = true, resolv, suppressdata, syscallno,
- tail, threads;
+bool decimal, fancy = true, resolv;
+static bool abiflag, suppressdata, syscallno, tail, threads;
static int timestamp, maxdata;
static const char *tracefile = DEF_TRACEFILE;
static struct ktr_header ktr_header;
@@ -139,37 +140,6 @@
#define TIME_FORMAT "%b %e %T %Y"
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
-#define print_number64(first,i,n,c) do { \
- uint64_t __v; \
- \
- if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \
- (i)++; \
- (n)--; \
- } \
- if (quad_slots == 2) \
- __v = (uint64_t)(uint32_t)(i)[0] | \
- ((uint64_t)(uint32_t)(i)[1]) << 32; \
- else \
- __v = (uint64_t)*(i); \
- if (decimal) \
- printf("%c%jd", (c), (intmax_t)__v); \
- else \
- printf("%c%#jx", (c), (uintmax_t)__v); \
- (i) += quad_slots; \
- (n) -= quad_slots; \
- (c) = ','; \
-} while (0)
-
-#define print_number(i,n,c) do { \
- if (decimal) \
- printf("%c%jd", c, (intmax_t)*i); \
- else \
- printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \
- i++; \
- n--; \
- c = ','; \
-} while (0)
-
struct proc_info
{
TAILQ_ENTRY(proc_info) info;
@@ -225,7 +195,7 @@
}
#endif /* WITH_CASPER */
-static void
+void
print_integer_arg(const char *(*decoder)(int), int value)
{
const char *str;
@@ -242,7 +212,7 @@
}
/* Like print_integer_arg but unknown values are treated as valid. */
-static void
+void
print_integer_arg_valid(const char *(*decoder)(int), int value)
{
const char *str;
@@ -258,7 +228,7 @@
}
}
-static bool
+bool
print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem)
{
@@ -266,7 +236,7 @@
return (decoder(stdout, value, rem));
}
-static void
+void
print_mask_arg(bool (*decoder)(FILE *, int, int *), int value)
{
bool invalid;
@@ -278,7 +248,7 @@
printf("<invalid>%u", rem);
}
-static void
+void
print_mask_arg0(bool (*decoder)(FILE *, int, int *), int value)
{
bool invalid;
@@ -329,7 +299,7 @@
printf("<invalid>%u", rem);
}
-static void
+void
print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), uint32_t value)
{
bool invalid;
@@ -342,7 +312,7 @@
printf("<invalid>%u", rem);
}
-static void
+void
print_mask_argul(bool (*decoder)(FILE *, u_long, u_long *), u_long value)
{
bool invalid;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 22, 7:19 PM (13 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33428607
Default Alt Text
D35356.id107232.diff (5 KB)
Attached To
Mode
D35356: kdump: For future use extract common code to a separate files
Attached
Detach File
Event Timeline
Log In to Comment