binutils-gdb.git
4 years agogdb/copyright.py: Convert to Python 3
Joel Brobecker [Wed, 1 Jan 2020 06:12:57 +0000 (10:12 +0400)]
gdb/copyright.py: Convert to Python 3

gdb/ChangeLog:

        * copyright.py: Convert to Python 3.

4 years agogdb/copyright.py: Adapt after move of gnulib from gdb to toplevel
Joel Brobecker [Wed, 1 Jan 2020 05:19:14 +0000 (09:19 +0400)]
gdb/copyright.py: Adapt after move of gnulib from gdb to toplevel

gdb/ChangeLog:

* copyright.py: Adapt after move of gnulib directory from gdb
directory to toplevel directory.

4 years agogdb/copyright.py: Exit if run from the wrong directory
Joel Brobecker [Wed, 1 Jan 2020 05:08:08 +0000 (09:08 +0400)]
gdb/copyright.py: Exit if run from the wrong directory

We printed an error, but kept going anyway... ;-)

gdb/ChangeLog:

* copyright.py (main): Exit if run from the wrong directory.

4 years agoupdate copyright year in version output of gdb, gdbserver and gdbreplay
Joel Brobecker [Wed, 1 Jan 2020 04:43:08 +0000 (08:43 +0400)]
update copyright year in version output of gdb, gdbserver and gdbreplay

gdb/ChangeLog:

        * top.c (print_gdb_version): Change copyright year to 2020.

gdb/gdbserver/ChangeLog:

        * server.c (gdbserver_version): Change copyright year to 2020.
        * gdbreplay.c (gdbreplay_version): Likewise.

4 years agoRotate gdb/ChangeLog (start of New Year procedure)
Joel Brobecker [Wed, 1 Jan 2020 04:40:23 +0000 (08:40 +0400)]
Rotate gdb/ChangeLog (start of New Year procedure)

gdb/ChangeLog:

* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2019

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Jan 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoasan: alpha-vms: Heap-buffer-overflow
Alan Modra [Tue, 31 Dec 2019 11:54:31 +0000 (22:24 +1030)]
asan: alpha-vms: Heap-buffer-overflow

This fixes yet more errors in the alpha-vms buffer size checks.

* vms-alpha.c (_bfd_vms_slurp_eisd): Don't overflow when checking
offset.  Don't overflow when checking rec_size, and do allow
rec_size to the end of the buffer.  Ensure eisd->type can be
accessed, not just the first 32 bytes.  Don't call
_bfd_vms_save_counted_string with zero length remaining.  Fail
on empty string section name.
(_bfd_vms_slurp_egsd): Formatting.  Catch more reads past end
of record size.  Correct remaining length calculation.  Fail
on empty string section name.  Consolidate error paths.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 31 Dec 2019 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoMake some TUI globals "static"
Tom Tromey [Mon, 30 Dec 2019 16:11:32 +0000 (09:11 -0700)]
Make some TUI globals "static"

This changes a few TUI globals to be "static".  Tested by rebuilding.

gdb/ChangeLog
2019-12-30  Tom Tromey  <tom@tromey.com>

* tui/tui-win.c (tui_border_mode_translate)
(tui_border_kind_translate_vline, tui_border_kind_translate_hline)
(tui_border_kind_translate_ulcorner)
(tui_border_kind_translate_urcorner)
(tui_border_kind_translate_llcorner)
(tui_border_kind_translate_lrcorner, tui_active_border_mode)
(tui_border_mode, tui_border_kind): Now static.

Change-Id: Ibb49a0df195dfe780a5ba1f90e9125ab5f6b7ce1

4 years agoUse "bool" in more spots in TUI
Tom Tromey [Mon, 30 Dec 2019 16:07:33 +0000 (09:07 -0700)]
Use "bool" in more spots in TUI

This changes a few spots in the TUI to use "bool" rather than "int".
Tested on x86-64 Fedora 28.

gdb/ChangeLog
2019-12-30  Tom Tromey  <tom@tromey.com>

* tui/tui-interp.c (tui_start_enabled): Now bool.
(_initialize_tui_interp): Update.
* tui/tui-hooks.c (tui_refreshing_registers): Now bool.
(tui_register_changed)
(tui_refresh_frame_and_register_information): Update.
* tui/tui-win.c (tui_update_variables): Return bool.
* tui/tui-win.h (tui_update_variables): Return bool.
* tui/tui.c (tui_get_command_dimension): Return bool.
* tui/tui.h (tui_get_command_dimension): Return bool.

Change-Id: I55b7f2d62d2ef88da3587dc914ada9f463ad8d2b

4 years agovms-alpha.c object_p memory leaks
Alan Modra [Mon, 30 Dec 2019 11:10:08 +0000 (21:40 +1030)]
vms-alpha.c object_p memory leaks

* vms-alpha.c (alpha_vms_free_private): New function, extracted..
(vms_close_and_cleanup): ..from here.
(alpha_vms_object_p): Call alpha_vms_free_private on failure.

4 years agocoff object_p memory leaks
Alan Modra [Mon, 30 Dec 2019 10:47:08 +0000 (21:17 +1030)]
coff object_p memory leaks

* coffgen.c (coff_real_object_p): Free malloc'd memory on failure.

4 years agoarchive.c bfd_zalloc
Alan Modra [Mon, 30 Dec 2019 01:18:20 +0000 (11:48 +1030)]
archive.c bfd_zalloc

Quite a few bfd_zalloc calls are wasting time clearing memory, and
should be bfd_alloc instead.

* archive.c (do_slurp_bsd_armap): Use bfd_alloc rather than
bfd_zalloc when memory is all written after the call.
(do_slurp_coff_armap): Likewise.  Set bfd_error on ridiculously
large allocations that overflow bfd_size_type.  Use just one
bfd_release on error exit.
(_bfd_slurp_extended_name_table): Use bfd_alloc for extended_names,
clear last byte rather than the entire array.  Use bfd_alloc for
string table.  Rearrange and simplify code copying file names.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Dec 2019 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRe: Revise sleb128 and uleb128 reader
Alan Modra [Sun, 29 Dec 2019 23:03:46 +0000 (09:33 +1030)]
Re: Revise sleb128 and uleb128 reader

A missing part of git commit cd30bcef4a685.

* od-macho.c: Include elfcomm.h.
(dump_dyld_info_rebase, dump_dyld_info_bind): Fix read_leb128 args.
(dump_dyld_info_export_1, dump_segment_split_info): Likewise.

4 years agoRe: Usage of unitialized heap in tic4x_print_cond
Alan Modra [Sun, 29 Dec 2019 22:49:25 +0000 (09:19 +1030)]
Re: Usage of unitialized heap in tic4x_print_cond

PR 25319
* tic4x-dis.c (tic4x_print_cond): Correct order of xcalloc args.

4 years agoFix setting breakpoints or stepping on line 65535
Bernd Edlinger [Sat, 23 Nov 2019 06:37:26 +0000 (07:37 +0100)]
Fix setting breakpoints or stepping on line 65535

This removes code that was present from the very first git revisison
7b4ac7e1ed2c4616bce56d1760807798be87ac9e from 1988.  It was in the
gdb/dbxread.c at the time (and makes more sense for dbx line info format
since line numbers are 16-bit entities in that debug format and debugging
files with more than 65535 lines would not work anyway) but moved from
there to gdb/buildsym.c which is used for dwarf line info as well, and
excluding an arbitrary line number does certainly not make sense nowadays.

Add a test case for line 65535

gdb:
2019-12-29  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* buildsym.c (buildsym_compunit::record_line): Do no longer ignore
line 65535.

gdb/testsuite:
2019-12-29  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* gdb.base/line65535.exp: New file.
* gdb.base/line65535.c: New file.

4 years agoubsan: sparc: left shift cannot be represented in type 'int'
Alan Modra [Sun, 29 Dec 2019 02:27:42 +0000 (12:57 +1030)]
ubsan: sparc: left shift cannot be represented in type 'int'

* sparc-dis.c (SEX): Don't use left and right shift to sign extend.
(compare_opcodes): Avoid signed shift left overflow.
(print_insn_sparc): Likewise.

4 years agoUsage of unitialized heap in tic4x_print_cond
Alan Modra [Sun, 29 Dec 2019 02:26:29 +0000 (12:56 +1030)]
Usage of unitialized heap in tic4x_print_cond

PR 25319
* tic4x-dis.c (tic4x_print_cond): Init all of condtable.

4 years agoubsan: alpha-vms: shift exponent is too large
Alan Modra [Sun, 29 Dec 2019 02:26:04 +0000 (12:56 +1030)]
ubsan: alpha-vms: shift exponent is too large

* vms-alpha.c (_bfd_vms_slurp_egsd): Make base_addr a bfd_vma.
Limit alignment power.  Correct and simplify alignment expression.
(evax_bfd_print_relocation_records): Avoid signed shift left.

4 years agoasan: alpha-vms: memory leaks
Alan Modra [Sun, 29 Dec 2019 02:25:34 +0000 (12:55 +1030)]
asan: alpha-vms: memory leaks

* vms-misc.c (_bfd_vms_save_sized_string): Add abfd param, make
size a size_t.  Use bfd_alloc rather than bfd_malloc.
(_bfd_vms_save_counted_string): Similarly.
* vms.h (_bfd_vms_save_sized_string): Update prototype.
(_bfd_vms_save_counted_string): Likewise.
* vms-alpha.c (_bfd_vms_slurp_ehdr): Adjust
_bfd_vms_save_counted_string and bfd_vms_save_sized_string calls.
(_bfd_vms_slurp_egsd, parse_module): Likewise.
(_bfd_vms_slurp_eisd): Likewise.  Check return status.
(alpha_vms_bfd_link_hash_table_free): New function.
(alpha_vms_bfd_link_hash_table_create): Arrange to call it.
(vms_close_and_cleanup): Free more memory.  Don't release tdata.

4 years agocoff_close_and_cleanup
Alan Modra [Sun, 29 Dec 2019 02:25:20 +0000 (12:55 +1030)]
coff_close_and_cleanup

Fixes leaks in _bfd_coff_get_external_symbols and
_bfd_coff_read_string_table.

* coffcode.h (coff_close_and_cleanup): Redefine to..
* coffgen.c (_bfd_coff_close_and_cleanup): ..this.  New function.
* libcoff-in.h (_bfd_coff_close_and_cleanup): Declare.
* libcoff.h: Regenerate.

4 years agoPR15350, Fix compressed debug sections for PE targets
Alan Modra [Sun, 29 Dec 2019 02:11:12 +0000 (12:41 +1030)]
PR15350, Fix compressed debug sections for PE targets

PR 15350
* bfd.c (bfd_update_compression_header): Write zlib header for
formats other than ELF too.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Dec 2019 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[PATCH] Adjust test gdb.ada/ptype_tagged_param.exp for when GNAT runtime does not...
Simon Marchi [Sat, 28 Dec 2019 01:58:42 +0000 (20:58 -0500)]
[PATCH] Adjust test gdb.ada/ptype_tagged_param.exp for when GNAT runtime does not have debug info

This test verifies that GDB correctly identifies the run-time type of
"s" as being the type "Circle".  However, that can only be done
correctly if the GNAT runtime has been compiled and shipped with debug
information, so that GDB can poke in its internal data structures.
Currently the test fails when when running against a GNAT runtime
without debug info.  This is the case, for example, on Arch Linux using
the distribution package.

This patch adds a helper in lib/ada.exp to check whether the GNAT
runtime has debug info or not.  It then uses it in
gdb.ada/ptype_tagged_param.exp to expect a different result, depending
on whether we have debug info or not in the runtime.

At first, I made it so we would XFAIL the test, in the absence of debug
info, but then I thought that we might as well test for the output we
expect in the absence of debug info instead.

gdb/testsuite/ChangeLog:

* lib/ada.exp (gnat_runtime_has_debug_info): New proc.
* lib/gnat_debug_info_test.adb: New file.
* gdb.ada/ptype_tagged_param.exp: Use
gnat_runtime_has_debug_info, expect a different output if
runtime does not have debug info.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 28 Dec 2019 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoRemove dead code from TUI
Tom Tromey [Fri, 27 Dec 2019 16:43:35 +0000 (09:43 -0700)]
Remove dead code from TUI

I found some dead code in the TUI -- some using #if 0, and some
commented-out code.  There's no reason to keep this, so this patch
removes it.

gdb/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

* tui/tui-source.c (tui_source_window::do_scroll_vertical): Remove
commented-out code.
* tui/tui.c: Remove #if 0 code.

Change-Id: Ie00933b2ba498417ce22e5da3f62f5a40c234f33

4 years agoReorder an "if" in print_disassembly
Tom Tromey [Tue, 24 Dec 2019 23:43:51 +0000 (16:43 -0700)]
Reorder an "if" in print_disassembly

I noticed that print_disassembly has two #if blocks for TUI code,
where one would do.  This patch rearranges the code slightly to remove
a #if.

gdb/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

* cli/cli-cmds.c (print_disassembly): Reorder "if".

Change-Id: I36f3f682f5685b3d9b148da5aed26eb3cc7d598e

4 years agoChange tui_active to bool
Tom Tromey [Sat, 21 Dec 2019 17:41:25 +0000 (10:41 -0700)]
Change tui_active to bool

This changes tui_active and tui_finish_init to have type "bool".

gdb/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_active): Now bool.
(tui_finish_init): Likewise.
(tui_enable): Update.
(tui_disable): Update.
(tui_is_window_visible): Update.
* tui/tui.h (tui_active): Now bool.

Change-Id: Ia159ae9beb041137e34956b77f5bcf4e83eaf2b9

4 years agoRemove tui_gen_win_info::viewport_height
Tom Tromey [Sat, 21 Dec 2019 17:35:59 +0000 (10:35 -0700)]
Remove tui_gen_win_info::viewport_height

tui_gen_win_info::viewport_height is only used in a couple of spots,
and is redundant with "height".  This patch removes viewport_height.

gdb/ChangeLog
2019-12-27  Tom Tromey  <tom@tromey.com>

* tui/tui-source.c (tui_source_window::maybe_update): Update.
* tui/tui-regs.c (tui_data_window::display_registers_from):
Update.
* tui/tui-layout.c (tui_gen_win_info::resize): Update.
* tui/tui-data.h (struct tui_gen_win_info) <viewport_height>:
Remove.
* tui/tui-command.c (tui_cmd_window::resize): Update.

Change-Id: I020e026fbe289adda8e2fdfebca91bdbdbc312e8

4 years agox86: adjust ignored prefix warning for branches
Jan Beulich [Fri, 27 Dec 2019 08:39:58 +0000 (09:39 +0100)]
x86: adjust ignored prefix warning for branches

There's no reason to not also issue them in Intel syntax mode, and it
can be quite helpful to mention the actual insn (after all there can be
multiple on a single line).

4 years agox86-64: correct / adjust prefix emission
Jan Beulich [Fri, 27 Dec 2019 08:39:17 +0000 (09:39 +0100)]
x86-64: correct / adjust prefix emission

First and foremost REX must come last. Next JumpInterSegment branches
can't possibly have a REX prefix, as they're consistently CpuNo64. And
finally make BND prefix handling in output_branch() consistent with that
of other prefixes in the same function, and make its placement among
prefixes consistent with output_jump() (which, oddly enough, still isn't
the supposedly canonical order specified by the *_PREFIX definitions).

