Skip to content

Commit

Permalink
utils: fix --demangle=full to only demangle mangled C++ symbols
Browse files Browse the repository at this point in the history
Currently, uftrace demangles all symbols, regardless of whether
they are mangled C++ symbols or unmangled C symbols.

But when setting --demangle=full, uftrace calls __cxa_demangle(),
which translates unmangled symbols confusingly; e.g., "f" is translated to "float".

To address this, now we only call __cxa_demangle() if a symbol is mangled
(starts with "_Z").

Fixed: #1778

Signed-off-by: Yufeng Jin <[email protected]>
  • Loading branch information
jyf111 authored and namhyung committed Jul 30, 2023
1 parent 9a85495 commit e80a263
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/demangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,10 @@ static char *demangle_full(char *str)
size_t len = 64; /* minimum length */
int status;

/* str is not mangled C++ symbol */
if (str[0] != '_' || str[1] != 'Z')
return xstrdup(str);

__cxa_demangle(str, NULL, &len, &status);
if (status < 0)
return xstrdup(str);
Expand Down

0 comments on commit e80a263

Please sign in to comment.