https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92170

X Ryl <boite.pour.spam at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boite.pour.spam at gmail dot 
com

--- Comment #8 from X Ryl <boite.pour.spam at gmail dot com> ---
Is there a reason why -fstack-usage doesn't output mangled name ?
It's very easy to run the output through c++filt.

Wouldn't it better if it was consistent with other tools and as such could be
compared ?

Typically, there is a tool (https://www.dlbeer.co.nz/oss/avstack.html) that's
used to compute the minimum stack size required for a program, and the fact
that -fstack-usage breaks for C++ (either with wrong names, or it outputs non
mangled name), it's not possible to link the reported stack usage with the
functions in the produced binary (for example, with objdump)

Even when the C++ item does not contain fancy dot, this is still a real pain
because if you demangle objdump's output, you'll get:

unsigned char * MyClass::foo(unsigned long)

while fstack-usage will return (with typedef):

uint8_t * MyClass::foo(uint64_t)



The patch is very simple, just bypass any demangling here since I don't think
it's the role of this method to demangle for you.






Index: gcc-7.3.0/gcc/toplev.c
===================================================================
--- gcc-7.3.0.orig/gcc/toplev.c
+++ gcc-7.3.0/gcc/toplev.c
@@ -996,28 +996,8 @@ output_stack_usage (void)
     {
       expanded_location loc
        = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
-      /* We don't want to print the full qualified name because it can be
long,
-        so we strip the scope prefix, but we may need to deal with the suffix
-        created by the compiler.  */
-      const char *suffix
-       = strchr (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)), '.');
-      const char *name
-       = lang_hooks.decl_printable_name (current_function_decl, 2);
-      if (suffix)
-       {
-         const char *dot = strchr (name, '.');
-         while (dot && strcasecmp (dot, suffix) != 0)
-           {
-             name = dot + 1;
-             dot = strchr (name, '.');
-           }
-       }
-      else
-       {
-         const char *dot = strrchr (name, '.');
-         if (dot)
-           name = dot + 1;
-       }
+      const char *name = IDENTIFIER_POINTER
+       (DECL_ASSEMBLER_NAME (current_function_decl));

       fprintf (stack_usage_file,
               "%s:%d:%d:%s\t" HOST_WIDE_INT_PRINT_DEC"\t%s\n",

Reply via email to