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.
This commit is contained in:
Niko Matsakis 2013-03-21 08:33:52 -04:00
parent e11d13f3de
commit 6f2783d515
5 changed files with 25 additions and 5 deletions

View file

@ -1579,7 +1579,15 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
id: ast::node_id,
impl_id: Option<ast::def_id>,
param_substs: Option<@param_substs>,
sp: Option<span>) -> fn_ctxt {
sp: Option<span>) -> 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, &param_substs));
let llbbs = mk_standard_basic_blocks(llfndecl);
return @mut fn_ctxt_ {
llfn: llfndecl,

View file

@ -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;

View file

@ -257,6 +257,11 @@ pub fn param_substs_to_str(tcx: ty::ctxt, substs: &param_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: &param_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));

View file

@ -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);

View file

@ -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);