This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings)


"-Wwrite-strings" is enabled by default for C++ programs:

  "When compiling C++, warn about the deprecated conversion from
  string literals to char *. This warning is enabled by default for
  C++ programs. "

This warning, via -Werror, makes this be a compile-time error:

 char *str = "hello";

It forces us to write instead either

 char *str = (char *) "hello"; // I know what I'm doing! (TM)

or:

 const char *str = "hello";    // Preferable.

However, I had disabled the warning for GDB in the earlier steps of
the C++ conversion:

  https://sourceware.org/ml/gdb-patches/2015-02/msg00203.html

... as an expedient hack, since we weren't enabling it in C mode
either.

I'd like to enable the warning now, to catch more bugs at compile
time.  I spotted one related bug in review last week (storing a string
literal in a vector of heap-allocated strings, leading to a bogus
"free" call later on), which was what prompted me to do this.

"Bah, I'll just do it.  Can't take more than a couple hours..."

Yeah, right...  /me will never learn.

Tested on x86_64 Fedora 23, built with --enable-targets=all.

Compile tested GDB on Aarch64 GNU/Linux, Power 64 GNU/Linux, AIX 7.1,
and 32-bit/64-bit mingw32-w64.

Also cross built MIPS and ARM GNU/Linux gdbserver.

The first patch needs approval from the binutils side, hence the cross
post.  The rest of the series is GDB-specific, so I'm sending those
patches to gdb-patches@ only.

Pedro Alves (18):
  -Wwrite-strings: Constify struct disassemble_info's
    disassembler_options field
  -Wwrite-strings: Constify macroexp.c:init_shared_buffer
  -Wwrite-strings: Don't initialize string command variables to empty
    string
  -Wwrite-strings: Constify shell_escape and plug make_command leak
  -Wwrite-strings: Constify warning_pre_print
  -Wwrite-strings: Constify target_pid_to_str and
    target_thread_extra_thread_info
  -Wwrite-strings: Constify work break character arrays
  -Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter
  -Wwrite-strings: MI -info-os
  -Wwrite-strings: gdbserver's 'port' parsing
  -Wwrite-strings: gdbserver/win32-low.c and TARGET_WAITKIND_EXECD
  -Wwrite-strings: More fix-old-Python-API wrappers
  -Wwrite-strings: Wrap PyGetSetDef for construction with string
    literals
  -Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *"
    overload
  -Wwrite-strings: execute_command calls with string literals
  -Wwrite-strings: Some constification in gdb/breakpoint.c
  -Wwrite-strings: The Rest
  -Wwrite-strings: Remove -Wno-write-strings

 gdb/ada-exp.y                    |   4 +-
 gdb/ada-lang.c                   |  58 +++++++++---------
 gdb/ada-lang.h                   |   8 +--
 gdb/aix-thread.c                 |   4 +-
 gdb/arc-tdep.c                   |   2 +-
 gdb/arm-tdep.c                   |   4 +-
 gdb/ax-gdb.c                     |  21 ++++---
 gdb/bcache.c                     |   2 +-
 gdb/bcache.h                     |   2 +-
 gdb/break-catch-throw.c          |  23 ++++---
 gdb/breakpoint.c                 |  38 ++++++------
 gdb/breakpoint.h                 |   8 +--
 gdb/bsd-kvm.c                    |   2 +-
 gdb/bsd-uthread.c                |   6 +-
 gdb/buildsym.c                   |   2 +-
 gdb/buildsym.h                   |   4 +-
 gdb/c-exp.y                      |   6 +-
 gdb/c-lang.h                     |   4 +-
 gdb/c-varobj.c                   |   2 +-
 gdb/charset.c                    |  11 +++-
 gdb/cli/cli-cmds.c               |  40 ++++++------
 gdb/cli/cli-decode.c             |   3 +-
 gdb/cli/cli-dump.c               |  15 ++---
 gdb/cli/cli-script.c             |   2 +-
 gdb/cli/cli-script.h             |   2 +-
 gdb/cli/cli-utils.c              |   6 +-
 gdb/cli/cli-utils.h              |  21 ++++++-
 gdb/coff-pe-read.c               |   2 +-
 gdb/command.h                    |   3 +-
 gdb/common/print-utils.c         |   2 +-
 gdb/completer.c                  |  62 +++++++++++--------
 gdb/completer.h                  |   8 ++-
 gdb/configure                    |   2 +-
 gdb/corefile.c                   |   2 +-
 gdb/corelow.c                    |   2 +-
 gdb/cp-name-parser.y             |   4 +-
 gdb/cp-valprint.c                |   2 +-
 gdb/cris-tdep.c                  |   6 +-
 gdb/d-exp.y                      |   6 +-
 gdb/d-lang.h                     |   2 +-
 gdb/darwin-nat.c                 |   4 +-
 gdb/dbxread.c                    |  80 ++++++++++++------------
 gdb/defs.h                       |   7 ++-
 gdb/disasm.c                     |   2 +-
 gdb/dwarf2read.c                 |   8 +--
 gdb/event-top.c                  |   4 +-
 gdb/exceptions.c                 |   4 +-
 gdb/exceptions.h                 |   3 +-
 gdb/expprint.c                   |  14 ++---
 gdb/expression.h                 |   6 +-
 gdb/f-exp.y                      |   8 +--
 gdb/f-lang.c                     |   2 +-
 gdb/f-lang.h                     |   2 +-
 gdb/fbsd-nat.c                   |   2 +-
 gdb/fbsd-tdep.c                  |   2 +-
 gdb/fork-child.c                 |   2 +-
 gdb/frv-tdep.c                   |   6 +-
 gdb/gdbarch.c                    |   6 +-
 gdb/gdbarch.h                    |   4 +-
 gdb/gdbarch.sh                   |   6 +-
 gdb/gdbcore.h                    |   2 +-
 gdb/gdbserver/configure          |   2 +-
 gdb/gdbserver/gdbreplay.c        |   2 +-
 gdb/gdbserver/linux-x86-low.c    |   2 +-
 gdb/gdbserver/remote-utils.c     |   8 +--
 gdb/gdbserver/remote-utils.h     |   4 +-
 gdb/gdbserver/server.c           |  13 ++--
 gdb/gdbserver/win32-low.c        |   5 --
 gdb/gnu-nat.c                    |   2 +-
 gdb/go-exp.y                     |   6 +-
 gdb/go-lang.h                    |   2 +-
 gdb/go32-nat.c                   |   4 +-
 gdb/guile/scm-breakpoint.c       |   3 +-
 gdb/guile/scm-cmd.c              |   4 +-
 gdb/guile/scm-param.c            |   2 +-
 gdb/h8300-tdep.c                 |   6 +-
 gdb/hppa-tdep.c                  |   4 +-
 gdb/i386-cygwin-tdep.c           |   2 +-
 gdb/i386-tdep.c                  |   4 +-
 gdb/ia64-tdep.c                  |   2 +-
 gdb/inf-ptrace.c                 |   2 +-
 gdb/infcmd.c                     |  12 ++--
 gdb/inferior.c                   |   2 +-
 gdb/language.c                   |  10 +--
 gdb/language.h                   |   8 +--
 gdb/linespec.c                   |   3 +-
 gdb/linux-nat.c                  |   2 +-
 gdb/linux-tdep.c                 |   2 +-
 gdb/linux-thread-db.c            |   6 +-
 gdb/lm32-tdep.c                  |   2 +-
 gdb/m2-exp.y                     |   4 +-
 gdb/m2-lang.h                    |   2 +-
 gdb/m32r-tdep.c                  |   2 +-
 gdb/m68hc11-tdep.c               |   2 +-
 gdb/m88k-tdep.c                  |   2 +-
 gdb/macroexp.c                   |  28 +++++----
 gdb/main.c                       |   6 +-
 gdb/mdebugread.c                 |  46 +++++++-------
 gdb/memattr.c                    |   2 +-
 gdb/mep-tdep.c                   |   2 +-
 gdb/mi/mi-cmd-break.c            |  12 ++--
 gdb/mi/mi-cmd-catch.c            |   8 +--
 gdb/mi/mi-cmd-disas.c            |   2 +-
 gdb/mi/mi-cmd-env.c              |  16 ++---
 gdb/mi/mi-cmd-file.c             |   6 +-
 gdb/mi/mi-cmd-info.c             |  10 +--
 gdb/mi/mi-cmd-stack.c            |  18 +++---
 gdb/mi/mi-cmd-target.c           |   6 +-
 gdb/mi/mi-cmd-var.c              |  36 +++++------
 gdb/mi/mi-cmds.h                 |   2 +-
 gdb/mi/mi-interp.c               |   2 +-
 gdb/mi/mi-main.c                 |  86 +++++++++++++-------------
 gdb/mi/mi-symbol-cmds.c          |   2 +-
 gdb/mips-tdep.c                  |   6 +-
 gdb/mn10300-tdep.c               |  10 +--
 gdb/moxie-tdep.c                 |   2 +-
 gdb/nat/linux-osdata.c           |   6 +-
 gdb/nto-tdep.c                   |   4 +-
 gdb/nto-tdep.h                   |   2 +-
 gdb/objc-lang.c                  |   8 +--
 gdb/objc-lang.h                  |   7 ++-
 gdb/objfiles.c                   |   2 +-
 gdb/objfiles.h                   |   2 +-
 gdb/obsd-nat.c                   |   2 +-
 gdb/osdata.c                     |  13 +++-
 gdb/osdata.h                     |   6 +-
 gdb/p-exp.y                      |   6 +-
 gdb/p-lang.h                     |   2 +-
 gdb/parser-defs.h                |   6 +-
 gdb/printcmd.c                   |   2 +-
 gdb/procfs.c                     |   4 +-
 gdb/psymtab.c                    |   2 +-
 gdb/python/py-arch.c             |   2 +-
 gdb/python/py-breakpoint.c       |   8 +--
 gdb/python/py-cmd.c              |  16 ++---
 gdb/python/py-event.c            |   4 +-
 gdb/python/py-event.h            |   4 +-
 gdb/python/py-evts.c             |   2 +-
 gdb/python/py-finishbreakpoint.c |   4 +-
 gdb/python/py-framefilter.c      |   2 +-
 gdb/python/py-inferior.c         |  11 ++--
 gdb/python/py-objfile.c          |   4 +-
 gdb/python/py-param.c            |   2 +-
 gdb/python/py-symbol.c           |   4 +-
 gdb/python/py-type.c             |   2 +-
 gdb/python/py-unwind.c           |   2 +-
 gdb/python/py-value.c            |   4 +-
 gdb/python/python-internal.h     | 120 ++++++++++++++++++++++++++++++++++++
 gdb/python/python.c              |   8 +--
 gdb/ravenscar-thread.c           |   8 +--
 gdb/record-btrace.c              |   8 +--
 gdb/record-full.c                |   2 +-
 gdb/record.c                     |  14 ++---
 gdb/remote-fileio.c              |   2 +-
 gdb/remote-sim.c                 |   2 +-
 gdb/remote.c                     |  12 ++--
 gdb/reverse.c                    |   2 +-
 gdb/rs6000-tdep.c                |   4 +-
 gdb/rust-exp.y                   |   2 +-
 gdb/rust-lang.c                  |   2 +-
 gdb/rust-lang.h                  |   2 +-
 gdb/serial.h                     |   2 +-
 gdb/sh-tdep.c                    |  22 +++----
 gdb/sh64-tdep.c                  |   2 +-
 gdb/sol-thread.c                 |   2 +-
 gdb/sol2-tdep.c                  |   2 +-
 gdb/sol2-tdep.h                  |   2 +-
 gdb/solib-darwin.c               |   2 +-
 gdb/spu-tdep.c                   |   4 +-
 gdb/stabsread.c                  | 129 ++++++++++++++++++++-------------------
 gdb/stabsread.h                  |  10 +--
 gdb/symfile.c                    |  12 ++--
 gdb/symfile.h                    |   2 +-
 gdb/target-delegates.c           |  18 +++---
 gdb/target-descriptions.c        |   8 ++-
 gdb/target.c                     |  18 +++---
 gdb/target.h                     |  11 ++--
 gdb/thread.c                     |   2 +-
 gdb/top.c                        |   7 ++-
 gdb/top.h                        |   2 +-
 gdb/tracefile-tfile.c            |   4 +-
 gdb/tracepoint.c                 |  24 +++++---
 gdb/tracepoint.h                 |   2 +-
 gdb/tui/tui-data.c               |   2 +-
 gdb/tui/tui-data.h               |   2 +-
 gdb/tui/tui-source.c             |   2 +-
 gdb/tui/tui-source.h             |   2 +-
 gdb/tui/tui-win.c                |  11 ++--
 gdb/tui/tui-windata.c            |   2 +-
 gdb/tui/tui-windata.h            |   2 +-
 gdb/tui/tui-winsource.c          |   2 +-
 gdb/tui/tui.c                    |   2 +-
 gdb/utils.c                      |  13 ++--
 gdb/utils.h                      |   4 +-
 gdb/varobj.c                     |   2 +-
 gdb/varobj.h                     |   2 +-
 gdb/vax-tdep.c                   |   2 +-
 gdb/warning.m4                   |   2 +-
 gdb/windows-nat.c                |   4 +-
 gdb/xcoffread.c                  |   8 +--
 gdb/xml-support.c                |  10 +--
 gdb/xml-tdesc.c                  |   3 +-
 gdb/xstormy16-tdep.c             |   2 +-
 gdb/xtensa-tdep.c                |   2 +-
 gdb/xtensa-tdep.h                |   2 +-
 include/dis-asm.h                |   8 +--
 opcodes/arc-dis.c                |   4 +-
 opcodes/arm-dis.c                |   4 +-
 opcodes/ppc-dis.c                |   2 +-
 opcodes/vax-dis.c                |   2 +-
 210 files changed, 983 insertions(+), 763 deletions(-)

-- 
2.5.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]