Created
October 8, 2022 19:11
-
-
Save iains/140cf56f4524fe561d8d6bebfa9984b1 to your computer and use it in GitHub Desktop.
debugging stuff for GCC coroutines.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ================= Debug. ================= */ | |
#include "cxx-pretty-print.h" | |
extern void debug_tree (tree); | |
void | |
coro_dump_frame (tree fr) | |
{ | |
gcc_checking_assert (TREE_CODE (fr) == RECORD_TYPE); | |
if (DECL_NAME (TYPE_NAME (fr))) | |
fprintf (stderr, "%s {\n", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (fr)))); | |
else | |
fprintf (stderr, "huh {\n"); | |
tree tmp = TYPE_FIELDS (fr); | |
while (tmp) | |
{ | |
/* Avoid to print recursively the structure. */ | |
/* FIXME : Not implemented correctly..., | |
what about the case when we have a cycle in the contain graph? ... | |
Maybe this could be solved by looking at the scope in which the | |
structure was declared. */ | |
if (TREE_TYPE (tmp) != fr | |
&& (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE | |
|| TREE_TYPE (TREE_TYPE (tmp)) != fr)) | |
{ | |
const char *ty; | |
if (TYPE_NAME (TREE_TYPE (tmp))) | |
ty = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_TYPE (tmp)))); | |
else | |
ty = "<unnamed>"; | |
fprintf (stderr, "%s %s\n", ty, | |
IDENTIFIER_POINTER (DECL_NAME (tmp))); | |
} | |
tmp = DECL_CHAIN (tmp); | |
} | |
fprintf (stderr, "}\n"); | |
} | |
void | |
coro_pretty_p_statements (tree stmts, const char *msg = NULL) | |
{ | |
cxx_pretty_printer pp; | |
pp.buffer->stream = stderr; | |
if (msg && msg[0] != 0) | |
pp_string (&pp, msg); | |
if (stmts) | |
pp.statement (stmts); | |
else | |
pp_string (&pp, "<null>"); | |
pp_newline_and_flush (&pp); | |
} | |
void | |
coro_pretty_p_expression (tree expr, const char *msg = NULL) | |
{ | |
cxx_pretty_printer pp; | |
pp.buffer->stream = stderr; | |
if (msg && msg[0] != 0) | |
pp_string (&pp, msg); | |
if (expr) | |
pp.expression (expr); | |
else | |
pp_string (&pp, "<null>"); | |
pp_newline_and_flush (&pp); | |
} | |
void | |
coro_pretty_p_decl (tree decl, const char *msg = NULL) | |
{ | |
cxx_pretty_printer pp; | |
pp.buffer->stream = stderr; | |
if (msg && msg[0] != 0) | |
pp_string (&pp, msg); | |
if (decl) | |
pp.declarator (decl); | |
else | |
pp_string (&pp, "<null>"); | |
pp_newline_and_flush (&pp); | |
} | |
void | |
coro_pretty_p_type (tree type, const char *msg = NULL) | |
{ | |
cxx_pretty_printer pp; | |
pp.buffer->stream = stderr; | |
if (msg && msg[0] != 0) | |
pp_string (&pp, msg); | |
if (type) | |
pp.type_id (type); | |
else | |
pp_string (&pp, "<null>"); | |
pp_newline_and_flush (&pp); | |
} | |
/* ================= END Debug. ================= */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment