Skip to content

Commit 42d824d

Browse files
committed
esp108/apptrace: Preserves target state when executing trace commands
1 parent 0cb9b51 commit 42d824d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/target/esp108_apptrace.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ int esp_cmd_apptrace_generic(struct target *target, int mode, const char **argv,
21132113
return res;
21142114
}
21152115
}
2116-
res = esp_apptrace_connect_targets(&s_at_cmd_ctx, true, true);
2116+
res = esp_apptrace_connect_targets(&s_at_cmd_ctx, true, old_state == TARGET_RUNNING);
21172117
if (res != ERROR_OK) {
21182118
LOG_ERROR("Failed to connect to targets (%d)!", res);
21192119
s_at_cmd_ctx.running = 0;
@@ -2207,7 +2207,7 @@ int esp_cmd_apptrace_generic(struct target *target, int mode, const char **argv,
22072207
LOG_ERROR("SEGGER: Failed to stop tracing!");
22082208
}
22092209
}
2210-
res = esp_apptrace_connect_targets(&s_at_cmd_ctx, false, true);
2210+
res = esp_apptrace_connect_targets(&s_at_cmd_ctx, false, old_state == TARGET_RUNNING);
22112211
if (res != ERROR_OK) {
22122212
LOG_ERROR("Failed to disconnect targets (%d)!", res);
22132213
}
@@ -2246,15 +2246,15 @@ int esp_cmd_apptrace_generic(struct target *target, int mode, const char **argv,
22462246
/* let registered timer callbacks to run */
22472247
target_call_timer_callbacks();
22482248
}
2249-
if (s_at_cmd_ctx.running) {
2250-
// data processor is alive, so wait for all received blocks to be processed
2251-
res = esp_apptrace_wait_pended_blocks(&s_at_cmd_ctx);
2252-
if (res != ERROR_OK) {
2253-
LOG_ERROR("Failed to wait for pended blocks (%d)!", res);
2254-
}
2255-
// signal thread to stop
2256-
s_at_cmd_ctx.running = 0;
2257-
}
2249+
if (s_at_cmd_ctx.running) {
2250+
// data processor is alive, so wait for all received blocks to be processed
2251+
res = esp_apptrace_wait_pended_blocks(&s_at_cmd_ctx);
2252+
if (res != ERROR_OK) {
2253+
LOG_ERROR("Failed to wait for pended blocks (%d)!", res);
2254+
}
2255+
// signal thread to stop
2256+
s_at_cmd_ctx.running = 0;
2257+
}
22582258
esp_apptrace_print_stats(&s_at_cmd_ctx);
22592259
res = esp_apptrace_cmd_cleanup(&s_at_cmd_ctx);
22602260
if (res != ERROR_OK) {

0 commit comments

Comments
 (0)