cxxfilt 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,150 @@
1
+ /* <ctype.h> replacement macros.
2
+
3
+ Copyright (C) 2000-2018 Free Software Foundation, Inc.
4
+ Contributed by Zack Weinberg <zackw@stanford.edu>.
5
+
6
+ This file is part of the libiberty library.
7
+ Libiberty is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU Library General Public
9
+ License as published by the Free Software Foundation; either
10
+ version 2 of the License, or (at your option) any later version.
11
+
12
+ Libiberty is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Library General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Library General Public
18
+ License along with libiberty; see the file COPYING.LIB. If
19
+ not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20
+ Boston, MA 02110-1301, USA. */
21
+
22
+ /* This is a compatible replacement of the standard C library's <ctype.h>
23
+ with the following properties:
24
+
25
+ - Implements all isxxx() macros required by C99.
26
+ - Also implements some character classes useful when
27
+ parsing C-like languages.
28
+ - Does not change behavior depending on the current locale.
29
+ - Behaves properly for all values in the range of a signed or
30
+ unsigned char.
31
+
32
+ To avoid conflicts, this header defines the isxxx functions in upper
33
+ case, e.g. ISALPHA not isalpha. */
34
+
35
+ #ifndef SAFE_CTYPE_H
36
+ #define SAFE_CTYPE_H
37
+
38
+ /* Determine host character set. */
39
+ #define HOST_CHARSET_UNKNOWN 0
40
+ #define HOST_CHARSET_ASCII 1
41
+ #define HOST_CHARSET_EBCDIC 2
42
+
43
+ #if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
44
+ && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
45
+ # define HOST_CHARSET HOST_CHARSET_ASCII
46
+ #else
47
+ # if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
48
+ && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
49
+ # define HOST_CHARSET HOST_CHARSET_EBCDIC
50
+ # else
51
+ # define HOST_CHARSET HOST_CHARSET_UNKNOWN
52
+ # endif
53
+ #endif
54
+
55
+ /* Categories. */
56
+
57
+ enum {
58
+ /* In C99 */
59
+ _sch_isblank = 0x0001, /* space \t */
60
+ _sch_iscntrl = 0x0002, /* nonprinting characters */
61
+ _sch_isdigit = 0x0004, /* 0-9 */
62
+ _sch_islower = 0x0008, /* a-z */
63
+ _sch_isprint = 0x0010, /* any printing character including ' ' */
64
+ _sch_ispunct = 0x0020, /* all punctuation */
65
+ _sch_isspace = 0x0040, /* space \t \n \r \f \v */
66
+ _sch_isupper = 0x0080, /* A-Z */
67
+ _sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
68
+
69
+ /* Extra categories useful to cpplib. */
70
+ _sch_isidst = 0x0200, /* A-Za-z_ */
71
+ _sch_isvsp = 0x0400, /* \n \r */
72
+ _sch_isnvsp = 0x0800, /* space \t \f \v \0 */
73
+
74
+ /* Combinations of the above. */
75
+ _sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
76
+ _sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
77
+ _sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
78
+ _sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
79
+ _sch_iscppsp = _sch_isvsp|_sch_isnvsp, /* isspace + \0 */
80
+ _sch_isbasic = _sch_isprint|_sch_iscppsp /* basic charset of ISO C
81
+ (plus ` and @) */
82
+ };
83
+
84
+ /* Character classification. */
85
+ extern const unsigned short _sch_istable[256];
86
+
87
+ #define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
88
+
89
+ #define ISALPHA(c) _sch_test(c, _sch_isalpha)
90
+ #define ISALNUM(c) _sch_test(c, _sch_isalnum)
91
+ #define ISBLANK(c) _sch_test(c, _sch_isblank)
92
+ #define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
93
+ #define ISDIGIT(c) _sch_test(c, _sch_isdigit)
94
+ #define ISGRAPH(c) _sch_test(c, _sch_isgraph)
95
+ #define ISLOWER(c) _sch_test(c, _sch_islower)
96
+ #define ISPRINT(c) _sch_test(c, _sch_isprint)
97
+ #define ISPUNCT(c) _sch_test(c, _sch_ispunct)
98
+ #define ISSPACE(c) _sch_test(c, _sch_isspace)
99
+ #define ISUPPER(c) _sch_test(c, _sch_isupper)
100
+ #define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
101
+
102
+ #define ISIDNUM(c) _sch_test(c, _sch_isidnum)
103
+ #define ISIDST(c) _sch_test(c, _sch_isidst)
104
+ #define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic)
105
+ #define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
106
+ #define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
107
+ #define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
108
+
109
+ /* Character transformation. */
110
+ extern const unsigned char _sch_toupper[256];
111
+ extern const unsigned char _sch_tolower[256];
112
+ #define TOUPPER(c) _sch_toupper[(c) & 0xff]
113
+ #define TOLOWER(c) _sch_tolower[(c) & 0xff]
114
+
115
+ /* Prevent the users of safe-ctype.h from accidently using the routines
116
+ from ctype.h. Initially, the approach was to produce an error when
117
+ detecting that ctype.h has been included. But this was causing
118
+ trouble as ctype.h might get indirectly included as a result of
119
+ including another system header (for instance gnulib's stdint.h).
120
+ So we include ctype.h here and then immediately redefine its macros. */
121
+
122
+ #include <ctype.h>
123
+ #undef isalpha
124
+ #define isalpha(c) do_not_use_isalpha_with_safe_ctype
125
+ #undef isalnum
126
+ #define isalnum(c) do_not_use_isalnum_with_safe_ctype
127
+ #undef iscntrl
128
+ #define iscntrl(c) do_not_use_iscntrl_with_safe_ctype
129
+ #undef isdigit
130
+ #define isdigit(c) do_not_use_isdigit_with_safe_ctype
131
+ #undef isgraph
132
+ #define isgraph(c) do_not_use_isgraph_with_safe_ctype
133
+ #undef islower
134
+ #define islower(c) do_not_use_islower_with_safe_ctype
135
+ #undef isprint
136
+ #define isprint(c) do_not_use_isprint_with_safe_ctype
137
+ #undef ispunct
138
+ #define ispunct(c) do_not_use_ispunct_with_safe_ctype
139
+ #undef isspace
140
+ #define isspace(c) do_not_use_isspace_with_safe_ctype
141
+ #undef isupper
142
+ #define isupper(c) do_not_use_isupper_with_safe_ctype
143
+ #undef isxdigit
144
+ #define isxdigit(c) do_not_use_isxdigit_with_safe_ctype
145
+ #undef toupper
146
+ #define toupper(c) do_not_use_toupper_with_safe_ctype
147
+ #undef tolower
148
+ #define tolower(c) do_not_use_tolower_with_safe_ctype
149
+
150
+ #endif /* SAFE_CTYPE_H */
@@ -0,0 +1,52 @@
1
+ /* xexit.c -- Run any exit handlers, then exit.
2
+ Copyright (C) 1994-2018 Free Software Foundation, Inc.
3
+
4
+ This file is part of the libiberty library.
5
+ Libiberty is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Library General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2 of the License, or (at your option) any later version.
9
+
10
+ Libiberty is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Library General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Library General Public
16
+ License along with libiberty; see the file COPYING.LIB. If not, write
17
+ to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18
+ Boston, MA 02110-1301, USA. */
19
+
20
+ /*
21
+
22
+ @deftypefn Replacement void xexit (int @var{code})
23
+
24
+ Terminates the program. If any functions have been registered with
25
+ the @code{xatexit} replacement function, they will be called first.
26
+ Termination is handled via the system's normal @code{exit} call.
27
+
28
+ @end deftypefn
29
+
30
+ */
31
+
32
+ #ifdef HAVE_CONFIG_H
33
+ #include "config.h"
34
+ #endif
35
+ #include <stdio.h>
36
+ #ifdef HAVE_STDLIB_H
37
+ #include <stdlib.h>
38
+ #endif
39
+ #include "libiberty.h"
40
+
41
+
42
+ /* This variable is set by xatexit if it is called. This way, xmalloc
43
+ doesn't drag xatexit into the link. */
44
+ void (*_xexit_cleanup) (void);
45
+
46
+ void
47
+ xexit (int code)
48
+ {
49
+ if (_xexit_cleanup != NULL)
50
+ (*_xexit_cleanup) ();
51
+ exit (code);
52
+ }
@@ -0,0 +1,184 @@
1
+ /* memory allocation routines with error checking.
2
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
3
+
4
+ This file is part of the libiberty library.
5
+ Libiberty is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Library General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2 of the License, or (at your option) any later version.
9
+
10
+ Libiberty is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Library General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Library General Public
16
+ License along with libiberty; see the file COPYING.LIB. If
17
+ not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18
+ Boston, MA 02110-1301, USA. */
19
+
20
+ /*
21
+
22
+ @deftypefn Replacement void* xmalloc (size_t)
23
+
24
+ Allocate memory without fail. If @code{malloc} fails, this will print
25
+ a message to @code{stderr} (using the name set by
26
+ @code{xmalloc_set_program_name},
27
+ if any) and then call @code{xexit}. Note that it is therefore safe for
28
+ a program to contain @code{#define malloc xmalloc} in its source.
29
+
30
+ @end deftypefn
31
+
32
+ @deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
33
+ Reallocate memory without fail. This routine functions like @code{realloc},
34
+ but will behave the same as @code{xmalloc} if memory cannot be found.
35
+
36
+ @end deftypefn
37
+
38
+ @deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
39
+
40
+ Allocate memory without fail, and set it to zero. This routine functions
41
+ like @code{calloc}, but will behave the same as @code{xmalloc} if memory
42
+ cannot be found.
43
+
44
+ @end deftypefn
45
+
46
+ @deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
47
+
48
+ You can use this to set the name of the program used by
49
+ @code{xmalloc_failed} when printing a failure message.
50
+
51
+ @end deftypefn
52
+
53
+ @deftypefn Replacement void xmalloc_failed (size_t)
54
+
55
+ This function is not meant to be called by client code, and is listed
56
+ here for completeness only. If any of the allocation routines fail, this
57
+ function will be called to print an error message and terminate execution.
58
+
59
+ @end deftypefn
60
+
61
+ */
62
+
63
+ #ifdef HAVE_CONFIG_H
64
+ #include "config.h"
65
+ #endif
66
+ #include "ansidecl.h"
67
+ #include "libiberty.h"
68
+ #include "environ.h"
69
+
70
+ #include <stdio.h>
71
+
72
+ #include <stddef.h>
73
+
74
+ #if VMS
75
+ #include <stdlib.h>
76
+ #include <unixlib.h>
77
+ #else
78
+ /* For systems with larger pointers than ints, these must be declared. */
79
+ # if HAVE_STDLIB_H && HAVE_UNISTD_H && HAVE_DECL_MALLOC \
80
+ && HAVE_DECL_REALLOC && HAVE_DECL_CALLOC && HAVE_DECL_SBRK
81
+ # include <stdlib.h>
82
+ # include <unistd.h>
83
+ # else
84
+ # ifdef __cplusplus
85
+ extern "C" {
86
+ # endif /* __cplusplus */
87
+ void *malloc (size_t);
88
+ void *realloc (void *, size_t);
89
+ void *calloc (size_t, size_t);
90
+ void *sbrk (ptrdiff_t);
91
+ # ifdef __cplusplus
92
+ }
93
+ # endif /* __cplusplus */
94
+ # endif /* HAVE_STDLIB_H ... */
95
+ #endif /* VMS */
96
+
97
+ /* The program name if set. */
98
+ static const char *name = "";
99
+
100
+ #ifdef HAVE_SBRK
101
+ /* The initial sbrk, set when the program name is set. Not used for win32
102
+ ports other than cygwin32. */
103
+ static char *first_break = NULL;
104
+ #endif /* HAVE_SBRK */
105
+
106
+ void
107
+ xmalloc_set_program_name (const char *s)
108
+ {
109
+ name = s;
110
+ #ifdef HAVE_SBRK
111
+ /* Win32 ports other than cygwin32 don't have brk() */
112
+ if (first_break == NULL)
113
+ first_break = (char *) sbrk (0);
114
+ #endif /* HAVE_SBRK */
115
+ }
116
+
117
+ void
118
+ xmalloc_failed (size_t size)
119
+ {
120
+ #ifdef HAVE_SBRK
121
+ size_t allocated;
122
+
123
+ if (first_break != NULL)
124
+ allocated = (char *) sbrk (0) - first_break;
125
+ else
126
+ allocated = (char *) sbrk (0) - (char *) &environ;
127
+ fprintf (stderr,
128
+ "\n%s%sout of memory allocating %lu bytes after a total of %lu bytes\n",
129
+ name, *name ? ": " : "",
130
+ (unsigned long) size, (unsigned long) allocated);
131
+ #else /* HAVE_SBRK */
132
+ fprintf (stderr,
133
+ "\n%s%sout of memory allocating %lu bytes\n",
134
+ name, *name ? ": " : "",
135
+ (unsigned long) size);
136
+ #endif /* HAVE_SBRK */
137
+ xexit (1);
138
+ }
139
+
140
+ PTR
141
+ xmalloc (size_t size)
142
+ {
143
+ PTR newmem;
144
+
145
+ if (size == 0)
146
+ size = 1;
147
+ newmem = malloc (size);
148
+ if (!newmem)
149
+ xmalloc_failed (size);
150
+
151
+ return (newmem);
152
+ }
153
+
154
+ PTR
155
+ xcalloc (size_t nelem, size_t elsize)
156
+ {
157
+ PTR newmem;
158
+
159
+ if (nelem == 0 || elsize == 0)
160
+ nelem = elsize = 1;
161
+
162
+ newmem = calloc (nelem, elsize);
163
+ if (!newmem)
164
+ xmalloc_failed (nelem * elsize);
165
+
166
+ return (newmem);
167
+ }
168
+
169
+ PTR
170
+ xrealloc (PTR oldmem, size_t size)
171
+ {
172
+ PTR newmem;
173
+
174
+ if (size == 0)
175
+ size = 1;
176
+ if (!oldmem)
177
+ newmem = malloc (size);
178
+ else
179
+ newmem = realloc (oldmem, size);
180
+ if (!newmem)
181
+ xmalloc_failed (size);
182
+
183
+ return (newmem);
184
+ }
@@ -0,0 +1,41 @@
1
+ /* xmemdup.c -- Duplicate a memory buffer, using xmalloc.
2
+ This trivial function is in the public domain.
3
+ Jeff Garzik, September 1999. */
4
+
5
+ /*
6
+
7
+ @deftypefn Replacement void* xmemdup (void *@var{input}, @
8
+ size_t @var{copy_size}, size_t @var{alloc_size})
9
+
10
+ Duplicates a region of memory without fail. First, @var{alloc_size} bytes
11
+ are allocated, then @var{copy_size} bytes from @var{input} are copied into
12
+ it, and the new memory is returned. If fewer bytes are copied than were
13
+ allocated, the remaining memory is zeroed.
14
+
15
+ @end deftypefn
16
+
17
+ */
18
+
19
+ #ifdef HAVE_CONFIG_H
20
+ #include "config.h"
21
+ #endif
22
+ #include "ansidecl.h"
23
+ #include "libiberty.h"
24
+
25
+ #include <sys/types.h> /* For size_t. */
26
+ #ifdef HAVE_STRING_H
27
+ #include <string.h>
28
+ #else
29
+ # ifdef HAVE_STRINGS_H
30
+ # include <strings.h>
31
+ # endif
32
+ #endif
33
+
34
+ PTR
35
+ xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
36
+ {
37
+ PTR output = xmalloc (alloc_size);
38
+ if (alloc_size > copy_size)
39
+ memset ((char *) output + copy_size, 0, alloc_size - copy_size);
40
+ return (PTR) memcpy (output, input, copy_size);
41
+ }
@@ -0,0 +1,36 @@
1
+ /* xstrdup.c -- Duplicate a string in memory, using xmalloc.
2
+ This trivial function is in the public domain.
3
+ Ian Lance Taylor, Cygnus Support, December 1995. */
4
+
5
+ /*
6
+
7
+ @deftypefn Replacement char* xstrdup (const char *@var{s})
8
+
9
+ Duplicates a character string without fail, using @code{xmalloc} to
10
+ obtain memory.
11
+
12
+ @end deftypefn
13
+
14
+ */
15
+
16
+ #ifdef HAVE_CONFIG_H
17
+ #include "config.h"
18
+ #endif
19
+ #include <sys/types.h>
20
+ #ifdef HAVE_STRING_H
21
+ #include <string.h>
22
+ #else
23
+ # ifdef HAVE_STRINGS_H
24
+ # include <strings.h>
25
+ # endif
26
+ #endif
27
+ #include "ansidecl.h"
28
+ #include "libiberty.h"
29
+
30
+ char *
31
+ xstrdup (const char *s)
32
+ {
33
+ register size_t len = strlen (s) + 1;
34
+ register char *ret = XNEWVEC (char, len);
35
+ return (char *) memcpy (ret, s, len);
36
+ }
@@ -6,7 +6,7 @@ module CXXFilt
6
6
  attr_reader :doc
