[c] gdb debug coreutils - xieyunzi/xieyunzi.github.io GitHub Wiki

build ignore warning

https://stackoverflow.com/questions/11561261/how-to-compile-without-warnings-being-treated-as-errors

diff --git a/configure.ac b/configure.ac
index 669e9d1f2..645c628b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,7 @@ AC_ARG_ENABLE([gcc-warnings],
 )

 if test "$gl_gcc_warnings" = yes; then
-  gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+  # gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
   AC_SUBST([WERROR_CFLAGS])

   nw=
@@ -475,7 +475,7 @@ fi
 ac_save_CFLAGS=$CFLAGS
 ac_save_LDFLAGS=$LDFLAGS
 # Detect warnings about ignored "constructor" attributes.
-gl_WARN_ADD([-Werror], [CFLAGS])
+# gl_WARN_ADD([-Werror], [CFLAGS])
 gl_WARN_ADD([-errwarn], [CFLAGS])
 # Put this message here, after gl_WARN_ADD's chatter.
 AC_MSG_CHECKING([whether this system supports stdbuf])

build it, then debug it with gdb

gdb ./src/cat
(gdb) b main
Breakpoint 1 at 0x17a0: file src/cat.c, line 504.
(gdb) run NEWs
Starting program: /vagrant/coreutils/src/cat NEWs

Breakpoint 1, main (argc=2, argv=0x7fffffffe618) at src/cat.c:504
504     {
(gdb) printf "%s\n", quotearg_n_style_colon(0, 3, "filename")
filename