From 1468f8dd3ba9fbca77eb531375978d9656bc86e5 Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Tue, 2 Apr 2019 00:55:58 +0800 Subject: [PATCH] app/trace: check num_entries before referring For trace file which is generated by spdk trace_record, if one lcore recorded no entries, there is no space for it to have idle entries to referring. Change-Id: I1cd89ec934407fc805bda66c8c87f76cb181679e Signed-off-by: Xiaodong Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449840 Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- app/trace/trace.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/trace/trace.cpp b/app/trace/trace.cpp index 7a2915447..f9ad27d41 100644 --- a/app/trace/trace.cpp +++ b/app/trace/trace.cpp @@ -411,7 +411,7 @@ int main(int argc, char **argv) if (lcore == SPDK_TRACE_MAX_LCORE) { for (i = 0; i < SPDK_TRACE_MAX_LCORE; i++) { history = spdk_get_per_lcore_history(g_histories, i); - if (history->entries[0].tsc == 0) { + if (history->num_entries == 0 || history->entries[0].tsc == 0) { continue; } @@ -423,7 +423,7 @@ int main(int argc, char **argv) } } else { history = spdk_get_per_lcore_history(g_histories, lcore); - if (history->entries[0].tsc != 0) { + if (history->num_entries > 0 && history->entries[0].tsc != 0) { if (g_verbose && history->num_entries) { printf("Trace Size of lcore (%d): %ju\n", lcore, history->num_entries); }