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