00001 /** @file rutz/demangle_cxxfilt.h demangle std::type_info::name() by 00002 piping through /usr/bin/c++filt */ 00003 00004 /////////////////////////////////////////////////////////////////////// 00005 // 00006 // Copyright (c) 2002-2004 California Institute of Technology 00007 // Copyright (c) 2004-2007 University of Southern California 00008 // Rob Peters <rjpeters at usc dot edu> 00009 // 00010 // created: Thu Feb 27 16:30:08 2003 00011 // commit: $Id: demangle_cxxfilt.h 8249 2007-04-12 06:03:40Z rjpeters $ 00012 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/rutz/demangle_cxxfilt.h $ 00013 // 00014 // -------------------------------------------------------------------- 00015 // 00016 // This file is part of GroovX. 00017 // [http://ilab.usc.edu/rjpeters/groovx/] 00018 // 00019 // GroovX is free software; you can redistribute it and/or modify it 00020 // under the terms of the GNU General Public License as published by 00021 // the Free Software Foundation; either version 2 of the License, or 00022 // (at your option) any later version. 00023 // 00024 // GroovX is distributed in the hope that it will be useful, but 00025 // WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00027 // General Public License for more details. 00028 // 00029 // You should have received a copy of the GNU General Public License 00030 // along with GroovX; if not, write to the Free Software Foundation, 00031 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00032 // 00033 /////////////////////////////////////////////////////////////////////// 00034 00035 #ifndef GROOVX_RUTZ_DEMANGLE_CXXFILT_H_UTC20050626084020_DEFINED 00036 #define GROOVX_RUTZ_DEMANGLE_CXXFILT_H_UTC20050626084020_DEFINED 00037 00038 #include "rutz/error.h" 00039 #include "rutz/fstring.h" 00040 #include "rutz/pipe.h" 00041 #include "rutz/sfmt.h" 00042 00043 #include <string> 00044 00045 #include "rutz/debug.h" 00046 GVX_DBG_REGISTER 00047 #include "rutz/trace.h" 00048 00049 namespace 00050 { 00051 std::string demangle_cxxfilt(const std::string& mangled) 00052 { 00053 GVX_TRACE("demangle_cxxfilt"); 00054 00055 rutz::shell_pipe pipe(rutz::sfmt("c++filt %s", 00056 mangled.c_str()).c_str(), 00057 "r"); 00058 00059 if (pipe.is_closed()) 00060 { 00061 throw rutz::error(rutz::sfmt("while demangling '%s': " 00062 "couldn't open pipe to c++filt", 00063 mangled.c_str()), 00064 SRC_POS); 00065 } 00066 00067 std::string demangled; 00068 std::getline(pipe.stream(), demangled); 00069 00070 return demangled; 00071 } 00072 } 00073 00074 static const char __attribute__((used)) vcid_groovx_rutz_demangle_cxxfilt_h_utc20050626084020[] = "$Id: demangle_cxxfilt.h 8249 2007-04-12 06:03:40Z rjpeters $ $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/rutz/demangle_cxxfilt.h $"; 00075 #endif // !GROOVX_RUTZ_DEMANGLE_CXXFILT_H_UTC20050626084020_DEFINED