void NAME(long p) { NAME(reinterpret_cast<const TYPE *>(p)); } \
void NAME(const TYPE *VAR)
+namespace
+{
+
+class SectionBuilder
+{
+public:
+ SectionBuilder(const std::string &tag) : _tag{tag}
+ {
+ // DO NOTHING
+ }
+
+public:
+ template <typename Callback> pp::LinearDocument build(Callback cb) const
+ {
+ pp::LinearDocument res;
+
+ res.append(_tag, " {");
+ res.indent();
+
+ cb(res);
+
+ res.unindent();
+ res.append("}");
+
+ return res;
+ }
+
+private:
+ std::string _tag;
+};
+
+template <typename Callback>
+pp::LinearDocument operator<<(const SectionBuilder &builder, Callback cb)
+{
+ return builder.build(std::forward<Callback>(cb));
+}
+
+SectionBuilder section(const std::string &tag) { return SectionBuilder{tag}; }
+}
+
/**
* SECTION: Op
*/
std::cout << "(nullptr)" << std::endl;
}
}
+
+DEBUGGING_API_P(enco_dump_all_ops, coco::Module, m)
+{
+ if (m == nullptr)
+ {
+ std::cout << "(nullptr)" << std::endl;
+ return;
+ }
+
+ SectionBuilder section_builder{"op"};
+
+ for (uint32_t n = 0; n < m->entity()->op()->size(); ++n)
+ {
+ auto op = m->entity()->op()->at(n);
+ assert(op != nullptr);
+
+ auto desc = section("op").build([op](pp::LinearDocument &doc) { doc.append(describe(op)); });
+
+ std::cout << desc << std::endl;
+ }
+}
*/
DEBUGGING_API_P(enco_dump_op, coco::Op);
+/**
+ * Print the details of all the allocated coco::Op in coco::Module
+ *
+ * (gdb) call enco_dump_all_ops(module)
+ * (gdb) call enco_dump_all_ops(0x....)
+ */
+DEBUGGING_API_P(enco_dump_all_ops, coco::Module);
+
#undef DEBUGGING_API_P
#endif // __ENCO_SUPPORT_DEBUGGING_H__
#include <gtest/gtest.h>
// This test aims to check whether debugging API is actually defined
-TEST(DebuggingTest, defined) { enco_dump_op(nullptr); }
+TEST(DebuggingTest, defined)
+{
+ enco_dump_op(nullptr);
+ enco_dump_all_ops(nullptr);
+}