Commit Graph

464 Commits

Author SHA1 Message Date
Simon Marchi e6a58aa8a7 Add xml_escape_text_append and use it
[This patch should go on top of "linux_qxfer_libraries_svr4: Use
 std::string", I should have sent them together as a series.]

I noticed that linux_qxfer_libraries_svr4 used xml_escape_text, which
returns an std::string.  That string is then copied into a larger
buffer.  It would be more efficient if we had a version of
xml_escape_text which appended to an existing string instead of
returning a new one.  This is what this patch does.

I manually verified that the output of linux_qxfer_libraries_svr4 didn't
change before/after the patch.

gdb/ChangeLog:

	* common/xml-utils.c (xml_escape_text): Move code to...
	(xml_escape_text_append): ... this new function.
	* common/xml-utils.h (xml_escape_text_append): New declaration.
	* unittests/xml-utils-selftests.c (test_xml_escape_text_append):
	New function.
	(_initialize_xml_utils): register test_xml_escape_text_append as
	a selftest.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_qxfer_libraries_svr4): Use
	xml_escape_text_append.
2018-03-08 18:04:46 -05:00
Simon Marchi f6e8a41e67 linux_qxfer_libraries_svr4: Use std::string
Use std::string, removing some manual memory management.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_qxfer_libraries_svr4): Use std::string.
2018-03-08 18:04:07 -05: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
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
James Clarke a0aad53764 gdb: Add missing #ifdef USE_THREAD_DB to gdbserver
Otherwise, linking fails with:

  [...]/linux-low.c:664: undefined reference to `thread_db_notice_clone(thread_info*, ptid_t)'

gdb/gdbserver/ChangeLog:

	* linux-low.c (handle_extended_wait): Surround call to
	thread_db_notice_clone with #ifdef USE_THREAD_DB.
2018-01-19 18:18:58 +00:00
Simon Marchi 4d9b86e175 Make linux_ptrace_attach_fail_reason return an std::string
This patch makes linux_ptrace_attach_fail_reason and
linux_ptrace_attach_fail_reason_string return std::string.  It also
replaces usages of struct buffer with std::string.  This allows getting
rid of a cleanup in in linux_ptrace_attach_fail_reason_string and
simplifies the code in general.

Something that looks odd to me is that in
linux_ptrace_attach_fail_reason, if the two messages are appended, there
is no separating space or \n, so the result won't be very nice.  I left
it as-is for now though.

gdb/ChangeLog:

	* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Return
	std::string.
	(linux_ptrace_attach_fail_reason_string): Likewise.
	* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason):
	Likewise.
	(linux_ptrace_attach_fail_reason_string): Likewise.
	* linux-nat.c (attach_proc_task_lwp_callback): Adjust.

gdb/gdbserver/ChangeLog:

	* linux-low.c (attach_proc_task_lwp_callback): Adjust to
	linux_ptrace_attach_fail_reason_string now returning an
	std::string.
	(linux_attach): Likewise.
	* thread-db.c (attach_thread): Likewise.
2018-01-17 12:34:50 -05:00
Yao Qi 9a70f35c8d Mark register unavailable when PTRACE_PEEKUSER fails
As described in PR 18749, GDB/GDBserver may get an error on accessing
memory or register because the thread may disappear.  However, some
path doesn't expect the error.  This patch fixes this problem by
marking the register unavailable when PTRACE_PEEKUSER fails instead
of throwing error.

gdb/gdbserver:

2018-01-16  Yao Qi  <yao.qi@linaro.org>

	PR gdb/18749
	* linux-low.c (fetch_register): Call supply_register instead of
	error.
2018-01-16 09:05:39 +00:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Simon Marchi f004534791 Remove for_each_inferior
This patch removes for_each_inferior, replacing all its usages with
for_each_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (for_each_inferior): Remove.
	(clear_inferiors): Use for_each_thread.
	* inferiors.h (for_each_inferior): Remove.
	* linux-low.c (linux_wait_for_event_filtered): Use
	for_each_thread.
	(linux_stabilize_threads): Likewise.
	* regcache.c (regcache_release): Likewise.
	* server.c (gdb_wants_all_threads_stopped): Likewise.
	(clear_pending_status_callback): Remove.
	(handle_status): Use for_each_thread.
	(captured_main): Likewise.
	* win32-low.c (child_init_thread_list): Likewise.
	(win32_clear_inferiors): Likewise.
	(fake_breakpoint_event): Likewise.
2017-12-02 20:37:53 -05:00
Simon Marchi 8f86d7aa85 Update comments
These functions were modified in the previous patch series, but I forgot
to update some comments.

gdb/gdbserver/ChangeLog:

	* linux-low.c (resume_status_pending_p): Update comment.
	(need_step_over_p): Update comment.
2017-12-02 20:36:44 -05:00
Simon Marchi e2b4407579 Remove usages of find_inferior that call proceed_one_lwp
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (proceed_one_lwp): Return void, change parameter
	type.
	(unsuspend_and_proceed_one_lwp): Likewise.
	(proceed_all_lwps): Use for_each_thread.
	(unstop_all_lwps): Likewise.
2017-12-02 20:36:43 -05:00
Simon Marchi c80825ff32 Remove usage of find_inferior in linux_resume
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_resume_one_thread): Return void, take
	parameter directly.
	(linux_resume): Use for_each_thread.
2017-12-02 20:36:42 -05:00
Simon Marchi df3e4dbe66 Remove usages of find_inferior in stop_all_lwps
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (send_sigstop_callback): Return void, change
	parameter type.  Rename to...
	(send_sigstop): ... this.
	(suspend_and_send_sigstop_callback): Return void, change parameter
	type.  Rename to...
	(suspend_and_send_sigstop): ... this.
	(stop_all_lwps): Use for_each_thread.
2017-12-02 20:36:42 -05:00
Simon Marchi 5a6b0a41df Remove usage of find_inferior in linux_stabilize_threads
Replace with find_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (lwp_running): Return bool, remove unused
	argument.
	(linux_stabilize_threads): Use find_thread.
2017-12-02 20:36:41 -05:00
Simon Marchi 39a64da5fc Remove usages of find_inferior in select_event_lwp
Replace with find_thread/for_each_thread.  I inlined the callbacks,
because they are relatively simple.

gdb/gdbserver/ChangeLog:

	* linux-low.c (select_singlestep_lwp_callback): Remove.
	(count_events_callback): Remove.
	(select_event_lwp_callback): Remove.
	(select_event_lwp): Use find_thread/for_each_thread.
2017-12-02 20:36:40 -05:00
Simon Marchi a1385b7b88 Remove usages of find_inferior calling not_stopped_callback
Replace with find_thread.  Writing a lambda inline in directly in the if
conditions would be a bit messy, so I chose to assign them to variables
instead.

gdb/gdbserver/ChangeLog:

	* linux-low.c (not_stopped_callback): Return bool, take filter
	argument directly.
	(linux_wait_for_event_filtered): Use find_thread.
	(linux_wait_1): Likewise.
2017-12-02 20:36:39 -05:00
Simon Marchi 454296a2c1 Remove usage of find_inferior in find_lwp_pid
Replace with find_thread.  We could almost use find_thread_ptid, except
that find_lwp_pid uses the pid of the input ptid of the lwp is 0, so the
behavior is not quite the same.

gdb/gdbserver/ChangeLog:

	* linux-low.c (same_lwp): Remove.
	(find_lwp_pid): Use find_thread.
2017-12-02 20:36:38 -05:00
Simon Marchi 6b2a85daf5 Remove usage of find_inferior in linux_mourn
Replace with for_each_thread with pid filtering.  The callback becomes
trivial enough that it's better to inline it.

gdb/gdbserver/ChangeLog:

	* linux-low.c (delete_lwp_callback): Remove.
	(linux_mourn): Use for_each_thread.
2017-12-02 20:36:37 -05:00
Simon Marchi 798a38e8de Remove usage of find_inferior in linux_detach
Replace with for_each_thread with pid filtering.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_detach_lwp_callback): Return void, remove
	args parameter, don't check for pid.
	(linux_detach): Use for_each_thread.
2017-12-02 20:36:36 -05:00
Simon Marchi e4eb0dec0b Remove usage of find_inferior in last_thread_of_process_p
Replace it with find_thread.  I also modified the code a bit to use a
lambda and a boolean.

gdb/gdbserver/ChangeLog:

	* linux-low.c (struct counter): Remove.
	(second_thread_of_pid_p): Remove.
	(last_thread_of_process_p): Use find_thread.
2017-12-02 20:36:36 -05:00
Simon Marchi 83e1b6c13a Remove find_inferior_in_random
Replace with find_thread_in_random.

gdb/gdbserver/ChangeLog:

	* inferiors.c (find_inferior_in_random): Remove.
	* inferiors.h (find_inferior_in_random): Remove.
	* linux-low.c (status_pending_p_callback): Return bool, accept
	parameter ptid directly.
	(linux_wait_for_event_filtered): Use find_thread_in_random.
	(linux_wait_1): Likewise.
2017-12-02 20:36:35 -05: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
Simon Marchi 578290ecaf Remove usage of find_inferior when calling kill_one_lwp_callback
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (kill_one_lwp_callback): Return void, take
	argument directly, don't filter on pid.
	(linux_kill): Use for_each_thread.
2017-11-19 22:23:28 -05:00
Simon Marchi eca55aec1d Remove usages of find_thread when calling need_step_over_p
Replace with find_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (need_step_over_p): Return bool, remove dummy
	argument.
	(linux_resume, proceed_all_lwps): Use find_thread.
2017-11-19 22:23:27 -05:00
Simon Marchi 25c28b4d15 Remove usage of find_thread when calling resume_status_pending_p
Replace with find_thread.  Instead of setting the flag in the callback,
make the callback return true/false, and check the result against NULL
in the caller.

gdb/gdbserver/ChangeLog:

	* linux-low.c (resume_status_pending_p): Return bool, remove
	flag_p argument.
	(linux_resume): Use find_thread.
2017-11-19 22:23:27 -05:00
Simon Marchi 5fdda39248 Remove usage of find_inferior when calling linux_set_resume_request
Replace it with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (struct thread_resume_array): Remove.
	(linux_set_resume_request): Return void, take arguments
	directly.
	(linux_resume): Use for_each_thread.
2017-11-19 22:23:26 -05:00
Simon Marchi fcb056a58d Remove usage of find_inferior in linux_stabilize_threads
Simply replace with find_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (stuck_in_jump_pad_callback): Change prototype,
	return bool, remove data argument.
	(linux_stabilize_threads): Use find_thread.
2017-11-19 22:23:25 -05:00
Simon Marchi 139720c5b3 Remove usage of find_inferior in unsuspend_all_lwps
Replace with for_each_thread.  I inlined unsuspend_one_lwp in
unsuspend_all_lwps, since it is very simple.

gdb/gdbserver/ChangeLog:

	* linux-low.c (unsuspend_one_lwp): Remove.
	(unsuspend_all_lwps): Use for_each_thread, inline code from
	unsuspend_one_lwp.
2017-11-19 22:23:24 -05:00
Simon Marchi 6d1e5673fe Remove usage of find_inferior in iterate_over_lwps
Replace find_inferior with find_thread.  Since it may be useful in the
future, I added another overload to find_thread which filters based on a
ptid (using ptid_t::matches), so now iterate_over_lwps doesn't have to
do the filtering itself.  iterate_over_lwps_filter is removed and
inlined into iterate_over_lwps.

gdb/gdbserver/ChangeLog:

	* gdbthread.h (find_thread): Add overload with ptid_t filter.
	* linux-low.c (struct iterate_over_lwps_args): Remove.
	(iterate_over_lwps_filter): Remove.
	(iterate_over_lwps): Use find_thread.
2017-11-19 22:23:23 -05:00
Simon Marchi bbf550d50e Remove usage of find_inferior in reset_lwp_ptrace_options_callback
Replace with for_each_thread, and inline code from
reset_lwp_ptrace_options_callback.

gdb/gdbserver/ChangeLog:

	* linux-low.c (reset_lwp_ptrace_options_callback): Remove.
	(linux_handle_new_gdb_connection): Use for_each_thread, inline
	code from reset_lwp_ptrace_options_callback.
2017-11-19 22:23:23 -05:00
Simon Marchi f27866ba9c Make process_info::syscalls_to_catch an std::vector
This patch makes the syscalls_to_catch field of process_info an
std::vector<int>.  The process_info structure must now be
newed/deleted.

In handle_extended_wait, the code that handles exec events destroys the
existing process_info and creates a new one.  It moves the content of
syscalls_to_catch from the old to the new vector.  I used std::move for
that (through an intermediary variable), which should have the same
behavior as the old code.

gdb/gdbserver/ChangeLog:

	* inferiors.h (struct process_info): Add constructor, initialize
	fields..
	<syscalls_to_catch>: Change type to std::vector<int>.
	* inferiors.c (add_process): Allocate process_info with new.
	(remove_process): Free process_info with delete.
	* linux-low.c (handle_extended_wait): Adjust.
	(gdb_catching_syscalls_p, gdb_catch_this_syscall_p): Adjust.
	* server.c (handle_general_set): Adjust.
2017-11-17 13:03:34 -05:00
Simon Marchi 4d3bb80e5d Add overloads of for_each_thread/find_thread that filter on pid
It happens often that we want to iterate or find threads restricted to a
given pid.  I think it's worth having an overload to help with this.
Right now there is a single user of each of the find_thread and
for_each_thread overload, but as we replace the usages of find_inferior
with for_each_thread/find_thread, more usages will pop up.

gdb/gdbserver/ChangeLog:

	* gdbthread.h (find_thread, for_each_thread): New functions.
	* inferiors.c (thread_of_pid): Remove.
	(find_any_thread_of_pid): Use find_thread.
	* linux-low.c (num_lwps): Use for_each_thread.
2017-10-21 12:20:21 -04:00
Simon Marchi 9c80ecd646 gdbserver: use std::list for all_threads
Remove the usage of inferior_list for the all_threads list in
gdbserver.  The entry field in thread_info is removed, and replaced by a
simple ptid field.

I added some functions to iterate (for_each_thread) and find threads
(find_thread).  However, changing all the users of find_inferior & co to
use these new functions would have made the patch way too big.  So I
opted instead to make find_inferior & co some shims, so that the
existing code only needs to be updated minimally.  We can then update
the existing code to use the new functions incrementally (I've started
to do the work, but I'll post it afterwards, see [1] if you want a peek).

This patch has been built-tested on all relevant platforms, except
lynx.  I also regtested using the native-gdbserver and
native-extended-gdbserver boards on x86.

[1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry

gdb/gdbserver/ChangeLog:

	* inferiors.h: (struct inferior_list): Remove.
	(struct inferior_list_entry); Remove.
	(add_inferior_to_list, clear_inferior_list, one_inferior_p,
	A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior,
	get_first_inferior): Remove.
	(for_each_inferior, for_each_inferior_with_data, find_inferior,
	find_inferior_id, find_inferior_in_random): Change signature.
	* inferiors.c (all_threads): Change type to
	std::list<thread_info *>.
	(get_thread): Remove macro.
	(find_inferior, find_inferior_id): Change signature, implement
	using find_thread.
	(find_inferior_in_random): Change signature, implement using
	find_thread_in_random.
	(for_each_inferior, for_each_inferior_with_data): Change
	signature, implement using for_each_thread.
	(add_inferior_to_list, remove_inferior): Remove.
	(add_thread, get_first_thread, thread_of_pid,
	find_any_thread_of_pid, free_one_thread, remove_thread): Update.
	(get_first_inferior, one_inferior_p, clear_inferior_list):
	Remove.
	(clear_inferiors, get_thread_process): Update.
	* gdbthread.h: Include <list>.
	(struct thread_info) <entry>: Remove field.
	<id>: New field.
	(all_threads): Change type to std::list<thread_info *>.
	(get_first_inferior): Add doc.
	(find_thread, for_each_thread, find_thread_in_random): New
	functions.
	(current_ptid, pid_of, ptid_of, lwpid_of): Update.
	* linux-arm-low.c (update_registers_callback): Update.
	* linux-low.c (second_thread_of_pid_p): Update.
	(kill_one_lwp_callback, linux_detach_lwp_callback,
	delete_lwp_callback, status_pending_p_callback, same_lwp,
	find_lwp_pid, num_lwps, iterate_over_lwps_filter,
	iterate_over_lwps, not_stopped_callback,
	resume_stopped_resumed_lwps, count_events_callback,
	select_singlestep_lwp_callback, select_event_lwp_callback,
	unsuspend_one_lwp, linux_wait_1, send_sigstop_callback,
	suspend_and_send_sigstop_callback, wait_for_sigstop,
	stuck_in_jump_pad_callback, move_out_of_jump_pad_callback,
	lwp_running, linux_set_resume_request, resume_status_pending_p,
	need_step_over_p, start_step_over, linux_resume_one_thread,
	proceed_one_lwp, unsuspend_and_proceed_one_lwp,
	reset_lwp_ptrace_options_callback): Update.
	* linux-mips-low.c (update_watch_registers_callback): Update.
	* regcache.c (regcache_invalidate_one, regcache_invalidate):
	Update.
	(free_register_cache_thread_one): Remove.
	(regcache_release): Update.
	* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt,
	handle_qxfer_threads_worker): Update.
	(handle_query): Update, use list iterator.
	(visit_actioned_threads, handle_pending_status,
	queue_stop_reply_callback, gdb_wants_all_threads_stopped,
	clear_pending_status_callback, set_pending_status_callback,
	find_status_pending_thread_callback, handle_status,
	process_serial_event): Update.
	* target.c (thread_search_callback): Update.
	* thread-db.c (thread_db_get_tls_address): Update.
	* tracepoint.c (tracepoint_finished_step, tracepoint_was_hit):
	Update.
	* win32-i386-low.c (update_debug_registers_callback): Update.
	* win32-low.c (delete_thread_info, child_delete_thread,
	continue_one_thread, suspend_one_thread,
	get_child_debug_event): Adjust.
2017-10-14 09:11:12 -04:00
Simon Marchi 9179355e65 gdbserver: Use std::list for all_processes
Remove the usage of inferior_list for the all_processes list in
gdbserver, replace it with an std::list. The entry field in process_info
is removed, and replaced by a simple pid field.

The pid_of macro, used for both processes and threads, is replaced with
separate functions.  For completeness, I changed ptid_of and lwpid_of to
functions as well.

gdb/gdbserver/ChangeLog:

	* gdbthread.h (ptid_of, pid_of, lwpid_of): New functions.
	* inferiors.h: Include <list>.
	(struct process_info) <entry>: Remove field.
	<pid>: New field.
	(pid_of): Change macro to function.
	(ptid_of, lwpid_of): Remove macro.
	(all_processes): Change type to std::list<process_info *>.
	(ALL_PROCESSES): Remove macro.
	(for_each_process, find_process): New function.
	* inferiors.c (all_processes): Change type to
	std::list<process_info *>.
	(find_thread_process): Adjust.
	(add_process): Likewise.
	(remove_process): Likewise.
	(find_process_pid): Likewise.
	(get_first_process): Likewise.
	(started_inferior_callback): Remove.
	(have_started_inferiors_p): Adjust.
	(attached_inferior_callback): Remove.
	(have_attached_inferiors_p): Adjust.
	* linux-low.c (check_zombie_leaders): Likewise.
	* linux-x86-low.c (x86_arch_setup_process_callback): Remove.
	(x86_linux_update_xmltarget): Adjust.
	* server.c (handle_query): Likewise.
	(gdb_reattached_process): Remove.
	(handle_status): Adjust.
	(kill_inferior_callback): Likewise.
	(detach_or_kill_inferior): Remove.
	(print_started_pid): Likewise.
	(print_attached_pid): Likewise.
	(detach_or_kill_for_exit): Update.
	(process_serial_event): Likewise.
	* linux-arm-low.c (arm_new_fork): Likewise.
2017-10-14 09:10:42 -04:00
Simon Marchi 04ec7890fc linux low: Make the arch code free arch_process_info
For the same reason as the previous patch, we need to make the
arch-specific code free the arch_process_info structure it allocates.

gdb/gdbserver/ChangeLog:

	* linux-low.h (struct linux_target_ops) <delete_process>: New
	field.
	* linux-low.c (linux_mourn): Call the_low_target.delete_process.
	* linux-aarch64-low.c (aarch64_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-arm-low.c (arm_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-bfin-low.c (struct linux_target_ops): Likewise.
	* linux-crisv32-low.c (struct linux_target_ops): Likewise.
	* linux-m32r-low.c (struct linux_target_ops): Likewise.
	* linux-mips-low.c (mips_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-ppc-low.c (struct linux_target_ops): Likewise.
	* linux-s390-low.c (struct linux_target_ops): Likewise.
	* linux-sh-low.c (struct linux_target_ops): Likewise.
	* linux-tic6x-low.c (struct linux_target_ops): Likewise.
	* linux-tile-low.c (struct linux_target_ops): Likewise.
	* linux-x86-low.c (x86_linux_delete_process): New.
	(struct linux_target_ops): Add delete_process callback.
	* linux-xtensa-low.c (struct linux_target_ops): Likewise.
2017-10-12 16:49:27 -04:00
Simon Marchi 466eeceef4 lwp_info: Make the arch code free arch_lwp_info
I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types.  A few things need to be
fixed in the mean time, this is one.

The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info.  However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation.  This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.

My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill.  Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place).  This is
what this patch does.

Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.

There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:

  aarch64-linux-gnu
  alpha-linux-gnu
  arm-linux-gnueabihf
  hppa-linux-gnu
  m68k-linux-gnu
  mips64el-linux-gnuabi64
  powerpc64-linux-gnu
  s390x-linux-gnu
  sh4-linux-gnu
  sparc64-linux-gnu
  x86_64-linux-gnu
  x86_64-w64-mingw32

A buildbot run didn't find any regression.

[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html

gdb/ChangeLog:

	* linux-nat.h (linux_nat_set_delete_thread): New declaration.
	* linux-nat.c (linux_nat_delete_thread): New variable.
	(lwp_free): Invoke linux_nat_delete_thread if set.
	(linux_nat_set_delete_thread): New function.
	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
	thread delete callback.
	* arm-linux-nat.c (arm_linux_delete_thread): New function.
	(_initialize_arm_linux_nat): Assign thread delete callback.
	* s390-linux-nat.c (s390_delete_thread): New function.
	(_initialize_s390_nat): Assign thread delete callback.
	* x86-linux-nat.c (x86_linux_add_target): Likewise.
	* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
	function.
	* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
	declaration.
	* nat/x86-linux.c (x86_linux_delete_thread): New function.
	* nat/x86-linux.h (x86_linux_delete_thread): New declaration.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (the_low_target): Add thread delete
	callback.
	* linux-arm-low.c (arm_delete_thread): New function.
	(the_low_target): Add thread delete callback.
	* linux-bfin-low.c (the_low_target): Likewise.
	* linux-crisv32-low.c (the_low_target): Likewise.
	* linux-low.c (delete_lwp): Invoke delete_thread callback if
	set.
	* linux-low.h (struct linux_target_ops) <delete_thread>: New
	field.
	* linux-m32r-low.c (the_low_target): Add thread delete callback.
	* linux-mips-low.c (mips_linux_delete_thread): New function.
	(the_low_target): Add thread delete callback.
	* linux-ppc-low.c (the_low_target): Likewise.
	* linux-s390-low.c (the_low_target): Likewise.
	* linux-sh-low.c (the_low_target): Likewise.
	* linux-tic6x-low.c (the_low_target): Likewise.
	* linux-tile-low.c (the_low_target): Likewise.
	* linux-x86-low.c (the_low_target): Likewise.
	* linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 16:48:22 -04:00
Pedro Alves 94c207e097 Fix gdbserver regression exposed by gdb.threads/multi-create-ns-info-thr.exp
Commit 8629910955 ("Add thread_db_notice_clone to gdbserver")
introduced calls into libthread_db without making sure that the
current thread is pointing to a know-stopped thread.  This resulted in
sometimes thread_db_notice_clone failing->find_one_thread failing like
this, as seen when running gdb.threads/multi-create-ns-info-thr.exp:

~~~
  Thread <6> executing
  Thread <7> executing
  gdbserver: PID mismatch!  Expected 27472, got 27471
  gdbserver: Cannot find thread after clone.

  Thread <1000> executing
  Thread <1001> executing
~~~

Things go south from here and sometimes that ends up resulting in
gdbserver crashing and the test failing.

gdb/gdbserver/ChangeLog:
2017-09-29  Pedro Alves  <palves@redhat.com>

	* linux-low.c (handle_extended_wait): Pass parent thread instead
	of process to thread_db_notice_clone.
	* linux-low.h (thread_db_notice_clone): Replace parent process
	parameter with parent thread parameter.
	* thread-db.c (find_one_thread): Add comment.
	(thread_db_notice_clone): Replace parent process parameter with
	parent thread parameter.  Temporarily switch to the parent thread.
2017-09-29 13:06:34 +01:00
Kevin Buettner f6327dcbf0 Add thread_handle_to_thread_info support for remote targets
This patch adds support to remote targets for converting a thread
handle to a thread_info struct pointer.

A thread handle is fetched via a "handle" attribute which has been
added to the qXfer:threads:read query packet.  An implementation is
provided in gdbserver for targets using the Linux kernel.

gdb/gdbserver/ChangeLog:

	* linux-low.h (struct lwp_info): Add new field, thread_handle.
	(thread_db_thread_handle): Declare.
	* linux-low.c (linux_target_ops): Initialize thread_handle.
	* server.c (handle_qxfer_threads_worker): Add support for
	"handle" attribute.
	* target.h (struct target_ops): Add new function pointer,
	thread_handle.
	(target_thread_handle): Define.
	* thread-db.c (find_one_thread, attach_thread): Set thread_handle
	field in lwp.
	(thread_db_thread_handle): New function.

gdb/ChangeLog:

	* remote.c (vector): Include.
	(struct private_thread_info): Add field, thread_handle.
	(free_private_thread_info): Deallocate storage associated with
	thread handle.
	(get_private_info_thread): Initialize `thread_handle' field.
	(struct thread_item): Add field, thread_handle.
	(clear_threads_listing_context): Deallocate storage associated
	with thread handle.
	(start_thread): Add support for "handle" attribute.
	(thread_attributes): Add "handle".
	(remote_get_threads_with_qthreadinfo): Initialize thread_handle
	field.
	(remote_update_thread_list): Update thread_handle.
	(remote_thread_handle_to_thread_info): New function.
	(init_remote_ops): Initialize to_thread_handle_to_thread_info.
