]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
-Wwrite-strings: Fix Solaris "set procfs-file"
authorPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:36 +0000 (19:21 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:36 +0000 (19:21 +0100)
commit3e83a920090130052a407621b94b94513f539fda
tree67e4b825fac13a2e7b841f389b55efc7edf4735e
parent63160a43508fb50d9013df061b2191de71f67b50
-Wwrite-strings: Fix Solaris "set procfs-file"

Compiling GDB with -Wwrite-strings flags this code in gdb/proc-api.c:

  static char *procfs_filename = "procfs_trace";

as needing a cast.  However, this variable is a command variable, and
as such it's incorrect to initialize it to a literal, since when you
use the corresponding set command, gdb frees the old string...

I didn't manage to fully build Solaris gdb (fails for other reasons),
but I confirmed that the system GDB on Solaris 11 crashes when running
this command:

 (gdb) set procfs-file foo
 Segmentation Fault (core dumped)

So I don't think this commit can make it worse than the status quo.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* proc-api.c (procfs_filename): Don't initialize
        procfs_filename.
(prepare_to_trace): Assume procfs_filename is non-NULL.
(_initialize_proc_api): Give procfs_filename a default value here.
gdb/ChangeLog
gdb/proc-api.c