summaryrefslogtreecommitdiff
path: root/gdb/main.c
Commit message (Collapse)AuthorAgeFilesLines
* gdb: move struct ui and related things to ui.{c,h}Simon Marchi2023-05-011-0/+1
| | | | | | | | | I'd like to move some things so they become methods on struct ui. But first, I think that struct ui and the related things are big enough to deserve their own file, instead of being scattered through top.{c,h} and event-top.c. Change-Id: I15594269ace61fd76ef80a7b58f51ff3ab6979bc
* Turn set_inferior_args_vector into method of inferiorTom Tromey2023-05-011-1/+2
| | | | | | | This patch turns set_inferior_args_vector into an overload of inferior::set_args. Regression tested on x86-64 Fedora 36.
* Handle gdb SIGTERM by throwing / catching gdb_exception_force_quitKevin Buettner2023-02-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a GDB process receives the SIGTERM signal, handle_sigterm() in event-top.c is called. The global variable 'sync_quit_force_run' is set by this signal handler. It does some other things too, but the setting of this global is the important bit for the SIGTERM part of this discussion. GDB will periodically check to see whether a Ctrl-C or SIGTERM has been received. This is performed via use of the QUIT macro in GDB's code. QUIT is defined to invoke maybe_quit(), which will be periodically called during any lengthy operation. This is supposed to ensure that the user won't have to wait too long for a Ctrl-C or SIGTERM to be acted upon. When a Ctrl-C / SIGINT is received, quit_handler() will decide whether to pass the SIGINT onto the inferior or to call quit() which causes gdb_exception_quit to be thrown. This exception (usually) propagates to the top level. Control is then returned to the top level event loop. At the moment, SIGTERM is handled very differently. Instead of throwing an exception, quit_force() is called. This does eventually cause GDB to exit(), but prior to that happening, the inferiors are killed or detached and other target related cleanup occurs. As shown in this discussion between Pedro Alves and myself... https://sourceware.org/pipermail/gdb-patches/2021-July/180802.html https://sourceware.org/pipermail/gdb-patches/2021-July/180902.html https://sourceware.org/pipermail/gdb-patches/2021-July/180903.html ...we found that it is possible for inferior_ptid and current_thread_ to get out of sync. When that happens, the "current_thread_ != nullptr" assertion in inferior_thread() can fail resulting in a GDB internal error. Pedro recommended that we "let the normal quit exception propagate all the way to the top level, and then have the top level call quit_force if sync_quit_force_run is set." However, after the v2 series for this patch set, we tweaked that idea by introducing a new exception for handling SIGTERM. This commit implements the obvious part of Pedro's suggestion: Instead of calling quit_force from quit(), throw_forced_quit() is now called instead. This causes the new exception 'gdb_exception_forced_quit' to be thrown. At the top level, I changed catch_command_errors() and captured_main() to catch gdb_exception_forced_quit and then call quit_force() from the catch block. I also changed start_event_loop() to also catch gdb_exception_forced_quit; while we could also call quit_force() from that catch block, it's sufficient to simply rethrow the exception since it'll be caught by the newly added code in captured_main(). Making these changes fixed the failure / regression that I was seeing for gdb.base/gdb-sigterm.exp when run on a machine with glibc-2.34. However, there are many other paths back to the top level which this test case does not test. I did an audit of all of the try / catch code in GDB in which calls in the try-block might (eventually) call QUIT. I found many cases where gdb_exception_quit and the new gdb_exception_forced_quit will be swallowed. (When using GDB, have you ever hit Ctrl-C and not have it do anything; if so, it could be due to a swallowed gdb_exception_quit in one of the cases I've identified.) The rest of the patches in this series deal with this concern. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 Tested-by: Tom de Vries <tdevries@suse.de> Approved-by: Pedro Alves <pedro@palves.net>
* 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.
* Remove MI version 1Tom Tromey2022-12-191-21/+1
| | | | | | | | MI version 1 is long since obsolete. Several years ago, I filed PR mi/23170 for this. I think it's finally time to remove this. Any users of MI 1 can and should upgrade to a newer version. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23170
* Remove a ui-related memory leakTom Tromey2022-08-311-0/+1
| | | | | | | | | | | gdb_setup_readline makes new streams and assigns to the various stream members of struct ui. However, these assignments cause the previous values to leak. As far as I can, this code is simply unnecessary and can be removed -- with the exception of the assignment to gdb_stdtarg, which is not initialized anywhere else.
* Remove the "for moment" commentsTom Tromey2022-08-311-2/+2
| | | | | | | | A few spots setting some gdb output stream variables have a "for moment" comment. These comments aren't useful and I think the moment has passed -- these are permanent now.
* Use std::string for interpreter_pTom Tromey2022-06-221-15/+9
| | | | | | | | | The global interpreter_p is a manually-managed 'char *'. This patch changes it to be a std::string instead, and removes some erroneous comments.
* gdbsupport: make gdb_abspath return an std::stringSimon Marchi2022-04-181-6/+1
| | | | | | | | | I'm trying to switch these functions to use std::string instead of char arrays, as much as possible. Some callers benefit from it (can avoid doing a copy of the result), while others suffer (have to make one more copy). Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
* Style URLs in GDB outputTom Tromey2022-03-311-2/+2
| | | | | | | | | | | | 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.
* Remove dbx modeTom Tromey2022-03-311-8/+0
| | | | | This patch removes gdb's dbx mode. Regression tested on x86-64 Fedora 34.
* Remove unnecessary calls to wrap_here and gdb_flushTom Tromey2022-03-291-4/+0
| | | | | | | | | | | | | | | | Various spots in gdb currently know about the wrap buffer, and so are careful to call wrap_here to be certain that all output has been flushed. Now that the pager is just an ordinary stream, this isn't needed, and a simple call to gdb_flush is enough. Similarly, there are places where gdb prints to gdb_stderr, but first flushes gdb_stdout. stderr_file already flushes gdb_stdout, so these aren't needed.
* Unify gdb printf functionsTom Tromey2022-03-291-20/+20
| | | | | | | | | 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.
* Unify gdb puts functionsTom Tromey2022-03-291-10/+10
| | | | | | | | | Now that filtered and unfiltered output can be treated identically, we can unify the puts family of functions. This is done under the name "gdb_puts". Most of this patch was written by script.
* Deprecate dbx modeTom Tromey2022-03-071-0/+3
| | | | | | | | | GDB has a dbx emulation mode that adds a few aliases and helper commands. This mode is barely documented and is very superficial besides. I suspect it is rarely used, and I would like to propose deprecating it for GDB 12, and then removing it in GDB 13.
* Always call the wrap_here methodTom Tromey2022-01-261-4/+4
| | | | | | | | This changes all existing calls to wrap_here to call the method on the appropriate ui_file instead. The choice of ui_file is determined by context.
* Convert wrap_here to use integer parameterTom Tromey2022-01-261-4/+4
| | | | | | | | | I think it only really makes sense to call wrap_here with an argument consisting solely of spaces. Given this, it seemed better to me that the argument be an int, rather than a string. This patch is the result. Much of it was written by a script.
* 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.
* gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptrAndrew Burgess2021-11-161-1/+1
| | | | | | | | The motivation is to reduce the number of places where unmanaged pointers are returned from allocation type routines. All of the callers are updated. There should be no user visible changes after this commit.
* gdb: make string-like set show commands use std::string variableSimon Marchi2021-10-031-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String-like settings (var_string, var_filename, var_optional_filename, var_string_noescape) currently take a pointer to a `char *` storage variable (typically global) that holds the setting's value. I'd like to "mordernize" this by changing them to use an std::string for storage. An obvious reason is that string operations on std::string are often easier to write than with C strings. And they avoid having to do any manual memory management. Another interesting reason is that, with `char *`, nullptr and an empty string often both have the same meaning of "no value". String settings are initially nullptr (unless initialized otherwise). But when doing "set foo" (where `foo` is a string setting), the setting now points to an empty string. For example, solib_search_path is nullptr at startup, but points to an empty string after doing "set solib-search-path". This leads to some code that needs to check for both to check for "no value". Or some code that converts back and forth between NULL and "" when getting or setting the value. I find this very error-prone, because it is very easy to forget one or the other. With std::string, we at least know that the variable is not "NULL". There is only one way of representing an empty string setting, that is with an empty string. I was wondering whether the distinction between NULL and "" would be important for some setting, but it doesn't seem so. If that ever happens, it would be more C++-y and self-descriptive to use optional<string> anyway. Actually, there's one spot where this distinction mattered, it's in init_history, for the test gdb.base/gdbinit-history.exp. init_history sets the history filename to the default ".gdb_history" if it sees that the setting was never set - if history_filename is nullptr. If history_filename is an empty string, it means the setting was explicitly cleared, so it leaves it as-is. With the change to std::string, this distinction doesn't exist anymore. This can be fixed by moving the code that chooses a good default value for history_filename to _initialize_top. This is ran before -ex commands are processed, so an -ex command can then clear that value if needed (what gdb.base/gdbinit-history.exp tests). Another small improvement, in my opinion is that we can now easily give string parameters initial values, by simply initializing the global variables, instead of xstrdup-ing it in the _initialize function. In Python and Guile, when registering a string-like parameter, we allocate (with new) an std::string that is owned by the param_smob (in Guile) and the parmpy_object (in Python) objects. This patch started by changing all relevant add_setshow_* commands to take an `std::string *` instead of a `char **` and fixing everything that failed to build. That includes of course all string setting variable and their uses. string_option_def now uses an std::string also, because there's a connection between options and settings (see add_setshow_cmds_for_options). The add_path function in source.c is really complex and twisted, I'd rather not try to change it to work on an std::string right now. Instead, I added an overload that copies the std:string to a `char *` and back. This means more copying, but this is not used in a hot path at all, so I think it is acceptable. Change-Id: I92c50a1bdd8307141cdbacb388248e4e4fc08c93 Co-authored-by: Lancelot SIX <lsix@lancelotsix.com>
* Fix option type comments for CMDARG_EARLYINIT_FILE and CMDARG_EARLYINIT_COMMAND.Philippe Waroquiers2021-05-221-3/+3
| | | | | | | | | The comments in the enum cmdarg_kind were using -sx and -sex instead of -eix and -eiex. (Note that gdb --help does not speak about these options). (pushed as obvious)
* gdb: extension languages finish_initialization to initializeAndrew Burgess2021-04-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that both Python and Guile are fully initialized from their respective finish_initialization methods, the "finish" in the method name doesn't really make sense; initialization starts _and_ finishes with that method. As such, this commit renames finish_initialization to just initialize. There should be no user visible changes after this commit. gdb/ChangeLog: * extension-priv.h (struct extension_language_ops): Rename 'finish_initialization' to 'initialize'. * extension.c (finish_ext_lang_initialization): Renamed to... (ext_lang_initialization): ...this, update comment, and updated the calls to reflect the change in struct extension_language_ops. * extension.h (finish_ext_lang_initialization): Renamed to... (ext_lang_initialization): ...this. * guile/guile.c (gdbscm_finish_initialization): Renamed to... (gdbscm_initialize): ...this, update comment at definition. (guile_extension_ops): Update. * main.c (captured_main_1): Update call to finish_ext_lang_initialization. * python/python.c (gdbpy_finish_initialization): Rename to... (gdbpy_initialize): ...this, update comment at definition, and update call to do_finish_initialization. (python_extension_ops): Update. (do_finish_initialization): Rename to... (do_initialize): ...this, and update comment.
* gdb: initialise extension languages after processing early startup filesAndrew Burgess2021-04-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Now (thanks to the last few commits) all extension languages are fully initialised in their finish_initialization method, this commit delays the call to this method until after the early initialization files have been processed. Right now there's no benefit from doing this, but in a later commit I plan to add new options for Python that will control how Python is initialized. With this commit in place, my next commits will allow the user to add options to their early initialization file and alter how Python starts up. There should be no user visible changes after this commit. gdb/ChangeLog: * main.c (captured_main_1): Add a call to finish_ext_lang_initialization. * top.c (gdb_init): Remove call to finish_ext_lang_initialization.
* gdb: remove unused argument from gdb_initAndrew Burgess2021-04-281-1/+1
| | | | | | | | | | | | | The argument to gdb_init is not used, remove it. There should be no user visible changes after this commit. gdb/ChangeLog: * main.c (captured_main_1): Don't pass argument to gdb_init. * top.c (gdb_init): Remove unused argument, and add header comment. * top.h (gdb_init): Remove argument.
* gdb: add "set startup-quietly" commandTom Tromey2021-04-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | This adds a new command to change GDB to behave as though "-quiet" were always given. This new command can be added to the gdbearlyinit file to affect future GDB sessions. gdb/ChangeLog: * NEWS: Add entry. * main.c (captured_main_1): Call check_quiet_mode. * top.c (startup_quiet): New global. (check_quiet_mode): New function. (show_startup_quiet): New function. (init_main): Register new command. * top.h (check_quiet_mode): Declare. gdb/doc/ChangeLog: * gdb.texinfo (Mode Options): Mention "set startup-quietly". gdb/testsuite/ChangeLog: * gdb.base/startup-file.exp: Add more tests.
* gdb: process early initialization files and command line optionsAndrew Burgess2021-04-151-1/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the ability to process commands at a new phase during GDB's startup. This phase is earlier than the current initialisation file processing, before GDB has produced any output. The number of commands that can be processed at this early stage will be limited, and it is expected that the only commands that would be processed at this stage will relate to some of the fundamentals of how GDB starts up. Currently the only commands that it makes sense to add to this early initialization file are those like 'set style version ....' as the version string is displayed during startup before the standard initialization files are parsed. As such this commit fully resolved bug cli/25956. This commit adds a mechanism to execute these early initialization files from a users HOME directory, as well as some corresponding command line flags for GDB. The early initialization files that GDB will currently check for are ~/.config/gdb/gdbearlyinit (on Linux like systems) or ~/.gdbearlyinit if the former is not found. The output of 'gdb --help' has been extended to include a list of the early initialization files being processed. gdb/ChangeLog: PR cli/25956 * NEWS: Mention new early init files and command line options. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Define GDBEARLYINIT. * main.c (get_earlyinit_files): New function. (enum cmdarg_kind): Add CMDARG_EARLYINIT_FILE and CMDARG_EARLYINIT_COMMAND. (captured_main_1): Add support for new command line flags, and for processing startup files. (print_gdb_help): Include startup files in the output. gdb/doc/ChangeLog: PR cli/25956 * gdb.texinfo (File Options): Mention new command line options. (Startup): Discuss when early init files are processed. (Initialization Files): Add description of early init files. (Output Styling): Update description of 'version' style. (gdb man): Mention early init files. gdb/testsuite/ChangeLog: PR cli/25956 * gdb.base/early-init-file.c: New file. * gdb.base/early-init-file.exp: New file. * lib/gdb-utils.exp (style): Handle style 'none'.
* gdb: refactor the initialization file lookup codeAndrew Burgess2021-04-151-63/+124
| | | | | | | | | | | | | | | | In preparation for the next patch, which adds startup files, this commit refactors the code for looking up the initialization files so that the code can be more easily reused in the next commit. There should be no user visible changes after this commit. gdb/ChangeLog: * main.c (relocate_gdbinit_path_maybe_in_datadir): Rename to... (relocate_file_path_maybe_in_datadir): ...this. (class gdb_initfile_finder): New class. (get_init_files): Now uses gdb_initfile_finder. (print_gdb_help): Print 'None found' when there are no init files.
* gdb: add missing full stops in --helpMarco Barisione2021-02-181-2/+2
| | | | | | | | | | | | | The descriptions for most options printed by gdb --help end with a full stop but, before this patch, not the ones for --args and --interpreter. This makes the line containing --args a bit longer but still not longer than the previously longest line, that is the one for the --tty option. gdb/ChangeLog: * main.c (print_gdb_help): Add full stops at the end of the descriptions for the --args and --interpreter options.
* gdb: convert auto-load to new-style debug macrosSimon Marchi2021-01-211-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Function file_is_auto_load_safe was taking a format string and varargs just to output a debug print. This is probably because that function is used in linux-thread-db.c and main.c, but debug_auto_load is static in auto-load.c. I simplified that, making debug_auto_load visible outside of auto-load.c, and making the callers of file_is_auto_load_safe output the debug print themselves. This file uses _() for internationalization of the debug messages. This is not necessary, as these are mostly messages for GDB developers, and it's not used in other files anyway. So I removed them. The rest is pretty much standard. gdb/ChangeLog: * auto-load.h (debug_auto_load): Move here. (auto_load_debug_printf): New. * auto-load.c: Use auto_load_debug_printf. (debug_auto_load): Move to header. * linux-thread-db.c (try_thread_db_load): Use auto_load_debug_printf. * main.c (captured_main_1): Likewise. Change-Id: I468dc2a1d24b7dbf171f55181a11abbfafe70ba1
* gdb: move baud_rate and serial_parity declarations to serial.hSimon Marchi2021-01-121-0/+1
| | | | | | | | | | | | | | They are currently in target.h, it would make more sense to have them in serial.h, since they are defined in serial.c. gdb/ChangeLog: * target.h (baud_rate, serial_parity): Move declarations... * serial.h: ... here. * main.c: Include serial.h. * serial.c (baud_rate, serial_parity): Update doc. Change-Id: Idc983c154c80ccc29b07ce68df3483cefe03fb71
* 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/main: execute breakpoint commands for '-iex' and '-ex' commandsTankut Baris Aktemur2020-12-071-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suppose we have the script file below: break main commands print 123 end run If started with this script file, GDB executes the breakpoint command: $ gdb -q -x myscript --args ./test Reading symbols from ./test... Breakpoint 1 at 0x114e: file test.c, line 2. Breakpoint 1, main () at test.c:2 2 return 0; $1 = 123 (gdb) However, if we remove the "run" line from the script and pass it with the '-ex' option instead, the command is not executed: $ gdb -q -x myscript_no_run --args ./test Reading symbols from ./test... Breakpoint 1 at 0x114e: file test.c, line 2. Starting program: /path/to/test Breakpoint 1, main () at test.c:2 2 return 0; (gdb) If the user enters a command at this point, the breakpoint command is executed, yielding weird output: $ gdb -q -x myscript_no_run --args ./test Reading symbols from ./test... Breakpoint 1 at 0x114e: file test.c, line 2. Starting program: /path/to/test Breakpoint 1, main () at test.c:2 2 return 0; (gdb) print "a" $1 = "a" $2 = 123 When consuming script files, GDB runs bp actions after executing a command. See `command_handler` in event-top.c: if (c[0] != '#') { execute_command (command, ui->instream == ui->stdin_stream); /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); } However, for '-ex' commands, `bpstat_do_actions` is not invoked. Hence, the misaligned output explained above occurs. To fix the problem, add a call to `bpstat_do_actions` after executing a command. gdb/ChangeLog: 2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * main.c (catch_command_errors): Add a flag parameter; invoke `bpstat_do_actions` if the flag is set. (execute_cmdargs): Update a call to `catch_command_errors`. gdb/testsuite/ChangeLog: 2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/bp-cmds-run-with-ex.c: New file. * gdb.base/bp-cmds-run-with-ex.exp: New file. * gdb.base/bp-cmds-run-with-ex.gdb: New file. * gdb.gdb/python-interrupts.exp: Update the call to 'catch_command_errors' with the new argument. * gdb.gdb/python-selftest.exp: Ditto.
* gdb: new function to wrap up executing command line scripts/commandsAndrew Burgess2020-11-021-32/+22
| | | | | | | | | | | | Small refactor to wrap up executing the scripts and commands passed using the -x, -ex, -ix, -iex command line flags. There should be no user visible changes after this commit. gdb/ChangeLog: * main.c (execute_cmdargs): New function. (captured_main_1): Make use of execute_cmdargs.
* gdb: use get_standard_config_dir when looking for .gdbinitAndrew Burgess2020-11-021-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit effectively changes the default location of the .gdbinit file, while maintaining backward compatibility. For non Apple hosts the .gdbinit file will now be looked for in the following locations: $XDG_CONFIG_HOME/gdb/gdbinit $HOME/.config/gdb/gdbinit $HOME/.gdbinit On Apple hosts the search order is instead: $HOME/Library/Preferences/gdb/gdbinit $HOME/.gdbinit I've performed an extensive rewrite of the documentation, moving all information about initialization files and where to find them into a new @node, text from other areas has been moved into this one location, and other areas cross-reference to this new @node as much as possible. gdb/ChangeLog: * NEWS: Mention changes to config file search path. * main.c gdb/doc/ChangeLog: * gdb.texinfo (Mode Options): Descriptions of initialization files has been moved to 'Initialization Files'. (Startup): Likewise. (Initialization Files): New node. (gdb man): Update to mention alternative file paths. (gdbinit man): Likewise.
* gdb, gdbserver, gdbsupport: fix leading space vs tabs issuesSimon Marchi2020-11-021-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many spots incorrectly use only spaces for indentation (for example, there are a lot of spots in ada-lang.c). I've always found it awkward when I needed to edit one of these spots: do I keep the original wrong indentation, or do I fix it? What if the lines around it are also wrong, do I fix them too? I probably don't want to fix them in the same patch, to avoid adding noise to my patch. So I propose to fix as much as possible once and for all (hopefully). One typical counter argument for this is that it makes code archeology more difficult, because git-blame will show this commit as the last change for these lines. My counter counter argument is: when git-blaming, you often need to do "blame the file at the parent commit" anyway, to go past some other refactor that touched the line you are interested in, but is not the change you are looking for. So you already need a somewhat efficient way to do this. Using some interactive tool, rather than plain git-blame, makes this trivial. For example, I use "tig blame <file>", where going back past the commit that changed the currently selected line is one keystroke. It looks like Magit in Emacs does it too (though I've never used it). Web viewers of Github and Gitlab do it too. My point is that it won't really make archeology more difficult. The other typical counter argument is that it will cause conflicts with existing patches. That's true... but it's a one time cost, and those are not conflicts that are difficult to resolve. I have also tried "git rebase --ignore-whitespace", it seems to work well. Although that will re-introduce the faulty indentation, so one needs to take care of fixing the indentation in the patch after that (which is easy). gdb/ChangeLog: * aarch64-linux-tdep.c: Fix indentation. * aarch64-ravenscar-thread.c: Fix indentation. * aarch64-tdep.c: Fix indentation. * aarch64-tdep.h: Fix indentation. * ada-lang.c: Fix indentation. * ada-lang.h: Fix indentation. * ada-tasks.c: Fix indentation. * ada-typeprint.c: Fix indentation. * ada-valprint.c: Fix indentation. * ada-varobj.c: Fix indentation. * addrmap.c: Fix indentation. * addrmap.h: Fix indentation. * agent.c: Fix indentation. * aix-thread.c: Fix indentation. * alpha-bsd-nat.c: Fix indentation. * alpha-linux-tdep.c: Fix indentation. * alpha-mdebug-tdep.c: Fix indentation. * alpha-nbsd-tdep.c: Fix indentation. * alpha-obsd-tdep.c: Fix indentation. * alpha-tdep.c: Fix indentation. * amd64-bsd-nat.c: Fix indentation. * amd64-darwin-tdep.c: Fix indentation. * amd64-linux-nat.c: Fix indentation. * amd64-linux-tdep.c: Fix indentation. * amd64-nat.c: Fix indentation. * amd64-obsd-tdep.c: Fix indentation. * amd64-tdep.c: Fix indentation. * amd64-windows-tdep.c: Fix indentation. * annotate.c: Fix indentation. * arc-tdep.c: Fix indentation. * arch-utils.c: Fix indentation. * arch/arm-get-next-pcs.c: Fix indentation. * arch/arm.c: Fix indentation. * arm-linux-nat.c: Fix indentation. * arm-linux-tdep.c: Fix indentation. * arm-nbsd-tdep.c: Fix indentation. * arm-pikeos-tdep.c: Fix indentation. * arm-tdep.c: Fix indentation. * arm-tdep.h: Fix indentation. * arm-wince-tdep.c: Fix indentation. * auto-load.c: Fix indentation. * auxv.c: Fix indentation. * avr-tdep.c: Fix indentation. * ax-gdb.c: Fix indentation. * ax-general.c: Fix indentation. * bfin-linux-tdep.c: Fix indentation. * block.c: Fix indentation. * block.h: Fix indentation. * blockframe.c: Fix indentation. * bpf-tdep.c: Fix indentation. * break-catch-sig.c: Fix indentation. * break-catch-syscall.c: Fix indentation. * break-catch-throw.c: Fix indentation. * breakpoint.c: Fix indentation. * breakpoint.h: Fix indentation. * bsd-uthread.c: Fix indentation. * btrace.c: Fix indentation. * build-id.c: Fix indentation. * buildsym-legacy.h: Fix indentation. * buildsym.c: Fix indentation. * c-typeprint.c: Fix indentation. * c-valprint.c: Fix indentation. * c-varobj.c: Fix indentation. * charset.c: Fix indentation. * cli/cli-cmds.c: Fix indentation. * cli/cli-decode.c: Fix indentation. * cli/cli-decode.h: Fix indentation. * cli/cli-script.c: Fix indentation. * cli/cli-setshow.c: Fix indentation. * coff-pe-read.c: Fix indentation. * coffread.c: Fix indentation. * compile/compile-cplus-types.c: Fix indentation. * compile/compile-object-load.c: Fix indentation. * compile/compile-object-run.c: Fix indentation. * completer.c: Fix indentation. * corefile.c: Fix indentation. * corelow.c: Fix indentation. * cp-abi.h: Fix indentation. * cp-namespace.c: Fix indentation. * cp-support.c: Fix indentation. * cp-valprint.c: Fix indentation. * cris-linux-tdep.c: Fix indentation. * cris-tdep.c: Fix indentation. * darwin-nat-info.c: Fix indentation. * darwin-nat.c: Fix indentation. * darwin-nat.h: Fix indentation. * dbxread.c: Fix indentation. * dcache.c: Fix indentation. * disasm.c: Fix indentation. * dtrace-probe.c: Fix indentation. * dwarf2/abbrev.c: Fix indentation. * dwarf2/attribute.c: Fix indentation. * dwarf2/expr.c: Fix indentation. * dwarf2/frame.c: Fix indentation. * dwarf2/index-cache.c: Fix indentation. * dwarf2/index-write.c: Fix indentation. * dwarf2/line-header.c: Fix indentation. * dwarf2/loc.c: Fix indentation. * dwarf2/macro.c: Fix indentation. * dwarf2/read.c: Fix indentation. * dwarf2/read.h: Fix indentation. * elfread.c: Fix indentation. * eval.c: Fix indentation. * event-top.c: Fix indentation. * exec.c: Fix indentation. * exec.h: Fix indentation. * expprint.c: Fix indentation. * f-lang.c: Fix indentation. * f-typeprint.c: Fix indentation. * f-valprint.c: Fix indentation. * fbsd-nat.c: Fix indentation. * fbsd-tdep.c: Fix indentation. * findvar.c: Fix indentation. * fork-child.c: Fix indentation. * frame-unwind.c: Fix indentation. * frame-unwind.h: Fix indentation. * frame.c: Fix indentation. * frv-linux-tdep.c: Fix indentation. * frv-tdep.c: Fix indentation. * frv-tdep.h: Fix indentation. * ft32-tdep.c: Fix indentation. * gcore.c: Fix indentation. * gdb_bfd.c: Fix indentation. * gdbarch.sh: Fix indentation. * gdbarch.c: Re-generate * gdbarch.h: Re-generate. * gdbcore.h: Fix indentation. * gdbthread.h: Fix indentation. * gdbtypes.c: Fix indentation. * gdbtypes.h: Fix indentation. * glibc-tdep.c: Fix indentation. * gnu-nat.c: Fix indentation. * gnu-nat.h: Fix indentation. * gnu-v2-abi.c: Fix indentation. * gnu-v3-abi.c: Fix indentation. * go32-nat.c: Fix indentation. * guile/guile-internal.h: Fix indentation. * guile/scm-cmd.c: Fix indentation. * guile/scm-frame.c: Fix indentation. * guile/scm-iterator.c: Fix indentation. * guile/scm-math.c: Fix indentation. * guile/scm-ports.c: Fix indentation. * guile/scm-pretty-print.c: Fix indentation. * guile/scm-value.c: Fix indentation. * h8300-tdep.c: Fix indentation. * hppa-linux-nat.c: Fix indentation. * hppa-linux-tdep.c: Fix indentation. * hppa-nbsd-nat.c: Fix indentation. * hppa-nbsd-tdep.c: Fix indentation. * hppa-obsd-nat.c: Fix indentation. * hppa-tdep.c: Fix indentation. * hppa-tdep.h: Fix indentation. * i386-bsd-nat.c: Fix indentation. * i386-darwin-nat.c: Fix indentation. * i386-darwin-tdep.c: Fix indentation. * i386-dicos-tdep.c: Fix indentation. * i386-gnu-nat.c: Fix indentation. * i386-linux-nat.c: Fix indentation. * i386-linux-tdep.c: Fix indentation. * i386-nto-tdep.c: Fix indentation. * i386-obsd-tdep.c: Fix indentation. * i386-sol2-nat.c: Fix indentation. * i386-tdep.c: Fix indentation. * i386-tdep.h: Fix indentation. * i386-windows-tdep.c: Fix indentation. * i387-tdep.c: Fix indentation. * i387-tdep.h: Fix indentation. * ia64-libunwind-tdep.c: Fix indentation. * ia64-libunwind-tdep.h: Fix indentation. * ia64-linux-nat.c: Fix indentation. * ia64-linux-tdep.c: Fix indentation. * ia64-tdep.c: Fix indentation. * ia64-tdep.h: Fix indentation. * ia64-vms-tdep.c: Fix indentation. * infcall.c: Fix indentation. * infcmd.c: Fix indentation. * inferior.c: Fix indentation. * infrun.c: Fix indentation. * iq2000-tdep.c: Fix indentation. * language.c: Fix indentation. * linespec.c: Fix indentation. * linux-fork.c: Fix indentation. * linux-nat.c: Fix indentation. * linux-tdep.c: Fix indentation. * linux-thread-db.c: Fix indentation. * lm32-tdep.c: Fix indentation. * m2-lang.c: Fix indentation. * m2-typeprint.c: Fix indentation. * m2-valprint.c: Fix indentation. * m32c-tdep.c: Fix indentation. * m32r-linux-tdep.c: Fix indentation. * m32r-tdep.c: Fix indentation. * m68hc11-tdep.c: Fix indentation. * m68k-bsd-nat.c: Fix indentation. * m68k-linux-nat.c: Fix indentation. * m68k-linux-tdep.c: Fix indentation. * m68k-tdep.c: Fix indentation. * machoread.c: Fix indentation. * macrocmd.c: Fix indentation. * macroexp.c: Fix indentation. * macroscope.c: Fix indentation. * macrotab.c: Fix indentation. * macrotab.h: Fix indentation. * main.c: Fix indentation. * mdebugread.c: Fix indentation. * mep-tdep.c: Fix indentation. * mi/mi-cmd-catch.c: Fix indentation. * mi/mi-cmd-disas.c: Fix indentation. * mi/mi-cmd-env.c: Fix indentation. * mi/mi-cmd-stack.c: Fix indentation. * mi/mi-cmd-var.c: Fix indentation. * mi/mi-cmds.c: Fix indentation. * mi/mi-main.c: Fix indentation. * mi/mi-parse.c: Fix indentation. * microblaze-tdep.c: Fix indentation. * minidebug.c: Fix indentation. * minsyms.c: Fix indentation. * mips-linux-nat.c: Fix indentation. * mips-linux-tdep.c: Fix indentation. * mips-nbsd-tdep.c: Fix indentation. * mips-tdep.c: Fix indentation. * mn10300-linux-tdep.c: Fix indentation. * mn10300-tdep.c: Fix indentation. * moxie-tdep.c: Fix indentation. * msp430-tdep.c: Fix indentation. * namespace.h: Fix indentation. * nat/fork-inferior.c: Fix indentation. * nat/gdb_ptrace.h: Fix indentation. * nat/linux-namespaces.c: Fix indentation. * nat/linux-osdata.c: Fix indentation. * nat/netbsd-nat.c: Fix indentation. * nat/x86-dregs.c: Fix indentation. * nbsd-nat.c: Fix indentation. * nbsd-tdep.c: Fix indentation. * nios2-linux-tdep.c: Fix indentation. * nios2-tdep.c: Fix indentation. * nto-procfs.c: Fix indentation. * nto-tdep.c: Fix indentation. * objfiles.c: Fix indentation. * objfiles.h: Fix indentation. * opencl-lang.c: Fix indentation. * or1k-tdep.c: Fix indentation. * osabi.c: Fix indentation. * osabi.h: Fix indentation. * osdata.c: Fix indentation. * p-lang.c: Fix indentation. * p-typeprint.c: Fix indentation. * p-valprint.c: Fix indentation. * parse.c: Fix indentation. * ppc-linux-nat.c: Fix indentation. * ppc-linux-tdep.c: Fix indentation. * ppc-nbsd-nat.c: Fix indentation. * ppc-nbsd-tdep.c: Fix indentation. * ppc-obsd-nat.c: Fix indentation. * ppc-ravenscar-thread.c: Fix indentation. * ppc-sysv-tdep.c: Fix indentation. * ppc64-tdep.c: Fix indentation. * printcmd.c: Fix indentation. * proc-api.c: Fix indentation. * producer.c: Fix indentation. * producer.h: Fix indentation. * prologue-value.c: Fix indentation. * prologue-value.h: Fix indentation. * psymtab.c: Fix indentation. * python/py-arch.c: Fix indentation. * python/py-bpevent.c: Fix indentation. * python/py-event.c: Fix indentation. * python/py-event.h: Fix indentation. * python/py-finishbreakpoint.c: Fix indentation. * python/py-frame.c: Fix indentation. * python/py-framefilter.c: Fix indentation. * python/py-inferior.c: Fix indentation. * python/py-infthread.c: Fix indentation. * python/py-objfile.c: Fix indentation. * python/py-prettyprint.c: Fix indentation. * python/py-registers.c: Fix indentation. * python/py-signalevent.c: Fix indentation. * python/py-stopevent.c: Fix indentation. * python/py-stopevent.h: Fix indentation. * python/py-threadevent.c: Fix indentation. * python/py-tui.c: Fix indentation. * python/py-unwind.c: Fix indentation. * python/py-value.c: Fix indentation. * python/py-xmethods.c: Fix indentation. * python/python-internal.h: Fix indentation. * python/python.c: Fix indentation. * ravenscar-thread.c: Fix indentation. * record-btrace.c: Fix indentation. * record-full.c: Fix indentation. * record.c: Fix indentation. * reggroups.c: Fix indentation. * regset.h: Fix indentation. * remote-fileio.c: Fix indentation. * remote.c: Fix indentation. * reverse.c: Fix indentation. * riscv-linux-tdep.c: Fix indentation. * riscv-ravenscar-thread.c: Fix indentation. * riscv-tdep.c: Fix indentation. * rl78-tdep.c: Fix indentation. * rs6000-aix-tdep.c: Fix indentation. * rs6000-lynx178-tdep.c: Fix indentation. * rs6000-nat.c: Fix indentation. * rs6000-tdep.c: Fix indentation. * rust-lang.c: Fix indentation. * rx-tdep.c: Fix indentation. * s12z-tdep.c: Fix indentation. * s390-linux-tdep.c: Fix indentation. * score-tdep.c: Fix indentation. * ser-base.c: Fix indentation. * ser-mingw.c: Fix indentation. * ser-uds.c: Fix indentation. * ser-unix.c: Fix indentation. * serial.c: Fix indentation. * sh-linux-tdep.c: Fix indentation. * sh-nbsd-tdep.c: Fix indentation. * sh-tdep.c: Fix indentation. * skip.c: Fix indentation. * sol-thread.c: Fix indentation. * solib-aix.c: Fix indentation. * solib-darwin.c: Fix indentation. * solib-frv.c: Fix indentation. * solib-svr4.c: Fix indentation. * solib.c: Fix indentation. * source.c: Fix indentation. * sparc-linux-tdep.c: Fix indentation. * sparc-nbsd-tdep.c: Fix indentation. * sparc-obsd-tdep.c: Fix indentation. * sparc-ravenscar-thread.c: Fix indentation. * sparc-tdep.c: Fix indentation. * sparc64-linux-tdep.c: Fix indentation. * sparc64-nbsd-tdep.c: Fix indentation. * sparc64-obsd-tdep.c: Fix indentation. * sparc64-tdep.c: Fix indentation. * stabsread.c: Fix indentation. * stack.c: Fix indentation. * stap-probe.c: Fix indentation. * stubs/ia64vms-stub.c: Fix indentation. * stubs/m32r-stub.c: Fix indentation. * stubs/m68k-stub.c: Fix indentation. * stubs/sh-stub.c: Fix indentation. * stubs/sparc-stub.c: Fix indentation. * symfile-mem.c: Fix indentation. * symfile.c: Fix indentation. * symfile.h: Fix indentation. * symmisc.c: Fix indentation. * symtab.c: Fix indentation. * symtab.h: Fix indentation. * target-float.c: Fix indentation. * target.c: Fix indentation. * target.h: Fix indentation. * tic6x-tdep.c: Fix indentation. * tilegx-linux-tdep.c: Fix indentation. * tilegx-tdep.c: Fix indentation. * top.c: Fix indentation. * tracefile-tfile.c: Fix indentation. * tracepoint.c: Fix indentation. * tui/tui-disasm.c: Fix indentation. * tui/tui-io.c: Fix indentation. * tui/tui-regs.c: Fix indentation. * tui/tui-stack.c: Fix indentation. * tui/tui-win.c: Fix indentation. * tui/tui-winsource.c: Fix indentation. * tui/tui.c: Fix indentation. * typeprint.c: Fix indentation. * ui-out.h: Fix indentation. * unittests/copy_bitwise-selftests.c: Fix indentation. * unittests/memory-map-selftests.c: Fix indentation. * utils.c: Fix indentation. * v850-tdep.c: Fix indentation. * valarith.c: Fix indentation. * valops.c: Fix indentation. * valprint.c: Fix indentation. * valprint.h: Fix indentation. * value.c: Fix indentation. * value.h: Fix indentation. * varobj.c: Fix indentation. * vax-tdep.c: Fix indentation. * windows-nat.c: Fix indentation. * windows-tdep.c: Fix indentation. * xcoffread.c: Fix indentation. * xml-syscall.c: Fix indentation. * xml-tdesc.c: Fix indentation. * xstormy16-tdep.c: Fix indentation. * xtensa-config.c: Fix indentation. * xtensa-linux-nat.c: Fix indentation. * xtensa-linux-tdep.c: Fix indentation. * xtensa-tdep.c: Fix indentation. gdbserver/ChangeLog: * ax.cc: Fix indentation. * dll.cc: Fix indentation. * inferiors.h: Fix indentation. * linux-low.cc: Fix indentation. * linux-nios2-low.cc: Fix indentation. * linux-ppc-ipa.cc: Fix indentation. * linux-ppc-low.cc: Fix indentation. * linux-x86-low.cc: Fix indentation. * linux-xtensa-low.cc: Fix indentation. * regcache.cc: Fix indentation. * server.cc: Fix indentation. * tracepoint.cc: Fix indentation. gdbsupport/ChangeLog: * common-exceptions.h: Fix indentation. * event-loop.cc: Fix indentation. * fileio.cc: Fix indentation. * filestuff.cc: Fix indentation. * gdb-dlfcn.cc: Fix indentation. * gdb_string_view.h: Fix indentation. * job-control.cc: Fix indentation. * signals.cc: Fix indentation. Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
* Make {get,set}_inferior_io_terminal inferior methodsPedro Alves2020-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This converts the get_inferior_io_terminal and set_inferior_io_terminal free functions to inferior methods. Since the related commands are called "tty", "{set,show} inferior-tty", and MI's "-inferior-tty-{set,show}", to make the connection between the commands and the code more obvious, the methods are named set_tty/tty instead of set_io_terminal/io_terminal. gdb/ChangeLog: * fork-child.c (prefork_hook): Adjust. * infcmd.c (set_inferior_io_terminal, get_inferior_io_terminal): Delete. (set_inferior_tty_command, show_inferior_tty_command): Adjust. * inferior.c (inferior::set_tty, inferior::tty): New methods. * inferior.h (set_inferior_io_terminal, get_inferior_io_terminal): Remove declarations. (struct inferior) <set_tty, tty>: New methods. (struct inferior) <terminal>: Rename to ... (struct inferior) <m_terminal>: ... this and make private. * main.c (captured_main_1): Adjust. * mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): Adjust. (mi_cmd_inferior_tty_show): Adjust. * nto-procfs.c (nto_procfs_target::create_inferior): Adjust. * windows-nat.c (windows_nat_target::create_inferior): Adjust.
* gdb: add mailing list and IRC information to --helpJonny Grant2020-06-111-3/+6
| | | | | | | | | | | | | | | | | | | | | A few user-vibisble changes to the --help output: * Remove unnecessary quotes around bug url. * Mention the mailing list and IRC channel as places where users can ask GDB-related questions. * Add empty lines between items in the footer, to improve readability. * Remove unnecessary new line at the end of output. 2020-06-09 Jonny Grant <jg@jguk.org> 2020-06-09 Simon Marchi <simon.marchi@polymtl.ca> * main.c (captured_main_1): Don't print new line after help. (print_gdb_help): add mailing list and IRC channel information to --help. Add new lines between items in the footer. Remove quotes around bug url. Signed-off-by: Jonathan Grant <jg@jguk.org> Change-Id: Ibd0746a348d558fb35b5cd7e366f107742806565
* Move event-loop.[ch] to gdbsupport/Tom Tromey2020-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves event-loop.[ch] to gdbsupport/ and updates the uses in gdb. gdb/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * run-on-main-thread.c: Update include. * unittests/main-thread-selftests.c: Update include. * tui/tui-win.c: Update include. * tui/tui-io.c: Update include. * tui/tui-interp.c: Update include. * tui/tui-hooks.c: Update include. * top.h: Update include. * top.c: Update include. * ser-base.c: Update include. * remote.c: Update include. * remote-notif.c: Update include. * remote-fileio.c: Update include. * record-full.c: Update include. * record-btrace.c: Update include. * python/python.c: Update include. * posix-hdep.c: Update include. * mingw-hdep.c: Update include. * mi/mi-main.c: Update include. * mi/mi-interp.c: Update include. * main.c: Update include. * linux-nat.c: Update include. * interps.c: Update include. * infrun.c: Update include. * inf-loop.c: Update include. * event-top.c: Update include. * event-loop.c: Move to ../gdbsupport/. * event-loop.h: Move to ../gdbsupport/. * async-event.h: Update include. * Makefile.in (COMMON_SFILES, HFILES_NO_SRCDIR): Update. gdbsupport/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * event-loop.h: Move from ../gdb/. * event-loop.cc: Move from ../gdb/.
* Move start_event_loop out of event-loop.cTom Tromey2020-04-131-0/+56
| | | | | | | | | | | | | | | | A subsequent patch is going to move event-loop.c to gdbsupport. In a review of an earlier version of this series, Pedro pointed out that the resulting code would be cleaner if start_event_loop were not shared -- because gdb and gdbserver have some different needs here -- and so this moves start_event_loop to main.c. Because the only caller is there, it is also now static. gdb/ChangeLog 2020-04-13 Tom Tromey <tom@tromey.com> * event-loop.h (start_event_loop): Don't declare. * event-loop.c (start_event_loop): Move... * main.c (start_event_loop): ...here. Now static.
* gdb: Allow more control over where to find python librariesAndrew Burgess2020-02-201-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivation behind this commit is to make it easier to bundle the Python *.py library files with GDB when statically linking GDB against libpython. The Python files will be manually added into the GDB installation tree, and GDB should be able to find them at run-time. The installation tree will look like this: . |-- bin/ |-- include/ |-- lib/ | `-- python3.8/ `-- share/ The benefit here is that the entire installation tree can be bundled into a single archive and copied to another machine with a different version of Python installed, and GDB will still work, including its Python support. In use the new configure options would be used something like this, first build and install a static Python library: mkdir python cd python # Clone or download Python into a src/ directory. mkdir build export PYTHON_INSTALL_PATH=$PWD/install cd build ../src/configure --disable-shared --prefix=$PYTHON_INSTALL_PATH make make install Now build and install GDB: mkdir binutils-gdb cd binutils-gdb # Clone or download GDB into a src/ directory. mkdir build export GDB_INSTALL_DIR=$PWD/install cd build ../src/configure \ --prefix=$GDB_INSTALL_DIR \ --with-python=$PYTHON_INSTALL_PATH/bin/python3 \ --with-python-libdir=$GDB_INSTALL_DIR/lib make all-gdb make install-gdb Finally, copy the Python libraries into the GDB install: cp -r $PYTHON_INSTALL_DIR/lib/python3.8/ $GDB_INSTALL_DIR/lib After this the Python src, build, and install directories are no longer needed and can be deleted. If the new --with-python-libdir option is not used then the existing behaviour is left unchanged, GDB will look for the Python libraries in the lib/ directory within the python path. The concatenation of the python prefix and the string 'lib/' is now done at configure time, rather than at run time in GDB as it was previous, however, this was never something that the user had dynamic control over, so there's no loss of functionality. gdb/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add --with-python-libdir option. * main.c: Use WITH_PYTHON_LIBDIR.
* Ensure GDB warnings are styled.Philippe Waroquiers2020-01-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While handling the comments of Tom related to [RFC] Have an option to tell GDB to detect and possibly handle mismatched exec-files. https://sourceware.org/ml/gdb-patches/2019-12/msg00621.html I saw that GDB warnings are produced ignoring the given styles. This patch: * ensures that style markups are properly handled by "warning". * changes 'set/show data-directory' so that file style is used in warnings and in 'show message' * changes all other messages in top.c to use file style when appropriate. * Uses the above data-directory changes in gdb.base/style.exp 2020-01-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * ui-file.c (stdio_file::can_emit_style_escape) (tee_file::can_emit_style_escape): Ensure style is used also on gdb_stderr when gdb_stderr is a tty supporting styling, similarly to gdb_stdout. * main.c (set_gdb_data_directory): Use file style to output the warning that the given pathname is not a directory. * top.c (show_history_filename, gdb_safe_append_history) (show_gdb_datadir): Use file style. 2020-01-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Test that warnings are styled.
* Update copyright year range in all GDB files.Joel Brobecker2020-01-011-1/+1
| | | | | | gdb/ChangeLog: Update copyright year range in all GDB files.
* Introduce alternate_signal_stack RAII classTom Tromey2019-11-261-24/+2
| | | | | | | | | | | | | | | | | | This introduces a new RAII class that temporarily installs an alternate signal stack (on systems that have sigaltstack); then changes the one gdb use of sigaltstack to use this class instead. This will be used in a later patch, when creating new threads that may want to handle SIGSEGV. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * main.c (setup_alternate_signal_stack): Remove. (captured_main_1): Use gdb::alternate_signal_stack. * gdbsupport/alt-stack.h: New file. Change-Id: I721c047ae9d51a35fd274a6dbc00a58c6440dae6
* Load system gdbinit files from a directoryChristian Biesinger2019-10-291-14/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a configure option --with-system-gdbinit-dir to specify a directory in which to look for gdbinit files. All files in this directory are loaded on startup (subject to -n/-nx as usual) as long as the extension matches a known and enabled scripting language (.gdb/.py/.scm). This also changes get_ext_lang_of_file to support ".gdb" files, similar to get_ext_lang_defn's handling of EXT_LANG_GDB. gdb/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * NEWS: Mention new --with-system-gdbinit-dir option. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add new option --with-system-gdbinit-dir. * extension.c (get_ext_lang_of_file): Return extension_language_gdb for a ".gdb" suffix. * main.c (get_init_files): Change system_gdbinit argument to a vector and return the files in SYSTEM_GDBINIT_DIR in addition to SYSTEM_GDBINIT. (captured_main_1): Update. (print_gdb_help): Update. * top.c (print_gdb_configuration): Also print the value of SYSTEM_GDBINIT_DIR. gdb/doc/ChangeLog: 2019-10-29 Christian Biesinger <cbiesinger@google.com> * Makefile.in: Also set SYSTEM_GDBINIT_DIR for the info manual generation. * gdb.texinfo (many sections): Document new --with-system-gdbinit-dir option. Change-Id: If233859ecc21bc6421d589b37cd658a3c7d030f2
* [gdb] Fix typos in commentsTom de Vries2019-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-17 Tom de Vries <tdevries@suse.de> * arm-nbsd-nat.c: Fix typos in comments. * arm-tdep.c: Same. * darwin-nat-info.c: Same. * dwarf2read.c: Same. * elfread.c: Same. * event-top.c: Same. * findvar.c: Same. * gdbtypes.c: Same. * hppa-tdep.c: Same. * i386-tdep.c: Same. * jit.c: Same. * main.c: Same. * mdebugread.c: Same. * moxie-tdep.c: Same. * nto-procfs.c: Same. * osabi.c: Same. * ppc-linux-tdep.c: Same. * remote.c: Same. * riscv-tdep.c: Same. * s390-tdep.c: Same. * sh-tdep.c: Same. * sparc-linux-tdep.c: Same. * sparc-nat.c: Same. * stack.c: Same. * target-descriptions.c: Same. * top.c: Same. * varobj.c: Same. Change-Id: I6047967abd2d51c9000dea15184d19f4e952c3ff
* Include gdbtk.h to avoid declarationsChristian Biesinger2019-10-101-4/+3
| | | | | | | | | | | | | | Once https://sourceware.org/ml/insight/2019-q4/msg00000.html lands, we can just include gdbtk.h to get the declarations for external_editor_command and gdbtk_test, instead of having to declare them here in main.c. gdb/ChangeLog: 2019-10-07 Christian Biesinger <cbiesinger@google.com> * main.c (captured_main_1): Include gdbtk.h and remove declarations for external_editor_command and gdbtk_test.
* Fix leak due to assigning a xstrdup-ed string to the std::string gdb_datadirPhilippe Waroquiers2019-10-011-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Valgrind reports the following leak: ==32623== 56 bytes in 1 blocks are definitely lost in loss record 1,099 of 6,654 ==32623== at 0x4835753: malloc (vg_replace_malloc.c:307) ==32623== by 0x25CF67: xmalloc (alloc.c:60) ==32623== by 0x65FBD9: xstrdup (xstrdup.c:34) ==32623== by 0x413D9E: captured_main_1(captured_main_args*) (main.c:553) ==32623== by 0x414FFA: captured_main (main.c:1172) ==32623== by 0x414FFA: gdb_main(captured_main_args*) (main.c:1197) ==32623== by 0x22531A: main (gdb.c:32) Commit f2aec7f6d14 changed gdb_datadir to std::string. So, xstrdup-ing the result of relocate_gdb_directory (returning a std::string) is not needed and creates a leak. Fix the leak by removing the xstrdup and the not needed c_str (). Also removes a useless conversion of gdb_datadir to std::string. gdb/ChangeLog 2019-10-01 Philippe Waroquiers <philippe.waroquiers@skynet.be> * main.c (relocate_gdbinit_path_maybe_in_datadir): Remove std::string conversion of gdb_datadir. (captured_main_1): Remove xstrdup when assigning to gdb_datadir, remove not needed c_str ().
* Change boolean options to bool instead of intChristian Biesinger2019-09-181-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is for add_setshow_boolean_cmd as well as the gdb::option interface. gdb/ChangeLog: 2019-09-17 Christian Biesinger <cbiesinger@google.com> * ada-lang.c (ada_ignore_descriptive_types_p): Change to bool. (print_signatures): Likewise. (trust_pad_over_xvs): Likewise. * arch/aarch64-insn.c (aarch64_debug): Likewise. * arch/aarch64-insn.h (aarch64_debug): Likewise. * arm-linux-nat.c (arm_apcs_32): Likewise. * arm-linux-tdep.c (arm_apcs_32): Likewise. * arm-nbsd-nat.c (arm_apcs_32): Likewise. * arm-tdep.c (arm_debug): Likewise. (arm_apcs_32): Likewise. * auto-load.c (debug_auto_load): Likewise. (auto_load_gdb_scripts): Likewise. (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * auto-load.h (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * breakpoint.c (disconnected_dprintf): Likewise. (breakpoint_proceeded): Likewise. (automatic_hardware_breakpoints): Likewise. (always_inserted_mode): Likewise. (target_exact_watchpoints): Likewise. (_initialize_breakpoint): Update. * breakpoint.h (target_exact_watchpoints): Change to bool. * btrace.c (maint_btrace_pt_skip_pad): Likewise. * cli/cli-cmds.c (trace_commands): Likewise. * cli/cli-cmds.h (trace_commands): Likewise. * cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument to bool*. * cli/cli-logging.c (logging_overwrite): Change to bool. (logging_redirect): Likewise. (debug_redirect): Likewise. * cli/cli-option.h (option_def) <boolean>: Change return type to bool*. (struct boolean_option_def) <get_var_address_cb_>: Change return type to bool. <boolean_option_def>: Update. (struct flag_option_def): Change default type of Context to bool from int. <flag_option_def>: Change return type of var_address_cb_ to bool*. * cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*. (get_setshow_command_value_string): Likewise. * cli/cli-style.c (cli_styling): Change to bool. (source_styling): Likewise. * cli/cli-style.h (source_styling): Likewise. (cli_styling): Likewise. * cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change to bool. * command.h (var_types): Update comment. (add_setshow_boolean_cmd): Change int* var argument to bool*. * compile/compile-cplus-types.c (debug_compile_cplus_types): Change to bool. (debug_compile_cplus_scopes): Likewise. * compile/compile-internal.h (compile_debug): Likewise. * compile/compile.c (compile_debug): Likewise. (struct compile_options) <raw>: Likewise. * cp-support.c (catch_demangler_crashes): Likewise. * cris-tdep.c (usr_cmd_cris_version_valid): Likewise. (usr_cmd_cris_dwarf2_cfi): Likewise. * csky-tdep.c (csky_debug): Likewise. * darwin-nat.c (enable_mach_exceptions): Likewise. * dcache.c (dcache_enabled_p): Likewise. * defs.h (info_verbose): Likewise. * demangle.c (demangle): Likewise. (asm_demangle): Likewise. * dwarf-index-cache.c (debug_index_cache): Likewise. * dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2read.c (check_physname): Likewise. (use_deprecated_index_sections): Likewise. (dwarf_always_disassemble): Likewise. * eval.c (overload_resolution): Likewise. * event-top.c (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * event-top.h (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * exec.c (write_files): Likewise. * fbsd-nat.c (debug_fbsd_lwp): Likewise (debug_fbsd_nat): Likewise. * frame.h (struct frame_print_options) <print_raw_frame_arguments>: Likewise. (struct set_backtrace_options) <backtrace_past_main>: Likewise. <backtrace_past_entry> Likewise. * gdb-demangle.h (demangle): Likewise. (asm_demangle): Likewise. * gdb_bfd.c (bfd_sharing): Likewise. * gdbcore.h (write_files): Likewise. * gdbsupport/common-debug.c (show_debug_regs): Likewise. * gdbsupport/common-debug.h (show_debug_regs): Likewise. * gdbthread.h (print_thread_events): Likewise. * gdbtypes.c (opaque_type_resolution): Likewise. (strict_type_checking): Likewise. * gnu-nat.c (gnu_debug_flag): Likewise. * guile/scm-auto-load.c (auto_load_guile_scripts): Likewise. * guile/scm-param.c (pascm_variable): Add boolval. (add_setshow_generic): Update. (pascm_param_value): Update. (pascm_set_param_value_x): Update. * hppa-tdep.c (hppa_debug): Change to bool.. * infcall.c (may_call_functions_p): Likewise. (coerce_float_to_double_p): Likewise. (unwind_on_signal_p): Likewise. (unwind_on_terminating_exception_p): Likewise. * infcmd.c (startup_with_shell): Likewise. * inferior.c (print_inferior_events): Likewise. * inferior.h (startup_with_shell): Likewise. (print_inferior_events): Likewise. * infrun.c (step_stop_if_no_debug): Likewise. (detach_fork): Likewise. (debug_displaced): Likewise. (disable_randomization): Likewise. (non_stop): Likewise. (non_stop_1): Likewise. (observer_mode): Likewise. (observer_mode_1): Likewise. (set_observer_mode): Update. (sched_multi): Change to bool. * infrun.h (debug_displaced): Likewise. (sched_multi): Likewise. (step_stop_if_no_debug): Likewise. (non_stop): Likewise. (disable_randomization): Likewise. * linux-tdep.c (use_coredump_filter): Likewise. (dump_excluded_mappings): Likewise. * linux-thread-db.c (auto_load_thread_db): Likewise. (check_thread_db_on_load): Likewise. * main.c (captured_main_1): Update. * maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt, xx2_opt, boolean_opt>: Change to bool. * maint-test-settings.c (maintenance_test_settings_boolean): Likewise. * maint.c (maintenance_profile_p): Likewise. (per_command_time): Likewise. (per_command_space): Likewise. (per_command_symtab): Likewise. * memattr.c (inaccessible_by_default): Likewise. * mi/mi-main.c (mi_async): Likewise. (mi_async_1): Likewise. * mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise. * nat/fork-inferior.h (startup_with_shell): Likewise. * nat/linux-namespaces.c (debug_linux_namespaces): Likewise. * nat/linux-namespaces.h (debug_linux_namespaces): Likewise. * nios2-tdep.c (nios2_debug): Likewise. * or1k-tdep.c (or1k_debug): Likewise. * parse.c (parser_debug): Likewise. * parser-defs.h (parser_debug): Likewise. * printcmd.c (print_symbol_filename): Likewise. * proc-api.c (procfs_trace): Likewise. * python/py-auto-load.c (auto_load_python_scripts): Likewise. * python/py-param.c (union parmpy_variable): Add "bool boolval" field. (set_parameter_value): Update. (add_setshow_generic): Update. * python/py-value.c (copy_py_bool_obj): Change argument from int* to bool*. * python/python.c (gdbpy_parameter_value): Cast to bool* instead of int*. * ravenscar-thread.c (ravenscar_task_support): Change to bool. * record-btrace.c (record_btrace_target::store_registers): Update. * record-full.c (record_full_memory_query): Change to bool. (record_full_stop_at_limit): Likewise. * record-full.h (record_full_memory_query): Likewise. * remote-notif.c (notif_debug): Likewise. * remote-notif.h (notif_debug): Likewise. * remote.c (use_range_stepping): Likewise. (interrupt_on_connect): Likewise. (remote_break): Likewise. * ser-tcp.c (tcp_auto_retry): Likewise. * ser-unix.c (serial_hwflow): Likewise. * skip.c (debug_skip): Likewise. * solib-aix.c (solib_aix_debug): Likewise. * spu-tdep.c (spu_stop_on_load_p): Likewise. (spu_auto_flush_cache_p): Likewise. * stack.c (struct backtrace_cmd_options) <full, no_filters, hide>: Likewise. (struct info_print_options) <quiet>: Likewise. * symfile-debug.c (debug_symfile): Likewise. * symfile.c (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symfile.h (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symtab.c (basenames_may_differ): Likewise. (struct filename_partial_match_opts) <dirname, basename>: Likewise. (struct info_print_options) <quiet, exclude_minsyms>: Likewise. (struct info_types_options) <quiet>: Likewise. * symtab.h (demangle): Likewise. (basenames_may_differ): Likewise. * target-dcache.c (stack_cache_enabled_1): Likewise. (code_cache_enabled_1): Likewise. * target.c (trust_readonly): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. (auto_connect_native_target): Likewise. (target_stop_and_wait): Update. (target_async_permitted): Change to bool. (target_async_permitted_1): Likewise. (may_write_registers_1): Likewise. (may_write_memory_1): Likewise. (may_insert_breakpoints_1): Likewise. (may_insert_tracepoints_1): Likewise. (may_insert_fast_tracepoints_1): Likewise. (may_stop_1): Likewise. * target.h (target_async_permitted): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. * thread.c (struct info_threads_opts) <show_global_ids>: Likewise. (make_thread_apply_all_options_def_group): Change argument from int* to bool*. (thread_apply_all_command): Update. (print_thread_events): Change to bool. * top.c (confirm): Likewise. (command_editing_p): Likewise. (history_expansion_p): Likewise. (write_history_p): Likewise. (info_verbose): Likewise. * top.h (confirm): Likewise. (history_expansion_p): Likewise. * tracepoint.c (disconnected_tracing): Likewise. (circular_trace_buffer): Likewise. * typeprint.c (print_methods): Likewise. (print_typedefs): Likewise. * utils.c (debug_timestamp): Likewise. (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * utils.h (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * valops.c (overload_resolution): Likewise. * valprint.h (struct value_print_options) <prettyformat_arrays, prettyformat_structs, vtblprint, unionprint, addressprint, objectprint, stop_print_at_null, print_array_indexes, deref_ref, static_field_print, pascal_static_field_print, raw, summary, symbol_print, finish_print>: Likewise. * windows-nat.c (new_console): Likewise. (cygwin_exceptions): Likewise. (new_group): Likewise. (debug_exec): Likewise. (debug_events): Likewise. (debug_memory): Likewise. (debug_exceptions): Likewise. (useshell): Likewise. * windows-tdep.c (maint_display_all_tib): Likewise. * xml-support.c (debug_xml): Likewise.
* Make relocate_{path,gdb_directory} return std::stringChristian Biesinger2019-09-111-46/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies memory management. I've also changed some global variables to std::string accordingly (which store the result of these functions), but not all because some are used with add_setshow_optional_filename_cmd which requires a char*. gdb/ChangeLog: 2019-09-11 Christian Biesinger <cbiesinger@google.com> * auto-load.c (auto_load_expand_dir_vars): Update. * defs.h (gdb_datadir): Change to std::string. (python_libdir): Likewise. (relocate_gdb_directory): Change return type to std::string. * guile/guile.c (gdbscm_data_directory): Update. (initialize_scheme_side): Update. * jit.c (jit_reader_dir): Change to std::string. (jit_reader_load_command): Update. * main.c (gdb_datadir): Change to std::string. (python_libdir): Likewise. (set_gdb_data_directory): Update. (relocate_path): Change to return std::string. (relocate_gdb_directory): Change to return std::string. (relocate_gdbinit_path_maybe_in_datadir): Update. (captured_main_1): Update. * python/python.c (do_start_initialization): Update. * top.c (show_gdb_datadir): Update. * xml-syscall.c (xml_init_syscalls_info): Update. (init_syscalls_info): Update.
* Factor out the code to do the datadir-relocation for gdbinitChristian Biesinger2019-09-111-31/+43
| | | | | | | | | | | | | This simplifies get_init_files and makes it possible to reuse this code in an upcoming patch for SYSTEM_GDBINIT_DIR. gdb/ChangeLog: 2019-09-11 Christian Biesinger <cbiesinger@google.com> * main.c (relocate_gdbinit_path_maybe_in_datadir): Factor this code out of get_init_files. (get_init_files): Update.