Use strtok_r instead of strtok

Improves threadsafety. This will be important when the patch series at
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176
lands.

gdb/ChangeLog:

2019-11-06  Christian Biesinger  <cbiesinger@google.com>

	* linux-tdep.c (linux_info_proc): Use strtok_r instead of strtok.
	* mi/mi-main.c (output_cores): Likewise.
	* nat/linux-osdata.c (linux_xfer_osdata_cpus): Likewise.
	(linux_xfer_osdata_modules): Likewise.
	* remote.c (register_remote_support_xml): Likewise.
	* sparc64-tdep.c (adi_is_addr_mapped): Likewise.
	* xml-syscall.c (syscall_create_syscall_desc): Likewise.

gdb/gdbserver/ChangeLog:

2019-11-06  Christian Biesinger  <cbiesinger@google.com>

	* linux-x86-low.c (x86_linux_process_qsupported): Use strtok_r
	instead of strtok.
	* server.c (handle_query): Likewise.
	(captured_main): Likewise.

Change-Id: Ief6138965a24398e5fc064598cd8f2abd3b5047c
This commit is contained in:
Christian Biesinger
2019-11-02 12:09:31 -05:00
parent 848288b363
commit ca3a04f65d
10 changed files with 56 additions and 27 deletions

View File

@ -839,9 +839,10 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
" Size", " Offset", "objfile");
}
for (line = strtok (map.get (), "\n");
char *saveptr;
for (line = strtok_r (map.get (), "\n", &saveptr);
line;
line = strtok (NULL, "\n"))
line = strtok_r (NULL, "\n", &saveptr))
{
ULONGEST addr, endaddr, offset, inode;
const char *permissions, *device, *mapping_filename;