Commit Graph

88571 Commits

Author SHA1 Message Date
Pedro Alves 85ad3aaf40 gdb: Coalesce/aggregate (async) vCont packets/actions
Currently, with "maint set target-non-stop on", that is, when gdb
connects with the non-stop/asynchronous variant of the remote
protocol, even with "set non-stop off", GDB always sends one vCont
packet per thread resumed.  This patch makes GDB aggregate and
coalesce vCont packets, so we send vCont packets like "vCont;s:p1.1;c"
in non-stop mode too.

Basically, this is done by:

  - Adding a new target method target_commit_resume that is called
    after calling target_resume one or more times.  When resuming a
    batch of threads, we'll only call target_commit_resume once after
    calling target_resume for all threads.

  - Making the remote target defer sending the actual vCont packet to
    target_commit_resume.

Special care must be taken to avoid sending a vCont action with a
"wildcard" thread-id (all threads of process / all threads) when that
would resume threads/processes that should not be resumed.  See
remote_commit_resume comments for details.

Unlike all-stop's remote_resume implementation, this handles the case
of too many actions resulting in a too-big vCont packet, by flushing
the vCont packet and starting a new one.

E.g., imagining that the "c" action in:

  vCont;s:1;c

overflows the packet buffer, we split the actions like:

  vCont;s:1
  vCont;c

Tested on x86_64 Fedora 20, with and without "maint set
target-non-stop on".

Also tested with a hack that makes remote_commit_resume flush the vCont
packet after every action appended (which caught a few bugs).

gdb/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* inferior.h (ALL_NON_EXITED_INFERIORS): New macro.
	* infrun.c (do_target_resume): Call target_commit_resume.
	(proceed): Defer target_commit_resume while looping over threads,
	resuming them.  Call target_commit_resume at the end.
	* record-btrace.c (record_btrace_commit_resume): New function.
	(init_record_btrace_ops): Install it as to_commit_resume method.
	* record-full.c (record_full_commit_resume): New function.
	(record_full_wait_1): Call the beneath target's to_commit_resume
	method.
	(init_record_full_ops): Install record_full_commit_resume as
	to_commit_resume method.
	* remote.c (struct private_thread_info) <last_resume_step,
	last_resume_sig, vcont_resumed>: New fields.
	(remote_add_thread): Set the new thread's vcont_resumed flag.
	(demand_private_info): Delete.
	(get_private_info_thread, get_private_info_ptid): New functions.
	(remote_update_thread_list): Adjust.
	(process_initial_stop_replies): Clear the thread's vcont_resumed
	flag.
	(remote_resume): If connected in non-stop mode, record the resume
	request and return early.
	(struct private_inferior): New.
	(struct vcont_builder): New.
	(vcont_builder_restart, vcont_builder_flush)
	(vcont_builder_push_action): New functions.
	(MAX_ACTION_SIZE): New macro.
	(remote_commit_resume): New function.
	(thread_pending_fork_status, is_pending_fork_parent_thread): New
	functions.
	(check_pending_event_prevents_wildcard_vcont_callback)
	(check_pending_events_prevent_wildcard_vcont): New functions.
	(process_stop_reply): Adjust.  Clear the thread's vcont_resumed
	flag.
	(init_remote_ops): Install remote_commit_resume.
	* target-delegates.c: Regenerate.
	* target.c (defer_target_commit_resume): New global.
	(target_commit_resume, make_cleanup_defer_target_commit_resume):
	New functions.
	* target.h (struct target_ops) <to_commit_resume>: New field.
	(target_resume): Update comments.
	(target_commit_resume): New declaration.
2016-10-26 16:22:50 +01:00
Pedro Alves 5a04c4cf5d gdbserver: Leave already-vCont-resumed threads as they were
Currently GDB never sends more than one action per vCont packet, when
connected in non-stop mode.  A follow up patch will change that, and
it exposed a gdbserver problem with the vCont handling.

For example, this in non-stop mode:

  => vCont;s:p1.1;c
  <= OK

Should be equivalent to:

  => vCont;s:p1.1
  <= OK
  => vCont;c
  <= OK

But gdbserver currently doesn't handle this.  In the latter case,
"vCont;c" makes gdbserver clobber the previous step request.  This
patch fixes that.

Note the server side must ignore resume actions for the thread that
has a pending %Stopped notification (and any other threads with events
pending), until GDB acks the notification with vStopped.  Otherwise,
e.g., the following case is mishandled:

 #1 => g  (or any other packet)
 #2 <= [registers]
 #3 <= %Stopped T05 thread:p1.2
 #4 => vCont s:p1.1;c
 #5 <= OK

Above, the server must not resume thread p1.2 when it processes the
vCont.  GDB can't know that p1.2 stopped until it acks the %Stopped
notification.  (Otherwise it wouldn't send a default "c" action.)

(The vCont documentation already specifies this.)

Finally, special care must also be given to handling fork/vfork
events.  A (v)fork event actually tells us that two processes stopped
-- the parent and the child.  Until we follow the fork, we must not
resume the child.  Therefore, if we have a pending fork follow, we
must not send a global wildcard resume action (vCont;c).  We can still
send process-wide wildcards though.

(The comments above will be added as code comments to gdb in a follow
up patch.)

gdb/gdbserver/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* linux-low.c (handle_extended_wait): Link parent/child fork
	threads.
	(linux_wait_1): Unlink them.
	(linux_set_resume_request): Ignore resume requests for
	already-resumed and unhandled fork child threads.
	* linux-low.h (struct lwp_info) <fork_relative>: New field.
	* server.c (in_queued_stop_replies_ptid, in_queued_stop_replies):
	New functions.
	(handle_v_requests) <vCont>: Don't call require_running.
	* server.h (in_queued_stop_replies): New declaration.
2016-10-26 16:22:27 +01:00
Pedro Alves ca6eff5908 gdb/doc: Clarify vCont packet description
Specifically, what happens with multiple actions that could match a
thread, and what happens when we get a vCont action that matches a
thread that was already running.  E.g., what does:

 "vCont;s:2"
 "vCont;s:1;c"

mean for thread 2.

(Thread 2 continues stepping.)

gdb/doc/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Packets): Clarify vCont packets with multiple
	actions that match a thread, and what happens when an action
	matches a thread that is already running.