4 years agox86-64: fix Intel64 handling of branch with data16 prefix
Jan Beulich [Fri, 27 Dec 2019 08:38:34 +0000 (09:38 +0100)]
x86-64: fix Intel64 handling of branch with data16 prefix

The expectation of x86-64-branch-3 for "call" / "jmp" with an obvious
direct destination to translate to an indirect _far_ branch is plain
wrong. The operand size prefix should have no effect at all on the
interpretation of the operand. The main underlying issue here is that
the Intel64 templates of the direct branches don't include Disp16, yet
various assumptions exist that it would always be there when there's
also Disp32/Disp32S, toggled by the operand size prefix (which is
being ignored by direct branches in Intel64 mode).

Along these lines it was also wrong to base the displacement width
decision solely on the operand size prefix: REX.W cancels this effect
and hence needs taking into consideration, too.

A disassembler change is needed here as well: XBEGIN was wrongly treated
the same as direct CALL/JMP, which isn't the case - the operand size
prefix does affect displacement size there, it's merely ignored when it
comes to updating [ER]IP.

4 years agox86: consolidate Disp<NN> handling a little
Jan Beulich [Fri, 27 Dec 2019 08:22:03 +0000 (09:22 +0100)]
x86: consolidate Disp<NN> handling a little

In memory operand addressing, which forms of displacement are permitted
besides Disp8 is pretty clearly limited
- outside of 64-bit mode, Disp16 or Disp32 only, depending on address
  size (MPX being special in not allowing Disp16),
- in 64-bit mode, Disp32s or Disp64 without address size override, and
  solely Disp32 with one.
Adjust assembler and i386-gen to match this, observing that templates
already get adjusted before trying to match them against input depending
on the presence of an address size prefix.

This adjustment logic gets extended to all cases, as certain DispNN
values should also be dropped when there's no such prefix. In fact
behavior of the assembler, perhaps besides the exact diagnostics wording,
should not differ between there being templates applicable to 64-bit and
non-64-bit at the same time, or there being fully separate sets of
templates, with their DispNN settings already reduced accordingly.

This adjustment logic further gets guarded such that there wouldn't be
and Disp<N> conversion based on address size prefix when this prefix
doesn't control the width of the displacement (on branches other than
absolute ones).

These adjustments then also allow folding two MOV templates, which had
been split between 64-bit and non-64-bits variants so far.

Once in this area also
- drop the bogus DispNN from JumpByte templates, leaving just the
  correct Disp8 there (compensated by i386_finalize_displacement()
  now setting Disp8 on their operands),
- add the missing Disp32S to XBEGIN.

Note that the changes make it necessary to temporarily mark a test as
XFAIL; this will get taken care of by a subsequent patch. The failing
parts are entirely bogus and will get replaced.

4 years agoMake symbol_set_names a member function
Christian Biesinger [Thu, 28 Nov 2019 02:52:35 +0000 (20:52 -0600)]
Make symbol_set_names a member function

This also renames it to make it clearer that this is not a cheap
function (to compute_and_set_names).  Also renames name to m_name
to make the implementation of the renamed function more readable.

Most of the places that access sym->m_name directly were also changed
to call linkage_name () instead, to make it clearer which name they
are accessing.

gdb/ChangeLog:

2019-12-26  Christian Biesinger  <cbiesinger@google.com>

* ada-lang.c (ada_decode_symbol): Update.
* buildsym.c (add_symbol_to_list): Update.
* coffread.c (process_coff_symbol): Update.
* ctfread.c (ctf_add_enum_member_cb): Update.
(new_symbol): Update.
(ctf_add_var_cb): Update.
* dwarf2read.c (fixup_go_packaging): Update.
(dwarf2_compute_name): Update.
(new_symbol): Update.
* jit.c (finalize_symtab): Update.
* language.c (language_alloc_type_symbol): Update.
* mdebugread.c (new_symbol): Update.
* minsyms.c (minimal_symbol_reader::record_full): Update.
(minimal_symbol_reader::install): Update.
* psymtab.c (print_partial_symbols): Update.
(psymbol_hash): Update.
(psymbol_compare): Update.
(add_psymbol_to_bcache): Update.
(maintenance_check_psymtabs): Update.
* stabsread.c (define_symbol): Update.
* symtab.c (symbol_set_names): Rename to...
(general_symbol_info::compute_and_set_names): ...this.
(general_symbol_info::natural_name): Update.
(general_symbol_info::search_name): Update.
(fixup_section): Update.
* symtab.h (struct general_symbol_info) <name>: Rename to...
<m_name>: ...this.
<compute_and_set_names>: Rename from...
(symbol_set_names): ...this.
(SYMBOL_SET_NAMES): Remove.
(struct symbol) <ctor>: Update.

Change-Id: I8da1f10cab4e0b89f19d5750fa4e6e2ac8d2b24f

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Dec 2019 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAdd a NEWS entry for multithreaded symbol loading
Christian Biesinger [Fri, 20 Dec 2019 00:24:22 +0000 (18:24 -0600)]
Add a NEWS entry for multithreaded symbol loading

Now that we enabled it by default, this change adds a NEWS entry for it.

gdb/ChangeLog:

2019-12-26  Christian Biesinger  <cbiesinger@google.com>

* NEWS: Mention that multithreaded symbol loading is now on by
default.

Change-Id: Ic344596a3b1b6e612a0071a50df49588b833c15d

4 years agoAvoid ubsan bug complaining about &p->field
Alan Modra [Tue, 26 Nov 2019 06:19:44 +0000 (16:49 +1030)]
Avoid ubsan bug complaining about &p->field

I reckon it's quite OK to write &p->field in C when p might be NULL,
and lots of old C programmers probably agree with me.  However, ubsan
disagrees and so do some people I respect.  I suspect C++ influence is
to blame for the ubsan behaviour.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92634.  So far no one has
educated me as to why I'm wrong to claim that there isn't anything in
the C standard to say that p->field is always (*p).field.  Note 79
doesn't quite do that because it doesn't cover null pointers.  If
there was such an equivalence then you could claim &p->field has a
null pointer reference when p is NULL, even though no C compiler would
ever dereference p.

Anyway, to silence ubsan I'm going to apply the following though I
prefer to avoid casts when possible.  And I'm using (void *)
deliberately because this is C, not C++!

* ldlang.c (lang_output_section_find_by_flags): Don't use &p->field
when p might be NULL.
* ldelf.c (output_rel_find, ldelf_place_orphan): Likewise.
(insert_os_after, lang_insert_orphan, lookup_name): Likewise.
(strip_excluded_output_sections, lang_clear_os_map): Likewise.
(lang_check, lang_for_each_input_file): Likewise.
(lang_reset_memory_regions, find_replacements_insert_point): Likewise.
(find_rescan_insertion, lang_propagate_lma_regions): Likewise.
(lang_record_phdrs): Likewise.
* emultempl/alphaelf.em (alpha_after_open): Likewise.
* emultempl/mmo.em (mmo_place_orphan): Likewise.
* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
* emultempl/ppc32elf.em (ppc_after_check_relocs): Likewise.
* emultempl/spuelf.em (spu_before_allocation): Likewise.
(embedded_spu_file): Likewise.

4 years agoubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'
Alan Modra [Thu, 26 Dec 2019 05:34:20 +0000 (16:04 +1030)]
ubsan: crx: index 5 out of bounds for type 'operand_desc const[5]'

* crx-dis.c (get_number_of_operands): Don't access operands[]
out of bounds.

4 years agoubsan: v850: left shift cannot be represented in type 'int'
Alan Modra [Thu, 26 Dec 2019 05:26:25 +0000 (15:56 +1030)]
ubsan: v850: left shift cannot be represented in type 'int'

Another 1 << 31 complaint.

* v850-dis.c (disassemble): Avoid signed overflow.  Don't use
long vars when unsigned int will do.

4 years agoasan: som: heap-buffer-overflow
Alan Modra [Thu, 26 Dec 2019 01:55:31 +0000 (12:25 +1030)]
asan: som: heap-buffer-overflow

