[svn:parrot] r37208 - trunk/src
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Sun Mar 8 17:50:47 UTC 2009
Author: NotFound
Date: Sun Mar 8 17:50:46 2009
New Revision: 37208
URL: https://trac.parrot.org/parrot/changeset/37208
Log:
[core] show annotations in traces and backtraces
Modified:
trunk/src/debug.c
trunk/src/exceptions.c
trunk/src/trace.c
Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c Sun Mar 8 16:30:24 2009 (r37207)
+++ trunk/src/debug.c Sun Mar 8 17:50:46 2009 (r37208)
@@ -3450,8 +3450,25 @@
if (!PMC_IS_NULL(sub)) {
str = Parrot_Context_infostr(interp, ctx);
- if (str)
- Parrot_io_eprintf(interp, "%Ss\n", str);
+ if (str) {
+ Parrot_io_eprintf(interp, "%Ss", str);
+ if (interp->code->annotations) {
+ PMC *annot = PackFile_Annotations_lookup(interp, interp->code->annotations,
+ ctx->current_pc - interp->code->base.data + 1, NULL);
+ if (!PMC_IS_NULL(annot)) {
+ PMC *pfile = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "file"));
+ PMC *pline = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "line"));
+ if ((!PMC_IS_NULL(pfile)) && (!PMC_IS_NULL(pline))) {
+ STRING *file = VTABLE_get_string(interp, pfile);
+ INTVAL line = VTABLE_get_integer(interp, pline);
+ Parrot_io_eprintf(interp, " (%Ss:%li)", file, (long)line);
+ }
+ }
+ }
+ Parrot_io_eprintf(interp, "\n");
+ }
}
/* backtrace: follow the continuation chain */
@@ -3486,8 +3503,25 @@
}
/* print the context description */
- if (rec_level == 0)
- Parrot_io_eprintf(interp, "%Ss\n", str);
+ if (rec_level == 0) {
+ Parrot_io_eprintf(interp, "%Ss", str);
+ if (interp->code->annotations) {
+ PMC *annot = PackFile_Annotations_lookup(interp, interp->code->annotations,
+ sub_cont->to_ctx->current_pc - interp->code->base.data + 1, NULL);
+ if (!PMC_IS_NULL(annot)) {
+ PMC *pfile = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "file"));
+ PMC *pline = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "line"));
+ if ((!PMC_IS_NULL(pfile)) && (!PMC_IS_NULL(pline))) {
+ STRING *file = VTABLE_get_string(interp, pfile);
+ INTVAL line = VTABLE_get_integer(interp, pline);
+ Parrot_io_eprintf(interp, " (%Ss:%li)", file, (long)line);
+ }
+ }
+ }
+ Parrot_io_eprintf(interp, "\n");
+ }
/* get the next Continuation */
ctx = PMC_cont(sub)->to_ctx;
Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c Sun Mar 8 16:30:24 2009 (r37207)
+++ trunk/src/exceptions.c Sun Mar 8 17:50:46 2009 (r37208)
@@ -111,7 +111,6 @@
STRING * const message = VTABLE_get_string(interp, exception);
INTVAL exit_status = 1;
const INTVAL severity = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"));
- PMC *annotations;
/* flush interpreter output to get things printed in order */
Parrot_io_flush(interp, Parrot_io_STDOUT(interp));
@@ -143,17 +142,6 @@
PDB_backtrace(interp);
}
- Parrot_PCCINVOKE(interp, exception, CONST_STRING(interp, "annotations"), "->P", &annotations);
-
- if (!PMC_IS_NULL(annotations)) {
- PMC *file = VTABLE_get_pmc_keyed_str(interp, annotations, CONST_STRING(interp, "file"));
- if (!PMC_IS_NULL(file)) {
- PMC *line = VTABLE_get_pmc_keyed_str(interp, annotations, CONST_STRING(interp, "line"));
- if (!PMC_IS_NULL(line))
- Parrot_io_eprintf(interp, "current source: (%Ps:%Ps)\n", file, line);
- }
- }
-
/*
* returning NULL from here returns resume address NULL to the
* runloop, which will terminate the thread function finally
Modified: trunk/src/trace.c
==============================================================================
--- trunk/src/trace.c Sun Mar 8 16:30:24 2009 (r37207)
+++ trunk/src/trace.c Sun Mar 8 17:50:46 2009 (r37208)
@@ -450,6 +450,27 @@
}
}
done:
+
+ if (interp->code->annotations) {
+ PMC *annot = PackFile_Annotations_lookup(interp, interp->code->annotations,
+ pc - code_start + 1, NULL);
+ if (!PMC_IS_NULL(annot)) {
+ PMC *pfile = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "file"));
+ PMC *pline = VTABLE_get_pmc_keyed_str(interp, annot,
+ Parrot_str_new_constant(interp, "line"));
+ if ((!PMC_IS_NULL(pfile)) && (!PMC_IS_NULL(pline))) {
+ /* The debugger interpreter may not be the same as
+ * the main interpreter, extract values from the
+ * PMC instad of passing them directly
+ */
+ STRING *file = VTABLE_get_string(interp, pfile);
+ INTVAL line = VTABLE_get_integer(interp, pline);
+ Parrot_io_eprintf(debugger, " (%Ss:%li)", file, (long)line);
+ }
+ }
+ }
+
Parrot_io_eprintf(debugger, "\n");
}
More information about the parrot-commits
mailing list