summaryrefslogtreecommitdiff
path: root/gdb/debuginfod-support.c
Commit message (Collapse)AuthorAgeFilesLines
* Make ui_out::do_progress_end 'private'Tom Tromey2023-03-201-44/+57
| | | | | | | | | I noticed that ui_out::do_progress_end is public, just to support one use in debuginfod-support.c. This patch makes it private, updates progress_info to call it from its destructor, and finally changes debuginfod-support.c to follow.
* Update copyright year range in header of all files managed by GDBJoel Brobecker2023-01-011-1/+1
| | | | | | | This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
* gdb/debuginfod: Improve progress updatesAaron Merey2022-11-101-43/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | If the download size is known, a progress bar is displayed along with the percentage of completion and the total download size. Downloading separate debug info for /lib/libxyz.so [############ ] 25% (10.01 M) If the download size is not known, a progress indicator is displayed with a ticker ("###") that moves across the screen at a rate of 1 tick every 0.5 seconds. Downloading separate debug info for /lib/libxyz.so [ ### ] If the output stream is not a tty, batch mode is enabled, the screen is too narrow or width has been set to 'unlimited', then only a static description of the download is printed. No bar or ticker is displayed. Downloading separate debug info for /lib/libxyz.so... In any case, if the size of the download is known at the time the description is printed then it will be included in the description. Downloading 10.01 MB separate debug info for /lib/libxyz.so...
* gdb-add-index always generates an error when libdebuginfod wasn't compiled inAaron Merey2022-07-151-1/+3
| | | | | | | | | | gdb-add-index runs gdb with -iex 'set debuginfod enabled off'. If gdb is not compiled against libdebuginfod this causes an unnecessary error message to be printed to stderr indicating that gdb was not built with debuginfod support. Fix this by changing the 'set debuginfod enabled off' command to a no-op when gdb isn't built with libdebuginfod.
* gdb: Always suppress stringop-overread warning in debuginfod-support.cMark Wielaard2022-06-151-7/+4
| | | | | | | | | | | | | | Just like on s390x with g++ 11.2.1 and ppc64le with g++ 11.3.1 g++ 11 on hppa produces a spurious warning for stringop-overread in debuginfod_is_enabled for url_view. Just always suppress it on all arches. https://sourceware.org/bugzilla/show_bug.cgi?id=29198 gdb/ChangeLog: * debuginfod-support.c (debuginfod_is_enabled): Always use DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD.
* gdb: Workaround stringop-overread warning in debuginfod-support.c on powerpc64Mark Wielaard2022-05-121-5/+5
| | | | | | | | | | | Just like on s390x with g++ 11.2.1, ppc64le with g++ 11.3.1 produces a spurious warning for stringop-overread in debuginfod_is_enabled for url_view. Also suppress it on powerpc64. gdb/ChangeLog: * debuginfod-support.c (debuginfod_is_enabled): Use DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD on powerpc64.
* gdb: Workaround stringop-overread warning in debuginfod-support.c on s390xMark Wielaard2022-05-041-0/+11
| | | | | | | | | | | | | | | | For some reason g++ 11.2.1 on s390x produces a spurious warning for stringop-overread in debuginfod_is_enabled for url_view. Add a new DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD macro to suppress this warning. include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD): New macro. gdb/ChangeLog: * debuginfod-support.c (debuginfod_is_enabled): Use DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD on s390x.
* gdb/debuginfod: Whitespace-only URL should disable debuginfodAaron Merey2022-05-021-3/+4
| | | | | | | | | | | | Currently debuginfod is disabled when the string of server URLs is unset or set to be the empty string (via the $DEBUGINFOD_URLS environment variable or the 'set debuginfod urls' gdb command). Extend this functionality so that a whitespace-only URL also disables debuginfod. Modify a testcase to verify that a whitespace-only URL disables debuginfod.
* gdb/debuginfod: Prevent out_of_range exceptionAaron Merey2022-04-201-3/+4
| | | | | | | | | | | | | Trailing whitespace in the string of debuginfod URLs causes an out_of_range exception during the printing of URLs for the first use notice. To fix this, stop printing URLs when the substring to be printed consists only of whitespace. Also add first use notice testcases. Co-Authored-By: Pedro Alves <pedro@palves.net>
* gdb/debuginfod-support.c: Always display debuginfod errorsAaron Merey2022-04-011-3/+3
| | | | | | | | | | | Errors encountered when downloading files from debuginfod servers are not displayed if debuginfod verbosity is set to 0 (via 'set debuginfod verbose 0'). Tom recommended that these errors always be displayed, regardless of the verbosity setting [1]. Fix this. [1] https://sourceware.org/pipermail/gdb-patches/2022-March/186350.html
* Style URLs in GDB outputTom Tromey2022-03-311-4/+21
| | | | | | | | | | | | I noticed that GDB will display URLs in a few spots. This changes them to be styled. Originally I thought I'd introduce a new "url" style, but there aren't many places to use this, so I just reused filename styling instead. This patch also changes the debuginfod URL list to be printed one URL per line. I think this is probably a bit easier to read.
* Unify gdb printf functionsTom Tromey2022-03-291-33/+33
| | | | | | | | | Now that filtered and unfiltered output can be treated identically, we can unify the printf family of functions. This is done under the name "gdb_printf". Most of this patch was written by script.
* Remove download size from debuginfod progress messages if unavailableAaron Merey2022-03-241-18/+26
| | | | | | | | | | | | | | | | | | | Currently debuginfod progress update messages include the size of each download: Downloading 7.5 MB separate debug info for /lib/libxyz.so.0 This value originates from the Content-Length HTTP header of the transfer. However this header is not guaranteed to be present for each download. This can happen when debuginfod servers compress files on-the-fly at the time of transfer. In this case gdb wrongly prints "-0.00 MB" as the size. This patch removes download sizes from progress messages when they are not available. It also removes usage of the progress bar until a more thorough reworking of progress updating is implemented. [1] [1] https://sourceware.org/pipermail/gdb-patches/2022-February/185798.html
* PR gdb/27570: missing support for debuginfod in core_target::build_file_mappingsAaron Merey2022-03-211-0/+51
| | | | | | | | | | | | | | | | | | | | | Add debuginfod support to core_target::build_file_mappings and locate_exec_from_corefile_build_id to enable the downloading of missing executables and shared libraries referenced in core files. Also add debuginfod support to solib_map_sections so that previously downloaded shared libraries can be retrieved from the local debuginfod cache. When core file shared libraries are found locally, verify that their build-ids match the corresponding build-ids found in the core file. If there is a mismatch, attempt to query debuginfod for the correct build and print a warning if unsuccessful: warning: Build-id of /lib64/libc.so.6 does not match core file. Also disable debuginfod when gcore invokes gdb. Debuginfo is not needed for core file generation so debuginfod queries will slow down gcore unnecessarily.
* Simplify the ui-out progress APITom Tromey2022-03-101-1/+1
| | | | | | | | | I noticed that 'progress' is a method on ui-out, but it seems to me that it would be better if the only API were via the progress_meter class. This patch makes this change, changing progress to be a method on the meter itself.
* PR gdb/27876 - debuginfod-downloaded source files don't pass proper fullname ↵Aaron Merey2022-03-081-2/+3
| | | | | | | | | | | | | | | across mi / (gdb)info source Source files downloaded from debuginfod currently use their original DWARF filename as their "fullname". This causes a mismatch between the fullname and the actual location of the source file in the debuginfod client cache. MI consumers such as VSCode will fail to open debuginfod-downloaded source files due to this. Also 'info source' will fail to include the true paths of these files. To fix this, use the debuginfod cache path as the fullname for debuginfod- downloaded source files.
* Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker2022-01-011-1/+1
| | | | | | | | This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
* Use filtered output in show callbacksTom Tromey2021-12-291-4/+4
| | | | | | "show" command callbacks, like most ordinary gdb commands, should use filtered output. I found a few that did not, so this patch changes them to use the filtered form.
* Consistently Use ui_file parameter to show callbacksTom Tromey2021-12-291-2/+3
| | | | | | | | | I happened to notice that one "show" callback was printing to gdb_stdout rather than to the passed-in ui_file parameter. I went through all such callbacks and fixed them to consistently use the ui_file. Regression tested on x86-64 Fedora 34.
* [PR gdb/27026] CTRL-C is ignored when debug info is downloadedAaron Merey2021-11-291-0/+15
| | | | | | | | | | | | | During debuginfod downloads, ctrl-c should result in the download being cancelled and skipped. However in some cases, ctrl-c fails to get delivered to gdb during downloading. This can result in downloads being unskippable. Fix this by ensuring that target_terminal::ours is in effect for the duration of each download. Co-authored-by: Tom de Vries <tdevries@suse.de> https://sourceware.org/bugzilla/show_bug.cgi?id=27026#c3
* gdb: rework "set debuginfod" commandsSimon Marchi2021-11-151-188/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed here [1], do some re-work in the "set debuginfod commands". First, use "set debuginfod enabled on/off/ask" instead of "set debuginfod on/off/ask". This is more MI-friendly, and it gives an output that makes more sense in "info set", for example. Then, make the show commands not call "error" when debuginfod support is not compiled in. This makes the commands "show" and "show debuginfod" stop early, breaking gdb.base/default.exp: Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/default.exp ... FAIL: gdb.base/default.exp: info set FAIL: gdb.base/default.exp: show - Make the "debuginfod enabled" setting default to "off" when debuginfod support is not compiled in, and "ask" otherwise. - Make the setter of "debuginfod enabled" error out when debuginfod support is not compiled in, so that "debuginfod enabled" will always remain "off" in that case. - Make the setter of "debuginfod verbose" work in any case. I don't see the harm in letting the user change that setting, since the user will hit an error if they try to enable the use of debuginfod. - I would do the same for the "debuginfod urls" setter, but because this one needs to see the DEBUGINFOD_URLS_ENV_VAR macro, provided by libdebuginfod, I made that one error out as well if debuginfod support is not compiled it (otherwise, I would have left it like "debuginfod verbose". Alternatively, we could hard-code "DEBUGINFOD_URLS" in the code (in fact, it was prior to this patch, but I think it was an oversight, as other spots use DEBUGINFOD_URLS_ENV_VAR), or use a dummy string to store the setting, but I don't really see the value in that. Rename debuginfod_enable to debuginfod_enabled, just so it matches the setting name. [1] https://sourceware.org/pipermail/gdb-patches/2021-October/182937.html Change-Id: I45fdb2993f668226a5639228951362b7800f09d5 Co-Authored-By: Aaron Merey <amerey@redhat.com>
* Fix unittest.exp failure due to 'set debuginfod' additionTom Tromey2021-10-311-2/+2
| | | | | | | | | | | | The 'set debuginfod' change caused a regression in unittest.exp: Running selftest help_doc_invariants. help doc broken invariant: command 'info set debuginfod' help doc first line is not terminated with a '.' character help doc broken invariant: command 'set debuginfod' help doc first line is not terminated with a '.' character help doc broken invariant: command 'show debuginfod' help doc first line is not terminated with a '.' character Self test failed: self-test failed at ../../binutils-gdb/gdb/unittests/command-def-selftests.c:100 This patch fixes the problem. I'm checking it in.
* gdb: add set/show commands for managing debuginfodAaron Merey2021-10-291-8/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add 'set debuginfod' command. Accepts 'on', 'off' or 'ask' as an argument. 'on' enables debuginfod for the current session. 'off' disables debuginfod for the current session. 'ask' will prompt the user to either enable or disable debuginfod when the next query is about to be performed: This GDB supports auto-downloading debuginfo from the following URLs: <URL1> <URL2> ... Enable debuginfod for this session? (y or [n]) y Debuginfod has been enabled. To make this setting permanent, add 'set debuginfod on' to .gdbinit. For interactive sessions, 'ask' is the default. For non-interactive sessions, 'off' is the default. Add 'show debuginfod status' command. Displays whether debuginfod is set to 'on', 'off' or 'ask'. Add 'set/show debuginfod urls' commands. Accepts a string of space-separated debuginfod server URLs to be queried. The default value is copied from the DEBUGINFOD_URLS environment variable. Finally add 'set/show debuginfod verbose' commands to control whether debuginfod-related output is displayed. Verbose output is enabled by default. (gdb) run Starting program: /bin/sleep 5 Download failed: No route to host. Continuing without debug info for /lib64/libc.so.6. If GDB is not built with debuginfod then these commands will just display Support for debuginfod is not compiled into GDB.
* debuginfod-support.c: Use long-lived debuginfod_clientAaron Merey2021-05-071-12/+20
| | | | | | | | | | | | | | | | | Instead of initializing a new debuginfod_client for each query, store the first initialized client for the remainder of the GDB session and use it for every debuginfod query. In conjunction with upcoming changes to libdebuginfod, using one client for all queries will avoid latency caused by unneccesarily setting up TCP connections multiple times. Tested on Fedora 33 x86_64. gdb/ChangeLog: * debuginfod-support.c (debuginfod_init): Remove. (get_debuginfod_client): New function.
* Update copyright year range in all GDB filesJoel Brobecker2021-01-011-1/+1
| | | | | | | | | This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
* [gdb] Print progress for debuginfodMartin Liska2020-12-161-8/+19
| | | | | | | | | | | | | | | | | | | | | Prints progress like: Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20. Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5. Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1. Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so. [### ] Tested on x86_64-linux. ChangeLog: 2020-12-16 Martin Liska <mliska@suse.cz> Tom de Vries <tdevries@suse.de> * gdb/debuginfod-support.c (struct user_data): Remove has_printed field. Add meter field. (progressfn): Print progress using meter.
* [gdb] Don't return non-existing path in debuginfod_source_queryTom de Vries2020-11-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting env var DEBUGINFOD_URLS to " " and running the testsuite, we run into these regressions: ... FAIL: gdb.base/list-missing-source.exp: info source FAIL: gdb.base/source-dir.exp: info source before setting directory search list ... Setting var DEBUGINFOD_URLS to " " allows the debuginfod query function debuginfod_source_query to get past its early exit. The function debuginfod_source_query is documented as: "If the file is successfully retrieved, its path on the local machine is stored in DESTNAME". However, in case we get back -ENOENT from libdebuginfod, we still set DESTNAME: .... if (fd.get () < 0 && fd.get () != -ENOENT) printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"), safe_strerror (-fd.get ()), styled_string (file_name_style.style (), srcpath)); else *destname = make_unique_xstrdup (srcpath); return fd; ... Fix this by making debuginfod_source_query fit it's documentation and only setting DESTNAME when successfully retrieving a file. Likewise in debuginfod_debuginfo_query. gdb/ChangeLog: 2020-11-23 Tom de Vries <tdevries@suse.de> * debuginfod-support.c (debuginfod_source_query) (debuginfod_debuginfo_query): Only set DESTNAME if successful.
* [gdb] Improve early exits for env var in debuginfod-support.cTom de Vries2020-11-181-2/+4
| | | | | | | | | | | | | | | | | | | | | | There's an early exit in libdebuginfod's debuginfod_query_server, which checks both for: - getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL, and - (getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'. In debuginfod_source_query and debuginfod_debuginfo_query (which both end up calling debuginfod_query_server) there are also early exits checking the same env var, but those just check for NULL. Make the early exit tests in debuginfod-support.c match those in libdebuginfod. gdb/ChangeLog: 2020-11-18 Tom de Vries <tdevries@suse.de> * debuginfod-support.c (debuginfod_source_query) (debuginfod_debuginfo_query): Also do early exit if "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'".
* gdb: introduce debuginfod_client_up typeSimon Marchi2020-09-141-11/+24
| | | | | | | | | | | | | | | | Introduce and use a unique pointer specialization for the debuginfod_client type. The deleter calls debuginfod_end to free the client. gdb/ChangeLog: * debuginfod-support.c (debuginfod_client_deleter): New. (debuginfod_client_up): New. (debuginfod_init): Return debuginfod_client_up. (debuginfod_source_query): Adjust. (debuginfod_debuginfo_query): Adjust. Change-Id: Ie56441e123ab80b78e5311c824c162cd804f68c0
* gdb: use make_unique_xstrdup in debuginfod-support.cSimon Marchi2020-09-141-1/+1
| | | | | | | | | | | Use make_unique_xstrdup instead of reset + xstrdup. gdb/ChangeLog: * debuginfod-support.c (debuginfod_source_query): Use make_unique_xstrdup. Change-Id: Iee9524fea7630b4d6ee5c74e30c60fe222dc1d2c
* debuginfod-support.c: Replace globals with user_dataAaron Merey2020-08-131-16/+22
| | | | | | | | Store query information in user_data struct instead of global variables. gdb/ChangeLog: * debuginfod-support.c: Replace global variables with user_data.
* gdb: Move defs.h before any system header in debuginfod-support.cJon Turney2020-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | * defs.h includes config.h * config.h may define _GNU_SOURCE * if _GNU_SOURCE is defined, that must be before including any system header (see feature_test_macro(7)) This is necessary to ensure that a prototype for mkostemp() is brought into scope by <stdlib.h> when compiling filestuff.h, on platforms where _GNU_SOURCE isn't unconditionally defined for C++. In file included from ../../gdb/../gdbsupport/scoped_fd.h:24, from ../../gdb/debuginfod-support.c:22: ../../gdb/../gdbsupport/filestuff.h: In function ‘int gdb_mkostemp_cloexec(char*, int)’: ../../gdb/../gdbsupport/filestuff.h:59:10: error: ‘mkostemp’ was not declared in this scope; did you mean ‘mkstemp’? gdb/ChangeLog: 2020-02-29 Jon Turney <jon.turney@dronecode.org.uk> * debuginfod-support.c: Include defs.h first.
* Add debuginfod support to GDBAaron Merey2020-02-261-0/+155
debuginfod is a lightweight web service that indexes ELF/DWARF debugging resources by build-id and serves them over HTTP. This patch enables GDB to query debuginfod servers for separate debug files and source code when it is otherwise not able to find them. GDB can be built with debuginfod using the --with-debuginfod configure option. This requires that libdebuginfod be installed and found at configure time. debuginfod is packaged with elfutils, starting with version 0.178. For more information see https://sourceware.org/elfutils/. Tested on x86_64 Fedora 31. gdb/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * Makefile.in: Handle optional debuginfod support. * NEWS: Update. * README: Add --with-debuginfod summary. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Handle optional debuginfod support. * debuginfod-support.c: debuginfod helper functions. * debuginfod-support.h: Ditto. * doc/gdb.texinfo: Add --with-debuginfod to configure options summary. * dwarf2/read.c (dwarf2_get_dwz_file): Query debuginfod servers when a dwz file cannot be found. * elfread.c (elf_symfile_read): Query debuginfod servers when a debuginfo file cannot be found. * source.c (open_source_file): Query debuginfod servers when a source file cannot be found. * top.c (print_gdb_configuration): Include --{with,without}-debuginfod in the output. gdb/testsuite/ChangeLog: 2020-02-26 Aaron Merey <amerey@redhat.com> * gdb.debuginfod: New directory for debuginfod tests. * gdb.debuginfod/main.c: New test file. * gdb.debuginfod/fetch_src_and_symbols.exp: New tests.