Triggered by overflow of size calulation resulting in a too small
buffer.  The testcase found one of the som_bfd_count_ar_symbols
problems.

* som.c (setup_sections): Don't overflow space_strings_size.  Use
bfd_malloc2 to catch overflow of size calculation.
(som_prep_for_fixups): Use bfd_zalloc2 to catch overflow of size
calculation.
(som_build_and_write_symbol_table): Similarly use bfd_zmalloc2.
(som_slurp_symbol_table): Similarly use bfd_zmalloc2, bfd_malloc2,
and bfd_zalloc2.
(bfd_som_attach_aux_hdr): Use size_t vars for string length.
(som_bfd_count_ar_symbols): Use bfd_malloc2 to catch overflow of
size calculation.  Use size_t vars for length and catch overflow.
(som_slurp_armap): Use bfd_alloc2 to catch overflow of size
calculation.
(som_bfd_ar_write_symbol_stuff): Similarly use bfd_zmalloc2 and
bfd_malloc2.  Perform size calculations in bfd_size_type.

4 years agoAdd profiling outputs to .gitignore
Christian Biesinger [Thu, 19 Dec 2019 21:19:26 +0000 (15:19 -0600)]
Add profiling outputs to .gitignore

"perf record" creates files perf.data/perf.data.old; these can be safely
ignored in .gitignore, to avoid showing up in git status.

ChangeLog:

2019-12-26  Christian Biesinger  <cbiesinger@google.com>

* .gitignore: Add perf.data and perf.data.old.

Change-Id: I214ae9d6b7265c2cb1356f11c9b0b82e2b391352

4 years agope_bfd_read_buildid memory leak
Hannes Domani [Thu, 26 Dec 2019 01:54:45 +0000 (12:24 +1030)]
pe_bfd_read_buildid memory leak

* peicode.h (pe_bfd_read_buildid): Free data.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Dec 2019 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix printing ULONGEST variables on x86-32
Ruslan Kabatsayev [Wed, 25 Dec 2019 21:09:40 +0000 (00:09 +0300)]
Fix printing ULONGEST variables on x86-32

gdb/ChangeLog
2019-12-26  Ruslan Kabatsayev  <b7.10110111@gmail.com>

        * dwarf2read.c (is_valid_DW_AT_defaulted)
        (is_valid_DW_AT_calling_convention_for_type)
        (is_valid_DW_AT_calling_convention_for_subroutine): Fix printing
        ULONGEST variables on x86-32.

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Dec 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoubsan: arm: shift exponent 32 is too large for 32-bit type 'unsigned int'
Alan Modra [Mon, 23 Dec 2019 23:41:40 +0000 (10:11 +1030)]
ubsan: arm: shift exponent 32 is too large for 32-bit type 'unsigned int'

* arm-dis.c (print_insn_arm): Don't shift by 32 on unsigned int var.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Dec 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoFix compilation of Readline on mingw.org's MinGW
Eli Zaretskii [Mon, 23 Dec 2019 14:28:32 +0000 (16:28 +0200)]
Fix compilation of Readline on mingw.org's MinGW

readline/ChangeLog
2019-12-23  Eli Zaretskii  <eliz@gnu.org>

* posixstat.h (S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH)
(S_IXOTH, S_IRWXG, S_IRWXO): Define if undefined, even if S_IRWXU
is defined, because non-Posix systems may defined only the user
bits.

4 years agoFix build 32-bit-host build error last for last binutils/dwarf2.c change.
Hans-Peter Nilsson [Mon, 23 Dec 2019 12:19:59 +0000 (13:19 +0100)]
Fix build 32-bit-host build error last for last binutils/dwarf2.c change.

* dwarf.c (display_debug_lines_decoded): Cast printf parameter to
format type to correct last change.

4 years agoppc: misc minor build corrections
Jan Beulich [Mon, 23 Dec 2019 10:53:10 +0000 (11:53 +0100)]
ppc: misc minor build corrections

Avoid shadowing a libiberty symbol (which oldish gcc warns about by
default), and allow building cleanly on 32-bit distros.

4 years agoasan: vms-alpha: heap-buffer-overflow
Alan Modra [Mon, 23 Dec 2019 07:36:23 +0000 (18:06 +1030)]
asan: vms-alpha: heap-buffer-overflow

Two buffer overflows, and some over restrictive length checks.

* vms-alpha.c (add_symbol): Add "max" parameter.  Error on string
length larger than max.
(_bfd_vms_slurp_egsd): Ensure record is at least large enough to
read string length byte, error if not.  Pass size to add_symbol.
(_bfd_vms_slurp_etir): Don't read past end of buffer when reading
type and length.  Allow read of last byte in buffer.

4 years agoubsan: score: left shift of 2 by 31 places cannot be represented in type 'int'
Alan Modra [Mon, 23 Dec 2019 07:35:19 +0000 (18:05 +1030)]
ubsan: score: left shift of 2 by 31 places cannot be represented in type 'int'

* score-dis.c (print_insn_score32): Avoid signed overflow.
(print_insn_score48): Likewise.  Don't cast to int when printing
hex values.

4 years agoubsan: iq2000: left shift of negative value
Alan Modra [Mon, 23 Dec 2019 07:34:12 +0000 (18:04 +1030)]
ubsan: iq2000: left shift of negative value

cpu/
* iq2000.cpu (f-offset): Avoid left shift of negative values.
opcodes/
* iq2000-ibld.c: Regenerate.

4 years agoubsan: d30v: left shift cannot be represented in type 'long long'
Alan Modra [Mon, 23 Dec 2019 07:32:44 +0000 (18:02 +1030)]
ubsan: d30v: left shift cannot be represented in type 'long long'

* d30v-dis.c (extract_value): Make num param a uint64_t, constify
oper.  Use unsigned vars.
(print_insn): Make num var uint64_t.  Constify oper and remove now
unnecessary casts on extract_value calls.
(print_insn_d30v): Use unsigned vars.  Adjust printf formats.

4 years agoRevise sleb128 and uleb128 reader
Alan Modra [Mon, 23 Dec 2019 07:31:34 +0000 (18:01 +1030)]
Revise sleb128 and uleb128 reader

This patch catches and reports errors when reading leb128 values,
addressing a FIXME in read_leb128.

