X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fdemangle.cc;h=78520433c7f0ffefb24410f3b88106e3b4a2598d;hb=f1d64f7debcbf236e73b8ccef942ffbd81ec1929;hp=e858181a68f4ec83b4a3e30e71ba13c5bb082cd8;hpb=e5d36443c6d03453f985721a6b16b4f1749846c4;p=platform%2Fupstream%2Fglog.git diff --git a/src/demangle.cc b/src/demangle.cc index e858181..7852043 100644 --- a/src/demangle.cc +++ b/src/demangle.cc @@ -35,10 +35,16 @@ // Note that we only have partial C++0x support yet. #include // for NULL +#include "utilities.h" #include "demangle.h" +#if defined(OS_WINDOWS) +#include +#endif + _START_GOOGLE_NAMESPACE_ +#if !defined(OS_WINDOWS) typedef struct { const char *abbrev; const char *real_name; @@ -1293,12 +1299,37 @@ static bool ParseTopLevelMangledName(State *state) { } return false; } +#endif // The demangler entry point. bool Demangle(const char *mangled, char *out, int out_size) { +#if defined(OS_WINDOWS) + // When built with incremental linking, the Windows debugger + // library provides a more complicated `Symbol->Name` with the + // Incremental Linking Table offset, which looks like + // `@ILT+1105(?func@Foo@@SAXH@Z)`. However, the demangler expects + // only the mangled symbol, `?func@Foo@@SAXH@Z`. Fortunately, the + // mangled symbol is guaranteed not to have parentheses, + // so we search for `(` and extract up to `)`. + // + // Since we may be in a signal handler here, we cannot use `std::string`. + char buffer[1024]; // Big enough for a sane symbol. + const char *lparen = strchr(mangled, '('); + if (lparen) { + // Extract the string `(?...)` + const char *rparen = strchr(lparen, ')'); + size_t length = rparen - lparen - 1; + strncpy(buffer, lparen + 1, length); + buffer[length] = '\0'; + mangled = buffer; + } // Else the symbol wasn't inside a set of parentheses + // We use the ANSI version to ensure the string type is always `char *`. + return UnDecorateSymbolName(mangled, out, out_size, UNDNAME_COMPLETE); +#else State state; InitState(&state, mangled, out, out_size); return ParseTopLevelMangledName(&state) && !state.overflowed; +#endif } _END_GOOGLE_NAMESPACE_