当前位置: 首页>>代码示例>>C++>>正文


C++ demangle函数代码示例

本文整理汇总了C++中demangle函数的典型用法代码示例。如果您正苦于以下问题:C++ demangle函数的具体用法?C++ demangle怎么用?C++ demangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了demangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: str

void OneshotTracer::tick(std::map<pid_t, std::vector<Frame>> stacktraces) {
    for (const auto& kv: stacktraces) {
        std::cout << boost::format("Thread %d:\n") % kv.first;
        for (const auto& frame: kv.second) {
            std::cout << str(boost::format("0x%x %s\n") %
                        frame.ip %
                        abbrev(demangle(frame.procName)));
        }
        std::cout << std::endl;
    }
}
开发者ID:eeight,项目名称:wat,代码行数:11,代码来源:oneshot_tracer.cpp

示例2: type_string

const string_t type_string(const std::type_info& Info)
{
	detail::initialize_types();

	detail::type_to_name_map_t::iterator type = detail::type_to_name_map.find(detail::type_info(Info));
	if(type != detail::type_to_name_map.end())
		return type->second;

	log() << error << k3d_file_reference << ": unknown type: " << demangle(Info) << std::endl;
	return "";
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:11,代码来源:type_registry.cpp

示例3: demangle

std::string
Transient::getTimeStepperName()
{
  if (_time_stepper)
  {
    TimeStepper & ts = *_time_stepper;
    return demangle(typeid(ts).name());
  }
  else
    return std::string();
}
开发者ID:modulexcite,项目名称:moose,代码行数:11,代码来源:Transient.C

示例4: _ex_terminate

static void _ex_terminate()
{
    static bool already_tried = false;

    Log::setLogHandler(NULL);

    try
    {
        // try once to re-throw currently active exception
        if( !already_tried )
        {
        	already_tried = true;
        	throw;
        }
    }
    catch( const RuntimeError &e )
    {
    	e.Log();
    }
    catch (const std::exception &e)
    {
        do_log_msg( LOG_PRIORITY_ERROR, NULL, typeid(e).name(), e.what() );
    }
    catch (...) {
        do_log_msg( LOG_PRIORITY_ERROR, NULL, "Unknown", "Unknown exception" );
    }

	fprintf( stderr, "Unhandled exception, program terminated\n" );

#ifndef SMART_LOG_NO_BACKTRACE

	fprintf( stderr, "Backtrace:\n" );

    void* fnAddr[UTIL_LOG_BACKTRACE_SIZE];
    int size = backtrace(fnAddr, UTIL_LOG_BACKTRACE_SIZE);

    char** fnSyms = backtrace_symbols(fnAddr, size);

    if( fnSyms != NULL )
    {
		// We skip the first call in the stack, which is the call to this
    	// function
		for (int i=1; i < size; i++)
		{
		    fprintf( stderr,"[%d]: %s\n", i, demangle(fnSyms[i]).c_str() );
		}

		free(fnSyms);
    }

#endif // SMART_LOG_NO_BACKTRACE

    abort();
}
开发者ID:jgonzalezdr,项目名称:smartlib,代码行数:54,代码来源:Log.cpp

示例5: main

int main() {
  struct {
    const char* raw;
    const char* expect;
  } TestCases[] = {
      {typeid(int).name(), "i"}, // FIXME
      {typeid(MyType).name(), "MyType"},
      {typeid(ArgumentListID<int, MyType>).name(), "ArgumentListID<int, MyType>"}
  };
  const size_t size = sizeof(TestCases) / sizeof(TestCases[0]);
  for (size_t i=0; i < size; ++i) {
    const char* raw = TestCases[i].raw;
    const char* expect = TestCases[i].expect;
#ifdef TEST_HAS_NO_DEMANGLE
    assert(demangle(raw) == raw);
#else
    assert(demangle(raw) == expect);
#endif
  }
}
开发者ID:kraj,项目名称:libcxx,代码行数:20,代码来源:test_demangle.pass.cpp

示例6: splitFilePath

void FSEventsService::rename(std::vector<std::string> *paths) {
  auto *binNamesByPath = new std::map<std::string, std::vector<std::string> *>;

  for (auto pathIterator = paths->begin(); pathIterator != paths->end(); ++pathIterator) {
    std::string directory, name;
    splitFilePath(directory, name, *pathIterator);
    if (binNamesByPath->find(directory) == binNamesByPath->end()) {
      (*binNamesByPath)[directory] = new std::vector<std::string>;
    }
    (*binNamesByPath)[directory]->push_back(name);
  }

  for (auto binIterator = binNamesByPath->begin(); binIterator != binNamesByPath->end(); ++binIterator) {
    if (binIterator->second->size() == 2) {
      std::string sideA = (*binIterator->second)[0],
                  sideB = (*binIterator->second)[1];
      std::string fullSideA = binIterator->first + "/" + sideA,
                  fullSideB = binIterator->first + "/" + sideB;
      struct stat renameSideA, renameSideB;
      bool sideAExists = stat(fullSideA.c_str(), &renameSideA) == 0,
           sideBExists = stat(fullSideB.c_str(), &renameSideB) == 0;

      if (sideAExists && !sideBExists) {
        mQueue.enqueue(RENAMED, binIterator->first, sideB, sideA);
      } else if (!sideAExists && sideBExists) {
        mQueue.enqueue(RENAMED, binIterator->first, sideA, sideB);
      } else {
        demangle(fullSideA);
        demangle(fullSideB);
      }

    } else {
      for (auto pathIterator = binIterator->second->begin(); pathIterator != binIterator->second->end(); ++pathIterator) {
        demangle(binIterator->first + "/" + *pathIterator);
      }
    }
    delete binIterator->second;
    binIterator->second = NULL;
  }
  delete binNamesByPath;
}
开发者ID:Axosoft,项目名称:nsfw,代码行数:41,代码来源:FSEventsService.cpp

示例7: main

int main(int argc, char **argv) {
#if defined(__CYGWIN__)
  // Cygwin clang 3.5.2 with '-O3' generates CRASHING BINARY,
  // if main()'s first function call is passing argv[0].
  std::rand();
#endif  
  llvm::cl::ParseCommandLineOptions(argc, argv);

  swift::Demangle::DemangleOptions options;
  options.SynthesizeSugarOnTypes = !DisableSugar;
  if (Simplified)
    options = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions();

  if (InputNames.empty()) {
    CompactMode = true;
    auto input = llvm::MemoryBuffer::getSTDIN();
    if (!input) {
      llvm::errs() << input.getError().message() << '\n';
      return EXIT_FAILURE;
    }
    llvm::StringRef inputContents = input.get()->getBuffer();

    // This doesn't handle Unicode symbols, but maybe that's okay.
    llvm::Regex maybeSymbol("_T[_a-zA-Z0-9$]+");
    llvm::SmallVector<llvm::StringRef, 1> matches;
    while (maybeSymbol.match(inputContents, &matches)) {
      llvm::outs() << substrBefore(inputContents, matches.front());
      demangle(llvm::outs(), matches.front(), options);
      inputContents = substrAfter(inputContents, matches.front());
    }
    llvm::outs() << inputContents;

  } else {
    for (llvm::StringRef name : InputNames) {
      demangle(llvm::outs(), name, options);
      llvm::outs() << '\n';
    }
  }

  return EXIT_SUCCESS;
}
开发者ID:007Indian,项目名称:swift,代码行数:41,代码来源:swift-demangle.cpp

示例8: print_sym

static int print_sym(void *user_data, const char *name, address_t value)
{
	(void)user_data;

	char demangled[MAX_SYMBOL_LENGTH];
	if (demangle(name, demangled, sizeof(demangled)) > 0)
		printc("0x%04x: %s (%s)\n", value, name, demangled);
	else
		printc("0x%04x: %s\n", value, name);

	return 0;
}
开发者ID:Batov,项目名称:libusb_chrome_api,代码行数:12,代码来源:sym.c

示例9: main

	void main() {
		#if 0
			// Utilisation incorrecte avec zéro argument
			std::cout << max() << std::endl;
			// => Ne compile pas : error: static_assert failed "max needs at least 1 argument"
		#endif

		#if 0
			// Utilisation incorrecte avec zéro argument (bypasse le point d'entrée et appel direct de l'implantation max_impl)
			std::cout << max_impl() << std::endl;
			// => Ne compile pas : error: no matching function for call to 'max_impl'
		#endif

		std::cout << max(2) << std::endl;
		// => Affiche "2"

		std::cout << max(2, 1) << std::endl;
		// => Affiche "2"

		std::cout << max(2, 1, 6) << std::endl;
		// => Affiche "6"

		// Fonctionne avec tout type qui implante l'opérateur >
		std::string s1{"def"}, s2{"abc"};
		std::cout << max(s1, s2) << std::endl;
		// => Affiche "def"

		// Attention tout de même! l'opérateur > ici compare les adresses
		std::cout << max(s1.c_str(), s2.c_str()) << std::endl;
		// => Affiche "abc" sur ma machine

		// Attention tout de même! l'opérateur > ici compare les adresses
		char a1[]{"abc"}, a2[]{"def"}, a3[]{"abc"};
		std::cout << max(a1, a2) << std::endl;
		// => Affiche "abc" sur ma machine
		std::cout << max(a2, a3) << std::endl;
		// => Affiche "def" sur ma machine

		// Fonctionne très bien avec des types hétérogènes
		std::cout << max(2, 1.0, 6.0f, 4ull) << std::endl;
		// => Affiche "6"

		// Voyons quel est le type du résultat ...
		auto result = max(2, 1.0, 6.0f, 4ull);
		std::cout << demangle(typeid(result).name()) << std::endl;
		// => Affiche "double"

		#if 0
			// Vérification statique (à la compilation) que les types sont compatibles
			std::cout << max(s1, 123) << std::endl;
			// => Ne compile pas : error: invalid operands to binary expression ('std::basic_string<char>' and 'int')
		#endif
	}
开发者ID:NantesCppMeetup,项目名称:NCM,代码行数:53,代码来源:max_variadic_template.hpp

示例10: exception_to_r_condition

SEXP exception_to_r_condition( const std::exception& ex){
    std::string ex_class = demangle( typeid(ex).name() ) ;
    std::string ex_msg   = ex.what() ; 
    
    SEXP cppstack = PROTECT( rcpp_get_stack_trace() ) ;
    SEXP call = PROTECT( get_last_call() ) ;
    SEXP classes = PROTECT( get_exception_classes(ex_class) ) ;
    SEXP condition = PROTECT( make_condition( ex_msg, call, cppstack, classes ) ) ; 
    rcpp_set_stack_trace( R_NilValue ) ;
    UNPROTECT(4) ;
    return condition ;
}
开发者ID:jjallaire,项目名称:Rcpp,代码行数:12,代码来源:exceptions.cpp

示例11: __type_of

    std::string __type_of(typename std::remove_reference<Tp>::type &)
    {
        auto name = demangle(typeid(Tp).name());
        if (std::is_const<
             typename std::remove_reference<Tp>::type>::value)
            name.append(" const");

        if (std::is_volatile<
             typename std::remove_reference<Tp>::type>::value)
            name.append(" volatile");

        return name.append("&");
    }
开发者ID:awgn,项目名称:codes,代码行数:13,代码来源:cxxabi.hpp

示例12: printf

    template <class T> inline Matrix<T>&
	Get              (const std::string& name) {

		reflist::iterator it = m_ref.find(name);

        if (it == m_ref.end())
            printf ("**WARNING**: Matrix %s could not be found in workspace!\n", name.c_str());

        const boost::any& ba = m_store[it->second[0]];

        try {
			boost::any_cast<boost::shared_ptr<Matrix<T> > >(m_store[it->second[0]]);
		} catch (const boost::bad_any_cast& e) {
			printf ("**WARNING**: Failed to retrieve %s - %s.\n             Requested %s - have %s.\n",
					name.c_str(), e.what(),
                    demangle(typeid(boost::shared_ptr<Matrix<T> >).name()).c_str(),
                    demangle(ba.type().name()).c_str());
		}

		return *boost::any_cast<boost::shared_ptr<Matrix<T> > >(m_store[it->second[0]]);

	}
开发者ID:nomissretep,项目名称:codeare,代码行数:22,代码来源:Workspace.hpp

示例13: getRegistryMap

stk::diag::Writer &
Registry::verbose_print(
  stk::diag::Writer &		dout) const
{
  if (dout.shouldPrint()) {
    dout << "Registry, size " << getRegistryMap().size() << stk::diag::push << stk::diag::dendl;

    for (RegistryMap::const_iterator it = getRegistryMap().begin(); it != getRegistryMap().end(); ++it)
      dout << (*it).first.second << " of type " << demangle((*it).first.first->name()) << " at " << (*it).second << stk::diag::dendl;
    dout << stk::diag::pop;
  }
  return dout;
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:13,代码来源:UserPlugin.cpp

示例14: print_backtrace

void print_backtrace(char const* label)
{
	void* stack[50];
	int size = backtrace(stack, 50);
	char** symbols = backtrace_symbols(stack, size);

	fprintf(stderr, "%s\n", label);
	for (int i = 1; i < size; ++i)
	{
		fprintf(stderr, "%d: %s\n", i, demangle(symbols[i]).c_str());
	}

	free(symbols);
}
开发者ID:BlackYoup,项目名称:medusa,代码行数:14,代码来源:assert.cpp

示例15: metatype

	Metatype &
	metatype( const std::string& pname ) {
		std::string name = pname;
#ifdef __BORLANDC__
		if ( name[name.length()-1]=='&' ) {
			name = name.substr( 0, name.length()-2 );
		}
#endif
		TypeMap::iterator it = _meta_types.find( name );
		if ( it == _meta_types.end() ) {
			throw Error( "Metatype '" + demangle( name ) + "' not declared" );
		}
		return *it->second;
	}
开发者ID:fast01,项目名称:jrtti,代码行数:14,代码来源:reflector.hpp


注:本文中的demangle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。