xref: /freebsd/contrib/elftoolchain/libelftc/elftc_demangle.3 (revision ae500c1ff8974130f7f2692772cf288b90349e0d)
1a85fe12eSEd Maste.\" Copyright (c) 2009,2011 Joseph Koshy.  All rights reserved.
2a85fe12eSEd Maste.\"
3a85fe12eSEd Maste.\" Redistribution and use in source and binary forms, with or without
4a85fe12eSEd Maste.\" modification, are permitted provided that the following conditions
5a85fe12eSEd Maste.\" are met:
6a85fe12eSEd Maste.\" 1. Redistributions of source code must retain the above copyright
7a85fe12eSEd Maste.\"    notice, this list of conditions and the following disclaimer.
8a85fe12eSEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright
9a85fe12eSEd Maste.\"    notice, this list of conditions and the following disclaimer in the
10a85fe12eSEd Maste.\"    documentation and/or other materials provided with the distribution.
11a85fe12eSEd Maste.\"
12a85fe12eSEd Maste.\" This software is provided by Joseph Koshy ``as is'' and
13a85fe12eSEd Maste.\" any express or implied warranties, including, but not limited to, the
14a85fe12eSEd Maste.\" implied warranties of merchantability and fitness for a particular purpose
15a85fe12eSEd Maste.\" are disclaimed.  in no event shall Joseph Koshy be liable
16a85fe12eSEd Maste.\" for any direct, indirect, incidental, special, exemplary, or consequential
17a85fe12eSEd Maste.\" damages (including, but not limited to, procurement of substitute goods
18a85fe12eSEd Maste.\" or services; loss of use, data, or profits; or business interruption)
19a85fe12eSEd Maste.\" however caused and on any theory of liability, whether in contract, strict
20a85fe12eSEd Maste.\" liability, or tort (including negligence or otherwise) arising in any way
21a85fe12eSEd Maste.\" out of the use of this software, even if advised of the possibility of
22a85fe12eSEd Maste.\" such damage.
23a85fe12eSEd Maste.\"
24*ae500c1fSEd Maste.\" $Id: elftc_demangle.3 3645 2018-10-15 20:17:14Z jkoshy $
25a85fe12eSEd Maste.\"
26a85fe12eSEd Maste.Dd August 24, 2011
27a85fe12eSEd Maste.Dt ELFTC_DEMANGLE 3
28*ae500c1fSEd Maste.Os
29a85fe12eSEd Maste.Sh NAME
30a85fe12eSEd Maste.Nm elftc_demangle
31a85fe12eSEd Maste.Nd demangle a C++ name
32a85fe12eSEd Maste.Sh LIBRARY
33a85fe12eSEd Maste.Lb libelftc
34a85fe12eSEd Maste.Sh SYNOPSIS
35a85fe12eSEd Maste.In libelftc.h
36a85fe12eSEd Maste.Ft int
37a85fe12eSEd Maste.Fo elftc_demangle
38a85fe12eSEd Maste.Fa "const char *encodedname"
39a85fe12eSEd Maste.Fa "char *buffer"
40a85fe12eSEd Maste.Fa "size_t bufsize"
41a85fe12eSEd Maste.Fa "unsigned int flags"
42a85fe12eSEd Maste.Fc
43a85fe12eSEd Maste.Sh DESCRIPTION
44a85fe12eSEd MasteFunction
45a85fe12eSEd Maste.Fn elftc_demangle
46a85fe12eSEd Mastedecodes a symbol name encoded according to the type encoding rules
47a85fe12eSEd Mastefor the C++ language and returns a string denoting an equivalent
48a85fe12eSEd MasteC++ prototype.
49a85fe12eSEd Maste.Pp
50a85fe12eSEd MasteArgument
51a85fe12eSEd Maste.Ar encodedname
52a85fe12eSEd Mastespecifies the encoded symbol name.
53a85fe12eSEd MasteArgument
54a85fe12eSEd Maste.Ar buffer
55a85fe12eSEd Mastedenotes a programmer-specified area to place the prototype string in.
56a85fe12eSEd MasteArgument
57a85fe12eSEd Maste.Ar bufsize
58a85fe12eSEd Mastespecifies the size of the programmer-specified area.
59a85fe12eSEd MasteArgument
60a85fe12eSEd Maste.Ar flags
61a85fe12eSEd Mastespecifies the encoding style in use for argument
62a85fe12eSEd Maste.Ar encodedname .
63a85fe12eSEd MasteSupported encoding styles are:
64a85fe12eSEd Maste.Bl -tag -width ".Dv ELFTC_DEM_GNU3"
65a85fe12eSEd Maste.It Dv ELFTC_DEM_ARM
66a85fe12eSEd MasteThe encoding style used by compilers adhering to the conventions of the
67a85fe12eSEd MasteC++ Annotated Reference Manual.
68a85fe12eSEd Maste.It Dv ELFTC_DEM_GNU2
69a85fe12eSEd MasteThe encoding style by GNU C++ version 2.
70a85fe12eSEd Maste.It Dv ELFTC_DEM_GNU3
71a85fe12eSEd MasteThe encoding style by GNU C++ version 3 and later.
72a85fe12eSEd Maste.El
73a85fe12eSEd Maste.Pp
74a85fe12eSEd MasteArgument
75a85fe12eSEd Maste.Ar flags
76a85fe12eSEd Mastemay be zero, in which case the function will attempt to guess the
77a85fe12eSEd Masteencoding scheme from the contents of
78a85fe12eSEd Maste.Ar encodedname .
79*ae500c1fSEd Maste.Sh RETURN VALUES
80a85fe12eSEd MasteFunction
81a85fe12eSEd Maste.Fn elftc_demangle
82a85fe12eSEd Mastereturns 0 on success.
83a85fe12eSEd MasteIn case of an error it returns -1 and sets the
84a85fe12eSEd Maste.Va errno
85a85fe12eSEd Mastevariable.
86a85fe12eSEd Maste.Sh EXAMPLES
87a85fe12eSEd MasteTo decode a name that uses an unknown encoding style use:
88a85fe12eSEd Maste.Bd -literal -offset indent
89a85fe12eSEd Mastechar buffer[1024];
90a85fe12eSEd Masteconst char *funcname;
91a85fe12eSEd Maste
92a85fe12eSEd Mastefuncname = ...; /* points to string to be demangled */
93a85fe12eSEd Masteif (elftc_demangle(funcname, buffer, sizeof(buffer), 0) == 0)
94a85fe12eSEd Maste	printf("Demangled name: %\\n", buffer);
95a85fe12eSEd Masteelse
96a85fe12eSEd Maste	perror("Cannot demangle %s", funcname);
97a85fe12eSEd Maste.Ed
98a85fe12eSEd Maste.Sh ERRORS
99a85fe12eSEd MasteFunction
100a85fe12eSEd Maste.Fn elftc_demangle
101a85fe12eSEd Mastemay fail with the following errors:
102a85fe12eSEd Maste.Bl -tag -width ".Bq Er ENAMETOOLONG"
103a85fe12eSEd Maste.It Bq Er EINVAL
104a85fe12eSEd MasteArgument
105a85fe12eSEd Maste.Ar encodedname
106a85fe12eSEd Mastewas not a valid encoded name.
107a85fe12eSEd Maste.It Bq Er ENAMETOOLONG
108a85fe12eSEd MasteThe output buffer specified by arguments
109a85fe12eSEd Maste.Ar buffer
110a85fe12eSEd Masteand
111a85fe12eSEd Maste.Ar bufsize
112a85fe12eSEd Mastewas too small to hold the decoded function prototype.
113a85fe12eSEd Maste.El
114a85fe12eSEd Maste.Sh SEE ALSO
115a85fe12eSEd Maste.Xr elf 3 ,
116a85fe12eSEd Maste.Xr elf_strptr 3
117