예제 #1
0
  static void print_demangle(std::string s) {
    squeeze_space(s);
    const char* str = s.c_str();
    const char* pos = strstr(str, " _Z");
    /* Found a mangle. */
    if(pos) {
      size_t sz = 1024;
      char *cpp_name = 0;
      char* name = strdup(pos + 1);
      char* end = strstr(name, " + ");
      *end = 0;

      int status;
      cpp_name = abi::__cxa_demangle(name, cpp_name, &sz, &status);

      if(!status) {
        std::string full_cpp = std::string(str, pos - str) + " " + cpp_name +
          " " + (++end);
        s = full_cpp;
      }
      if(cpp_name) free(cpp_name);
      free(name);
    }

    printf("%s\n", s.c_str());
  }
예제 #2
0
  static void demangle(VMException::Backtrace& s) {
    for (size_t i = 0; i < s.size(); i++) {
      squeeze_space(s[i]);
      const char* str = s[i].c_str();
      const char* pos = strstr(str, " _Z");
      /* Found a mangle. */
      if(pos) {
        size_t sz = 1024;
        char *cpp_name = 0;
        char* name = strdup(pos + 1);
        char* end = strstr(name, " + ");
        *end = 0;

        int status;
        cpp_name = abi::__cxa_demangle(name, cpp_name, &sz, &status);

        if(!status) {
          std::string full_cpp = std::string(str, pos - str) + " " + cpp_name +
            " " + (++end);
          s[i] = full_cpp;
        }
        if(cpp_name) free(cpp_name);
        free(name);
      }
    }
  }
예제 #3
0
  static void demangle(VMException::Backtrace& s) {
    for (size_t i = 0; i < s.size(); i++) {
      squeeze_space(s[i]);
      const char* str = s[i].c_str();
      const char* pos = strstr(str, " _Z");
      /* Found a mangle. */
      if(pos) {
        size_t sz = 0;
        char *cpp_name = 0;
        char* name = strdup(pos + 1);
        char* end = strstr(name, " + ");
        *end = 0;

        int status;
        cpp_name = abi::__cxa_demangle(name, cpp_name, &sz, &status);

        // It's possible for __cxa_demangle to return 0x0, which probably
        // shouldn't happen with status == 0, but it was observed in OS X
        // Mavericks Preview 2 so be paranoid.
        if(cpp_name) {
          if(!status) {
            std::string full_cpp = std::string(str, pos - str) + " " + cpp_name +
              " " + (++end);
            s[i] = full_cpp;
          }
          free(cpp_name);
        }
        free(name);
      }
    }
  }