2017-09-21 11:49:47 -07:00
Kevin Buettner 8629910955 Add thread_db_notice_clone to gdbserver
While working on a patch for fetching a thread handle in gdbserver, I
ran into a circumstance in which tests in gdb.mi/mi-nsmoribund.exp
would occasionally fail.  Over a large enough number of runs, it would
fail roughly 2% of the time.

That thread handle patch caused find_one_thread() to be called on
every stop.  find_one_thread() calls td_ta_map_lwp2thr() which, in
turn, can cause ps_get_thread_area() to be called.
ps_get_thread_area() makes a call to ptrace() for getting the thread
area address.  If this should happen when the thread is not stopped,
the call to ptrace will return error which in turn propogates back to
find_one_thread().  find_one_thread() calls error() in this instance
which causes the program to die.

This patch causes find_one_thread() to be called upon reciept of a
clone event.  Since the clone is stopped, the circumstances described
above cannot occur.

gdb/gdbserver/ChangeLog:

	* linux-low.c (handle_extended_wait): Call thread_db_notice_clone().
	* linux-low.h (thread_db_notice_clone): Declare.
	* thread-db.c (thread_db_notice_clone): New function.
2017-09-21 11:49:47 -07:00
Simon Marchi 5e1875543d Make xml_escape_text return an std::string
This is a simple replacement, it allows removing some manual free'ing in
the callers.

gdb/ChangeLog:

	* common/buffer.c (buffer_xml_printf): Adjust.
	* common/xml-utils.c (xml_escape_text): Change return type to
	std::string, update code accordingly.
	* common/xml-utils.h (xml_escape_text): Change return type to
	std::string.
	* rs6000-aix-tdep.c (rs6000_aix_shared_library_to_xml): Adjust.
	* windows-tdep.c (windows_xfer_shared_library): Adjust.
	* unittests/xml-utils-selftests.c (test_xml_escape_text):
	Adjust.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_qxfer_libraries_svr4): Adjust to change of
	return type of xml_escape_text.
	* server.c (emit_dll_description): Likewise.
2017-09-16 14:19:31 +02:00
Simon Marchi 0eb0a40713 linux-low: Remove unused variables
gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_set_resume_request): Remove unused
	variables.
2017-09-15 16:41:35 +02:00
Sergio Durigan Junior cc397f3a23 Fix build breakage on GNU/Linux AArch64
This patch fixes the build breakage that has been happening on AArch64
since September 5th.  The breakage was introduced by the following
commit:

  author        Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  committer     Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  commit        f7000548a2

  Use VEC for target_desc.reg_defs

The build log for this commit can be seen here:

  <https://gdb-build.sergiodj.net/builders/Ubuntu-AArch64-native-gdbserver-m64/builds/2696/steps/compile%20gdb/logs/stdio>

And the underlying problem is that the code is not calling the new
function "allocate_target_description" to allocate the "struct
target_desc" using "new" instead of XNEW, which end up not properly
initializing the fields of the structure.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	* linux-low.c (handle_extended_wait): Use
	"allocate_target_description" instead of "XNEW".
	* linux-x86-low.c (initialize_low_arch): Likewise.
2017-09-10 12:33:28 -04:00
Simon Marchi 23fdd69e42 Make target_waitstatus_to_string return an std::string
A quite straightforward change.  It does "fix" leaks in record-btrace.c,
although since this is only used in debug printing code, it has no real
world impact.

gdb/ChangeLog:

	* target/waitstatus.h (target_waitstatus_to_string): Change
	return type to std::string.
	* target/waitstatus.c (target_waitstatus_to_string): Return
	std::string.
	* target.h (target_waitstatus_to_string): Remove declaration.
	* infrun.c (resume, clear_proceed_status_thread,
	print_target_wait_results, do_target_wait, save_waitstatus,
	stop_all_threads): Adjust.
	* record-btrace.c (record_btrace_wait): Adjust.
	* target-debug.h
	(target_debug_print_struct_target_waitstatus_p): Adjust.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_wait_1): Adjust.
	* server.c (queue_stop_reply_callback): Adjust.
2017-09-03 10:23:31 +02:00
Simon Marchi 229d26fc9e Add enum for result of fast_tracepoint_collecting
I got confused by the result value of fast_tracepoint_collecting, while
it sounds like it would return true/false (whether the thread is
collecting or not), it actually returns:

  0: not collecting
  1: in the jump pad, before the relocated instruction
  2: in the jump pad, at or after the relocated instruction

To avoid confusion, I think it would be nice to make it return an enum.
If you can help find a shorter but still relavant name, it would be
awesome.  Otherwise, we'll go with that, fast_tpoint_collect_result,
which is at least consistent with the existing
fast_tpoint_collect_status.

gdb/gdbserver/ChangeLog:

	* tracepoint.h (enum class fast_tpoint_collect_result): New
	enumeration.
	(fast_tracepoint_collecting): Change return type to
	fast_tpoint_collect_result.
	* tracepoint.c (fast_tracepoint_collecting): Likewise.
	* linux-low.h: Include tracepoint.h.
	(struct lwp_info) <collecting_fast_tracepoint>: Change type to
	fast_tpoint_collect_result.
	* linux-low.c (handle_tracepoints): Adjust.
	(linux_fast_tracepoint_collecting): Change return type to
	fast_tpoint_collect_result.
	(maybe_move_out_of_jump_pad, linux_wait_for_event_filtered,
	linux_wait_1, stuck_in_jump_pad_callback,
	lwp_signal_can_be_delivered, linux_resume_one_lwp_throw,
	proceed_one_lwp): Adjust to type change.
2017-07-26 10:57:07 +02:00
Sergio Durigan Junior 9a6c7d9c02 C++ify gdb/common/environ.c
As part of the preparation necessary for my upcoming task, I'd like to
propose that we turn gdb_environ into a class.  The approach taken
here is simple: the class gdb_environ contains everything that is
needed to manipulate the environment variables.  These variables are
stored in an std::vector<char *>, which can be converted to a 'char
**' and passed as argument to functions that need it.

The usage has not changed much.  As per Pedro's suggestion, this class
uses a static factory method initialization.  This means that when an
instance is created, it is initially empty.  When needed, it has to be
initialized using the static method 'from_host_environ'.

As mentioned before, this is a preparation for an upcoming work that I
will be posting in the next few weeks or so.  For that work, I'll
probably create another data structure that will contain all the
environment variables that were set by the user using the 'set
environment' command, because I'll need access to them.  This will be
much easier with the class-ification of gdb_environ.

As noted, this has been regression-tested with the new version of
environ.exp and no regressions were found.

gdb/ChangeLog:
2017-06-20  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	'unittests/environ-selftests.c'.
	(SUBDIR_UNITTESTS_OBS): Add 'environ-selftests.o'.
	* charset.c (find_charset_names): Declare object 'iconv_env'.
	Update code to use 'iconv_env' object.  Remove call to
	'free_environ'.
	* common/environ.c: Include <utility>.
	(make_environ): Delete function.
	(free_environ): Delete function.
	(gdb_environ::clear): New function.
	(gdb_environ::operator=): New function.
	(gdb_environ::get): Likewise.
	(environ_vector): Delete function.
	(set_in_environ): Delete function.
	(gdb_environ::set): New function.
	(unset_in_environ): Delete function.
	(gdb_environ::unset): New function.
	(gdb_environ::envp): Likewise.
	* common/environ.h: Include <vector>.
	(struct gdb_environ): Delete; transform into...
	(class gdb_environ): ... this class.
	(free_environ): Delete prototype.
	(init_environ, get_in_environ, set_in_environ, unset_in_environ,
	environ_vector): Likewise.
	* infcmd.c (run_command_1): Update code to call
	'envp' from 'gdb_environ' class.
	(environment_info): Update code to call methods from 'gdb_environ'
	class.
	(unset_environment_command): Likewise.
	(path_info): Likewise.
	(path_command): Likewise.
	* inferior.c (inferior::~inferior): Delete call to 'free_environ'.
	(inferior::inferior): Initialize 'environment' using the host's
	information.
	* inferior.h: Remove forward declaration of 'struct gdb_environ'.
	Include "environ.h".
	(class inferior) <environment>: Change type from 'struct
	gdb_environ' to 'gdb_environ'.
	* mi/mi-cmd-env.c (mi_cmd_env_path): Update code to call
	methods from 'gdb_environ' class.
	* solib.c (solib_find_1): Likewise
	* unittests/environ-selftests.c: New file.

gdb/gdbserver/ChangeLog:
2017-06-20  Sergio Durigan Junior  <sergiodj@redhat.com>

	* linux-low.c (linux_create_inferior): Adjust code to access the
	environment information via 'gdb_environ' class.
	* lynx-low.c (lynx_create_inferior): Likewise.
	* server.c (our_environ): Make it an instance of 'gdb_environ'.
	(get_environ): Return a pointer to 'our_environ'.
	(captured_main): Initialize 'our_environ'.
	* server.h (get_environ): Adjust prototype.
	* spu-low.c (spu_create_inferior): Adjust code to access the
	environment information via 'gdb_environ' class.
2017-06-20 08:59:27 -04:00
Simon Marchi ae3e2ccfe7 linux-low: Remove usage of "register" keyword
AFAIK, the register keyword is not relevant today, and clang complains
about it:

/home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-low.c:5873:3: error: 'register' storage class specifier is deprecated and incompatible with C++1z
      [-Werror,-Wdeprecated-register]
  register PTRACE_XFER_TYPE *buffer;
  ^~~~~~~~~

I think we can safely remove it.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_read_memory, linux_write_memory): Remove
	usage of "register" keyword.
2017-06-17 23:19:09 +02:00
Sergio Durigan Junior 2090129c36 Share fork_inferior et al with gdbserver
This is the most important (and the biggest, sorry) patch of the
series.  It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.

There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.

I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch.  The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).

Everything is working as expected, and no regressions were present
during the tests.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
	and "nat/fork-inferior.h".
	* common/common-inferior.h: New file, with contents from
	"gdb/inferior.h".
	* commom/common-utils.c: Include "common-utils.h".
	(stringify_argv): New function.
	* common/common-utils.h (stringify_argv): New prototype.
	* configure.nat: Add "fork-inferior.o" as a dependency for
	"*linux*", "fbsd*" and "nbsd*" hosts.
	* corefile.c (get_exec_file): Update comment.
	* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
	instead of "startup_inferior".
	(darwin_create_inferior): Call "add_thread_silent" after
	"fork_inferior".
	* fork-child.c: Cleanup unnecessary includes.
	(SHELL_FILE): Move to "common/common-fork-child.c".
	(environ): Likewise.
	(exec_wrapper): Initialize.
	(get_exec_wrapper): New function.
	(breakup_args): Move to "common/common-fork-child.c"; rename to
	"breakup_args_for_exec".
	(escape_bang_in_quoted_argument): Move to
	"common/common-fork-child.c".
	(saved_ui): New variable.
	(prefork_hook): New function.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(gdb_startup_inferior): Likewise.
	(fork_inferior): Move to "common/common-fork-child.c".  Update
	function to support gdbserver.
	(startup_inferior): Likewise.
	* gdbcore.h (get_exec_file): Remove declaration.
	* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
	(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inferior.h: Include "common-inferior.h".
	(trace_start_error): Move to "common/common-utils.h".
	(trace_start_error_with_name): Likewise.
	(fork_inferior): Move prototype to "nat/fork-inferior.h".
	(startup_inferior): Likewise.
	(gdb_startup_inferior): New prototype.
	* nat/fork-inferior.c: New file, with contents from "fork-child.c".
	* nat/fork-inferior.h: New file.
	* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* target.h (target_terminal_init): Move prototype to
	"target/target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target/target.h (target_terminal_init): New prototype, moved
	from "target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* utils.c (gdb_flush_out_err): New function.

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add "nat/fork-inferior.o".
	* configure: Regenerate.
	* configure.srv (srv_linux_obj): Add "fork-child.o" and
	"fork-inferior.o".
	(i[34567]86-*-lynxos*): Likewise.
	(spu*-*-*): Likewise.
	* fork-child.c: New file.
	* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
	and "environ.h".
	(linux_ptrace_fun): New function.
	(linux_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	(linux_request_interrupt): Delete "signal_pid".
	* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(lynx_ptrace_fun): New function.
	(lynx_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	* nto-low.c (nto_create_inferior): Adjust function prototype and
	code to reflect change on "target.h".  Update comments.
	* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
	"common-terminal.h" and "environ.h".
	(terminal_fd): Moved to fork-child.c.
	(old_foreground_pgrp): Likewise.
	(restore_old_foreground_pgrp): Likewise.
	(last_status): Make it global.
	(last_ptid): Likewise.
	(our_environ): New variable.
	(startup_with_shell): Likewise.
	(program_name): Likewise.
	(program_argv): Rename to...
	(program_args): ...this.
	(wrapper_argv): New variable.
	(start_inferior): Delete function.
	(get_exec_wrapper): New function.
	(get_exec_file): Likewise.
	(get_environ): Likewise.
	(prefork_hook): Likewise.
	(post_fork_inferior): Likewise.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(handle_v_run): Update code to deal with arguments coming from the
	remote host.  Update calls from "start_inferior" to
	"create_inferior".
	(captured_main): Likewise.  Initialize environment variable.  Call
	"have_job_control".
	* server.h (post_fork_inferior): New prototype.
	(get_environ): Likewise.
	(last_status): Declare.
	(last_ptid): Likewise.
	(signal_pid): Likewise.
	* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(spu_ptrace_fun): New function.
	(spu_create_inferior): Adjust function prototype to reflect change
	on "target.h".  Adjust function code to use "fork_inferior".
	* target.c (target_terminal_init): New function.
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target.h: Include <vector>.
	(struct target_ops) <create_inferior>: Update prototype.
	(create_inferior): Update macro.
	* utils.c (gdb_flush_out_err): New function.
	* win32-low.c (win32_create_inferior): Adjust function prototype
	and code to reflect change on "target.h".

gdb/testsuite/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.server/non-existing-program.exp: Update regex in order to
	reflect the fact that gdbserver is now using fork_inferior (with a
	shell) to startup the inferior.
2017-06-07 19:56:09 -04:00
Simon Marchi a0ff9e1ad2 Change return type of gdbarch_software_single_step to vector<CORE_ADDR>
This is a relatively straightforward patch that changes
gdbarch_software_single_step so it returns an std::vector<CORE_ADDR>
instead of a VEC (CORE_ADDR).

gdb/ChangeLog:

	* gdbarch.sh (software_single_step): Change return type to
	std::vector<CORE_ADDR>.
	* gdbarch.c, gdbarch.h: Re-generate.
	* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw):
	Adjust.
	(arm_deal_with_atomic_sequence_raw): Adjust.
	(thumb_get_next_pcs_raw): Adjust.
	(arm_get_next_pcs_raw): Adjust.
	(arm_get_next_pcs): Adjust.
	* arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust.
	* aarch64-tdep.c (aarch64_software_single_step): Adjust.
	* alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust.
	(alpha_software_single_step): Adjust.
	* alpha-tdep.h (alpha_software_single_step): Adjust.
	* arm-linux-tdep.c (arm_linux_software_single_step): Adjust.
	* arm-tdep.c (arm_software_single_step): Adjust.
	(arm_breakpoint_kind_from_current_state): Adjust.
	* arm-tdep.h (arm_software_single_step): Adjust.
	* breakpoint.c (insert_single_step_breakpoint): Adjust.
	* cris-tdep.c (cris_software_single_step): Adjust.
	* mips-tdep.c (mips_deal_with_atomic_sequence): Adjust.
	(micromips_deal_with_atomic_sequence): Adjust.
	(deal_with_atomic_sequence): Adjust.
	(mips_software_single_step): Adjust.
	* mips-tdep.h (mips_software_single_step): Adjust.
	* moxie-tdep.c (moxie_software_single_step): Adjust.
	* nios2-tdep.c (nios2_software_single_step): Adjust.
	* ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust.
	* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
	* s390-linux-tdep.c (s390_software_single_step): Adjust.
	* sparc-tdep.c (sparc_software_single_step): Adjust.
	* spu-tdep.c (spu_software_single_step): Adjust.
	* tic6x-tdep.c (tic6x_software_single_step): Adjust.

gdb/gdbserver/ChangeLog:

	* linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to
	software_single_step change of return type to
	std::vector<CORE_ADDR>.
	* linux-low.c (install_software_single_step_breakpoints):
	Likewise.
	* linux-low.h (install_software_single_step_breakpoints):
	Likewise.
2017-05-02 13:30:07 -04:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Pedro Alves 9986ba0887 gdbserver: Use warning for warnings
gdb/gdbserver/ChangeLog:
2016-11-23  Pedro Alves  <palves@redhat.com>

	* event-loop.c (handle_file_event): Use warning.
	* linux-low.c (linux_resume_one_lwp_throw): Use warning.
	* mem-break.c (add_breakpoint_condition, add_breakpoint_commands):
	Use warning.
2016-11-23 01:18:42 +00:00