Skip to content
This repository
Browse code

NIECZA_VERBOSE_EXCEPTIONS to print .args.perl in backtraces

  • Loading branch information...
commit 048c930020f29b2b5196c0e76bda0e485e80798d 1 parent de5e663
Stefan O'Rear authored

Showing 2 changed files with 31 additions and 4 deletions. Show diff stats Hide diff stats

  1. +27 2 lib/Kernel.cs
  2. +4 2 perf/perf.TODO
29 lib/Kernel.cs
@@ -1045,6 +1045,8 @@ public class Frame: P6any {
1045 1045
1046 1046 public static readonly bool TraceCalls =
1047 1047 Environment.GetEnvironmentVariable("NIECZA_TRACE_CALLS") != null;
  1048 + public static readonly bool VerboseExceptions =
  1049 + Environment.GetEnvironmentVariable("NIECZA_VERBOSE_EXCEPTIONS") != null;
1048 1050
1049 1051 public Frame MakeChild(Frame outer, SubInfo info) {
1050 1052 if (reusable_child == null) {
@@ -1113,6 +1115,27 @@ public class Frame: P6any {
1113 1115 }
1114 1116 }
1115 1117
  1118 + public Variable GetArgs() {
  1119 + P6any nw = new P6opaque(Kernel.CaptureMO);
  1120 + nw.SetSlot("positionals", pos ?? new Variable[0]);
  1121 + nw.SetSlot("named", named);
  1122 + return Kernel.NewROScalar(nw);
  1123 + }
  1124 +
  1125 + public string DescribeArgs() {
  1126 + string ret = null;
  1127 + try {
  1128 + Variable a = GetArgs();
  1129 + Variable sa = Kernel.RunInferior(a.Fetch().InvokeMethod(
  1130 + Kernel.GetInferiorRoot(), "perl", new Variable[] { a },
  1131 + null));
  1132 + ret = sa.Fetch().mo.mro_raw_Str.Get(sa);
  1133 + } catch (Exception ex) {
  1134 + ret = "[cannot display arguments: " + ex + "]";
  1135 + }
  1136 + return ret;
  1137 + }
  1138 +
1116 1139 public string ExecutingFile() {
1117 1140 BValue l;
1118 1141 SubInfo i = info;
@@ -3258,10 +3281,12 @@ class LastFrameNode {
3258 3281 while (from != upto) {
3259 3282 sb.Append(Console.Out.NewLine);
3260 3283 try {
3261   - sb.AppendFormat(" at {0} line {1} ({2} @ {3})",
  3284 + sb.AppendFormat(" at {0} line {1} ({2} @ {3}) {4}",
3262 3285 new object[] {
3263 3286 from.ExecutingFile(), from.ExecutingLine(),
3264   - from.info.name, from.ip });
  3287 + from.info.name, from.ip,
  3288 + Frame.VerboseExceptions ? from.DescribeArgs() : ""
  3289 + });
3265 3290 } catch (Exception ex) {
3266 3291 sb.AppendFormat(" (frame display failed: {0})", ex);
3267 3292 }
6 perf/perf.TODO
@@ -8,13 +8,15 @@ Experiment with "if non-overriden, then replace method" hooks
8 8 Experiment with making P6any: Variable
9 9
10 10 Make LISTSTORE off-loop?
11   -
12 11 push, shift, etc off-loop?
13 12
14 13 Avoid calling a function for trivial attribute (or parameter) defaults
15 14
16 15 Improve isa, somehow.
17 16
18   -Subquadratic nibbling.
  17 +Subquadratic nibbling. Also improve nibbler's use of GetKey and push.
  18 +
  19 +Reduce redundant Cursor creation for, e.g., { say 2 }
  20 +Reduce ContextHelper use in ws, or make it faster.
19 21
20 22 81537 Mu.new attr: 14093 RxOp.zyg,

0 comments on commit 048c930

Please sign in to comment.
Something went wrong with that request. Please try again.