* dwarf.h (read_leb128): Update prototype.
(report_leb_status): New inline function.
(SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define.
* dwarf.c: Use above macros throughout file.  Formatting.
(read_leb128): Reorder params.  Add status return param.
Don't stop reading until finding terminator or end of data.
Detect loss of significant bits.  Sign extend only on
terminating byte.
(read_sleb128, read_uleb128): Delete functions.
(SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros.
(read_and_print_leb128): Rewrite.
(process_extended_line_op): Return a size_t.  Use size_t vars.
Adjust to suit new macros.  Add proper name size to "data" when
processing DW_LNE_define_file.
(process_abbrev_section): Adjust to suit new macros.
(decode_location_expression, skip_attr_bytes): Likewise.
(get_type_signedness): Likewise.
(read_and_display_attr_value): Likewise.  Consolidate block code.
(process_debug_info): Adjust to suit new macros.
(display_formatted_table, display_debug_lines_raw): Likewise.
(display_debug_lines_decoded): Likewise.  Properly check for end
of DW_LNS_extended_op.
(display_debug_macinfo): Adjust to suit new macros.
(get_line_filename_and_dirname, display_debug_macro): Likewise.
(display_view_pair_list): Likewise.  Don't back off when hitting
end of data.
(display_loc_list): Adjust to suit new macros.
(display_loclists_list, display_loc_list_dwo): Likewise.
(display_debug_rnglists_list, read_cie): Likewise.
(display_debug_frames): Likewise.
* readelf.c: Use new ULEB macros throughout file.
(read_uleb128): Delete.
(decode_arm_unwind_bytecode): Use read_leb128.
(decode_tic6x_unwind_bytecode): Likewise.
(display_tag_value): Adjust to suit new macros.
(display_arc_attribute, display_arm_attribute): Likewise.
(display_gnu_attribute, display_power_gnu_attribute): Likewise.
(display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise.
(display_mips_gnu_attribute, display_tic6x_attribute): Likewise.
(display_msp430x_attribute, display_msp430_gnu_attribute): Likewise.
(display_riscv_attribute, process_attributes): Likewise.

4 years agoubsan: wasm: shift is too large for 64-bit type 'bfd_vma'
Alan Modra [Mon, 23 Dec 2019 07:28:09 +0000 (17:58 +1030)]
ubsan: wasm: shift is too large for 64-bit type 'bfd_vma'

bfd/
* wasm-module.c (wasm_read_leb128): Don't allow oversize shifts.
Catch value overflow.  Sign extend only on terminating byte.
opcodes/
* wasm32-dis.c (wasm_read_leb128): Don't allow oversize shifts.
Catch value overflow.  Sign extend only on terminating byte.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Dec 2019 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 22 Dec 2019 00:01:09 +0000 (00:01 +0000)]
Automatic date update in version.in

4 years agoFix disabling of solib probes when LD_AUDITing
George Barrett [Sun, 15 Dec 2019 00:12:09 +0000 (11:12 +1100)]
Fix disabling of solib probes when LD_AUDITing

The SVR4 solib event handler determines whether an event is related to a
non-base link namespace by comparing the event's debug struct address
to the debug struct address of the initial program image. However, this
can fail when using LD_AUDIT as audit libraries are loaded before the
loader has initialised the initial program image's debug struct. When
the event handler fails to find the debug struct, the probe-based
debugger interface is disabled and a warning is flagged to the user.

This commit adds a fallback test to help determine whether an event is
for a foreign link namespace when the debug struct isn't available.

gdb/ChangeLog:
2019-12-15  George Barrett  <bob@bob131.so>

* solib-svr4.c (svr4_handle_solib_event): Add fallback link
namespace test for when the debug struct isn't available.

4 years agoFix whitespace in last change in top.c
Eli Zaretskii [Sat, 21 Dec 2019 07:40:41 +0000 (09:40 +0200)]
Fix whitespace in last change in top.c

4 years agoInclude xxHash support status in GDB configuration report
Eli Zaretskii [Sat, 21 Dec 2019 07:23:44 +0000 (09:23 +0200)]
Include xxHash support status in GDB configuration report

gdb/ChangeLog
2019-12-21  Eli Zaretskii  <eliz@gnu.org>

* top.c (print_gdb_configuration): Print "--with-xxhash" or
"--without-xxhash" according to HAVE_LIBXXHASH.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 21 Dec 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoAddress Tom Tromey's comments on the CTF reader.
Weimin Pan [Fri, 20 Dec 2019 22:30:17 +0000 (22:30 +0000)]
Address Tom Tromey's comments on the CTF reader.

 * Use the type-safe registry for ctf_file_key;
 * Drop "typedef" when defining "struct ctf_context";
 * Use ANOFFSET with SECT_OFF_TEXT to get the text base address;

gdb/ChangeLog
2019-12-20  Weimin Pan  <weimin.pan@oracle.com>
        * ctfread.c (ctf_file_key): Change type to objfile_key.
        (struct ctf_context): Remove typedef.
        (get_objfile_text_range): Use ANOFFSET to get text base.

4 years agosym-info-cmds.exp: add yet another missing quote in test name
Simon Marchi [Fri, 20 Dec 2019 20:59:24 +0000 (15:59 -0500)]
sym-info-cmds.exp: add yet another missing quote in test name

In my previous commit, I missed this other spot that is missing a
quote...

gdb/testsuite/ChangeLog:

* lib/sym-info-cmds.exp (GDBInfoSymbols::check_no_entry): Add
(another) quote in test name.

4 years agosym-info-cmds.exp: add missing quote in test name
Simon Marchi [Fri, 20 Dec 2019 20:26:00 +0000 (15:26 -0500)]
sym-info-cmds.exp: add missing quote in test name

gdb/testsuite/ChangeLog:

* lib/sym-info-cmds.exp (GDBInfoModuleSymbols::check_no_entry):
Add quote in test name.

4 years agoUse enum bitfield for the calling_convention attribute of a subroutine
Tankut Baris Aktemur [Fri, 20 Dec 2019 17:23:32 +0000 (18:23 +0100)]
Use enum bitfield for the calling_convention attribute of a subroutine

This is a refactoring.  Instead of a plain unsigned value, use an enum
bitfield.

gdb/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* dwarf2read.c (is_valid_DW_AT_calling_convention_for_subroutine):
New function.
(read_subroutine_type): Validate the parsed
DW_AT_calling_convention value before assigning it to a
subroutine's calling_convention attribute.
* gdbtypes.h (struct func_type) <calling_convention>: Use
an enum bitfield as its type, instead of plain unsigned.

Change-Id: Ibc6b2f71e885cbc5c3c9d49734f7125acbfd1bcd

4 years agotestsuite, cp: increase the coverage of testing pass-by-ref arguments
Tankut Baris Aktemur [Fri, 20 Dec 2019 16:43:07 +0000 (17:43 +0100)]
testsuite, cp: increase the coverage of testing pass-by-ref arguments

Extend testcases for GDB's infcall of call-by-value functions that
take aggregate values as parameters.  In particular, existing test has
been substantially extended with class definitions whose definitions
of copy constructor, destructor, and move constructor functions are a
combination of

(1) explicitly defined by the user,
(2) defaulted inside the class declaration,
(3) defaulted outside the class declaration,
(4) deleted
(5) not defined in the source.

For each combination, a small and a large class is generated as well
as a derived class and a container class.  Additionally, the following
manually-written cases are provided:

- a dynamic class (i.e. class with a virtual method)
- classes that contain an array field
- a class whose copy ctor is inlined
- a class whose destructor is deleted
- classes with multiple copy and/or move ctors

Test cases check whether GDB makes the right decision to pass an
object by value or implicitly by reference, whether really a copy of
the argument is passed, and whether the copy constructor and
destructor of the clone of the argument are invoked properly.

The input program pass-by-ref.cc is generated in the test's output
directory.  The input program pass-by-ref-2.cc is manually-written.

Tests have been verified on the X86_64 architecture with
GCC 7.4.0, 8.2.0, and 9.2.1.

gdb/testsuite/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.cp/pass-by-ref.cc: Delete.  Generated in the output
directory instead.
* gdb.cp/pass-by-ref.exp: Extend with more cases.
* gdb.cp/pass-by-ref-2.cc: New file.
* gdb.cp/pass-by-ref-2.exp: New file.

Change-Id: Ie8ab1f260c6ad5ee4eb34b2c1597ce24af04abb6

4 years agoinfcall: handle pass-by-reference arguments appropriately
Tankut Baris Aktemur [Fri, 20 Dec 2019 16:43:06 +0000 (17:43 +0100)]
infcall: handle pass-by-reference arguments appropriately

If an aggregate argument is implicitly pass-by-reference, allocate a
temporary object on the stack, initialize it via the copy constructor
(if exists) or trivially by memcpy'ing.  Pass the reference of the
temporary to the callee function.  After the callee returns, invoke
the destructor of the temporary.

gdb/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

PR gdb/25054
* infcall.c (call_function_by_hand_dummy): Update the argument-
passing section for call-by-value parameters.
(struct destructor_info): New struct.
(call_destructors): New auxiliary function.

Change-Id: I18fa5d0df814dfa0defe9e862a88a6dbf1d99d01

4 years agoinfcall, c++: collect more pass-by-reference information
Tankut Baris Aktemur [Fri, 20 Dec 2019 16:43:06 +0000 (17:43 +0100)]
infcall, c++: collect more pass-by-reference information

Walk through a given type to collect information about whether the
type is copy constructible, destructible, trivially copyable,
trivially copy constructible, trivially destructible.  The previous
algorithm returned only a boolean result about whether the type is
trivially copyable.  This patch computes more info.  Additionally, it
utilizes DWARF attributes that were previously not taken into account;
namely, DW_AT_deleted, DW_AT_defaulted, and DW_AT_calling_convention.

gdb/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gnu-v3-abi.c (enum definition_style): New enum type.
(get_def_style): New function.
(is_user_provided_def): New function.
(is_implicit_def): New function.
(is_copy_or_move_constructor_type): New function.
(is_copy_constructor_type): New function.
(is_move_constructor_type): New function.
(gnuv3_pass_by_reference): Collect language_pass_by_ref_info
for a given type.

Change-Id: Ic05bd98a962d07ec3c1ad041f709687eabda3bb9

4 years agoinfcall, c++: allow more info to be computed for pass-by-reference values
Tankut Baris Aktemur [Fri, 20 Dec 2019 16:43:06 +0000 (17:43 +0100)]
infcall, c++: allow more info to be computed for pass-by-reference values

In C++, call-by-value arguments that cannot be trivially copied are
implicitly passed by reference.  When making an infcall, GDB needs to
find out if an argument is pass-by-reference or not, so that the
correct semantics can be followed.  This patch enriches the
information computed by the language ops for pass-by-reference
arguments.  Instead of a plain binary result, the computed information
now includes whether the argument is

  - copy constructible
  - destructible
  - trivially copyable
  - trivially copy constructible
  - trivially destructible

This information is stored in a struct named 'language_pass_by_ref_info'.

This patch paves the way for GDB's infcall mechanism to call the copy
ctor and the destructor of a pass-by-ref argument appropriately.

gdb/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* language.h (struct language_pass_by_ref_info): New struct.
(struct language_defn)<la_pass_by_reference>: Change the signature
to return a language_pass_by_ref_info instead of an int.
(language_pass_by_reference): Ditto.
(default_pass_by_reference): Ditto.
Adjust the users listed below.
* arch-utils.c (default_return_in_first_hidden_param_p):
Update.
* cp-abi.c (cp_pass_by_reference): Update.
* cp-abi.h (cp_pass_by_reference): Update declaration.
(struct cp_abi_ops)<pass_by_reference>: Update.
* gnu-v3-abi.c (gnuv3_pass_by_reference): Update.
* infcall.c (call_function_by_hand_dummy): Update.
* language.c (language_pass_by_reference): Update.
(default_pass_by_reference): Update.
* tic6x-tdep.c (tic6x_return_value): Update.

Change-Id: Ib1c1f87f2490a5737c469f7b7185ddc7f6a164cb

4 years agogdb: recognize new DWARF attributes: defaulted, deleted, calling conv.
Tankut Baris Aktemur [Fri, 20 Dec 2019 16:43:06 +0000 (17:43 +0100)]
gdb: recognize new DWARF attributes: defaulted, deleted, calling conv.

Extend GDB's internal representation of types to include the
DW_AT_calling_convention, DW_AT_defaulted, and DW_AT_deleted attributes
that were introduced in DWARF5.

These attributes will be helpful in a future patch about infcall'ing
functions with call-by-value parameters.  GDB will use the attributes
to decide whether the type of a call-by-value parameter is implicitly
pass-by-reference.

gdb/ChangeLog:
2019-12-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* dwarf2read.c (dwarf2_add_member_fn): Read the DW_AT_defaulted
and DW_AT_deleted attributes of a function.
(read_structure_type): Read the DW_AT_calling_convention attribute
of a type.
(is_valid_DW_AT_defaulted): New function.
(is_valid_DW_AT_calling_convention_for_type): New function.
* gdbtypes.h: Include dwarf2.h.
(struct fn_field)<defaulted>: New field to store the
DW_AT_defaulted attribute.
(struct fn_field)<is_deleted>: New field to store the
DW_AT_deleted attribute.
(struct cplus_struct_type)<calling_convention>: New field to store
the DW_AT_calling_convention attribute.
(TYPE_FN_FIELD_DEFAULTED): New macro.
(TYPE_FN_FIELD_DELETED): New macro.
(TYPE_CPLUS_CALLING_CONVENTION): New macro.
* gdbtypes.c (dump_fn_fieldlists): Update for the changes made
to the .h file.
(print_cplus_stuff): Likewise.

Change-Id: I54192f363115b78ec7435a8563b73fcace420765

4 years agoDon't call tui_show_source from tui_ui_out
Tom Tromey [Wed, 13 Nov 2019 23:47:58 +0000 (16:47 -0700)]
Don't call tui_show_source from tui_ui_out

This removes the call to tui_show_source from tui_ui_out.  This always
seemed like a hack, and now that the TUI is using the proper
observers, it seems not to be needed.

The rest of the logic remains, unfortunately, because it is needed to
suppress some gdb output in the TUI case.  We could probably find a
nicer way to do this (maybe a ui_out_flag), but I haven't attempted
this.

This was the last caller of tui_show_source, so this is removed as
well.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_show_source): Remove.
* tui/tui.h (tui_show_source): Don't declare.
* tui/tui-out.c (tui_ui_out::do_field_string): Don't call
tui_show_source.

Change-Id: Id71098e597ee4ebfef0429562baa45f537bd2c2b

4 years agoChange tui_show_frame_info to return bool
Tom Tromey [Wed, 13 Nov 2019 23:33:21 +0000 (16:33 -0700)]
Change tui_show_frame_info to return bool

This changes tui_show_frame_info to return bool.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-stack.h (tui_show_frame_info): Return bool.
* tui/tui-stack.c (tui_show_frame_info): Return bool.
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Update.

Change-Id: Id1374f04f919c30a9f50c1beeb70cbc10b9a8f3b

4 years agoFix "list" command in the TUI
Tom Tromey [Wed, 13 Nov 2019 23:30:52 +0000 (16:30 -0700)]
Fix "list" command in the TUI

PR tui/18932 notes that "list" no longer works in the TUI.  At some
point in the past, it switched the TUI source window to show the
specified source; but now this source briefly flashes before the TUI
reverts to showing the current stack frame's source.

This patch fixes this bug by introducing a new observer that notices
when the user selected context has changed.  Then, the existing
before-prompt observer is updated to request the correct update:
either one based on the current stack frame, or one based on the
user's source symtab_and_line.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

PR tui/18932:
* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
Rename parameters.  Handle the not-from-stack-frame case.
(from_stack, from_source_symtab): New globals.
(tui_before_prompt, tui_normal_stop): Update.
(tui_context_changed, tui_symtab_changed): New functions.
(tui_attach_detach_observers): Attach new observers.

gdb/testsuite/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* gdb.tui/list-before.exp: New file.

Change-Id: I62013825f6c1afdd568a1c7a8c019b0c881131af

4 years agoAdd observable to watch current source symtab
Tom Tromey [Thu, 14 Nov 2019 23:11:15 +0000 (16:11 -0700)]
Add observable to watch current source symtab

This patch adds an observable, so that a later patch can change the
TUI to notice when the user has selected a new source symtab, say via
"list".

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* source.c (struct current_source_location) <set, symtab, line>:
New methods.
<m_symtab, m_line>: Rename.  Now private.
(get_current_source_symtab_and_line)
(set_default_source_symtab_and_line)
(set_current_source_symtab_and_line)
(clear_current_source_symtab_and_line, select_source_symtab)
(info_source_command, print_source_lines_base)
(info_line_command, search_command_helper): Update.
* observable.h (current_source_symtab_and_line_changed): Declare
observable.
* observable.c (current_source_symtab_and_line_changed): Define
observable.

Change-Id: I3c0f6b40f2df84b590bdf5b5ec5ccd8423bb7f22

4 years agoUse bool in tui_before_prompt
Tom Tromey [Wed, 13 Nov 2019 23:05:36 +0000 (16:05 -0700)]
Use bool in tui_before_prompt

This changes tui_before_prompt to take a bool rather than an int.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-hooks.c (tui_before_prompt): Change parameter to bool.
(tui_before_prompt, tui_normal_stop): Update.

Change-Id: I9c7f2b764748fe19621851dc4fed4775a6db211a

4 years agoDon't call set_current_source_symtab_and_line from TUI
Tom Tromey [Wed, 13 Nov 2019 22:54:47 +0000 (15:54 -0700)]
Don't call set_current_source_symtab_and_line from TUI

update_source_window_as_is calls set_current_source_symtab_and_line,
but I don't think there is any reason it should be doing this.  This
patch removes the call.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c
(tui_source_window_base::update_source_window_as_is): Don't call
set_current_source_symtab_and_line.

Change-Id: I1152fc7c78150974bd3d555b8568a6f88b65dbe6

4 years agoChange set_locator_info to take a symtab_and_line
Tom Tromey [Wed, 13 Nov 2019 22:41:08 +0000 (15:41 -0700)]
Change set_locator_info to take a symtab_and_line

This changes set_locator_info to take a symtab_and_line, rather than
the individual components.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-stack.h (struct tui_locator_window) <set_locator_info>:
Take a symtab_and_line.
* tui/tui-stack.c (tui_locator_window::set_locator_info): Take a
symtab_and_line.
(tui_show_frame_info): Update.

Change-Id: Icb58d67e6c5bdc034eede9e5bbe8c1d1e633fbb5

4 years agoRemove a call to update_exec_info
Tom Tromey [Wed, 13 Nov 2019 07:16:39 +0000 (00:16 -0700)]
Remove a call to update_exec_info

tui_show_frame_info calls update_exec_info after calling
erase_source_content, but there's no need to do this, as
erase_source_content already clears the exec info.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-stack.c (tui_show_frame_info): Don't call
update_exec_info.

Change-Id: I63d658561028ac1bc0a0a2b7ac17da1b9c6134fe

4 years agoDisplay "main" on initial TUI startup
Tom Tromey [Wed, 13 Nov 2019 01:20:58 +0000 (18:20 -0700)]
Display "main" on initial TUI startup

I noticed that even when there's a symbol file, "tui enable" won't
show "main" by default.  I think it should, and this patch fixes this.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_enable): Call tui_display_main.

