Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HenrikBengtsson/34d9338848abc9e00731b3e2f584bdb5 to your computer and use it in GitHub Desktop.
Save HenrikBengtsson/34d9338848abc9e00731b3e2f584bdb5 to your computer and use it in GitHub Desktop.
--- R-3.2.1/src/main/memory.c.orig 2015-07-31 23:15:07.017151621 -0700
+++ R-3.2.1/src/main/memory.c 2015-07-31 23:17:10.185150073 -0700
@@ -3724,11 +3724,21 @@
static FILE *R_MemReportingOutfile;
static R_size_t R_MemReportingThreshold;
+static void printLineNum(FILE *file, SEXP srcref) {
+ if (srcref && !isNull(srcref)) {
+ int line = asInteger(srcref);
+ fprintf(file, "#%d ", line);
+ } else {
+ fprintf(file, " ");
+ }
+}
+
static void R_OutputStackTrace(FILE *file)
{
int newline = 0;
RCNTXT *cptr;
+ SEXP srcref = R_Srcref;
for (cptr = R_GlobalContext; cptr; cptr = cptr->nextcontext) {
if ((cptr->callflag & (CTXT_FUNCTION | CTXT_BUILTIN))
&& TYPEOF(cptr->call) == LANGSXP) {
@@ -3737,6 +3747,8 @@
fprintf(file, "\"%s\" ",
TYPEOF(fun) == SYMSXP ? CHAR(PRINTNAME(fun)) :
"<Anonymous>");
+ printLineNum(file, srcref);
+ srcref = cptr->srcref;
}
}
if (newline) fprintf(file, "\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment