Ticket #45827: pure-0.64-debugger-hotfix.diff

File pure-0.64-debugger-hotfix.diff, 2.2 KB (added by agraef (Albert Graef), 10 years ago)

Updated debugger hotfix with latest fixes from upstream. This resolves another bug in the expression printer which tripped another assertion in the debugger.

  • interpreter.cc

    diff -r 0163df6e1ff4 pure/interpreter.cc
     
    1715617156      debug(msg.str().c_str()); }
    1715717157#endif
    1715817158    if (retv) {
     17159      if (rp) debug_redn(rp, retv);
    1715917160      if (f.n+f.m != 0 || !debugging) {
    1716017161        // do cleanup
    1716117162        Function *free_fun = module->getFunction("pure_pop_args");
    1716217163        f.builder.CreateCall3(free_fun, retv, UInt(f.n), UInt(f.m));
    1716317164      }
    17164       if (rp) debug_redn(rp, retv);
    1716517165      f.builder.CreateRet(retv);
    1716617166    } else if (tail) {
    1716717167      // Tail-recursive type rule. Perform a direct tail call on the rightmost
  • printer.cc

    diff -r 0163df6e1ff4 pure/printer.cc
     
    917917static inline bool pstr(ostream& os, pure_expr *x)
    918918{
    919919  static bool recursive = false;
     920  if (!x) return false;
    920921  if (recursive ||
    921922      // We don't want to force a thunk here. Unfortunately, this means that
    922923      // currently you can't define a print representation for a thunk, at
     
    928929  map<int32_t,GlobalVar>::iterator it;
    929930  if (f > 0 && (it = interp.globalvars.find(f)) != interp.globalvars.end() &&
    930931      it->second.x && it->second.x->tag >= 0 && it->second.x->data.clos) {
    931     assert(x->refc > 0);
    932932    pure_aframe *ex = interp.push_aframe(interp.sstk_sz);
    933933    if (setjmp(ex->jmp)) {
    934934      // caught an exception
     
    943943      recursive = false;
    944944      return false;
    945945    } else {
     946      bool ret = false;
    946947      recursive = true;
     948      // The argument expression may well be a temporary if we're being
     949      // invoked internally, so make sure that it doesn't get collected
     950      // prematurely.
     951      pure_ref(x);
    947952      pure_expr *y = pure_app(it->second.x, x);
    948953      interp.pop_aframe();
    949954      recursive = false;
    950       assert(y);
    951       if (y->tag == EXPR::STR) {
    952         char *s = fromutf8(y->data.s);
     955      if (y) {
     956        if (y->tag == EXPR::STR) {
     957          char *s = fromutf8(y->data.s);
     958          if (s) {
     959            os << s; free(s);
     960            ret = true;
     961          }
     962        }
    953963        pure_freenew(y);
    954         if (s) {
    955           os << s; free(s);
    956           return true;
    957         } else
    958           return false;
    959       } else
    960         return false;
     964      }
     965      pure_unref(x);
     966      return ret;
    961967    }
    962968  } else
    963969    return false;