gdb/testsuite/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* gdb.tui/list.exp: Check for source on initial listing.

Change-Id: Ic7bfc930e1179f5b61111e30a2dae46a98b00064

4 years agoReimplement tui_get_begin_asm_address
Tom Tromey [Wed, 13 Nov 2019 01:20:32 +0000 (18:20 -0700)]
Reimplement tui_get_begin_asm_address

tui_get_begin_asm_address looks for the inferior's "main" to display
it.  I think this is incorrect in two ways.

First, it should probably instead use the user's most recent source
context, if one has been set.

Second, it uses a hard-coded list of "main" names, but gdb already has
a better approach to handling this.

This patch fixes both of these problems.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-disasm.c (tui_get_begin_asm_address): Use
get_current_source_symtab_and_line, and main_name.

Change-Id: I77dc13d49148e8dec5aa3eeb357ce3968a68d0bd

4 years agoSimplify tui_update_source_windows_with_line
Tom Tromey [Wed, 13 Nov 2019 01:04:01 +0000 (18:04 -0700)]
Simplify tui_update_source_windows_with_line

This changes tui_update_source_windows_with_line to take a
symtab_and_line, rather than separate parameters, and then updates the
caller.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_show_source): Update.
* tui/tui-winsource.h (tui_update_source_windows_with_line): Update.
* tui/tui-winsource.c (tui_update_source_windows_with_line): Take
a symtab_symbol_info, not a separate symtab and line.  Simplify.

