Simplify complex C ++ pattern characters

I am working on a debug / memory tool. I want to display characters coming from C ++, the problem is that they are very verbose. At the moment, I just use __cxa_demangle , but this often leads to huge lines of over 500 characters due to the inclusion of default template options.

clang++ can clearly do smart things when it communicates characters, is there a way I can use it?

As a simple example, take:

 std::map<std::string const, unsigned int, std::less<std::string const>, std::allocator<std::pair<std::string const, unsigned int> > >::find(std::string const&) 

Which clearly could be reported as:

 std::map<std::string const, unsigned int>::find(std::string const&) 

.. if I had a smart enough tool. It is clear that this is difficult to do without any additional knowledge (for example, inclusions that were originally used - I can potentially get from them), but I would be grateful for any pointers.

So far I have been pointing to libcxxabi , but besides the fact that there was no open interface for parsing the tree (which would not stop me on my own), it seems that I would have to do the hard work of determining what parameters were by default. It would be great if I could somehow fool it into doing it for me.

+4
source share
1 answer

STLFilt can help you. There are two perl scripts: STLFilt.pl (for Visual C ++) and gSTLFilt.p (for gcc). It is intended to be used to simplify error messages, but I have already used it to display __cxa_demangle processing results.

Used on your simple example without any parameters:

 echo "std::map<std::string const, unsigned int, std::less<std::string const>, std::allocator<std::pair<std::string const, unsigned int> > >::find(std::string const&)" \ | perl ./gSTLFilt.pl 

Gets the output:

 BD Software STL Message Decryptor v3.10 for gcc 2/3/4 map<string const, unsigned int>::find(string const &) 

If you want to play around with such options, you should be able to customize the reformatting (I have not tried).

+5
source

All Articles