[gdbsupport] Fix get_print_cell use in threads

PR gdb/33753 reports problems with get_print_cell when used from threads.

Fix this by making the two static variables in get_print_cell thread_local.

Tested on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33753
This commit is contained in:
Tom de Vries
2026-01-06 21:05:46 +01:00
parent 4f0ba520b3
commit 8543102f51

View File

@@ -28,8 +28,8 @@
char *
get_print_cell (void)
{
static char buf[NUMCELLS][PRINT_CELL_SIZE];
static int cell = 0;
static thread_local char buf[NUMCELLS][PRINT_CELL_SIZE];
static thread_local int cell = 0;
if (++cell >= NUMCELLS)
cell = 0;