Skip to content

Commit

Permalink
Add common/symbolDemangle.c
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent 91ae028 commit 9fe9b39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
19 changes: 0 additions & 19 deletions common/src/symbolDemangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,6 @@
#include "symbolDemangle.h"


// Returns a malloc'd string that is the demangled symbol name. THe caller is
// responsible for the freeing this memory. Returns NULL on malloc failure.
// The symbol name symName is demangled using the cplus_demangle function after
// first removing any versioning suffixes (first '@')
// to create the mangled name. If cplus_demangle fails, the mangled name
// is returned unmodified. If cplus_demangle succeeds and includeParams is
// false, then any clone suffixes (the first '.' to the end of the mangled
// name) are appended to the value from cplus_demangle.
//
// Other than the removal of versioning suffixes, and appending any
// clone suffixes if includeParams is false to the result, the result should be
// equivalent to using c++filt. Below are the c++filt and cplus_demangle
// options
//
// includeParams c++ filt opts cplus_demangle opts
// ------------- ------------- -------------------
// false -i -p DMGL_AUTO | DMGL_ANSI
// true -i DMGL_AUTO | DMGL_ANSI | DMGL_PARAMS
//
char *symbol_demangle(const char *symName, int includeParams)
{
int cloneOffset = -1; // offset to clone suffix
Expand Down
19 changes: 19 additions & 0 deletions docs/common/developer/symbolDemangle.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,22 @@ symbolDemangle.h
################

.. cpp:function:: char *symbol_demangle(const char *symName, int includeParams)

Returns a malloc'd string that is the demangled symbol name. THe caller is
responsible for the freeing this memory. Returns NULL on malloc failure.
The symbol name symName is demangled using the cplus_demangle function after
first removing any versioning suffixes (first '@')
to create the mangled name. If cplus_demangle fails, the mangled name
is returned unmodified. If cplus_demangle succeeds and includeParams is
false, then any clone suffixes (the first '.' to the end of the mangled
name) are appended to the value from cplus_demangle.

Other than the removal of versioning suffixes, and appending any
clone suffixes if includeParams is false to the result, the result should be
equivalent to using c++filt.

.. csv-table:: c++filt and cplus_demangle options
:header: "includeParams", "c++ filt opts", "cplus_demangle opts"

"false","-i -p","DMGL_AUTO | DMGL_ANSI"
"true","-i","DMGL_AUTO | DMGL_ANSI | DMGL_PARAMS"

0 comments on commit 9fe9b39

Please sign in to comment.