Skip to content

Commit

Permalink
the bootstrapped setup.winxed fails after recent winxed updates. Add …
Browse files Browse the repository at this point in the history
…some functions for getting a friendlier backtrace using annotations
  • Loading branch information
Whiteknight committed Jun 9, 2011
1 parent fc2c635 commit f04d754
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
14 changes: 7 additions & 7 deletions setup.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ function setup_lib_constants(var rosella, string name, string prefix, var args)
// version. If we do have one built, use that instead
function setup_distutils()
{
int e = 0;
string distutils = "src/winxed/Distutils.pir";
${ stat e, distutils, 0 };
if (e)
load_bytecode(distutils);
else {
//int e = 0;
//string distutils = "src/winxed/Distutils.pir";
//${ stat e, distutils, 0 };
//if (e)
// load_bytecode(distutils);
//else {
say("Bootstrapping build with existing distutils library");
load_bytecode("src/winxed/Distutils.bootstrap.pir");
}
//}

using Rosella.Winxed.Distutils.winxed_setup;
winxed_setup();
Expand Down
36 changes: 36 additions & 0 deletions src/core/Parrot.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,41 @@ namespace Rosella
while(1)
return config;
}

// Get an array of strings representing a backtrace from the caller
function get_backtrace_strings()
{
var cur_ctx = getinterp()["context"];
var last_ctx = cur_ctx.caller_ctx;
return __format_backtrace(last_ctx.backtrace());
}

// Get an array of strings representing a backtrace from the exception
function get_backtrace_ex_strings(var ex)
{
var bt = ex.backtrace();
return __format_backtrace(bt);

}

// private routine. Format backtrace information into an array of
// human-readable strings
function __format_backtrace(var bt)
{
var bts = [];
for (int i = 0; i < elements(bt); i++) {
var sub = bt[i]["sub"];
string subname = "(entry)";
if (sub != null)
subname = string(sub);
var annotations = bt[i]["annotations"];
string filename = annotations["file"];
int lineno = annotations["line"];
bts[i] = sprintf("Called from '%s' (%s : %d)", [subname, filename, lineno]);
if (sub == null)
break;
}
return bts;
}
}
}

0 comments on commit f04d754

Please sign in to comment.