Commit Graph

43437 Commits

Author SHA1 Message Date
Tom Tromey 9923f347c4 Change members of tui_locator_window to std::string
This changes two members of tui_locator_window to have type
std::string.  This removes a static limit.

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

	* tui/tui-stack.h (MAX_LOCATOR_ELEMENT_LEN): Remove define.
	(struct tui_locator_window) <full_name, proc_name>: Now
	std::string.
	* tui/tui-stack.c (tui_locator_window::make_status_line)
	(tui_locator_window::set_locator_fullname)
	(tui_locator_window::set_locator_info): Update.
	* tui/tui-source.c (tui_source_window::set_contents)
	(tui_source_window::showing_source_p): Update.
2019-09-20 13:49:10 -06:00
Tom Tromey b76251abaf Remove a call to tui_locator_win_info_ptr
Commit e594a5d1 ("Turn two locator functions into methods") turned
set_locator_fullname into a method on tui_locator_window.  I missed it
at the time, but this change allows for the removal of a call to
tui_locator_win_info_ptr.

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

	* tui/tui-stack.c (tui_locator_window::set_locator_fullname):
	Don't call tui_locator_win_info_ptr.
2019-09-20 13:49:09 -06:00
Tom Tromey 0891be0835 Don't call refresh in tui_resize_all
There's no reason to call refresh in tui_resize_all.  This call
flushes the curses window contents to the terminal -- but, because
we're about the resize all the windows, we're going to be sending more
data to the terminal momentarily.  This patch removes the call.

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

	* tui/tui-win.c (tui_resize_all): Don't call refresh.
