Commit 7e4597d7aea6a085f5ebfcfe56654d4c46a2ede7

Authored by bellard
1 parent 437a88a5

added debug_insn_start debug instruction

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4531 c046a42c-6fe2-441c-8c8c-71466251a162
tcg/tcg-op.h
@@ -1291,6 +1291,18 @@ static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id) @@ -1291,6 +1291,18 @@ static inline void tcg_gen_macro_2(TCGv ret0, TCGv ret1, int macro_id)
1291 #error must include QEMU headers 1291 #error must include QEMU headers
1292 #endif 1292 #endif
1293 1293
  1294 +/* debug info: write the PC of the corresponding QEMU CPU instruction */
  1295 +static inline void tcg_gen_debug_insn_start(uint64_t pc)
  1296 +{
  1297 + /* XXX: must really use a 32 bit size for TCGArg in all cases */
  1298 +#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
  1299 + tcg_gen_op2i(INDEX_op_debug_insn_start,
  1300 + (uint32_t)(pc), (uint32_t)(pc >> 32));
  1301 +#else
  1302 + tcg_gen_op1i(INDEX_op_debug_insn_start, pc);
  1303 +#endif
  1304 +}
  1305 +
1294 static inline void tcg_gen_exit_tb(tcg_target_long val) 1306 static inline void tcg_gen_exit_tb(tcg_target_long val)
1295 { 1307 {
1296 tcg_gen_op1i(INDEX_op_exit_tb, val); 1308 tcg_gen_op1i(INDEX_op_exit_tb, val);
tcg/tcg-opc.h
@@ -156,6 +156,11 @@ DEF2(neg_i64, 1, 1, 0, 0) @@ -156,6 +156,11 @@ DEF2(neg_i64, 1, 1, 0, 0)
156 #endif 156 #endif
157 157
158 /* QEMU specific */ 158 /* QEMU specific */
  159 +#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
  160 +DEF2(debug_insn_start, 0, 0, 2, 0)
  161 +#else
  162 +DEF2(debug_insn_start, 0, 0, 1, 0)
  163 +#endif
159 DEF2(exit_tb, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) 164 DEF2(exit_tb, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS)
160 DEF2(goto_tb, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) 165 DEF2(goto_tb, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS)
161 /* Note: even if TARGET_LONG_BITS is not defined, the INDEX_op 166 /* Note: even if TARGET_LONG_BITS is not defined, the INDEX_op
tcg/tcg.c
@@ -743,17 +743,31 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) @@ -743,17 +743,31 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile)
743 const uint16_t *opc_ptr; 743 const uint16_t *opc_ptr;
744 const TCGArg *args; 744 const TCGArg *args;
745 TCGArg arg; 745 TCGArg arg;
746 - int c, i, k, nb_oargs, nb_iargs, nb_cargs; 746 + int c, i, k, nb_oargs, nb_iargs, nb_cargs, first_insn;
747 const TCGOpDef *def; 747 const TCGOpDef *def;
748 char buf[128]; 748 char buf[128];
749 749
  750 + first_insn = 1;
750 opc_ptr = gen_opc_buf; 751 opc_ptr = gen_opc_buf;
751 args = gen_opparam_buf; 752 args = gen_opparam_buf;
752 while (opc_ptr < gen_opc_ptr) { 753 while (opc_ptr < gen_opc_ptr) {
753 c = *opc_ptr++; 754 c = *opc_ptr++;
754 def = &tcg_op_defs[c]; 755 def = &tcg_op_defs[c];
755 - fprintf(outfile, " %s ", def->name);  
756 - if (c == INDEX_op_call) { 756 + if (c == INDEX_op_debug_insn_start) {
  757 + uint64_t pc;
  758 +#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
  759 + pc = ((uint64_t)args[1] << 32) | args[0];
  760 +#else
  761 + pc = args[0];
  762 +#endif
  763 + if (!first_insn)
  764 + fprintf(outfile, "\n");
  765 + fprintf(outfile, " ---- 0x%" PRIx64, pc);
  766 + first_insn = 0;
  767 + nb_oargs = def->nb_oargs;
  768 + nb_iargs = def->nb_iargs;
  769 + nb_cargs = def->nb_cargs;
  770 + } else if (c == INDEX_op_call) {
757 TCGArg arg; 771 TCGArg arg;
758 772
759 /* variable number of arguments */ 773 /* variable number of arguments */
@@ -762,6 +776,8 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) @@ -762,6 +776,8 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile)
762 nb_iargs = arg & 0xffff; 776 nb_iargs = arg & 0xffff;
763 nb_cargs = def->nb_cargs; 777 nb_cargs = def->nb_cargs;
764 778
  779 + fprintf(outfile, " %s ", def->name);
  780 +
765 /* function name */ 781 /* function name */
766 fprintf(outfile, "%s", 782 fprintf(outfile, "%s",
767 tcg_get_helper_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1])); 783 tcg_get_helper_str_idx(s, buf, sizeof(buf), args[nb_oargs + nb_iargs - 1]));
@@ -785,6 +801,7 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile) @@ -785,6 +801,7 @@ void tcg_dump_ops(TCGContext *s, FILE *outfile)
785 } 801 }
786 } 802 }
787 } else { 803 } else {
  804 + fprintf(outfile, " %s ", def->name);
788 if (c == INDEX_op_nopn) { 805 if (c == INDEX_op_nopn) {
789 /* variable number of arguments */ 806 /* variable number of arguments */
790 nb_cargs = *args; 807 nb_cargs = *args;
@@ -1037,6 +1054,9 @@ void tcg_liveness_analysis(TCGContext *s) @@ -1037,6 +1054,9 @@ void tcg_liveness_analysis(TCGContext *s)
1037 /* mark end of basic block */ 1054 /* mark end of basic block */
1038 tcg_la_bb_end(s, dead_temps); 1055 tcg_la_bb_end(s, dead_temps);
1039 break; 1056 break;
  1057 + case INDEX_op_debug_insn_start:
  1058 + args -= def->nb_args;
  1059 + break;
1040 case INDEX_op_nopn: 1060 case INDEX_op_nopn:
1041 nb_args = args[-1]; 1061 nb_args = args[-1];
1042 args -= nb_args; 1062 args -= nb_args;
@@ -1840,6 +1860,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, @@ -1840,6 +1860,9 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
1840 dead_iargs = s->op_dead_iargs[op_index]; 1860 dead_iargs = s->op_dead_iargs[op_index];
1841 tcg_reg_alloc_mov(s, def, args, dead_iargs); 1861 tcg_reg_alloc_mov(s, def, args, dead_iargs);
1842 break; 1862 break;
  1863 + case INDEX_op_debug_insn_start:
  1864 + /* debug instruction */
  1865 + break;
1843 case INDEX_op_nop: 1866 case INDEX_op_nop:
1844 case INDEX_op_nop1: 1867 case INDEX_op_nop1:
1845 case INDEX_op_nop2: 1868 case INDEX_op_nop2: