[svn:parrot] r39193 - in trunk: include/parrot src/runcore
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed May 27 11:49:23 UTC 2009
Author: bacek
Date: Wed May 27 11:49:22 2009
New Revision: 39193
URL: https://trac.parrot.org/parrot/changeset/39193
Log:
Factor out debugger_or_interp helper function to fetch debugger or interp itself during tracing.
Modified:
trunk/include/parrot/runcore_trace.h
trunk/src/runcore/trace.c
Modified: trunk/include/parrot/runcore_trace.h
==============================================================================
--- trunk/include/parrot/runcore_trace.h Wed May 27 10:35:01 2009 (r39192)
+++ trunk/include/parrot/runcore_trace.h Wed May 27 11:49:22 2009 (r39193)
@@ -18,6 +18,10 @@
/* HEADERIZER BEGIN: src/runcore/trace.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
+PARROT_CANNOT_RETURN_NULL
+Interp * debugger_or_interp(PARROT_INTERP)
+ __attribute__nonnull__(1);
+
int trace_key_dump(PARROT_INTERP, ARGIN(PMC *key))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -40,6 +44,8 @@
void trace_pmc_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
__attribute__nonnull__(1);
+#define ASSERT_ARGS_debugger_or_interp __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_trace_key_dump __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(key)
Modified: trunk/src/runcore/trace.c
==============================================================================
--- trunk/src/runcore/trace.c Wed May 27 10:35:01 2009 (r39192)
+++ trunk/src/runcore/trace.c Wed May 27 11:49:22 2009 (r39193)
@@ -44,6 +44,21 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
+/*
+
+=item C<Interp * debugger_or_interp(PARROT_INTERP)>
+
+Get debugger if available
+
+=cut
+*/
+PARROT_CANNOT_RETURN_NULL
+Interp *
+debugger_or_interp(PARROT_INTERP) {
+ return interp->pdb && interp->pdb->debugger
+ ? interp->pdb->debugger
+ : interp;
+}
/*
@@ -87,7 +102,7 @@
trace_pmc_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
{
ASSERT_ARGS(trace_pmc_dump)
- Interp * const debugger = interp->pdb->debugger;
+ Interp * const debugger = debugger_or_interp(interp);
Parrot_sub *sub;
if (!pmc) {
@@ -175,7 +190,7 @@
trace_key_dump(PARROT_INTERP, ARGIN(PMC *key))
{
ASSERT_ARGS(trace_key_dump)
- Interp * const debugger = interp->pdb->debugger;
+ Interp * const debugger = debugger_or_interp(interp);
int len = Parrot_io_eprintf(debugger, "[");
@@ -261,7 +276,7 @@
ASSERT_ARGS(trace_op_dump)
INTVAL s, n;
int more = 0, var_args;
- Interp * const debugger = interp->pdb->debugger;
+ Interp * const debugger = debugger_or_interp(interp);
op_info_t * const info = &interp->op_info_table[*pc];
PMC *sig;
int type;
More information about the parrot-commits
mailing list