New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move type info into hpx::debug namespace and add print helper functions #3192
Conversation
hpx/util/demangle_helper.hpp
Outdated
@@ -36,6 +41,7 @@ namespace hpx { namespace util | |||
private: | |||
char* demangled_; | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same structure below needs to be moved into hpx::debug
as well
hpx/util/demangle_helper.hpp
Outdated
template <typename T=void> | ||
inline std::string print_type(const char *delim="") | ||
{ | ||
return std::string(debug::type_id<T>::typeid_.type_id());; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous ';'
Should these be moved to an |
Good point! |
would |
9279688
to
e7f4f5e
Compare
I'd vote for |
|
||
// disable the code specific to gcc for now as this causes problems | ||
// (see #811: simple_central_tuplespace_client run error) | ||
#if 0 // defined(__GNUC__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I right in thinking that the reason why the code was #ifdefed out here is because the demangle_helper uses abi::__cxa_demangle(typeid(T).name(), 0, 0, 0)
which returns a char *
and this char * is deleted when the helper goes out of scope - but the char *
is held onto by the (serialization) code that uses it.
If this is the case, is there anything we can do to make the serialization code keep the memory alive?
For debugging, the demangled version is very useful, in the debug::print(...)
code, the char *
is copied into a string, so no memory violations occur. Perhaps we should just use the undemangled version in the serialization, and keep the demangled one for debug stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for that, we'd just need to implement proper resource management. std::string
, std::shared_ptr<char>
or std::vector<char>
are available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played with this some more and something very odd is going on. The code segfaults in function registration of pointers when the debug mangler is used, but it's not caused by the pointer being invalid AFAICT. the test any_serialization_test_exe
fails if the GNU cxxabi demangler is used and I'm baffled as to what is going wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll leave the serialization code using the standard typeid stuff and enable the demangler for debugging and printing types, it is very useful to me and worth having, but I'll just provide two types and use one for debug and the other for serialization. Unless someone has a clue as to why the cxxabi demangler causes problems
41f78ed
to
3ba439a
Compare
Unfortunately, the cxxabi demangler utility causes an error in the serialization code. Until that is resolved (see also issue #811) use the normal typeid string for serialization and cxxabi for debug printing.
3ba439a
to
d4c022d
Compare
I have made 2 versions of the debug mangler I'd like this to go into 1.2 release if possible. |
hpx/util/debug/demangle_helper.hpp
Outdated
|
||
~cxxabi_demangle_helper() | ||
{ | ||
free(demangled_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to this, the class can't be copied. I think it would make sense to use proper memory management here. As I suggested previously, using either std::vector<char>
, std::unique_ptr<char, deleter>
or even std::string
might help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to clarify - the code in question was copied directly from the old implementation and used only in one place to initialize a static var that is used for the symbol translation (so copying is not planned or supported for this class). I will however use a unique_ptr if that makes you happy.
d7710d6
to
8239943
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to go as soon as pycicle finishes with gcc 4.9.
Proposed Changes
Adds an extra couple of type info print helpers and moves the demangler into the debug namespace.
Might not compile on all platforms because we had some problems with it in the past, so wanting to see what pycicle gives after a build/test of this PR.