From fb45679b4fce33ea4dc4f207ccf9d62c6b9ed33b 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, 15 Nov 2018 10:50:32 +0900 Subject: [PATCH] [enco] Introduce enco_dump_all_bags (#2293) This commit introduces enco_dump_all_bags which shows the details of all the allocated bags in a given module. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Support/Debugging.cpp | 34 +++++++++++++++++++++++++++++ contrib/enco/core/src/Support/Debugging.h | 8 +++++++ 2 files changed, 42 insertions(+) diff --git a/contrib/enco/core/src/Support/Debugging.cpp b/contrib/enco/core/src/Support/Debugging.cpp index d457247..332c840 100644 --- a/contrib/enco/core/src/Support/Debugging.cpp +++ b/contrib/enco/core/src/Support/Debugging.cpp @@ -64,6 +64,40 @@ SectionBuilder section(const std::string &tag) { return SectionBuilder{tag}; } } /** + * SECTION: Bag + */ +namespace +{ + +pp::LinearDocument describe(const coco::Bag *bag) +{ + pp::LinearDocument doc; + + doc.append("addr: ", bag); + doc.append("size: ", bag->size()); + // TODO Print Read + // TODO Print Update + // TODO Print Dep + return doc; +} + +} // namespace + +DEBUGGING_API_P(enco_dump_all_bags, coco::Module, m) +{ + for (uint32_t n = 0; n < m->entity()->bag()->size(); ++n) + { + auto bag = m->entity()->bag()->at(n); + assert(bag != nullptr); + + auto set = [bag](pp::LinearDocument &doc) { doc.append(describe(bag)); }; + auto desc = section("bag").build(set); + + std::cout << desc << std::endl; + } +} + +/** * SECTION: Op */ namespace diff --git a/contrib/enco/core/src/Support/Debugging.h b/contrib/enco/core/src/Support/Debugging.h index ea51429..d1c23d5 100644 --- a/contrib/enco/core/src/Support/Debugging.h +++ b/contrib/enco/core/src/Support/Debugging.h @@ -34,6 +34,14 @@ static_assert(sizeof(long) == sizeof(void *), "sizeof(long) == sizeof(pointer)") void NAME(long); /** + * Print the details of all the allocated coco::Bag in coco::Module + * + * (gdb) call enco_dump_all_bags(bag) + * (gdb) call enco_dump_all_bags(0x...) + */ +DEBUGGING_API_P(enco_dump_all_bags, coco::Module); + +/** * Print the details of coco::Op * * (gdb) call enco_dump_op(op) -- 2.7.4