Commit Graph

93543 Commits

Author SHA1 Message Date
Tom Tromey 9c3630e983 Don't reference past the end of the vector
An earlier change made find_source_lines read:

    end = &data[size];

However, since 'size' is the size of the vector, this seems fishy.
More obviously ok is to compute the end of the data directly:

    end = data.data () + size;

2018-02-09  Tom Tromey  <tom@tromey.com>

	* source.c (find_source_lines): Don't reference past the end of
	the vector.
2018-02-09 06:46:11 -07:00
Markus Metzger c4e1263132 btrace: reword error messages
Reword some btrace error messages to align with the format discussed in
https://sourceware.org/ml/gdb-patches/2018-02/msg00135.html.

gdb/
	* remote.c (remote_btrace_maybe_reopen): Change error message.
	* btrace.c (btrace_enable): Likewise.
	(parse_xml_btrace): Likewise.
	(parse_xml_btrace_conf): Likewise.

testsuite/
	* lib/gdb.exp (skip_btrace_pt_tests): Update expected error message.
	Fix test name.
2018-02-09 14:03:22 +01:00
Markus Metzger 88711fbfea btrace: check perf_event_paranoid
One recurring error on Debian systems is that the default perf_event_paranoid
setting disables the perf_event interface for user-space.

Check the current level and point the user to the file.

gdb/
	* nat/linux-btrace.c (diagnose_perf_event_open_fail): New.
	(linux_enable_pt, linux_enable_bts): Call
	diagnose_perf_event_open_fail.
2018-02-09 14:03:21 +01:00
Markus Metzger 17ad2a4f46 btrace: improve enable error messages
Improve the error message when GDB fails to start recording branch trace.

This patch also removes a zero buffer size check for PT to align with BTS.  The
buffer size can not be configured to be zero.

gdb/
	* nat/linux-btrace.c (perf_event_pt_event_type): Improve error message.
	Remove parameter and change return type.  Update callers.  Move it.
	(linux_enable_bts, linux_enable_pt): Improve error message.
	(linux_enable_pt): Remove zero buffer size check.
	(linux_enable_btrace): Improve error messages.  Remove NULL return
	check.
2018-02-09 14:03:20 +01:00
Markus Metzger de6242d307 btrace, gdbserver: remove the to_supports_btrace target method
Remove the to_supports_btrace target method and instead rely on detecting errors
when trying to enable recording.  This will also provide a suitable error
message explaining why recording is not possible.

For remote debugging, gdbserver will now always advertise branch tracing related
packets.  When talking to an older GDB, this will cause GDB to try to enable
branch tracing and gdbserver to report a suitable error message every time.

An older gdbserver will not advertise branch tracing related packets if the
one-time check failed, so a newer GDB with this patch will fail to enable branch
tracing at remote_enable_btrace() rather than at btrace_enable().  The error
message is the same in both cases so there should be no user-visible change.

gdb/
	* btrace.c (btrace_enable): Remove target_supports_btrace call.
	* nat/linux-btrace.c (perf_event_pt_event_type): Move.
	(kernel_supports_bts, kernel_supports_pt, linux_supports_bts)
	(linux_supports_pt, linux_supports_btrace): Remove.
	(linux_enable_bts): Call cpu_supports_bts.
	* nat/linux-btrace.h (linux_supports_btrace): Remove.
	* remote.c (remote_supports_btrace): Remove.
	(init_remote_ops): Remove remote_supports_btrace.
	* target-delegates.c: Regenerated.
	* target.c (target_supports_btrace): Remove.
	* target.h (target_ops) <to_supports_btrace>: Remove
	(target_supports_btrace): Remove.
	* x86-linux-nat.c (x86_linux_create_target): Remove
	linux_supports_btrace.

gdbserver/
	* linux-low.c (linux_target_ops): Remove linux_supports_btrace.
	* nto-low.c (nto_target_ops): Remove NULL for supports_btrace.
	* spu-low.c (spu_target_ops): Likewise.
	* win32-low.c (win32_target_ops): Likewise.
	* server.c (supported_btrace_packets): Report packets unconditionally.
	* target.h (target_ops) <supports_btrace>: Remove.
	(target_supports_btrace): Remove.
2018-02-09 14:03:20 +01:00
Markus Metzger 9ee23a853c btrace, gdbserver: use exceptions to convey btrace enable/disable errors
Change error reporting to use exceptions and be prepared to catch them in
gdbserver.  We use the exception message in our error reply to GDB.

This may remove some detail from the error message in the native case since
errno is no longer printed.  Later patches will improve that.

We're still using error strings on the RSP level.  This patch does not affect
the interoperability of older/newer GDB/gdbserver.

gdbserver/
	* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt)
	(handle_btrace_disable): Change return type to void.  Use exceptions
	to report errors.
	(handle_btrace_general_set): Catch exception and copy message to
	return message.

gdb/
	* nat/linux-btrace.c (linux_enable_btrace): Throw exception if enabling
	btrace failed.
	* x86-linux-nat.c (x86_linux_enable_btrace): Catch btrace enabling
	exception and use message in own exception.
2018-02-09 14:03:19 +01:00
Markus Metzger 5c3284c1ec btrace: prepare for throwing exceptions when enabling btrace
We indicate success or failure for enabling branch tracing via the pointer
return value.  Depending on the type of error, errno may provide additional
information.

Prepare for using exceptions with more descriptive error messages by using smart
pointers and objects with automatic destruction to hold intermediate results.

gdb/
	* nat/linux-btrace.c: Include scoped_fd.h and scoped_mmap.h.
	(perf_event_pt_event_type): Use gdb_file_up.
	(linux_enable_bts, linux_enable_pt): Use gdb::unique_xmalloc_ptr,
	scoped_fd, and scoped_mmap.
2018-02-09 14:03:19 +01:00
Markus Metzger 84696f37ae common: add scoped_mmap
Add a simple helper to automatically unmap a memory mapping.

gdb/
	* common/scoped_mmap.h: New.
	* unittests/scoped_mmap-selftest.c: New.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/scoped_mmap-selftest.c.
2018-02-09 14:03:19 +01:00
Markus Metzger ea4a088812 common: add scoped_fd
Add a simple helper to automatically close a file descriptor.

gdb/
	* common/scoped_fd.h: New.
	* unittests/scoped_fd-selftest.c: New.
	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/scoped_fd-selftest.c.
2018-02-09 14:03:18 +01:00
Tom Tromey 869e8290ea Use gdb::unique_xmalloc_ptr in auto_load_section_scripts
This changes auto_load_section_scripts to use gdb::unique_xmalloc_ptr,
allowing the removal of a cleanup.

2018-02-09  Tom Tromey  <tom@tromey.com>

	* auto-load.c (auto_load_section_scripts): Use
	gdb::unique_xmalloc_ptr.
2018-02-09 05:53:22 -07:00
Tom Tromey a37a2ae708 Use std::string in execute_script_contents
This changes execute_script_contents to use a std::string, allowing
the removal of a cleanup.

2018-02-09  Tom Tromey  <tom@tromey.com>

	* auto-load.c (execute_script_contents): Use std::string.
2018-02-09 05:53:21 -07:00
Joel Brobecker 4e72534799 gdb/NEWS: Clarify the news entry for "rbreak" in GDB 8.1
gdb/ChangeLog:

        * NEWS <Changes in GDB 8.1>: Clarify that "rbreak" is a new
        Python function, rather than a new command.
2018-02-09 16:04:38 +04:00
H.J. Lu 15b23f3612 x86: Set need_global_offset_table with info->output_bfd->xvec
* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
	Remove prototype.
	(i386_elf32_sol2_vec): Declared.
	(elf_i386_link_setup_gnu_properties): Set
	need_global_offset_table with info->output_bfd->xvec.
	* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
	Remove prototype.
	(x86_64_elf64_sol2_vec): Declared.
	(elf_x86_64_link_setup_gnu_properties): Set
	need_global_offset_table with info->output_bfd->xvec.
2018-02-08 16:30:55 -08:00
GDB Administrator 4d6945e70a Automatic date update in version.in 2018-02-09 00:00:25 +00:00
H.J. Lu dc11dea212 x86: Keep the unused _GLOBAL_OFFSET_TABLE_ for Solaris
Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it isn't used.
This patch detects Solaris target and keeps _GLOBAL_OFFSET_TABLE_ for
Solaris.

	* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
	New prototype.
	(elf_i386_link_setup_gnu_properties): Set need_global_offset_table
	for Solaris.
	* elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields):
	New prototype.
	(elf_x86_64_link_setup_gnu_properties): Set
	need_global_offset_table for Solaris.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep the
	unused _GLOBAL_OFFSET_TABLE_ for Solaris.
	(_bfd_x86_elf_link_setup_gnu_properties): Copy
	need_global_offset_table.
	* elfxx-x86.h (elf_x86_link_hash_table): Add
	need_global_offset_table.
	(elf_x86_init_table): Likewise.
2018-02-08 13:52:22 -08:00
Jim Wilson 3f48fe4a95 RISC-V: Add comment for previous change.
bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous
	change.
2018-02-08 13:15:10 -08:00
Tom Tromey 9a897d43f0 Remove cleanups from solib.c
This removes a couple of cleanups from solib.c, replacing one with
std::string and another with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* solib.c (solib_find_1): Use std::string.
	(solib_bfd_fopen): Use unique_xmalloc_ptr.
2018-02-08 11:46:57 -07:00
Tom Tromey 58ef3771fb Use unique_xmalloc_ptr in build_id_to_debug_bfd
This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr,
removing a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr.
2018-02-08 11:46:57 -07:00
Tom Tromey a9abc43451 Use gdb::def_vector in find_source_lines
This replaces an explicit malloc and a cleanup with a gdb::def_vector.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* source.c (find_source_lines): Use gdb::def_vector.
2018-02-08 11:46:57 -07:00
Tom Tromey 84f27c6fcb Remove cleanups from macro_define_command
This removes cleanups from macro_define_command, by introducing a new
struct temporary_macro_definition that cleans up after itself.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macrocmd.c (struct temporary_macro_definition): New.
	(macro_define_command): Use temporary_macro_definition.  Remove
	cleanups.
	(free_macro_definition_ptr): Remove.
2018-02-08 11:46:56 -07:00
Tom Tromey 0354904bda Use std::string in maybe_expand
This patch changes maybe_expand to use std::string rather than an
explicit malloc and a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macroexp.c (maybe_expand): Use std::string.
2018-02-08 11:46:56 -07:00
Tom Tromey 1739cf248f Class-ify macro_buffer
This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members.  Then this is
used to remove various cleanups in macroexp.c.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* macroexp.c (struct macro_buffer): Add initializers for some
	members.
	(init_buffer, init_shared_buffer, free_buffer)
	(free_buffer_return_text): Remove.
	(macro_buffer): New constructors.
	(~macro_buffer): New destructor.
	(macro_buffer::set_shared): New method.
	(macro_buffer::resize_buffer, macro_buffer::appendc)
	(macro_buffer::appendmem): Now methods, not free functions.
	(set_token, append_tokens_without_splicing, stringify)
	(macro_stringify): Update.
	(gather_arguments): Change return type.  Remove argc_p argument,
	add args_ptr argument.  Use std::vector.
	(substitute_args): Remove argc argument.  Accept std::vector.
	(expand): Update.  Use std::vector.
	(scan, macro_expand, macro_expand_next): Update.
2018-02-08 11:46:56 -07:00
Tom Tromey f6c2623eb8 Return unique_xmalloc_ptr from macro scope functions
This changes the macro scope functions (sal_macro_scope,
user_macro_scope, and default_macro_scope) to return a
unique_xmalloc_ptr, then fixes up the users.  This allowed for the
removal of several cleanups.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* symtab.c (default_collect_symbol_completion_matches_break_on):
	Use unique_xmalloc_ptr.
	* macroscope.h: (sal_macro_scope, user_macro_scope)
	(default_macro_scope): Return unique_xmalloc_ptr.
	* macroscope.c (sal_macro_scope, user_macro_scope)
	(default_macro_scope): Return unique_xmalloc_ptr.
	* macroexp.h (macro_expand, macro_expand_once): Return
	unique_xmalloc_ptr.
	* macroexp.c (macro_expand, macro_expand_once): Return
	unique_xmalloc_ptr.
	* macrocmd.c (macro_expand_command, macro_expand_once_command)
	(info_macro_command, info_macros_command): Use
	unique_xmalloc_ptr.
	* compile/compile-c-support.c (write_macro_definitions): Use
	unique_xmalloc_ptr.
	* c-exp.y (c_parse): Use unique_xmalloc_ptr.
2018-02-08 11:46:55 -07:00
Tom Tromey 8ce47547b3 Remove make_cleanup_restore_current_thread from gdbserver
This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* linux-low.c (install_software_single_step_breakpoints): Use
	make_scoped_restore.
	* inferiors.c (make_cleanup_restore_current_thread): Remove.
	(do_restore_current_thread_cleanup): Remove.
	* gdbthread.h (make_cleanup_restore_current_thread): Don't
	declare.
2018-02-08 11:46:55 -07:00
Tom Tromey 45dd3607e2 Remove a cleanup from gdbserver
This removes a cleanup from gdbserver's set_raw_breakpoint_at,
replacing it with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

	* mem-break.c (set_raw_breakpoint_at): Use
	gdb::unique_xmalloc_ptr.
2018-02-08 11:46:55 -07:00
Nick Clifton 8de3a6e2af Speed up readelf and objdump by not looking for DWO links unless the user has requested that they be displayed/followed.
PR 22802
	* dwarf.c (load_separate_debug_file): Return early if the user is
	not interested in debug links.
2018-02-08 12:29:07 +00:00
Nick Clifton ef135d4314 Fix a seg-fault in the ELF note parser when a note with an excessively large alignment is encountered.
PR 22788
	* elf.c (elf_parse_notes): Reject notes with excessuively large
	alignments.
2018-02-08 10:28:25 +00:00
Alan Modra a9479dc051 PR22819, powerpc gas "instruction address is not a multiple of 4"
Checks for insn alignment were hopelessly confused when misaligned
data starts a new frag.  The real-world testcase happened to run out
of frag space in the middle of emitting a trace-back table via
something like:
	.byte 0		/* VERSION=0 */
 	.byte 9		/* LANG=C++ */
	.byte 34	/* Bits on: has_tboff, fp_present */
	.byte 64	/* Bits on: name_present */
	.byte 128	/* Bits on: stores_bc, FP_SAVED=0 */
	.byte 0		/* Bits on: GP_SAVED=0 */
	.byte 2		/* FIXEDPARMS=2 */
	.byte 1		/* FLOATPARMS=0, parmsonstk */
	.long 0
	.long 768	/* tb_offset: 0x300 */
	.hword 45	/* Function name length: 45 */
 	.long 0x334e5a5f
	.long 0x31766f70
	.long 0x65744932
	.long 0x69746172
	.long 0x7a5f6e6f
	.long 0x64504533
	.long 0x5f534e50
	.long 0x72463431
	.long 0x61746361
	.long 0x74535f6c
	.long 0x74637572
	.byte 0x45
	.byte 0
The trigger being those misaligned .long's output for the function
name.  A most horrible way to output a string, especially considering
endian issues..

	PR 22819
	* config/tc-ppc.c (md_assemble): Rewrite insn alignment checking.
	(ppc_frag_check): Likewise.
	* testsuite/gas/ppc/misalign.d,
	* testsuite/gas/ppc/misalign.l,
	* testsuite/gas/ppc/misalign.s: New test.
	* testsuite/gas/ppc/misalign2.d,
	* testsuite/gas/ppc/misalign2.s: New test.
	* testsuite/gas/ppc/ppc.exp: Run them.
2018-02-08 13:56:29 +10:30
GDB Administrator 02ecce62be Automatic date update in version.in 2018-02-08 00:00:32 +00:00
Simon Marchi c2e0e465f9 Fix type of values representing optimized out static members
As reported here:

  https://sourceware.org/ml/gdb/2018-02/msg00019.html

the type of values representing static members that are optimized out is
wrong.  It currently assigns the type of the containing class rather
than the type of the field.  This patch fixes that.

I found a place in m-static.exp already dealing with optimized out
static members, so I just added some gdb_test there.

gdb/ChangeLog:

	* value.c (value_static_field): Assign field type instead of
	containing type when returning an optimized out value.

gdb/testsuite/ChangeLog:

	* gdb.cp/m-static.exp: Check type of optimized out static
	member.
2018-02-07 08:49:56 -05:00
Alan Modra 407aa07cee Revert "PowerPC PLT speculative execution barriers"
This reverts most of commit 1be5d8d3bb.
Left in place are addition of --no-plt-align to some ppc32 ld tests
and the ld.texinfo --no-plt-thread-safe fix.
2018-02-07 14:23:08 +10:30
Jim Wilson ed01220cc8 RISC-V: Eliminate spurious error w/ reloc truncated message
bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used
	callback to report an error.
2018-02-06 16:53:41 -08:00
GDB Administrator f3342ae030 Automatic date update in version.in 2018-02-07 00:00:39 +00:00
Yao Qi 3f8c94b478 Remove some $ARCH_read_pc and $ARCH_write_pc
Nowadays, gdbarch_read_pc is called in this way,

  if (gdbarch_read_pc_p (gdbarch))
    pc_val = gdbarch_read_pc (gdbarch, regcache);
  /* Else use per-frame method on get_current_frame.  */
  else if (gdbarch_pc_regnum (gdbarch) >= 0)
    {
      ULONGEST raw_val;

      if (regcache_cooked_read_unsigned (regcache,
					 gdbarch_pc_regnum (gdbarch),
					 &raw_val) == REG_UNAVAILABLE)

some ports don't have to define its own gdbarch read_pc method if the
pc value is simply a unsigned value from "pc" register.  The same rule
applies to regcache_write_pc.  This patch removes these $ARCH_read_pc
and $ARCH_write_pc functions.

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

	* ft32-tdep.c (ft32_read_pc): Remove.
	(ft32_write_pc): Remove.
	(ft32_gdbarch_init): Update.
	* m32r-tdep.c (m32r_read_pc): Remove.
	(m32r_gdbarch_init): Update.
	* mep-tdep.c (mep_read_pc): Remove.
	(mep_gdbarch_init): Update.
	* microblaze-tdep.c (microblaze_write_pc): Remove.
	(microblaze_gdbarch_init): Update.
	* mn10300-tdep.c (mn10300_read_pc): Remove.
	(mn10300_write_pc): Remove.
	(mn10300_gdbarch_init): Update.
	* moxie-tdep.c (moxie_read_pc): Remove.
	(moxie_write_pc): Remove.
	(moxie_gdbarch_init): Update.
2018-02-06 17:31:33 +00:00
Eric Botcazou c20c30f615 Fix PR ld/22263 on SPARC.
This is -fpie -pie generating dynamic relocations in the text section,
simply because no TLS transitions are applied in PIE mode.  The meat
of the patch is to turn calls to bfd_link_pic (info) in TLS-related code
into !bfd_link_executable (info) and there are quite a lot of them...

bfd/
	* elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic
	into call to !bfd_link_executable and tidy up.
	(_bfd_sparc_elf_check_relocs): Fix formatting and tidy up.
	<R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_TLS_IE_HI22>: Likewise.
	<GOT relocations>: Remove useless code, tidy and merge blocks.
	<R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_WPLT30>: Tidy up.
	(_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call
	to !bfd_link_executable.
	(allocate_dynrelocs): Likewise.
	(_bfd_sparc_elf_relocate_section): Fix formatting and tidy up.
	<R_SPARC_TLS_GD_HI22>: Merge into...
	<R_SPARC_TLS_GD_LO10>: ...this.  Adjust 4th argument in call to
	sparc_elf_tls_transition and remove redundant code.
	<R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to
	!bfd_link_executable.
	<R_SPARC_TLS_LDO_HIX22>: Likewise.
	<R_SPARC_TLS_LE_HIX22>: Likewise.  Tidy up.
	<R_SPARC_TLS_LDM_CALL>: Likewise.
	<R_SPARC_TLS_GD_CALL>: Likewise.  Tidy up.
	<R_SPARC_TLS_GD_ADD>: Likewise.
	<R_SPARC_TLS_LDM_ADD>: Likewise.
	<R_SPARC_TLS_LDO_ADD>: Likewise.
	<R_SPARC_TLS_IE_LD>: Likewise.
ld/
	* testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC.
	(pr22263-1): Pass AFLAGS_PIC to the assembler.
	* testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions.
	* testsuite/ld-sparc/tlspie32.dd: Adjust to above.
	* testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions.
	* testsuite/ld-sparc/tlspie64.dd: Adjust to above.
2018-02-06 18:17:39 +01:00
Yao Qi bca65a2394 Treat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL
When I debug some fortran expression parsing, I got

(gdb) set debug expression 1
(gdb) p intvla(5,5,5)
Dump of expression @ 0x205fa80, before conversion to prefix form:
	Language fortran, 19 elements, 16 bytes each.
	Index                Opcode         Hex Value  String Value
	    0          OP_VAR_VALUE  40  (...............
	    1    <unknown 31863232>  31863232  .1..............
....
	   14             BINOP_REM  5  ................
	   15               OP_LONG  38  &...............
	   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
	   17             BINOP_MUL  3  ................
	   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x205fa80, after conversion to prefix form:
Expression: `Invalid expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This patch fixes this problem by handling OP_F77_UNDETERMINED_ARGLIST in
the same way as handling OP_FUNCALL.  With this patch applied, the output
looks better,

(gdb) p intvla (5,5,5)
Dump of expression @ 0x2d75590, before conversion to prefix form:
	Language fortran, 19 elements, 16 bytes each.
	Index                Opcode         Hex Value  String Value
	    0          OP_VAR_VALUE  40  (...............
....
	   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
	   17             BINOP_MUL  3  ................
	   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x2d75590, after conversion to prefix form:
Expression: `vla_primitives::intvla (5, 5, 5)'
	Language fortran, 19 elements, 16 bytes each.

	    0  OP_F77_UNDETERMINED_ARGLIST  Number of args: 3
	    3    OP_VAR_VALUE          Block @0x297e1c0, symbol @0x297cd50 (intvla)
	    7    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
	   11    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
	   15    OP_LONG               Type @0x2976900 (int), value 5 (0x5)

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

	* expprint.c (print_subexp_standard): Handle
	OP_F77_UNDETERMINED_ARGLIST.
	(dump_subexp_body_standard): Likewise.
2018-02-06 17:12:12 +00:00
Yao Qi 583e3f9061 Fix up one ChangeLog entry date
The patch was committed on 5th Feb, and the first line of ChangeLog
entry is too long.  The max line length is 74.
https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog
2018-02-06 17:08:47 +00:00
Nick Clifton 46d09186d3 Improve the find_nearest_line function for the MIPS target so that it tries harder to find a function name.
PR 22789
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf
	functions failed to find the function name, try the generic elf
	find function instead.
2018-02-06 17:00:25 +00:00
Sergio Durigan Junior 8278e7cec3 Fix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.c
GCC 8 will bring a new warning option which will detect possible
overflow and truncation on string manipulation functions.  For more
details, see:

  https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00471.html

While compiling BFD with it, I can see one place on bfd/coff-rs6000.c
where the warning is triggered.  This:

  (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);

will not include the trailing NUL on fhdr.magic, but that's fine
because it's a magic number.  The fix is trivial: just use memcpy
instead.

OK to push?

2018-02-06  Sergio Durigan Junior  <sergiodj@redhat.com>

	* coff-rs6000.c (xcoff_write_archive_contents_old): Use
	'memcpy' instead of 'strncpy' when writing the magic number.
2018-02-06 11:47:24 -05:00
Nick Clifton 68807c3cd6 Replace reachable assertion with a test and return of NULL.
PR 22793
	* readelf.c (find_section): Replace assertion with test and return
	of NULL.
	(find_section_by_address): Add test of section header table
	existance.
	(find_section_by_type): Likewise.
	(find_section_in_set): Likewise.
2018-02-06 16:05:13 +00:00
Nick Clifton 64e234d417 Prevent attempts to call strncpy with a zero-length field by chacking the size of debuglink sections.
PR 22794
	* opncls.c (bfd_get_debug_link_info_1): Check the size of the
	section before attempting to read it in.
	(bfd_get_alt_debug_link_info): Likewise.
2018-02-06 15:48:29 +00:00
Paul Carroll 422f3d3d6d Allow the find_abstract_instance_name() function in the BFD library to also return file and line number information.
The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available.
We have a tool that consumes this information and displays it.
This identified a problem with the 'nm' utility.

When a source is compiled with -O2, functions can be inlined.  The compiler also produces an uninlined copy of the function, normally for linking to other object files.
In the case of DWARF2 debug information, the compiler generates debug information to describe a function.  If that function is inlined, the compiler then references that debug information from the inlined and uninlined copies of the routine through the use of the DW_AT_abstract_origin reference.
When nm is used on such a file, it is not able to find file and line information because that information is present in the common debug information and not at each actual implementation of the function.
The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more.

What I am proposing is to modify the find_abstract_instance_name() function (which I renamed to find_abstract_instance() ) to return the name of the function as well as any file and line information.  The routine is already parsing all of the debug information in the abstract instance, so it is easy to pick up the file and line information at that time. If, for some reason, the file and line information is not present, the routine behaves as before.

For example, if I have a simple test case:

int foo(int j)
{
        if (j < 15)
                j += j << 2;
        else
                j += j << 6;
        return j;
}

int main (int argc,char **argv)
{
        int i = argc;
        i += foo(i);
        return i;
}

If that test case is compiled with -O2 and then 'nm -l' reads that executable, it currently produces this symbol output (ignoring a lot of library symbols):

8048400 T foo
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12

If I modify 'nm' to return file and line information for abstract instances, it produces the following output:

08048400 T foo  /scratch/pcarroll/its254/test/mytest.c:1
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12
--------------------------------------------------------------------------
bfd	* bfd/dwarf2.c (find_abstract_name): Modified to return file and
	line information in addition to name, if they can be found.
2018-02-06 15:45:31 +00:00
GDB Administrator 9d0e82daf9 Automatic date update in version.in 2018-02-06 00:00:23 +00:00
Jan Kratochvil 72dd273062 ppc64: Fix stwux encoding
With gcc-8.0.1-0.9.fc28.x86_64 I get:

../../gdb/rs6000-tdep.c: In function 'CORE_ADDR skip_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, rs6000_framedata*)':
../../gdb/rs6000-tdep.c:1911:34: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
       else if ((op & 0xfc1f016a) == 0x7c01016e)
                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.alangref/idalangref_stwux_stux_instrs.htm
says
	bit 21 - 30 = 183
	Those are bits 1..10 in normal bit order: 183<<1 = 0x16e

gdb/ChangeLog
2018-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* rs6000-tdep.c (skip_prologue): Fix stwux encoding.
2018-02-05 20:20:23 +01:00
Renlin Li 279b2f9416 [PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared object.
The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi
will be used to generate an address does not hold for absolute symbol.
In this case, it is a value fixed at static linking time.

The condition to check the relocations is relax to allow absolute symbol and
undefined symbol case.

bfd/

2018-02-05  Renlin Li  <renlin.li@arm.com>

	PR ld/22764
	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
	R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
	check for writeable section as well.

ld/

2018-02-05  Renlin Li  <renlin.li@arm.com>

	PR ld/22764
	* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
	* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
	* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
	* testsuite/ld-aarch64/pr22764.s: New.
	* testsuite/ld-aarch64/pr22764.d: New.
2018-02-05 18:18:45 +00:00
Antoine Tremblay f3b91ed8f9 Remove myself as a write-after-approval GDB maintainer.
Since I'll be leaving Ericsson.

gdb/
	* MAINTAINERS (Write After Approval): Remove Antoine Tremblay.
2018-02-05 11:41:03 -05:00
H.J. Lu cd04836359 x86: Remove the unused _GLOBAL_OFFSET_TABLE_
Since _GLOBAL_OFFSET_TABLE_ may be referenced implicitly on x86,
checking ref_regular_nonweak leaves the unused _GLOBAL_OFFSET_TABLE_
in output.  This patch checks explicit GOT references instead.

ld-i386/discarded1.s and ld-x86-64/discarded1.s are updated to avoid
linker optimization which removes GOT references.

bfd/

	PR ld/22782
	* elf32-i386.c (elf_i386_check_relocs): Set got_referenced if
	_GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve
	undefined weak symbol to 0.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced
	if _GLOBAL_OFFSET_TABLE_ is referenced.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check
	got_referenced instead of ref_regular_nonweak.  Remove the
	unused _GLOBAL_OFFSET_TABLE_ from symbol table.
	* elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced.

ld/

	PR ld/22782
	* testsuite/ld-i386/discarded1.s: Replace mov with div.
	* testsuite/ld-x86-64/discarded1.s: Likewise.
	* testsuite/ld-i386/i386.exp: Run pr22782.
	* testsuite/ld-i386/load1-nacl.d: Updated for removing
	_GLOBAL_OFFSET_TABLE_ from output.
	* testsuite/ld-i386/load1.d: Likewise.
	* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1a.d: Likewise.
	* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1b.d: Likewise.
	* testsuite/ld-i386/pr22782.d: New file.
	* testsuite/ld-i386/pr22782.s: Likewise.
	* testsuite/ld-x86-64/pr22782.s: Likewise.
	* testsuite/ld-x86-64/pr22782a.d: Likewise.
	* testsuite/ld-x86-64/pr22782b.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr22782a and pr22782b.
2018-02-05 08:38:16 -08:00
Alan Hayward b8df6ca79e Use visitors for make_gdb_type
Remove the make_gdb_type functions from the tdesc_type_ classes.
Replace with a static make_gdb_type function that uses a element
visitor called gdb_type_creator.

gdb/
	* target-descriptions.c (tdesc_element_visitor) Add empty implementations.
	(tdesc_type): Move make_gdb_type from here.
	(tdesc_type_builtin): Likewise.
	(tdesc_type_vector): Likewise.
	(tdesc_type_with_fields): Move make_gdb_type_ functions from here.
	(make_gdb_type_struct): Move from tdesc_type_with_fields.
	(make_gdb_type_union): Likewise.
	(make_gdb_type_flags): Likewise.
	(make_gdb_type_enum): Likewise.
	(make_gdb_type): New function.
	(tdesc_register_type): Use static make_gdb_type.
2018-02-05 16:34:13 +00:00
Maciej W. Rozycki 89424b1d69 RISC-V/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC
Correct a commit f0531ed6a4 ("Compress loads/stores with implicit 0
offset.") regression and remove a `-Wshadow' compilation error:

cc1: warnings being treated as errors
.../gas/config/tc-riscv.c: In function 'riscv_handle_implicit_zero_offset':
.../gas/config/tc-riscv.c:1194: error: declaration of 'expr' shadows a global declaration
.../gas/expr.h:180: error: shadowed declaration is here
make[4]: *** [tc-riscv.o] Error 1

which for versions of GCC before 4.8 prevents GAS for RISC-V targets
from being built.  See also GCC PR c/53066.

	gas/
	* config/tc-riscv.c (riscv_handle_implicit_zero_offset): Rename
	`expr' parameter to `ep'.
2018-02-05 14:06:46 +00:00
Maciej W. Rozycki e65b1a7868 RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC
Correct a commit 9d06997adb ("RISC-V: Relax RISCV_PCREL_* to
RISCV_GPREL_*") regression and remove a `-Wmissing-field-initializers'
compilation error:

cc1: warnings being treated as errors
.../bfd/elfnn-riscv.c: In function '_bfd_riscv_relax_pc':
.../bfd/elfnn-riscv.c:3117: error: missing initializer
.../bfd/elfnn-riscv.c:3117: error: (near initialization for 'hi_reloc.hi_addend')
make[4]: *** [elf64-riscv.lo] Error 1

which for versions of GCC before 4.7 prevents support for RISC-V targets
from being built.  See also GCC PR c/36750.

	bfd/
	* elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to
	initialize `hi_reloc'.
2018-02-05 14:06:46 +00:00