Change-Id: I8803a0a6fd2938ceee859aea53a57ce582f3e80d

4 years agoSimplify tui_update_source_windows_with_addr
Tom Tromey [Wed, 13 Nov 2019 00:59:06 +0000 (17:59 -0700)]
Simplify tui_update_source_windows_with_addr

After the previous changes, tui_update_source_windows_with_addr simply
updates each source-like window separately, passing the same data to
each.  So, it can be simplified by using a loop instead.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_update_source_windows_with_addr):
Simplify.

Change-Id: Id2ba6b3145ec005dbed1b1115118bd1ef4efb842

4 years agoUse symtab_and_line when updating TUI windows
Tom Tromey [Wed, 13 Nov 2019 00:56:42 +0000 (17:56 -0700)]
Use symtab_and_line when updating TUI windows

This changes a few TUI source window methods to take a symtab_and_line
rather than separate symtab and tui_line_or_address parameters.  A
symtab_and_line already incorporates the same information, so this
seemed simpler.  Also, it helps avoid the problem that the source and
disassembly windows need different information -- both forms are
present in the SAL.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (struct tui_source_window_base)
<set_contents, update_source_window_as_is, update_source_window>:
Take a sal, not a separate symtab and tui_line_or_address.
* tui/tui-winsource.c (tui_source_window_base::update_source_window)
(tui_source_window_base::update_source_window_as_is): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_update_source_windows_with_addr)
(tui_update_source_windows_with_line)
(tui_source_window_base::rerender)
(tui_source_window_base::refill): Update.
* tui/tui-source.h (struct tui_source_window) <set_contents>: Take
a sal, not a separate symtab and tui_line_or_address.
* tui/tui-source.c (tui_source_window::set_contents): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_source_window::maybe_update): Update.
* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>: Take
a sal, not a separate symtab and tui_line_or_address.
* tui/tui-disasm.c (tui_disasm_window::set_contents): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_disasm_window::do_scroll_vertical)
(tui_disasm_window::maybe_update): Update.

Change-Id: I6974a03589930a0f910c657ef50b7f6f7397c87d

4 years agoUse start_line_or_addr in TUI windows
Tom Tromey [Wed, 13 Nov 2019 00:40:33 +0000 (17:40 -0700)]
Use start_line_or_addr in TUI windows

A few spots in the TUI source and disassembly windows referred to
content[0], where start_line_or_addr is equivalent.  This patch makes
this substitution.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_source_window_base::refill): Use
start_line_or_addr.
* tui/tui-source.c (tui_source_window::do_scroll_vertical): Use
start_line_or_addr.
* tui/tui-disasm.c (tui_disasm_window::do_scroll_vertical): Use
start_line_or_addr.

Change-Id: I1fa807321cd7ad88b3cc5e41cc50f4d4e2d46271

4 years agoChange tui_source_window_base::set_contents to return bool
Tom Tromey [Wed, 13 Nov 2019 00:26:50 +0000 (17:26 -0700)]
Change tui_source_window_base::set_contents to return bool

This changes tui_source_window_base::set_contents to return bool,
rather than tui_status.  It also changes one implementation of
set_contents to use early returns rather than a variable, which IMO
makes it easier to follow.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (struct tui_source_window_base)
<set_contents>: Return bool.
* tui/tui-winsource.c
(tui_source_window_base::update_source_window_as_is): Update.
* tui/tui-source.h (struct tui_source_window) <set_contents>:
Return bool.
* tui/tui-source.c (tui_source_window::set_contents): Return
bool.  Simplify.
* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>:
Return bool.
* tui/tui-disasm.c (tui_disasm_window::set_contents): Return
bool.

Change-Id: I8c5212400cd7aadf35760c22d5344cd3b9435674

4 years agoRemove tui_source_window::show_symtab_source
Tom Tromey [Wed, 13 Nov 2019 00:23:18 +0000 (17:23 -0700)]
Remove tui_source_window::show_symtab_source

