Back to index

cell-binutils  2.17cvs20070401
demangle.h
Go to the documentation of this file.
00001 /* Defs for interface to demanglers.
00002    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
00003    2003, 2004, 2005, 2007 Free Software Foundation, Inc.
00004    
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street - Fifth Floor,
00018    Boston, MA 02110-1301, USA.  */
00019 
00020 
00021 #if !defined (DEMANGLE_H)
00022 #define DEMANGLE_H
00023 
00024 #include "libiberty.h"
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif /* __cplusplus */
00029 
00030 /* Options passed to cplus_demangle (in 2nd parameter). */
00031 
00032 #define DMGL_NO_OPTS  0            /* For readability... */
00033 #define DMGL_PARAMS   (1 << 0)     /* Include function args */
00034 #define DMGL_ANSI     (1 << 1)     /* Include const, volatile, etc */
00035 #define DMGL_JAVA     (1 << 2)     /* Demangle as Java rather than C++. */
00036 #define DMGL_VERBOSE  (1 << 3)     /* Include implementation details.  */
00037 #define DMGL_TYPES    (1 << 4)     /* Also try to demangle type encodings.  */
00038 #define DMGL_RET_POSTFIX (1 << 5)       /* Print function return types (when
00039                                            present) after function signature */
00040 
00041 #define DMGL_AUTO     (1 << 8)
00042 #define DMGL_GNU      (1 << 9)
00043 #define DMGL_LUCID    (1 << 10)
00044 #define DMGL_ARM      (1 << 11)
00045 #define DMGL_HP       (1 << 12)       /* For the HP aCC compiler;
00046                                             same as ARM except for
00047                                             template arguments, etc. */
00048 #define DMGL_EDG      (1 << 13)
00049 #define DMGL_GNU_V3   (1 << 14)
00050 #define DMGL_GNAT     (1 << 15)
00051 
00052 /* If none of these are set, use 'current_demangling_style' as the default. */
00053 #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT)
00054 
00055 /* Enumeration of possible demangling styles.
00056 
00057    Lucid and ARM styles are still kept logically distinct, even though
00058    they now both behave identically.  The resulting style is actual the
00059    union of both.  I.E. either style recognizes both "__pt__" and "__rf__"
00060    for operator "->", even though the first is lucid style and the second
00061    is ARM style. (FIXME?) */
00062 
00063 extern enum demangling_styles
00064 {
00065   no_demangling = -1,
00066   unknown_demangling = 0,
00067   auto_demangling = DMGL_AUTO,
00068   gnu_demangling = DMGL_GNU,
00069   lucid_demangling = DMGL_LUCID,
00070   arm_demangling = DMGL_ARM,
00071   hp_demangling = DMGL_HP,
00072   edg_demangling = DMGL_EDG,
00073   gnu_v3_demangling = DMGL_GNU_V3,
00074   java_demangling = DMGL_JAVA,
00075   gnat_demangling = DMGL_GNAT
00076 } current_demangling_style;
00077 
00078 /* Define string names for the various demangling styles. */
00079 
00080 #define NO_DEMANGLING_STYLE_STRING            "none"
00081 #define AUTO_DEMANGLING_STYLE_STRING            "auto"
00082 #define GNU_DEMANGLING_STYLE_STRING             "gnu"
00083 #define LUCID_DEMANGLING_STYLE_STRING           "lucid"
00084 #define ARM_DEMANGLING_STYLE_STRING             "arm"
00085 #define HP_DEMANGLING_STYLE_STRING       "hp"
00086 #define EDG_DEMANGLING_STYLE_STRING             "edg"
00087 #define GNU_V3_DEMANGLING_STYLE_STRING        "gnu-v3"
00088 #define JAVA_DEMANGLING_STYLE_STRING          "java"
00089 #define GNAT_DEMANGLING_STYLE_STRING          "gnat"
00090 
00091 /* Some macros to test what demangling style is active. */
00092 
00093 #define CURRENT_DEMANGLING_STYLE current_demangling_style
00094 #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
00095 #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
00096 #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
00097 #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
00098 #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
00099 #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
00100 #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
00101 #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
00102 #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
00103 
00104 /* Provide information about the available demangle styles. This code is
00105    pulled from gdb into libiberty because it is useful to binutils also.  */
00106 
00107 extern const struct demangler_engine
00108 {
00109   const char *const demangling_style_name;
00110   const enum demangling_styles demangling_style;
00111   const char *const demangling_style_doc;
00112 } libiberty_demanglers[];
00113 
00114 extern char *
00115 cplus_demangle (const char *mangled, int options);
00116 
00117 extern int
00118 cplus_demangle_opname (const char *opname, char *result, int options);
00119 
00120 extern const char *
00121 cplus_mangle_opname (const char *opname, int options);
00122 
00123 /* Note: This sets global state.  FIXME if you care about multi-threading. */
00124 
00125 extern void
00126 set_cplus_marker_for_demangling (int ch);
00127 
00128 extern enum demangling_styles 
00129 cplus_demangle_set_style (enum demangling_styles style);
00130 
00131 extern enum demangling_styles 
00132 cplus_demangle_name_to_style (const char *name);
00133 
00134 /* Callback typedef for allocation-less demangler interfaces. */
00135 typedef void (*demangle_callbackref) (const char *, size_t, void *);
00136 
00137 /* V3 ABI demangling entry points, defined in cp-demangle.c.  Callback
00138    variants return non-zero on success, zero on error.  char* variants
00139    return a string allocated by malloc on success, NULL on error.  */
00140 extern int
00141 cplus_demangle_v3_callback (const char *mangled, int options,
00142                             demangle_callbackref callback, void *opaque);
00143 
00144 extern char*
00145 cplus_demangle_v3 (const char *mangled, int options);
00146 
00147 extern int
00148 java_demangle_v3_callback (const char *mangled,
00149                            demangle_callbackref callback, void *opaque);
00150 
00151 extern char*
00152 java_demangle_v3 (const char *mangled);
00153 
00154 enum gnu_v3_ctor_kinds {
00155   gnu_v3_complete_object_ctor = 1,
00156   gnu_v3_base_object_ctor,
00157   gnu_v3_complete_object_allocating_ctor
00158 };
00159 
00160 /* Return non-zero iff NAME is the mangled form of a constructor name
00161    in the G++ V3 ABI demangling style.  Specifically, return an `enum
00162    gnu_v3_ctor_kinds' value indicating what kind of constructor
00163    it is.  */
00164 extern enum gnu_v3_ctor_kinds
00165        is_gnu_v3_mangled_ctor (const char *name);
00166 
00167 
00168 enum gnu_v3_dtor_kinds {
00169   gnu_v3_deleting_dtor = 1,
00170   gnu_v3_complete_object_dtor,
00171   gnu_v3_base_object_dtor
00172 };
00173 
00174 /* Return non-zero iff NAME is the mangled form of a destructor name
00175    in the G++ V3 ABI demangling style.  Specifically, return an `enum
00176    gnu_v3_dtor_kinds' value, indicating what kind of destructor
00177    it is.  */
00178 extern enum gnu_v3_dtor_kinds
00179        is_gnu_v3_mangled_dtor (const char *name);
00180 
00181 /* The V3 demangler works in two passes.  The first pass builds a tree
00182    representation of the mangled name, and the second pass turns the
00183    tree representation into a demangled string.  Here we define an
00184    interface to permit a caller to build their own tree
00185    representation, which they can pass to the demangler to get a
00186    demangled string.  This can be used to canonicalize user input into
00187    something which the demangler might output.  It could also be used
00188    by other demanglers in the future.  */
00189 
00190 /* These are the component types which may be found in the tree.  Many
00191    component types have one or two subtrees, referred to as left and
00192    right (a component type with only one subtree puts it in the left
00193    subtree).  */
00194 
00195 enum demangle_component_type
00196 {
00197   /* A name, with a length and a pointer to a string.  */
00198   DEMANGLE_COMPONENT_NAME,
00199   /* A qualified name.  The left subtree is a class or namespace or
00200      some such thing, and the right subtree is a name qualified by
00201      that class.  */
00202   DEMANGLE_COMPONENT_QUAL_NAME,
00203   /* A local name.  The left subtree describes a function, and the
00204      right subtree is a name which is local to that function.  */
00205   DEMANGLE_COMPONENT_LOCAL_NAME,
00206   /* A typed name.  The left subtree is a name, and the right subtree
00207      describes that name as a function.  */
00208   DEMANGLE_COMPONENT_TYPED_NAME,
00209   /* A template.  The left subtree is a template name, and the right
00210      subtree is a template argument list.  */
00211   DEMANGLE_COMPONENT_TEMPLATE,
00212   /* A template parameter.  This holds a number, which is the template
00213      parameter index.  */
00214   DEMANGLE_COMPONENT_TEMPLATE_PARAM,
00215   /* A constructor.  This holds a name and the kind of
00216      constructor.  */
00217   DEMANGLE_COMPONENT_CTOR,
00218   /* A destructor.  This holds a name and the kind of destructor.  */
00219   DEMANGLE_COMPONENT_DTOR,
00220   /* A vtable.  This has one subtree, the type for which this is a
00221      vtable.  */
00222   DEMANGLE_COMPONENT_VTABLE,
00223   /* A VTT structure.  This has one subtree, the type for which this
00224      is a VTT.  */
00225   DEMANGLE_COMPONENT_VTT,
00226   /* A construction vtable.  The left subtree is the type for which
00227      this is a vtable, and the right subtree is the derived type for
00228      which this vtable is built.  */
00229   DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
00230   /* A typeinfo structure.  This has one subtree, the type for which
00231      this is the tpeinfo structure.  */
00232   DEMANGLE_COMPONENT_TYPEINFO,
00233   /* A typeinfo name.  This has one subtree, the type for which this
00234      is the typeinfo name.  */
00235   DEMANGLE_COMPONENT_TYPEINFO_NAME,
00236   /* A typeinfo function.  This has one subtree, the type for which
00237      this is the tpyeinfo function.  */
00238   DEMANGLE_COMPONENT_TYPEINFO_FN,
00239   /* A thunk.  This has one subtree, the name for which this is a
00240      thunk.  */
00241   DEMANGLE_COMPONENT_THUNK,
00242   /* A virtual thunk.  This has one subtree, the name for which this
00243      is a virtual thunk.  */
00244   DEMANGLE_COMPONENT_VIRTUAL_THUNK,
00245   /* A covariant thunk.  This has one subtree, the name for which this
00246      is a covariant thunk.  */
00247   DEMANGLE_COMPONENT_COVARIANT_THUNK,
00248   /* A Java class.  This has one subtree, the type.  */
00249   DEMANGLE_COMPONENT_JAVA_CLASS,
00250   /* A guard variable.  This has one subtree, the name for which this
00251      is a guard variable.  */
00252   DEMANGLE_COMPONENT_GUARD,
00253   /* A reference temporary.  This has one subtree, the name for which
00254      this is a temporary.  */
00255   DEMANGLE_COMPONENT_REFTEMP,
00256   /* A hidden alias.  This has one subtree, the encoding for which it
00257      is providing alternative linkage.  */
00258   DEMANGLE_COMPONENT_HIDDEN_ALIAS,
00259   /* A standard substitution.  This holds the name of the
00260      substitution.  */
00261   DEMANGLE_COMPONENT_SUB_STD,
00262   /* The restrict qualifier.  The one subtree is the type which is
00263      being qualified.  */
00264   DEMANGLE_COMPONENT_RESTRICT,
00265   /* The volatile qualifier.  The one subtree is the type which is
00266      being qualified.  */
00267   DEMANGLE_COMPONENT_VOLATILE,
00268   /* The const qualifier.  The one subtree is the type which is being
00269      qualified.  */
00270   DEMANGLE_COMPONENT_CONST,
00271   /* The restrict qualifier modifying a member function.  The one
00272      subtree is the type which is being qualified.  */
00273   DEMANGLE_COMPONENT_RESTRICT_THIS,
00274   /* The volatile qualifier modifying a member function.  The one
00275      subtree is the type which is being qualified.  */
00276   DEMANGLE_COMPONENT_VOLATILE_THIS,
00277   /* The const qualifier modifying a member function.  The one subtree
00278      is the type which is being qualified.  */
00279   DEMANGLE_COMPONENT_CONST_THIS,
00280   /* A vendor qualifier.  The left subtree is the type which is being
00281      qualified, and the right subtree is the name of the
00282      qualifier.  */
00283   DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
00284   /* A pointer.  The one subtree is the type which is being pointed
00285      to.  */
00286   DEMANGLE_COMPONENT_POINTER,
00287   /* A reference.  The one subtree is the type which is being
00288      referenced.  */
00289   DEMANGLE_COMPONENT_REFERENCE,
00290   /* A complex type.  The one subtree is the base type.  */
00291   DEMANGLE_COMPONENT_COMPLEX,
00292   /* An imaginary type.  The one subtree is the base type.  */
00293   DEMANGLE_COMPONENT_IMAGINARY,
00294   /* A builtin type.  This holds the builtin type information.  */
00295   DEMANGLE_COMPONENT_BUILTIN_TYPE,
00296   /* A vendor's builtin type.  This holds the name of the type.  */
00297   DEMANGLE_COMPONENT_VENDOR_TYPE,
00298   /* A function type.  The left subtree is the return type.  The right
00299      subtree is a list of ARGLIST nodes.  Either or both may be
00300      NULL.  */
00301   DEMANGLE_COMPONENT_FUNCTION_TYPE,
00302   /* An array type.  The left subtree is the dimension, which may be
00303      NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
00304      expression.  The right subtree is the element type.  */
00305   DEMANGLE_COMPONENT_ARRAY_TYPE,
00306   /* A pointer to member type.  The left subtree is the class type,
00307      and the right subtree is the member type.  CV-qualifiers appear
00308      on the latter.  */
00309   DEMANGLE_COMPONENT_PTRMEM_TYPE,
00310   /* An argument list.  The left subtree is the current argument, and
00311      the right subtree is either NULL or another ARGLIST node.  */
00312   DEMANGLE_COMPONENT_ARGLIST,
00313   /* A template argument list.  The left subtree is the current
00314      template argument, and the right subtree is either NULL or
00315      another TEMPLATE_ARGLIST node.  */
00316   DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
00317   /* An operator.  This holds information about a standard
00318      operator.  */
00319   DEMANGLE_COMPONENT_OPERATOR,
00320   /* An extended operator.  This holds the number of arguments, and
00321      the name of the extended operator.  */
00322   DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
00323   /* A typecast, represented as a unary operator.  The one subtree is
00324      the type to which the argument should be cast.  */
00325   DEMANGLE_COMPONENT_CAST,
00326   /* A unary expression.  The left subtree is the operator, and the
00327      right subtree is the single argument.  */
00328   DEMANGLE_COMPONENT_UNARY,
00329   /* A binary expression.  The left subtree is the operator, and the
00330      right subtree is a BINARY_ARGS.  */
00331   DEMANGLE_COMPONENT_BINARY,
00332   /* Arguments to a binary expression.  The left subtree is the first
00333      argument, and the right subtree is the second argument.  */
00334   DEMANGLE_COMPONENT_BINARY_ARGS,
00335   /* A trinary expression.  The left subtree is the operator, and the
00336      right subtree is a TRINARY_ARG1.  */
00337   DEMANGLE_COMPONENT_TRINARY,
00338   /* Arguments to a trinary expression.  The left subtree is the first
00339      argument, and the right subtree is a TRINARY_ARG2.  */
00340   DEMANGLE_COMPONENT_TRINARY_ARG1,
00341   /* More arguments to a trinary expression.  The left subtree is the
00342      second argument, and the right subtree is the third argument.  */
00343   DEMANGLE_COMPONENT_TRINARY_ARG2,
00344   /* A literal.  The left subtree is the type, and the right subtree
00345      is the value, represented as a DEMANGLE_COMPONENT_NAME.  */
00346   DEMANGLE_COMPONENT_LITERAL,
00347   /* A negative literal.  Like LITERAL, but the value is negated.
00348      This is a minor hack: the NAME used for LITERAL points directly
00349      to the mangled string, but since negative numbers are mangled
00350      using 'n' instead of '-', we want a way to indicate a negative
00351      number which involves neither modifying the mangled string nor
00352      allocating a new copy of the literal in memory.  */
00353   DEMANGLE_COMPONENT_LITERAL_NEG
00354 };
00355 
00356 /* Types which are only used internally.  */
00357 
00358 struct demangle_operator_info;
00359 struct demangle_builtin_type_info;
00360 
00361 /* A node in the tree representation is an instance of a struct
00362    demangle_component.  Note that the field names of the struct are
00363    not well protected against macros defined by the file including
00364    this one.  We can fix this if it ever becomes a problem.  */
00365 
00366 struct demangle_component
00367 {
00368   /* The type of this component.  */
00369   enum demangle_component_type type;
00370 
00371   union
00372   {
00373     /* For DEMANGLE_COMPONENT_NAME.  */
00374     struct
00375     {
00376       /* A pointer to the name (which need not NULL terminated) and
00377         its length.  */
00378       const char *s;
00379       int len;
00380     } s_name;
00381 
00382     /* For DEMANGLE_COMPONENT_OPERATOR.  */
00383     struct
00384     {
00385       /* Operator.  */
00386       const struct demangle_operator_info *op;
00387     } s_operator;
00388 
00389     /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR.  */
00390     struct
00391     {
00392       /* Number of arguments.  */
00393       int args;
00394       /* Name.  */
00395       struct demangle_component *name;
00396     } s_extended_operator;
00397 
00398     /* For DEMANGLE_COMPONENT_CTOR.  */
00399     struct
00400     {
00401       /* Kind of constructor.  */
00402       enum gnu_v3_ctor_kinds kind;
00403       /* Name.  */
00404       struct demangle_component *name;
00405     } s_ctor;
00406 
00407     /* For DEMANGLE_COMPONENT_DTOR.  */
00408     struct
00409     {
00410       /* Kind of destructor.  */
00411       enum gnu_v3_dtor_kinds kind;
00412       /* Name.  */
00413       struct demangle_component *name;
00414     } s_dtor;
00415 
00416     /* For DEMANGLE_COMPONENT_BUILTIN_TYPE.  */
00417     struct
00418     {
00419       /* Builtin type.  */
00420       const struct demangle_builtin_type_info *type;
00421     } s_builtin;
00422 
00423     /* For DEMANGLE_COMPONENT_SUB_STD.  */
00424     struct
00425     {
00426       /* Standard substitution string.  */
00427       const char* string;
00428       /* Length of string.  */
00429       int len;
00430     } s_string;
00431 
00432     /* For DEMANGLE_COMPONENT_TEMPLATE_PARAM.  */
00433     struct
00434     {
00435       /* Template parameter index.  */
00436       long number;
00437     } s_number;
00438 
00439     /* For other types.  */
00440     struct
00441     {
00442       /* Left (or only) subtree.  */
00443       struct demangle_component *left;
00444       /* Right subtree.  */
00445       struct demangle_component *right;
00446     } s_binary;
00447 
00448   } u;
00449 };
00450 
00451 /* People building mangled trees are expected to allocate instances of
00452    struct demangle_component themselves.  They can then call one of
00453    the following functions to fill them in.  */
00454 
00455 /* Fill in most component types with a left subtree and a right
00456    subtree.  Returns non-zero on success, zero on failure, such as an
00457    unrecognized or inappropriate component type.  */
00458 
00459 extern int
00460 cplus_demangle_fill_component (struct demangle_component *fill,
00461                                enum demangle_component_type,
00462                                struct demangle_component *left,
00463                                struct demangle_component *right);
00464 
00465 /* Fill in a DEMANGLE_COMPONENT_NAME.  Returns non-zero on success,
00466    zero for bad arguments.  */
00467 
00468 extern int
00469 cplus_demangle_fill_name (struct demangle_component *fill,
00470                           const char *, int);
00471 
00472 /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
00473    builtin type (e.g., "int", etc.).  Returns non-zero on success,
00474    zero if the type is not recognized.  */
00475 
00476 extern int
00477 cplus_demangle_fill_builtin_type (struct demangle_component *fill,
00478                                   const char *type_name);
00479 
00480 /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
00481    operator and the number of arguments which it takes (the latter is
00482    used to disambiguate operators which can be both binary and unary,
00483    such as '-').  Returns non-zero on success, zero if the operator is
00484    not recognized.  */
00485 
00486 extern int
00487 cplus_demangle_fill_operator (struct demangle_component *fill,
00488                               const char *opname, int args);
00489 
00490 /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
00491    number of arguments and the name.  Returns non-zero on success,
00492    zero for bad arguments.  */
00493 
00494 extern int
00495 cplus_demangle_fill_extended_operator (struct demangle_component *fill,
00496                                        int numargs,
00497                                        struct demangle_component *nm);
00498 
00499 /* Fill in a DEMANGLE_COMPONENT_CTOR.  Returns non-zero on success,
00500    zero for bad arguments.  */
00501 
00502 extern int
00503 cplus_demangle_fill_ctor (struct demangle_component *fill,
00504                           enum gnu_v3_ctor_kinds kind,
00505                           struct demangle_component *name);
00506 
00507 /* Fill in a DEMANGLE_COMPONENT_DTOR.  Returns non-zero on success,
00508    zero for bad arguments.  */
00509 
00510 extern int
00511 cplus_demangle_fill_dtor (struct demangle_component *fill,
00512                           enum gnu_v3_dtor_kinds kind,
00513                           struct demangle_component *name);
00514 
00515 /* This function translates a mangled name into a struct
00516    demangle_component tree.  The first argument is the mangled name.
00517    The second argument is DMGL_* options.  This returns a pointer to a
00518    tree on success, or NULL on failure.  On success, the third
00519    argument is set to a block of memory allocated by malloc.  This
00520    block should be passed to free when the tree is no longer
00521    needed.  */
00522 
00523 extern struct demangle_component *
00524 cplus_demangle_v3_components (const char *mangled, int options, void **mem);
00525 
00526 /* This function takes a struct demangle_component tree and returns
00527    the corresponding demangled string.  The first argument is DMGL_*
00528    options.  The second is the tree to demangle.  The third is a guess
00529    at the length of the demangled string, used to initially allocate
00530    the return buffer.  The fourth is a pointer to a size_t.  On
00531    success, this function returns a buffer allocated by malloc(), and
00532    sets the size_t pointed to by the fourth argument to the size of
00533    the allocated buffer (not the length of the returned string).  On
00534    failure, this function returns NULL, and sets the size_t pointed to
00535    by the fourth argument to 0 for an invalid tree, or to 1 for a
00536    memory allocation error.  */
00537 
00538 extern char *
00539 cplus_demangle_print (int options,
00540                       const struct demangle_component *tree,
00541                       int estimated_length,
00542                       size_t *p_allocated_size);
00543 
00544 /* This function takes a struct demangle_component tree and passes back
00545    a demangled string in one or more calls to a callback function.
00546    The first argument is DMGL_* options.  The second is the tree to
00547    demangle.  The third is a pointer to a callback function; on each call
00548    this receives an element of the demangled string, its length, and an
00549    opaque value.  The fourth is the opaque value passed to the callback.
00550    The callback is called once or more to return the full demangled
00551    string.  The demangled element string is always nul-terminated, though
00552    its length is also provided for convenience.  In contrast to
00553    cplus_demangle_print(), this function does not allocate heap memory
00554    to grow output strings (except perhaps where alloca() is implemented
00555    by malloc()), and so is normally safe for use where the heap has been
00556    corrupted.  On success, this function returns 1; on failure, 0.  */
00557 
00558 extern int
00559 cplus_demangle_print_callback (int options,
00560                                const struct demangle_component *tree,
00561                                demangle_callbackref callback, void *opaque);
00562 
00563 #ifdef __cplusplus
00564 }
00565 #endif /* __cplusplus */
00566 
00567 #endif /* DEMANGLE_H */