mirror of
https://github.com/Obfuscator-Collections/VMProtect.git
synced 2025-08-02 14:00:11 +03:00
first commit
Version 3.x.x
This commit is contained in:
436
third-party/demangle/ansidecl.h
vendored
Normal file
436
third-party/demangle/ansidecl.h
vendored
Normal file
@@ -0,0 +1,436 @@
|
||||
/* ANSI and traditional C compatability macros
|
||||
Copyright (C) 1991-2021 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* ANSI and traditional C compatibility macros
|
||||
|
||||
ANSI C is assumed if __STDC__ is #defined.
|
||||
|
||||
Macro ANSI C definition Traditional C definition
|
||||
----- ---- - ---------- ----------- - ----------
|
||||
PTR `void *' `char *'
|
||||
const not defined `'
|
||||
volatile not defined `'
|
||||
signed not defined `'
|
||||
|
||||
For ease of writing code which uses GCC extensions but needs to be
|
||||
portable to other compilers, we provide the GCC_VERSION macro that
|
||||
simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
|
||||
wrappers around __attribute__. Also, __extension__ will be #defined
|
||||
to nothing if it doesn't work. See below. */
|
||||
|
||||
#ifndef _ANSIDECL_H
|
||||
#define _ANSIDECL_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Every source file includes this file,
|
||||
so they will all get the switch for lint. */
|
||||
/* LINTLIBRARY */
|
||||
|
||||
/* Using MACRO(x,y) in cpp #if conditionals does not work with some
|
||||
older preprocessors. Thus we can't define something like this:
|
||||
|
||||
#define HAVE_GCC_VERSION(MAJOR, MINOR) \
|
||||
(__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
|
||||
|
||||
and then test "#if HAVE_GCC_VERSION(2,7)".
|
||||
|
||||
So instead we use the macro below and test it against specific values. */
|
||||
|
||||
/* This macro simplifies testing whether we are using gcc, and if it
|
||||
is of a particular minimum version. (Both major & minor numbers are
|
||||
significant.) This macro will evaluate to 0 if we are not using
|
||||
gcc at all. */
|
||||
#ifndef GCC_VERSION
|
||||
#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif /* GCC_VERSION */
|
||||
|
||||
#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
|
||||
/* All known AIX compilers implement these things (but don't always
|
||||
define __STDC__). The RISC/OS MIPS compiler defines these things
|
||||
in SVR4 mode, but does not define __STDC__. */
|
||||
/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
|
||||
C++ compilers, does not define __STDC__, though it acts as if this
|
||||
was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
|
||||
|
||||
#define PTR void *
|
||||
|
||||
#undef const
|
||||
#undef volatile
|
||||
#undef signed
|
||||
|
||||
/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
|
||||
it too, but it's not in C89. */
|
||||
#undef inline
|
||||
#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
|
||||
/* it's a keyword */
|
||||
#else
|
||||
# if GCC_VERSION >= 2007
|
||||
# define inline __inline__ /* __inline__ prevents -pedantic warnings */
|
||||
# else
|
||||
# define inline /* nothing */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else /* Not ANSI C. */
|
||||
|
||||
#define PTR char *
|
||||
|
||||
/* some systems define these in header files for non-ansi mode */
|
||||
#undef const
|
||||
#undef volatile
|
||||
#undef signed
|
||||
#undef inline
|
||||
#define const
|
||||
#define volatile
|
||||
#define signed
|
||||
#define inline
|
||||
|
||||
#endif /* ANSI C. */
|
||||
|
||||
/* Define macros for some gcc attributes. This permits us to use the
|
||||
macros freely, and know that they will come into play for the
|
||||
version of gcc in which they are supported. */
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
|
||||
#ifndef ATTRIBUTE_MALLOC
|
||||
# if (GCC_VERSION >= 2096)
|
||||
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
# else
|
||||
# define ATTRIBUTE_MALLOC
|
||||
# endif /* GNUC >= 2.96 */
|
||||
#endif /* ATTRIBUTE_MALLOC */
|
||||
|
||||
/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5. For
|
||||
g++ an attribute on a label must be followed by a semicolon. */
|
||||
#ifndef ATTRIBUTE_UNUSED_LABEL
|
||||
# ifndef __cplusplus
|
||||
# if GCC_VERSION >= 2093
|
||||
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
|
||||
# else
|
||||
# define ATTRIBUTE_UNUSED_LABEL
|
||||
# endif
|
||||
# else
|
||||
# if GCC_VERSION >= 4005
|
||||
# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
|
||||
# else
|
||||
# define ATTRIBUTE_UNUSED_LABEL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Similarly to ARG_UNUSED below. Prior to GCC 3.4, the C++ frontend
|
||||
couldn't parse attributes placed after the identifier name, and now
|
||||
the entire compiler is built with C++. */
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
#if GCC_VERSION >= 3004
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#else
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
#endif /* ATTRIBUTE_UNUSED */
|
||||
|
||||
/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
|
||||
identifier name. */
|
||||
#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
|
||||
# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
|
||||
#else /* !__cplusplus || GNUC >= 3.4 */
|
||||
# define ARG_UNUSED(NAME) NAME
|
||||
#endif /* !__cplusplus || GNUC >= 3.4 */
|
||||
|
||||
#ifndef ATTRIBUTE_NORETURN
|
||||
#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
#endif /* ATTRIBUTE_NORETURN */
|
||||
|
||||
/* Attribute `nonnull' was valid as of gcc 3.3. */
|
||||
#ifndef ATTRIBUTE_NONNULL
|
||||
# if (GCC_VERSION >= 3003)
|
||||
# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
|
||||
# else
|
||||
# define ATTRIBUTE_NONNULL(m)
|
||||
# endif /* GNUC >= 3.3 */
|
||||
#endif /* ATTRIBUTE_NONNULL */
|
||||
|
||||
/* Attribute `returns_nonnull' was valid as of gcc 4.9. */
|
||||
#ifndef ATTRIBUTE_RETURNS_NONNULL
|
||||
# if (GCC_VERSION >= 4009)
|
||||
# define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
|
||||
# else
|
||||
# define ATTRIBUTE_RETURNS_NONNULL
|
||||
# endif /* GNUC >= 4.9 */
|
||||
#endif /* ATTRIBUTE_RETURNS_NONNULL */
|
||||
|
||||
/* Attribute `pure' was valid as of gcc 3.0. */
|
||||
#ifndef ATTRIBUTE_PURE
|
||||
# if (GCC_VERSION >= 3000)
|
||||
# define ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# else
|
||||
# define ATTRIBUTE_PURE
|
||||
# endif /* GNUC >= 3.0 */
|
||||
#endif /* ATTRIBUTE_PURE */
|
||||
|
||||
/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
|
||||
This was the case for the `printf' format attribute by itself
|
||||
before GCC 3.3, but as of 3.3 we need to add the `nonnull'
|
||||
attribute to retain this behavior. */
|
||||
#ifndef ATTRIBUTE_PRINTF
|
||||
#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
|
||||
#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
|
||||
#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
|
||||
#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
|
||||
#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
|
||||
#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_PRINTF */
|
||||
|
||||
/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
|
||||
a function pointer. Format attributes were allowed on function
|
||||
pointers as of gcc 3.1. */
|
||||
#ifndef ATTRIBUTE_FPTR_PRINTF
|
||||
# if (GCC_VERSION >= 3001)
|
||||
# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
|
||||
# else
|
||||
# define ATTRIBUTE_FPTR_PRINTF(m, n)
|
||||
# endif /* GNUC >= 3.1 */
|
||||
# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
|
||||
# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_FPTR_PRINTF */
|
||||
|
||||
/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A
|
||||
NULL format specifier was allowed as of gcc 3.3. */
|
||||
#ifndef ATTRIBUTE_NULL_PRINTF
|
||||
# if (GCC_VERSION >= 3003)
|
||||
# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
|
||||
# else
|
||||
# define ATTRIBUTE_NULL_PRINTF(m, n)
|
||||
# endif /* GNUC >= 3.3 */
|
||||
# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
|
||||
# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
|
||||
# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
|
||||
# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
|
||||
# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
|
||||
#endif /* ATTRIBUTE_NULL_PRINTF */
|
||||
|
||||
/* Attribute `sentinel' was valid as of gcc 3.5. */
|
||||
#ifndef ATTRIBUTE_SENTINEL
|
||||
# if (GCC_VERSION >= 3005)
|
||||
# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
|
||||
# else
|
||||
# define ATTRIBUTE_SENTINEL
|
||||
# endif /* GNUC >= 3.5 */
|
||||
#endif /* ATTRIBUTE_SENTINEL */
|
||||
|
||||
|
||||
#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
|
||||
# if (GCC_VERSION >= 3000)
|
||||
# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
|
||||
# else
|
||||
# define ATTRIBUTE_ALIGNED_ALIGNOF(m)
|
||||
# endif /* GNUC >= 3.0 */
|
||||
#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
|
||||
|
||||
/* Useful for structures whose layout must match some binary specification
|
||||
regardless of the alignment and padding qualities of the compiler. */
|
||||
#ifndef ATTRIBUTE_PACKED
|
||||
# define ATTRIBUTE_PACKED __attribute__ ((packed))
|
||||
#endif
|
||||
|
||||
/* Attribute `hot' and `cold' was valid as of gcc 4.3. */
|
||||
#ifndef ATTRIBUTE_COLD
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_COLD __attribute__ ((__cold__))
|
||||
# else
|
||||
# define ATTRIBUTE_COLD
|
||||
# endif /* GNUC >= 4.3 */
|
||||
#endif /* ATTRIBUTE_COLD */
|
||||
#ifndef ATTRIBUTE_HOT
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_HOT __attribute__ ((__hot__))
|
||||
# else
|
||||
# define ATTRIBUTE_HOT
|
||||
# endif /* GNUC >= 4.3 */
|
||||
#endif /* ATTRIBUTE_HOT */
|
||||
|
||||
/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9. */
|
||||
#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED
|
||||
# if (GCC_VERSION >= 4009)
|
||||
# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
|
||||
# else
|
||||
# define ATTRIBUTE_NO_SANITIZE_UNDEFINED
|
||||
# endif /* GNUC >= 4.9 */
|
||||
#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
|
||||
|
||||
/* Attribute 'nonstring' was valid as of gcc 8. */
|
||||
#ifndef ATTRIBUTE_NONSTRING
|
||||
# if GCC_VERSION >= 8000
|
||||
# define ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
|
||||
# else
|
||||
# define ATTRIBUTE_NONSTRING
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Attribute `alloc_size' was valid as of gcc 4.3. */
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_1
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_2
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_1_2
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_1_2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Attribute `warn_unused_result' was valid as of gcc 3.3. */
|
||||
#ifndef ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
# if GCC_VERSION >= 3003
|
||||
# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
||||
# else
|
||||
# define ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* We use __extension__ in some places to suppress -pedantic warnings
|
||||
about GCC extensions. This feature didn't work properly before
|
||||
gcc 2.8. */
|
||||
#if GCC_VERSION < 2008
|
||||
#define __extension__
|
||||
#endif
|
||||
|
||||
/* This is used to declare a const variable which should be visible
|
||||
outside of the current compilation unit. Use it as
|
||||
EXPORTED_CONST int i = 1;
|
||||
This is because the semantics of const are different in C and C++.
|
||||
"extern const" is permitted in C but it looks strange, and gcc
|
||||
warns about it when -Wc++-compat is not used. */
|
||||
#ifdef __cplusplus
|
||||
#define EXPORTED_CONST extern const
|
||||
#else
|
||||
#define EXPORTED_CONST const
|
||||
#endif
|
||||
|
||||
/* Be conservative and only use enum bitfields with C++ or GCC.
|
||||
FIXME: provide a complete autoconf test for buggy enum bitfields. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define ENUM_BITFIELD(TYPE) enum TYPE
|
||||
#elif (GCC_VERSION > 2000)
|
||||
#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
|
||||
#else
|
||||
#define ENUM_BITFIELD(TYPE) unsigned int
|
||||
#endif
|
||||
|
||||
#if __cpp_constexpr >= 200704
|
||||
#define CONSTEXPR constexpr
|
||||
#else
|
||||
#define CONSTEXPR
|
||||
#endif
|
||||
|
||||
/* C++11 adds the ability to add "override" after an implementation of a
|
||||
virtual function in a subclass, to:
|
||||
(A) document that this is an override of a virtual function
|
||||
(B) allow the compiler to issue a warning if it isn't (e.g. a mismatch
|
||||
of the type signature).
|
||||
|
||||
Similarly, it allows us to add a "final" to indicate that no subclass
|
||||
may subsequently override the vfunc.
|
||||
|
||||
Provide OVERRIDE and FINAL as macros, allowing us to get these benefits
|
||||
when compiling with C++11 support, but without requiring C++11.
|
||||
|
||||
For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables
|
||||
this by default (actually GNU++14). */
|
||||
|
||||
#if defined __cplusplus
|
||||
# if __cplusplus >= 201103
|
||||
/* C++11 claims to be available: use it. Final/override were only
|
||||
implemented in 4.7, though. */
|
||||
# if GCC_VERSION < 4007
|
||||
# define OVERRIDE
|
||||
# define FINAL
|
||||
# else
|
||||
# define OVERRIDE override
|
||||
# define FINAL final
|
||||
# endif
|
||||
# elif GCC_VERSION >= 4007
|
||||
/* G++ 4.7 supports __final in C++98. */
|
||||
# define OVERRIDE
|
||||
# define FINAL __final
|
||||
# else
|
||||
/* No C++11 support; leave the macros empty. */
|
||||
# define OVERRIDE
|
||||
# define FINAL
|
||||
# endif
|
||||
#else
|
||||
/* No C++11 support; leave the macros empty. */
|
||||
# define OVERRIDE
|
||||
# define FINAL
|
||||
#endif
|
||||
|
||||
/* A macro to disable the copy constructor and assignment operator.
|
||||
When building with C++11 and above, the methods are explicitly
|
||||
deleted, causing a compile-time error if something tries to copy.
|
||||
For C++03, this just declares the methods, causing a link-time
|
||||
error if the methods end up called (assuming you don't
|
||||
define them). For C++03, for best results, place the macro
|
||||
under the private: access specifier, like this,
|
||||
|
||||
class name_lookup
|
||||
{
|
||||
private:
|
||||
DISABLE_COPY_AND_ASSIGN (name_lookup);
|
||||
};
|
||||
|
||||
so that most attempts at copy are caught at compile-time. */
|
||||
|
||||
#if __cplusplus >= 201103
|
||||
#define DISABLE_COPY_AND_ASSIGN(TYPE) \
|
||||
TYPE (const TYPE&) = delete; \
|
||||
void operator= (const TYPE &) = delete
|
||||
#else
|
||||
#define DISABLE_COPY_AND_ASSIGN(TYPE) \
|
||||
TYPE (const TYPE&); \
|
||||
void operator= (const TYPE &)
|
||||
#endif /* __cplusplus >= 201103 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ansidecl.h */
|
7001
third-party/demangle/cp-demangle.c
vendored
Normal file
7001
third-party/demangle/cp-demangle.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
201
third-party/demangle/cp-demangle.h
vendored
Normal file
201
third-party/demangle/cp-demangle.h
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/* Internal demangler interface for g++ V3 ABI.
|
||||
Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor <ian@wasabisystems.com>.
|
||||
|
||||
This file is part of the libiberty library, which is part of GCC.
|
||||
|
||||
This file is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU General Public License, the
|
||||
Free Software Foundation gives you unlimited permission to link the
|
||||
compiled version of this file into combinations with other programs,
|
||||
and to distribute those combinations without any restriction coming
|
||||
from the use of this file. (The General Public License restrictions
|
||||
do apply in other respects; for example, they cover modification of
|
||||
the file, and distribution when not linked into a combined
|
||||
executable.)
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* This file provides some definitions shared by cp-demangle.c and
|
||||
cp-demint.c. It should not be included by any other files. */
|
||||
|
||||
/* Information we keep for operators. */
|
||||
|
||||
struct demangle_operator_info
|
||||
{
|
||||
/* Mangled name. */
|
||||
const char *code;
|
||||
/* Real name. */
|
||||
const char *name;
|
||||
/* Length of real name. */
|
||||
int len;
|
||||
/* Number of arguments. */
|
||||
int args;
|
||||
};
|
||||
|
||||
/* How to print the value of a builtin type. */
|
||||
|
||||
enum d_builtin_type_print
|
||||
{
|
||||
/* Print as (type)val. */
|
||||
D_PRINT_DEFAULT,
|
||||
/* Print as integer. */
|
||||
D_PRINT_INT,
|
||||
/* Print as unsigned integer, with trailing "u". */
|
||||
D_PRINT_UNSIGNED,
|
||||
/* Print as long, with trailing "l". */
|
||||
D_PRINT_LONG,
|
||||
/* Print as unsigned long, with trailing "ul". */
|
||||
D_PRINT_UNSIGNED_LONG,
|
||||
/* Print as long long, with trailing "ll". */
|
||||
D_PRINT_LONG_LONG,
|
||||
/* Print as unsigned long long, with trailing "ull". */
|
||||
D_PRINT_UNSIGNED_LONG_LONG,
|
||||
/* Print as bool. */
|
||||
D_PRINT_BOOL,
|
||||
/* Print as float--put value in square brackets. */
|
||||
D_PRINT_FLOAT,
|
||||
/* Print in usual way, but here to detect void. */
|
||||
D_PRINT_VOID
|
||||
};
|
||||
|
||||
/* Information we keep for a builtin type. */
|
||||
|
||||
struct demangle_builtin_type_info
|
||||
{
|
||||
/* Type name. */
|
||||
const char *name;
|
||||
/* Length of type name. */
|
||||
int len;
|
||||
/* Type name when using Java. */
|
||||
const char *java_name;
|
||||
/* Length of java name. */
|
||||
int java_len;
|
||||
/* How to print a value of this type. */
|
||||
enum d_builtin_type_print print;
|
||||
};
|
||||
|
||||
/* The information structure we pass around. */
|
||||
|
||||
struct d_info
|
||||
{
|
||||
/* The string we are demangling. */
|
||||
const char *s;
|
||||
/* The end of the string we are demangling. */
|
||||
const char *send;
|
||||
/* The options passed to the demangler. */
|
||||
int options;
|
||||
/* The next character in the string to consider. */
|
||||
const char *n;
|
||||
/* The array of components. */
|
||||
struct demangle_component *comps;
|
||||
/* The index of the next available component. */
|
||||
int next_comp;
|
||||
/* The number of available component structures. */
|
||||
int num_comps;
|
||||
/* The array of substitutions. */
|
||||
struct demangle_component **subs;
|
||||
/* The index of the next substitution. */
|
||||
int next_sub;
|
||||
/* The number of available entries in the subs array. */
|
||||
int num_subs;
|
||||
/* The last name we saw, for constructors and destructors. */
|
||||
struct demangle_component *last_name;
|
||||
/* A running total of the length of large expansions from the
|
||||
mangled name to the demangled name, such as standard
|
||||
substitutions and builtin types. */
|
||||
int expansion;
|
||||
/* Non-zero if we are parsing an expression. */
|
||||
int is_expression;
|
||||
/* Non-zero if we are parsing the type operand of a conversion
|
||||
operator, but not when in an expression. */
|
||||
int is_conversion;
|
||||
/* 1: using new unresolved-name grammar.
|
||||
-1: using new unresolved-name grammar and saw an unresolved-name.
|
||||
0: using old unresolved-name grammar. */
|
||||
int unresolved_name_state;
|
||||
/* If DMGL_NO_RECURSE_LIMIT is not active then this is set to
|
||||
the current recursion level. */
|
||||
unsigned int recursion_level;
|
||||
};
|
||||
|
||||
/* To avoid running past the ending '\0', don't:
|
||||
- call d_peek_next_char if d_peek_char returned '\0'
|
||||
- call d_advance with an 'i' that is too large
|
||||
- call d_check_char(di, '\0')
|
||||
Everything else is safe. */
|
||||
#define d_peek_char(di) (*((di)->n))
|
||||
#ifndef CHECK_DEMANGLER
|
||||
# define d_peek_next_char(di) ((di)->n[1])
|
||||
# define d_advance(di, i) ((di)->n += (i))
|
||||
#endif
|
||||
#define d_check_char(di, c) (d_peek_char(di) == c ? ((di)->n++, 1) : 0)
|
||||
#define d_next_char(di) (d_peek_char(di) == '\0' ? '\0' : *((di)->n++))
|
||||
#define d_str(di) ((di)->n)
|
||||
|
||||
#ifdef CHECK_DEMANGLER
|
||||
static inline char
|
||||
d_peek_next_char (const struct d_info *di)
|
||||
{
|
||||
if (!di->n[0])
|
||||
abort ();
|
||||
return di->n[1];
|
||||
}
|
||||
|
||||
static inline void
|
||||
d_advance (struct d_info *di, int i)
|
||||
{
|
||||
if (i < 0)
|
||||
abort ();
|
||||
while (i--)
|
||||
{
|
||||
if (!di->n[0])
|
||||
abort ();
|
||||
di->n++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Functions and arrays in cp-demangle.c which are referenced by
|
||||
functions in cp-demint.c. */
|
||||
#ifdef IN_GLIBCPP_V3
|
||||
#define CP_STATIC_IF_GLIBCPP_V3 static
|
||||
#else
|
||||
#define CP_STATIC_IF_GLIBCPP_V3 extern
|
||||
#endif
|
||||
|
||||
#ifndef IN_GLIBCPP_V3
|
||||
extern const struct demangle_operator_info cplus_demangle_operators[];
|
||||
#endif
|
||||
|
||||
#define D_BUILTIN_TYPE_COUNT (34)
|
||||
|
||||
CP_STATIC_IF_GLIBCPP_V3
|
||||
const struct demangle_builtin_type_info
|
||||
cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT];
|
||||
|
||||
CP_STATIC_IF_GLIBCPP_V3
|
||||
struct demangle_component *
|
||||
cplus_demangle_mangled_name (struct d_info *, int);
|
||||
|
||||
CP_STATIC_IF_GLIBCPP_V3
|
||||
struct demangle_component *
|
||||
cplus_demangle_type (struct d_info *);
|
||||
|
||||
extern void
|
||||
cplus_demangle_init_info (const char *, int, size_t, struct d_info *);
|
||||
|
||||
/* cp-demangle.c needs to define this a little differently */
|
||||
#undef CP_STATIC_IF_GLIBCPP_V3
|
694
third-party/demangle/demangle.h
vendored
Normal file
694
third-party/demangle/demangle.h
vendored
Normal file
@@ -0,0 +1,694 @@
|
||||
/* Defs for interface to demanglers.
|
||||
Copyright (C) 1992-2021 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
In addition to the permissions in the GNU Library General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file into
|
||||
combinations with other programs, and to distribute those
|
||||
combinations without any restriction coming from the use of this
|
||||
file. (The Library Public License restrictions do apply in other
|
||||
respects; for example, they cover modification of the file, and
|
||||
distribution when not linked into a combined executable.)
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
|
||||
#if !defined (DEMANGLE_H)
|
||||
#define DEMANGLE_H
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Options passed to cplus_demangle (in 2nd parameter). */
|
||||
|
||||
#define DMGL_NO_OPTS 0 /* For readability... */
|
||||
#define DMGL_PARAMS (1 << 0) /* Include function args */
|
||||
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
|
||||
#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */
|
||||
#define DMGL_VERBOSE (1 << 3) /* Include implementation details. */
|
||||
#define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */
|
||||
#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when
|
||||
present) after function signature.
|
||||
It applies only to the toplevel
|
||||
function type. */
|
||||
#define DMGL_RET_DROP (1 << 6) /* Suppress printing function return
|
||||
types, even if present. It applies
|
||||
only to the toplevel function type.
|
||||
*/
|
||||
|
||||
#define DMGL_AUTO (1 << 8)
|
||||
#define DMGL_GNU_V3 (1 << 14)
|
||||
#define DMGL_GNAT (1 << 15)
|
||||
#define DMGL_DLANG (1 << 16)
|
||||
#define DMGL_RUST (1 << 17) /* Rust wraps GNU_V3 style mangling. */
|
||||
|
||||
/* If none of these are set, use 'current_demangling_style' as the default. */
|
||||
#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_DLANG|DMGL_RUST)
|
||||
|
||||
/* Disable a limit on the depth of recursion in mangled strings.
|
||||
Note if this limit is disabled then stack exhaustion is possible when
|
||||
demangling pathologically complicated strings. Bug reports about stack
|
||||
exhaustion when the option is enabled will be rejected. */
|
||||
#define DMGL_NO_RECURSE_LIMIT (1 << 18)
|
||||
|
||||
/* If DMGL_NO_RECURSE_LIMIT is not enabled, then this is the value used as
|
||||
the maximum depth of recursion allowed. It should be enough for any
|
||||
real-world mangled name. */
|
||||
#define DEMANGLE_RECURSION_LIMIT 2048
|
||||
|
||||
/* Enumeration of possible demangling styles.
|
||||
|
||||
Lucid and ARM styles are still kept logically distinct, even though
|
||||
they now both behave identically. The resulting style is actual the
|
||||
union of both. I.E. either style recognizes both "__pt__" and "__rf__"
|
||||
for operator "->", even though the first is lucid style and the second
|
||||
is ARM style. (FIXME?) */
|
||||
|
||||
extern enum demangling_styles
|
||||
{
|
||||
no_demangling = -1,
|
||||
unknown_demangling = 0,
|
||||
auto_demangling = DMGL_AUTO,
|
||||
gnu_v3_demangling = DMGL_GNU_V3,
|
||||
java_demangling = DMGL_JAVA,
|
||||
gnat_demangling = DMGL_GNAT,
|
||||
dlang_demangling = DMGL_DLANG,
|
||||
rust_demangling = DMGL_RUST
|
||||
} current_demangling_style;
|
||||
|
||||
/* Define string names for the various demangling styles. */
|
||||
|
||||
#define NO_DEMANGLING_STYLE_STRING "none"
|
||||
#define AUTO_DEMANGLING_STYLE_STRING "auto"
|
||||
#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3"
|
||||
#define JAVA_DEMANGLING_STYLE_STRING "java"
|
||||
#define GNAT_DEMANGLING_STYLE_STRING "gnat"
|
||||
#define DLANG_DEMANGLING_STYLE_STRING "dlang"
|
||||
#define RUST_DEMANGLING_STYLE_STRING "rust"
|
||||
|
||||
/* Some macros to test what demangling style is active. */
|
||||
|
||||
#define CURRENT_DEMANGLING_STYLE current_demangling_style
|
||||
#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
|
||||
#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
|
||||
#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
|
||||
#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
|
||||
#define DLANG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_DLANG)
|
||||
#define RUST_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_RUST)
|
||||
|
||||
/* Provide information about the available demangle styles. This code is
|
||||
pulled from gdb into libiberty because it is useful to binutils also. */
|
||||
|
||||
extern const struct demangler_engine
|
||||
{
|
||||
const char *const demangling_style_name;
|
||||
const enum demangling_styles demangling_style;
|
||||
const char *const demangling_style_doc;
|
||||
} libiberty_demanglers[];
|
||||
|
||||
extern char *
|
||||
cplus_demangle (const char *mangled, int options);
|
||||
|
||||
/* Note: This sets global state. FIXME if you care about multi-threading. */
|
||||
|
||||
extern enum demangling_styles
|
||||
cplus_demangle_set_style (enum demangling_styles style);
|
||||
|
||||
extern enum demangling_styles
|
||||
cplus_demangle_name_to_style (const char *name);
|
||||
|
||||
/* Callback typedef for allocation-less demangler interfaces. */
|
||||
typedef void (*demangle_callbackref) (const char *, size_t, void *);
|
||||
|
||||
/* V3 ABI demangling entry points, defined in cp-demangle.c. Callback
|
||||
variants return non-zero on success, zero on error. char* variants
|
||||
return a string allocated by malloc on success, NULL on error. */
|
||||
extern int
|
||||
cplus_demangle_v3_callback (const char *mangled, int options,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
extern char*
|
||||
cplus_demangle_v3 (const char *mangled, int options);
|
||||
|
||||
extern int
|
||||
java_demangle_v3_callback (const char *mangled,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
extern char*
|
||||
java_demangle_v3 (const char *mangled);
|
||||
|
||||
char *
|
||||
ada_demangle (const char *mangled, int options);
|
||||
|
||||
extern char *
|
||||
dlang_demangle (const char *mangled, int options);
|
||||
|
||||
extern int
|
||||
rust_demangle_callback (const char *mangled, int options,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
|
||||
extern char *
|
||||
rust_demangle (const char *mangled, int options);
|
||||
|
||||
enum gnu_v3_ctor_kinds {
|
||||
gnu_v3_complete_object_ctor = 1,
|
||||
gnu_v3_base_object_ctor,
|
||||
gnu_v3_complete_object_allocating_ctor,
|
||||
/* These are not part of the V3 ABI. Unified constructors are generated
|
||||
as a speed-for-space optimization when the -fdeclone-ctor-dtor option
|
||||
is used, and are always internal symbols. */
|
||||
gnu_v3_unified_ctor,
|
||||
gnu_v3_object_ctor_group
|
||||
};
|
||||
|
||||
/* Return non-zero iff NAME is the mangled form of a constructor name
|
||||
in the G++ V3 ABI demangling style. Specifically, return an `enum
|
||||
gnu_v3_ctor_kinds' value indicating what kind of constructor
|
||||
it is. */
|
||||
extern enum gnu_v3_ctor_kinds
|
||||
is_gnu_v3_mangled_ctor (const char *name);
|
||||
|
||||
|
||||
enum gnu_v3_dtor_kinds {
|
||||
gnu_v3_deleting_dtor = 1,
|
||||
gnu_v3_complete_object_dtor,
|
||||
gnu_v3_base_object_dtor,
|
||||
/* These are not part of the V3 ABI. Unified destructors are generated
|
||||
as a speed-for-space optimization when the -fdeclone-ctor-dtor option
|
||||
is used, and are always internal symbols. */
|
||||
gnu_v3_unified_dtor,
|
||||
gnu_v3_object_dtor_group
|
||||
};
|
||||
|
||||
/* Return non-zero iff NAME is the mangled form of a destructor name
|
||||
in the G++ V3 ABI demangling style. Specifically, return an `enum
|
||||
gnu_v3_dtor_kinds' value, indicating what kind of destructor
|
||||
it is. */
|
||||
extern enum gnu_v3_dtor_kinds
|
||||
is_gnu_v3_mangled_dtor (const char *name);
|
||||
|
||||
/* The V3 demangler works in two passes. The first pass builds a tree
|
||||
representation of the mangled name, and the second pass turns the
|
||||
tree representation into a demangled string. Here we define an
|
||||
interface to permit a caller to build their own tree
|
||||
representation, which they can pass to the demangler to get a
|
||||
demangled string. This can be used to canonicalize user input into
|
||||
something which the demangler might output. It could also be used
|
||||
by other demanglers in the future. */
|
||||
|
||||
/* These are the component types which may be found in the tree. Many
|
||||
component types have one or two subtrees, referred to as left and
|
||||
right (a component type with only one subtree puts it in the left
|
||||
subtree). */
|
||||
|
||||
enum demangle_component_type
|
||||
{
|
||||
/* A name, with a length and a pointer to a string. */
|
||||
DEMANGLE_COMPONENT_NAME,
|
||||
/* A qualified name. The left subtree is a class or namespace or
|
||||
some such thing, and the right subtree is a name qualified by
|
||||
that class. */
|
||||
DEMANGLE_COMPONENT_QUAL_NAME,
|
||||
/* A local name. The left subtree describes a function, and the
|
||||
right subtree is a name which is local to that function. */
|
||||
DEMANGLE_COMPONENT_LOCAL_NAME,
|
||||
/* A typed name. The left subtree is a name, and the right subtree
|
||||
describes that name as a function. */
|
||||
DEMANGLE_COMPONENT_TYPED_NAME,
|
||||
/* A template. The left subtree is a template name, and the right
|
||||
subtree is a template argument list. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE,
|
||||
/* A template parameter. This holds a number, which is the template
|
||||
parameter index. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE_PARAM,
|
||||
/* A function parameter. This holds a number, which is the index. */
|
||||
DEMANGLE_COMPONENT_FUNCTION_PARAM,
|
||||
/* A constructor. This holds a name and the kind of
|
||||
constructor. */
|
||||
DEMANGLE_COMPONENT_CTOR,
|
||||
/* A destructor. This holds a name and the kind of destructor. */
|
||||
DEMANGLE_COMPONENT_DTOR,
|
||||
/* A vtable. This has one subtree, the type for which this is a
|
||||
vtable. */
|
||||
DEMANGLE_COMPONENT_VTABLE,
|
||||
/* A VTT structure. This has one subtree, the type for which this
|
||||
is a VTT. */
|
||||
DEMANGLE_COMPONENT_VTT,
|
||||
/* A construction vtable. The left subtree is the type for which
|
||||
this is a vtable, and the right subtree is the derived type for
|
||||
which this vtable is built. */
|
||||
DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
|
||||
/* A typeinfo structure. This has one subtree, the type for which
|
||||
this is the tpeinfo structure. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO,
|
||||
/* A typeinfo name. This has one subtree, the type for which this
|
||||
is the typeinfo name. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO_NAME,
|
||||
/* A typeinfo function. This has one subtree, the type for which
|
||||
this is the tpyeinfo function. */
|
||||
DEMANGLE_COMPONENT_TYPEINFO_FN,
|
||||
/* A thunk. This has one subtree, the name for which this is a
|
||||
thunk. */
|
||||
DEMANGLE_COMPONENT_THUNK,
|
||||
/* A virtual thunk. This has one subtree, the name for which this
|
||||
is a virtual thunk. */
|
||||
DEMANGLE_COMPONENT_VIRTUAL_THUNK,
|
||||
/* A covariant thunk. This has one subtree, the name for which this
|
||||
is a covariant thunk. */
|
||||
DEMANGLE_COMPONENT_COVARIANT_THUNK,
|
||||
/* A Java class. This has one subtree, the type. */
|
||||
DEMANGLE_COMPONENT_JAVA_CLASS,
|
||||
/* A guard variable. This has one subtree, the name for which this
|
||||
is a guard variable. */
|
||||
DEMANGLE_COMPONENT_GUARD,
|
||||
/* The init and wrapper functions for C++11 thread_local variables. */
|
||||
DEMANGLE_COMPONENT_TLS_INIT,
|
||||
DEMANGLE_COMPONENT_TLS_WRAPPER,
|
||||
/* A reference temporary. This has one subtree, the name for which
|
||||
this is a temporary. */
|
||||
DEMANGLE_COMPONENT_REFTEMP,
|
||||
/* A hidden alias. This has one subtree, the encoding for which it
|
||||
is providing alternative linkage. */
|
||||
DEMANGLE_COMPONENT_HIDDEN_ALIAS,
|
||||
/* A standard substitution. This holds the name of the
|
||||
substitution. */
|
||||
DEMANGLE_COMPONENT_SUB_STD,
|
||||
/* The restrict qualifier. The one subtree is the type which is
|
||||
being qualified. */
|
||||
DEMANGLE_COMPONENT_RESTRICT,
|
||||
/* The volatile qualifier. The one subtree is the type which is
|
||||
being qualified. */
|
||||
DEMANGLE_COMPONENT_VOLATILE,
|
||||
/* The const qualifier. The one subtree is the type which is being
|
||||
qualified. */
|
||||
DEMANGLE_COMPONENT_CONST,
|
||||
/* The restrict qualifier modifying a member function. The one
|
||||
subtree is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_RESTRICT_THIS,
|
||||
/* The volatile qualifier modifying a member function. The one
|
||||
subtree is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_VOLATILE_THIS,
|
||||
/* The const qualifier modifying a member function. The one subtree
|
||||
is the type which is being qualified. */
|
||||
DEMANGLE_COMPONENT_CONST_THIS,
|
||||
/* C++11 A reference modifying a member function. The one subtree is the
|
||||
type which is being referenced. */
|
||||
DEMANGLE_COMPONENT_REFERENCE_THIS,
|
||||
/* C++11: An rvalue reference modifying a member function. The one
|
||||
subtree is the type which is being referenced. */
|
||||
DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS,
|
||||
/* A vendor qualifier. The left subtree is the type which is being
|
||||
qualified, and the right subtree is the name of the
|
||||
qualifier. */
|
||||
DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
|
||||
/* A pointer. The one subtree is the type which is being pointed
|
||||
to. */
|
||||
DEMANGLE_COMPONENT_POINTER,
|
||||
/* A reference. The one subtree is the type which is being
|
||||
referenced. */
|
||||
DEMANGLE_COMPONENT_REFERENCE,
|
||||
/* C++0x: An rvalue reference. The one subtree is the type which is
|
||||
being referenced. */
|
||||
DEMANGLE_COMPONENT_RVALUE_REFERENCE,
|
||||
/* A complex type. The one subtree is the base type. */
|
||||
DEMANGLE_COMPONENT_COMPLEX,
|
||||
/* An imaginary type. The one subtree is the base type. */
|
||||
DEMANGLE_COMPONENT_IMAGINARY,
|
||||
/* A builtin type. This holds the builtin type information. */
|
||||
DEMANGLE_COMPONENT_BUILTIN_TYPE,
|
||||
/* A vendor's builtin type. This holds the name of the type. */
|
||||
DEMANGLE_COMPONENT_VENDOR_TYPE,
|
||||
/* A function type. The left subtree is the return type. The right
|
||||
subtree is a list of ARGLIST nodes. Either or both may be
|
||||
NULL. */
|
||||
DEMANGLE_COMPONENT_FUNCTION_TYPE,
|
||||
/* An array type. The left subtree is the dimension, which may be
|
||||
NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
|
||||
expression. The right subtree is the element type. */
|
||||
DEMANGLE_COMPONENT_ARRAY_TYPE,
|
||||
/* A pointer to member type. The left subtree is the class type,
|
||||
and the right subtree is the member type. CV-qualifiers appear
|
||||
on the latter. */
|
||||
DEMANGLE_COMPONENT_PTRMEM_TYPE,
|
||||
/* A fixed-point type. */
|
||||
DEMANGLE_COMPONENT_FIXED_TYPE,
|
||||
/* A vector type. The left subtree is the number of elements,
|
||||
the right subtree is the element type. */
|
||||
DEMANGLE_COMPONENT_VECTOR_TYPE,
|
||||
/* An argument list. The left subtree is the current argument, and
|
||||
the right subtree is either NULL or another ARGLIST node. */
|
||||
DEMANGLE_COMPONENT_ARGLIST,
|
||||
/* A template argument list. The left subtree is the current
|
||||
template argument, and the right subtree is either NULL or
|
||||
another TEMPLATE_ARGLIST node. */
|
||||
DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
|
||||
/* A template parameter object (C++20). The left subtree is the
|
||||
corresponding template argument. */
|
||||
DEMANGLE_COMPONENT_TPARM_OBJ,
|
||||
/* An initializer list. The left subtree is either an explicit type or
|
||||
NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */
|
||||
DEMANGLE_COMPONENT_INITIALIZER_LIST,
|
||||
/* An operator. This holds information about a standard
|
||||
operator. */
|
||||
DEMANGLE_COMPONENT_OPERATOR,
|
||||
/* An extended operator. This holds the number of arguments, and
|
||||
the name of the extended operator. */
|
||||
DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
|
||||
/* A typecast, represented as a unary operator. The one subtree is
|
||||
the type to which the argument should be cast. */
|
||||
DEMANGLE_COMPONENT_CAST,
|
||||
/* A conversion operator, represented as a unary operator. The one
|
||||
subtree is the type to which the argument should be converted
|
||||
to. */
|
||||
DEMANGLE_COMPONENT_CONVERSION,
|
||||
/* A nullary expression. The left subtree is the operator. */
|
||||
DEMANGLE_COMPONENT_NULLARY,
|
||||
/* A unary expression. The left subtree is the operator, and the
|
||||
right subtree is the single argument. */
|
||||
DEMANGLE_COMPONENT_UNARY,
|
||||
/* A binary expression. The left subtree is the operator, and the
|
||||
right subtree is a BINARY_ARGS. */
|
||||
DEMANGLE_COMPONENT_BINARY,
|
||||
/* Arguments to a binary expression. The left subtree is the first
|
||||
argument, and the right subtree is the second argument. */
|
||||
DEMANGLE_COMPONENT_BINARY_ARGS,
|
||||
/* A trinary expression. The left subtree is the operator, and the
|
||||
right subtree is a TRINARY_ARG1. */
|
||||
DEMANGLE_COMPONENT_TRINARY,
|
||||
/* Arguments to a trinary expression. The left subtree is the first
|
||||
argument, and the right subtree is a TRINARY_ARG2. */
|
||||
DEMANGLE_COMPONENT_TRINARY_ARG1,
|
||||
/* More arguments to a trinary expression. The left subtree is the
|
||||
second argument, and the right subtree is the third argument. */
|
||||
DEMANGLE_COMPONENT_TRINARY_ARG2,
|
||||
/* A literal. The left subtree is the type, and the right subtree
|
||||
is the value, represented as a DEMANGLE_COMPONENT_NAME. */
|
||||
DEMANGLE_COMPONENT_LITERAL,
|
||||
/* A negative literal. Like LITERAL, but the value is negated.
|
||||
This is a minor hack: the NAME used for LITERAL points directly
|
||||
to the mangled string, but since negative numbers are mangled
|
||||
using 'n' instead of '-', we want a way to indicate a negative
|
||||
number which involves neither modifying the mangled string nor
|
||||
allocating a new copy of the literal in memory. */
|
||||
DEMANGLE_COMPONENT_LITERAL_NEG,
|
||||
/* A libgcj compiled resource. The left subtree is the name of the
|
||||
resource. */
|
||||
DEMANGLE_COMPONENT_JAVA_RESOURCE,
|
||||
/* A name formed by the concatenation of two parts. The left
|
||||
subtree is the first part and the right subtree the second. */
|
||||
DEMANGLE_COMPONENT_COMPOUND_NAME,
|
||||
/* A name formed by a single character. */
|
||||
DEMANGLE_COMPONENT_CHARACTER,
|
||||
/* A number. */
|
||||
DEMANGLE_COMPONENT_NUMBER,
|
||||
/* A decltype type. */
|
||||
DEMANGLE_COMPONENT_DECLTYPE,
|
||||
/* Global constructors keyed to name. */
|
||||
DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
|
||||
/* Global destructors keyed to name. */
|
||||
DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
|
||||
/* A lambda closure type. */
|
||||
DEMANGLE_COMPONENT_LAMBDA,
|
||||
/* A default argument scope. */
|
||||
DEMANGLE_COMPONENT_DEFAULT_ARG,
|
||||
/* An unnamed type. */
|
||||
DEMANGLE_COMPONENT_UNNAMED_TYPE,
|
||||
/* A transactional clone. This has one subtree, the encoding for
|
||||
which it is providing alternative linkage. */
|
||||
DEMANGLE_COMPONENT_TRANSACTION_CLONE,
|
||||
/* A non-transactional clone entry point. In the i386/x86_64 abi,
|
||||
the unmangled symbol of a tm_callable becomes a thunk and the
|
||||
non-transactional function version is mangled thus. */
|
||||
DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
|
||||
/* A pack expansion. */
|
||||
DEMANGLE_COMPONENT_PACK_EXPANSION,
|
||||
/* A name with an ABI tag. */
|
||||
DEMANGLE_COMPONENT_TAGGED_NAME,
|
||||
/* A transaction-safe function type. */
|
||||
DEMANGLE_COMPONENT_TRANSACTION_SAFE,
|
||||
/* A cloned function. */
|
||||
DEMANGLE_COMPONENT_CLONE,
|
||||
DEMANGLE_COMPONENT_NOEXCEPT,
|
||||
DEMANGLE_COMPONENT_THROW_SPEC
|
||||
};
|
||||
|
||||
/* Types which are only used internally. */
|
||||
|
||||
struct demangle_operator_info;
|
||||
struct demangle_builtin_type_info;
|
||||
|
||||
/* A node in the tree representation is an instance of a struct
|
||||
demangle_component. Note that the field names of the struct are
|
||||
not well protected against macros defined by the file including
|
||||
this one. We can fix this if it ever becomes a problem. */
|
||||
|
||||
struct demangle_component
|
||||
{
|
||||
/* The type of this component. */
|
||||
enum demangle_component_type type;
|
||||
|
||||
/* Guard against recursive component printing.
|
||||
Initialize to zero. Private to d_print_comp.
|
||||
All other fields are final after initialization. */
|
||||
int d_printing;
|
||||
int d_counting;
|
||||
|
||||
union
|
||||
{
|
||||
/* For DEMANGLE_COMPONENT_NAME. */
|
||||
struct
|
||||
{
|
||||
/* A pointer to the name (which need not NULL terminated) and
|
||||
its length. */
|
||||
const char *s;
|
||||
int len;
|
||||
} s_name;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_OPERATOR. */
|
||||
struct
|
||||
{
|
||||
/* Operator. */
|
||||
const struct demangle_operator_info *op;
|
||||
} s_operator;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */
|
||||
struct
|
||||
{
|
||||
/* Number of arguments. */
|
||||
int args;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_extended_operator;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_FIXED_TYPE. */
|
||||
struct
|
||||
{
|
||||
/* The length, indicated by a C integer type name. */
|
||||
struct demangle_component *length;
|
||||
/* _Accum or _Fract? */
|
||||
short accum;
|
||||
/* Saturating or not? */
|
||||
short sat;
|
||||
} s_fixed;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_CTOR. */
|
||||
struct
|
||||
{
|
||||
/* Kind of constructor. */
|
||||
enum gnu_v3_ctor_kinds kind;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_ctor;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_DTOR. */
|
||||
struct
|
||||
{
|
||||
/* Kind of destructor. */
|
||||
enum gnu_v3_dtor_kinds kind;
|
||||
/* Name. */
|
||||
struct demangle_component *name;
|
||||
} s_dtor;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */
|
||||
struct
|
||||
{
|
||||
/* Builtin type. */
|
||||
const struct demangle_builtin_type_info *type;
|
||||
} s_builtin;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_SUB_STD. */
|
||||
struct
|
||||
{
|
||||
/* Standard substitution string. */
|
||||
const char* string;
|
||||
/* Length of string. */
|
||||
int len;
|
||||
} s_string;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_*_PARAM. */
|
||||
struct
|
||||
{
|
||||
/* Parameter index. */
|
||||
long number;
|
||||
} s_number;
|
||||
|
||||
/* For DEMANGLE_COMPONENT_CHARACTER. */
|
||||
struct
|
||||
{
|
||||
int character;
|
||||
} s_character;
|
||||
|
||||
/* For other types. */
|
||||
struct
|
||||
{
|
||||
/* Left (or only) subtree. */
|
||||
struct demangle_component *left;
|
||||
/* Right subtree. */
|
||||
struct demangle_component *right;
|
||||
} s_binary;
|
||||
|
||||
struct
|
||||
{
|
||||
/* subtree, same place as d_left. */
|
||||
struct demangle_component *sub;
|
||||
/* integer. */
|
||||
int num;
|
||||
} s_unary_num;
|
||||
|
||||
} u;
|
||||
};
|
||||
|
||||
/* People building mangled trees are expected to allocate instances of
|
||||
struct demangle_component themselves. They can then call one of
|
||||
the following functions to fill them in. */
|
||||
|
||||
/* Fill in most component types with a left subtree and a right
|
||||
subtree. Returns non-zero on success, zero on failure, such as an
|
||||
unrecognized or inappropriate component type. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_component (struct demangle_component *fill,
|
||||
enum demangle_component_type,
|
||||
struct demangle_component *left,
|
||||
struct demangle_component *right);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_name (struct demangle_component *fill,
|
||||
const char *, int);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
|
||||
builtin type (e.g., "int", etc.). Returns non-zero on success,
|
||||
zero if the type is not recognized. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_builtin_type (struct demangle_component *fill,
|
||||
const char *type_name);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
|
||||
operator and the number of arguments which it takes (the latter is
|
||||
used to disambiguate operators which can be both binary and unary,
|
||||
such as '-'). Returns non-zero on success, zero if the operator is
|
||||
not recognized. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_operator (struct demangle_component *fill,
|
||||
const char *opname, int args);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
|
||||
number of arguments and the name. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_extended_operator (struct demangle_component *fill,
|
||||
int numargs,
|
||||
struct demangle_component *nm);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_ctor (struct demangle_component *fill,
|
||||
enum gnu_v3_ctor_kinds kind,
|
||||
struct demangle_component *name);
|
||||
|
||||
/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success,
|
||||
zero for bad arguments. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_fill_dtor (struct demangle_component *fill,
|
||||
enum gnu_v3_dtor_kinds kind,
|
||||
struct demangle_component *name);
|
||||
|
||||
/* This function translates a mangled name into a struct
|
||||
demangle_component tree. The first argument is the mangled name.
|
||||
The second argument is DMGL_* options. This returns a pointer to a
|
||||
tree on success, or NULL on failure. On success, the third
|
||||
argument is set to a block of memory allocated by malloc. This
|
||||
block should be passed to free when the tree is no longer
|
||||
needed. */
|
||||
|
||||
extern struct demangle_component *
|
||||
cplus_demangle_v3_components (const char *mangled, int options, void **mem);
|
||||
|
||||
/* This function takes a struct demangle_component tree and returns
|
||||
the corresponding demangled string. The first argument is DMGL_*
|
||||
options. The second is the tree to demangle. The third is a guess
|
||||
at the length of the demangled string, used to initially allocate
|
||||
the return buffer. The fourth is a pointer to a size_t. On
|
||||
success, this function returns a buffer allocated by malloc(), and
|
||||
sets the size_t pointed to by the fourth argument to the size of
|
||||
the allocated buffer (not the length of the returned string). On
|
||||
failure, this function returns NULL, and sets the size_t pointed to
|
||||
by the fourth argument to 0 for an invalid tree, or to 1 for a
|
||||
memory allocation error. */
|
||||
|
||||
extern char *
|
||||
cplus_demangle_print (int options,
|
||||
struct demangle_component *tree,
|
||||
int estimated_length,
|
||||
size_t *p_allocated_size);
|
||||
|
||||
/* This function takes a struct demangle_component tree and passes back
|
||||
a demangled string in one or more calls to a callback function.
|
||||
The first argument is DMGL_* options. The second is the tree to
|
||||
demangle. The third is a pointer to a callback function; on each call
|
||||
this receives an element of the demangled string, its length, and an
|
||||
opaque value. The fourth is the opaque value passed to the callback.
|
||||
The callback is called once or more to return the full demangled
|
||||
string. The demangled element string is always nul-terminated, though
|
||||
its length is also provided for convenience. In contrast to
|
||||
cplus_demangle_print(), this function does not allocate heap memory
|
||||
to grow output strings (except perhaps where alloca() is implemented
|
||||
by malloc()), and so is normally safe for use where the heap has been
|
||||
corrupted. On success, this function returns 1; on failure, 0. */
|
||||
|
||||
extern int
|
||||
cplus_demangle_print_callback (int options,
|
||||
struct demangle_component *tree,
|
||||
demangle_callbackref callback, void *opaque);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* DEMANGLE_H */
|
742
third-party/demangle/libiberty.h
vendored
Normal file
742
third-party/demangle/libiberty.h
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
/* Function declarations for libiberty.
|
||||
|
||||
Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
|
||||
Note - certain prototypes declared in this header file are for
|
||||
functions whoes implementation copyright does not belong to the
|
||||
FSF. Those prototypes are present in this file for reference
|
||||
purposes only and their presence in this file should not construed
|
||||
as an indication of ownership by the FSF of the implementation of
|
||||
those functions in any way or form whatsoever.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
Written by Cygnus Support, 1994.
|
||||
|
||||
The libiberty library provides a number of functions which are
|
||||
missing on some operating systems. We do not declare those here,
|
||||
to avoid conflicts with the system header files on operating
|
||||
systems that do support those functions. In this file we only
|
||||
declare those functions which are specific to libiberty. */
|
||||
|
||||
#ifndef LIBIBERTY_H
|
||||
#define LIBIBERTY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* Get a definition for size_t. */
|
||||
#include <stddef.h>
|
||||
/* Get a definition for va_list. */
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* If the OS supports it, ensure that the supplied stream is setup to
|
||||
avoid any multi-threaded locking. Otherwise leave the FILE pointer
|
||||
unchanged. If the stream is NULL do nothing. */
|
||||
|
||||
extern void unlock_stream (FILE *);
|
||||
|
||||
/* If the OS supports it, ensure that the standard I/O streams, stdin,
|
||||
stdout and stderr are setup to avoid any multi-threaded locking.
|
||||
Otherwise do nothing. */
|
||||
|
||||
extern void unlock_std_streams (void);
|
||||
|
||||
/* Open and return a FILE pointer. If the OS supports it, ensure that
|
||||
the stream is setup to avoid any multi-threaded locking. Otherwise
|
||||
return the FILE pointer unchanged. */
|
||||
|
||||
extern FILE *fopen_unlocked (const char *, const char *);
|
||||
extern FILE *fdopen_unlocked (int, const char *);
|
||||
extern FILE *freopen_unlocked (const char *, const char *, FILE *);
|
||||
|
||||
/* Build an argument vector from a string. Allocates memory using
|
||||
malloc. Use freeargv to free the vector. */
|
||||
|
||||
extern char **buildargv (const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Free a vector returned by buildargv. */
|
||||
|
||||
extern void freeargv (char **);
|
||||
|
||||
/* Duplicate an argument vector. Allocates memory using malloc. Use
|
||||
freeargv to free the vector. */
|
||||
|
||||
extern char **dupargv (char * const *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Expand "@file" arguments in argv. */
|
||||
|
||||
extern void expandargv (int *, char ***);
|
||||
|
||||
/* Write argv to an @-file, inserting necessary quoting. */
|
||||
|
||||
extern int writeargv (char * const *, FILE *);
|
||||
|
||||
/* Return the number of elements in argv. */
|
||||
|
||||
extern int countargv (char * const *);
|
||||
|
||||
/* A well-defined basename () that is always compiled in. */
|
||||
|
||||
extern const char *lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* Same, but assumes DOS semantics (drive name, backslash is also a
|
||||
dir separator) regardless of host. */
|
||||
|
||||
extern const char *dos_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* Same, but assumes Unix semantics (absolute paths always start with
|
||||
a slash, only forward slash is accepted as dir separator)
|
||||
regardless of host. */
|
||||
|
||||
extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
|
||||
|
||||
/* A well-defined realpath () that is always compiled in. */
|
||||
|
||||
extern char *lrealpath (const char *);
|
||||
|
||||
/* Return true when FD file descriptor exists. */
|
||||
|
||||
extern int is_valid_fd (int fd);
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using xmalloc. */
|
||||
|
||||
extern char *concat (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using xmalloc. The first argument is
|
||||
not one of the strings to be concatenated, but if not NULL is a
|
||||
pointer to be freed after the new string is created, similar to the
|
||||
way xrealloc works. */
|
||||
|
||||
extern char *reconcat (char *, const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Determine the length of concatenating an arbitrary number of
|
||||
strings. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. */
|
||||
|
||||
extern unsigned long concat_length (const char *, ...) ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings into a SUPPLIED area of
|
||||
memory. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. The supplied memory is assumed
|
||||
to be large enough. */
|
||||
|
||||
extern char *concat_copy (char *, const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1) ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Concatenate an arbitrary number of strings into a GLOBAL area of
|
||||
memory. You must pass NULL as the last argument of this function,
|
||||
to terminate the list of strings. The supplied memory is assumed
|
||||
to be large enough. */
|
||||
|
||||
extern char *concat_copy2 (const char *, ...) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* This is the global area used by concat_copy2. */
|
||||
|
||||
extern char *libiberty_concat_ptr;
|
||||
|
||||
/* Concatenate an arbitrary number of strings. You must pass NULL as
|
||||
the last argument of this function, to terminate the list of
|
||||
strings. Allocates memory using alloca. The arguments are
|
||||
evaluated twice! */
|
||||
#define ACONCAT(ACONCAT_PARAMS) \
|
||||
(libiberty_concat_ptr = (char *) alloca (concat_length ACONCAT_PARAMS + 1), \
|
||||
concat_copy2 ACONCAT_PARAMS)
|
||||
|
||||
/* Check whether two file descriptors refer to the same file. */
|
||||
|
||||
extern int fdmatch (int fd1, int fd2);
|
||||
|
||||
/* Return the position of the first bit set in the argument. */
|
||||
/* Prototypes vary from system to system, so we only provide a
|
||||
prototype on systems where we know that we need it. */
|
||||
#if defined (HAVE_DECL_FFS) && !HAVE_DECL_FFS
|
||||
extern int ffs(int);
|
||||
#endif
|
||||
|
||||
/* Get the working directory. The result is cached, so don't call
|
||||
chdir() between calls to getpwd(). */
|
||||
|
||||
extern char * getpwd (void);
|
||||
|
||||
/* Get the current time. */
|
||||
/* Prototypes vary from system to system, so we only provide a
|
||||
prototype on systems where we know that we need it. */
|
||||
#ifdef __MINGW32__
|
||||
/* Forward declaration to avoid #include <sys/time.h>. */
|
||||
struct timeval;
|
||||
extern int gettimeofday (struct timeval *, void *);
|
||||
#endif
|
||||
|
||||
/* Get the amount of time the process has run, in microseconds. */
|
||||
|
||||
extern long get_run_time (void);
|
||||
|
||||
/* Generate a relocated path to some installation directory. Allocates
|
||||
return value using malloc. */
|
||||
|
||||
extern char *make_relative_prefix (const char *, const char *,
|
||||
const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Generate a relocated path to some installation directory without
|
||||
attempting to follow any soft links. Allocates
|
||||
return value using malloc. */
|
||||
|
||||
extern char *make_relative_prefix_ignore_links (const char *, const char *,
|
||||
const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Returns a pointer to a directory path suitable for creating temporary
|
||||
files in. */
|
||||
|
||||
extern const char *choose_tmpdir (void) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Choose a temporary directory to use for scratch files. */
|
||||
|
||||
extern char *choose_temp_base (void) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Return a temporary file name or NULL if unable to create one. */
|
||||
|
||||
extern char *make_temp_file (const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Return a temporary file name with given PREFIX and SUFFIX
|
||||
or NULL if unable to create one. */
|
||||
|
||||
extern char *make_temp_file_with_prefix (const char *, const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Remove a link to a file unless it is special. */
|
||||
|
||||
extern int unlink_if_ordinary (const char *);
|
||||
|
||||
/* Allocate memory filled with spaces. Allocates using malloc. */
|
||||
|
||||
extern const char *spaces (int count);
|
||||
|
||||
/* Return the maximum error number for which strerror will return a
|
||||
string. */
|
||||
|
||||
extern int errno_max (void);
|
||||
|
||||
/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
|
||||
"EINVAL"). */
|
||||
|
||||
extern const char *strerrno (int);
|
||||
|
||||
/* Given the name of an errno value, return the value. */
|
||||
|
||||
extern int strtoerrno (const char *);
|
||||
|
||||
/* ANSI's strerror(), but more robust. */
|
||||
|
||||
extern char *xstrerror (int) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Return the maximum signal number for which strsignal will return a
|
||||
string. */
|
||||
|
||||
extern int signo_max (void);
|
||||
|
||||
/* Return a signal message string for a signal number
|
||||
(e.g., strsignal (SIGHUP) returns something like "Hangup"). */
|
||||
/* This is commented out as it can conflict with one in system headers.
|
||||
We still document its existence though. */
|
||||
|
||||
/*extern const char *strsignal (int);*/
|
||||
|
||||
/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
|
||||
"SIGHUP"). */
|
||||
|
||||
extern const char *strsigno (int);
|
||||
|
||||
/* Given the name of a signal, return its number. */
|
||||
|
||||
extern int strtosigno (const char *);
|
||||
|
||||
/* Register a function to be run by xexit. Returns 0 on success. */
|
||||
|
||||
extern int xatexit (void (*fn) (void));
|
||||
|
||||
/* Exit, calling all the functions registered with xatexit. */
|
||||
|
||||
extern void xexit (int status) ATTRIBUTE_NORETURN;
|
||||
|
||||
/* Set the program name used by xmalloc. */
|
||||
|
||||
extern void xmalloc_set_program_name (const char *);
|
||||
|
||||
/* Report an allocation failure. */
|
||||
extern void xmalloc_failed (size_t) ATTRIBUTE_NORETURN;
|
||||
|
||||
/* Allocate memory without fail. If malloc fails, this will print a
|
||||
message to stderr (using the name set by xmalloc_set_program_name,
|
||||
if any) and then call xexit. */
|
||||
|
||||
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Reallocate memory without fail. This works like xmalloc. Note,
|
||||
realloc type functions are not suitable for attribute malloc since
|
||||
they may return the same address across multiple calls. */
|
||||
|
||||
extern void *xrealloc (void *, size_t);
|
||||
|
||||
/* Allocate memory without fail and set it to zero. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Copy a string into a memory buffer without fail. */
|
||||
|
||||
extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Copy at most N characters from string into a buffer without fail. */
|
||||
|
||||
extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Copy an existing memory buffer to a new memory buffer without fail. */
|
||||
|
||||
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Physical memory routines. Return values are in BYTES. */
|
||||
extern double physmem_total (void);
|
||||
extern double physmem_available (void);
|
||||
|
||||
/* Compute the 32-bit CRC of a block of memory. */
|
||||
extern unsigned int xcrc32 (const unsigned char *, int, unsigned int);
|
||||
|
||||
/* These macros provide a K&R/C89/C++-friendly way of allocating structures
|
||||
with nice encapsulation. The XDELETE*() macros are technically
|
||||
superfluous, but provided here for symmetry. Using them consistently
|
||||
makes it easier to update client code to use different allocators such
|
||||
as new/delete and new[]/delete[]. */
|
||||
|
||||
/* Scalar allocators. */
|
||||
|
||||
#define XALLOCA(T) ((T *) alloca (sizeof (T)))
|
||||
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
|
||||
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
|
||||
#define XDUP(T, P) ((T *) xmemdup ((P), sizeof (T), sizeof (T)))
|
||||
#define XDELETE(P) free ((void*) (P))
|
||||
|
||||
/* Array allocators. */
|
||||
|
||||
#define XALLOCAVEC(T, N) ((T *) alloca (sizeof (T) * (N)))
|
||||
#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N)))
|
||||
#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T)))
|
||||
#define XDUPVEC(T, P, N) ((T *) xmemdup ((P), sizeof (T) * (N), sizeof (T) * (N)))
|
||||
#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))
|
||||
#define XDELETEVEC(P) free ((void*) (P))
|
||||
|
||||
/* Allocators for variable-sized structures and raw buffers. */
|
||||
|
||||
#define XALLOCAVAR(T, S) ((T *) alloca ((S)))
|
||||
#define XNEWVAR(T, S) ((T *) xmalloc ((S)))
|
||||
#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S)))
|
||||
#define XDUPVAR(T, P, S1, S2) ((T *) xmemdup ((P), (S1), (S2)))
|
||||
#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S)))
|
||||
|
||||
/* Type-safe obstack allocator. */
|
||||
|
||||
#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T)))
|
||||
#define XOBNEWVEC(O, T, N) ((T *) obstack_alloc ((O), sizeof (T) * (N)))
|
||||
#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
|
||||
#define XOBFINISH(O, T) ((T) obstack_finish ((O)))
|
||||
|
||||
/* hex character manipulation routines */
|
||||
|
||||
#define _hex_array_size 256
|
||||
#define _hex_bad 99
|
||||
extern const unsigned char _hex_value[_hex_array_size];
|
||||
extern void hex_init (void);
|
||||
#define hex_p(c) (hex_value (c) != _hex_bad)
|
||||
/* If you change this, note well: Some code relies on side effects in
|
||||
the argument being performed exactly once. */
|
||||
#define hex_value(c) ((unsigned int) _hex_value[(unsigned char) (c)])
|
||||
|
||||
/* Flags for pex_init. These are bits to be or'ed together. */
|
||||
|
||||
/* Record subprocess times, if possible. */
|
||||
#define PEX_RECORD_TIMES 0x1
|
||||
|
||||
/* Use pipes for communication between processes, if possible. */
|
||||
#define PEX_USE_PIPES 0x2
|
||||
|
||||
/* Save files used for communication between processes. */
|
||||
#define PEX_SAVE_TEMPS 0x4
|
||||
|
||||
/* Max number of alloca bytes per call before we must switch to malloc.
|
||||
|
||||
?? Swiped from gnulib's regex_internal.h header. Is this actually
|
||||
the case? This number seems arbitrary, though sane.
|
||||
|
||||
The OS usually guarantees only one guard page at the bottom of the stack,
|
||||
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||
allocate anything larger than 4096 bytes. Also care for the possibility
|
||||
of a few compiler-allocated temporary stack slots. */
|
||||
#define MAX_ALLOCA_SIZE 4032
|
||||
|
||||
/* Prepare to execute one or more programs, with standard output of
|
||||
each program fed to standard input of the next.
|
||||
FLAGS As above.
|
||||
PNAME The name of the program to report in error messages.
|
||||
TEMPBASE A base name to use for temporary files; may be NULL to
|
||||
use a random name.
|
||||
Returns NULL on error. */
|
||||
|
||||
extern struct pex_obj *pex_init (int flags, const char *pname,
|
||||
const char *tempbase) ATTRIBUTE_RETURNS_NONNULL;
|
||||
|
||||
/* Flags for pex_run. These are bits to be or'ed together. */
|
||||
|
||||
/* Last program in pipeline. Standard output of program goes to
|
||||
OUTNAME, or, if OUTNAME is NULL, to standard output of caller. Do
|
||||
not set this if you want to call pex_read_output. After this is
|
||||
set, pex_run may no longer be called with the same struct
|
||||
pex_obj. */
|
||||
#define PEX_LAST 0x1
|
||||
|
||||
/* Search for program in executable search path. */
|
||||
#define PEX_SEARCH 0x2
|
||||
|
||||
/* OUTNAME is a suffix. */
|
||||
#define PEX_SUFFIX 0x4
|
||||
|
||||
/* Send program's standard error to standard output. */
|
||||
#define PEX_STDERR_TO_STDOUT 0x8
|
||||
|
||||
/* Input file should be opened in binary mode. This flag is ignored
|
||||
on Unix. */
|
||||
#define PEX_BINARY_INPUT 0x10
|
||||
|
||||
/* Output file should be opened in binary mode. This flag is ignored
|
||||
on Unix. For proper behaviour PEX_BINARY_INPUT and
|
||||
PEX_BINARY_OUTPUT have to match appropriately--i.e., a call using
|
||||
PEX_BINARY_OUTPUT should be followed by a call using
|
||||
PEX_BINARY_INPUT. */
|
||||
#define PEX_BINARY_OUTPUT 0x20
|
||||
|
||||
/* Capture stderr to a pipe. The output can be read by
|
||||
calling pex_read_err and reading from the returned
|
||||
FILE object. This flag may be specified only for
|
||||
the last program in a pipeline.
|
||||
|
||||
This flag is supported only on Unix and Windows. */
|
||||
#define PEX_STDERR_TO_PIPE 0x40
|
||||
|
||||
/* Capture stderr in binary mode. This flag is ignored
|
||||
on Unix. */
|
||||
#define PEX_BINARY_ERROR 0x80
|
||||
|
||||
/* Append stdout to existing file instead of truncating it. */
|
||||
#define PEX_STDOUT_APPEND 0x100
|
||||
|
||||
/* Thes same as PEX_STDOUT_APPEND, but for STDERR. */
|
||||
#define PEX_STDERR_APPEND 0x200
|
||||
|
||||
/* Execute one program. Returns NULL on success. On error returns an
|
||||
error string (typically just the name of a system call); the error
|
||||
string is statically allocated.
|
||||
|
||||
OBJ Returned by pex_init.
|
||||
|
||||
FLAGS As above.
|
||||
|
||||
EXECUTABLE The program to execute.
|
||||
|
||||
ARGV NULL terminated array of arguments to pass to the program.
|
||||
|
||||
OUTNAME Sets the output file name as follows:
|
||||
|
||||
PEX_SUFFIX set (OUTNAME may not be NULL):
|
||||
TEMPBASE parameter to pex_init not NULL:
|
||||
Output file name is the concatenation of TEMPBASE
|
||||
and OUTNAME.
|
||||
TEMPBASE is NULL:
|
||||
Output file name is a random file name ending in
|
||||
OUTNAME.
|
||||
PEX_SUFFIX not set:
|
||||
OUTNAME not NULL:
|
||||
Output file name is OUTNAME.
|
||||
OUTNAME NULL, TEMPBASE not NULL:
|
||||
Output file name is randomly chosen using
|
||||
TEMPBASE.
|
||||
OUTNAME NULL, TEMPBASE NULL:
|
||||
Output file name is randomly chosen.
|
||||
|
||||
If PEX_LAST is not set, the output file name is the
|
||||
name to use for a temporary file holding stdout, if
|
||||
any (there will not be a file if PEX_USE_PIPES is set
|
||||
and the system supports pipes). If a file is used, it
|
||||
will be removed when no longer needed unless
|
||||
PEX_SAVE_TEMPS is set.
|
||||
|
||||
If PEX_LAST is set, and OUTNAME is not NULL, standard
|
||||
output is written to the output file name. The file
|
||||
will not be removed. If PEX_LAST and PEX_SUFFIX are
|
||||
both set, TEMPBASE may not be NULL.
|
||||
|
||||
ERRNAME If not NULL, this is the name of a file to which
|
||||
standard error is written. If NULL, standard error of
|
||||
the program is standard error of the caller.
|
||||
|
||||
ERR On an error return, *ERR is set to an errno value, or
|
||||
to 0 if there is no relevant errno.
|
||||
*/
|
||||
|
||||
extern const char *pex_run (struct pex_obj *obj, int flags,
|
||||
const char *executable, char * const *argv,
|
||||
const char *outname, const char *errname,
|
||||
int *err);
|
||||
|
||||
/* As for pex_run (), but takes an extra parameter to enable the
|
||||
environment for the child process to be specified.
|
||||
|
||||
ENV The environment for the child process, specified as
|
||||
an array of character pointers. Each element of the
|
||||
array should point to a string of the form VAR=VALUE,
|
||||
with the exception of the last element which must be
|
||||
a null pointer.
|
||||
*/
|
||||
|
||||
extern const char *pex_run_in_environment (struct pex_obj *obj, int flags,
|
||||
const char *executable,
|
||||
char * const *argv,
|
||||
char * const *env,
|
||||
const char *outname,
|
||||
const char *errname, int *err);
|
||||
|
||||
/* Return a stream for a temporary file to pass to the first program
|
||||
in the pipeline as input. The file name is chosen as for pex_run.
|
||||
pex_run closes the file automatically; don't close it yourself. */
|
||||
|
||||
extern FILE *pex_input_file (struct pex_obj *obj, int flags,
|
||||
const char *in_name);
|
||||
|
||||
/* Return a stream for a pipe connected to the standard input of the
|
||||
first program in the pipeline. You must have passed
|
||||
`PEX_USE_PIPES' to `pex_init'. Close the returned stream
|
||||
yourself. */
|
||||
|
||||
extern FILE *pex_input_pipe (struct pex_obj *obj, int binary);
|
||||
|
||||
/* Read the standard output of the last program to be executed.
|
||||
pex_run cannot be called after this. BINARY should be non-zero if
|
||||
the file should be opened in binary mode; this is ignored on Unix.
|
||||
Returns NULL on error. Don't call fclose on the returned FILE; it
|
||||
will be closed by pex_free. */
|
||||
|
||||
extern FILE *pex_read_output (struct pex_obj *, int binary);
|
||||
|
||||
/* Read the standard error of the last program to be executed.
|
||||
pex_run cannot be called after this. BINARY should be non-zero if
|
||||
the file should be opened in binary mode; this is ignored on Unix.
|
||||
Returns NULL on error. Don't call fclose on the returned FILE; it
|
||||
will be closed by pex_free. */
|
||||
|
||||
extern FILE *pex_read_err (struct pex_obj *, int binary);
|
||||
|
||||
/* Return exit status of all programs in VECTOR. COUNT indicates the
|
||||
size of VECTOR. The status codes in the vector are in the order of
|
||||
the calls to pex_run. Returns 0 on error, 1 on success. */
|
||||
|
||||
extern int pex_get_status (struct pex_obj *, int count, int *vector);
|
||||
|
||||
/* Return times of all programs in VECTOR. COUNT indicates the size
|
||||
of VECTOR. struct pex_time is really just struct timeval, but that
|
||||
is not portable to all systems. Returns 0 on error, 1 on
|
||||
success. */
|
||||
|
||||
struct pex_time
|
||||
{
|
||||
unsigned long user_seconds;
|
||||
unsigned long user_microseconds;
|
||||
unsigned long system_seconds;
|
||||
unsigned long system_microseconds;
|
||||
};
|
||||
|
||||
extern int pex_get_times (struct pex_obj *, int count,
|
||||
struct pex_time *vector);
|
||||
|
||||
/* Clean up a pex_obj. If you have not called pex_get_times or
|
||||
pex_get_status, this will try to kill the subprocesses. */
|
||||
|
||||
extern void pex_free (struct pex_obj *);
|
||||
|
||||
/* Just execute one program. Return value is as for pex_run.
|
||||
FLAGS Combination of PEX_SEARCH and PEX_STDERR_TO_STDOUT.
|
||||
EXECUTABLE As for pex_run.
|
||||
ARGV As for pex_run.
|
||||
PNAME As for pex_init.
|
||||
OUTNAME As for pex_run when PEX_LAST is set.
|
||||
ERRNAME As for pex_run.
|
||||
STATUS Set to exit status on success.
|
||||
ERR As for pex_run.
|
||||
*/
|
||||
|
||||
extern const char *pex_one (int flags, const char *executable,
|
||||
char * const *argv, const char *pname,
|
||||
const char *outname, const char *errname,
|
||||
int *status, int *err);
|
||||
|
||||
/* pexecute and pwait are the old pexecute interface, still here for
|
||||
backward compatibility. Don't use these for new code. Instead,
|
||||
use pex_init/pex_run/pex_get_status/pex_free, or pex_one. */
|
||||
|
||||
/* Definitions used by the pexecute routine. */
|
||||
|
||||
#define PEXECUTE_FIRST 1
|
||||
#define PEXECUTE_LAST 2
|
||||
#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
|
||||
#define PEXECUTE_SEARCH 4
|
||||
#define PEXECUTE_VERBOSE 8
|
||||
|
||||
/* Execute a program. */
|
||||
|
||||
extern int pexecute (const char *, char * const *, const char *,
|
||||
const char *, char **, char **, int);
|
||||
|
||||
/* Wait for pexecute to finish. */
|
||||
|
||||
extern int pwait (int, int *, int);
|
||||
|
||||
/* Like bsearch, but takes and passes on an argument like qsort_r. */
|
||||
|
||||
extern void *bsearch_r (const void *, const void *,
|
||||
size_t, size_t,
|
||||
int (*)(const void *, const void *, void *),
|
||||
void *);
|
||||
|
||||
#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
|
||||
/* Like sprintf but provides a pointer to malloc'd storage, which must
|
||||
be freed by the caller. */
|
||||
|
||||
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
|
||||
#endif
|
||||
|
||||
/* Like asprintf but allocates memory without fail. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
|
||||
|
||||
#if defined(HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
|
||||
/* Like vsprintf but provides a pointer to malloc'd storage, which
|
||||
must be freed by the caller. */
|
||||
|
||||
extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
|
||||
#endif
|
||||
|
||||
/* Like vasprintf but allocates memory without fail. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern char *xvasprintf (const char *, va_list) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF(1,0);
|
||||
|
||||
#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
|
||||
/* Like sprintf but prints at most N characters. */
|
||||
extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
|
||||
/* Like vsprintf but prints at most N characters. */
|
||||
extern int vsnprintf (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_DECL_STRNLEN) && !HAVE_DECL_STRNLEN
|
||||
extern size_t strnlen (const char *, size_t);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
|
||||
/* Compare version strings. */
|
||||
extern int strverscmp (const char *, const char *);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
|
||||
extern long int strtol (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
|
||||
extern unsigned long int strtoul (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOLL
|
||||
__extension__
|
||||
extern long long int strtoll (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOULL
|
||||
__extension__
|
||||
extern unsigned long long int strtoull (const char *nptr,
|
||||
char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
|
||||
/* Compare version strings. */
|
||||
extern int strverscmp (const char *, const char *);
|
||||
#endif
|
||||
|
||||
/* Set the title of a process */
|
||||
extern void setproctitle (const char *name, ...);
|
||||
|
||||
/* Increase stack limit if possible. */
|
||||
extern void stack_limit_increase (unsigned long);
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
/* Drastically simplified alloca configurator. If we're using GCC,
|
||||
we use __builtin_alloca; otherwise we use the C alloca. The C
|
||||
alloca is always available. You can override GCC by defining
|
||||
USE_C_ALLOCA yourself. The canonical autoconf macro C_ALLOCA is
|
||||
also set/unset as it is often used to indicate whether code needs
|
||||
to call alloca(0). */
|
||||
extern void *C_alloca (size_t) ATTRIBUTE_MALLOC;
|
||||
#undef alloca
|
||||
#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
|
||||
# define alloca(x) __builtin_alloca(x)
|
||||
# undef C_ALLOCA
|
||||
# define ASTRDUP(X) \
|
||||
(__extension__ ({ const char *const libiberty_optr = (X); \
|
||||
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
|
||||
char *const libiberty_nptr = (char *) alloca (libiberty_len); \
|
||||
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
|
||||
#else
|
||||
# define alloca(x) C_alloca(x)
|
||||
# undef USE_C_ALLOCA
|
||||
# define USE_C_ALLOCA 1
|
||||
# undef C_ALLOCA
|
||||
# define C_ALLOCA 1
|
||||
extern const char *libiberty_optr;
|
||||
extern char *libiberty_nptr;
|
||||
extern unsigned long libiberty_len;
|
||||
# define ASTRDUP(X) \
|
||||
(libiberty_optr = (X), \
|
||||
libiberty_len = strlen (libiberty_optr) + 1, \
|
||||
libiberty_nptr = (char *) alloca (libiberty_len), \
|
||||
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! defined (LIBIBERTY_H) */
|
1845
third-party/demangle/undname.c
vendored
Normal file
1845
third-party/demangle/undname.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
33
third-party/demangle/undname.h
vendored
Normal file
33
third-party/demangle/undname.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef UNDNAME_H
|
||||
#define UNDNAME_H
|
||||
|
||||
#define UNDNAME_COMPLETE (0x0000)
|
||||
#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) /* Don't show __ in calling convention */
|
||||
#define UNDNAME_NO_MS_KEYWORDS (0x0002) /* Don't show calling convention at all */
|
||||
#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) /* Don't show function/method return value */
|
||||
#define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
|
||||
#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
|
||||
#define UNDNAME_NO_MS_THISTYPE (0x0020)
|
||||
#define UNDNAME_NO_CV_THISTYPE (0x0040)
|
||||
#define UNDNAME_NO_THISTYPE (0x0060)
|
||||
#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) /* Don't show access specifier (public/protected/private) */
|
||||
#define UNDNAME_NO_THROW_SIGNATURES (0x0100)
|
||||
#define UNDNAME_NO_MEMBER_TYPE (0x0200) /* Don't show static/virtual specifier */
|
||||
#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
|
||||
#define UNDNAME_32_BIT_DECODE (0x0800)
|
||||
#define UNDNAME_NAME_ONLY (0x1000) /* Only report the variable/method name */
|
||||
#define UNDNAME_NO_ARGUMENTS (0x2000) /* Don't show method arguments */
|
||||
#define UNDNAME_NO_SPECIAL_SYMS (0x4000)
|
||||
#define UNDNAME_NO_COMPLEX_TYPE (0x8000)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char* undname(const char* mangled, unsigned short int flags, size_t* name_pos);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1865
third-party/demangle/unmangle.c
vendored
Normal file
1865
third-party/demangle/unmangle.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
136
third-party/demangle/unmangle.h
vendored
Normal file
136
third-party/demangle/unmangle.h
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*------------------------------------------------------------------------
|
||||
* filename - unmangle.h (C++ decorated symbol unmangler)
|
||||
*
|
||||
* function(s)
|
||||
*
|
||||
* _rtl_unmangle
|
||||
* _rtl_setUnmangleMode
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* C/C++ Run Time Library - Version 22.0
|
||||
*
|
||||
* Copyright (c) 1998, 2015 by Embarcadero Technologies, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Revision: 23325 $ */
|
||||
|
||||
#ifndef _UNMANGLE_
|
||||
#define _UNMANGLE_
|
||||
|
||||
#define _UMAPI
|
||||
|
||||
enum
|
||||
{
|
||||
/* The kind of symbol. */
|
||||
|
||||
x_UM_UNKNOWN = 0x00000000,
|
||||
|
||||
x_UM_FUNCTION = 0x00000001,
|
||||
x_UM_CONSTRUCTOR = 0x00000002,
|
||||
x_UM_DESTRUCTOR = 0x00000003,
|
||||
x_UM_OPERATOR = 0x00000004,
|
||||
x_UM_CONVERSION = 0x00000005,
|
||||
|
||||
x_UM_DATA = 0x00000006,
|
||||
x_UM_THUNK = 0x00000007,
|
||||
x_UM_TPDSC = 0x00000008,
|
||||
x_UM_VTABLE = 0x00000009,
|
||||
x_UM_VRDF_THUNK = 0x0000000a,
|
||||
x_UM_DYN_THUNK = 0x0000000b,
|
||||
|
||||
x_UM_KINDMASK = 0x000000ff,
|
||||
|
||||
/* Modifier (is it a member, template?). */
|
||||
|
||||
x_UM_QUALIFIED = 0x00000100,
|
||||
x_UM_TEMPLATE = 0x00000200,
|
||||
|
||||
x_UM_VIRDEF_FLAG = 0x00000400,
|
||||
x_UM_FRIEND_LIST = 0x00000800,
|
||||
x_UM_CTCH_HNDL_TBL = 0x00001000,
|
||||
x_UM_OBJ_DEST_TBL = 0x00002000,
|
||||
x_UM_THROW_LIST = 0x00004000,
|
||||
x_UM_EXC_CTXT_TBL = 0x00008000,
|
||||
x_UM_LINKER_PROC = 0x00010000,
|
||||
x_UM_SPECMASK = 0x0001fc00,
|
||||
|
||||
x_UM_MODMASK = 0x00ffff00,
|
||||
|
||||
/* Some kind of error occurred. */
|
||||
|
||||
x_UM_BUFOVRFLW = 0x01000000,
|
||||
x_UM_HASHTRUNC = 0x02000000,
|
||||
x_UM_ERROR = 0x04000000,
|
||||
|
||||
x_UM_ERRMASK = 0x7f000000,
|
||||
|
||||
/* This symbol is not a mangled name. */
|
||||
|
||||
x_UM_NOT_MANGLED = 0x80000000,
|
||||
};
|
||||
|
||||
typedef int _umKind;
|
||||
|
||||
#define UM_UNKNOWN ((_umKind) x_UM_UNKNOWN)
|
||||
#define UM_FUNCTION ((_umKind) x_UM_FUNCTION)
|
||||
#define UM_CONSTRUCTOR ((_umKind) x_UM_CONSTRUCTOR)
|
||||
#define UM_DESTRUCTOR ((_umKind) x_UM_DESTRUCTOR)
|
||||
#define UM_OPERATOR ((_umKind) x_UM_OPERATOR)
|
||||
#define UM_CONVERSION ((_umKind) x_UM_CONVERSION)
|
||||
#define UM_DATA ((_umKind) x_UM_DATA)
|
||||
#define UM_THUNK ((_umKind) x_UM_THUNK)
|
||||
#define UM_TPDSC ((_umKind) x_UM_TPDSC)
|
||||
#define UM_VTABLE ((_umKind) x_UM_VTABLE)
|
||||
#define UM_VRDF_THUNK ((_umKind) x_UM_VRDF_THUNK)
|
||||
#define UM_DYN_THUNK ((_umKind) x_UM_DYN_THUNK)
|
||||
#define UM_KINDMASK ((_umKind) x_UM_KINDMASK)
|
||||
#define UM_QUALIFIED ((_umKind) x_UM_QUALIFIED)
|
||||
#define UM_TEMPLATE ((_umKind) x_UM_TEMPLATE)
|
||||
#define UM_VIRDEF_FLAG ((_umKind) x_UM_VIRDEF_FLAG)
|
||||
#define UM_FRIEND_LIST ((_umKind) x_UM_FRIEND_LIST)
|
||||
#define UM_CTCH_HNDL_TBL ((_umKind) x_UM_CTCH_HNDL_TBL)
|
||||
#define UM_OBJ_DEST_TBL ((_umKind) x_UM_OBJ_DEST_TBL)
|
||||
#define UM_THROW_LIST ((_umKind) x_UM_THROW_LIST)
|
||||
#define UM_EXC_CTXT_TBL ((_umKind) x_UM_EXC_CTXT_TBL)
|
||||
#define UM_LINKER_PROC ((_umKind) x_UM_LINKER_PROC)
|
||||
#define UM_SPECMASK ((_umKind) x_UM_SPECMASK)
|
||||
#define UM_MODMASK ((_umKind) x_UM_MODMASK)
|
||||
#define UM_BUFOVRFLW ((_umKind) x_UM_BUFOVRFLW)
|
||||
#define UM_HASHTRUNC ((_umKind) x_UM_HASHTRUNC)
|
||||
#define UM_ERROR ((_umKind) x_UM_ERROR)
|
||||
#define UM_ERRMASK ((_umKind) x_UM_ERRMASK)
|
||||
#define UM_NOT_MANGLED ((_umKind) x_UM_NOT_MANGLED)
|
||||
|
||||
|
||||
#define _UM_MAXBUFFLEN 8192 /* maximum output length */
|
||||
|
||||
#define MAXBUFFLEN _UM_MAXBUFFLEN
|
||||
#define umKind _umKind
|
||||
#define UMAPI _UMAPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
_umKind _UMAPI
|
||||
unmangle(char * src, /* the string to be unmangled */
|
||||
char * dest, /* the unmangled output string */
|
||||
unsigned maxlen, /* the max length of the output string */
|
||||
char * qualP, /* optional additional string to hold
|
||||
only the qualifiers */
|
||||
|
||||
char * baseP, /* optional additional string to hold
|
||||
only the base name */
|
||||
int doArgs); /* handle function arguments? */
|
||||
|
||||
//int _UMAPI _rtl_setUnmangleMode(int); /* currently not implemented */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user