Print this page
Rich's feedback
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/dis/dis_util.c
+++ new/usr/src/cmd/dis/dis_util.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 *
26 - * Copyright 2017 Jason King.
26 + * Copyright 2018 Jason King.
27 27 */
28 28
29 29 #include <dlfcn.h>
30 30 #include <stdarg.h>
31 31 #include <stdio.h>
32 32 #include <stdlib.h>
33 -#include <demangle.h>
34 -#include <sysdemangle.h>
33 +#include <demangle-sys.h>
35 34
36 35 #include "dis_util.h"
37 36
38 37 int g_error; /* global process exit status, set when warn() is called */
39 38
40 39 /*
41 40 * Fatal error. Print out the error with a leading "dis: ", and then exit the
42 41 * program.
43 42 */
44 43 void
45 44 die(const char *fmt, ...)
46 45 {
47 46 va_list ap;
48 47
49 48 (void) fprintf(stderr, "dis: fatal: ");
50 49
51 50 va_start(ap, fmt);
52 51 (void) vfprintf(stderr, fmt, ap);
53 52 va_end(ap);
54 53
55 54 (void) fprintf(stderr, "\n");
56 55
57 56 exit(1);
58 57 }
59 58
60 59 /*
61 60 * Non-fatal error. Print out the error with a leading "dis: ", set the global
62 61 * error flag, and return.
63 62 */
64 63 void
65 64 warn(const char *fmt, ...)
66 65 {
67 66 va_list ap;
68 67
69 68 (void) fprintf(stderr, "dis: warning: ");
70 69
71 70 va_start(ap, fmt);
72 71 (void) vfprintf(stderr, fmt, ap);
73 72 va_end(ap);
74 73
75 74 (void) fprintf(stderr, "\n");
76 75
77 76 g_error = 1;
78 77 }
79 78
80 79 /*
81 80 * Convenience wrapper around malloc() to cleanly exit if any allocation fails.
82 81 */
83 82 void *
84 83 safe_malloc(size_t size)
85 84 {
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
86 85 void *ret;
87 86
88 87 if ((ret = calloc(1, size)) == NULL)
89 88 die("Out of memory");
90 89
91 90 return (ret);
92 91 }
93 92
94 93
95 94 /*
96 - * Since -C flag explicitly says C++, for now at least, force language to
95 + * Since the -C flag explicitly says C++, for now at least, force language to
97 96 * C++
98 97 */
99 98 const char *
100 99 dis_demangle(const char *name)
101 100 {
102 101 static char *demangled_name = NULL;
103 102
104 103 /*
105 104 * Since demangled_name is static, it may be preserved across
106 105 * invocations. As such, make sure any memory that might be present
107 106 * from previous invocations is freed.
108 107 */
109 108 free(demangled_name);
110 109 demangled_name = sysdemangle(name, SYSDEM_LANG_CPP, NULL);
111 110 return ((demangled_name != NULL) ? demangled_name : name);
112 111 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX