From 6f2783d5151cb8e9ee3aa9ab591b65847042cf1b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 21 Mar 2013 08:33:52 -0400 Subject: [PATCH] Add various debug statements to trans that I used to help track down the problem and which seem like they could be useful in the future. --- src/librustc/middle/trans/base.rs | 10 +++++++++- src/librustc/middle/trans/callee.rs | 2 +- src/librustc/middle/trans/common.rs | 7 ++++++- src/librustc/middle/trans/meth.rs | 5 +++++ src/librustc/middle/trans/monomorphize.rs | 6 ++++-- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 62fff583766..ebeab857b19 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1579,7 +1579,15 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext, id: ast::node_id, impl_id: Option, param_substs: Option<@param_substs>, - sp: Option) -> fn_ctxt { + sp: Option) -> fn_ctxt +{ + debug!("new_fn_ctxt_w_id(path=%s, id=%?, impl_id=%?, \ + param_substs=%s", + path_str(ccx.sess, path), + id, + impl_id, + opt_param_substs_to_str(ccx.tcx, ¶m_substs)); + let llbbs = mk_standard_basic_blocks(llfndecl); return @mut fn_ctxt_ { llfn: llfndecl, diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 607d4cff8d6..9916af6fab0 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -217,7 +217,7 @@ pub fn trans_fn_ref_with_vtables( // - `type_params`: values for each of the fn/method's type parameters // - `vtables`: values for each bound on each of the type parameters - let _icx = bcx.insn_ctxt("trans_fn_with_vtables"); + let _icx = bcx.insn_ctxt("trans_fn_ref_with_vtables"); let ccx = bcx.ccx(); let tcx = ccx.tcx; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 0b7d6f5c39b..625738ab1b9 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -257,6 +257,11 @@ pub fn param_substs_to_str(tcx: ty::ctxt, substs: ¶m_substs) -> ~str { substs.bounds.map(|b| ty::param_bounds_to_str(tcx, *b))) } +pub fn opt_param_substs_to_str(tcx: ty::ctxt, + substs: &Option<@param_substs>) -> ~str { + substs.map_default(~"None", |&ps| param_substs_to_str(tcx, ps)) +} + // Function context. Every LLVM function we create will have one of // these. pub struct fn_ctxt_ { @@ -1423,7 +1428,7 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin) } pub fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs, - n_param: uint, n_bound: uint) + n_param: uint, n_bound: uint) -> typeck::vtable_origin { debug!("find_vtable_in_fn_ctxt(n_param=%u, n_bound=%u, ps=%?)", n_param, n_bound, param_substs_to_str(tcx, ps)); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index ce6f6c8efa7..2ac8742f6e0 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -175,6 +175,9 @@ pub fn trans_method_callee(bcx: block, -> Callee { let _icx = bcx.insn_ctxt("impl::trans_method_callee"); + debug!("trans_method_callee(callee_id=%?, self=%s, mentry=%?)", + callee_id, bcx.expr_to_str(self), mentry); + // Replace method_self with method_static here. let mut origin = mentry.origin; match origin { @@ -218,6 +221,8 @@ pub fn trans_method_callee(bcx: block, typeck::method_trait(*) => {} } + debug!("origin=%?", origin); + match origin { typeck::method_static(did) => { let callee_fn = callee::trans_fn_ref(bcx, did, callee_id); diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index feddbabdcad..a38c82d37c4 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -67,9 +67,11 @@ pub fn monomorphic_fn(ccx: @CrateContext, must_cast = true; } - debug!("monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \ - hash_id = %?", + debug!("monomorphic_fn(fn_id=%? (%s), vtables=%?, \ + real_substs=%?, substs=%?, \ + hash_id = %?", fn_id, ty::item_path_str(ccx.tcx, fn_id), + vtables, real_substs.map(|s| ty_to_str(ccx.tcx, *s)), substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id);