tui_source_window::show_symtab_source is identical to
update_source_window, so remove the former.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_update_source_windows_with_addr)
(tui_update_source_windows_with_line): Call update_source_window.
* tui/tui-source.h (struct tui_source_window)
<show_symtab_source>: Don't declare.
* tui/tui-source.c (tui_source_window::show_symtab_source):
Remove.

Change-Id: I41781df2126e8bafad46d058532d52602a288e06

4 years agoRemove tui_show_disassem
Tom Tromey [Wed, 13 Nov 2019 00:19:59 +0000 (17:19 -0700)]
Remove tui_show_disassem

tui_show_disassem is just a wrapper for the update_source_window
method, and it only has a single caller.  This removes the function
and inlines the logic into that caller.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_update_source_windows_with_addr): Call
update_source_window directly.
* tui/tui-disasm.h (tui_show_disassem): Don't declare.
* tui/tui-disasm.c (tui_show_disassem): Remove.

Change-Id: I7ae7a3309f64a4a949c07a80c46e1664c7f12913

4 years agoRemove some unnecessary focus switches
Tom Tromey [Wed, 13 Nov 2019 00:15:12 +0000 (17:15 -0700)]
Remove some unnecessary focus switches

A couple of lower-level utility functions can change the TUI focus.
This seems incorrect to me -- focus switches should only be done
either by explicit user request, or ass a side effect of changing the
layout.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c
(tui_source_window_base::update_source_window_as_is): Don't switch focus.
* tui/tui-disasm.c (tui_show_disassem): Don't switch focus.

Change-Id: I0a5bb8a407cf8d52e2fd23b0598eb9bce56b1251

4 years agoSimplify tui_source_window_base::maybe_update method
Tom Tromey [Wed, 13 Nov 2019 00:08:25 +0000 (17:08 -0700)]
Simplify tui_source_window_base::maybe_update method

tui_source_window_base::maybe_update takes a symtab_and_line, plus a
separate line number and PC.  Because a symtab_and_line already holds
a line number and a PC, it is possible to remove these extra
parameters.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (struct tui_source_window_base)
<maybe_update>: Remove line_no and addr parameters.
* tui/tui-stack.c (tui_show_frame_info): Set PC on sal.  Update.
* tui/tui-source.h (struct tui_source_window) <maybe_update>:
Update.
* tui/tui-source.c (tui_source_window::maybe_update): Remove
line_no and addr parameters.
* tui/tui-disasm.h (struct tui_disasm_window) <maybe_update>:
Update.
* tui/tui-disasm.c (tui_disasm_window::maybe_update): Remove
line_no and addr parameters.

Change-Id: I33d8e1a669a179544edb4197f5f7c5429dfc368e

4 years agoRemove some TUI asserts
Tom Tromey [Wed, 13 Nov 2019 00:02:49 +0000 (17:02 -0700)]
Remove some TUI asserts

This removes a few asserts from the TUI.  These asserts aren't useful,
because they simply check an invariant that's already ensured by the
type system.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_source_window_base::set_is_exec_point_at)
(tui_source_window_base::update_breakpoint_info): Remove asserts.

Change-Id: I807e1e9bdb0cfa475e70375ceca3a5d4f2eb8d0b

4 years agoRemove tui_show_disassem_and_update_source
Tom Tromey [Wed, 6 Nov 2019 23:09:28 +0000 (16:09 -0700)]
Remove tui_show_disassem_and_update_source

tui_show_disassem_and_update_source only has a single caller.  This
patch simplifies that caller, by having it call tui_show_disassem, and
then removes tui_show_disassem_and_update_source.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.c (tui_update_source_windows_with_addr): Call
tui_show_disassem.
* tui/tui-disasm.h (tui_show_disassem_and_update_source): Don't
declare.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Remove.

Change-Id: I7554eca8e259f3539ea7710f2ff369b4a630dd9d

4 years agoRemove parameters from tui_show_source
Tom Tromey [Tue, 12 Nov 2019 23:30:24 +0000 (16:30 -0700)]
Remove parameters from tui_show_source

tui_show_source does not need its parameters, so this removes them.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui.h (tui_show_source): Remove parameters.
* tui/tui.c (tui_show_source): Remove parameters.
* tui/tui-out.c (tui_ui_out::do_field_string): Update.

Change-Id: I7cbcf20175b459c269549f1832d4fb844cc573db

4 years agoChange tui_update_locator_fullname to take a symtab
Tom Tromey [Tue, 12 Nov 2019 23:28:40 +0000 (16:28 -0700)]
Change tui_update_locator_fullname to take a symtab

This changes tui_update_locator_fullname to take a symtab.  This
somewhat consolidates the "??" handling.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

* tui/tui.c (tui_show_source): Update.
* tui/tui-winsource.c (tui_display_main): Update.
* tui/tui-stack.h (tui_update_locator_fullname): Change parameter
to symtab.
* tui/tui-stack.c (tui_update_locator_fullname): Change parameter
to symtab.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Update.

Change-Id: Ic61749517b44ac68561d829ff81f16976b830dec

4 years agoMake isearch change readline prompt in TUI
Tom Tromey [Wed, 20 Nov 2019 23:39:44 +0000 (16:39 -0700)]
Make isearch change readline prompt in TUI

PR tui/23619 points out that isearch changes the prompt in the CLI gdb
(and in Bash) -- but not in the TUI.  This turns out to be easily
fixed by removing tui_rl_saved_prompt and instead using the prompt
that readline computes.

This is stored in rl_display_prompt, which according to git was added
in readline 6.2.

gdb/ChangeLog
2019-12-20  Tom Tromey  <tom@tromey.com>

PR tui/23619:
* tui/tui-io.c (tui_rl_saved_prompt): Remove.
(tui_redisplay_readline): Use rl_display_prompt.
(tui_prep_terminal): Update.

Change-Id: Iae97e9776a5540bbe52c73b05e4707941d9cd11a

4 years agoPR25281, sh disassembler abort
Alan Modra [Fri, 20 Dec 2019 07:26:35 +0000 (17:56 +1030)]
PR25281, sh disassembler abort

PR 25281
* sh-dis.c (print_insn_ddt): Properly check validity of MOVX_NOPY
and MOVY_NOPX insns.  For invalid cases include 0xf000 in the word
printed.  Print .word in more cases.

4 years agoubsan: or1k: left shift of negative value
Alan Modra [Fri, 20 Dec 2019 04:07:44 +0000 (14:37 +1030)]
ubsan: or1k: left shift of negative value

cpu/
* or1korbis.cpu (f-disp26, f-disp21): Don't left shift negative values.
opcodes/
* or1k-ibld.c: Regenerate.

4 years agoubsan: xtensa: left shift cannot be represented in type 'int'
Alan Modra [Fri, 20 Dec 2019 02:14:33 +0000 (12:44 +1030)]
ubsan: xtensa: left shift cannot be represented in type 'int'

* xtensa-isa.c (xtensa_insnbuf_from_chars): Avoid signed overflow.

4 years agoubsan: hppa: left shift of negative value
Alan Modra [Fri, 20 Dec 2019 01:44:19 +0000 (12:14 +1030)]
ubsan: hppa: left shift of negative value

bfd/
* libhppa.h (hppa_field_adjust, bfd_hppa_insn2fmt): Delete forward
declaration.  Move ATTRIBUTE_UNUSED to definition.
(sign_extend, low_sign_extend, sign_unext, low_sign_unext),
(re_assemble_3, re_assemble_12, re_assemble_14, re_assemble_16),
(re_assemble_17, re_assemble_21, re_assemble_22): Likewise.  Make
args and return value unsigned.  Use unsigned variables.
(hppa_rebuild_insn): Similarly.
opcodes/
* hppa-dis.c (extract_16, extract_21, print_insn_hppa): Use
unsigned variables.