Skip to content

Instantly share code, notes, and snippets.

@iains
Created October 20, 2024 18:43
Show Gist options
  • Select an option

  • Save iains/f2a97ad58533eafb7942b8513bfecf65 to your computer and use it in GitHub Desktop.

Select an option

Save iains/f2a97ad58533eafb7942b8513bfecf65 to your computer and use it in GitHub Desktop.
some debug functions that can help in GDB.
DEBUG_FUNCTION void
coro_pretty_p_statements (tree stmts, const char *msg = NULL)
{
if (msg)
fprintf (stderr, "%s", msg);
cxx_pretty_printer pp;
pp.set_output_stream (stderr);
if (stmts)
{
pp_newline_and_indent (&pp, 0);
pp.statement (stmts);
}
else
pp_string (&pp, "<null>");
pp_newline_and_flush (&pp);
}
DEBUG_FUNCTION void
coro_pretty_p_expression (tree expr, const char *msg = NULL)
{
if (msg)
fprintf (stderr, "%s", msg);
cxx_pretty_printer pp;
pp.set_output_stream (stderr);
if (expr)
{
pp_newline_and_indent (&pp, 0);
pp.expression (expr);
}
else
pp_string (&pp, "<null>");
pp_newline_and_flush (&pp);
}
DEBUG_FUNCTION void
coro_pretty_p_decl (tree decl, const char *msg = NULL)
{
if (msg)
fprintf (stderr, "%s", msg);
cxx_pretty_printer pp;
pp.set_output_stream (stderr);
if (decl)
{
pp_newline_and_indent (&pp, 0);
pp.declarator (decl);
}
else
pp_string (&pp, "<null>");
pp_newline_and_flush (&pp);
}
DEBUG_FUNCTION void
coro_pretty_p_type (tree type, const char *msg = NULL)
{
if (msg)
fprintf (stderr, "%s", msg);
cxx_pretty_printer pp;
pp.set_output_stream (stderr);
if (type)
{
pp_newline_and_indent (&pp, 0);
pp.type_id (type);
}
else
pp_string (&pp, "<null>");
pp_newline_and_flush (&pp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment