On 06/06/19 22:33 +0200, François Dumont wrote:
Here is what I come up with.
Regarding allocation in print_function I would also prefer to avoid
it. But this patch also aim at creating a backtrace_state object in
case of UB so the alloc is perhaps not so important. I can't use
string_view as I need to modify it to display only a part of it
I was only referring to these strings, which allocated memory on every
call to print_function, but you don't modify:
+ const string cxx1998 = "__cxx1998::";
+ const string allocator = ", std::allocator<";
+ const string safe_iterator = "__gnu_debug::_Safe_iterator<";
I see you've changed them now though.
through fsprintf. I could try to use "%.*s" however. I haven't also
consider your remark about template parameters containing '<' yet.
+#if defined(_GLIBCXX_DEBUG_BACKTRACE)
+# if !defined(BACKTRACE_SUPPORTED)
+# if defined(__has_include) && !__has_include(<backtrace-supported.h>)
+# error No libbacktrace backtrace-supported.h file found.
+# endif
+# include <backtrace-supported.h>
+# endif
+# if !BACKTRACE_SUPPORTED
+# error libbacktrace not supported.
+# endif
+# include <backtrace.h>
+#else
+# include <stdint.h> // For uintptr_t.
Please use <cstdint> and std::uintptr_t.
I did so but then realized that to do so I had to be in C++11 mode. I
used tr1/cstdint in pre-C++11 mode.
Ugh, right, of course, sorry.
Then I guess <stdint.h> is better than relying on TR1 (even though
<stdint.h> isn't technically part of C++98 either).