summaryrefslogtreecommitdiffstats
path: root/rtemstoolkit/elftoolchain/libelftc/elftc_demangle.3
blob: 44cf0073ca55852e7b905900bc1d86970aa8f0df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
.\" Copyright (c) 2009,2011 Joseph Koshy.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" This software is provided by Joseph Koshy ``as is'' and
.\" any express or implied warranties, including, but not limited to, the
.\" implied warranties of merchantability and fitness for a particular purpose
.\" are disclaimed.  in no event shall Joseph Koshy be liable
.\" for any direct, indirect, incidental, special, exemplary, or consequential
.\" damages (including, but not limited to, procurement of substitute goods
.\" or services; loss of use, data, or profits; or business interruption)
.\" however caused and on any theory of liability, whether in contract, strict
.\" liability, or tort (including negligence or otherwise) arising in any way
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $Id: elftc_demangle.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd August 24, 2011
.Os
.Dt ELFTC_DEMANGLE 3
.Sh NAME
.Nm elftc_demangle
.Nd demangle a C++ name
.Sh LIBRARY
.Lb libelftc
.Sh SYNOPSIS
.In libelftc.h
.Ft int
.Fo elftc_demangle
.Fa "const char *encodedname"
.Fa "char *buffer"
.Fa "size_t bufsize"
.Fa "unsigned int flags"
.Fc
.Sh DESCRIPTION
Function
.Fn elftc_demangle
decodes a symbol name encoded according to the type encoding rules
for the C++ language and returns a string denoting an equivalent
C++ prototype.
.Pp
Argument
.Ar encodedname
specifies the encoded symbol name.
Argument
.Ar buffer
denotes a programmer-specified area to place the prototype string in.
Argument
.Ar bufsize
specifies the size of the programmer-specified area.
Argument
.Ar flags
specifies the encoding style in use for argument
.Ar encodedname .
Supported encoding styles are:
.Bl -tag -width ".Dv ELFTC_DEM_GNU3"
.It Dv ELFTC_DEM_ARM
The encoding style used by compilers adhering to the conventions of the
C++ Annotated Reference Manual.
.It Dv ELFTC_DEM_GNU2
The encoding style by GNU C++ version 2.
.It Dv ELFTC_DEM_GNU3
The encoding style by GNU C++ version 3 and later.
.El
.Pp
Argument
.Ar flags
may be zero, in which case the function will attempt to guess the
encoding scheme from the contents of
.Ar encodedname .
.Sh RETURN VALUE
Function
.Fn elftc_demangle
returns 0 on success.
In case of an error it returns -1 and sets the
.Va errno
variable.
.Sh EXAMPLES
To decode a name that uses an unknown encoding style use:
.Bd -literal -offset indent
char buffer[1024];
const char *funcname;

funcname = ...; /* points to string to be demangled */
if (elftc_demangle(funcname, buffer, sizeof(buffer), 0) == 0)
	printf("Demangled name: %\\n", buffer);
else
	perror("Cannot demangle %s", funcname);
.Ed
.Sh ERRORS
Function
.Fn elftc_demangle
may fail with the following errors:
.Bl -tag -width ".Bq Er ENAMETOOLONG"
.It Bq Er EINVAL
Argument
.Ar encodedname
was not a valid encoded name.
.It Bq Er ENAMETOOLONG
The output buffer specified by arguments
.Ar buffer
and
.Ar bufsize
was too small to hold the decoded function prototype.
.El
.Sh SEE ALSO
.Xr elf 3 ,
.Xr elf_strptr 3