7
7
  end
8
8
 
9
- demangler_map = Hash[@demanglers.map do |d|
9
+ @demangler_map = Hash[@demanglers.map do |d|
10
10
  [d.name.to_sym, d]
11
11
  end]
12
12
 
@@ -14,14 +14,14 @@ module CXXFilt
14
14
  @demanglers
15
15
  end
16
16
 
17
- def method_missing(sym, *args)
18
- if demangler_map.include?(sym) then
19
- return demangler_map[sym]
17
+ def self.method_missing(sym, *args)
18
+ if @demangler_map.include?(sym) then
19
+ return @demangler_map[sym]
20
20
  end
21
21
  super
22
22
  end
23
23
 
24
- def respond_to_missing?(sym, include_private=false)
25
- demangler_map.include?(sym) || super
24
+ def self.respond_to_missing?(sym, include_private=false)
25
+ @demangler_map.include?(sym) || super
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module CXXFilt
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxxfilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - misson20000
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2018-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,13 +99,28 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - cxxfilt.gemspec
102
+ - ext/cxxfilt/cp-demangle.c
103
+ - ext/cxxfilt/cp-demangle.h
104
+ - ext/cxxfilt/cp-demint.c
105
+ - ext/cxxfilt/cplus-dem.c
102
106
  - ext/cxxfilt/cxxfilt.c
107
+ - ext/cxxfilt/d-demangle.c
108
+ - ext/cxxfilt/demangle.h
109
+ - ext/cxxfilt/environ.h
103
110
  - ext/cxxfilt/extconf.rb
111
+ - ext/cxxfilt/libiberty.h
112
+ - ext/cxxfilt/rust-demangle.c
113
+ - ext/cxxfilt/safe-ctype.c
114
+ - ext/cxxfilt/safe-ctype.h
115
+ - ext/cxxfilt/xexit.c
116
+ - ext/cxxfilt/xmalloc.c
117
+ - ext/cxxfilt/xmemdup.c
118
+ - ext/cxxfilt/xstrdup.c
104
119
  - lib/cxxfilt/cxxfilt.rb
105
120
  - lib/cxxfilt/version.rb
106
121
  homepage: https://github.com/misson20000/cxxfilt-rb
107
122
  licenses:
108
- - MIT
123
+ - LGPL-2.1-or-later
109
124
  metadata: {}
110
125
  post_install_message:
111
126
  rdoc_options: []
@@ -124,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
139
  version: '0'
125
140
  requirements: []
126
141
  rubyforge_project:
127
- rubygems_version: 2.6.12
142
+ rubygems_version: 2.7.7
128
143
  signing_key:
129
144
  specification_version: 4
130
145
  summary: Demangle C++ symbols