aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-01-01ChangeLog rotationAlan Modra18-21434/+21560
2019-01-01update copyright year printed by gdb, gdbserver and gdbreplayJoel Brobecker5-3/+14
gdb/ChangeLog: * top.c (print_gdb_version): Update Copyright year in version message. gdb/gdbserver/ChangeLog: * gdbreplay.c (gdbreplay_version): Update copyright year in version message. * server.c (gdbserver_version): Likewise.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker5769-5768/+5772
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2019-01-01rotate gdb/ChangeLogJoel Brobecker3-17186/+17201
2019-01-01Automatic date update in version.inGDB Administrator1-1/+1
2018-12-31Use gdb::unique_xmalloc_ptr<char> in command_line_input to fix a leakPhilippe Waroquiers2-5/+10
Following the change of logic where the input_handler gets a gdb::unique_xmalloc_ptr<char>, a call to readline directly followed by a call to handle_line_of_input is missing a free, and causes the below leak. Use gdb::unique_xmalloc_ptr<char> to solve the leak. ==16291== VALGRIND_GDB_ERROR_BEGIN ==16291== 64 bytes in 1 blocks are definitely lost in loss record 1,815 of 4,111 ==16291== at 0x4C2E2B3: realloc (vg_replace_malloc.c:836) ==16291== by 0x41EB1C: xrealloc (common-utils.c:62) ==16291== by 0x41DBD3: buffer_grow(buffer*, char const*, unsigned long) [clone .part.1] (buffer.c:40) ==16291== by 0x66E8FF: buffer_grow_char (buffer.h:40) ==16291== by 0x66E8FF: gdb_readline_no_editing (top.c:798) ==16291== by 0x66E8FF: command_line_input(char const*, char const*) (top.c:1249) ==16291== by 0x66EBD8: read_command_file(_IO_FILE*) (top.c:421) ==16291== by 0x412C0C: script_from_file(_IO_FILE*, char const*) (cli-script.c:1547) ==16291== by 0x40BE90: source_script_from_stream (cli-cmds.c:569) ==16291== by 0x40BE90: source_script_with_search(char const*, int, int) (cli-cmds.c:606) ==16291== by 0x54D567: catch_command_errors(void (*)(char const*, int), char const*, int) (main.c:379) ==16291== by 0x54EA84: captured_main_1 (main.c:994) ==16291== by 0x54EA84: captured_main (main.c:1167) ==16291== by 0x54EA84: gdb_main(captured_main_args*) (main.c:1193) ==16291== by 0x29DA27: main (gdb.c:32) ==16291== ==16291== VALGRIND_GDB_ERROR_END gdb/ChangeLog 2018-12-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.c (command_line_input): Use unique_xmalloc_ptr to manage memory allocated by readline.
2018-12-31PR24042, Global-buffer-overflow problem in output_rel_findAlan Modra2-8/+20
place_orphan handled ELF SHT_REL/SHT_RELA specially, output_rel_find didn't. This mismatch was a bug and also meant it was possible to craft an object where ld accessed section->name out of bounds. PR 24042 * emultempl/elf32.em (output_rel_find): Drop "sec" param. Add "rela". (gld${EMULATION_NAME}_place_orphan): Use sh_type to calculate "rela" param of output_rel_find when ELF. Tidy uses of elfinput.
2018-12-31PR24041, Invalid Memory Address Dereference in elf_link_add_object_symbolsAlan Modra2-1/+7
PR 24041 * elflink.c (elf_link_add_object_symbols): Don't segfault on crafted ET_DYN with no program headers.
2018-12-31[PowerPC64] Nop out ld 2,24(1) after old-style __tls_get_addrAlan Modra2-1/+15
When optimising inline plt calls to __tls_get_addr without tls marker relocs, ld should zap any toc restore insn after the bctrl, to stop a load-hit-store stall. * elf64-ppc.c (ppc64_elf_relocate_section <tls_ldgd_opt>): When editing an old-style __tls_get_addr call, replace a toc restore insn with a nop.
2018-12-31Automatic date update in version.inGDB Administrator1-1/+1
2018-12-30Change input_handler to take a unique_xmalloc_ptrTom Tromey6-19/+32
This changes ui::input_handler to take a unique_xmalloc_ptr. This clarifies the ownership transfer of input_handler's argument. gdb/ChangeLog 2018-12-30 Tom Tromey <tom@tromey.com> * event-top.h (command_line_handler): Update. * top.c (class gdb_readline_wrapper_cleanup) <m_handler_orig>: Update. (gdb_readline_wrapper_line): Update. * top.h (struct ui) <input_handler>: Take a unique_xmalloc_ptr. (handle_line_of_input): Update. * event-top.c: Update. (gdb_readline_no_editing_callback): Update. (command_line_handler): Take a unique_xmalloc_ptr. (handle_line_of_input): Take a const char *. (command_line_append_input_line): Take a const char *.
2018-12-30Fix 'help set/show style' strange layouts/results.Philippe Waroquiers1-5/+5
The layout for 'help set address|variable' is strange, e.g.: (gdb) help set style address style address List of show Address display styling Configure address colors and display intensity subcommands: show Address display styling Configure address colors and display intensity background -- Set the background color for this property show Address display styling Configure address colors and display intensity foreground -- Set the foreground color for this property show Address display styling Configure address colors and display intensity intensity -- Set the display intensity color for this property Type "help show Address display styling Configure address colors and display intensity" followed by show Address display styling Configure address colors and display intensity subcommand name for full documentation. Type "apropos word" to search for commands related to "word". Command name abbreviations are allowed if unambiguous. (gdb) The help for 'set style function|filename' gives help for 'Show': (gdb) help set style filename Filename display styling Configure filename colors and display intensity. List of show style filename subcommands: show style filename background -- Set the background color for this property show style filename foreground -- Set the foreground color for this property show style filename intensity -- Set the display intensity color for this property The help for 'show style function|filename' is equally strange, as it speaks about commands, instead of sub commands: (gdb) help show style filename Filename display styling Configure filename colors and display intensity. List of commands: background -- Show the background color for this property foreground -- Show the foreground color for this property intensity -- Show the display intensity color for this property Type "help" followed by command name for full documentation. Type "apropos word" to search for commands related to "word". Command name abbreviations are allowed if unambiguous. (gdb) This patch fixes all this. Note that the 'set style' and 'show style' have the same prefix_doc: (gdb) help show style Style-specific settings Configure various style-related variables, such as colors ... (gdb) help set style Style-specific settings Configure various style-related variables, such as colors ... Other similar commands (such as set|show history) have typically a more specific prefix: (gdb) help show history Generic command for showing command history parameters. ... (gdb) help set history Generic command for setting command history parameters. ... This could be fixed by having set_prefix_doc and show_prefix_doc instead of the single prefix_doc argument to cli_style_option::add_setshow_commands. That could be improved if deemed better. 2018-12-29 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-style.c (cli_style_option::add_setshow_commands): Initialize m_set_prefix with "set", instead of re-assigning m_show_prefix. Use m_set_prefix for set_list and m_show_prefix for show_list. (_initialize_cli_style): Correct the order of arguments in variable_name_style.add_setshow_commands and address_style.add_setshow_commands calls.
2018-12-30Automatic date update in version.inGDB Administrator1-1/+1
2018-12-28Fix the build when GNU Source Highlight is not availableTom Tromey2-0/+8
The builder pointed out that, when GNU Source Highlight is not available, get_language_name is not used. This patch makes it conditional, fixing the build problem. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * source-cache.c (get_language_name): Conditionally compile.
2018-12-29Automatic date update in version.inGDB Administrator1-1/+1
2018-12-28Fix a crash in jit.cTom Tromey6-1/+115
A user at Mozilla pointed out a crash in jit.c. In his situation, an inferior using the JIT API exec'd an executable that did not use it. This caused an assertion failure when jit.c:free_objfile_data called delete_breakpoint with NULL. This patch fixes the problem in the obvious way. New test case included. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * jit.c (free_objfile_data): Only delete breakpoint if non-null. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> Simon Marchi <simark@simark.ca> * gdb.base/jit-exec.exp: New file. * gdb.base/jit-exec.c: New file. * gdb.base/jit-execd.c: New file.
2018-12-28Document the "set style" commandsTom Tromey4-0/+103
This documents the new "set style" commands. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * NEWS: Mention terminal styling. gdb/doc/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.texinfo (Output Styling): New node.
2018-12-28Highlight source code using GNU Source HighlightTom Tromey16-203/+576
This changes gdb to highlight source using GNU Source Highlight, if it is available. This affects the output of the "list" command and also the TUI source window. No new test because I didn't see a way to make it work when Source Highlight is not found. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * utils.h (can_emit_style_escape): Declare. * utils.c (can_emit_style_escape): No longer static. * cli/cli-style.c (set_style_enabled): New function. (_initialize_cli_style): Use it. * tui/tui-winsource.c (tui_show_source_line): Use tui_puts. (tui_alloc_source_buffer): Change how source lines are allocated. * tui/tui-source.c (copy_source_line): New function. (tui_set_source_content): Use source cache. * tui/tui-io.h (tui_puts): Update. * tui/tui-io.c (tui_puts_internal): Add window parameter. (tui_puts): Likewise. (tui_redisplay_readline): Update. * tui/tui-data.c (free_content_elements): Change how source window contents are freed. * source.c (forget_cached_source_info): Clear the source cache. (print_source_lines_base): Use the source cache. * source-cache.h: New file. * source-cache.c: New file. * configure.ac: Check for GNU Source Highlight library. * configure: Update. * config.in: Update. * Makefile.in (SRCHIGH_LIBS, SRCHIGH_CFLAGS): New variables. (INTERNAL_CFLAGS_BASE): Add SRCHIGH_CFLAGS. (CLIBS): Add SRCHIGH_LIBS. (COMMON_SFILES): Add source-cache.c. (HFILES_NO_SRCDIR): Add source-cache.h.
2018-12-28Use wclrtoeol in tui_show_source_lineTom Tromey2-7/+5
This changes tui_show_source_line to use wclrtoeol rather than manually emitting a sequence of spaces. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_show_source_line): Use wclrtoeol.
2018-12-28Make ANSI terminal escape sequences work in TUITom Tromey6-18/+251
PR tui/14126 notes that ANSI terminal escape sequences don't affect the colors shown in the TUI. A simple way to see this is to try the extended-prompt example from the gdb manual. Curses does not pass escape sequences through to the terminal. Instead, it replaces non-printable characters with a visible representation, for example "^[" for the ESC character. This patch fixes the problem by adding a simple ANSI terminal sequence parser to gdb. These sequences are decoded and those that are recognized are turned into the appropriate curses calls. The curses approach to color handling is unusual and so there are some oddities in the implementation. Standard curses has no notion of the default colors of the terminal. So, if you set the foreground color, it is not possible to reset it -- you have to pick some other color. ncurses provides an extension to handle this, so this patch updates configure and uses it when available. Second, in curses, colors always come in pairs: you cannot set just the foreground. This patch handles this by tracking actually-used pairs of colors and keeping a table of these for reuse. Third, there are a limited number of such pairs available. In this patch, if you try to use too many color combinations, gdb will just ignore some color changes. Finally, in addition to limiting the number of color pairs, curses also limits the number of colors. This means that, when using extended 8- or 24-bit color sequences, it may be possible to exhaust the curses color table. I am very sour on the curses design now. I do not know how to write a test for this, so I did not. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> PR tui/14126: * tui/tui.c (tui_enable): Call start_color and use_default_colors. * tui/tui-io.c (struct color_pair): New. (color_pair_map, last_color_pair, last_style): New globals. (tui_setup_io): Clean up color map when shutting down. (curses_colors): New constant. (get_color_pair, apply_ansi_escape): New functions. (tui_write): Rewrite. (tui_puts_internal): New function, from tui_puts. Add "height" parameter. (tui_puts): Use tui_puts_internal. (tui_redisplay_readline): Use tui_puts_internal. (_initialize_tui_io): New function. (color_map): New globals. (get_color): New function. * configure.ac: Check for use_default_colors. * config.in, configure: Rebuild.
2018-12-28Style addressesTom Tromey10-16/+66
This changes gdb to style addresses. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind) <ADDRESS>: New constant. * ui-out.c (ui_out::field_core_addr): Add styling. * stack.c (print_frame): Add styling. * printcmd.c (print_address): Add styling. (print_address_demangle, info_address_command): Likewise. * cli/cli-style.h (address_style): Declare. * cli/cli-style.c (address_style): New global. (_initialize_cli_style): Register new commands. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Update test to check for address styling.
2018-12-28Style the "Reading symbols" messageTom Tromey4-1/+19
The "Reading symbols" message does not use ui-out (perhaps it should?), so this styles it using the low-level API. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * symfile.c (symbol_file_add_with_addrs): Style file name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for styling of "Reading symbols" message.
2018-12-28Style the gdb welcome messageTom Tromey4-1/+22
This changes gdb to style the welcome message that is shown by default. The styling is only done interactively. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * top.c (print_gdb_version): Style gdb version number. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for version number styling.
2018-12-28Style print_address_symbolicTom Tromey4-4/+15
print_address_symbolic does not use ui-out, so it did not style function names. This patch changes it to use the low-level style code directly. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * printcmd.c (print_address_symbolic): Style function name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for print_address_symbolic.
2018-12-28Style locations when setting a breakpointTom Tromey4-4/+21
say_where does not use ui-out, so function and file names printed by it were not styled. This patch changes say_where to use the low-level style code directly. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * breakpoint.c (say_where): Style file name. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for breakpoint setting.
2018-12-28Style variable namesTom Tromey9-4/+42
This adds style support for variable names. For the time being, this is only done in backtraces, not in ptype or print; those places do not use ui-out and so would need ad hoc changes. This also adds styling to the names printed for local variables in "backtrace full". This code does not use ui-out, so the styling is done using the low-level API. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * ui-out.h (enum class ui_out_style_kind) <VARIABLE>: New global. * stack.c (print_frame_arg): Style name. * printcmd.c (print_variable_and_value): Style variable name. * cli/cli-style.h (variable_name_style): Declare. * cli/cli-style.c (variable_name_style): New global. (_initialize_cli_style): Update. * cli-out.c (cli_ui_out::do_field_string): Update. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add test for variable names.
2018-12-28Reset terminal stylesTom Tromey5-6/+48
This adds a function that can be used to reset terminal styles, regardless of what style the low-level output routines currently think is applied. This is used to make "echo" and "printf" work properly when emitting ANSI terminal escapes -- now gdb will reset the style at the end of the command. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * utils.h (reset_terminal_style): Declare. * utils.c (can_emit_style_escape): New function. (set_output_style): Use it. (reset_terminal_style): New function. * printcmd.c (printf_command): Call reset_terminal_style. * cli/cli-cmds.c (echo_command): Call reset_terminal_style.
2018-12-28Add output styles to gdbTom Tromey25-46/+666
This adds some output styling to the CLI. A style is currently a foreground color, a background color, and an intensity (dim or bold). (This list could be expanded depending on terminal capabilities.) A style can be applied while printing. For ui-out, this is done by passing the style constant as an argument. For low-level cases, fprintf_styled and fputs_styled are provided. Users can control the style via a number of new set/show commands. In the interest of not typing many nearly-identical documentation strings, I automated this. On the down side, this is not very i18n-friendly. I've chose some default colors to use. I think it would be good to enable this by default, so that when users start the new gdb, they will see the new feature. Stylizing is done if TERM is set and is not "dumb". This could be improved when the TUI is available by using the curses has_colors call. That is, the lowest layer could call this without committing to using curses everywhere; see my other patch for TUI colorizing. I considered adding a new "set_style" method to ui_file. However, because the implementation had to interact with the pager code, I didn't take this approach. But, one idea might be to put the isatty check there and then have it defer to the lower layers. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * utils.h (set_output_style, fprintf_styled) (fputs_styled): Declare. * utils.c (applied_style, desired_style): New globals. (emit_style_escape, set_output_style): New function. (prompt_for_continue): Emit style escapes. (fputs_maybe_filtered): Likewise. (fputs_styled, fprintf_styled): New functions. * ui-out.h (enum class ui_out_style_kind): New. (class ui_out) <field_string, field_stream, do_field_string>: Add style parameter. * ui-out.c (ui_out::field_stream, ui_out::field_string): Add style parameter. * tui/tui-out.h (class tui_ui_out) <do_field_string>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_string): Add style parameter. (tui_ui_out::do_field_string): Update. * tracepoint.c (print_one_static_tracepoint_marker): Style output. * stack.c (print_frame_info, print_frame): Style output. * source.c (print_source_lines_base): Style output. * skip.c (info_skip_command): Style output. * record-btrace.c (btrace_call_history_src_line): Style output. (btrace_call_history): Likewise. * python/py-framefilter.c (py_print_frame): Style output. * mi/mi-out.h (class mi_ui_out) <do_field_string>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_table_header) (mi_ui_out::do_field_int): Update. (mi_ui_out::do_field_string): Update. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Style output. * cli/cli-style.h: New file. * cli/cli-style.c: New file. * cli-out.h (class cli_ui_out) <do_field_string>: Add style parameter. * cli-out.c (cli_ui_out::do_table_header) (cli_ui_out::do_field_int, cli_ui_out::do_field_skip): Update. (cli_ui_out::do_field_string): Add style parameter. Style the output. * breakpoint.c (print_breakpoint_location): Style output. (update_static_tracepoint): Likewise. * Makefile.in (SUBDIR_CLI_SRCS): Add cli-style.c. (HFILES_NO_SRCDIR): Add cli-style.h. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: New file. * gdb.base/style.c: New file.
2018-12-28Change gdb test suite's TERM settingTom Tromey3-49/+59
This changes the gdb test suite to set TERM to "dumb" by default. This setting disables terminal styling, so that the existing tests do not need to be updated. gdb/testsuite/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * lib/gdb.exp (gdb_init): Set the TERM environment variable to "dumb". * gdb.base/readline.exp (operate_and_get_next): Save and restore the TERM environment variable.
2018-12-28Introduce ui_file_styleTom Tromey6-0/+749
This introduces the new ui_file_style class and various helpers. This class represents a terminal style and provides methods for parsing and emitting the corresponding ANSI terminal escape sequences. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * unittests/style-selftests.c: New file. * ui-style.c: New file. * ui-style.h: New file. * ui-file.h: Include ui-style.h. * Makefile.in (COMMON_SFILES): Add ui-style.c. (HFILES_NO_SRCDIR): Add ui-style.h. (SUBDIR_UNITTESTS_SRCS): Add style-selftests.c.
2018-12-28Add a "context" argument to add_setshow_enum_cmdTom Tromey3-4/+15
This adds a "context" argument to add_setshow_enum_cmd. Now add_setshow_enum_cmd will call set_cmd_context on both of the new commands. This is used in a later patch. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * command.h (add_setshow_enum_cmd): Add "context" argument. * cli/cli-decode.c (add_setshow_enum_cmd): Add "context" argument. Call set_cmd_context.
2018-12-28Change wrap buffering to use a std::stringTom Tromey2-37/+35
Currently wrap buffering is implemented by allocating a string that is the same width as the window, and then writing characters into it. However, if gdb emits terminal escapes, then these could possibly overflow the buffer. To prevent this, change the wrap buffer to be a std::string and update the various uses. This also changes utils.c to always emit characters to the wrap buffer. This simplifies future patches which emit terminal escape sequences, and also makes it possible for the "echo" and "printf" commands to be used to emit terminal escapes and have these work in the TUI. gdb/ChangeLog 2018-12-28 Tom Tromey <tom@tromey.com> * utils.c (filter_initialized): New global. (wrap_buffer): Now a std::string. (wrap_pointer): Remove. (flush_wrap_buffer): New function. (filtered_printing_initialized, set_width, wrap_here) (fputs_maybe_filtered): Update.
2018-12-28Fix leak of set/show verbose doc, avoid xfree of static stringPhilippe Waroquiers1-5/+11
In the tests py-pp-registration/gdb.log default/gdb.log foll-fork/gdb.log setshow/gdb.log break-interp/gdb.log Valgrind detects a leak of the doc strings for the set and show verbose cmd. Here is the stacktrace of the leaked set doc: ==25548== 15 bytes in 1 blocks are definitely lost in loss record 101 of 3,120 ==25548== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309) ==25548== by 0x409C27: xmalloc (common-utils.c:44) ==25548== by 0x778AF9: xstrdup (xstrdup.c:34) ==25548== by 0x3F860F: add_setshow_cmd_full(char const*, command_class, var_types, void*, char const*, char const*, char const*, void (*)(char const*, int, cmd_list_element*), void (*)(ui_file*, int, cmd_list_element*, char const*), cmd_list_element**, cmd_list_element**, cmd_list_element**, cmd_list_element**) [clone .constprop.10] (cli-decode.c:495) ==25548== by 0x3F8ADB: add_setshow_boolean_cmd(char const*, command_class, int*, char const*, char const*, char const*, void (*)(char const*, int, cmd_list_element*), void (*)(ui_file*, int, cmd_list_element*, char const*), cmd_list_element**, cmd_list_element**) (cli-decode.c:593) ==25548== by 0x3F7442: _initialize_cli_cmds() (cli-cmds.c:1768) ==25548== by 0x69EED3: initialize_all_files() (init.c:365) ==25548== by 0x658A84: gdb_init(char*) (top.c:2163) ==25548== by 0x5403E1: captured_main_1 (main.c:863) ==25548== by 0x5403E1: captured_main (main.c:1167) ==25548== by 0x5403E1: gdb_main(captured_main_args*) (main.c:1193) ==25548== by 0x289CA7: main (gdb.c:32) The leak is created by top.c set_verbose 'elaborate joke': the doc string is changed according to the verbosity: (gdb) help set verbose Set verbosity. (gdb) set verbose on (gdb) help set verbose Set verbose printing of informational messages. (gdb) set_verbose creates the leak as it replaces the string allocated in the above stacktrace by a static (non translated) string: ... if (info_verbose) { c->doc = "Set verbose printing of informational messages."; ... Also, this can possibly trigger a call to 'free' of a static string, as c->doc_allocated is kept true, while the string is not allocated anymore. This patch: * fixes the leak by freeing the previous docs if doc_allocated. * internationalize the messages. * properly sets doc_allocated to 0 once doc strings are static. gdb/ChangeLog 2018-12-28 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.c (set_verbose): Free previous docs if doc_allocated. Internationalize messages. Set doc_allocated to 0.
2018-12-28Avoid internal errors when stepping outside 'main' on MinGWEli Zaretskii2-2/+10
When one steps with "next" past the 'main's 'return' statement in MinGW programs built by mingw.org's tools, PC lands in a function whose symbol is not in any symtab. GDB then looks up the nearest symbol, and should find none, because all those with addresses below PC are not real functions. Having unresolved symbols, whose address is zero, in minsyms tricked GDB into using these bogus symbols, which then caused assertion violation and internal_error. See the discussion at https://sourceware.org/ml/gdb-patches/2018-12/msg00176.html for more details. gdb/ChangeLog 2018-12-28 Eli Zaretskii <eliz@gnu.org> * coffread.c (coff_symtab_read): Don't record in minsyms symbols that are unresolved. This avoids triggering an internal error when stepping outside of 'main' in MinGW programs.
2018-12-28PR24015, glibc-2.28 on little-endian mips32 brokenAlan Modra3-2/+10
Commit 2bf2bf23da exposed a bug on targets that create common sections other than the standard ELF SHN_COMMON. If these are output by ld -r, then their type becomes SHT_PROGBITS unless the target handles them specially (eg. by elf_backend_special_sections), and if they are merged into .bss/.sbss by ld -r then that section becomes SHT_PROGBITS. Worse, if they are output by ld -r, then their size is increased by bfd_generic_define_common_symbol during final link, which leads to bogus file contents being copied to output. For mips, it seems to me that the .scommon section should not be output for ld -r, but I haven't made that change in this patch. PR 24015 * elf.c (bfd_elf_get_default_section_type): Make common sections SHT_NOBITS. * linker.c (bfd_generic_define_common_symbol): Clear SEC_HAS_CONTENTS.
2018-12-28PR23966, mingw failure due to 32-bit longAlan Modra2-2/+13
PR 23966 * libbfd.c (SSIZE_MAX): Define. (bfd_malloc, bfd_realloc): Don't cast size to long to check for "negative" values, compare against SSIZE_MAX instead.
2018-12-28PR24028, PPC_INT_FMTAlan Modra4-18/+21
PPC_INT_FMT is redundant now that bfd.h pulls in inttypes.h if available. Apparently MacOS Mojave defines int64_t as long long even though long is also 64 bits, which confuses the logic selecting PPC_INT_FMT (and BFD_PRI64 too). Hopefully inttypes.h is available on Mojave. PR 24028 include/ * opcode/ppc.h (PPC_INT_FMT): Delete. opcodes/ * ppc-dis.c (print_insn_powerpc): Replace PPC_INT_FMT uses with PRId64/PRIx64.
2018-12-28Automatic date update in version.inGDB Administrator1-1/+1
2018-12-27Translate PyExc_KeyboardInterrupt to gdb "quit"Tom Tromey4-1/+53
A while back I typed "info pretty-printers" with a large number of printers installed, and I typed "q" to stop the pagination. I noticed that gdb printed a Python exception in this case. It seems to me that, instead, quitting pagination (or control-c'ing a Python command generally) should be handled the same way that gdb normally handles a quit. This patch implements this idea by changing gdbpy_handle_exception to treat PyExc_KeyboardInterrupt specially. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * python/py-utils.c (gdbpy_handle_exception): Translate PyExc_KeyboardInterrupt to quit. gdb/testsuite/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * gdb.python/py-cmd.exp (test_python_inline_or_multiline): Add pagination test.
2018-12-27Consolidate some Python exception-printing functionsTom Tromey5-24/+29
A few places in the Python code would either call gdbpy_print_stack, or throw a gdb "quit", depending on the pending exception. This patch consolidates these into a helper function. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * python/python-internal.h (gdbpy_print_stack_or_quit): Declare. * python/py-unwind.c (pyuw_sniffer): Use gdbpy_print_stack_or_quit. * python/py-framefilter.c (throw_quit_or_print_exception): Remove. (gdbpy_apply_frame_filter): Use gdbpy_print_stack_or_quit. * python/python.c (gdbpy_print_stack_or_quit): New function.
2018-12-27Use gdbpy_convert_exception in a few more spotsTom Tromey5-12/+13
I noticed a few places were converting a gdb exception to a Python exception "by hand". It's better to use the existing gdbpy_convert_exception helper function, as this handles memory errors correctly, and in the future may be enhanced in other ways. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * python/py-value.c (convert_value_from_python): Use gdbpy_convert_exception. * python/py-param.c (parmpy_init): Use gdbpy_convert_exception. * python/py-cmd.c (cmdpy_init): Use gdbpy_convert_exception. * python/py-breakpoint.c (bppy_init): Use gdbpy_convert_exception.
2018-12-27Build gdb "nat" files in subdirectoryTom Tromey3-39/+50
This moves the various "nat" object files into the nat/ subdirectory. This allows for the removal of a pattern rule from the gdb Makefile, which is a small cleanup. I made the configure.nat change in a (semi-) automated way, hopefully meaning that it is more likely to be correct than had I done it by hand. Eventually I would like for the various configure scripts to only mention source files, and let the Makefile compute the object file names. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * configure.nat (NATDEPFILES): Use nat/ prefix. * Makefile.in (CONFIG_SRC_SUBDIR): Add nat. (%.o: ${srcdir}/nat/%.c): Remove rule. (INIT_FILES): Do not filter out NATDEPFILES.
2018-12-27Make init.c depend on source filesTom Tromey2-24/+17
I noticed that init.c depends on the object files that go into gdb. Because init.c actually only requires the contents of the corresponding source files, this unnecessarily serializes the step that builds init.c. This patch changes gdb's Makefile to make init.c depend on the source files. This also simplifies the rule to build init.c. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * Makefile.in (INIT_FILES): Redefine. (stamp-init): Remove sed, tr invocations. Use for loop. Don't set LANG or LC_ALL.
2018-12-27Remove gdbtypes special case from init.c ruleTom Tromey2-15/+5
The rule to make init.c has a special case for gdbtypes, with a long explanatory comment. All of this is obsolete, as the globals referred to by the comment no longer exist. This patch simplifies the rule. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * Makefile.in (stamp-init): Remove gdbtypes special case.
2018-12-27Remove empty nm-fbsd.h header for FreeBSD/i386 native target.John Baldwin4-25/+6
gdb/ChangeLog: * config/i386/nm-fbsd.h: Remove file. * Makefile.in (HFILES_NO_SRCDIR): Remove config/i386/nm-fbsd.h. * configure.nat: Remove NAT_FILE for FreeBSD/i386.
2018-12-27Use DISABLE_COPY_AND_ASSIGN in minimal_symbol_readerTom Tromey2-4/+6
This changes minimal_symbol_reader to use DISABLE_COPY_AND_ASSIGN, rather than the manual approach it currently uses. Tested by rebuilding. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * minsyms.h (class minimal_symbol_reader): Use DISABLE_COPY_AND_ASSIGN.
2018-12-27Remove more calls to xfree from PythonTom Tromey8-57/+40
This changes the Python code to remove some more calls to xfree, in favor of self-managing data structures. Tested on x86-64 Fedora 28. gdb/ChangeLog 2018-12-27 Tom Tromey <tom@tromey.com> * python/python.c (python_interactive_command): Use std::string. (gdbpy_parameter): Likewise. * python/py-utils.c (unicode_to_encoded_string): Update comment. * python/py-symtab.c (salpy_str): Use PyString_FromFormat. * python/py-record-btrace.c (recpy_bt_insn_data): Use byte_vector. * python/py-objfile.c (objfpy_get_build_id): Use unique_xmalloc_ptr. * python/py-inferior.c (infpy_read_memory): Use unique_xmalloc_ptr. * python/py-cmd.c (gdbpy_parse_command_name): Use std::string.
2018-12-27Fix gdb.ada/fun_renaming.exp by using more unique names.Philippe Waroquiers4-14/+16
The test fails due to conflict between var 'next' and s-pooloc.adb next: (gdb) print next(1) Multiple matches for next [0] cancel [1] pack.next (integer) return integer at /bd/home/philippe/gdb/git/binutils-gdb/gdb/testsuite/gdb.ada/fun_renaming/pack.adb:19 [2] system.pool_local.next (system.address) return system.pool_local.acc_address at s-pooloc.adb:151 > FAIL: gdb.ada/fun_renaming.exp: print next(1) (timeout) Fix by making the names and renamings more unique. gdb/testsuite/ChangeLog 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/fun_renaming/pack.ads (Next): Rename to Fun_Rename_Test_Next. (Renamed_Next): Rename to Renamed_Fun_Rename_Test_Next. gdb.ada/fun_renaming/pack.adb (Next): Rename to Fun_Rename_Test_Next. gdb.ada/fun_renaming/fun_renaming.adb (N): Rename to Fun_Rename_Test_N. gdb.ada/fun_renaming.exp: Update accordingly.
2018-12-27Fix gdb.ada/assign_arr.exp by using more unique names.Philippe Waroquiers3-3/+3
The test fails (timeout) due to conflict between var 'input' and s-ststop.adb 'input': (gdb) print input.u2 := (0.25,0.5,0.75) Multiple matches for input [0] cancel [1] system.strings.stream_ops.storage_array_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return system.storage_elements.storage_array at s-ststop.adb:127 [2] system.strings.stream_ops.stream_element_array_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return ada.streams.stream_element_array at s-ststop.adb:127 [3] system.strings.stream_ops.string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return string at s-ststop.adb:127 [4] system.strings.stream_ops.wide_string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return wide_string at s-ststop.adb:127 [5] system.strings.stream_ops.wide_wide_string_ops.input (access ada.streams.root_stream_type; system.strings.stream_ops.io_kind; natural) return wide_wide_string at s-ststop.adb:127 [6] target_wrapper.input at /bd/home/philippe/gdb/git/info_t/gdb/testsuite/gdb.ada/assign_arr/target_wrapper.ads:24 > FAIL: gdb.ada/assign_arr.exp: print input.u2 := (0.25,0.5,0.75) (timeout) gdb/testsuite/ChangeLog 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.ada/assign_arr/target_wrapper.ads (Input): Rename to Assign_Arr_Input. main_p324_051.adb: Update accordingly. gdb.ada/assign_arr.exp: Likewise.
2018-12-27Improve gdb.ada/rename_subscript_param.exp by using more unique names.Philippe Waroquiers2-6/+6
With old compilers, the test fails because no debug info is generated for 'B' and GDB finds some 'b' in atnat.h: (gdb) print b Multiple matches for b [0] cancel [1] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 [2] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 [3] b at ../sysdeps/ieee754/dbl-64/atnat.h:106 > FAIL: gdb.ada/rename_subscript_param.exp: print b before changing its value (timeout) Avoid the timeout by renaming 'b' to rename_subscript_param_b. Also, change 'before' to 'after' in the gdb_test message that prints the value after changing it. The test still fails with old compilers that do not properly generate debug info for this renaming: (gdb) print rename_subscript_param_b No definition of "rename_subscript_param_b" in current context. (gdb) FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b before changing its value Note: if the compiler would generate the correct debug info, the test should succeed with the name B. However, waiting for this fix, changing the name ensures that the test fails directly, instead of causing a timeout. 2018-12-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> PR ada/23381 * gdb.ada/rename_subscript_param/pkg.adb (B): Rename to Rename_Subscript_Param_B. All users updated. gdb.ada/rename_subscript_param.exp: Test names made unique. Note that PR ada/23381 is only fully fixed when using a recent compiler.