2016-10-26 16:22:05 +01:00
Pedro Alves ef4a339527 gdb: Free inferior->priv when inferior exits
(Where "exits" includes being killed or detached.)

Nothing is clearing inferior->priv currently.  This is a problem if we
change the inferior's process_stratum targets in a single debug
session.  This field is currently only used by darwin-nat.c, but a
follow up patch will make remote.c use it too.  Without the fix,
remote.c might end up mistaking the priv object allocated by
darwin-nat.c with its own.

(Found by inspection.)

gdb/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* inferior.c (exit_inferior_1): Free 'priv'.
2016-10-26 16:21:40 +01:00
Pedro Alves 7b68ffbb32 gdb: Clean up remote.c:remote_resume
Just some refactoring / TLC.  Mainly split the old c/s/C/S packet
handling to a separate function.

gdb/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_resume_with_hc): New function, factored out
	from ...
	(remote_resume): ... this.  Always try vCont first.
	(remote_vcont_resume): Rename to ...
	(remote_resume_with_vcont): ... this.  Bail out if execution
	direction is reverse.
2016-10-26 16:15:28 +01:00
Alan Modra 2a3a749076 Revert "bison warning fixes"
This reverts commit 95e61695c1.  People
still want to use older versions of bison, apparently.

	Revert 2016-10-06  Alan Modra  <amodra@gmail.com>
	* config/rl78-parse.y: Do use old %name-prefix syntax.
	* config/rx-parse.y: Likewise.
2016-10-26 11:45:50 +10:30
GDB Administrator 21280c0ae3 Automatic date update in version.in 2016-10-26 00:00:19 +00:00
Pedro Alves beb18c865c Make dwarf_expr_context's destructor virtual
Ref: https://sourceware.org/ml/gdb-patches/2016-10/msg00662.html

 $ make WERROR_CFLAGS="-Wnon-virtual-dtor" dwarf2expr.o
 ...
 In file included from .../src/gdb/dwarf2expr.c:28:0:
 .../src/gdb/dwarf2expr.h:68:8: warning: ‘struct dwarf_expr_context’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
  struct dwarf_expr_context
	 ^~~~~~~~~~~~~~~~~~

Happens to not be a problem in practice currently because concrete
subclasses are allocated on the stack.  I.e., we don't ever delete
objects of types that derive from dwarf_expr_context through pointers
to dwarf_expr_context.

gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

	* dwarf2expr.h (struct dwarf_expr_context) <~dwarf_expr_context>:
	Make virtual.
2016-10-25 14:32:35 +01:00
Rainer Orth b196bc4cb4 Fix gdb C++ compilation on Solaris (PR build/20712)
gdb 7.12 doesn't compile as C++ (tried with g++ 4.9) on Solaris (tried
10 and 12, sparc and x86).  The following patch (relative to the 7.12
release, though I expect most if not all issues to be present on trunk,
too) fixes this.

Only a few of the changes bear explanation:

* Initially, compilation failed whereever defs.h. was included:

In file included from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:0:
/vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:630:33: error: 'double atof(const char*)' conflicts with a previous declaration
 extern double atof (const char *); /* X3.159-1989  4.10.1.1 */
                                 ^
In file included from /usr/include/stdlib.h:17:0,
                 from build-gnulib/import/stdlib.h:36,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/common/common-defs.h:32,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/defs.h:28,
                 from /vol/src/gnu/gdb/gdb-7.12/gdb/gdb.c:19:
/vol/gcc-4.9/lib/gcc/i386-pc-solaris2.10/4.9.0/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
 extern double atof(const char *);
               ^

  This is due to this gem in gdb/defs.h which seems to have been present
  like forever:

#ifndef atof
extern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
#endif

  In the Solaris headers, the appropriate functions are in namespace std,
  thus the conflict.  I've wrapped the defs.h declaration in !__cplusplus
  to avoid this; perhaps it can go completely instead.

* All the casts are necessary to appease g++ and should be pretty
  obvious.

* The sol-thread.c changes are here to handle

/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c: In function 'void _initialize_sol_thread()':
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1252:36: error: invalid conversion from 'void*' to 'void (*)(int)' [-fpermissive]
   if (!(p_##X = dlsym (dlhandle, #X))) \
                                    ^
/vol/src/gnu/gdb/gdb-7.12/gdb/sol-thread.c:1255:3: note: in expansion of macro 'resolve'
   resolve (td_log);
   ^

  and are modeled after linux-thread-db.c (try_thread_db_load_1).

The patch allowed both 32 and 64-bit C++ builds on sparc-sun-solaris2.10
and i386-pc-solaris2.10 to complete.  The resulting binary hasn't seen
more than a smoke test (invoke it on itself, b main, run) yet.

When investigating the failure to detect -static-libstdc++
support (more below), I found two more issues which only show up with
-Werror:

/vol/src/gnu/gdb/gdb/local/gdb/procfs.c: In function 'ssd* proc_get_LDT_entry(procinfo*, int)':
/vol/src/gnu/gdb/gdb/local/gdb/procfs.c:2487:19: error: variable 'old_chain' set but not used [-Werror=unused-but-set-variable]
   struct cleanup *old_chain = NULL;
                   ^

Unless I'm mistaken, you need to run do_cleanups on every return from
the function.

Afterwards, I ran a 32-bit compilation, which (after adding
--disable-largefile to avoid

In file included from /usr/include/sys/procfs.h:28:0,
                 from /vol/src/gnu/gdb/gdb/local/gdb/i386-sol2-nat.c:23:
/usr/include/sys/old_procfs.h:39:2: error: #error "Cannot use procfs in the large file compilation environment"
 #error "Cannot use procfs in the large file compilation environment"
  ^

and two more instances) revealed

/vol/src/gnu/gdb/gdb/local/gdb/top.c: In function 'void gdb_safe_append_history()':
/vol/src/gnu/gdb/gdb/local/gdb/top.c:1170:59: error: format '%d' expects argument of type 'int', but argument 3 has type 'pid_t {aka long int}' [-Werror=format=]
     = xstrprintf ("%s-gdb%d~", history_filename, getpid ());
                                                           ^

Fixed by casting pid_t to long and printing it as such.
2016-10-25 15:19:46 +02:00
Pedro Alves b30f354acb common/common-defs.h: Define __STDC_FORMAT_MACROS as well
Ref: https://sourceware.org/ml/gdb-patches/2016-10/msg00694.html

gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

	* common/common-defs.h (__STDC_FORMAT_MACROS): Define.
2016-10-25 13:50:20 +01:00
Pedro Alves e4426cb42f new-op.c: Add comment about -fsanitize=address
gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

	* common/new-op.c: Add comment about -fsanitize=address.
2016-10-25 13:32:26 +01:00
Pedro Alves 28fe4f87e0 Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again.
Revert commit f6abaf7a40 (gdb: no longer define
__STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS), with the tweak suggested
in that commit's log: the macros are now defined before any system
header is included.

This should fix AIX:
  https://sourceware.org/ml/gdb-patches/2016-10/msg00682.html

gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

       * common/common-defs.h (__STDC_CONSTANT_MACROS)
       (__STDC_LIMIT_MACROS): Define.
2016-10-25 11:47:18 +01:00
Yao Qi 3ef9d661f4 Don't override operator new if GDB is built with -fsanitize=address
Nowadays, if we build GDB with -fsanitize=address, we can get the asan
error below,

(gdb) quit
=================================================================
==9723==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x60200003bf70
    #0 0x7f88f3837527 in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x55527)
    #1 0xac8e13 in __gnu_cxx::new_allocator<void (*)()>::deallocate(void (**)(), unsigned long) /usr/include/c++/4.9/ext/new_allocator.h:110
    #2 0xac8cc2 in __gnu_cxx::__alloc_traits<std::allocator<void (*)()> >::deallocate(std::allocator<void (*)()>&, void (**)(), unsigned long) /usr/include/c++/4.9/ext/alloc_traits.h:185
....
0x60200003bf70 is located 0 bytes inside of 8-byte region [0x60200003bf70,0x60200003bf78)
allocated by thread T0 here:
    #0 0x7f88f38367ef in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x547ef)
    #1 0xbd2762 in operator new(unsigned long) /home/yao/SourceCode/gnu/gdb/git/gdb/common/new-op.c:42
    #2 0xac8edc in __gnu_cxx::new_allocator<void (*)()>::allocate(unsigned long, void const*) /usr/include/c++/4.9/ext/new_allocator.h:104
    #3 0xac8d81 in __gnu_cxx::__alloc_traits<std::allocator<void (*)()> >::allocate(std::allocator<void (*)()>&, unsigned long) /usr/include/c++/4.9/ext/alloc_traits.h:182

The reason for this is that we override operator new but don't override
operator delete.  This patch does the override if the code is NOT
compiled with asan.

gdb:

2016-10-25  Yao Qi  <yao.qi@linaro.org>

	PR gdb/20716
	* common/new-op.c (__has_feature): New macro.
	Don't override operator new if asan is used.
2016-10-25 11:13:00 +01:00
Maciej W. Rozycki a18a2a347d elfxx-mips: Correct STUB_JALR's description
bfd/
	* elfxx-mips.c (STUB_JALR): Correct description.
2016-10-25 02:08:26 +01:00
GDB Administrator 73b088be72 Automatic date update in version.in 2016-10-25 00:00:22 +00:00
Luis Machado b5e1db8789 Fix potential NULL pointer dereference
This patch addresses a potential NULL pointer dereference when we try to
duplicate a string. The input pointer can be NULL and that may lead to
crashes. We simply add a check for that case.

gdb/ChangeLog:
2016-10-24  Luis Machado  <lgustavo@codesourcery.com>

	* exec.c (exec_file_locate_attach): Prevent NULL pointer dereference
	when duplicating a string.
2016-10-24 17:51:33 -05:00
Luis Machado 010ece9c47 Fix obvious gotcha in string comparison
This patch fixes a gotcha when comparing exception's messages in
exception_print_same. It should've used the statically-allocated
string versions msg1 and msg2 instead.

As is, it could lead to crashes.

gdb/ChangeLog:
2016-10-24  Luis Machado  <lgustavo@codesourcery.com>

	* exec.c (exception_print_same): Fix string comparison to use
	statically-allocated ones.
2016-10-24 17:44:56 -05:00
Jan Kratochvil b8d38ee425 testsuite: Fix false FAIL for gdb.base/morestack.exp
Since
	[commit] [testsuite patch] Fix gcc_compiled for gcc 6 & 7
	https://sourceware.org/ml/gdb-patches/2016-10/msg00620.html

there has started running again
	 Running gdb/testsuite/gdb.base/morestack.exp ...
	+FAIL: gdb.base/morestack.exp: continue
	+PASS: gdb.base/morestack.exp: up 3000

but as you can see it FAILs now - on Fedora 24 x86_64 (although for example it
still PASSes on CentOS-7.2 x86_64).

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff787c7bb in malloc_consolidate (av=av@entry=0x7ffff7bbcb00 <main_arena>) at malloc.c:4181
4181		      unlink(av, nextchunk, bck, fwd);
(gdb) bt
[...]
[...]

This apparently is due to - man gcc - -fsplit-stack:
	When code compiled with -fsplit-stack calls code compiled without
	-fsplit-stack, there may not be much stack space available for the
	latter code to run.  If compiling all code, including library code,
	with -fsplit-stack is not an option, then the linker can fix up these
	calls so that the code compiled without -fsplit-stack always has
	a large stack.  Support for this is implemented in the gold linker in
	GNU binutils release 2.21 and later.

gdb/testsuite/ChangeLog
2016-10-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/morestack.exp: Try to build it using -fuse-ld=gold first.
2016-10-24 14:13:51 +02:00
Yao Qi cb93dc7f26 [GDBserver] Fix conversion warning
I got the following warning if I build GDBserver for aarch64_be-linux-gnu,

git/gdb/gdbserver/linux-aarch64-low.c:1539:39: error: invalid conversion from 'void*' to 'uint32_t* {aka unsigned int*}' [-fpermissive]
   uint32_t *le_buf = xmalloc (byte_len);
                                       ^
The patch is to fix the warning.

gdb/gdbserver:

2016-10-24  Yao Qi  <yao.qi@linaro.org>

	PR server/20733
	* linux-aarch64-low.c (append_insns): Cast the return value to
	'uint32_t *'.
2016-10-24 11:07:24 +01:00
GDB Administrator 638101973d Automatic date update in version.in 2016-10-24 00:00:21 +00:00
GDB Administrator 243050da09 Automatic date update in version.in 2016-10-23 00:00:19 +00:00
GDB Administrator dcf293fda8 Automatic date update in version.in 2016-10-22 00:00:19 +00:00
Tom Tromey befbff861e Make some dwarf_expr_context methods pure virtual
This patch changes some dwarf_expr_context to be pure virtual, as
mentioned during the discussion of an earlier patch in this series.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* dwarf2expr.h (class dwarf_expr_context)
	<get_frame_base, get_frame_cfa, get_tls_address, dwarf_call,
	push_dwarf_block_entry_value, get_addr_index, get_object_address>:
	Now pure virtual.
	* dwarf2-frame.c (class dwarf_expr_executor)
	<get_frame_base, get_frame_cfa, get_tls_address, dwarf_call,
	push_dwarf_block_entry_value, get_addr_index, get_object_address>:
	New methods.
	<invalid>: New method.
2016-10-21 14:17:40 -06:00
Tom Tromey ce6c454e5a Change minimal_symbol_reader::record_full to take a bool
This changes an "int" to a "bool" in the signature for
minimal_symbol_reader::record_full, and then fixes the callers.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* minsyms.h (minimal_symbol_reader::record_full): "copy_name" now
	a bool.
	(record, record_with_info): Update.
	* minsyms.c (record): Fix indentation.
	(record_full): Fix indentation.  Update for type change.
	* elfread.c (record_minimal_symbol): "copy_name" now a bool.
	(elf_symtab_read): "copy_names" now a bool.
	(elf_rel_plt_read, elf_read_minimal_symbols): Update.
2016-10-21 14:17:39 -06:00
Tom Tromey f60ee22ea1 Remove last cleanup from captured_main_1
An earlier patch split captured_main into two parts.  This patch
removes the last remaining cleanup from captured_main_1, and also
replaces a second hand-rolled VEC-like array with a std::vector.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* main.c: Include <vector>.
	(cmdarg_s): Remove typedef.  Don't define VEC.
	(captured_main_1): Use vector, not VEC.  Remove cleanups.
2016-10-21 14:17:39 -06:00
Tom Tromey 192ca6d8ea Convert dwarf_expr_context_funcs to methods
This patch converts the function pointers in dwarf_expr_context_funcs
into methods on dwarf_expr_context, and then updates the various
implementations and callers to follow.

NB this patch uses "override" (which caught a couple of renaming bugs
during development) -- but this is C++11, so this patch at least has
to wait for Pedro's patch that adds the OVERRIDE macro.

After this patch it would be possible to do one more, that makes
various members of dwarf_expr_context "protected"; but I haven't done
this.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* dwarf2loc.c (struct dwarf_expr_context_funcs): Don't declare.
	(dwarf_expr_read_addr_from_reg, dwarf_expr_get_reg_value)
	(dwarf_expr_read_mem, dwarf_expr_frame_base): Rename; turn into
	methods.
	(get_frame_pc_for_per_cu_dwarf_call): New function.
	(dwarf_expr_frame_cfa, dwarf_expr_frame_pc)
	(dwarf_expr_tls_address): Rename; turn into methods.
	(per_cu_dwarf_call): Remove arguments.  Use
	get_frame_pc_for_per_cu_dwarf_call.
	(dwarf_evaluate_loc_desc): New class.
	(dwarf_expr_dwarf_call, dwarf_expr_context)
	(dwarf_expr_push_dwarf_reg_entry_value)
	(dwarf_expr_get_addr_index, dwarf_expr_get_obj_addr): Rename; turn
	into methods.
	(dwarf_expr_ctx_funcs): Remove.
	(dwarf2_evaluate_loc_desc_full): Update.
	(dwarf2_locexpr_baton_eval): Update.
	(symbol_needs_eval_context): New class.
	(symbol_needs_read_addr_from_reg, symbol_needs_get_reg_value)
	(symbol_needs_read_mem, symbol_needs_frame_base)
	(symbol_needs_frame_cfa, symbol_needs_tls_address)
	(symbol_needs_dwarf_call, needs_dwarf_reg_entry_value): Rename;
	turn into methods.
	(needs_get_addr_index, needs_get_obj_addr): Remove; turn into
	methods.
	(symbol_needs_ctx_funcs): Remove.
	(dwarf2_loc_desc_get_symbol_read_needs): Update.
	* dwarf2expr.h (struct dwarf_expr_context_funcs): Remove; turn
	contents into methods.
	(struct dwarf_expr_context) <baton, funcs>: Remove.
	<read_addr_from_reg, get_reg_value, read_mem, get_frame_base,
	get_frame_cfa, get_frame_pc, get_tls_address, dwarf_call,
	impl_get_base_type, push_dwarf_block_entry_value, get_addr_index,
	get_object_address>: Declare new methods.
	(ctx_no_get_frame_base, ctx_no_get_frame_cfa)
	(ctx_no_get_frame_pc, ctx_no_get_tls_address, ctx_no_dwarf_call)
	(ctx_no_get_base_type, ctx_no_push_dwarf_reg_entry_value)
	(ctx_no_get_addr_index): Don't declare.
	* dwarf2expr.c (get_base_type): Use impl_get_base_type.
	(execute_stack_op): Update.
	(ctx_no_get_frame_base, ctx_no_get_frame_cfa)
	(ctx_no_get_frame_pc, ctx_no_get_tls_address, ctx_no_dwarf_call)
	(ctx_no_get_base_type, ctx_no_push_dwarf_reg_entry_value)
	(ctx_no_get_addr_index): Remove; now methods on
	dwarf_expr_context.
	* dwarf2-frame.c (read_addr_from_reg): Take a frame_info, not a
	baton.
	(class dwarf_expr_executor): New class.
	(get_reg_value, read_mem): Rename, turn into methods.
	(execute_stack_op): Use dwarf_expr_executor.
2016-10-21 14:17:38 -06:00
Tom Tromey 595d2e303c Convert DWARF expr functions to methods
This converts various DWARF expr functions to be members on
dwarf_expr_context, then fixes up the various users.  This results in
somewhat less wordy code and sets the stage for the next patch.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* dwarf2loc.c (per_cu_dwarf_call)
	(dwarf_expr_push_dwarf_reg_entry_value)
	(dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval)
	(needs_dwarf_reg_entry_value)
	(dwarf2_loc_desc_get_symbol_read_needs): Update.
	* dwarf2expr.h (dwarf_expr_context) <push_address, eval, fetch,
	fetch_address, fetch_in_stack_memory, address_type, grow_stack,
	push, stack_empty_p, add_piece, get_base_type, execute_stack_op,
	pop>: New method declarations.
	(dwarf_expr_push_address, dwarf_expr_eval, dwarf_expr_fetch)
	(dwarf_expr_fetch_address, dwarf_expr_fetch_in_stack_memory):
	Don't declare.
	* dwarf2expr.c (address_type, grow_stack, push, push_address)
	(pop, fetch, fetch_address, fetch_in_stack_memory)
	(stack_empty_p, add_piece, eval, get_base_type)
	(execute_stack_op): Rename.  Turn into methods.
	* dwarf2-frame.c (execute_stack_op): Update.
2016-10-21 14:17:38 -06:00
Tom Tromey 718b962660 Initial conversion of dwarf_expr_ctx
This is the first step in the conversion of dwarf_expr_ctx to a C++
class.  This conversion is done in steps to make the patches, and the
reviews, a bit simpler.  This patch changes dwarf_expr_ctx to be
stack-allocated and removes the associated cleanup.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Stack-allocate
	dwarf_expr_context.  Remove cleanups.
	(dwarf2_locexpr_baton_eval)
	(dwarf2_loc_desc_get_symbol_read_needs):  Likewise.
	* dwarf2expr.h (dwarf_expr_context, ~dwarf_expr_context): Add
	constructors and destructors.
	(new_dwarf_expr_context, free_dwarf_expr_context)
	(make_cleanup_free_dwarf_expr_context): Don't declare.
	* dwarf2-frame.c (execute_stack_op): Stack-allocate
	dwarf_expr_context.  Remove cleanups.
	(dwarf_expr_context): Rename from new_dwarf_expr_context.  Turn
	into constructor.
	(free_dwarf_expr_context, free_dwarf_expr_context_cleanup):
	Remove.
	(~dwarf_expr_context): Rename from
	make_cleanup_free_dwarf_expr_context.  Turn into destructor.
2016-10-21 14:17:37 -06:00
Tom Tromey 5841433461 Some cleanup removal in dwarf2loc.c
This removes some cleanups and manual allocation handling in
dwarf2loc.c with std::vector.  Note that this patch has a case where
the vector would normally fall into the "use gdb::unique_ptr"
guidelines -- but here because the vector is immediately initialized,
I moved the initialization into the constructor call, for further
code savings.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* dwarf2loc.c: Include <vector>.
	(read_pieced_value, write_pieced_value)
	(dwarf2_compile_expr_to_ax): Use std::vector.
2016-10-21 14:17:37 -06:00
Tom Tromey 67ad9399e2 Remove make_cleanup_restore_current_uiout
This removes make_cleanup_restore_current_uiout in favor of an
RAII-based class.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* stack.c (print_stack_frame_to_uiout): Use scoped_restore.
	* ui-out.c (make_cleanup_restore_current_uiout)
	(restore_current_uiout_cleanup): Remove.
	* infrun.c (print_stop_event): Use scoped_restore.
	* ui-out.h (make_cleanup_restore_current_uiout): Don't declare.
2016-10-21 14:17:36 -06:00
Tom Tromey d1e4a62469 Use gdb::unique_ptr in elf_read_minimal_symbols
This changes elf_read_minimal_symbols to use gdb::unique_ptr rather
than an explicit allocation.  This removes a cleanup.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
2016-10-21 14:17:36 -06:00
Tom Tromey cd9da5b077 Replace two xmallocs with unique_ptr
This replaces a couple of uses of xmalloc with gdb::unique_ptr, also
removing a couple of cleanups.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* cli/cli-dump.c (dump_memory_to_file): Use gdb::unique_ptr.
	(restore_binary_file): Likewise.
2016-10-21 14:17:35 -06:00
Tom Tromey 1e3b796d58 Change command stats reporting to use class
This removes make_command_stats_cleanup in favor of an RAII class.
The patch is reasonably straightforward, but keeping the same
semantics without excessive reindentation required splitting
captured_main in two.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* maint.h (scoped_command_stats): New class.
	(make_command_stats_cleanup): Don't declare.
	* maint.c (struct cmd_stats): Remove.
	(~scoped_command_stats): Rename from report_command_stats.  Now a
	destructor.
	(scoped_command_stats): Rename from make_command_stats_cleanup.
	Now a constructor.
	* main.c (captured_main_1): New function.  Use
	scoped_command_stats.
	(captured_main): Call captured_main_1.
	* event-top.c (command_handler): Use scoped_command_stats.
2016-10-21 14:17:35 -06:00
Tom Tromey 6fc31fc73b Remove some cleanups in MI
This patch removes a couple of cleanups from MI by using
gdb::unique_ptr.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (mi_cmd_data_read_memory): Use gdb::unique_ptr.
	Remove some cleanups.
2016-10-21 14:17:34 -06:00
Tom Tromey 0e454242cc Remove make_cleanup_restore_current_ui
This removes make_cleanup_restore_current_ui by converting the last
use.  The last use was in a few functions used to iterate over all
UIs.  This patch replaces these functions with a class, and arranges
for the class destructor to do the needed cleanup.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* tui/tui-interp.c (tui_on_normal_stop, tui_on_signal_received)
	(tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
	(tui_on_no_history, tui_on_user_selected_context_changed):
	Update.
	* top.h (switch_thru_all_uis): New class.
	(SWITCH_THRU_ALL_UIS): Rewrite.
	(make_cleanup_restore_current_ui, switch_thru_all_uis_init)
	(switch_thru_all_uis_cond, switch_thru_all_uis_next): Don't
	declare.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
	(mi_inferior_exit, mi_inferior_removed, mi_on_signal_received)
	(mi_on_end_stepping_range, mi_on_signal_exited, mi_on_exited)
	(mi_on_no_history, mi_on_normal_stop, mi_traceframe_changed)
	(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
	(mi_breakpoint_created, mi_breakpoint_deleted)
	(mi_breakpoint_modified, mi_output_running_pid, mi_on_resume)
	(mi_solib_loaded, mi_solib_unloaded, mi_command_param_changed)
	(mi_memory_changed, mi_user_selected_context_changed): Update.
	* infrun.c (all_uis_check_sync_execution_done)
	(all_uis_on_sync_execution_starting, normal_stop): Update.
	* event-top.c (restore_ui_cleanup)
	(make_cleanup_restore_current_ui, switch_thru_all_uis_init)
	(switch_thru_all_uis_cond, switch_thru_all_uis_next): Remove.
	* cli/cli-interp.c (cli_on_normal_stop, cli_on_signal_received)
	(cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
	(cli_on_no_history, cli_on_user_selected_context_changed):
	Update.
	* breakpoint.c (watchpoint_check): Update.
2016-10-21 14:17:34 -06:00
Tom Tromey 8dddcb8f00 Record minimal symbols directly in reader.
This patch changes minimal symbol creation in two ways.  First, it
removes global variables in favor of members of minimal_symbol_reader.
Second, it changes functions like prim_record_minimal_symbol to be
member functions of minimal_symbol_reader.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add
	"reader" argument.  Update.
	(xcoff_initial_scan): Update.
	* symfile.h (mdebug_build_psymtabs): Add "reader" argument.
	* mipsread.c (mipscoff_symfile_read): Update.
	(read_alphacoff_dynamic_symtab): Add "reader" argument.  Update.
	* minsyms.h (minimal_symbol_reader) <record, record_full>:
	Declare.
	<m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members.
	<record_with_info>: New function, renamed from
	prim_record_minimal_symbol_and_info.
	* minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove
	globals.
	(minimal_symbol_reader): Initialize new members.
	(minimal_symbol_reader::record): Renamed from
	prim_record_minimal_symbol.
	(minimal_symbol_reader::record_full): Renamed from
	prim_record_minimal_symbol_full.
	(prim_record_minimal_symbol_and_info): Move to minsyms.h; rename.
	* mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols)
	(record_minimal_symbol): Add "reader" argument.  Update.
	(elfmdebug_build_psymtabs): Update.
	* machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add
	"reader" argument.  Update.
	(macho_symfile_read): Update.
	* elfread.c (record_minimal_symbol, elf_symtab_read)
	(elf_rel_plt_read): Add "reader" argument.  Update.
	(elf_read_minimal_symbols): Update.
	* dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab)
	(read_dbx_symtab): Add "reader" argument.  Update.
	(dbx_symfile_read): Update.
	* coffread.c (record_minimal_symbol, coff_symtab_read): Add
	"reader" argument.  Update.
	(coff_symfile_read): Update.
	* coff-pe-read.h (read_pe_exported_syms): Add "reader" argument.
	* coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym)
	(read_pe_exported_syms): Add "reader" argument.  Update.
2016-10-21 14:17:33 -06:00
Tom Tromey d25e871993 Change minimal_symbol_reader to store objfile
This changes minimal_symbol_reader to require the objfile to be
passed to the constructor.  The class now records the objfile and
automatically uses it later in "install".

This is a minor cleanup that will come in useful in the next patch.
It is separate from the first patch to keep that one a bit simpler to
understand.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Update.
	* mipsread.c (mipscoff_symfile_read): Update.
	* minsyms.c (minimal_symbol_reader): Add obj argument.
	Initialize member.
	(install): Remove objfile argument.  Update.
	* mdebugread.c (elfmdebug_build_psymtabs): Update.
	* machoread.c (macho_symfile_read): Update.
	* elfread.c (elf_read_minimal_symbols): Update.
	* dbxread.c (dbx_symfile_read): Update.
	* coffread.c (coff_symfile_read): Update.
	* minsyms.h (minimal_symbol_reader): Add m_objfile member.
	(constructor): Add objfile argument.
	(minimal_symbol_reader::install): Remove objfile argument.
2016-10-21 14:17:33 -06:00
Tom Tromey 873a915e0a Introduce minimal_symbol_reader
This patch introduced minimal_symbol_reader, a RAII-based class which
replaces the current make_cleanup_discard_minimal_symbols.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Use
	minimal_symbol_reader.
	* mipsread.c (mipscoff_symfile_read): Use
	minimal_symbol_reader.
	* minsyms.h (minimal_symbol_reader): New class.
	(init_minimal_symbol_collection)
	(make_cleanup_discard_minimal_symbols, install_minimal_symbols):
	Don't declare.
	* minsyms.c (minimal_symbol_reader): Renamed from
	init_minimal_symbol_collection, turned into constructor.
	(~minimal_symbol_reader): Renamed from
	do_discard_minimal_symbols_cleanup, turned into destructor.
	(make_cleanup_discard_minimal_symbols): Remove.
	(minimal_symbol_reader::install): Rename form
	install_minimal_symbols.
	* mdebugread.c (elfmdebug_build_psymtabs): Use
	minimal_symbol_reader.
	* machoread.c (macho_symfile_read): Use
	minimal_symbol_reader.
	* elfread.c (elf_read_minimal_symbols): Use
	minimal_symbol_reader.
	* dbxread.c (dbx_symfile_read): Use minimal_symbol_reader.
	* coffread.c (coff_symfile_read): Use
	minimal_symbol_reader.
2016-10-21 14:17:33 -06:00
Tom Tromey 4b6749b9a4 Use scoped_restore for current_ui
This changes most uses of make_cleanup_restore_current_ui to use
scoped_restore.  The use in switch_thru_all_uis_init still remains;
that is dealt with in a later patch by replacing this iterator with a
real class.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* top.c (new_ui_command, wait_sync_command_done)
	(gdb_readline_wrapper): Use scoped_restore.
	* infrun.c (fetch_inferior_event): Use scoped_restore.
	* infcall.c (call_thread_fsm_should_stop): Use scoped_restore.
2016-10-21 14:17:32 -06:00
Tom Tromey 9746809447 Use scoped_restore for ui_file
This replaces all the uses of make_cleanup_restore_ui_file with
scoped_restore.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* utils.c (make_cleanup_restore_ui_file, do_restore_ui_file)
	(struct restore_ui_file_closure): Remove.
	* utils.h (make_cleanup_restore_ui_file): Don't declare.
	* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
	scoped_restore.
	* top.c (execute_command_to_string): Use scoped_restore.
2016-10-21 14:17:32 -06:00
Tom Tromey b7b633e9b1 Use RAII to save and restore scalars
This patch replaces many (but not all) uses of
make_cleanup_restore_integer with a simple RAII-based template class.
It also removes the similar restore_execution_direction cleanup in
favor of this new class.  Subsequent patches will replace other
similar cleanups with this class.

The class is typically instantiated using make_scoped_restore.  This
allows for template argument deduction.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* common/scoped_restore.h: New file.
	* utils.h: Include scoped_restore.h.
	* top.c (execute_command_to_string): Use scoped_restore.
	* python/python.c (python_interactive_command): Use
	scoped_restore.
	(python_command, execute_gdb_command): Likewise.
	* printcmd.c (do_one_display): Use scoped_restore.
	* mi/mi-main.c (exec_continue): Use scoped_restore.
	* mi/mi-cmd-var.c (mi_cmd_var_assign): Use scoped_restore.
	* linux-fork.c (checkpoint_command): Use scoped_restore.
	* infrun.c (restore_execution_direction): Remove.
	(fetch_inferior_event): Use scoped_restore.
	* compile/compile.c (compile_file_command): Use
	scoped_restore.
	(compile_code_command, compile_print_command): Likewise.
	* cli/cli-script.c (execute_user_command): Use
	scoped_restore.
	(while_command, if_command, script_from_file): Likewise.
	* arm-tdep.c (arm_insert_single_step_breakpoint): Use
	scoped_restore.
2016-10-21 14:17:31 -06:00
Tom Tromey 9a1e3f0031 Fix build failure in xcoffread.c
This changes read_xcoff_symtab to be const-correct.  This fixes a
build failure.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Make "filestring" const.
2016-10-21 14:10:39 -06:00
H.J. Lu b5cefccad8 X86: Remove pcommit instruction
Remove x86 pcommit instruction support, which has been deprecated:

https://software.intel.com/en-us/blogs/2016/09/12/deprecate-pcommit-instruction

gas/

	* config/tc-i386.c (cpu_arch): Remove .pcommit.
	* doc/c-i386.texi: Likewise.
	* testsuite/gas/i386/i386.exp: Remove pcommit tests.
	* testsuite/gas/i386/pcommit-intel.d: Removed.
	* testsuite/gas/i386/pcommit.d: Likewise.
	* testsuite/gas/i386/pcommit.s: Likewise.
	* testsuite/gas/i386/x86-64-pcommit-intel.d: Likewise.
	* testsuite/gas/i386/x86-64-pcommit.d: Likewise.
	* testsuite/gas/i386/x86-64-pcommit.s: Likewise.

opcodes/

	* i386-dis.c (PREFIX_RM_0_0FAE_REG_7): Removed.
	(prefix_table): Remove the PREFIX_RM_0_0FAE_REG_7 entry.
	(rm_table): Update the RM_0FAE_REG_7 entry.
	* i386-gen.c (cpu_flag_init): Remove CPU_PCOMMIT_FLAGS.
	(cpu_flags): Remove CpuPCOMMIT.
	* i386-opc.h (CpuPCOMMIT): Removed.
	(i386_cpu_flags): Remove cpupcommit.
	* i386-opc.tbl: Remove pcommit.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2016-10-21 12:16:32 -07:00
Gergely Nagy ac423761af Fix PR 17704.
This fix keeps the section with the highest alignment when folding sections with ICF.

	PR gold/17704
	* icf.cc (match_sections): Add new parameter section_addraligns.
	Check section alignment and keep the section with the strictest
	alignment.
	(find_identical_sections): New local variable section_addraligns.
	Store each section's alignment.
	* testsuite/pr17704a_test.s: New file.
	* testsuite/Makefile.am (pr17704a_test): New test.
	* testsuite/Makefile.in: Regenerate.
2016-10-21 11:10:46 -07:00
Ulrich Weigand d11261fc63 Fix symbol table file name on AIX
When xlc -qfuncsect or gcc -ffunction-sections options is used in AIX,
each function csect is associated with each psymtab, so each psymtab
will have it's corresponding filename entries set.

If the pst filename isn't set then we will be seeing the below output
when we set a breakpoint.

(gdb) br main
Breakpoint 1 at 0x10000374: file  _start_ , line 18.

With the fix it will be.

(gdb) br main
Breakpoint 1 at 0x10000518: file test.c, line 24.

Attached patch resolve this issue and correct filename will be set.

gdb/
2016-10-21  Sangamesh Mallayya  <sangamesh.swamy@in.ibm.com>
	    Ulrich Weigand  <uweigand@de.ibm.com>

	* xcoffread.c (read_xcoff_symtab): Make name of current file as
	pst->filename instead of _start_ in AIX.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-10-21 17:47:15 +02:00
Philipp Rudo 4db41a0a10 Delete target_so_ops->special_symbol_handling hook
No one(!) actually implements this hook. So simply delete it.

gdb/ChangeLog:

	* solist.h (struct target_so_ops): Delete special_symbol_handling
	hook.
	* solib.c (solib_add, reload_shared_libraries): Adjust.
	* solib-aix.c (solib_aix_special_symbol_handling): Delete
	(_initialize_solib_aix): Adjust
	* solib-darwin.c (darwin_special_symbol_handling): Delete
	(_initialize_darwin_solib): Adjust
	* solib-dsbt.c (dsbt_special_symbol_handling): Delete
	(_initialize_dsbt_solib): Adjust
	* solib-frv.c (frv_special_symbol_handling): Delete
	(_initialize_frv_solib): Adjust
	* solib-svr4.c (svr4_special_symbol_handling): Delete
	(_initialize_svr4_solib): Adjust
	* solib-target.c (solib_target_special_symbol_handling): Delete
	(_initialize_solib_target): Adjust
2016-10-21 12:32:52 +02:00
GDB Administrator 16017f1915 Automatic date update in version.in 2016-10-21 00:00:20 +00:00
H.J. Lu 9889cbb14e Check invalid mask registers
In 32-bit, the REX_B bit in the 3-byte VEX prefix is ignored and the
the highest bit in VEX.vvvv is either 1 or ignored.  In 64-bit, we
need to check invalid mask registers.

gas/

	PR binutis/20705
	* testsuite/gas/i386/i386.exp: Run x86-64-opcode-bad.
	* testsuite/gas/i386/x86-64-opcode-bad.d: New file.
	* testsuite/gas/i386/x86-64-opcode-bad.s: Likewise.

opcodes/

	PR binutis/20705
	* i386-dis.c (get_valid_dis386): Ignore the REX_B bit and
	the highest bit in VEX.vvvv for the 3-byte VEX prefix in
	32-bit mode.  Don't check vex.register_specifier in 32-bit
	mode.
	(OP_E_register): Check invalid mask registers.
	(OP_G): Likewise.
	(OP_VEX): Likewise.
2016-10-20 15:26:23 -07:00
Jan Kratochvil f90fd8c2f1 testsuite: Fix gcc_compiled for gcc 6 & 7
gdb/testsuite/ChangeLog
2016-10-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* lib/gdb.exp (get_compiler_info): Generalize gcc_compile regexp.
2016-10-20 21:58:54 +02:00
Nick Clifton 789b4e0035 Regenerate bfd.pot. 2016-10-20 11:45:58 +01:00