From 02b0255c7dcb271469312c46a875ec9b7cc5fc2b Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Tue, 25 Feb 2020 15:12:16 -0500 Subject: [PATCH] reduce debuginfod-related chatter --- gdb/Makefile.in | 5 +- gdb/configure | 209 +++++++++++++++++++-------------------- gdb/configure.ac | 34 +------ gdb/debuginfod-support.c | 44 ++++++--- 4 files changed, 141 insertions(+), 151 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index e31493df9e7..f57975542a0 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -591,8 +591,7 @@ INTERNAL_CFLAGS_BASE = \ $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \ $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ $(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(ENABLE_CFLAGS) \ - $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) $(TOP_CFLAGS) $(PTHREAD_CFLAGS) \ - @DEBUGINFOD_CFLAGS@ + $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) $(TOP_CFLAGS) $(PTHREAD_CFLAGS) INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS) INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS) @@ -618,7 +617,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \ $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \ $(WIN32LIBS) $(LIBGNU) $(LIBICONV) \ $(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \ - @DEBUGINFOD_LIBS@ + @LIBDEBUGINFOD@ CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \ $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \ $(LIBSUPPORT) diff --git a/gdb/configure b/gdb/configure index 6286e9ea650..0e7fef528f7 100755 --- a/gdb/configure +++ b/gdb/configure @@ -719,6 +719,7 @@ GUILE_LIBS GUILE_CPPFLAGS GUILD_TARGET_FLAG GUILD +pkg_config_prog_path HAVE_PYTHON_FALSE HAVE_PYTHON_TRUE PYTHON_LIBS @@ -757,9 +758,7 @@ REPORT_BUGS_TEXI REPORT_BUGS_TO PKGVERSION CODESIGN_CERT -DEBUGINFOD_CFLAGS -DEBUGINFOD_LIBS -pkg_config_prog_path +LIBDEBUGINFOD HAVE_NATIVE_GCORE_TARGET TARGET_OBS subdirs @@ -2256,6 +2255,52 @@ rm -f conftest.val } # ac_fn_c_compute_int +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -2377,52 +2422,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type -# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES -# --------------------------------------------- -# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. -ac_fn_c_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_decl - # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including @@ -6831,6 +6830,8 @@ esac # Handle optional debuginfod support +# Enable debuginfod + # Check whether --with-debuginfod was given. if test "${with_debuginfod+set}" = set; then : withval=$with_debuginfod; @@ -6843,79 +6844,75 @@ $as_echo_n "checking whether to use debuginfod... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_debuginfod" >&5 $as_echo "$with_debuginfod" >&6; } -if test "x$with_debuginfod" != xno; then - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_pkg_config_prog_path+:} false; then : +if test "${with_debuginfod}" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod support disabled; some features may be unavailable." >&5 +$as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for debuginfod_begin in -ldebuginfod" >&5 +$as_echo_n "checking for debuginfod_begin in -ldebuginfod... " >&6; } +if ${ac_cv_lib_debuginfod_debuginfod_begin+:} false; then : $as_echo_n "(cached) " >&6 else - case $pkg_config_prog_path in - [\\/]* | ?:[\\/]*) - ac_cv_path_pkg_config_prog_path="$pkg_config_prog_path" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_pkg_config_prog_path="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldebuginfod $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - test -z "$ac_cv_path_pkg_config_prog_path" && ac_cv_path_pkg_config_prog_path="missing" - ;; -esac -fi -pkg_config_prog_path=$ac_cv_path_pkg_config_prog_path -if test -n "$pkg_config_prog_path"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pkg_config_prog_path" >&5 -$as_echo "$pkg_config_prog_path" >&6; } +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char debuginfod_begin (); +int +main () +{ +return debuginfod_begin (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_debuginfod_debuginfod_begin=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_lib_debuginfod_debuginfod_begin=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_debuginfod_debuginfod_begin" >&5 +$as_echo "$ac_cv_lib_debuginfod_debuginfod_begin" >&6; } +if test "x$ac_cv_lib_debuginfod_debuginfod_begin" = xyes; then : + have_debuginfod_lib=yes fi + ac_fn_c_check_decl "$LINENO" "debuginfod_begin" "ac_cv_have_decl_debuginfod_begin" "#include +" +if test "x$ac_cv_have_decl_debuginfod_begin" = xyes; then : + have_debuginfod_h=yes +fi - if test "${pkg_config_prog_path}" != "missing"; then - ${pkg_config_prog_path} --exists --atleast-version=0.178 libdebuginfod - if test $? = 0; then - DEBUGINFOD_LIBS=`${pkg_config_prog_path} --libs libdebuginfod` - - DEBUGINFOD_CFLAGS=`${pkg_config_prog_path} --cflags libdebuginfod` - + if test "x$have_debuginfod_lib" = "xyes" -a \ + "x$have_debuginfod_h" = "xyes"; then $as_echo "#define HAVE_LIBDEBUGINFOD 1" >>confdefs.h - else - if test "x$with_debuginfod" = xyes; then - as_fn_error $? "\"--with-debuginfod was given, but libdebuginfod is missing or unusable.\"" "$LINENO" 5 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&5 -$as_echo "$as_me: WARNING: libdebuginfod is missing or unusable; some features may be unavailable." >&2;} - fi - fi + LIBDEBUGINFOD="-ldebuginfod" + else - if test "x$with_debuginfod" = xyes; then - as_fn_error $? "--with-debuginfod was given, but pkg-config missing or unusable; cannot find libdebuginfod" "$LINENO" 5 + + if test "$with_debuginfod" = yes; then + as_fn_error $? "debuginfod is missing or unusable" "$LINENO" 5 else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config missing or unusable; debuginfod support disabled." >&5 -$as_echo "$as_me: WARNING: pkg-config missing or unusable; debuginfod support disabled." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&5 +$as_echo "$as_me: WARNING: debuginfod is missing or unusable; some features may be unavailable." >&2;} fi fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: debuginfod support disabled; some features may be unavailable." >&5 -$as_echo "$as_me: WARNING: debuginfod support disabled; some features may be unavailable." >&2;} fi + # Libunwind support for ia64. # Check whether --with-libunwind-ia64 was given. diff --git a/gdb/configure.ac b/gdb/configure.ac index dd55f4418b9..2051ccb40e5 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -18,6 +18,8 @@ dnl along with this program. If not, see . dnl Process this file with autoconf to produce a configure script. +m4_include(../config/debuginfod.m4) + AC_INIT(main.c) AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h]) AM_MAINTAINER_MODE @@ -324,37 +326,7 @@ case $host_os in esac # Handle optional debuginfod support -AC_ARG_WITH([debuginfod], - AC_HELP_STRING([--with-debuginfod], [Enable debuginfo lookups with debuginfod (auto/yes/no)]), - [], [with_debuginfod=auto]) -AC_MSG_CHECKING([whether to use debuginfod]) -AC_MSG_RESULT([$with_debuginfod]) - -if test "x$with_debuginfod" != xno; then - AC_PATH_PROG(pkg_config_prog_path, pkg-config, missing) - if test "${pkg_config_prog_path}" != "missing"; then - ${pkg_config_prog_path} --exists --atleast-version=0.178 libdebuginfod - if test $? = 0; then - AC_SUBST([DEBUGINFOD_LIBS], [`${pkg_config_prog_path} --libs libdebuginfod`]) - AC_SUBST([DEBUGINFOD_CFLAGS], [`${pkg_config_prog_path} --cflags libdebuginfod`]) - AC_DEFINE([HAVE_LIBDEBUGINFOD], [1], [Define to 1 if debuginfod is enabled.]) - else - if test "x$with_debuginfod" = xyes; then - AC_MSG_ERROR(["--with-debuginfod was given, but libdebuginfod is missing or unusable."]) - else - AC_MSG_WARN([libdebuginfod is missing or unusable; some features may be unavailable.]) - fi - fi - else - if test "x$with_debuginfod" = xyes; then - AC_MSG_ERROR([--with-debuginfod was given, but pkg-config missing or unusable; cannot find libdebuginfod]) - else - AC_MSG_WARN([pkg-config missing or unusable; debuginfod support disabled.]) - fi - fi -else - AC_MSG_WARN([debuginfod support disabled; some features may be unavailable.]) -fi +AC_DEBUGINFOD # Libunwind support for ia64. AC_ARG_WITH(libunwind-ia64, diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 3472c5fb709..7bb1207c0b9 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -43,15 +43,28 @@ debuginfod_debuginfo_query (const unsigned char *build_id, #else #include +/* TODO: Use debuginfod API extensions to print filename from progressfn. */ +static const char *fname; +static bool has_printed; + static int progressfn (debuginfod_client *c, long cur, long total) { if (check_quit_flag ()) { - printf_filtered ("Cancelling download...\n"); + printf_filtered ("Cancelling download of %ps...\n", + styled_string (file_name_style.style (), fname)); return 1; } + if (!has_printed) + { + /* Print this message only once. */ + has_printed = true; + printf_unfiltered ("Debuginfod downloading %ps...\n", + styled_string (file_name_style.style (), fname)); + } + return 0; } @@ -74,13 +87,16 @@ debuginfod_source_query (const unsigned char *build_id, const char *srcpath, gdb::unique_xmalloc_ptr *destname) { + if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) + return scoped_fd (-ENOSYS); + debuginfod_client *c = debuginfod_init (); if (c == nullptr) return scoped_fd (-ENOMEM); - printf_filtered (_("Debuginfod fetching source file %ps...\n"), - styled_string (file_name_style.style (), srcpath)); + fname = srcpath; + has_printed = false; scoped_fd fd (debuginfod_find_source (c, build_id, @@ -88,10 +104,12 @@ debuginfod_source_query (const unsigned char *build_id, srcpath, nullptr)); - if (fd.get () < 0) + /* TODO: Add 'set debug debuginfod' command to control when error messages are shown. */ + if (fd.get () < 0 && fd.get () != -ENOENT) { - printf_filtered (_("Download failed. Continuing without source file %ps.\n"), - styled_string (file_name_style.style (), srcpath)); + printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"), + strerror (-fd.get ()), + styled_string (file_name_style.style (), srcpath)); } else destname->reset (xstrdup (srcpath)); @@ -108,19 +126,23 @@ debuginfod_debuginfo_query (const unsigned char *build_id, const char *filename, gdb::unique_xmalloc_ptr *destname) { + if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) + return scoped_fd (-ENOSYS); + debuginfod_client *c = debuginfod_init (); if (c == nullptr) return scoped_fd (-ENOMEM); - printf_filtered (_("Debuginfod fetching debug info for %ps...\n"), - styled_string (file_name_style.style (), filename)); - + fname = filename; + has_printed = false; char *dname = nullptr; + scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len, &dname)); - if (fd.get () < 0) - printf_filtered (_("Download failed. Continuing without debug info for %ps.\n"), + if (fd.get () < 0 && fd.get () != -ENOENT) + printf_filtered (_("Download failed: %s. Continuing without debug info for %ps.\n"), + strerror (-fd.get ()), styled_string (file_name_style.style (), filename)); destname->reset (dname); -- 2.47.2