From 00451bb168ef4fb599fffec067545879ed2b1cc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 6 Dec 2018 15:29:01 +0900 Subject: [PATCH] [enco] Support block dump (#2528) This commit implement "enco_dump_block" debugging helper which shows all the instructions in a given block. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Support/Debugging.cpp | 24 ++++++++++++++++++++++++ contrib/enco/core/src/Support/Debugging.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/contrib/enco/core/src/Support/Debugging.cpp b/contrib/enco/core/src/Support/Debugging.cpp index 987fa1d..519fd1b 100644 --- a/contrib/enco/core/src/Support/Debugging.cpp +++ b/contrib/enco/core/src/Support/Debugging.cpp @@ -387,3 +387,27 @@ DEBUGGING_API_P(enco_dump_all_instrs, coco::Module, m) std::cout << desc << std::endl; } } + +/** + * SECTION: Block + */ +namespace +{ + +pp::LinearDocument describe(const coco::Block *blk) +{ + pp::LinearDocument doc; + + for (auto ins = blk->instr()->head(); ins; ins = ins->next()) + { + auto setter = [ins](pp::LinearDocument &doc) { doc.append(describe(ins)); }; + auto desc = section("instr").build(setter); + doc.append(desc); + } + + return doc; +} + +} // namespace + +DEBUGGING_API_P(enco_dump_block, coco::Block, blk) { std::cout << describe(blk) << std::endl; } diff --git a/contrib/enco/core/src/Support/Debugging.h b/contrib/enco/core/src/Support/Debugging.h index bf1d625..a3a36cc 100644 --- a/contrib/enco/core/src/Support/Debugging.h +++ b/contrib/enco/core/src/Support/Debugging.h @@ -81,6 +81,14 @@ DEBUGGING_API_P(enco_dump_all_ops, coco::Module); */ DEBUGGING_API_P(enco_dump_all_instrs, coco::Module); +/** + * Print the details of all the instruction in a given block + * + * (gdb) call enco_dump_block(b) + * (gdb) call enco_dump_block(0x...) + */ +DEBUGGING_API_P(enco_dump_block, coco::Block); + #undef DEBUGGING_API_P #endif // __ENCO_SUPPORT_DEBUGGING_H__ -- 2.7.4