Go patch committed: Add debugger-callable ASP dump functions
Ian Lance Taylor
iant@golang.org
Tue Feb 19 18:44:00 GMT 2019
This patch to the Go frontend by Than McIntosh adds some
debugger-callable AST dump functions, similar to function like
debug_tree or debug_rtx. They are all named debug_go_xxx.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed
to mainline.
Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 269019)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-fe0382eabbf1e8b148dc8cb7733348bd9d887e10
+08cd59a502127da776e076a8a37016a668ef27fa
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/ast-dump.cc
===================================================================
--- gcc/go/gofrontend/ast-dump.cc (revision 268949)
+++ gcc/go/gofrontend/ast-dump.cc (working copy)
@@ -482,7 +482,7 @@ Ast_dump_context::write_string(const std
this->ostream() << s;
}
-// Dump statment to stream.
+// Dump statement to stream.
void
Ast_dump_context::dump_to_stream(const Statement* stm, std::ostream* out)
@@ -499,3 +499,84 @@ Ast_dump_context::dump_to_stream(const E
Ast_dump_context adc(out, false);
expr->dump_expression(&adc);
}
+
+// Dump an expression to std::cerr. This is intended to be used
+// from within a debugging session.
+
+void
+debug_go_expression(const Expression* expr)
+{
+ if (expr == NULL)
+ std::cerr << "<null>";
+ else
+ {
+ Ast_dump_context::dump_to_stream(expr, &std::cerr);
+ std::string lstr = Linemap::location_to_string(expr->location());
+ std::cerr << " // loc " << lstr << std::endl;
+ }
+}
+
+// Shallow dump of stmt to std::cerr. This is intended to be used
+// from within a debugging session.
+
+void
+debug_go_statement(const Statement* stmt)
+{
+ if (stmt == NULL)
+ std::cerr << "<null>\n";
+ else
+ {
+ std::string lstr = Linemap::location_to_string(stmt->location());
+ Statement *ncstmt = const_cast<Statement*>(stmt);
+ Block_statement* bs = ncstmt->block_statement();
+ if (bs != NULL)
+ std::cerr << "Block " << bs->block()
+ << " // location: " << lstr << std::endl;
+ else
+ Ast_dump_context::dump_to_stream(stmt, &std::cerr);
+ }
+}
+
+// Deep dump of statement to std::cerr. This is intended to be used
+// from within a debugging session.
+
+void
+debug_go_statement_deep(const Statement* statement)
+{
+ Ast_dump_context adc(&std::cerr, true);
+ statement->dump_statement(&adc);
+}
+
+// Shallow dump of a block to std::cerr. This is intended to be used
+// from within a debugging session.
+
+void
+debug_go_block(const Block* block)
+{
+ if (block == NULL)
+ std::cerr << "<null>";
+ else
+ {
+ std::cerr << "Block " << block
+ << " (enclosing " << block->enclosing() << "):\n";
+ const std::vector<Statement*>* stmts = block->statements();
+ if (stmts != NULL)
+ {
+ for (size_t i = 0; i < stmts->size(); ++i)
+ {
+ debug_go_statement(stmts->at(i));
+ }
+ }
+ }
+}
+
+// Deep dump of a block to std:cerr. This is intended to be used
+// from within a debugging session.
+
+void
+debug_go_block_deep(const Block* block)
+{
+ Ast_dump_context adc(&std::cerr, true);
+ Block* ncblock = const_cast<Block*>(block);
+ adc.dump_block(ncblock);
+}
More information about the Gcc-patches
mailing list