View | Details | Raw Unified | Return to bug 507
Collapse All | Expand All

(-)a/src/core/callback.cc (+54 lines)
 Lines 35-38   CallbackValue::DeserializeFromString (st Link Here 
35
35
36
ATTRIBUTE_CHECKER_IMPLEMENT (Callback);
36
ATTRIBUTE_CHECKER_IMPLEMENT (Callback);
37
37
38
// Demangling calls based on __cxa_demangle - Author: Timo Bingmann, 2009
39
40
#if (__GNUC__ >= 3)
41
42
#include <cxxabi.h>
43
#include "log.h"
44
45
std::string
46
CallbackBase::Demangle(const std::string& mangled)
47
{
48
    int status;
49
    char* demangled = abi::__cxa_demangle(mangled.c_str(),
50
                                          NULL, NULL, &status);
51
52
    std::string ret;
53
    if (status == 0) {
54
        NS_ASSERT(demangled);
55
        ret = demangled;
56
    }
57
    else if (status == -1) {
58
        NS_LOG_UNCOND("Callback demangling failed: Memory allocation failure occured.");
59
        ret = mangled;
60
    }
61
    else if (status == -2) {
62
        NS_LOG_UNCOND("Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules.");
63
        ret = mangled;
64
    }
65
    else if (status == -3) {
66
        NS_LOG_UNCOND("Callback demangling failed: One of the arguments is invalid.");
67
        ret = mangled;
68
    }
69
    else {
70
        NS_LOG_UNCOND("Callback demangling failed: status " << status);
71
        ret = mangled;
72
    }
73
74
    if (demangled) {
75
        free(demangled);
76
    }
77
    return ret;
78
}
79
80
#else
81
82
std::string
83
CallbackBase::Demangle(const std::string& mangled)
84
{
85
    return mangled;
86
}
87
88
#endif
89
90
// End of demangling
91
38
} // namespace ns3
92
} // namespace ns3
(-)a/src/core/callback.h (-3 / +5 lines)
 Lines 340-345   public: Link Here 
340
protected:
340
protected:
341
  CallbackBase (Ptr<CallbackImplBase> impl) : m_impl (impl) {}
341
  CallbackBase (Ptr<CallbackImplBase> impl) : m_impl (impl) {}
342
  Ptr<CallbackImplBase> m_impl;
342
  Ptr<CallbackImplBase> m_impl;
343
344
  static std::string Demangle(const std::string& mangled);
343
};
345
};
344
346
345
/**
347
/**
 Lines 476-484   private: Link Here 
476
  void DoAssign (Ptr<const CallbackImplBase> other) {
478
  void DoAssign (Ptr<const CallbackImplBase> other) {
477
    if (!DoCheckType (other))
479
    if (!DoCheckType (other))
478
      {
480
      {
479
        NS_FATAL_ERROR ("Incompatible types. (feed to \"c++filt -t\")"
481
        NS_FATAL_ERROR ("Incompatible types. (feed to \"c++filt -t\" if needed)" << std::endl <<
480
                        " got=" << typeid (*other).name () << 
482
                        "got=" << Demangle ( typeid (*other).name () ) << std::endl <<
481
                        ", expected=" << typeid (CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9> *).name ());
483
                        "expected=" << Demangle ( typeid (CallbackImpl<R,T1,T2,T3,T4,T5,T6,T7,T8,T9> *).name () ));
482
      }
484
      }
483
    m_impl = const_cast<CallbackImplBase *> (PeekPointer (other));
485
    m_impl = const_cast<CallbackImplBase *> (PeekPointer (other));
484
  }
486
  }

Return to bug 507