lockstep.c (a9c17e9a21af9c4bf9c08dedf0f0df4a6566cf52) | lockstep.c (3045019fc9d4fbfe62a23b9c4eacb2a5ee944d4d) |
---|---|
1/* 2 * Lockstep Execution Plugin 3 * 4 * Allows you to execute two QEMU instances in lockstep and report 5 * when their execution diverges. This is mainly useful for developers 6 * who want to see where a change to TCG code generation has 7 * introduced a subtle and hard to find bug. 8 * --- 94 unchanged lines hidden (view full) --- 103static void report_divergance(ExecState *us, ExecState *them) 104{ 105 DivergeState divrec = { log, 0 }; 106 g_autoptr(GString) out = g_string_new(""); 107 bool diverged = false; 108 109 /* 110 * If we have diverged before did we get back on track or are we | 1/* 2 * Lockstep Execution Plugin 3 * 4 * Allows you to execute two QEMU instances in lockstep and report 5 * when their execution diverges. This is mainly useful for developers 6 * who want to see where a change to TCG code generation has 7 * introduced a subtle and hard to find bug. 8 * --- 94 unchanged lines hidden (view full) --- 103static void report_divergance(ExecState *us, ExecState *them) 104{ 105 DivergeState divrec = { log, 0 }; 106 g_autoptr(GString) out = g_string_new(""); 107 bool diverged = false; 108 109 /* 110 * If we have diverged before did we get back on track or are we |
111 * totally losing it? | 111 * totally loosing it? |
112 */ 113 if (divergence_log) { 114 DivergeState *last = (DivergeState *) divergence_log->data; 115 GSList *entry; 116 117 for (entry = log; g_slist_next(entry); entry = g_slist_next(entry)) { 118 if (entry == last->log_pos) { 119 break; --- 9 unchanged lines hidden (view full) --- 129 diverged = true; 130 } 131 } 132 divergence_log = g_slist_prepend(divergence_log, 133 g_memdup2(&divrec, sizeof(divrec))); 134 135 /* Output short log entry of going out of sync... */ 136 if (verbose || divrec.distance == 1 || diverged) { | 112 */ 113 if (divergence_log) { 114 DivergeState *last = (DivergeState *) divergence_log->data; 115 GSList *entry; 116 117 for (entry = log; g_slist_next(entry); entry = g_slist_next(entry)) { 118 if (entry == last->log_pos) { 119 break; --- 9 unchanged lines hidden (view full) --- 129 diverged = true; 130 } 131 } 132 divergence_log = g_slist_prepend(divergence_log, 133 g_memdup2(&divrec, sizeof(divrec))); 134 135 /* Output short log entry of going out of sync... */ 136 if (verbose || divrec.distance == 1 || diverged) { |
137 g_string_printf(out, "@ 0x%016lx vs 0x%016lx (%d/%d since last)\n", | 137 g_string_printf(out, 138 "@ 0x%016" PRIx64 " vs 0x%016" PRIx64 139 " (%d/%d since last)\n", |
138 us->pc, them->pc, g_slist_length(divergence_log), 139 divrec.distance); 140 qemu_plugin_outs(out->str); 141 } 142 143 if (diverged) { 144 int i; 145 GSList *entry; 146 | 140 us->pc, them->pc, g_slist_length(divergence_log), 141 divrec.distance); 142 qemu_plugin_outs(out->str); 143 } 144 145 if (diverged) { 146 int i; 147 GSList *entry; 148 |
147 g_string_printf(out, "Δ insn_count @ 0x%016lx (%ld) vs 0x%016lx (%ld)\n", | 149 g_string_printf(out, 150 "Δ insn_count @ 0x%016" PRIx64 151 " (%ld) vs 0x%016" PRIx64 " (%ld)\n", |
148 us->pc, us->insn_count, them->pc, them->insn_count); 149 150 for (entry = log, i = 0; 151 g_slist_next(entry) && i < 5; 152 entry = g_slist_next(entry), i++) { 153 ExecInfo *prev = (ExecInfo *) entry->data; 154 g_string_append_printf(out, | 152 us->pc, us->insn_count, them->pc, them->insn_count); 153 154 for (entry = log, i = 0; 155 g_slist_next(entry) && i < 5; 156 entry = g_slist_next(entry), i++) { 157 ExecInfo *prev = (ExecInfo *) entry->data; 158 g_string_append_printf(out, |
155 " previously @ 0x%016lx/%ld (%ld insns)\n", | 159 " previously @ 0x%016" PRIx64 "/%" PRId64 160 " (%ld insns)\n", |
156 prev->block->pc, prev->block->insns, 157 prev->insn_count); 158 } 159 qemu_plugin_outs(out->str); 160 qemu_plugin_outs("too much divergence... giving up."); 161 qemu_plugin_uninstall(our_id, plugin_cleanup); 162 } 163} --- 193 unchanged lines hidden --- | 161 prev->block->pc, prev->block->insns, 162 prev->insn_count); 163 } 164 qemu_plugin_outs(out->str); 165 qemu_plugin_outs("too much divergence... giving up."); 166 qemu_plugin_uninstall(our_id, plugin_cleanup); 167 } 168} --- 193 unchanged lines hidden --- |