]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdbsupport] Fix get_print_cell use in threads
authorTom de Vries <tdevries@suse.de>
Tue, 6 Jan 2026 20:05:46 +0000 (21:05 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 6 Jan 2026 20:05:46 +0000 (21:05 +0100)
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

gdbsupport/print-utils.cc

index da47d1b45b588ba2113f780a247260ee02c69402..d5a91ba0f834a5c9801a2b7a0138d01f109f6084 100644 (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;