Browse Source

util: avoid double printing of ellipsis in print_array

When PAF_ARRAY_TRUNCATED flag is provided to print_array_ex.

* util.c (print_array_ex): Add truncated flag, set it when the output
is truncated, avoid explicit ellipsis printing when it is set.

Fixes: v5.3~14 "Add PAF_ARRAY_TRUNCATED flag for print_array_ex"
Eugene Syromyatnikov 1 month ago
parent
commit
ad937e4b7e
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      util.c

+ 4
- 1
util.c View File

@@ -1329,6 +1329,7 @@ print_array_ex(struct tcb *const tcp,
1329 1329
 	kernel_ulong_t cur;
1330 1330
 	kernel_ulong_t idx = 0;
1331 1331
 	enum xlat_style xlat_style = flags & XLAT_STYLE_MASK;
1332
+	bool truncated = false;
1332 1333
 
1333 1334
 	for (cur = start_addr; cur < end_addr; cur += elem_size, idx++) {
1334 1335
 		if (cur != start_addr)
@@ -1341,6 +1342,7 @@ print_array_ex(struct tcb *const tcp,
1341 1342
 				else {
1342 1343
 					tprints("...");
1343 1344
 					printaddr_comment(cur);
1345
+					truncated = true;
1344 1346
 				}
1345 1347
 				break;
1346 1348
 			}
@@ -1354,6 +1356,7 @@ print_array_ex(struct tcb *const tcp,
1354 1356
 		if (cur >= abbrev_end) {
1355 1357
 			tprints("...");
1356 1358
 			cur = end_addr;
1359
+			truncated = true;
1357 1360
 			break;
1358 1361
 		}
1359 1362
 
@@ -1377,7 +1380,7 @@ print_array_ex(struct tcb *const tcp,
1377 1380
 	}
1378 1381
 
1379 1382
 	if ((cur != start_addr) || !tfetch_mem_func) {
1380
-		if (flags & PAF_ARRAY_TRUNCATED) {
1383
+		if ((flags & PAF_ARRAY_TRUNCATED) && !truncated) {
1381 1384
 			if (cur != start_addr)
1382 1385
 				tprints(", ");
1383 1386
 

Loading…
Cancel
Save