Skip to content

Commit

Permalink
Make libc++'s std::type_info::name() demangle.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eelis committed Oct 16, 2016
1 parent 5d22b38 commit 906f58b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
26 changes: 26 additions & 0 deletions prelude/libcxx_demangle_typeinfo_name.patch
@@ -0,0 +1,26 @@
@@ -69,6 +69,8 @@
#pragma GCC system_header
#endif

+namespace geordi { char const * demangle(char const *); }
+
namespace std // purposefully not using versioning namespace
{

@@ -98,11 +100,14 @@

_LIBCPP_INLINE_VISIBILITY
const char* name() const _NOEXCEPT
+ {
#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
- {return __type_name;}
+ char const * r = __type_name;
#else
- {return reinterpret_cast<const char*>(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);}
+ char const * r = reinterpret_cast<const char*>(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);
#endif
+ return geordi::demangle(r);
+ }

_LIBCPP_INLINE_VISIBILITY
bool before(const type_info& __arg) const _NOEXCEPT
File renamed without changes.
23 changes: 13 additions & 10 deletions prelude/prelude.hpp
@@ -1,15 +1,18 @@
#ifndef __clang__

#include "patched_typeinfo.hpp"
#include <debug/macros.h>

#ifdef _GLIBCXX_DEBUG_VERIFY
#undef _GLIBCXX_DEBUG_VERIFY
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
do if (! (_Condition)) ::__gnu_debug::_Error_formatter::_M_at("E7tKRJpMcGq574LY", 0)._ErrorMessage._M_error(); while (false)
#ifdef __clang__
#include "libcxx_patched_typeinfo.hpp"
#else
#include "libstdcxx_patched_typeinfo.hpp"
#endif
// "E7tKRJpMcGq574LY" is just a random string, recognized by the error filters, chosen to minimize the chance of false positives.

#ifndef __clang__
#include <debug/macros.h>

#ifdef _GLIBCXX_DEBUG_VERIFY
#undef _GLIBCXX_DEBUG_VERIFY
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
do if (! (_Condition)) ::__gnu_debug::_Error_formatter::_M_at("E7tKRJpMcGq574LY", 0)._ErrorMessage._M_error(); while (false)
// "E7tKRJpMcGq574LY" is just a random string, recognized by the error filters, chosen to minimize the chance of false positives.
#endif
#endif

#if __cplusplus >= 201103 // maybe backport parts of these even further someday
Expand Down
7 changes: 4 additions & 3 deletions prep-image
Expand Up @@ -18,9 +18,10 @@ gcc -fPIC -shared -Wall -o /lib/libdiagnose_sigsys.so /geordi/src/diagnose_sigsy
/geordi/src/lockdown/compile.sh

cd /geordi/src/prelude
patch /usr/local/include/c++/7.0.0/typeinfo demangle_typeinfo_name.patch -o patched_typeinfo.hpp
# TODO: don't hard-code version
chmod a+r patched_typeinfo.hpp
patch /usr/local/include/c++/7.0.0/typeinfo libstdcxx_demangle_typeinfo_name.patch -o libstdcxx_patched_typeinfo.hpp
patch /usr/local/include/c++/v1/typeinfo libcxx_demangle_typeinfo_name.patch -o libcxx_patched_typeinfo.hpp
# TODO: don't hard-code versions
chmod a+r *_patched_typeinfo.hpp
patch /usr/include/features.h dont_use_misc.patch

/geordi/src/prelude/compile.sh
Expand Down

0 comments on commit 906f58b

Please sign in to comment.