[Lldb-commits] [lldb] r270941 - Add a new "lldb" log channel named "demangle". If we have crashes that are related to demangling, we now can enable this logging and we will be able to reproduce demangler crashes (usually due to overflowing the stack) without needing someone's project.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu May 26 17:56:30 PDT 2016


Just curious, is this related to the dump I sent you a while back?

On Thu, May 26, 2016 at 5:23 PM Greg Clayton via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

> Author: gclayton
> Date: Thu May 26 19:17:18 2016
> New Revision: 270941
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270941&view=rev
> Log:
> Add a new "lldb" log channel named "demangle". If we have crashes that are
> related to demangling, we now can enable this logging and we will be able
> to reproduce demangler crashes (usually due to overflowing the stack)
> without needing someone's project.
>
> <rdar://problem/25221899>
>
> Modified:
>     lldb/trunk/include/lldb/Core/Logging.h
>     lldb/trunk/source/Core/Logging.cpp
>     lldb/trunk/source/Core/Mangled.cpp
>
> Modified: lldb/trunk/include/lldb/Core/Logging.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Logging.h?rev=270941&r1=270940&r2=270941&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/Logging.h (original)
> +++ lldb/trunk/include/lldb/Core/Logging.h Thu May 26 19:17:18 2016
> @@ -49,6 +49,7 @@
>  #define LIBLLDB_LOG_JIT_LOADER          (1u << 27)
>  #define LIBLLDB_LOG_LANGUAGE            (1u << 28)
>  #define LIBLLDB_LOG_DATAFORMATTERS      (1u << 29)
> +#define LIBLLDB_LOG_DEMANGLE            (1u << 30)
>  #define LIBLLDB_LOG_ALL                 (UINT32_MAX)
>  #define LIBLLDB_LOG_DEFAULT             (LIBLLDB_LOG_PROCESS
> |\
>                                           LIBLLDB_LOG_THREAD
>  |\
>
> Modified: lldb/trunk/source/Core/Logging.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Logging.cpp?rev=270941&r1=270940&r2=270941&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Logging.cpp (original)
> +++ lldb/trunk/source/Core/Logging.cpp Thu May 26 19:17:18 2016
> @@ -150,6 +150,7 @@ lldb_private::DisableLog (const char **c
>                  else if (0 == ::strcasecmp(arg, "jit"))         flag_bits
> &= ~LIBLLDB_LOG_JIT_LOADER;
>                  else if (0 == ::strcasecmp(arg, "language"))    flag_bits
> &= ~LIBLLDB_LOG_LANGUAGE;
>                  else if (0 == ::strncasecmp(arg, "formatters", 10))
>  flag_bits &= ~LIBLLDB_LOG_DATAFORMATTERS;
> +                else if (0 == ::strncasecmp(arg, "demangle", 8))
> flag_bits &= ~LIBLLDB_LOG_DEMANGLE;
>                  else
>                  {
>                      feedback_strm->Printf ("error:  unrecognized log
> category '%s'\n", arg);
> @@ -225,6 +226,7 @@ lldb_private::EnableLog (StreamSP &log_s
>              else if (0 == ::strcasecmp(arg, "jit"))         flag_bits |=
> LIBLLDB_LOG_JIT_LOADER;
>              else if (0 == ::strcasecmp(arg, "language"))    flag_bits |=
> LIBLLDB_LOG_LANGUAGE;
>              else if (0 == ::strncasecmp(arg, "formatters", 10))
>  flag_bits |= LIBLLDB_LOG_DATAFORMATTERS;
> +            else if (0 == ::strncasecmp(arg, "demangle", 8))
> flag_bits |= LIBLLDB_LOG_DEMANGLE;
>              else
>              {
>                  feedback_strm->Printf("error: unrecognized log category
> '%s'\n", arg);
> @@ -251,6 +253,7 @@ lldb_private::ListLogCategories (Stream
>                   "  communication - log communication activities\n"
>                   "  connection - log connection details\n"
>                   "  default - enable the default set of logging
> categories for liblldb\n"
> +                 "  demangle - log mangled names to catch demangler
> crashes\n"
>                   "  dyld - log shared library related activities\n"
>                   "  events - log broadcaster, listener and event queue
> activities\n"
>                   "  expr - log expressions\n"
>
> Modified: lldb/trunk/source/Core/Mangled.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=270941&r1=270940&r2=270941&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Mangled.cpp (original)
> +++ lldb/trunk/source/Core/Mangled.cpp Thu May 26 19:17:18 2016
> @@ -34,6 +34,8 @@
>  #include "llvm/ADT/DenseMap.h"
>
>  #include "lldb/Core/ConstString.h"
> +#include "lldb/Core/Log.h"
> +#include "lldb/Core/Logging.h"
>  #include "lldb/Core/Mangled.h"
>  #include "lldb/Core/RegularExpression.h"
>  #include "lldb/Core/Stream.h"
> @@ -271,6 +273,8 @@ Mangled::GetDemangledName (lldb::Languag
>                              "Mangled::GetDemangledName (m_mangled = %s)",
>                              m_mangled.GetCString());
>
> +        Log *log = lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_DEMANGLE);
> +
>          // Don't bother running anything that isn't mangled
>          const char *mangled_name = m_mangled.GetCString();
>          ManglingScheme
> mangling_scheme{cstring_mangling_scheme(mangled_name)};
> @@ -285,6 +289,8 @@ Mangled::GetDemangledName (lldb::Languag
>                  case eManglingSchemeMSVC:
>                  {
>  #if defined(_MSC_VER)
> +                    if (log)
> +                        log->Printf("demangle msvc: %s", mangled_name);
>                      const size_t demangled_length = 2048;
>                      demangled_name = static_cast<char
> *>(::malloc(demangled_length));
>                      ::ZeroMemory(demangled_name, demangled_length);
> @@ -295,6 +301,14 @@ Mangled::GetDemangledName (lldb::Languag
>                              UNDNAME_NO_MEMBER_TYPE         | // Strip
> virtual, static, etc specifiers
>                              UNDNAME_NO_MS_KEYWORDS           // Strip all
> MS extension keywords
>                          );
> +                    if (log)
> +                    {
> +                        if (demangled_name && demangled_name[0])
> +                            log->Printf("demangled msvc: %s -> \"%s\"",
> mangled_name, demangled_name);
> +                        else
> +                            log->Printf("demangled msvc: %s -> error:
> 0x%" PRIx64, mangled_name, result);
> +                    }
> +
>                      if (result == 0)
>                      {
>                          free(demangled_name);
> @@ -306,6 +320,8 @@ Mangled::GetDemangledName (lldb::Languag
>                  case eManglingSchemeItanium:
>                  {
>  #ifdef LLDB_USE_BUILTIN_DEMANGLER
> +                    if (log)
> +                        log->Printf("demangle itanium: %s", mangled_name);
>                      // Try to use the fast-path demangler first for the
>                      // performance win, falling back to the full
> demangler only
>                      // when necessary
> @@ -315,6 +331,13 @@ Mangled::GetDemangledName (lldb::Languag
>  #else
>                      demangled_name = abi::__cxa_demangle(mangled_name,
> NULL, NULL, NULL);
>  #endif
> +                    if (log)
> +                    {
> +                        if (demangled_name)
> +                            log->Printf("demangled itanium: %s ->
> \"%s\"", mangled_name, demangled_name);
> +                        else
> +                            log->Printf("demangled itanium: %s -> error:
> failed to demangle", mangled_name);
> +                    }
>                      break;
>                  }
>                  case eManglingSchemeNone:
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160527/8112cc17/attachment-0001.html>


More information about the lldb-commits mailing list