对不起,如果这是愚蠢的,但我对此感到困惑。
我做了谷歌我的问题,但未能找到任何相关的结果。
对于已编译并写入a.out的以下代码:
char x;
cout<<typeid(x).name()<<endl; /a.out给了我c,这正是我所期望的char。我发现了这个所以问题,并得出结论,我们需要使用c++filt -t来分解结果,所以我这样做了:
./a.out | c++filt -t 还有呼呼!我得到了(这不是字典词)的名字char。
很公平!
但困扰我的问题是c++filt是怎么发现的?
我加倍检查一根管子能做什么这里。如果我理解正确的话,它只是将输出传递给c++filt -t,在本例中是c++filt -t。
c++filt在哪里查找这些信息?
解模过程如何与c++filt协同工作
发布于 2015-11-27 15:25:36
正如那人所写的:
c++filt copies each file name in sequence, and writes it on
the standard output after decoding symbols that look like
C++ mangled names.
c++filt handles Solaris Studio C++ legacy versions as well
as the current version.
c++filt reads from the standard input if no input file is
specified.下面是关于恶魔的一点介绍:
#include <exception>
#include <iostream>
#include <cxxabi.h>
struct empty { };
template <typename T, int N>
struct bar { };
int main()
{
int status;
char *realname;
// exception classes not in <stdexcept>, thrown by the implementation
// instead of the user
std::bad_exception e;
realname = abi::__cxa_demangle(e.what(), 0, 0, &status);
std::cout << e.what() << "\t=> " << realname << "\t: " << status << '\n';
free(realname);
// typeid
bar<empty,17> u;
const std::type_info &ti = typeid(u);
realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n';
free(realname);
return 0;
}这个指纹
St13bad_exception => std::bad_exception : 0
3barI5emptyLi17EE => bar<empty, 17> : 0发布于 2015-11-27 15:27:05
c++filt在哪里查找这些信息? 如何与c++filt工作过程中的需求?
损坏的工作方式取决于您的平台是什么。因此,恶魔的运作方式也取决于它。
c++filt的程序员查看了描述您的平台上的符号是如何损坏的规范。或者,他们可能只是调用一个由实现提供的函数,该函数分解符号。
在后一种情况下,实现编译器的人以及因此而来的demangling函数知道符号是如何损坏的,因为它们首先实现了损坏。
c++filt是开源软件,您可以阅读它们的源代码来了解它的功能。
如果您对如何自己分解符号感兴趣,我建议您查看编译器的手册。
https://stackoverflow.com/questions/33960263
复制相似问题