Bug 507 - Automatic demangling of Callback function signatures when they mismatch
Automatic demangling of Callback function signatures when they mismatch
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
All All
: P3 enhancement
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-21 07:12 UTC by TimoB
Modified: 2009-02-23 10:33 UTC (History)
3 users (show)

See Also:


Attachments
Demangling (2.89 KB, patch)
2009-02-21 07:12 UTC, TimoB
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description TimoB 2009-02-21 07:12:05 UTC
Created attachment 383 [details]
Demangling

This bugged me one time too many:

Incompatible types. (feed to "c++filt -t")
got=N3ns319FunctorCallbackImplIPFvSsNS_3PtrIKNS_6PacketEEEdNS_8WifiModeEEvSsS4_dS5_NS_5emptyES8_S8_S8_S8_EE
expected=PN3ns312CallbackImplIvSsNS_3PtrIKNS_6PacketEEEdNS_8WifiModeENS_12WifiPreambleENS_5emptyES7_S7_S7_EE

Because I connected an incompatible callback function to a TraceSource.

My patch uses abi::__cxa_demangle to convert the names above to

Incompatible types. (feed to "c++filt -t" if needed)
got=ns3::FunctorCallbackImpl<void (*)(std::string, ns3::Ptr<ns3::Packet const>, double, ns3::WifiMode), void, std::string, ns3::Ptr<ns3::Packet const>, double, ns3::WifiMode, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>
expected=ns3::CallbackImpl<void, std::string, ns3::Ptr<ns3::Packet const>, double, ns3::WifiMode, ns3::WifiPreamble, ns3::empty, ns3::empty, ns3::empty, ns3::empty>*

Not really much better, but at least I can read something now.

Maybe someone knows how to cast the "got" function to CallbackImpl before printing. That would improve legibility.
Comment 1 Mathieu Lacage 2009-02-21 14:08:18 UTC
Looks good to me. Do you have commit powers to ns-3-dev ?
Comment 2 TimoB 2009-02-21 14:14:20 UTC
Nope. Talked to Tom today to get a user account first.

You have any idea how to cast before printing?
Comment 3 Mathieu Lacage 2009-02-21 14:23:51 UTC
(In reply to comment #2)
 
> You have any idea how to cast before printing?

Nope, I don't see how you could cast to the right type: you would need to know the type of the object you got before casting it and you can't obviously do this since you don't know what you got.
Comment 4 Tom Henderson 2009-02-21 22:37:36 UTC
one small nit before you commit, to strip this comment
+// Demangling calls based on __cxa_demangle - Author: Timo Bingmann, 2009
to avoid authorship comments in the source code

Otherwise, I think it is a great addition.
Comment 5 TimoB 2009-02-22 02:42:25 UTC
Okay, I was more about who's to blame for problems.
But we know this thru hg anyway, right?
Comment 6 Tom Henderson 2009-02-22 10:11:37 UTC
(In reply to comment #5)
> Okay, I was more about who's to blame for problems.
> But we know this thru hg anyway, right?
> 

Yes, that is the idea.
Comment 7 Rajib Bhattacharjea 2009-02-23 10:33:33 UTC
4205:751691462d36