Commit Graph

92626 Commits

Author SHA1 Message Date
Tom Tromey bd810fff78 Move guile object files to guile subdirectory
Move the object files corresponding to guile/*.c to the guile
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac (CONFIG_OBS): Refer to guile/guile.o.
	* Makefile.in (SUBDIR_GUILE_OBS): Redefine.
	(CONFIG_SRC_SUBDIR): Add guile.
	(%.o): Remove guile rule.
2017-11-27 16:53:24 -07:00
Tom Tromey 75787ac19c Move unittests object files to unittests subdirectory
Move the object files corresponding to unittests/*.c to the unittests
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SUBDIR_UNITTESTS_OBS): Redefine.
	(%.o): Remove unittests rule.
	(CONFIG_SRC_SUBDIR): Add unittests.
2017-11-27 16:53:24 -07:00
Tom Tromey 5c8a943144 Move tui object files to tui subdirectory
Move the object files corresponding to tui/*.c to the tui subdirectory
in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SUBDIR_TUI_OBS): Redefine.
	(CONFIG_SRC_SUBDIR): Add tui.
	(%.o): Remove tui rule.
2017-11-27 16:53:23 -07:00
Tom Tromey a26aa30cc5 Move compile object files to compile subdirectory
Move the object files corresponding to compile/*.c to the compile
subdirectory in the build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SUBDIR_GCC_COMPILE_OBS): Redefine.
	(%.o): Remove compile rule.
	(CONFIG_SRC_SUBDIR): Add compile.
2017-11-27 16:53:23 -07:00
Tom Tromey 6f3cdf9a3b Move mi objects to mi subdirectory
Move object files corresponding to mi/*.c to a subdirectory in the
build tree.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SUBDIR_MI_OBS): Redefine.
	(%.o): Remove mi rule.
	(CONFIG_SRC_SUBDIR): Add mi.
	(COMMON_OBS): Use mi/mi-common.o
2017-11-27 16:53:22 -07:00
Tom Tromey f06afa5336 Move cli object files to cli subdirectory
Following the "arch" move, this moves the object files corresponding
to the cli/*.c source files to the "cli" build directory.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SUBDIR_CLI_OBS): Redefine.
	(%.o): Remove cli rule.
	(CONFIG_SRC_SUBDIR): Add cli.
2017-11-27 16:53:22 -07:00
Tom Tromey b22c88c2ca A simpler way to make the "arch" build directory
This implements a simpler way to make the "arch" build directory --
namely, now it is done as an order-only dependency in the Makefile,
rather than being created when config.status is run.  This simpler
because it means that the build directories can be changed without
re-running autoconf.

ChangeLog
2017-11-27  Tom Tromey  <tom@tromey.com>

	* configure.ac (CONFIG_SRC_SUBDIR): Don't subst.
	* configure: Rebuild.
	* Makefile.in (CONFIG_SRC_SUBDIR): Redefine.
	(CONFIG_DEP_SUBDIR): New variable.
	(%.o): Add order-only dependency.
	($(CONFIG_DEP_SUBDIR)): New target.
2017-11-27 16:53:21 -07:00
Max Filippov 407e114084 gas: xtensa: speed up find_trampoline_seg
find_trampoline_seg takes noticeable time when assembling source with
many sections. Cache the result of the most recent search and check it
first. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (find_trampoline_seg): Add static variable
	that caches the result of the most recent search.
2017-11-27 15:16:22 -08:00
Max Filippov 148d638429 gas: xtensa: implement trampoline coalescing
There is a recurring pattern in assembly files generated by a compiler
where a lot of jumps in a function are going to the same place. When
these jumps are relaxed with trampolines the assembler generates a
separate jump thread from each source.
Create an index of trampoline jump targets for each segment and see if a
jump being relaxed goes to a location from that index, in which case
replace its target with a location of existing trampoline jump that
results in the shortest path to the original target.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain)
	(trampoline_chain_index): New structures.
	(trampoline_index): Add chain_index field.
	(xg_order_trampoline_chain_entry, xg_sort_trampoline_chain)
	(xg_find_chain_entry, xg_get_best_chain_entry)
	(xg_order_trampoline_chain, xg_get_trampoline_chain)
	(xg_find_best_eq_target, xg_add_location_to_chain)
	(xg_create_trampoline_chain, xg_get_single_symbol_slot): New
	functions.
	(xg_relax_fixups): Call xg_find_best_eq_target to adjust jump
	target to point to an existing jump. Call
	xg_create_trampoline_chain to create new jump target. Call
	xg_add_location_to_chain to add newly created trampoline jump
	to the corresponding chain.
	(add_jump_to_trampoline): Extract loop searching for a single
	slot with a symbol into a separate function, replace that code
	with a call to that function.
	(relax_frag_immed): Call xg_find_best_eq_target to adjust jump
	target to point to an existing jump.
	* testsuite/gas/xtensa/all.exp: Add trampoline-2 test.
	* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
	as many duplicate trampoline chains are now coalesced.
	* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
	stays in sync with instruction stream.
	* testsuite/gas/xtensa/trampoline-2.l: New test result file.
	* testsuite/gas/xtensa/trampoline-2.s: New test source file.
2017-11-27 15:15:46 -08:00
Max Filippov 76a493ab99 gas: xtensa: reuse trampoline placement code
There's almost exact copy of the trampoline placement code in the
search_trampolines function that is used for jumps generated for relaxed
branch instructions. Get rid of the duplication and reuse
xg_find_best_trampoline function for that.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (search_trampolines, get_best_trampoline):
	Remove definitions.
	(xg_find_best_trampoline_for_tinsn): New function.
	(relax_frag_immed): Replace call to get_best_trampoline with a
	call to xg_find_best_trampoline_for_tinsn.
	* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
	as the placement of trampolines for relaxed branches has been
	changed.
2017-11-27 15:14:48 -08:00
Max Filippov fe6c2f1b64 gas: xtensa: rewrite xg_relax_trampoline
Replace linked list of trampoline frags with an ordered array, so that
instead of indexing fixups trampolines could be indexed. Keep each array
in the trampoline_seg structure, so there's no need to rebuild it for
every new processed segment. Don't run relaxation for each trampoline
frag, instead run it for each fixup in the current segment that needs
relaxation at the beginning of each relaxation pass. This way the
complexity of this process drops from about O(n^2 * m) to about
O(log n * m), where n is the number of trampoline frags and m is the
number of fixups that need relaxation in the segment.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (trampoline_index): New structure.
	(trampoline_seg): Replace trampoline list with trampoline index.
	(xg_find_trampoline, xg_add_trampoline_to_index)
	(xg_remove_trampoline_from_index, xg_add_trampoline_to_seg)
	(xg_is_trampoline_frag_full, xg_get_fulcrum)
	(xg_find_best_trampoline, xg_relax_fixup, xg_relax_fixups)
	(xg_is_relaxable_fixup): New functions.
	(J_MARGIN): New macro.
	(xtensa_create_trampoline_frag): Use xg_add_trampoline_to_seg
	instead of open-coded addition to the linked list.
	(dump_trampolines): Iterate through the trampoline_seg::index.
	(cached_fixupS, cached_fixup, fixup_cacheS, fixup_cache)
	(fixup_order, xtensa_make_cached_fixup)
	(xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups)
	(xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup)
	(xtensa_add_cached_fixup, check_and_update_trampolines): Remove
	definitions.
	(xg_relax_trampoline): Extract logic into separate functions,
	replace body with a call to xg_relax_fixups.
	(search_trampolines): Replace search in linked list with search
	in index. Change data type of address-tracking variables from
	int to offsetT. Replace abs with labs.
	(xg_append_jump): Finish the trampoline frag if it's full.
	(add_jump_to_trampoline): Remove trampoline frag from the index
	if the frag is full.
	* config/tc-xtensa.h (xtensa_frag_type): Remove next_trampoline.
	* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
	as the placement of trampolines has slightly changed.
	* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
	stays in sync with instruction stream.
2017-11-27 15:13:52 -08:00
Max Filippov 46888d7100 gas: xtensa: merge trampoline_frag into xtensa_frag_type
The split between fragS and trampoline_frag doesn't save much space, but
makes trampolines management much more awkward. Merge trampoline_frag
data into the xtensa_frag_type, which is a part of fragS. No functional
changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (init_trampoline_frag): Replace pointer to
	struct trampoline_frag parameter with pointer to fragS.
	(xg_append_jump): Remove jump_around parameter.
	(struct trampoline_frag): Remove.
	(struct trampoline_seg): Change type of trampoline_list from
	struct trampoline_frag to fragS.
	(xtensa_create_trampoline_frag): Don't allocate struct
	trampoline_frag. Initialize new fragS::tc_frag_data fields.
	(dump_trampolines, xg_relax_trampoline, search_trampolines)
	(get_best_trampoline, init_trampoline_frag)
	(add_jump_to_trampoline, relax_frag_immed): Replace pointer to
	struct trampoline_frag with a pointer to fragS.
	(xg_append_jump): Remove jump_around parameter, use
	fragS::tc_frag_data.jump_around_fix instead.
	(xg_relax_trampoline, init_trampoline_frag)
	(add_jump_to_trampoline): Don't pass jump_around parameter to
	xg_append_jump.
	* config/tc-xtensa.h (struct xtensa_frag_type): Add new fields:
	needs_jump_around, next_trampoline and jump_around_fix.
2017-11-27 15:13:00 -08:00
Max Filippov 1c2649f50f gas: xtensa: reuse find_trampoline_seg
xtensa_create_trampoline_frag has opencoded fragment equivalent to
find_trampoline_seg. Drop the fragment and use find_trampoline_seg
instead. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (find_trampoline_seg): Move above the first
	use.
	(xtensa_create_trampoline_frag): Replace trampoline seg search
	code with a call to find_trampoline_seg.
2017-11-27 15:12:21 -08:00
Max Filippov fec68fb168 gas: xtensa: extract jump assembling for trampolines
init_trampoline_frag, add_jump_to_trampoline and xg_relax_trampoline add
a jump to the end of a trampoline frag. Extract it into a separate
funciton and use it in all these places. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xg_append_jump): New function.
	(xg_relax_trampoline, init_trampoline_frag)
	(add_jump_to_trampoline): Replace trampoline jump assembling
	code with a call to xg_append_jump.
2017-11-27 15:11:38 -08:00
Max Filippov 120bc8b8b9 gas: extract xg_relax_trampoline from xtensa_relax_frag
To make measurement and changes easier extract trampoline relaxation
function. No functional changes.

gas/
2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xg_relax_trampoline): New function.
	(xtensa_relax_frag): Replace trampoline relaxation code with a
	call to xg_relax_trampoline.
2017-11-27 15:10:49 -08:00
Joel Brobecker 10329bb27f fix two issues in gdb.ada/mi_catch_ex.exp (re: "exception-message")
The following patch introduced a new feature related to Ada exception
catchpoints:

    commit e547c119d0
    Author: Joel Brobecker <brobecker@adacore.com>
    Date:   Fri Nov 24 17:09:42 2017 -0500
    Subject: (Ada) provide the exception message when hitting an exception catchpoint

Unfortunately, the patch left 2 errors in gdb.ada/mi_catch_ex.exp,
both inside the "continue_to_exception" function:

  1. The exception message on the console can include the exception
     message, and thus this patch adjust the expected output in
     the corresponding gdb_expect call to allow it;
     to allow it.

  2. There was a TCL syntax confusion in "$exception_name(..."
     that caused TCL to evaluate "exception_name as an array,
     rather than as a variable. This patch fixes this by escaping
     the '(' (and the corresponding closing parenthesis, for
     consistency).

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_catch_ex.exp (continue_to_exception): Adjust
        expected output in gdb_expect call to allow the exception
        message to be present as well.  Fix syntax confusion to avoid
        TCL thinking that exception_name is an array.

Tested on x86_64-linux, with:

    DejaGnu version  1.6
    Expect version   5.45
    Tcl version      8.6
2017-11-27 11:39:45 -08:00
Szabolcs Nagy 6dda7875a8 [PR ld/22263] aarch64: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.

Fixes
FAIL: Build pr22263-1

bfd/
	PR ld/22263
	* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Use
	bfd_link_executable instead of bfd_link_pic for TLS.
	(elfNN_aarch64_allocate_dynrelocs): Likewise.
	(aarch64_can_relax_tls): Likewise.
2017-11-27 11:53:04 +00:00
Szabolcs Nagy a377ae2ad6 [PR ld/22269] aarch64: Handle local undefined weak symbols
With static pie linking undefined weak symbols are forced to resolve locally
to 0, so no GOT setup is needed in elfNN_aarch64_finish_dynamic_symbol,
which previously failed for these symbols.

The failure caused the unhelpful error message:
"ld: final link failed: Nonrepresentable section on output"

bfd/
	PR ld/22269
	* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Use
	UNDEFWEAK_NO_DYNAMIC_RELOC to avoid dynamic GOT relocs.
	(elfNN_aarch64_allocate_dynrelocs): Likewise.
2017-11-27 11:49:53 +00:00
Nick Clifton 64973b0ac4 Update the simplified Chinese translation of the messages in the opcodes library.
* po/zh_CN.po: Updated simplified Chinese translation.
2017-11-27 11:14:38 +00:00
Nick Clifton 4dff97b2ce Fix a seg-fault when displaying notes from a prorgam segment. Check for a NULL string section before attempting compute the name of a separate debug info file.
PR 22490
	* readelf.c (dump_section_as_bytes): Check for a NULL string
	section pointer.
	(process_notes_at): Compute the alignment to use if displaying
	notes from a segment.
2017-11-27 11:05:39 +00:00
Nick Clifton e3d4058216 When creating a .note section to contain a version note, set the section alignment to 4 bytes.
PR 22492
	* config/obj-elf.c (obj_elf_version): Set the alignment of the
	.note section.
2017-11-27 11:04:17 +00:00
Dominik Czarnota ee9a09e959 Update find command help and search memory docs
This patch updates the `find` command help and docs description to show
how to search for not null terminated strings when current language's
strings includes it.

gdb/ChangeLog:

	PR gdb/21945
	* findcmd.c (_initialize_mem_search): Update find command help
	text.

gdb/doc/ChangeLog:

	PR gdb/21945
	* gdb.texinfo (Search Memory): Update description and example
	about how to search a string without NULL terminator.
2017-11-26 22:42:19 -05:00
Simon Marchi e8e7d10c39 python: Fix memleak in do_start_initialization
While playing with valgrind, I noticed that with Python 3, the progname
variable in do_start_initialization is not being freed (concat returns a
malloc'ed string).  This patch uses unique_xmalloc_ptr to manage it.
With Python 2, we pass progname it directly to Py_SetProgramName, so it
should not be freed.  We therefore release it before passing it.

gdb/ChangeLog:

	* python/python.c (do_start_initialization): Change progname
	type to gdb::unique_xmalloc_ptr.  Release the pointer when using
	Python 2.
2017-11-26 19:32:47 -05:00
GDB Administrator 7db85adb3b Automatic date update in version.in 2017-11-27 00:00:27 +00:00
Tom Tromey 6a997029fb Add include guards to common/format.h
This adds include guards to common/format.h.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

	* common/format.h: Add include guards.
2017-11-26 12:02:40 -07:00
H.J. Lu 2b63c337d9 Rename argument name from link to xlink
This fixed the build with GCC 4.2:

cc1: warnings being treated as errors
binutils-gdb/binutils/dwarf.c: In function ‘load_separate_debug_info’:
binutils-gdb/binutils/dwarf.c:9650: warning: declaration of ‘link’ shadows a global declaration
/usr/include/unistd.h:757: warning: shadowed declaration is here

	* dwarf.c (load_separate_debug_info): Rename argument name from
	link to xlink.
2017-11-26 10:12:35 -08:00
Tom Tromey 41272101db Change maybe_disable_address_space_randomization to a class
This changes maybe_disable_address_space_randomization to be an RAII
class, rather than having it return a cleanup.

Regression tested by the buildbot.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

	* nat/linux-personality.h (class
	maybe_disable_address_space_randomization): New class.
	(maybe_disable_address_space_randomization): Don't declare
	function.
	* nat/linux-personality.c (restore_personality)
	(make_disable_asr_cleanup): Remove.
	(maybe_disable_address_space_randomization): Now a constructor.
	(~maybe_disable_address_space_randomization): New destructor.
	* linux-nat.c (linux_nat_create_inferior): Update.

gdbserver/ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

	* linux-low.c (linux_create_inferior): Update.
2017-11-26 10:42:15 -07:00
Tom Tromey 44287fd890 Removes a cleanup from gcore.c
This removes a cleanup from gcore.c, replacing it with
unique_xmalloc_ptr.

Regression tested by the buildbot.

ChangeLog
2017-11-26  Tom Tromey  <tom@tromey.com>

	* gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.
2017-11-26 10:41:13 -07:00
H.J. Lu 8e2495f2f7 gas: Update x86 sse-noavx tests
This fixed:

FAIL: i386 SSE without AVX equivalent
FAIL: x86-64 SSE without AVX equivalent
FAIL: x86-64 (ILP32) SSE without AVX equivalent

on x86-64.

	* testsuite/gas/i386/sse-noavx.s: Add tests for fisttps and
	fisttpl.
	* testsuite/gas/i386/x86-64-sse-noavx.s: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-sse-noavx.d: Updated.
	* testsuite/gas/i386/sse-noavx.d: Likewise.
	* testsuite/gas/i386/x86-64-sse-noavx.d: Likewise.
2017-11-26 08:32:26 -08:00
Ulrich Weigand 58f7f0bf54 Fix broken ChangeLog entry for last commit. 2017-11-26 17:29:00 +01:00
Ulrich Weigand 617cd4bc36 [spu] Fix various test cases
The SPU-specific test cases were not modified to use standard_output_file
and therefore all were no longer being executed.  Fixing this exposed a
few other bugs in spu-info noticed by using a more recent compiler, which
are also fixed here.

gdb/testsuite/ChangeLog:
2017-11-26  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.arch/spu-info.c: Include <unistd.h>.
	(do_signal_test): Fix broken calls to write.
	* gdb.arch/spu-info.exp: Use prepare_for_testing.
	Fix checks for empty mailboxes.  Update signal tests for corrected
	do_signal_test routine.  Allow nonzero event status.
2017-11-26 17:19:57 +01:00
Ulrich Weigand 5ffd2cb722 [spu] Fix single-stepping regression
Switching spu_software_single_step to use a regcache instead of a frame:
https://sourceware.org/ml/gdb-patches/2016-11/msg00355.html
cause a serious regression to SPU single-stepping.

There were two separate problems:
- SPU_LSLR_REGNUM is a pseudo register, so we must use the "cooked"
  regcache methods instead of the "raw" ones to access it.
- When accessing a branch target register, we must only use the first
  four bytes of the 16-byte vector register.  This was done automatically
  by the frame routines, but not by the regcache routines.

gdb/ChangeLog:
2017-11-26  Ulrich Weigand  <uweigand@de.ibm.com>

	* spu-tdep.c (spu_software_single_step): Access SPU_LSLR_REGNUM as
	"cooked" register.  Access only first four bytes of branch target
	registers.
2017-11-26 17:15:25 +01:00
GDB Administrator e5a8dd426d Automatic date update in version.in 2017-11-26 00:00:27 +00:00
Sergio Durigan Junior 0e5457dca1 Adding ChangeLog entry for the last commit. 2017-11-25 10:57:58 -05:00
Sergio Durigan Junior 685de8c299 Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface.  The failure is
kind of cryptic:

 77 break -pstap bar
 78 Breakpoint 3 at 0x40048d
 79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
 80 continue
 81 Continuing.
 82
 83 Program received signal SIGILL, Illegal instruction.
 84 main () at amd64-stap-optional-prefix.S:26
 85 26              STAP_PROBE1(probe, foo, (%rsp))

It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.

In the end, this was a mistake that was introduced during the review
process of the patch.  When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address).  This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.

I am pushing this patch to correct the mistake.

On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here.  However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed.  I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed.  Oh, well.

2017-11-25  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR gdb/22491
	* stap-probe.c (relocate_address): New function.
	(stap_probe::get_relocated_address): Use 'relocate_address'.
	(stap_probe::set_semaphore): Use 'relocate_address' and pass
	'm_sem_addr'.
	(stap_probe::clear_semaphore): Likewise.
2017-11-25 01:13:03 -05:00
Pedro Alves deeeba559b Use TOLOWER in SYMBOL_HASH_NEXT
The support for setting breakpoint in functions with ABI tags patch
will add a use of SYMBOL_HASH_NEXT in cp-support.c, which fails to
compile with:

  src/gdb/cp-support.c:38:0:
  src/gdb/cp-support.c: In function ‘unsigned int cp_search_name_hash(const char*)’:
  src/gdb/../include/safe-ctype.h:148:20: error: ‘do_not_use_tolower_with_safe_ctype’ was not declared in this scope
   #define tolower(c) do_not_use_tolower_with_safe_ctype
		      ^
  src/gdb/minsyms.h:174:18: note: in expansion of macro ‘tolower’
     ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
		    ^
  src/gdb/cp-support.c:1677:14: note: in expansion of macro ‘SYMBOL_HASH_NEXT’
	 hash = SYMBOL_HASH_NEXT (hash, *string);
		^

This fixes the problem before it happens.

I was somewhat worried about whether this might have an impact with
languages that are case insensitive, but I convinced myself that it
doesn't.  As bonus, this improves GDB's minsym interning performance a
bit (3%-10%).  See
<https://sourceware.org/ml/gdb/2017-11/msg00021.html>.

gdb/ChangeLog:
2017-11-25  Pedro Alves  <palves@redhat.com>

	* dictionary.c: Include "safe-ctype.h".
	* minsyms.c: Include "safe-ctype.h".
	* minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower.
2017-11-25 00:33:05 +00:00
Pedro Alves a81aaca057 Fix completing an empty string
Earlier while working on the big completer rework series, I managed to
break

 (gdb) [TAB]

locally, and make GDB crash, but only notice a few weeks down the
road, because we have no test for that...

I also noticed that:

 (gdb)     [TAB]

didn't work (didn't show all commands as matches), even though
entering a command with leading whitespace works:

 (gdb)     help

This commit fixes the latter and adds a testcase that covers both
issues.

The gdb.base/completion.exp change is necessary because the new test
has a file name that also starts with "gdb.base/complet", making that
particular test ambiguous.  Adding another letter disambiguates.

gdb/ChangeLog:
2017-11-25   Pedro Alves  <palves@redhat.com>

	* completer.c (complete_line_internal_1): Skip spaces until the
	start of the command.

gdb/testsuite/ChangeLog:
2017-11-25   Pedro Alves  <palves@redhat.com>

	* gdb.base/complete-empty.exp: New file.
	* gdb.base/completion.exp: Adjust.
2017-11-25 00:20:31 +00:00
Pedro Alves 6a3c6ee418 Add comprehensive C++ operator linespec/location/completion tests
This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc.  Particularly, makes sure all that
works without quoting.

Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)

Grows the gdb.linespec/ tests like this:

 -# of expected passes           3464
 +# of expected passes           7823

gdb/testsuite/ChangeLog:
2017-11-25  Pedro Alves  <palves@redhat.com>

	* gdb.linespec/cpls-ops.cc: New file.
	* gdb.linespec/cpls-ops.exp: New file.
	* lib/completion-support.exp (test_complete_prefix_range_re): New,
	factored out from ...
	(test_complete_prefix_range): ... this.
2017-11-25 00:09:25 +00:00
GDB Administrator 13450e7c7f Automatic date update in version.in 2017-11-25 00:00:26 +00:00
Pedro Alves 8955eb2da3 Comprehensive C++ linespec/completer tests
Exercises all sorts of aspects fixed by previous patches, going back a
few months.

 - Exercises label completion, linespecs and explicit locations.

 - Exercises both quoting vs non-quoting, source filenames, function
   names, labels, with both linespecs and explicit locations.

 - Tests corner cases around not-quoting function names, and
   whitespace and/and completing inside a parameter or template
   argument list, anonymous namespace awareness, etc.

   E.g.,

     "break foo<[TAB]"          -> "break foo<int>()"
     "break bar ( int[TAB]"     -> "break bar ( int)
     "break ( anon"             -> "break ( anonymous namespace)::func()"
     "b cfunc() [tab]"          -> "b cfunc() const"
     "b rettype templfunc[tab]" -> "b rettype templfunc<bar>()"

   ... and others.

 - Tests the "b source.c[TAB] -> b source.cc:" feature.  I.e., colon
   auto-appending.

 - Exercises corner cases around C++ "operator<" / "operator<<".
   (Much more extensive C++ operator completion/linespec handling in a
   separate patch.)

 - Exercises both tab completion and "complete" command completion,
   using routines that handle it automatically, to ensure no test
   forgets either mode.

 - Many of the completion tests test completion at at prefix of a
   given tricky name, to make sure all corner cases are covered.
   E.g., completing before, at and after ":", "(", "<".

 - Exercises "keyword" completion.  I.e., "b function() [TAB]"
   displaying "if task thread" as completion match list.  Likewise for
   display explicit location options matches at the appropriate
   points.

 - Ensures that the completer finds the same breakpoint locations that
   setting a breakpoint finds.

 - Tests that linespec/location completion doesn't find data symbols.

 - Tests that expression completion still kicks in after a
   linespec/location keyword.  I.e., this:

     "b function () if global1 + global[TAB]"

   knows that after "if", you're completing on an expression, and thus
   breaks words after "if" as an expression and matches on "global" as
   a data symbol.

 - Adds common routines to help with all the above, to be used by
   multiple completion and linespec/location test cases.

 - More...

Grows the gdb.linespec/ tests like this:

  -# of expected passes           573
  +# of expected passes           3464

gdb/testsuite/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

	* gdb.linespec/cpcompletion.exp: New file.
	* gdb.linespec/cpls-hyphen.cc: New file.
	* gdb.linespec/cpls.cc: New file.
	* gdb.linespec/cpls2.cc: New file.
	* gdb.linespec/explicit.exp: Load completion-support.exp.  Adjust
	test to use test_gdb_complete_unique.  Add label completion,
	keyword completion and explicit location completion tests.
	* lib/completion-support.exp: New file.
2017-11-24 23:41:12 +00:00
Pedro Alves 0662b6a7c1 Make strcmp_iw NOT ignore whitespace in the middle of tokens
currently "b func tion" manages to set a breakpoint at "function" !

All these years I had never noticed this, but now that the linespec
completer actually works, this easily happens by accident, with:

  "b func t<tab>"

expecting to get "thread", but getting instead:

  "b func tion"

...

Also, this:

  "b rettypefunc<int>"

manages to set a breakpoint on "rettype func<int>()".

These things happen due to strcmp_iw "magic".

Fix it by teaching strcmp_iw about when can it skip whitespace.  This
required handling user-defined operators, and scope operators,
complicating the code a bit, unfortunately.  I added unit tests for
all the corner cases I stumbled on, as I was developing this, and then
in the end wrote a testsuite testcase covering many of the same things
and more (to be added later).

gdb/ChangeLog:
2017-11-24  Pedro Alves  <palves@redhat.com>

	* cp-support.c (cp_symbol_name_matches_1): New, factored out from
	cp_fq_symbol_name_matches.  Pass language_cplus to
	strncmp_with_mode.
	(cp_fq_symbol_name_matches): Call cp_symbol_name_matches_1.
	(selftests::test_cp_symbol_name_cmp): New.
	(_initialize_cp_support): Register "cp_symbol_name_matches"
	selftests.
	* language.c (default_symbol_name_matcher): Pass language_minimal
	to strncmp_iw_with_mode.
	* utils.c: Include "cp-support.h" and <algorithm>.
	(valid_identifier_name_char, cp_skip_operator_token, skip_ws)
	(cp_is_operator): New functions.
	(strncmp_iw_with_mode): Use them.  Add language parameter.  Don't
	skip whitespace in the symbol name when the lookup name doesn't
	have spaces, and vice versa.
	(strncmp_iw, strcmp_iw): Pass language to strncmp_iw_with_mode.
	* utils.h (strncmp_iw_with_mode): Add language parameter.
2017-11-24 23:30:04 +00:00
H.J. Lu 276da9b31b Re-apply "elf: Properly compute offsets of note descriptor and next note"
CORE PT_NOTE segments may have p_align values of 0 or 1.  gABI specifies
that PT_NOTE alignment should be aligned to 4 bytes for 32-bit objects
and to 8 bytes for 64-bit objects.  If segment alignment is less than 4,
we use 4 byte alignment.
2017-11-24 14:52:15 -08:00
Joel Brobecker e547c119d0 (Ada) provide the exception message when hitting an exception catchpoint
This patch enhances the debugger to print the exception message, when
available, as part of an exception catchpoint hit notification (both
GDB/CLI and GDB/MI). For instance, with the following code...

    procedure A is
    begin
       raise Constraint_Error with "hello world";
    end A;

... instead of printing...

    Catchpoint 1, CONSTRAINT_ERROR at 0x000000000040245c in a () at a.adb:3

... it now prints:

    Catchpoint 1, CONSTRAINT_ERROR (hello world) at 0x000000000040245c in a ()
                                   ^^^^^^^^^^^^^

This enhancement requires runtime support. If not present, the debugger
just behaves as before.

In GDB/MI mode, if the exception message is available, it is provided
as an extra field named "exception-message" in the catchpoint notification:

    *stopped,bkptno="1",[...],exception-name="CONSTRAINT_ERROR",
       exception-message="hello world",[...]

gdb/ChangeLog:

        * ada-lang.c (ada_exception_message_1, ada_exception_message):
        New functions.
        (print_it_exception): If available, display the exception
        message as well.
        * NEWS: Document new feature.

gdb/doc/ChangeLog:

        * gdb.texinfo (GDB/MI Ada Exception Information): Document
        new "exception-message" field.

gdb/testsuite/ChangeLog:

        * gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp,
        gdb.ada/mi_ex_cond.exp: Accept optional exception message in
        when hitting an exception catchpoint.
2017-11-24 17:15:30 -05:00
Simon Marchi 5f1ca24acd Fix issues with gdb-memory-map.dtd
While writing a unit test for parse_memory_map, I tried to validate my
test input against gdb-memory-map.dtd, and found a few problems with it.
This doesn't influence how gdb parses it (AFAIK it doesn't use the
linked dtd), but if you edit the xml file in an editor that supports
dtds, you'll get plenty of errors.

  - The <memory-map> element accepts exactly one <memory> OR <property>
    as a child.  This is a problem because you can't have multiple
    <memory> elements and you shouldn't be able to have <property> elements
    as direct children of <memory-map>.
  - The <memory> element wants exactly one <property> child.  This is
    wrong, since you could have zero or more (even though we only
    support one kind of property currently).
  - I have no idea wht the device attribute of <memory> is, GDB doesn't
    read that.  I searched back in time a bit but couldn't find a trace
    of it.

I took the opportunity to tighten what is accepted as a value of the
memory type and property name attributes.  We currently accept any
string, but we can restrict them to the values GDB really accepts (and
which are documented).

AFAIK, this "file" only exists in the documentation, in gdb.texinfo, so
this is what I modified.  However, it's also available at
http://sourceware.org/gdb/gdb-memory-map.dtd.  This one should be
updated too, but I don't know how that should be done.

gdb/doc/ChangeLog:

	* gdb.texinfo (Memory Map Format): Update gdb-memory-map.dtd.
2017-11-24 17:14:07 -05:00
Ulrich Weigand f5291a6f32 [spu] Fix spu-linux gdbserver build
Fix a typo in a newly added argument name.

gdb/ChangeLog:
2017-11-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* spu-low.c (spu_create_inferior): Fix typo in argument name.
2017-11-24 22:04:41 +01:00
Ulrich Weigand d7fcdff980 [spu] Fix spu-linux native build
Add missing file to NATDEPFILES.

gdb/ChangeLog:
2017-11-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* configure.nat <spu-linux>: Add fork-inferior.o to NATDEPFILES.
2017-11-24 22:03:28 +01:00
Simon Marchi 4e25ac038e Revert "elf: Properly compute offsets of note descriptor and next note"
This reverts commit 650444eb54.

With this patch, running the GDB test case gdb.base/auxv.exp is stuck in
an infinite loop, consuming memory to the point that it renders the
machine unusable. I am reverting it so we can take our time to
investigate while not killing all the developers' machines.
2017-11-24 15:43:51 -05:00
Jim Wilson 0fbc35681f Add reference to implicit use in _bfd_elf_is_local_label_name.
gas/
	* write.h (FAKE_LABEL_CHAR): Expand comment.
2017-11-24 09:31:59 -08:00
H.J. Lu 8b77421a20 Update PR ld/21562 tests for underscore targets
We also need to provide __start_scnfoo and __stop_scnfoo with the extra
leading underscore for underscore targets.

This patch fixed:

FAIL: ld-elf/pr21562k
FAIL: ld-elf/pr21562l
FAIL: ld-elf/pr21562m
FAIL: ld-elf/pr21562n

for metag-linux,

	* testsuite/ld-elf/pr21562c.t: Also provide ___start_scnfoo and
	___stop_scnfoo.
	* testsuite/ld-elf/pr21562d.t: Likewise.
2017-11-24 08:58:56 -08:00
Philipp Rudo 30649c1451 Workaround build bug with GCC 6.2.1
Building GDB with GCC 6.2.1 gives multiple errors like

gdb/dtrace-probe.c: In member function ‘void dtrace_probe::build_arg_exprs(gdbarch*)’:
gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror]
    for (struct dtrace_probe_arg &arg : m_args

Fix it by removing the 'struct' keyword.

A similar Bug was already fixed for GCC 6.3.1
https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html

gdb/ChangeLog:

	* dtrace-probe.c (dtrace_probe::build_arg_exprs)
	(dtrace_probe::is_enabled, dtrace_probe::enable)
	(dtrace_probe::disable): Remove keyword 'struct' at for-range
	variable
	* probe.c (gen_ui_out_table_header_info)
	(print_ui_out_not_applicables):  Remove keyword 'struct' at
	for-range variable
2017-11-24 11:16:37 -05:00