3 #define DEBUG_SLOT(slot) ((int)((slot) ? ((slot) - iln->ctx->n_debug_stackbase) : (-1)))
6 printf("linenumbertable_entry %p: pc=%p line=%08x, lntsize=%d, looking for pc=%p\n",
7 (void*)lntentry,(void*)lntentry->pc,lntentry->line,lntsize,(void*)pc);
11 printf("inline entry %p: pc=%p line=%08x, lntsize=%d, looking for pc=%p\n",
12 (void*)lntinline,(void*)lntinline->pc,lntinline->line,lntsize,(void*)pc);
13 printf("\trecurse %p into %p ",(void*)lntinline,(void*)lntinline->pc); method_println((methodinfo *)lntinline->pc);
20 for (i=0; i<oa->header.size; ++i) {
21 printf("\t%i: %p ",i,(void*)oa->data[i]);
23 class_println((classinfo *)oa->data[i]);
28 printf("GOT CLASS: %p\n",c);
32 printf("GOT CLASSLOADER: %p\n",cl);
34 class_println(cl->vftbl->class);
38 static void debug_dump_inline_context(inline_node *iln)
40 inline_stack_translation *tr;
42 printf("inline_context @%p: stackbase=%p transstart=%p translationlimit=%p\n",
43 (void*)iln->ctx,(void*)iln->ctx->n_debug_stackbase,
44 (void*)iln->ctx->stacktranslationstart,(void*)iln->ctx->o_translationlimit);
45 tr = iln->ctx->stacktranslationstart;
46 while (tr >= iln->ctx->stacktranslation) {
47 printf("\ttranslate %p -> %d (%p)\n",
48 (void*)tr->o_sp,DEBUG_SLOT(tr->n_sp),(void*)tr->n_sp);
53 static void debug_dump_stack(stackptr sp)
56 printf("%p (%d) (%01d:%02d:%01x) -> ",(void*)sp,sp->type,sp->varkind,sp->varnum,sp->flags);
59 printf("%p",(void*)NULL);
62 static void dump_inline_tree(inline_node *iln)
69 printf("(inline_node *)null\n");
73 for (i=0; i<iln->depth; ++i)
80 printf("parent unset");
83 printf("%s[%d] L%03d %d-%d (ins %d,st %d) (sd=%d,cs=%p,lofs=%d) cum(ins %d,st %d,bb %d) ",
84 indent,iln->depth,iln->callerblock->debug_nr,
85 iln->callerpc,(int)(iln->callerblock->iinstr - iln->parent->m->basicblocks->iinstr),
86 iln->instructioncount,iln->stackcount,iln->n_callerstackdepth,
87 (void*)iln->n_callerstack,
89 iln->cumul_instructioncount,iln->cumul_stackcount,iln->cumul_basicblockcount);
93 printf("%s[%d] MAIN (ins %d,st %d) (cs=%p) cum(ins %d,st %d,bb %d) ",indent,iln->depth,
94 iln->instructioncount,iln->stackcount,
95 (void*)iln->n_callerstack,
96 iln->cumul_instructioncount,iln->cumul_stackcount,iln->cumul_basicblockcount);
98 method_println(iln->m);
100 child = iln->children;
103 dump_inline_tree(child);
105 while ((child = child->next) != iln->children);
111 static stackptr first_stackslot_of_block(basicblock *block)
119 return block->instack - (block->indepth-1);
122 iptr = block->iinstr;
137 static void debug_print_stack(inline_node *iln,stackptr sp,int validstackmin,int validstackmax)
145 for (i=0; i<iln->cumul_maxstack; ++i) {
147 idx = sp - iln->n_inlined_stack;
149 case TYPE_ADR: typechar = 'a'; break;
150 case TYPE_INT: typechar = 'i'; break;
151 case TYPE_LNG: typechar = 'l'; break;
152 case TYPE_FLT: typechar = 'f'; break;
153 case TYPE_DBL: typechar = 'd'; break;
154 default: typechar = '?';
156 switch (sp->varkind) {
157 case STACKVAR: kindchar = 's'; break;
158 case LOCALVAR: kindchar = 'l'; break;
159 case TEMPVAR : kindchar = 't'; break;
160 case UNDEFVAR: kindchar = 'u'; break;
161 case ARGVAR : kindchar = 'a'; break;
162 default: kindchar = '_'; break;
164 if (sp->flags & SAVEDVAR)
165 kindchar = toupper(kindchar);
166 printf("%c%-3d(%c%-2d:%01x) ",typechar,idx,kindchar,sp->varnum,sp->flags);
169 assert(idx >= validstackmin);
170 assert(idx <= validstackmax);
172 if (idx < validstackmin || idx > validstackmax) {
173 printf("INVALID STACK INDEX: %d\n",idx);
184 static void debug_dump_inlined_code(inline_node *iln,methodinfo *newmethod,codegendata *cd,registerdata *rd)
190 basicblock *nextblock;
197 printf("INLINED CODE: maxstack=%d maxlocals=%d leafmethod=%d\n",
198 newmethod->maxstack,newmethod->maxlocals,newmethod->isleafmethod);
200 for (i=0; i<newmethod->maxlocals; ++i) {
201 for (type=0; type<5; ++type) {
202 if (rd->locals[i][type].type < 0)
204 printf("\tlocal %d type %d: flags %01x\n",i,type,rd->locals[i][type].flags);
208 for (i=0; i<newmethod->maxstack; ++i) {
209 for (type=0; type<5; ++type) {
210 if (rd->interfaces[i][type].type < 0)
212 printf("\tinterface %d type %d: flags %01x\n",i,type,rd->interfaces[i][type].flags);
216 printf("registerdata:\n");
217 printf("\tmemuse = %d\n",rd->memuse);
218 printf("\targintreguse = %d\n",rd->argintreguse);
219 printf("\targfltreguse = %d\n",rd->argfltreguse);
223 bptr = iln->inlined_basicblocks;
224 for (; bptr; bptr = bptr->next) {
225 curstack = bptr->instack;
229 nextblock = bptr->next;
232 dst = first_stackslot_of_block(nextblock);
234 validstackmax = (dst - iln->n_inlined_stack) - 1;
237 nextblock = nextblock->next;
242 validstackmax = 10000; /* XXX */
245 debug_print_stack(iln,curstack,validstackmin,validstackmax);
246 printf("L%03d BLOCK %p indepth=%d outdepth=%d icount=%d stack=[%d,%d] type=%d flags=%d\n",
247 bptr->debug_nr,(void*)bptr,bptr->indepth,bptr->outdepth,bptr->icount,
248 validstackmin,validstackmax,
249 bptr->type,bptr->flags);
254 debug_print_stack(iln,dst,validstackmin,validstackmax);
256 show_icmd(iptr,false); printf("\n");
263 /* next basic block */
264 validstackmin = validstackmax + 1;