[binutils-gdb/gdb-17-branch] [gdbsupport] Fix get_print_cell use in threads
Tom de Vries
vries@sourceware.org
Sun Jan 11 09:32:53 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59ffbefc0ee0152b0679cd5cea46397e8e74e5db
commit 59ffbefc0ee0152b0679cd5cea46397e8e74e5db
Author: Tom de Vries <tdevries@suse.de>
Date: Sun Jan 11 10:32:49 2026 +0100
[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>
Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33753
(cherry picked from commit 8543102f51fa6edb5b2c63081378965adfc900ca)
Diff:
---
gdbsupport/print-utils.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 8514720d963..145a8838e16 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -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;
More information about the Gdb-cvs
mailing list