2019-09-20 13:49:09 -06:00
Tom Tromey 1b935acf7e Set TUI locator height to 1
The TUI has long had code to resize the locator, using 2 as the
height.  However the code has "1" in a comment, like:

    locator->resize (2 /* 1 */ ,

This patch fixes the resizing code to set the height to 1.  Doing this
revealed what was probably the reason for setting the height to 2 in
the first place: this caused the locator window to scroll.  However,
this is easily handled by calling scrollok on the locator window.

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

	* tui/tui-win.c (tui_resize_all, tui_adjust_win_heights): Use 1 as
	height for locator.
	* tui/tui-stack.c (tui_locator_window::rerender): Call scrollok.
	* tui/tui-layout.c (show_source_disasm_command, show_data)
	(show_source_or_disasm_and_command): Use 1 as height for locator.
2019-09-20 13:49:08 -06:00
Tom Tromey 9abd8a65c1 Change "win_resized" to bool
This changes the "win_resized" global to be a bool and then updates
the uses.

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

	* tui/tui.c (tui_enable): Update.
	* tui/tui-win.c (tui_sigwinch_handler, tui_async_resize_screen):
	Update.
	* tui/tui-data.h (tui_win_resized, tui_set_win_resized_to):
	Update.
	* tui/tui-data.c (win_resized): Now bool.
	(tui_win_resized): Return bool.
	(tui_set_win_resized_to): Accept a bool.
2019-09-20 13:49:08 -06:00
Tom Tromey b545782674 Use "bool" in tui_data_window::show_register_group
This changes tui_data_window::show_register_group to use "bool" rather
than "int".

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

	* tui/tui-regs.h (struct tui_data_window) <show_register_group>:
	Change type of "refresh_values_only".
	* tui/tui-regs.c (tui_data_window::show_register_group): Change
	type of "refresh_values_only".
2019-09-20 13:49:07 -06:00
Tom Tromey 6b915f7d0c Simplify TUI disassembly
This simplifies TUI disassembly somewhat, by removing manual memory
management.

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

	* tui/tui-disasm.c (struct tui_asm_line) <addr_string, insn>: Now
	std::string.
	(tui_disassemble): Add "pos" parameter.
	(tui_disasm_window::set_contents): Simplify.
2019-09-20 13:49:07 -06:00
Tom Tromey 2ad52f6fb3 Simplify tui_source_window_base::show_source_content
tui_source_window_base::show_source_content is not used outside the
class any more, so this makes it private.  Examining the callers shows
that it can't be called without source contents, so it can be
simplified as well.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<show_source_content>: Now private.
	* tui/tui-winsource.c
	(tui_source_window_base::show_source_content): Don't handle empty
	content case.
2019-09-20 13:49:06 -06:00
Tom Tromey b3b1bde658 Remove some explicit re-rendering from the TUI
A couple of spots in tui-layout.c still call the show_source_content
method.  However, now that re-rendering is done by the resize method,
these calls are no longer needed.

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

	* tui/tui-layout.c (show_source_disasm_command)
	(show_source_or_disasm_and_command): Don't call
	show_source_content.
2019-09-20 13:49:06 -06:00
Tom Tromey 71a25ed2e7 Change tui_make_status_line to be a method
This changes tui_make_status_line to be a method on
tui_locator_window.  This is a minor cleanup.

This also changes the new method to use the locator's width, rather
than the terminal width.  This is important if we ever want to allow
windows to be made more narrow.

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

	* tui/tui-stack.h (struct tui_locator_window) <make_status_line>:
	Declare.
	* tui/tui-stack.c (tui_locator_window::make_status_line): Rename
	from tui_make_status_line.
	(tui_locator_window::rerender): Update.
2019-09-20 13:49:05 -06:00
Tom Tromey f853215443 Change tui_make_status_line to return std::string
This changes tui_make_status_line to return std::string.  This cleans
it up a bit, and removes some explicit memory management.

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

	* tui/tui-stack.c (tui_make_status_line): Return std::string.
	(tui_locator_window::rerender): Update.
2019-09-20 13:49:05 -06:00
Tom Tromey 2d81b34998 Move "fullname" to tui_source_window
The "fullname" field in tui_source_window_base is only used by one
subclass.  This patch moves the field to that subclass, and changes it
to be a unique_xmalloc_ptr.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<~tui_source_window_base>: Don't declare.
	<fullname>: Remove.
	* tui/tui-winsource.c (~tui_source_window_base): Remove.
	* tui/tui-source.h (struct tui_source_window) <fullname>: New
	member.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	(tui_source_window::location_matches_p)
	(tui_source_window::maybe_update): Update.
2019-09-20 13:49:05 -06:00
Tom Tromey f14bec587f Change tui_source_element::line to be a unique_xmalloc_ptr
This changes tui_source_element::line to be a unique_xmalloc_ptr,
removing some manual memory management.

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

	* tui/tui-winsource.h (~tui_source_element): Remove.
	(tui_source_element): Update.
	(struct tui_source_element) <line>: Now a unique_xmalloc_ptr.
	* tui/tui-winsource.c (tui_show_source_line): Update.
	* tui/tui-source.c (tui_source_window::set_contents): Update.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.
2019-09-20 13:49:04 -06:00
Tom Tromey 78d5933a43 Remove tui_clear_source_windows_detail
The calls to tui_clear_source_windows_detail in tui_add_win_to_layout
aren't needed, because (after the resize unification) resizing will
update the window contents.  Removing these calls lets us remove
several other things as well.

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

	* tui/tui-data.h (tui_clear_source_windows_detail): Don't
	declare.
	* tui/tui-layout.c (tui_add_win_to_layout): Don't call
	tui_clear_source_windows_detail.
	* tui/tui-winsource.h (struct tui_source_window_base)
	<clear_detail>: Don't declare.
	* tui/tui-winsource.c (tui_source_window_base::clear_detail):
	Remove.
	* tui/tui-data.c (tui_clear_source_windows_detail): Remove.
2019-09-20 13:49:04 -06:00
Tom Tromey d420769627 Fix crash in Ada "catch exception"
PR ada/24919 concerns a crash that Tom de Vries noticed when running
the "catch_ex" Ada test case.  He sent a test executable and tracked
this down to commit f21c2bd7b7 ("Fix Fortran regression with variables
in nested functions").

Looking at that patch, you can see the obvious error:

    -  return 0;
    +  return true;

Oops!  This patch fixes the bug.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-09-20  Tom Tromey  <tromey@adacore.com>

	PR ada/24919:
	* block.c (contained_in): Fix final return value.
2019-09-20 11:34:21 -06:00
Alan Modra 00f93c4492 bfd macro conversion to inline functions
This converts some of the macros that access struct bfd fields to
inline functions.

bfd/
	* archive.c (bfd_generic_archive_p): Use bfd_set_thin_archive.
	* bfd-in.h (bfd_get_filename, bfd_get_cacheable, bfd_get_format),
	(bfd_get_target, bfd_get_flavour, bfd_family_coff, bfd_big_endian),
	(bfd_little_endian, bfd_header_big_endian, bfd_header_little_endian),
	(bfd_get_file_flags, bfd_applicable_file_flags),
	(bfd_applicable_section_flags, bfd_has_map, bfd_is_thin_archive),
	(bfd_valid_reloc_types, bfd_usrdata, bfd_get_start_address),
	(bfd_get_symcount, bfd_get_outsymbols, bfd_count_sections),
	(bfd_get_dynamic_symcount, bfd_get_symbol_leading_char): Delete.
	* bfd/bfd.c (bfd_get_filename, bfd_get_cacheable, bfd_get_format),
	(bfd_get_file_flags, bfd_get_start_address, bfd_get_symcount),
	(bfd_get_dynamic_symcount, bfd_get_outsymbols, bfd_count_sections),
	(bfd_has_map, bfd_is_thin_archive, bfd_set_thin_archive),
	(bfd_usrdata, bfd_set_usrdata): New inline functions.
	* targets.c (bfd_get_target, bfd_get_flavour),
	(bfd_applicable_file_flags, bfd_family_coff, bfd_big_endian),
	(bfd_little_endian, bfd_header_big_endian),
	(bfd_header_little_endian, bfd_applicable_section_flags),
	(bfd_get_symbol_leading_char): New inline functions.
	* bfd-in2.h: Regenerate.
binutils/
	* ar.c (write_archive): Use bfd_set_thin_archive.
gdb/
	* gdb_bfd.c (gdb_bfd_ref, gdb_bfd_unref): Use bfd_set_usrdata.
	* dwarf2read.c (dwarf2_read_gdb_index, dwarf2_read_debug_names),
	(read_indirect_string_from_dwz): Use bfd accessor.
	* dwarf2read.h (struct dwz_file <filename>): Likewise.
	* machoread.c (macho_symfile_read_all_oso): Likewise.
	* solib.c (solib_bfd_open): Likewise.
ld/
	* ldelf.c (ldelf_after_open, ldelf_place_orphan
	* ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata.
	(load_symbols, ldlang_add_file): Use bfd_set_usrdata.
	* ldmain.c (add_archive_element): Use bfd_usrdata.
	* ldlang.h (bfd_input_just_syms): New inline function.
	* emultempl/aarch64elf.em (build_section_lists): Use it.
	* 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/ppc64elf.em (build_section_lists): Likewise.
sim/
	* ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
2019-09-20 18:04:02 +09:30
Christian Biesinger e4153ae630 Move declaration of overload_resolution to value.h
The variable is defined in valops.c and has an extern decl in
eval.c; move it to the header file.

gdb/ChangeLog:

2019-09-19  Christian Biesinger  <cbiesinger@google.com>

	* eval.c: Move declaration of overload_resolution to...
	* value.h: ...here.
2019-09-20 09:19:15 +09:00
Christian Biesinger c7ae7675cf Move arm_apcs_32 extern declaration to header
Instead of having several extern declarations for arm_apcs_32
in a few .c files, declare it in arm-tdep.h. This file is already
included from these .c files.

gdb/ChangeLog:

2019-09-19  Christian Biesinger  <cbiesinger@google.com>

	* arm-linux-nat.c: Remove extern declaration for arm_apcs_32.
	* arm-linux-tdep.c: Likewise.
	* arm-nbsd-nat.c: Likewise.
	* arm-tdep.h: Declare arm_apcs_32.
2019-09-20 09:17:49 +09:00
Christian Biesinger e86f08d28f Declare dwarf_always_disassemble in dwarf2read.h
And remove the declaration from dwarf2loc.c, for better typesafety.

gdb/ChangeLog:

2019-09-19  Christian Biesinger  <cbiesinger@google.com>

	* dwarf2loc.c: Remove extern declaration of dwarf_always_disassemble.
	* dwarf2read.h: Declare dwarf_always_disassemble.
2019-09-20 09:13:53 +09:00
Tom de Vries e452e88f54 [gdb/testsuite] Don't use FOOBAR pattern in gdb_test
If gdb_test is used with fewer than five arguments, then the question_string
defaults to "^FOOBAR$":
...
    if [llength $args]==5 {
       set question_string [lindex $args 3]
       set response_string [lindex $args 4]
    } else {
       set question_string "^FOOBAR$"
    }
...

This can however match "FOOBAR", so perhaps "\$FOOBAR^" would have been a
better choice.

Eliminate the FOOBAR pattern from gdb_test by instead of defining a default
regexp, conditionally appending the regexp matching to a user_code variable.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (gdb_test): Eliminate "^FOOBAR$" pattern.
2019-09-19 19:54:15 +02:00
Tom de Vries f64e2f4045 [gdb] Catch exception when constructing the highlighter
Currently in source_cache::ensure we catch the exception that triggers when
highlighter->highlight is called:
...
         try
           {
             std::istringstream input (contents);
             std::ostringstream output;
             highlighter->highlight (input, output, lang_name, fullname);
...
and the file used earlier in the construction of the highlighter:
...
             highlighter = new srchilite::SourceHighlight ("esc.outlang");
...
is missing.

The fact that this exception triggers when highlighter->highlight is called is
an implementation artefact of libsource-highlight.so though, and this could be
different for older or newer versions.

Make things more robust by also catching exceptions thrown during construction
of the highlighter.  This makes the handling on master equivalent with what
has been committed for 8.3.1.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

	PR gdb/25009
	* source-cache.c (source_cache::ensure): Catch exception thrown during
	construction of the highlighter.
2019-09-19 19:49:39 +02:00
Alan Modra fd3619828e bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions.  The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections.  Those sections shouldn't be modified
anyway.

The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma.  I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section.  This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.

bfd/
	* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
	(bfd_get_section_lma, bfd_get_section_alignment),
	(bfd_get_section_size, bfd_get_section_flags),
	(bfd_get_section_userdata): Delete.
	(bfd_section_name, bfd_section_size, bfd_section_vma),
	(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
	(bfd_section_flags, bfd_section_userdata): New.
	(bfd_is_com_section): Rename parameter.
	* section.c (bfd_set_section_userdata, bfd_set_section_vma),
	(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
	(bfd_set_section_size): Delete bfd parameter, rename section parameter.
	(bfd_set_section_lma): New.
	* bfd-in2.h: Regenerate.
	* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
	update callers.
	* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
	* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
	* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
	* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
	* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
	* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
	* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
	* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
	* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
	* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
	* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
	* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
	* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
	* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
	* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
	* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
	* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
	* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
	* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
	* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
	* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
	* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
	* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
	* xcofflink.c: Update throughout for bfd section macro and function
	changes.
binutils/
	* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
	* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
	* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
	* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
	throughout for bfd section macro and function changes.
gas/
	* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
	* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
	* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
	* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
	* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
	* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
	* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
	* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
	* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
	* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
	* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
	* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
	* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
	* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
	* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
	* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
	* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
	* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
	* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
	* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
	* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
	* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
	* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
	bfd section macro and function changes.
	* write.c (compress_debug): Use bfd_rename_section.
gdb/
	* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
	* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
	* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
	* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
	* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
	* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
	* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
	* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
	* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
	* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
	* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
	* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
	* solib-spu.c, * solib-svr4.c, * solib-target.c,
	* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
	* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
	* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
	* mi/mi-interp.c: Update throughout for bfd section macro and
	function changes.
	* gcore (gcore_create_callback): Use bfd_set_section_lma.
	* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
	* corefile.c, * symtab.c: Update throughout for bfd section
	macro and function changes.
ld/
	* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
	* emultempl/aarch64elf.em, * emultempl/aix.em,
	* emultempl/armcoff.em, * emultempl/armelf.em,
	* emultempl/cr16elf.em, * emultempl/cskyelf.em,
	* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
	* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
	* emultempl/mmo.em, * emultempl/msp430.em,
	* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
	* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
	throughout for bfd section macro and function changes.
libctf/
	* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
	* arc-ext.c: Update throughout for bfd section macro changes.
sim/
	* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
	* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
	* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
	* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
	* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-19 09:40:13 +09:30
Tom de Vries 8a6251301c [gdb/testsuite] Fix gdb_target_cmd
In commit 81dc3ab594 "[gdb/testsuite] Handle unreachable network in
server-connect.exp" a regression was introduced in gdb_target_cmd, causing
ERRORs like this:
...
ERROR: tcl error sourcing src/gdb/testsuite/gdb.server/abspath.exp.
ERROR: wrong # args: should be "gdb_target_cmd {$args}"
    while executing
"gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport"
...

Fix the argument passing in gdb_target_cmd.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

	* lib/gdbserver-support.exp (gdb_target_cmd): Fix argument passing.
2019-09-19 01:14:19 +02:00
Tom de Vries 81dc3ab594 [gdb/testsuite] Handle unreachable network in server-connect.exp
When running gdb.server/server-connect.exp I run into:
...
FAIL: gdb.server/server-connect.exp: tcp6: connect to gdbserver using tcp6:::1
FAIL: gdb.server/server-connect.exp: tcp6-with-brackets: connect to gdbserver \
  using tcp6:[::1]
FAIL: gdb.server/server-connect.exp: udp6: connect to gdbserver using udp6:::1
FAIL: gdb.server/server-connect.exp: udp6-with-brackets: connect to gdbserver \
  using udp6:[::1]
...

The FAIL is caused by the fact that the ipv6 loopback address is not available:
...
PASS: gdb.server/server-connect.exp: tcp6: start gdbserver
target remote tcp6:::1:2347^M
A program is being debugged already.  Kill it? (y or n) y^M
tcp6:::1:2347: Network is unreachable.^M
(gdb) FAIL: gdb.server/server-connect.exp: tcp6: connect to gdbserver using tcp6:::1
...
This should be marked UNSUPPORTED rather than FAIL.

Furthermore, the test-case takes about 4 minutes, because the 'Network is
unreachable' response is not explicitly handled in gdb_target_cmd, so instead
it runs into the timeout case.

Fix this by handling the 'Network is unreachable' response as UNSUPPORTED.
This reduces testing time from 4 minutes to about 2 seconds.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

	* lib/gdbserver-support.exp (gdb_target_cmd_ext): Return 2 (meaning
	UNSUPPORTED) for 'Network is unreachable' message.  Factor out of ...
	(gdb_target_cmd): ... here.
	* gdb.server/server-connect.exp: Use gdb_target_cmd_ext, handle return
	value 2.
2019-09-19 00:23:54 +02:00
Joel Brobecker a1726c38a9 Update ChangeLog entry of commit 677052f2a5c67f1d9b2e6d1b2a2149b5f0c20cd0...
... to include PR breakpoints/24541 (for documentation purposes).

For the reader's convenience, the commit in question was the following:

    commit 677052f2a5
    Author: Sergio Durigan Junior <sergiodj@redhat.com>
    Date:   Thu May 16 16:23:24 2019 -0400
    Subject: Make stap-probe.c:stap_parse_register_operand's "regname"
       an std::string
2019-09-18 14:42:24 -07:00
Tom Tromey 11061048d1 Give a name to the TUI SingleKey keymap
Readline 8.0 has a feature that lets an application name a keymap.
This in turn makes it simpler for users to bind keys in keymaps in
their .inputrc.

This patch gives a name to the TUI SingleKey keymap, so that
additional bindings can be made there.  For example:

    $if gdb
    set keymap SingleKey
    "X": "echo hello\\n\n"
    $endif

The call to rl_initialize, in tui_initialize_readline, had to be
removed so that .inputrc was not read too early.  Note that Readline
explicitly documents that this call is not needed.

gdb/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
	call rl_initialize.
	(tui_enable): Do not call rl_initialize.

gdb/doc/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Editing): Document readline application name.
	(TUI Single Key Mode): Document TUI SingleKey keymap name.
2019-09-18 15:03:29 -06:00
Christian Groessler 7a27b85f6d gdb: Fix native build on Linux/Alpha.
Fixes:

  CXX    alpha-linux-nat.o
alpha-linux-nat.c: In member function 'virtual CORE_ADDR alpha_linux_nat_target::register_u_offset(gdbarch*, int, int)':
alpha-linux-nat.c:93:16: error: 'gdbarch_pc_regnum' was not declared in this scope
   if (regno == gdbarch_pc_regnum (gdbarch))
                ^~~~~~~~~~~~~~~~~
alpha-linux-nat.c:93:16: note: suggested alternative: 'gdbarch_info'
   if (regno == gdbarch_pc_regnum (gdbarch))
                ^~~~~~~~~~~~~~~~~
                gdbarch_info
alpha-linux-nat.c:97:15: error: 'gdbarch_fp0_regnum' was not declared in this scope
   if (regno < gdbarch_fp0_regnum (gdbarch))
               ^~~~~~~~~~~~~~~~~~
alpha-linux-nat.c:97:15: note: suggested alternative: 'gdbarch_info'
   if (regno < gdbarch_fp0_regnum (gdbarch))
               ^~~~~~~~~~~~~~~~~~
               gdbarch_info
make[2]: *** [Makefile:1638: alpha-linux-nat.o] Error 1
make[2]: Leaving directory '/home/chris/tmp/binutils-gdb/gdb'

2019-09-12  Christian Groessler  <chris@groessler.org>

       * alpha-linux-nat.c: Include gdbarch.h.
2019-09-18 15:18:39 -04:00
Simon Marchi f64eea3a59 gdb: remove local extern declaration of cli_styling
Following the int -> bool conversion of boolean options (commit
491144b5e2 ("Change boolean options to bool instead of int")), I see
this ASAN error:

  ==357543==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55555b25d440 at pc 0x5555583ce9e1 bp 0x7fffffffd390 sp 0x7fffffffd380
  READ of size 4 at 0x55555b25d440 thread T0
      #0 0x5555583ce9e0 in term_cli_styling /home/simark/src/binutils-gdb/gdb/ui-file.c:111
      #1 0x5555583cf8b0 in stdio_file::can_emit_style_escape() /home/simark/src/binutils-gdb/gdb/ui-file.c:308
      #2 0x5555584450d2 in set_output_style /home/simark/src/binutils-gdb/gdb/utils.c:1442
      #3 0x5555584491af in fprintf_styled(ui_file*, ui_file_style const&, char const*, ...) /home/simark/src/binutils-gdb/gdb/utils.c:2143
      #4 0x5555582fa13c in print_gdb_version(ui_file*, bool) /home/simark/src/binutils-gdb/gdb/top.c:1339
      #5 0x555557b723ab in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:981
      #6 0x555557b7353b in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1172
      #7 0x555557b735d0 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1197
      #8 0x55555700a53d in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
      #9 0x7ffff64c9ee2 in __libc_start_main (/usr/lib/libc.so.6+0x26ee2)
      #10 0x55555700a30d in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x1ab630d)

  0x55555b25d441 is located 0 bytes to the right of global variable 'cli_styling' defined in '/home/simark/src/binutils-gdb/gdb/cli/cli-style.c:31:6' (0x55555b25d440) of size 1

The reason of this is that we have this declaration of cli_styling in cli/cli-style.h:

  extern bool cli_styling;

but ui-file.c uses its  own local declaration:

  extern int cli_styling;

Because of that, the code in ui-file.c thinks the variable is 4 bytes
long, when it is actually 1 byte long, so the generated code reads past
the variable.

Fix it by removing the declaration and making ui-file.c include
cli/cli-style.h.

gdb/ChangeLog:

	* ui-file.c: Include cli/cli-style.h.
	(term_cli_styling): Remove cli_styling declaration.
2019-09-18 13:33:33 -04:00
Andrew Burgess b078f3ac88 gdb/testsuite: Avoid directory names in test names
Give a test an actual name in order to avoid having a directory name
in the .sum file.

gdb/testsuite/ChangeLog:

	* gdb.base/source-dir.exp: Avoid having directory names in test
	names.
2019-09-18 12:36:05 -04:00
Alan Modra e6f7f6d14f bfd_asymbol_* macros
The main point of this patch is to give bfd_get_section a better name,
bfd_asymbol_section.

bfd/
	* bfd-in.h (bfd_asymbol_section): Rename from bfd_get_section.
	(bfd_get_output_section): Delete.
	(bfd_asymbol_base): Delete.
	(bfd_asymbol_section, bfd_asymbol_value, bfd_asymbol_name),
	(bfd_asymbol_bfd, bfd_asymbol_flavour): Tidy.
	(bfd_set_asymbol_name): New macro.
	* bfd-in2.h: Regenerate.
	* aout-cris.c: Update throughout to use bfd_asymbol_section.
	* aoutx.h: Likewise.
	* cofflink.c: Likewise.
	* dwarf2.c: Likewise.
	* ecoff.c: Likewise.
	* elf.c: Likewise.
	* elf32-arm.c: Likewise.
	* elf32-mips.c: Likewise.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elfn32-mips.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* linker.c: Likewise.
	* pdp11.c: Likewise.
	* elf64-mmix.c (mmix_elf_reloc): Expand bfd_get_output_section.
binutils/
	* nm.c: Update bfd_get_section to bfd_asymbol_section throughout.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* rdcoff.c: Likewise.
	* objcopy.c (create_new_symbol): Use bfd_set_asymbol_name.
	(filter_symbols): Likewise.
gas/
	* symbols.c (S_IS_LOCAL): Update bfd_get_section to
	bfd_asymbol_section.
gdb/
	* arm-tdep.c (arm_record_special_symbol): Update bfd_get_section
	to bfd_asymbol_section.
ld/
	* ldcref.c (check_reloc_refs): Update bfd_get_section to
	bfd_asymbol_section.
2019-09-18 23:07:31 +09:30
Alan Modra 1d38e9d14c Constify target name, reloc name, and carsym name
bfd/
	* bfd-in.h (carsym.name): Make const.
	* reloc.c (struct reloc_howto_struct.name): Likewise.
	* targets.c (bfd_target.name): Likewise.!
	* bfd.c (bfd_get_sign_extend_vma): Make variable const.
	* som.c (som_bfd_fill_in_ar_symbols): Use an intermediary variable
	when setting carsym.name.
	* bfd-in2.h: Regenerate.
gdb/
	* amd64-dicos-tdep.c (amd64_dicos_osabi_sniffer): Constify target.
	* i386-cygwin-tdep.c (i386_cygwin_init_abi): Likewise.
	* i386-dicos-tdep.c (i386_dicos_osabi_sniffer): Likewise.
ld/
	* ldlang.c (stricpy, strcut, name_compare): Constify params.
	(get_first_input_target): Make return and "target" const.
2019-09-18 21:32:51 +09:30
Alan Modra 90d92a632a Use bfd_set_filename more
Fixes a few leaks in bfd and ld.

bfd/
	* mach-o.c (bfd_mach_o_fat_member_init): Likewise.  Replace
	xstrdup and xmalloc with bfd_strdup and bfd_malloc.  Return an
	error status.  Adjust calls.
	* vms-lib.c (_bfd_vms_lib_get_module): Test mhd->id earlier.
	Close bfd on failure.  Replace xstrdup/bfd_alloc use with
	bfd_malloc.  Use bfd_set_filename.
gdb/
	* solib-spu.c (spu_bfd_open): Use bfd_set_filename.
	* spu-linux-nat.c (spu_bfd_open): Likewise.
ld/
	* emultempl/pe.em (after_open): Use bfd_set_filename.
	* emultempl/pep.em (after_open): Use bfd_set_filename.
2019-09-18 21:32:51 +09:30
Christian Biesinger a3d181d2e7 Make extern declaration of dwarf_always_disassemble correct
This was an oversight in 491144b5e21bbfd41969c175aebb663976f59058;
dwarf2loc.c has an extern definition for dwarf_always_disassemble
that I missed. This patch updates it from int to bool to match
the definition in dwarf2read.c.

gdb/ChangeLog:

2019-09-18  Christian Biesinger  <cbiesinger@google.com>

	* dwarf2loc.c: Change extern declaration of dwarf_always_disassemble
	to bool to match definition in dwarf2read.c.
2019-09-18 13:54:48 +09:00
Christian Biesinger 491144b5e2 Change boolean options to bool instead of int
This is for add_setshow_boolean_cmd as well as the gdb::option interface.

gdb/ChangeLog:

2019-09-17  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_ignore_descriptive_types_p): Change to bool.
	(print_signatures): Likewise.
	(trust_pad_over_xvs): Likewise.
	* arch/aarch64-insn.c (aarch64_debug): Likewise.
	* arch/aarch64-insn.h (aarch64_debug): Likewise.
	* arm-linux-nat.c (arm_apcs_32): Likewise.
	* arm-linux-tdep.c (arm_apcs_32): Likewise.
	* arm-nbsd-nat.c (arm_apcs_32): Likewise.
	* arm-tdep.c (arm_debug): Likewise.
	(arm_apcs_32): Likewise.
	* auto-load.c (debug_auto_load): Likewise.
	(auto_load_gdb_scripts): Likewise.
	(global_auto_load): Likewise.
	(auto_load_local_gdbinit): Likewise.
	(auto_load_local_gdbinit_loaded): Likewise.
	* auto-load.h (global_auto_load): Likewise.
	(auto_load_local_gdbinit): Likewise.
	(auto_load_local_gdbinit_loaded): Likewise.
	* breakpoint.c (disconnected_dprintf): Likewise.
	(breakpoint_proceeded): Likewise.
	(automatic_hardware_breakpoints): Likewise.
	(always_inserted_mode): Likewise.
	(target_exact_watchpoints): Likewise.
	(_initialize_breakpoint): Update.
	* breakpoint.h (target_exact_watchpoints): Change to bool.
	* btrace.c (maint_btrace_pt_skip_pad): Likewise.
	* cli/cli-cmds.c (trace_commands): Likewise.
	* cli/cli-cmds.h (trace_commands): Likewise.
	* cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument
	to bool*.
	* cli/cli-logging.c (logging_overwrite): Change to bool.
	(logging_redirect): Likewise.
	(debug_redirect): Likewise.
	* cli/cli-option.h (option_def) <boolean>: Change return type to bool*.
	(struct boolean_option_def) <get_var_address_cb_>: Change return type
	to bool.
	<boolean_option_def>: Update.
	(struct flag_option_def): Change default type of Context to bool
	from int.
	<flag_option_def>: Change return type of var_address_cb_ to bool*.
	* cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*.
	(get_setshow_command_value_string): Likewise.
	* cli/cli-style.c (cli_styling): Change to bool.
	(source_styling): Likewise.
	* cli/cli-style.h (source_styling): Likewise.
	(cli_styling): Likewise.
	* cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change
	to bool.
	* command.h (var_types): Update comment.
	(add_setshow_boolean_cmd): Change int* var argument to bool*.
	* compile/compile-cplus-types.c (debug_compile_cplus_types): Change to
	bool.
	(debug_compile_cplus_scopes): Likewise.
	* compile/compile-internal.h (compile_debug): Likewise.
	* compile/compile.c (compile_debug): Likewise.
	(struct compile_options) <raw>: Likewise.
	* cp-support.c (catch_demangler_crashes): Likewise.
	* cris-tdep.c (usr_cmd_cris_version_valid): Likewise.
	(usr_cmd_cris_dwarf2_cfi): Likewise.
	* csky-tdep.c (csky_debug): Likewise.
	* darwin-nat.c (enable_mach_exceptions): Likewise.
	* dcache.c (dcache_enabled_p): Likewise.
	* defs.h (info_verbose): Likewise.
	* demangle.c (demangle): Likewise.
	(asm_demangle): Likewise.
	* dwarf-index-cache.c (debug_index_cache): Likewise.
	* dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise.
	* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise.
	* dwarf2read.c (check_physname): Likewise.
	(use_deprecated_index_sections): Likewise.
	(dwarf_always_disassemble): Likewise.
	* eval.c (overload_resolution): Likewise.
	* event-top.c (set_editing_cmd_var): Likewise.
	(exec_done_display_p): Likewise.
	* event-top.h (set_editing_cmd_var): Likewise.
	(exec_done_display_p): Likewise.
	* exec.c (write_files): Likewise.
	* fbsd-nat.c (debug_fbsd_lwp): Likewise
	(debug_fbsd_nat): Likewise.
	* frame.h (struct frame_print_options) <print_raw_frame_arguments>:
	Likewise.
	(struct set_backtrace_options) <backtrace_past_main>: Likewise.
	<backtrace_past_entry> Likewise.
	* gdb-demangle.h (demangle): Likewise.
	(asm_demangle): Likewise.
	* gdb_bfd.c (bfd_sharing): Likewise.
	* gdbcore.h (write_files): Likewise.
	* gdbsupport/common-debug.c (show_debug_regs): Likewise.
	* gdbsupport/common-debug.h (show_debug_regs): Likewise.
	* gdbthread.h (print_thread_events): Likewise.
	* gdbtypes.c (opaque_type_resolution): Likewise.
	(strict_type_checking): Likewise.
	* gnu-nat.c (gnu_debug_flag): Likewise.
	* guile/scm-auto-load.c (auto_load_guile_scripts): Likewise.
	* guile/scm-param.c (pascm_variable): Add boolval.
	(add_setshow_generic): Update.
	(pascm_param_value): Update.
	(pascm_set_param_value_x): Update.
	* hppa-tdep.c (hppa_debug): Change to bool..
	* infcall.c (may_call_functions_p): Likewise.
	(coerce_float_to_double_p): Likewise.
	(unwind_on_signal_p): Likewise.
	(unwind_on_terminating_exception_p): Likewise.
	* infcmd.c (startup_with_shell): Likewise.
	* inferior.c (print_inferior_events): Likewise.
	* inferior.h (startup_with_shell): Likewise.
	(print_inferior_events): Likewise.
	* infrun.c (step_stop_if_no_debug): Likewise.
	(detach_fork): Likewise.
	(debug_displaced): Likewise.
	(disable_randomization): Likewise.
	(non_stop): Likewise.
	(non_stop_1): Likewise.
	(observer_mode): Likewise.
	(observer_mode_1): Likewise.
	(set_observer_mode): Update.
	(sched_multi): Change to bool.
	* infrun.h (debug_displaced): Likewise.
	(sched_multi): Likewise.
	(step_stop_if_no_debug): Likewise.
	(non_stop): Likewise.
	(disable_randomization): Likewise.
	* linux-tdep.c (use_coredump_filter): Likewise.
	(dump_excluded_mappings): Likewise.
	* linux-thread-db.c (auto_load_thread_db): Likewise.
	(check_thread_db_on_load): Likewise.
	* main.c (captured_main_1): Update.
	* maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt,
	xx2_opt, boolean_opt>: Change to bool.
	* maint-test-settings.c (maintenance_test_settings_boolean): Likewise.
	* maint.c (maintenance_profile_p): Likewise.
	(per_command_time): Likewise.
	(per_command_space): Likewise.
	(per_command_symtab): Likewise.
	* memattr.c (inaccessible_by_default): Likewise.
	* mi/mi-main.c (mi_async): Likewise.
	(mi_async_1): Likewise.
	* mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise.
	* nat/fork-inferior.h (startup_with_shell): Likewise.
	* nat/linux-namespaces.c (debug_linux_namespaces): Likewise.
	* nat/linux-namespaces.h (debug_linux_namespaces): Likewise.
	* nios2-tdep.c (nios2_debug): Likewise.
	* or1k-tdep.c (or1k_debug): Likewise.
	* parse.c (parser_debug): Likewise.
	* parser-defs.h (parser_debug): Likewise.
	* printcmd.c (print_symbol_filename): Likewise.
	* proc-api.c (procfs_trace): Likewise.
	* python/py-auto-load.c (auto_load_python_scripts): Likewise.
	* python/py-param.c (union parmpy_variable): Add "bool boolval" field.
	(set_parameter_value): Update.
	(add_setshow_generic): Update.
	* python/py-value.c (copy_py_bool_obj): Change argument from int*
	to bool*.
	* python/python.c (gdbpy_parameter_value): Cast to bool* instead of
	int*.
	* ravenscar-thread.c (ravenscar_task_support): Change to bool.
	* record-btrace.c (record_btrace_target::store_registers): Update.
	* record-full.c (record_full_memory_query): Change to bool.
	(record_full_stop_at_limit): Likewise.
	* record-full.h (record_full_memory_query): Likewise.
	* remote-notif.c (notif_debug): Likewise.
	* remote-notif.h (notif_debug): Likewise.
	* remote.c (use_range_stepping): Likewise.
	(interrupt_on_connect): Likewise.
	(remote_break): Likewise.
	* ser-tcp.c (tcp_auto_retry): Likewise.
	* ser-unix.c (serial_hwflow): Likewise.
	* skip.c (debug_skip): Likewise.
	* solib-aix.c (solib_aix_debug): Likewise.
	* spu-tdep.c (spu_stop_on_load_p): Likewise.
	(spu_auto_flush_cache_p): Likewise.
	* stack.c (struct backtrace_cmd_options) <full, no_filters, hide>:
	Likewise.
	(struct info_print_options) <quiet>: Likewise.
	* symfile-debug.c (debug_symfile): Likewise.
	* symfile.c (auto_solib_add): Likewise.
	(separate_debug_file_debug): Likewise.
	* symfile.h (auto_solib_add): Likewise.
	(separate_debug_file_debug): Likewise.
	* symtab.c (basenames_may_differ): Likewise.
	(struct filename_partial_match_opts) <dirname, basename>: Likewise.
	(struct info_print_options) <quiet, exclude_minsyms>: Likewise.
	(struct info_types_options) <quiet>: Likewise.
	* symtab.h (demangle): Likewise.
	(basenames_may_differ): Likewise.
	* target-dcache.c (stack_cache_enabled_1): Likewise.
	(code_cache_enabled_1): Likewise.
	* target.c (trust_readonly): Likewise.
	(may_write_registers): Likewise.
	(may_write_memory): Likewise.
	(may_insert_breakpoints): Likewise.
	(may_insert_tracepoints): Likewise.
	(may_insert_fast_tracepoints): Likewise.
	(may_stop): Likewise.
	(auto_connect_native_target): Likewise.
	(target_stop_and_wait): Update.
	(target_async_permitted): Change to bool.
	(target_async_permitted_1): Likewise.
	(may_write_registers_1): Likewise.
	(may_write_memory_1): Likewise.
	(may_insert_breakpoints_1): Likewise.
	(may_insert_tracepoints_1): Likewise.
	(may_insert_fast_tracepoints_1): Likewise.
	(may_stop_1): Likewise.
	* target.h (target_async_permitted): Likewise.
	(may_write_registers): Likewise.
	(may_write_memory): Likewise.
	(may_insert_breakpoints): Likewise.
	(may_insert_tracepoints): Likewise.
	(may_insert_fast_tracepoints): Likewise.
	(may_stop): Likewise.
	* thread.c (struct info_threads_opts) <show_global_ids>: Likewise.
	(make_thread_apply_all_options_def_group): Change argument from int*
	to bool*.
	(thread_apply_all_command): Update.
	(print_thread_events): Change to bool.
	* top.c (confirm): Likewise.
	(command_editing_p): Likewise.
	(history_expansion_p): Likewise.
	(write_history_p): Likewise.
	(info_verbose): Likewise.
	* top.h (confirm): Likewise.
	(history_expansion_p): Likewise.
	* tracepoint.c (disconnected_tracing): Likewise.
	(circular_trace_buffer): Likewise.
	* typeprint.c (print_methods): Likewise.
	(print_typedefs): Likewise.
	* utils.c (debug_timestamp): Likewise.
	(sevenbit_strings): Likewise.
	(pagination_enabled): Likewise.
	* utils.h (sevenbit_strings): Likewise.
	(pagination_enabled): Likewise.
	* valops.c (overload_resolution): Likewise.
	* valprint.h (struct value_print_options) <prettyformat_arrays,
	prettyformat_structs, vtblprint, unionprint, addressprint, objectprint,
	stop_print_at_null, print_array_indexes, deref_ref, static_field_print,
	pascal_static_field_print, raw, summary, symbol_print, finish_print>:
	Likewise.
	* windows-nat.c (new_console): Likewise.
	(cygwin_exceptions): Likewise.
	(new_group): Likewise.
	(debug_exec): Likewise.
	(debug_events): Likewise.
	(debug_memory): Likewise.
	(debug_exceptions): Likewise.
	(useshell): Likewise.
	* windows-tdep.c (maint_display_all_tib): Likewise.
	* xml-support.c (debug_xml): Likewise.
2019-09-18 09:35:12 +09:00
Mike Gulick f1b620e9b4 gdb: Look for compilation directory relative to directory search path
The 'directory' command allows the user to provide a list of filesystem
directories in which to search for source code.  The directories in this
search path are used as the base directory for the source filename from
the debug information (DW_AT_name).  Thus the directory search path
provides alternatives to the existing compilation directory from the
debug information (DW_AT_comp_dir).  Generally speaking, DW_AT_name
stores the filename argument passed to the compiler (including any
directory components), and DW_AT_comp_dir stores the current working
directory from which the compiler was executed.  For example:

    $ cd /path/to/project/subdir1
    $ gcc -c a/test.c -g

The corresponding debug information will look like this:

    DW_AT_name      : a/test.c
    DW_AT_comp_dir  : /path/to/project/subdir1

When compiling with the -fdebug-prefix-map GCC option, the compilation
directory can be arbitrarily rewritten.  In the above example, we may
rewrite the compilation directory as follows:

    $ gcc -c a/test.c -g -fdebug-prefix-map=/path/to/project=

In this case, the corresponding debug information will look like:

    DW_AT_name      : a/test.c
    DW_AT_comp_dir  : /subdir1

This prevents GDB from finding the corresponding source code based on
the debug information alone.  In some cases, a substitute-path command
can be used to re-map a consistent prefix in the rewritten compilation
directory to the real filesystem path.  However, there may not be a
consistent prefix remaining in the debug symbols (for example in a
project that has source code in many subdirectories under the project's
root), thereby requiring multiple substitute-path rules.  In this case,
it is easier to add the missing prefix to the directory search path via
the 'directory' command.

The function find_and_open_source currently searches in:

    SEARCH_PATH/FILENAME

where SEARCH_PATH corresponds to each individual entry in the directory
search path (which is guaranteed to contain the compilation directory
from the debug information, as well as the current working directory).
FILENAME corresponds to the source filename (DW_AT_name), which may have
directory components in it.  In addition, GDB searches in:

    SEARCH_PATH/FILE_BASENAME

where FILE_BASENAME is the basename of the DW_AT_name entry.

This change modifies find_and_open_source to additionally search in:

    SEARCH_PATH/COMP_DIR/FILENAME

where COMP_DIR is the compilation directory from the debug symbols.  In
the example given earlier, running:

    (gdb) directory /path/to/project

will now allow GDB to correctly locate the source code from the debug
information.

gdb/ChangeLog:

	* source.c (prepare_path_for_appending): New function.
	(openp): Make use of new function.
	(find_and_open_source): Search for the compilation directory and
	source file as a relative path beneath the directory search path.

gdb/doc/ChangeLog:

	* gdb.texinfo (Source Path): Additional text to better describe
	how the source path directory list is used when searching for
	source files.

gdb/testsuite/ChangeLog:

	* gdb.base/source-dir.exp: Add extra test for mapped compilation
	directory.
2019-09-17 16:20:19 -04:00
Andrew Burgess 67f3ed6afe gdb: Catch exceptions when accessing source cache
The source_cache::get_line_charpos function can currently throw an
exception if the source file is missing, which doesn't match the
expected behaviour documented in the functions header file.  The
documented behaviour is to return false on failure, and this is how
the function appears to be used throughout GDB.

I spotted this in the 'info source' command, currently for a missing
source file you'll see something like this:

  (gdb) info source
  Current source file is /path/to/src/file.c
  Compilation directory is /path/to/build/
  /path/to/src/file.c: No such file or directory.
  (gdb)

After this patch we see this:

  (gdb) info source
  Current source file is /path/to/src/file.c
  Compilation directory is /path/to/build/
  Source language is c.
  Producer is COMPILER VERSION AND FLAGS.
  Compiled with DWARF 2 debugging format.
  Does not include preprocessor macro info.

We don't currently indicate that the source file can't be found, and
maybe that would be something worth adding in the future.

gdb/ChangeLog:

	* source-cache.c (source_cache::get_line_charpos): Catch
	exceptions and return false, this matches the behaviour documented
	in the header file.

gdb/testsuite/ChangeLog:

	* gdb.base/list-missing-source.exp: New file.
2019-09-17 15:53:32 -04:00
Joel Brobecker 7433218996 (Ada) do not print Ada task names in quotes in "info tasks" output
A recent change enhanced a couple of notifications about Ada tasks to
include the task's name in addition to the task's number. That change
also modified the output of the "info tasks" when printing the detailed
information of one given task. I believe this change was unintentionally
left over from the initial version after it was decided that quoting
the task's name should not be done. This patch therefore undoes this
part of the patch.

gdb/ChangeLog:

        * ada-tasks.c (info_task): Remove quoting of the task's name.

Tested on x86_64-linux, with both the official testsuite as well as
AdaCore's testsuite.
2019-09-17 14:27:55 -04:00
Christian Biesinger f2f24aa9c4 Don't duplicate comment in symfile.c and .h
This just replaces the comment in the .c file with
"See symfile.h.".

gdb/ChangeLog:

2019-09-16  Christian Biesinger  <cbiesinger@google.com>

	* symfile.c (auto_solib_add): Replace comment with a reference
	to the header file.
2019-09-16 22:10:36 -05:00
Christian Biesinger 6a062a93d7 Add a NEWS entry that gdb can be compiled with py3 on Windows.
This was fixed in commit 272044897e.

2019-09-14  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention that gdb can now be compiled with Python 3
	on Windows.
2019-09-14 22:36:47 -04:00
Tom de Vries d1b70248bd [gdb/testsuite] Require gnatmake 8 for gdb.ada/rename_subscript_param.exp
When running gdb.ada/rename_subscript_param.exp with gnatmake 7.4.1, we get:
...
FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \
  before changing its value
FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \
  after changing its value
...

The commit last touching the test-case (afcfda091e) states:
...
    The test still fails with old compilers that do not properly
    generate debug info for this renaming:
...

Fix this by requiring at least gnatmake 8 for the test-case.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-14  Tom de Vries  <tdevries@suse.de>

	PR teststuite/24599
	* gdb.ada/rename_subscript_param.exp: Require gnatmake 8.
	* lib/ada.exp (gnatmake_version_at_least): New proc.
2019-09-14 10:35:48 +02:00
Andrew Burgess ec6c8338a8 gdb: Force use of float version of log10
This commit:

  commit aa17805fb9
  Date:   Sat Aug 31 23:44:40 2019 +0100

      gdb: Have 'maint info sections' print all sections again

introduced a use of log10 that took an int as a parameter.
Unfortunately this was causing a compilation error on Solaris, see:

  https://sourceware.org/ml/gdb-patches/2019-09/msg00230.html
  https://sourceware.org/ml/gdb-patches/2019-09/msg00231.html

because there was only a float, double, or long double version of
log10, and the compiler doesn't know which to choose.

This commit should resolve this issue by casting the argument to
float.

gdb/ChangeLog:

	* maint.c (maint_print_section_data::maint_print_section_data):
	Force use of 'float log10 (float)' by casting the argument to
	float.
2019-09-12 21:23:37 -04:00
Andrew Burgess 5fabdcd680 gdb/testsuite: Make use of exec_has_index_section function
Make use of exec_has_index_section library function rather than
manually checking in the 'maintenance info sections' output.  Should
make no difference to the test results, just makes the code easier to
read.

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Use exec_has_index_section.
2019-09-12 20:31:29 -04:00
Andrew Burgess aa17805fb9 gdb: Have 'maint info sections' print all sections again
In this commit:

  commit 6eac171f06
  Date:   Fri Aug 16 00:25:14 2019 +0200

      [gdb] Make maint info sections print relocated addresses

A couple of things broke with the 'maintenance info sections' command,
here is some before output:

  (gdb) maintenance info sections
  Exec file:
      `/path/to/gdb/build/gdb/testsuite/outputs/gdb.base/maint/maint',
          file type elf64-x86-64.
   [0]     0x00400238->0x00400254 at 0x00000238: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS
   [1]     0x00400254->0x00400274 at 0x00000254: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS
   [2]     0x00400274->0x00400298 at 0x00000274: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS
   [3]     0x00400298->0x004002bc at 0x00000298: .gnu.hash ALLOC LOAD READONLY DATA HAS_CONTENTS
   [4]     0x004002c0->0x00400380 at 0x000002c0: .dynsym ALLOC LOAD READONLY DATA HAS_CONTENTS
   [5]     0x00400380->0x004003e3 at 0x00000380: .dynstr ALLOC LOAD READONLY DATA HAS_CONTENTS
   [6]     0x004003e4->0x004003f4 at 0x000003e4: .gnu.version ALLOC LOAD READONLY DATA HAS_CONTENTS
   [7]     0x004003f8->0x00400418 at 0x000003f8: .gnu.version_r ALLOC LOAD READONLY DATA HAS_CONTENTS
   [8]     0x00400418->0x00400460 at 0x00000418: .rela.dyn ALLOC LOAD READONLY DATA HAS_CONTENTS
   [9]     0x00400460->0x004004c0 at 0x00000460: .rela.plt ALLOC LOAD READONLY DATA HAS_CONTENTS
   [10]     0x004004c0->0x004004d7 at 0x000004c0: .init ALLOC LOAD READONLY CODE HAS_CONTENTS
   [11]     0x004004e0->0x00400530 at 0x000004e0: .plt ALLOC LOAD READONLY CODE HAS_CONTENTS
   [12]     0x00400530->0x00400802 at 0x00000530: .text ALLOC LOAD READONLY CODE HAS_CONTENTS
   [13]     0x00400804->0x0040080d at 0x00000804: .fini ALLOC LOAD READONLY CODE HAS_CONTENTS
   [14]     0x00400810->0x0040084e at 0x00000810: .rodata ALLOC LOAD READONLY DATA HAS_CONTENTS
   [15]     0x00400850->0x004008c4 at 0x00000850: .eh_frame_hdr ALLOC LOAD READONLY DATA HAS_CONTENTS
   [16]     0x004008c8->0x00400ab8 at 0x000008c8: .eh_frame ALLOC LOAD READONLY DATA HAS_CONTENTS
   [17]     0x00600e00->0x00600e08 at 0x00000e00: .init_array ALLOC LOAD DATA HAS_CONTENTS
   [18]     0x00600e08->0x00600e10 at 0x00000e08: .fini_array ALLOC LOAD DATA HAS_CONTENTS
   [19]     0x00600e10->0x00600ff0 at 0x00000e10: .dynamic ALLOC LOAD DATA HAS_CONTENTS
   [20]     0x00600ff0->0x00601000 at 0x00000ff0: .got ALLOC LOAD DATA HAS_CONTENTS
   [21]     0x00601000->0x00601038 at 0x00001000: .got.plt ALLOC LOAD DATA HAS_CONTENTS
   [22]     0x00601038->0x0060103c at 0x00001038: .data ALLOC LOAD DATA HAS_CONTENTS
   [23]     0x00601040->0x006012c8 at 0x0000103c: .bss ALLOC
   [24]     0x00000000->0x0000002c at 0x0000103c: .comment READONLY HAS_CONTENTS
   [25]     0x00000000->0x00000060 at 0x00001068: .debug_aranges READONLY HAS_CONTENTS
   [26]     0x00000000->0x0000061b at 0x000010c8: .debug_info READONLY HAS_CONTENTS
   [27]     0x00000000->0x00000264 at 0x000016e3: .debug_abbrev READONLY HAS_CONTENTS
   [28]     0x00000000->0x000001e6 at 0x00001947: .debug_line READONLY HAS_CONTENTS
   [29]     0x00000000->0x00000487 at 0x00001b2d: .debug_str READONLY HAS_CONTENTS
  (gdb)

And here is the output after the above commit:

  (gdb) maintenance info sections
  +maintenance info sections
  Exec file:
      `/path/to/gdb/build/gdb/testsuite/outputs/gdb.base/maint/maint',
          file type elf64-x86-64.
      0x00400238->0x00400254 at 0x00000238: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400254->0x00400274 at 0x00000254: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400274->0x00400298 at 0x00000274: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400298->0x004002bc at 0x00000298: .gnu.hash ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x004002c0->0x00400380 at 0x000002c0: .dynsym ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400380->0x004003e3 at 0x00000380: .dynstr ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x004003e4->0x004003f4 at 0x000003e4: .gnu.version ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x004003f8->0x00400418 at 0x000003f8: .gnu.version_r ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400418->0x00400460 at 0x00000418: .rela.dyn ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400460->0x004004c0 at 0x00000460: .rela.plt ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x004004c0->0x004004d7 at 0x000004c0: .init ALLOC LOAD READONLY CODE HAS_CONTENTS
      0x004004e0->0x00400530 at 0x000004e0: .plt ALLOC LOAD READONLY CODE HAS_CONTENTS
      0x00400530->0x00400802 at 0x00000530: .text ALLOC LOAD READONLY CODE HAS_CONTENTS
      0x00400804->0x0040080d at 0x00000804: .fini ALLOC LOAD READONLY CODE HAS_CONTENTS
      0x00400810->0x0040084e at 0x00000810: .rodata ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00400850->0x004008c4 at 0x00000850: .eh_frame_hdr ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x004008c8->0x00400ab8 at 0x000008c8: .eh_frame ALLOC LOAD READONLY DATA HAS_CONTENTS
      0x00600e00->0x00600e08 at 0x00000e00: .init_array ALLOC LOAD DATA HAS_CONTENTS
      0x00600e08->0x00600e10 at 0x00000e08: .fini_array ALLOC LOAD DATA HAS_CONTENTS
      0x00600e10->0x00600ff0 at 0x00000e10: .dynamic ALLOC LOAD DATA HAS_CONTENTS
      0x00600ff0->0x00601000 at 0x00000ff0: .got ALLOC LOAD DATA HAS_CONTENTS
      0x00601000->0x00601038 at 0x00001000: .got.plt ALLOC LOAD DATA HAS_CONTENTS
      0x00601038->0x0060103c at 0x00001038: .data ALLOC LOAD DATA HAS_CONTENTS
      0x00601040->0x006012c8 at 0x0000103c: .bss ALLOC
      0x00000000->0x00000000 at 0x00000000: *COM* IS_COMMON
      0x00000000->0x00000000 at 0x00000000: *UND*
      0x00000000->0x00000000 at 0x00000000: *ABS*
      0x00000000->0x00000000 at 0x00000000: *IND*
  (gdb)

We lost the section index numbers, but more importantly, we lost the
information about the .debug* sections.  We also gained entries for
the "fake" sections *COM*, *UND*, *ABS*, and *IND*.

I noticed this when running:

  make check-gdb RUNTESTFLAGS="--target_board=cc-with-gdb-index gdb.base/maint.exp"

As this test relies on looking in the 'maint info sections' output to
see if we have a .debug_names or .gdb_index section, and these are
debug sections so they no longer show up in the 'main info sections'
output, the gdb.base/maint.exp test fails.

This commit restores the old behaviour while keeping the important
change that the above commit introduced, the addresses printed for
sections are the relocated addresses where appropriate.  The above
commit mentions using this test:

   make check-gdb RUNTESTFLAGS="CFLAGS_FOR_TARGET='-pie' gdb.base/compare-sections.exp"

And this still passes after this commit.

The output for 'maint info sections' now looks like this:

  (gdb) maintenance info sections
  Exec file:
      `/home/andrew/projects/binutils-gdb/build/gdb/testsuite/outputs/gdb.base/maint/maint',
          file type elf64-x86-64.
   [0]      0x00400238->0x00400254 at 0x00000238: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS
   [1]      0x00400254->0x00400274 at 0x00000254: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS
   [2]      0x00400274->0x00400298 at 0x00000274: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS
   [3]      0x00400298->0x004002bc at 0x00000298: .gnu.hash ALLOC LOAD READONLY DATA HAS_CONTENTS
   [4]      0x004002c0->0x00400380 at 0x000002c0: .dynsym ALLOC LOAD READONLY DATA HAS_CONTENTS
   [5]      0x00400380->0x004003e3 at 0x00000380: .dynstr ALLOC LOAD READONLY DATA HAS_CONTENTS
   [6]      0x004003e4->0x004003f4 at 0x000003e4: .gnu.version ALLOC LOAD READONLY DATA HAS_CONTENTS
   [7]      0x004003f8->0x00400418 at 0x000003f8: .gnu.version_r ALLOC LOAD READONLY DATA HAS_CONTENTS
   [8]      0x00400418->0x00400460 at 0x00000418: .rela.dyn ALLOC LOAD READONLY DATA HAS_CONTENTS
   [9]      0x00400460->0x004004c0 at 0x00000460: .rela.plt ALLOC LOAD READONLY DATA HAS_CONTENTS
   [10]     0x004004c0->0x004004d7 at 0x000004c0: .init ALLOC LOAD READONLY CODE HAS_CONTENTS
   [11]     0x004004e0->0x00400530 at 0x000004e0: .plt ALLOC LOAD READONLY CODE HAS_CONTENTS
   [12]     0x00400530->0x00400802 at 0x00000530: .text ALLOC LOAD READONLY CODE HAS_CONTENTS
   [13]     0x00400804->0x0040080d at 0x00000804: .fini ALLOC LOAD READONLY CODE HAS_CONTENTS
   [14]     0x00400810->0x0040084e at 0x00000810: .rodata ALLOC LOAD READONLY DATA HAS_CONTENTS
   [15]     0x00400850->0x004008c4 at 0x00000850: .eh_frame_hdr ALLOC LOAD READONLY DATA HAS_CONTENTS
   [16]     0x004008c8->0x00400ab8 at 0x000008c8: .eh_frame ALLOC LOAD READONLY DATA HAS_CONTENTS
   [17]     0x00600e00->0x00600e08 at 0x00000e00: .init_array ALLOC LOAD DATA HAS_CONTENTS
   [18]     0x00600e08->0x00600e10 at 0x00000e08: .fini_array ALLOC LOAD DATA HAS_CONTENTS
   [19]     0x00600e10->0x00600ff0 at 0x00000e10: .dynamic ALLOC LOAD DATA HAS_CONTENTS
   [20]     0x00600ff0->0x00601000 at 0x00000ff0: .got ALLOC LOAD DATA HAS_CONTENTS
   [21]     0x00601000->0x00601038 at 0x00001000: .got.plt ALLOC LOAD DATA HAS_CONTENTS
   [22]     0x00601038->0x0060103c at 0x00001038: .data ALLOC LOAD DATA HAS_CONTENTS
   [23]     0x00601040->0x006012c8 at 0x0000103c: .bss ALLOC
   [24]     0x00000000->0x0000002c at 0x0000103c: .comment READONLY HAS_CONTENTS
   [25]     0x00000000->0x00000060 at 0x00001068: .debug_aranges READONLY HAS_CONTENTS
   [26]     0x00000000->0x0000061b at 0x000010c8: .debug_info READONLY HAS_CONTENTS
   [27]     0x00000000->0x00000264 at 0x000016e3: .debug_abbrev READONLY HAS_CONTENTS
   [28]     0x00000000->0x000001e6 at 0x00001947: .debug_line READONLY HAS_CONTENTS
   [29]     0x00000000->0x00000487 at 0x00001b2d: .debug_str READONLY HAS_CONTENTS
  (gdb)

This is basically as it was before, except that the index numbers are
now padded so the section information all lines up.

When GDB has relocated a section then the relocated addresses will be
printed, otherwise the non-relocated addresses from the bfd will be
printed.

I've added a test to gdb.base/maint.exp to do some basic validation of
the output format.

gdb/ChangeLog:

	* maint.c: Add 'cmath' include.
	(struct maint_print_section_data): New structure.
	(print_section_index): New function.
	(print_bfd_section_info): Add header comment, small whitespace
	cleanup, and update to call new print_section_index function.
	(print_objfile_section_info): Likewise.
	(maint_obj_section_from_bfd_section): New function.
	(print_bfd_section_info_maybe_relocated): New function.
	(maintenance_info_sections): Add header comment, always use
	bfd_map_over_sections instead of ALL_OBJFILE_OSECTIONS.

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Add test for 'maint info sections'.
2019-09-12 20:31:29 -04:00
Andrew Burgess 3dd9bb4620 gdb: Don't fault for 'maint print psymbols' when using an index
I found that these tests:

  make check-gdb RUNTESTFLAGS="--target_board=cc-with-gdb-index gdb.base/maint.exp"
  make check-gdb RUNTESTFLAGS="--target_board=cc-with-debug-names gdb.base/maint.exp"

were causing GDB to segfault.  It turns out that this test runs this
command:

  maint print psymbols -pc main /path/to/some/file

which tries to lookup the partial_symtab for 'main'.  The problem is
that there is no partial_symtab for 'main' as we are using the
.gdb_index or .debug_names instead of partial_symtabs.

What happens is that maintenance_print_symbols calls
find_pc_sect_psymtab, which looks for the partial_symtab in the
objfile's objfile->partial_symtabs->psymtabs_addrmap.

This is a problem because when we are using the indexes
psymtabs_addrmap is reused to hold things other than partial_symtabs,
this can be seen in dwarf2read.c in create_addrmap_from_index and
create_addrmap_from_aranges.  If we then lookup in psymtabs_addrmap we
end up returning a pointer to something that isn't really a
partial_symtab, after which everything goes wrong.

Initially I simply added a check at the start of find_pc_sect_psymtab
that the objfile had some partial_symtabs, like:

  if (objfile->partial_symtabs->psymtabs == NULL)
    return NULL;

Figuring that if there were no partial_symtabs at all then this
function should always return NULL, however, this caused a failure in
the test gdb.python/py-event.exp which I didn't dig into too deeply,
but seems to be that in this tests there are initially no psymtabs,
but the second part of find_pc_sect_psymtab does manage to read some
in from somewhere, with the check I added the test fails as we
returned NULL here and this caused GDB to load in the full symtabs
earlier than was expected.

Instead I chose to guard only the access to psymtabs_addrmap with a
check that the function has some psymtabs.  This allows my original
tests to pass, and the py-event.exp test to pass too.

Now, a good argument can be made that we simply should never call
find_pc_sect_psymtab on an objfile that is using indexes instead of
partial_symtabs.  I did consider this approach, we could easily add an
assert into find_pc_sect_psymtab that if we find a partial_symtab in
psymtabs_addrmap then the psymtabs pointer must be non-null.  The
responsibility would then be on the user of find_pc_sect_psymtab to
ensure that the objfile being checked is suitable.  In the end I
didn't take this approach as the check in find_pc_sect_psymtab is
cheap and this ensures that any future miss-uses of the function will
not cause problems.

I also extended the comment on psymtabs_addrmap to indicate that it
holds more than just partial_symtabs as this was not at all clear from
the original comment, and caused me some confusion when I was
initially debugging this problem.

gdb/ChangeLog:

	* psymtab.c (find_pc_sect_psymtab): Move baseaddr local into more
	inner scope, add check that the objfile has psymtabs before
	checking psymtabs_addrmap.
	* psymtab.h (psymtab_storage) <psymtabs_addrmap>: Extend comment.
2019-09-12 20:31:29 -04:00
Tom de Vries 25e5c20918 [gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported
The test-case gdb.base/store.exp fails with gcc 7.4.0:
...
nr of unexpected failures        27
...

The first FAIL:
...
110       l = add_float (l, r);
(gdb) PASS: gdb.base/store.exp: continue to wack_float
print l
$21 = <optimized out>
FAIL: gdb.base/store.exp: var float l; print old l, expecting -1
...
relates to this bit in the test-case (compiled at -O0):
...
   106  float
   107  wack_float (register float u, register float v)
   108  {
   109    register float l = u, r = v;
   110    l = add_float (l, r);
   111    return l + r;
   112  }
...
and it expects to be able to read and modify variable l before executing line
110, but it already fails to read the value, because l has no DW_AT_location
attribute in the debug info.

Variable l is declared with the register keyword, and GCC implements the
register keyword at -O0 like so:
...
the compiler allocates distinct stack memory for all variables that do not
have the register storage-class specifier; if register is specified, the
variable may have a shorter lifespan than the code would indicate and may
never be placed in memory.
...

The fact that l has no DW_AT_location attribute, matches with the documented
"variable may have a shorter lifespan that code would indicate", (though it
is the most extreme case of it) so the gcc behaviour is valid.  We can of
course improve gcc to generate better debuginfo (filed gcc PR91611), but
this not a wrong-debug problem.

[ The test-case passes with gcc 4.2.1, but for the failing test discussed
above, it passes simply because it doesn't store l in a register. ]

With the debug info missing for l, reading and setting l is unsupported, so
fix the FAIL by marking the test UNSUPPORTED instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-12  Tom de Vries  <tdevries@suse.de>

	* gdb.base/store.exp: Allow register variables to be optimized out at
	-O0.
2019-09-12 22:36:37 +02:00
Philippe Waroquiers 4993045d18 Output the Ada task name in more messages.
With this patch, we e.g. get:
      [Switching to task 2 "task_list(1)"]
      [Current task is 2 "task_list(1)"]
    instead of
      [Switching to task 2]
      [Current task is 2]

The logic to produce the taskno optionally followed
by the task name has been factorized in the task_to_str function.

Task names are output between double quotes in the new messages,
similarly to what GDB does for thread names.
However, no quotes are put around task names in 'info tasks' Name column.
This was discussed with Tom, that preferred no quotes there, while I
was more in favour of visual consistency.
I discussed with a few more users, which led to (exactly) 50% preferring
quotes and 50% preferring no quotes :).
To arrive to the decision to remove the quotes, the following "killing args"
were used:
 * To have quotes or to not have quotes, that is the question; yes
   but not *THE* question :).
 * If there is not a clear majority that prefers quotes, better to
   not disturb the existing user basis for a (somewhat) irrelevant
   aspect.
 * The opinion of the reviewer has more weight.

So, compared to the previous version, this version remotes the quotes
in 'info tasks'.

It improves the alignement of 'info tasks' output.
With this patch, we get:
      (gdb) info task
         ID           TID P-ID Pri State                  Name
      *   1  555555759030       48 Runnable               main_task
          2  555555759e30    1  48 Selective Wait         mit
      (gdb)
   instead of
      (gdb) info task
         ID       TID P-ID Pri State                  Name
      *   1 555555759030       48 Runnable               main_task
          2 555555759e30    1  48 Selective Wait         mit
      (gdb)
(e.g. the first one properly shows parent and priority under the
correct header).

This is version 4 of the 'task name' patch.
Compared to version 3, the changes are:
   output task names between quotes but not in 'info tasks'

gdb/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS: Announce that Ada task names are now shown at more places,
	and between quotes (except in info task output).
	* gdb/ada-tasks.c (task_to_str): New function.
	(display_current_task_id): Call task_to_str.
	(task_command_1): Likewise.
	(print_ada_task_info): In non-mi mode, Properly align headers and data
	when task-id length is > 9 (9 is the default for a 32 bits CORE_ADDR).

gdb/doc/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Ada Tasks): Tell the task name is printed, update
	examples.

gdb/testsuite/ChangeLog
2019-09-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.ada/rdv_wait.exp: Update to new task names.
	* gdb.base/task_switch_in_core.exp: Likewise.
	* gdb.base/info_sources_base.c: Likewise.
2019-09-12 21:57:10 +02:00
Rainer Orth 7a28970742 Fix signals reported for faults on Solaris
It's been a long-standing nuisance that gdb reported unaligned accesses
on Solaris/SPARC as SIGSEGV, contrary to the shells and truss which
correctly report SIGBUS instead.

I could trace this down to the fault handling code in procfs.c
(procfs_target::wait): when pr_why is set to PR_FAULTED, the current
code sets the signal based on the fault number.  For one, the code gets
this wrong for FLTACCESS (the unaligned access case) where it uses
SIGSEGV.  What's worse, it's completely unnecessary to make up the
signal number inside gdb.  Instead, it should just take what procfs
reports to avoid mismatches, which is what this patch does.  I've
completely removed the explicit handling of the various fault codes: for
one, the list has already been incomplete, lacking FLTCPCOVF which
existed since at least Solaris 8.  Besides, there's no reason to error
out on unknown fault codes: either the fault causes a signal which can
then be reported from procfs, or it doesn't (as for FLTPAGE) and no
reporting is necessary.

Tested on sparcv9-sun-solaris2.11 and x86_64-pc-solaris2.11.  Also
spot-checked manually for a couple of cases (unaligned access, division
by 0, NULL pointer dereference).

	* procfs.c (procfs_target::wait) <PR_FAULTED>: Get signal from
	prstatus.pr_lwp.pr_info instead of making it up.
2019-09-12 10:40:59 +02:00
Christian Biesinger f2aec7f6d1 Make relocate_{path,gdb_directory} return std::string
This simplifies memory management. I've also changed some global variables
to std::string accordingly (which store the result of these functions),
but not all because some are used with add_setshow_optional_filename_cmd
which requires a char*.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* auto-load.c (auto_load_expand_dir_vars): Update.
	* defs.h (gdb_datadir): Change to std::string.
	(python_libdir): Likewise.
	(relocate_gdb_directory): Change return type to std::string.
	* guile/guile.c (gdbscm_data_directory): Update.
	(initialize_scheme_side): Update.
	* jit.c (jit_reader_dir): Change to std::string.
	(jit_reader_load_command): Update.
	* main.c (gdb_datadir): Change to std::string.
	(python_libdir): Likewise.
	(set_gdb_data_directory): Update.
	(relocate_path): Change to return std::string.
	(relocate_gdb_directory): Change to return std::string.
	(relocate_gdbinit_path_maybe_in_datadir): Update.
	(captured_main_1): Update.
	* python/python.c (do_start_initialization): Update.
	* top.c (show_gdb_datadir): Update.
	* xml-syscall.c (xml_init_syscalls_info): Update.
	(init_syscalls_info): Update.
2019-09-11 16:31:36 -05:00
Christian Biesinger 9224a01377 Factor out the code to do the datadir-relocation for gdbinit
This simplifies get_init_files and makes it possible to reuse
this code in an upcoming patch for SYSTEM_GDBINIT_DIR.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* main.c (relocate_gdbinit_path_maybe_in_datadir): Factor this code
	out of get_init_files.
	(get_init_files): Update.
2019-09-11 16:30:00 -05:00
Christian Biesinger f48cd8368b Refactor get_init_files to use std::string
To avoid manual memory management.

Tested on buildbot.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* main.c (get_init_files): Change to use std::string.
	(captured_main_1): Update.
	(print_gdb_help): Update.
2019-09-11 16:29:10 -05:00
Ali Tamur 9cab7ecda2 Fix float to LONGEST conversion.
The code used to have undefined behaviour when template parameter is float and
host_float is NaN, because it attempted to convert NaN value to LONGEST at the
last statement. This frequently caused crashes on tests that checked "info
all-registers" (at least when the code is compiled with clang; I didn't test
with gdb).

gdb/ChangeLog:

	*target-float.c (host_float_ops<T>::to_longest): Update
	implementation.
2019-09-11 12:21:50 -07:00
Christian Biesinger 67547d896b Change the type of copy_names from int to bool
This parameter is really a boolean, so change the type accordingly
and update the callers.

This is for symbol_set_names, add_psymbol_to_bcache, and
add_psymbol_to_list.

minimal_symbol_reader::record_full was already passing a bool
to symbol_set_names.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* dbxread.c (read_dbx_symtab): Update.
	* dwarf2read.c (load_partial_dies): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	(handle_psymbol_enumerators): Update.
	* psympriv.h (add_psymbol_to_list): Change type of copy_names to bool.
	* psymtab.c (add_psymbol_to_bcache): Likewise.
	(add_psymbol_to_list): Likewise.
	* symtab.c (symbol_set_names): Likewise.
	* symtab.h (symbol_set_names): Likewise.
	* xcoffread.c (scan_xcoff_symtab): Update.
2019-09-11 12:43:45 -05:00
Tom Tromey 64b2d4a0a4 Introduce bfd_set_filename
This introduces a new bfd_set_filename function, which is then used in
various spots in gdb.  This allows for the removal of some casts.

bfd/ChangeLog
2019-09-11  Tom Tromey  <tom@tromey.com>

	* opncls.c (bfd_set_filename): New function.
	* bfd-in2.h: Regenerate.

gdb/ChangeLog
2019-09-11  Tom Tromey  <tom@tromey.com>

	* symfile-mem.c (symbol_file_add_from_memory): Use
	bfd_set_filename.
	* solib-darwin.c (darwin_bfd_open): Use bfd_set_filename.
	* solib-aix.c (solib_aix_bfd_open): Use bfd_set_filename.
2019-09-11 07:02:46 -06:00
Tom Tromey 2d60161648 Update "save gdb-index" documentation
This updates the "save gdb-index" documentation to reflect the new
state of Ada support.  It also corrects an existing grammatical error.

gdb/doc/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Index Files): Update Ada text.
2019-09-10 08:30:45 -06:00
Tom Tromey 8a51616424 Add Ada support to cc-with-tweaks.exp
This adds Ada support to the cc-with-tweaks.exp board file, so that we
can test Ada this way.  The cc-with-tweaks.sh script already works
reasonably well as a wrapper for gnatmake.

gdb/testsuite/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* boards/cc-with-tweaks.exp: Set GNATMAKE_FOR_TARGET.
2019-09-10 08:30:45 -06:00
Tom Tromey 3b00ef10a2 Add Ada support for .debug_names
This patch adds support for Ada to .debug_names.  I opted to leave
.gdb_index alone, because in my view it is a defunct format.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* dwarf-index-write.c (write_psymbols): Extend error message.
	(debug_names::insert): Add Ada code.
	(debug_names::write_psymbols): Remove Ada check.
	(debug_names) <m_string_obstack>: New member.
	* dwarf2read.c (gdb_index_symbol_name_matcher): Remove.
	(gdb_index_symbol_name_matcher::matches): Remove.
	(mapped_index_base::find_name_components_bounds): Add "lang"
	parameter.
	(mapped_index_base::build_name_components): Also split names
	according to Ada syntax.
	(dw2_expand_symtabs_matching_symbol): Loop over languages.  Change
	type of "match_callback".
	(check_match, check_find_bounds_finds)
	(dw2_expand_symtabs_matching): Update.
	(dw2_debug_names_iterator): Add new constructor.
	(dw2_debug_names_map_matching_symbols): New function.
	(dw2_debug_names_expand_symtabs_matching): Update.
	(dwarf2_debug_names_functions): Use
	dw2_debug_names_map_matching_symbols.
2019-09-10 08:30:45 -06:00
Tom Tromey aa39165480 Fix latent bug in .debug_names file-name handling
An internal Ada test case showed that the .debug_names code does not
compute the same list of file names as the partial symbol reader.  In
particular, the partial symbol reader uses the DW_AT_name of the CU:

  /* Allocate a new partial symbol table structure.  */
  filename = dwarf2_string_attr (comp_unit_die, DW_AT_name, cu);
  if (filename == NULL)
    filename = "";

  pst = create_partial_symtab (per_cu, filename);

This patch changes the .debug_names reader to follow.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* dwarf2read.c (dw2_get_file_names_reader): Add the
	CU's file name to the results.

gdb/testsuite/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/dgopt.exp: New file.
	* gdb.ada/dgopt/x.adb: New file.
2019-09-10 08:30:45 -06:00
Tom Tromey b054970d54 Change map_matching_symbols to take a lookup_name_info
This patch further simplifies the map_matching_symbols callback, by
having it take a lookup_name_info rather than a plain string.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (add_nonlocal_symbols): Combine calls to
	map_matching_symbols.  Update.
	* dwarf2read.c (dw2_map_matching_symbols): Update.
	* psymtab.c (match_partial_symbol): Change type; update.
	(psym_map_matching_symbols): Likewise.
	* symfile-debug.c (debug_qf_map_matching_symbols): Change
	type; update.
	* symfile.h (struct quick_symbol_functions)
	<map_matching_symbols>: Change "name" to be a lookup_name_info.
	Remove "match".
2019-09-10 08:30:45 -06:00
Tom Tromey 6a3dbf1bc6 Simplify psym_map_matching_symbols
This introduces a new helper function,
iterate_over_symbols_terminated, and changes psym_map_matching_symbols
to use it.  A subsequent patch will introduce a new user of this
function in the DWARF reader.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* psymtab.c (map_block): Remove.
	(psym_map_matching_symbols): Use iterate_over_symbols_terminated.
	* symtab.c (iterate_over_symbols_terminated): New function.
	* symtab.c (iterate_over_symbols_terminated): Declare.
2019-09-10 08:30:45 -06:00
Tom Tromey 6969f124b9 Change iterate_over_symbols to return bool
This changes iterate_over_symbols to return a bool.  This allows it to
be reused in another context in a subsequent patch.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (ada_iterate_over_symbols): Return bool.
	* language.h (struct language_defn) <la_iterate_over_symbols>:
	Return bool.
	* symtab.c (iterate_over_symbols): Return bool.
	* symtab.h (iterate_over_symbols): Return bool.
2019-09-10 08:30:45 -06:00
Tom Tromey 199b4314ef Change map_matching_symbols to take a symbol_found_callback_ftype
This changes map_matching_symbols to take a
symbol_found_callback_ftype, rather than separate callback and data
parameters.  This enables a future patch to clean up some existing
code so that it can more readily be shared.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (aux_add_nonlocal_symbols): Change type.
	(add_nonlocal_symbols): Update.
	* dwarf2read.c (dw2_map_matching_symbols): Change type.
	* psymtab.c (map_block, psym_map_matching_symbols): Change type.
	* symfile-debug.c (debug_qf_map_matching_symbols): Change type.
	* symfile.h (struct quick_symbol_functions) <map_matching_symbols>:
	Change type of "callback".  Remove "data".
2019-09-10 08:30:45 -06:00
Ali Tamur a084a2a6a1 DWARF 5 support: Handle dwo_id
* DW_UT_skeleton and DW_UT_split_compile compilation units have dwo ids
to match the compilation unit in the skeleton and .dwo files. The dwo_id is
in the header.

Tested with CC=/usr/bin/gcc (version 8.3.0) against master branch (also with
-gsplit-dwarf and -gdwarf-4 flags) and there was no increase in the set of
tests that fails.

This is part of an effort to support DWARF 5 in gdb.

gdb/ChangeLog:

        * dwarf2read.c (comp_unit_head): Update comment.
        (dwarf2_dwo_name): New function declaration.
        (dwarf_unit_type_name): New function declaration.
        (read_comp_unit_head): Add support for new compilation units,
        DW_UT_partial, DW_UT_skeleton, DW_UT_split_compile, DW_UT_split_type.
        Particularly, DW_UT_skeleton and DW_UT_split_compile have dwo_id
        (currently named as "signature") in their header. Also clarify error
        messages.
        (lookup_dwo_id): New function. Returns the dwo id of the given
        compile unit.
        (lookup_dwo_unit): Use the new lookup_dwo_id function.
        (init_cutu_and_read_dies): Use the new dwarf2_dwo_name and lookup_dwo_id
        functions.
        (create_dwo_cu_reader): Use the added lookup_dwo_id function.
        (dwarf2_dwo_name): Get the dwo name if present.
        (dwarf_unit_type_name): Convert DW_UT_* types to string for diagnostic
        purposes.
2019-09-09 18:35:43 -07:00
Tom Tromey 25a2915e8d Use ui_out for "info win"
This changes the "info win" command to use ui-out.  This yields
somewhat nicer table output.

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

	* tui/tui-win.c (tui_all_windows_info): Use ui_out.
2019-09-09 17:06:22 -06:00
Philippe Waroquiers e4df087431 Fix leak detected in python.c initialization code.
Valgrind reports the below leak.
Make the variable progname_copy static, so that Valgrind continues
to find a pointer to the memory given to Python.
Note that the comment in do_start_initialization and the Python documentation
indicates that the progname given to Py_SetProgramName cannot be freed.
However, in Python 3.7.4, Py_SetProgramName does:
void
Py_SetProgramName(const wchar_t *program_name)
{
    ...
    PyMem_RawFree(_Py_path_config.program_name);
    _Py_path_config.program_name = _PyMem_RawWcsdup(program_name);

So, it looks like 3.7.4 Python duplicates its argument, which explains
the leak found by Valgrind.
It looks better to respect the doc and not have GDB freeing the string
given to Py_SetProgramName, and avoid the leak error by declaring
the progname_copy static.
This will work with Python versions that really use this string without
duplicating it, and avoids a leak report for Python version that duplicates
it.

==4023== 200 bytes in 1 blocks are definitely lost in loss record 4,545 of 7,116^M
==4023==    at 0x4C29F33: malloc (vg_replace_malloc.c:307)^M
==4023==    by 0x446D27: xmalloc (alloc.c:60)^M
==4023==    by 0x657C77: do_start_initialization (python.c:1610)^M
==4023==    by 0x657C77: _initialize_python() (python.c:1823)^M
==4023==    by 0x75FE24: initialize_all_files() (init.c:231)^M
==4023==    by 0x708A94: gdb_init(char*) (top.c:2242)^M
==4023==    by 0x5E7460: captured_main_1 (main.c:857)^M
==4023==    by 0x5E7460: captured_main (main.c:1161)^M
==4023==    by 0x5E7460: gdb_main(captured_main_args*) (main.c:1186)^M
==4023==    by 0x4122D4: main (gdb.c:32)^M

gdb/ChangeLog
2019-09-09  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* python/python.c (do_start_initialization): Make progname_copy static,
	to avoid a leak report.
2019-09-09 23:50:37 +02:00
Tom Tromey 8634b4628e Truncate long TUI window titles
If a TUI window has a long title, it can overflow the title line.
This changes the TUI to use just the tail part of the title in this
case.

gdb/ChangeLog
2019-09-08  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (box_win): Truncate long window titles.

gdb/testsuite/ChangeLog
2019-09-08  Tom Tromey  <tom@tromey.com>

	* gdb.tui/resize.exp: Remove setup_xfail.
	* gdb.tui/regs.exp: Remove setup_xfail.
	* gdb.tui/basic.exp: Remove setup_xfail.
2019-09-08 14:06:54 -06:00
Simon Marchi c7f839cbf0 Change lookup_symbol's block_index parameter type to block_enum
The only two values valid to pass to the block_index parameter of
quick_symbol_functions::lookup_symbol are GLOBAL_BLOCK and STATIC_BLOCK,
part of enum block_enum.  Change the type of that parameter to
block_enum.

Change also the block_index field of dw2_symtab_iterator in the same
way..  This makes it consistent with dw2_debug_names_iterator, which
already uses block_enum for its block_index field.

This is a follow-up to this thread:

https://sourceware.org/ml/gdb-patches/2019-08/msg00097.html

gdb/ChangeLog:

	* dwarf2read.c (struct dw2_symtab_iterator) <block_index>:
	Change type to gdb::optional<block_enum>.
	(dw2_symtab_iter_init): Change block_index parameter type
	to gdb::optional<block_enum>.
	(dw2_lookup_symbol): Change block_index parameter
	type to block_enum.c
	(dw2_debug_names_lookup_symbol): Likewise.
	* psymtab.c (psym_lookup_symbol): Likewise.
	* symfile-debug.c (debug_qf_lookup_symbol): Likewise.
	* symfile.h (struct quick_symbol_functions) <lookup_symbol>:
	Likewise.
2019-09-07 12:06:01 -04:00
David Blaikie 736b0f7618 un-XFAIL under Clang tests using labels
gdb/testsuite/
	* gdb.base/label.exp: un-XFAIL label related tests under Clang.
	* gdb.cp/cplabel.exp: Ditto.
	* gdb.linespec/ls-errs.exp: Ditto.
2019-09-06 14:17:36 -07:00
Christian Biesinger ead0e69a4a Change int to bool for the relocate_* functions
These parameters are only used as bools. This also
renames "flag" to "relocatable" to make it clearer
what it does.

gdb/ChangeLog:

2019-09-06  Christian Biesinger  <cbiesinger@google.com>

	* defs.h (relocate_gdb_directory): Change int to bool in
	signature and rename flag to relocatable.
	* main.c (relocate_path): Likewise.
	(relocate_gdb_directory): Likewise.
2019-09-06 14:34:00 -05:00
Alan Modra b16c44debc bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
   a char * without a warning.  */

I reckon that isn't such a good idea since it can result in char*
variables where const char* is appropriate.  Not very many places
need the char* cast.

bfd/
	* aout-target.h (object_p): Formatting.
	* bfd-in.h (bfd_get_filename): Don't cast to char*.
	* corefile.c (generic_core_file_matches_executable_p): Constify
	variables and remove cast.
	* bfd-in2.h: Regenerate.
binutils/
	* nm.c (print_object_filename_bsd, print_object_filename_sysv),
	(print_object_filename_posix, print_archive_filename_bsd),
	(print_archive_filename_sysv, print_archive_filename_posix),
	(print_archive_member_bsd, print_archive_member_sysv),
	(print_archive_member_posix): Constify parameter.
	(struct output_fns <print_object_filename, print_archive_filename>),
	(<print_archive_member>): Likewise.
	* objcopy.c (copy_archive): Add cast for make_tempdir.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
	variable.
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
gdb/
	* coffread.c (coff_symfile_read): Constify filename variable.
	* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
	* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
	* solib.c (reload_shared_libraries_1): Likewise.
	* symfile.c (reread_symbols): Likewise.
	* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
	* solib-darwin.c (darwin_bfd_open): Likewise.
	* symfile-mem.c (symbol_file_add_from_memory): Likewise.
sim/cris/
	* sim-if.c (sim_open): Constify filename variable.
2019-09-06 12:22:59 +09:30
Tom de Vries 30331a6ca0 [gdb/testsuite] Restore breakpoint command in ui-redirect.exp
In gdb.base/ui-redirect.exp, the "save breakpoint" command is used to write
the current breakpoints to a file, but the actual output is not verified.

Consequently, the test has regressed in that the "print 1" command associated
with a breakpoint on main is removed by a subsequent runto_main, which first
deletes all breakpoints:
...
(gdb) break main
Breakpoint 1 at 0x4004d7: file start.c, line 34.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
> PASS: gdb.base/ui-redirect.exp: commands
print 1
> PASS: gdb.base/ui-redirect.exp: print 1
end
(gdb) PASS: gdb.base/ui-redirect.exp: end
delete breakpoints
Delete all breakpoints? (y or n) y
...
and consequently the "save breakpoint" output is missing the breakpoint
command for main:
...
 break main
-  commands
-    print 1
-  end
 break foo
 break bar
...

Fix this by replacing "gdb_breakpoint main" with runto_main, and verifying the
"save breakpoints" output.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-05  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (cmp_file_string): New proc.
	* gdb.base/ui-redirect.exp: Replace "gdb_breakpoint main" with
	runto_main.  Verify save breakpoints output.
2019-09-05 14:33:10 +02:00
Philippe Waroquiers 98b0ebab0a Avoid expect's buffer overflow in info-var.exp test.
Once the executable is started, info variables can show thousands
of variables belonging to glibc (see below).

This long list of variables then causes the test to fail, due
to expect's buffer overflow:
  Running /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var.exp ...
  ERROR: internal buffer is full.
  ERROR: internal buffer is full.
  ERROR: internal buffer is full.

Fix this by testing 'info variables' without running the executable.

gdb ./info-var
...
Reading symbols from ./info-var...
(gdb) |info variables|wc
     27      54     971
(gdb) start
Temporary breakpoint 1 at 0x1129: file /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var-f1.c, line 23.
Starting program: /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/outputs/gdb.base/info-var/info-var

Temporary breakpoint 1, main ()
    at /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var-f1.c:23
23	  return global_var + get_offset() + f1_var;
(gdb) |info variables|wc
   4334   14581  130738
(gdb)

gdb/testsuite/ChangeLog
2019-09-04  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/info-var.exp: Test info variables without running
	to main, to avoid expect's buffer overflow.
2019-09-04 22:16:56 +02:00
Andrew Burgess 06ff036ed2 gdb: Handle missing domain types in: maintenance print psymbols
Some domain_enum values were not handled in print_partial_symbols
which means that 'maintenance print psymbols' would print '<invalid
domain>' when it shouldn't have.

gdb/ChangeLog:

	* psymtab.c (print_partial_symbols): Handle missing domain_enum
	values MODULE_DOMAIN and COMMON_BLOCK_DOMAIN.
2019-09-03 22:29:07 +01:00
Tom Tromey 4e962e74e4 Handle biased types
In Ada, the programmer can request that a range type with a non-zero
base be stored in the minimal number of bits required for the range.
This is done by biasing the values; so, for example, a range of -7..-4
may be stored as two bits with a bias of -7.

This patch implements this for gdb.  It is done by adding a bias to
struct range_bounds and then adjusting a few spots to handle this.

The test case is written to use -fgnat-encodings=minimal, but a future
compiler patch will change the compiler to emit DW_AT_GNU_bias with
-fgnat-encodings=gdb.  It seemed good to get the gdb patch in first.

Tested on x86-64 Fedora 29; plus a variety of targets using AdaCore's
internal test suite.

gdb/ChangeLog
2019-09-03  Tom Tromey  <tromey@adacore.com>

	* ada-valprint.c (ada_val_print_num): Don't recurse for range
	types.
	(has_negatives): Unbias a range type bound.
	* dwarf2read.c (read_subrange_type): Handle DW_AT_GNU_bias.
	* gdbtypes.c (operator==): Handle new field.
	(create_range_type): Add "bias" parameter.
	(create_static_range_type, resolve_dynamic_range): Update.
	* gdbtypes.h (struct range_bounds) <bias>: New member.
	(create_range_type): Add bias parameter.
	* printcmd.c (print_scalar_formatted): Unbias range types.
	* value.c (unpack_long): Unbias range types.
	(pack_long): Bias range types.

gdb/testsuite/ChangeLog
2019-09-03  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/bias.exp: New file.
	* gdb.ada/bias/bias.adb: New file.
	* gdb.ada/print_chars.exp: Add regression test.
	* gdb.ada/print_chars/foo.adb (My_Character): New type.
	(MC): New variable.
2019-09-03 10:20:40 -06:00
Alan Hayward d90b8f2632 Check arguments for all probes before using them
There is a long standing bug in the Arm toolchain where invalid
stap probes get created due to the probes referring to symbols which
have been resolved away.

More details are here:
https://bugzilla.redhat.com/show_bug.cgi?id=1196181

When these invalid probes are present, GDB will create the breakpoints
and then fail to stop. The errors are only spotted the first time
GDB stops, which is too late.

The solution is to ensure the arguments for all the probes are
resolved before using them.

This fixes >100 timeouts when running break-interp.exp when using
bad probes.

gdb/ChangeLog:

	* solib-svr4.c (svr4_find_and_create_probe_breakpoints): Check all
	probe arguments.
2019-09-02 14:00:42 +01:00
Alan Hayward fe01123efb Use gdbarch for probe::get_argument_count
The probe function get_argument_count does not need a frame, only
the current gdbarch.  Switch the code to pass gdbarch instead.
No functional changes.

gdb/ChangeLog:

	* break-catch-throw.c (fetch_probe_arguments): Use gdbarch.
	* dtrace-probe.c (dtrace_probe::get_argument_count): Likewise.
	* probe.c (probe_safe_evaluate_at_pc) (compute_probe_arg)
	(compile_probe_arg): Likewise.
	* probe.h (get_argument_count): Likewise.
	* solib-svr4.c (solib_event_probe_action): Likewise.
	* stap-probe.c (stap_probe::get_argument_count): Likewise.
2019-09-02 13:58:48 +01:00
Alan Hayward e661ef01e5 Refactor svr4_create_solib_event_breakpoints
Move the bulk of svr4_create_solib_event_breakpoints into a new
function to simplify the logic. No functional changes.

gdb/ChangeLog:

	* solib-svr4.c (svr4_find_and_create_probe_breakpoints): Move
	code to here...
	(svr4_create_solib_event_breakpoints): ...from here.
2019-09-02 13:57:12 +01:00
Sergio Durigan Junior 47a536d940 Remove "\nError: " suffix from nat/fork-inferior.c:trace_start_error warning message
Rationale: https://sourceware.org/ml/gdb-patches/2019-08/msg00651.html

This very simple patch removes the "\nError: " suffix from the warning
message printed by nat/fork-inferior.c:trace_start_error.  This proved
to just pollute the screen, causing things like:

  Starting program: /usr/bin/true
  warning: Could not trace the inferior process.
  Error:
  warning: ptrace: Permission denied

This "Error: " string is not useful at all, and can confuse things,
therefore let's just remove it and simplify the resulting messages:

  Starting program: /usr/bin/true
  warning: Could not trace the inferior process.
  warning: ptrace: Permission denied

gdb/ChangeLog:
2019-08-30  Sergio Durigan Junior  <sergiodj@redhat.com>

	* nat/fork-inferior.c (trace_start_error): Remove "\nError: "
	suffix from warning message.
2019-08-30 17:04:37 -04:00
Tom Tromey d6a00eba2a Remove tui_win_info::refresh_all
The TUI has two duplicate "re-render this window" methods, "rerender"
and "refresh_all".  They differ only slightly in semantics, so I
wanted to see if they could be unified.

After looking into this, I decided that refresh_all was not needed.
There are 4 calls to tui_refresh_all_win (the only caller of this
method):

1. tui_enable.  This sets the layout, which renders the windows.

2. tui_cont_sig.  Here, I think it's sufficient to simply redraw the
   current window contents from the curses backing store, because gdb
   state didn't change while it was suspended

3. tui_dispatch_ctrl_char.  This is the C-l handler, and here it's
   explicitly enough to just refresh the screen (as above).

4. tui_refresh_all_command.  This is the command equivalent of C-l.

So, this patch removes this method entirely and simplifies
tui_refresh_all_win.

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

	* tui/tui-winsource.h (struct tui_source_window_base)
	<refresh_all>: Don't declare.
	* tui/tui-winsource.c (tui_source_window_base::refresh_all):
	Remove.
	* tui/tui-win.c (tui_refresh_all_win): Don't call refresh_all or
	tui_show_locator_content.
	* tui/tui-regs.h (struct tui_data_window) <refresh_all>: Don't
	declare.
	* tui/tui-regs.c (tui_data_window::refresh_all): Remove.
	* tui/tui-data.h (struct tui_win_info) <refresh_all>: Don't
	declare.
2019-08-30 12:57:10 -06:00
Tom Tromey 55b2657bdc Don't call wrefresh from tui_cont_sig
tui_cont_sig does not need to call wrefresh, because this is already
done by tui_refresh_all_win.

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

	* tui/tui-io.c (tui_cont_sig): Don't call wrefresh.
2019-08-30 12:57:10 -06:00
Tom Tromey 12a8555a54 Minor rearrangement of tui-stack.c
This move _initialize_tui_stack to the end of tui-stack.c, per the gdb
style; and then removes two unnecessary forward declarations.

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

	* tui/tui-stack.c (_initialize_tui_stack): Move later.
	Remove unnecessary forward declarations.
2019-08-30 12:57:09 -06:00
Tom Tromey 900ac24287 Make tui_locator_window::set_locator_fullname re-render
This changes tui_locator_window::set_locator_fullname to re-render the
locator window, so that the callers don't need to do this.

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

	* tui/tui-stack.c (tui_locator_window::set_locator_fullname): Call
	rerender.
	(tui_update_locator_fullname, tui_show_frame_info): Don't call
	tui_show_locator_content.
2019-08-30 12:57:09 -06:00
Tom Tromey 99ab33fb2d Swap tui_show_locator_content and tui_locator_window::rerender
This swaps the bodies ot tui_show_locator_content and
tui_locator_window::rerender, so that the latter does the work, and
the former is now just an exported convenience wrapper.

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

	* tui/tui-stack.c (tui_show_locator_content): Move lower.  Rewrite.
	(tui_locator_window::rerender): Rewrite using body of previous
	tui_show_locator_content.
2019-08-30 12:57:08 -06:00
Tom Tromey e594a5d19e Turn two locator functions into methods
This changes tui_set_locator_fullname and tui_set_locator_info to be
methods on tui_locator_window.  This enables some subsequent
cleannups.

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

	* tui/tui-stack.h (struct tui_locator_window) <set_locator_info,
	set_locator_fullname>: New methods.
	* tui/tui-stack.c (tui_locator_window::set_locator_fullname):
	Rename from tui_set_locator_fullname.
	(tui_locator_window::set_locator_info): Rename from
	tui_set_locator_info.  Return bool.
	(tui_update_locator_fullname, tui_show_frame_info): Update.
2019-08-30 12:57:07 -06:00
Tom Tromey 715bb467fe Don't call tui_refresh_all from show_layout
show_layout calls tui_refresh_all in one case.  However, it doesn't
need to any more, because the resize method on each window will also
update the contents.

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

	* tui/tui-layout.c (show_layout): Don't call tui_refresh_all.
2019-08-30 12:57:07 -06:00
Tom Tromey 772f3f0398 Don't call touchwin in tui_gen_win_info::refresh_window
The call to touchwin in tui_gen_win_info::refresh_window was an
artifact of some earlier refactorings.  Testing shows it isn't needed
any more -- I believe it was only ever needed for the data item window
display problem; but that's been solved more locally.

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

	* tui/tui-wingeneral.c (tui_gen_win_info::refresh_window): Don't
	call touchwin.
2019-08-30 12:57:06 -06:00
Tom Tromey 108e13abdf Remove NULL checks from box_win
box_win can't be called with a NULL window, or with an invisible
window.  So, the NULL checks in that function can be removed.

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

	* tui/tui-wingeneral.c (box_win): Assume win_info and
	win_info->handle cannot be NULL.
2019-08-30 12:57:05 -06:00
Tom Tromey cdaa6eb439 Simplify register display
This patch starts with the observation that the code in
tui_data_window::display_registers_from can all be replaced with a
call to resize.  To make this work propertly, it also changes
tui_display_register to be the "rerender" method on
tui_data_item_window.

The refresh_window method is needed due to the use of nested windows
here.  The ncurses man page makes it sound like this is not very well
supported; and experience bears this out: negelecting the touchwin
call in this path will cause the register window to blank when
switching focus.

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

	* tui/tui-regs.h (struct tui_data_item_window) <rerender,
	refresh_window>: Declare.
	* tui/tui-regs.c (tui_data_window::display_registers_from): Call
	resize.
	(tui_data_item_window::rerender): Rename from
	tui_display_register.
	(tui_data_item_window::refresh_window): New method.
	* tui/tui-layout.c (tui_gen_win_info::resize): Do nothing on
	no-op.
2019-08-30 12:57:05 -06:00
Tom Tromey 89df7f9056 Private data members in tui_data_window
This changes tui_data_window so that the data members are private.
This required the addition of a simple accessor method in one case.

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

	* tui/tui-regs.h (struct tui_data_window) <regs_content,
	regs_column_count, current_group>: Move later.  Now private.
	<get_current_group>: New method.
	* tui/tui-regs.c (tui_reg_command): Update.
	* tui/tui-layout.c (tui_set_layout): Update.
2019-08-30 12:57:04 -06:00
Tom Tromey 1bf2866a59 Remove some calls in tui_data_window
This patch removes a call to erase_data_content in refresh_all and
then removes some other calls that are more clearly unnecessary once
one follows calls from that point.

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

	* tui/tui-regs.c (tui_data_window::display_registers_from_line)
	(tui_data_window::rerender): Don't call
	check_and_display_highlight_if_needed.
	(tui_data_window::refresh_all): Remove call to
	erase_data_content.
2019-08-30 12:57:04 -06:00
Tom Tromey 0670413d0e Remove some checks of .empty()
A few methods in tui_data_window check whether the contents are empty;
but all the callers already check this, so these calls can be removed.

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

	* tui/tui-regs.c (tui_data_window::last_regs_line_no)
	(tui_data_window::display_registers_from)
	(tui_data_window::display_reg_element_at_line)
	(tui_data_window::display_registers_from_line): Remove checks of
	"empty".
2019-08-30 12:57:03 -06:00
Tom Tromey 18bb55c722 Remove tui_data_window::display_all_data
tui_data_window::rerender clears the data item windows, and then calls
display_all_data.  However, that method only does anything if the
contents are not empty.  So, display_all_data can be renamed and the
wrapper removed.

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

	* tui/tui-regs.h (struct tui_data_window) <display_all_data>:
	Don't declare.
	* tui/tui-regs.c (tui_data_window::show_registers): Call
	rerender.
	(tui_data_window::rerender): Rename from display_all_data.
	(tui_data_window::rerender): Remove old implementation.
2019-08-30 12:57:02 -06:00
Tom Tromey 1f6d2f100a Remove NO_DATA_STRING
NO_DATA_STRING shouldn't be used.  It's referenced in a single spot,
in tui_data_window::display_all_data.  This patch removes the use and
replaces it with the more correct text.  A later patch (though not in
this series) will remove this call entirely, when it's more obviously
correct to do so.

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

	* tui/tui-regs.c (tui_data_window::display_all_data): Change
	text.
	* tui/tui-data.h (NO_DATA_STRING): Remove define.
2019-08-30 12:57:02 -06:00
Sandra Loosemore 2ea1a07a0a Run argv0-symlink.exp only on native target and local host.
This testcase was originally for PR gdb/15415, a problem with the
"run" command expanding symlinks in the name of the program being run.
It does not correctly distinguish between files on build, host, and
target, and it is not clear if it would be testing anything useful in
configurations where "run" is not being used.

2019-08-29  Sandra Loosemore  <sandra@codesourcery.com>

	* gdb.base/argv0-symlink.exp: Run only on native target
	and local host.
2019-08-29 14:48:05 -07:00
Bernhard Wodok 16d01f9cd4 Fix PR win32/24284: tcp_auto_retry doesn't work in MinGW
This was reported by Bernhard Wodok, along with a patch to fix the
issue.  I adjusted the patch a bit, and I'm submitting the patch on
his behalf.

According to Bernhard, the issue can be reproduced by doing:

  1. start gdb
  2. enter 'target remote :2345'
  3. observe that it throws a "connection refused" error immediately
  instead of waiting and throwing a timeout error

I.e., I believe it can be reproduced by our current tests, which is
why I'm not proposing any extra tests here (well, I don't use nor have
any Windows system to test this, so...).

The problem happens because, on ser-tcp:wait_for_connect, we call
'gdb_select' passing 0 as its first argument, which, when using MinGW,
ends up using the 'gdb_select' version from mingw-hdep.c, and when the
first argument is 0 this means that WaitForMultipleObjects will be
called with 0 as its first argument as well.  According to the MS API
docs, this is forbidden:

  https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects

The proposed fix is simple: we just call Sleep when N == 0 (and when
TIMEOUT is non-NULL), and return 0.  It makes sense to me.

Both Bernhard and Paul Carroll confirmed that the fix works.  I'm
Cc'ing Bernhard in case you have any questions about the patch.

OK?

gdb/ChangeLog:
2019-08-29  Bernhard Wodok  <barto@gmx.net>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	PR win32/24284
	* mingw-hdep.c (gdb_select): Handle case when 'n' is zero.
2019-08-29 12:35:58 -04:00
Tom de Vries 8077c50dbb [gdb/testsuite] Fix gdb.fortran/info-types.exp regexp
The gdb.fortran/info-types.exp test-case passes with gcc 7 (though not on
openSUSE, due to the extra debug info) and fails with gcc 4.8 and gcc 8.

Fix the gdb_test regexp to fix all those cases.

gdb/testsuite/ChangeLog:

2019-08-29  Tom de Vries  <tdevries@suse.de>

	* gdb.fortran/info-types.exp: Fix gdb_test regexp to allow more
	diverse debug info.
	* lib/fortran.exp (fortran_int8): New proc, based on fortran_int4.
2019-08-29 14:43:11 +02:00
Tom de Vries 48352473b1 [gdb/testsuite] Fix info-var.exp for debug info from other files
On openSUSE Leap 15.1, I get:
...
FAIL: gdb.base/info-var.exp: info variables
FAIL: gdb.base/info-var.exp: info variables -n
...
because the info variables command prints info also for init.c:
...
File init.c:^M
24:     const int _IO_stdin_used;^M
...
while the regexps in the test-case only expect info for info-var-f1.c and
info-var-f2.c.

Fix this by extending the regexps.

Tested on x86_64-linux, both openSUSE Leap 15.1 and Fedora 30.

gdb/testsuite/ChangeLog:

2019-08-28  Tom de Vries  <tdevries@suse.de>

	* gdb.base/info-var.exp: Allow info variables to print info for files
	other than info-var-f1.c and info-var-f2.c.
2019-08-28 19:13:29 +02:00
Andrew Burgess d8f27c6018 gdb/fortran: Don't include module symbols when searching for types
Currently the 'info types' command will return symbols that correspond
to Fortran modules.  This is because the symbols are created with
domain MODULE_DOMAIN and address_class LOC_TYPEDEF.  The address_class
LOC_TYPEDEF is the same address_class used for type symbols which is
why the modules show up when listing types.

This commit explicitly prevents symbols in the MODULE_DOMAIN from
appearing when we search for symbols in the TYPES_DOMAIN, this
prevents the Fortran module symbols from appearing in the output of
'info types'.

gdb/ChangeLog:

	* symtab.c (search_symbols): Don't include MODULE_DOMAIN symbols
	when searching for types.

gdb/testsuite/ChangeLog:

	* gdb.fortran/info-types.exp: Add module.
	* gdb.fortran/info-types.f90: Update expected results.
2019-08-28 13:33:55 +01:00
Andrew Burgess 1f20c35ea4 gdb/fortran: Implement la_print_typedef for Fortran
Implement an la_print_typedef method for Fortran, this allows 'info
types' to work for Fortran.  The implementation is just copied from
ada_print_typedef (with the appropriate changes).

To support the testing of this patch I added a new proc,
fortran_character1, to lib/fortran.exp which returns a regexp to match
a 1-byte character type.  The regexp returned is correct for current
versions of gFortran.  All of the other regexp are guesses based on
all of the other support procs in lib/fortran.exp, I haven't tested
them myself.

gdb/ChangeLog:

	* f-lang.c (f_language_defn): Use f_print_typedef.
	* f-lang.h (f_print_typedef): Declare.
	* f-typeprint.c (f_print_typedef): Define.

gdb/testsuite/ChangeLog:

	* gdb.fortran/info-types.exp: New file.
	* gdb.fortran/info-types.f90: New file.
	* lib/fortran.exp (fortran_character1): New proc.
2019-08-28 13:33:54 +01:00
Christian Biesinger 550105b779 Fix compiler warning in linux-namespaces.c
../../gdb/nat/linux-namespaces.c: In function ‘void mnsh_main(int)’:
../../gdb/nat/linux-namespaces.c:604:8: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  close (fd);
  ~~~~~~^~~~

And the warning is correct -- mnsh_recv_message can return -1 and leave fd
uninitialized, and mnsh_main will still call close (fd) if that happens.

Initialize fd to -1 to avoid that.

gdb/ChangeLog:

2019-08-27  Christian Biesinger  <cbiesinger@google.com>

	* nat/linux-namespaces.c (mnsh_main): Initialize fd (to -1).
2019-08-27 13:53:05 -05:00
Andrew Burgess 4acfdd20c9 gdb: Add new -n flag to some info commands
The 'info variables', its alias 'whereis', and 'info functions' all
include non-debug symbols in the output by default.  The list of
non-debug symbols can sometimes be quite long, resulting in the
debug symbol based results being scrolled off the screen.

This commit adds a '-n' flag to all of the commands listed above that
excludes the non-debug symbols from the results, leaving just the
debug symbol based results.

gdb/ChangeLog:

	* cli/cli-utils.c (info_print_options_defs): Delete.
	(make_info_print_options_def_group): Delete.
	(extract_info_print_options): Delete.
	(info_print_command_completer): Delete.
	(info_print_args_help): Add extra parameter, and optionally
	include text about -n flag.
	* cli/cli-utils.h (struct info_print_options): Delete.
	(extract_info_print_options): Delete declaration.
	(info_print_command_completer): Delete declaration.
	(info_print_args_help): Add extra parameter, extend header
	comment.
	* python/python.c (gdbpy_rbreak): Pass additional parameter to
	search_symbols.
	* stack.c (struct info_print_options): New type.
	(info_print_options_defs): New file scoped variable.
	(make_info_print_options_def_group): New static function.
	(info_print_command_completer): New static function.
	(info_locals_command): Update to use new local functions.
	(info_args_command): Likewise.
	(_initialize_stack): Add extra parameter to calls to
	info_print_args_help.
	* symtab.c (search_symbols): Add extra parameter, use this to
	possibly excluse non-debug symbols.
	(symtab_symbol_info): Add extra parameter, which is passed on to
	search_symbols.
	(struct info_print_options): New type.
	(info_print_options_defs): New file scoped variable.
	(make_info_print_options_def_group): New static function.
	(info_print_command_completer): New static function.
	(info_variables_command): Update to use local functions, and pass
	extra parameter through to symtab_symbol_info.
	(info_functions_command): Likewise.
	(info_types_command): Pass additional argument through to
	symtab_symbol_info.
	(rbreak_command): Pass extra argument to search_symbols.
	(_initialize_symtab): Add extra arguments for calls to
	info_print_args_help, and update help text for 'info variables',
	'whereis', and 'info functions' commands.
	* symtab.h (search_symbols): Add extra argument to declaration.
	* NEWS: Mention new flags.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols): Add information about the -n flag to
	"info variables" and "info functions".

gdb/testsuite/ChangeLog:

	* gdb.base/info-fun.exp: Extend to test the -n flag for 'info
	functions'.  Reindent as needed.
	* gdb.base/info-var-f1.c: New file.
	* gdb.base/info-var-f2.c: New file.
	* gdb.base/info-var.exp: New file.
	* gdb.base/info-var.h: New file.
2019-08-27 16:21:42 +01:00