Commit Graph

735 Commits

Author SHA1 Message Date
Yao Qi 8dc5b31971 Use rs->buf after getpkt
Hi,
The following code snippet looks wrong to me

 char *buf = rs->buf;

 getpkt (&rs->buf, &rs->buf_size, 0);
 packet_ok (buf, );

if rs->buf is reallocated in getpkt, buf points to an out of dated
memory.  This patch removes local 'buf' and uses rs->buf.

gdb:

2014-02-05  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_pass_signals): Remove local 'buf' and use
	rs->buf.
	(remote_program_signals): Likewise.
2014-02-05 20:25:47 +08:00
Christian Eggers f4ccffad18 Call remote_check_symbols even if only symbol-file (not file) has been given
The Eclipse "C/C++ GDB Hardware Debugging" plugin runs only the
"symbol-file" command.  In this case, remote_check_symbols is not
called and no qSymbol:: packet is sent to the server (OpenOCD in my
case).

gdb/
2014-02-04  Christian Eggers  <ceggers@gmx.de>  (tiny change)

	* remote.c (remote_start_remote): Call remote_check_symbols even
	if only symbol-file (not file) has been given.
2014-02-04 19:42:12 +00:00
Yao Qi 6b6aa82881 Change len's type to ULONGEST: remote_read_bytes and get_core_siginfo
Functions remote_read_bytes and get_core_siginfo are the callees of
target to_xfer_partial interface, so argument 'len' should be changed
to type ULONGEST.

gdb:

2014-01-24  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_read_bytes): Change type of len to ULONGEST.
	* corelow.c (get_core_siginfo): Likewise.
2014-01-24 21:31:30 +08:00
Yao Qi 5d6df42390 Change len's type to ULONGEST: remote_write_bytes_aux
Hi,
This patch changes the type of 'len' from ssize_t to ULONGEST.

At the beginning Siddhesh Poyarekar proposed this patch

  [PATCH] Memory reads and writes should have size_t length
  https://sourceware.org/ml/gdb-patches/2012-05/msg01073.html

to change type of 'len' to size_t.  However, after Jan's review, we
decide to change it to ssize_t, because callers of these functions
may pass signed type to them.

AFAICS, the target layer is a boundary.  In one side, we pass size_t
or ssize_t to target related APIs, and in the other side, the
implementation side, we used LONGEST (ULONGEST in latest code) because
of to_xfer_partial.

Since remote_write_bytes_aux and remote_write_bytes belong to the
implementation of remote target, we should use ULONGEST for len, IMO.

Regression tested on x86_64-linux.  Is it OK?

gdb:

2014-01-24  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_write_bytes_aux): Change type of 'len' to
	ULONGEST.  Don't check 'len' is negative.
	(remote_write_bytes):  Change type of 'len' to ULONGEST.
2014-01-24 21:31:26 +08:00
Sergio Durigan Junior c90a6fb765 Add "volatile" keyword to "struct gdb_exception" declaration
While doing something else, I found that those 2 places were incorrectly
declaring a "struct gdb_exception" without using the "volatile" keyword.
This commit fixes that.

2014-01-17  Sergio Durigan Junior  <sergiodj@redhat.com>

	* breakpoint.c (insert_bp_location): Add "volatile" keyword to "struct
	gdb_exception" declaration.
	* remote.c (getpkt_or_notif_sane): Likewise.
2014-01-17 19:39:57 -02:00
Tom Tromey 77a1944595 remove extended_remote_create_inferior_1
I noticed that extended_remote_create_inferior_1 is called from a
single spot.  This patch unifies the callee and caller.  It's just a
simple cleanup that made the coming refactoring simpler.

2014-01-16  Tom Tromey  <tromey@redhat.com>

	* remote.c (extended_remote_create_inferior): Rename from
	extended_remote_create_inferior_1.  Add "ops" argument.  Remove
	old implementation.
2014-01-16 12:12:32 -07:00
Markus Metzger 969c39fbcd btrace, gdbserver: read branch trace incrementally
Read branch trace data incrementally and extend the current trace rather than
discarding it and reading the entire trace buffer each time.

If the branch trace buffer overflowed, we can't extend the current trace so we
discard it and start anew by reading the entire branch trace buffer.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/linux-btrace.c (perf_event_read_bts, linux_read_btrace):
	Support delta reads.
	(linux_disable_btrace): Change return type.
	* common/linux-btrace.h (linux_read_btrace): Change parameters
	and return type to allow error reporting.  Update users.
	(linux_disable_btrace): Change return type.  Update users.
	* common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>:
	New.
	(btrace_error): New.
	(btrace_block) <begin>: Comment on BEGIN == 0.
	* btrace.c (btrace_compute_ftrace): Start from the end of
	the current trace.
	(btrace_stitch_trace, btrace_clear_history): New.
	(btrace_fetch): Read delta trace, return if replaying.
	(btrace_clear): Move clear history code to btrace_clear_history.
	(parse_xml_btrace): Throw an error if parsing failed.
	* target.h (struct target_ops) <to_read_btrace>: Change parameters
	and return type to allow error reporting.
	(target_read_btrace): Change parameters and return type to allow
	error reporting.
	* target.c (target_read_btrace): Update.
	* remote.c (remote_read_btrace): Support delta reads.  Pass
	errors on.
	* NEWS: Announce it.

gdbserver/
	* target.h (target_ops) <read_btrace>: Change parameters and
	return type to allow error reporting.
	* server.c (handle_qxfer_btrace): Support delta reads.  Pass
	trace reading errors on.
	* linux-low.c (linux_low_read_btrace): Pass trace reading
	errors on.
	(linux_low_disable_btrace): New.
2014-01-16 13:11:42 +01:00
Markus Metzger 3db08215d4 target, breakpoint: allow insert/remove breakpoint to be forwarded
2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* target.h (target_ops) <to_insert_breakpoint>
	<to_remove_breakpoint>: Add target_ops parameter.
	(forward_target_insert_breakpoint): New.
	(forward_target_remove_breakpoint): New.
	(memory_remove_breakpoint, memory_insert_breakpoint):
	Add target_ops parameter.
	* target.c (target_insert_breakpoint): Split into this and ...
	(forward_target_insert_breakpoint): ... this.
	(target_remove_breakpoint): Split into this and ...
	(forward_target_remove_breakpoint): ... this.
	(debug_to_insert_breakpoint): Add target_ops parameter.
	Call forward_target_insert_breakpoint.
	(debug_to_remove_breakpoint): Add target_ops parameter.
	Call forward_target_remove_breakpoint.
	(update_current_target): Do not inherit or default to_insert_breakpoint
	and to_remove_breakpoint.
	* corelow.c (ignore): Add target_ops parameter.
	* exec.c (ignore): Add target_ops parameter.
	* mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
	Add target_ops parameter.
	* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
	Add target_ops parameter.
	* nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint):
	Add target_ops parameter.
	* record-full.c (record_full_beneath_to_insert_breakpoint)
	(record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint)
	(tmp_to_remove_breakpoint, record_full_insert_breakpoint)
	(record_full_remove_breakpoint, record_full_core_insert_breakpoint)
	(record_full_core_remove_breakpoint): Add target_ops parameter.
	Update users.
	(record_full_beneath_to_insert_breakpoint_ops)
	(record_full_beneath_to_remove_breakpoint_ops)
	(tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New.
	(record_full_open): Initialize tmp_to_insert_breakpoint_ops,
	tmp_to_remove_breakpoint_ops,
	record_full_beneath_to_insert_breakpoint_ops, and
	record_full_beneath_to_remove_breakpoint_ops.
	* remote-m32r-sdi.c (m32r_insert_breakpoint)
	(m32r_remove_breakpoint): Add target_ops parameter.
	* remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint):
	Add target_ops parameter.
	* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
	Add target_ops parameter.
2014-01-16 13:06:13 +01:00
Markus Metzger f32dbf8c79 Add target_ops argument to to_prepare_to_store
2013-12-17  Tom Tromey  <tromey@redhat.com>

	* windows-nat.c (windows_prepare_to_store): Add 'self' argument.
	* target.h (struct target_ops) <to_prepare_to_store>: Add
	argument.
	(target_prepare_to_store): Add argument.
	* target.c (debug_to_prepare_to_store): Add argument.
	(update_current_target): Update.
	* remote.c (remote_prepare_to_store): Add 'self' argument.
	* remote-sim.c (gdbsim_prepare_to_store): Add 'self' argument.
	* remote-mips.c (mips_prepare_to_store): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_prepare_to_store): Add 'self' argument.
	* record-full.c (record_full_core_prepare_to_store): Add 'self'
	argument.
	* ravenscar-thread.c (ravenscar_prepare_to_store): Add argument.
	* nto-procfs.c (procfs_prepare_to_store): Add 'self' argument.
	* monitor.c (monitor_prepare_to_store): Add 'self' argument.
	* inf-child.c (inf_child_prepare_to_store): Add 'self' argument.
	* go32-nat.c (go32_prepare_to_store): Add 'self' argument.
2014-01-16 13:06:10 +01:00
Markus Metzger 864089d2f6 btrace: uppercase btrace_read_type
2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

	* common/btrace-common.h (btrace_read_type) <btrace_read_all>:
	Change to ...
	(btrace_read_type) <BTRACE_READ_ALL>: ... this.  Update users.
	(btrace_read_type) <btrace_read_new>: Change to ...
	(btrace_read_type) <BTRACE_READ_NEW>: ... this.  Update users.
2014-01-16 12:45:10 +01:00
Yao Qi b55e14c72c Change to_xfer_partial 'len' type to ULONGEST.
This patch changes to_xfer_partial's len's type to ULONGEST, and
adjust its implementations.

gdb:

2014-01-14  Yao Qi  <yao@codesourcery.com>

	* target.h (target_xfer_partial_ftype): Update.
	(struct target_ops) <to_xfer_partial>: Change 'len' type to
	ULONGEST.
	* aix-thread.c (aix_thread_xfer_partial): Change type of
	argument 'len' to ULONGEST.
	* auxv.c (procfs_xfer_auxv): Likewise.
	(ld_so_xfer_auxv): Likewise.
	(memory_xfer_auxv): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
	* bsd-uthread.c (bsd_uthread_xfer_partial): Likewise.
	* corelow.c (core_xfer_partial): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* darwin-nat.c (darwin_read_write_inferior): Likewise.  Use
	'%u'.
	(darwin_read_dyld_info): Likewise.
	(darwin_xfer_partial): Likewise.
	* exec.c (section_table_xfer_memory_partial): Likewise.
	(exec_xfer_partial): Likewise.
	* exec.h (section_table_xfer_memory_partial): Update
	declaration.
	* gnu-nat.c (gnu_xfer_memory): Likewise.  Call pulongest
	instead of plongest.
	(gnu_xfer_partial): Likewise.
	* ia64-hpux-nat.c (ia64_hpux_xfer_memory): Likewise.
	(ia64_hpux_xfer_solib_got): Likewise.
	(ia64_hpux_xfer_partial): Likewise.
	* ia64-linux-nat.c (ia64_linux_xfer_partial):
	* inf-ptrace.c (inf_ptrace_xfer_partial):
	* inf-ttrace.c (inf_ttrace_xfer_partial):
	* linux-nat.c (linux_xfer_siginfo): Likewise.
	(linux_nat_xfer_partial): Likewise.
	(spu_enumerate_spu_ids, linux_proc_xfer_spu): Likewise.
	(linux_nat_xfer_osdata, linux_xfer_partial): Likewise.
	* monitor.c (monitor_xfer_memory): Likewise.
	(monitor_xfer_partial): Likewise.
	* procfs.c (procfs_xfer_partial): Likewise.
	* record-full.c (record_full_xfer_partial): Likewise.
	(record_full_core_xfer_partial): Likewise.
	* remote-sim.c (gdbsim_xfer_memory): Likewise.  Call pulongest
	instead of plongest.
	(gdbsim_xfer_partial): Likewise.
	* remote.c (remote_xfer_partial): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	* rs6000-aix-tdep.h (rs6000_aix_ld_info_to_xml): Update
	declaration.
	* rs6000-nat.c (rs6000_xfer_partial): Likewise.
	(rs6000_xfer_shared_libraries): Likewise.
	* sol-thread.c (sol_thread_xfer_partial): Likewise.
	* sparc-nat.c (sparc_xfer_wcookie): Likewise.
	(sparc_xfer_partial): Likewise.
	* spu-linux-nat.c (spu_proc_xfer_spu): Likewise.
	(spu_xfer_partial): Likewise.
	* spu-multiarch.c (spu_xfer_partial): Likewise.
	* target.c (target_read_live_memory): Likewise.
	(memory_xfer_live_readonly_partial): Likewise.
	(memory_xfer_partial, memory_xfer_partial_1): Likewise.
	(target_xfer_partial, default_xfer_partial): Likewise.
	(current_xfer_partial): Likewise.
	* tracepoint.c (tfile_xfer_partial): Likewise.
	* windows-nat.c (windows_xfer_memory): Likewise.  Call
	pulongest instead of plongest.
	(windows_xfer_partial): Likewise.
	(windows_xfer_shared_libraries): Likewise.
2014-01-14 22:20:44 +08:00
Tom Tromey 70ba0933ad replace XMALLOC with XNEW
This replaces XMALLOC with XNEW, and removes XMALLOC.  The only
non-mechanical bit here was remembering to edit gdbarch.sh.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XMALLOC): Remove.
	* avr-tdep.c (avr_gdbarch_init): Use XNEW, not XMALLOC.
	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
	* cli-out.c (struct ui_out *): Likewise.
	* cli/cli-dump.c (add_dump_command): Likewise.
	(add_dump_command): Likewise.
	* complaints.c (get_complaints): Likewise.
	(find_complaint): Likewise.
	* dwarf2-frame.c (execute_cfa_program): Likewise.
	* dwarf2read.c (abbrev_table_read_table): Likewise.
	* gdbarch.sh: Likewise.
	* gdbarch.c: Rebuild.
	* inf-ttrace.c (inf_ttrace_add_page): Likewise.
	* interps.c (interp_new): Likewise.
	* lm32-tdep.c (lm32_gdbarch_init): Likewise.
	* m32r-tdep.c (m32r_gdbarch_init): Likewise.
	* mi/mi-console.c (mi_console_file_new): Likewise.
	* mi/mi-interp.c (mi_interpreter_init): Likewise.
	* mi/mi-out.c (mi_out_new): Likewise.
	* mi/mi-parse.c (mi_parse): Likewise.
	* microblaze-tdep.c (microblaze_gdbarch_init): Likewise.
	* moxie-tdep.c (moxie_gdbarch_init): Likewise.
	* observer.c (xalloc_observer_list_node): Likewise.
	* regcache.c (regcache_xmalloc_1): Likewise.
	* reggroups.c (reggroup_new): Likewise.
	(_initialize_reggroup): Likewise.
	* registry.c (register_data_with_cleanup): Likewise.
	* remote.c (remote_notif_stop_alloc_reply): Likewise.
	* ser-base.c (serial_ttystate): Likewise.
	* ser-mingw.c (make_pipe_state): Likewise.
	* ser-pipe.c (pipe_open): Likewise.
	* serial.c (serial_open): Likewise.
	* sh64-tdep.c (sh64_gdbarch_init): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-file.c (tui_file_new): Likewise.
	* tui/tui-out.c (tui_out_new): Likewise.
	* ui-file.c (mem_file_new): Likewise.
	* ui-out.c (push_level): Likewise.
	(make_cleanup_ui_out_end): Likewise.
	(append_header_to_list): Likewise.
	(ui_out_new): Likewise.
	* user-regs.c (user_reg_add_builtin): Likewise.
2014-01-13 07:31:28 -07:00
Pedro Alves 0000e5ccd8 Handle the case of a remote target supporting target side commands, but not on software breakpoints.
Although we can tell upfront whether a remote target supports target
side commands, we can only tell whether the target supports that in
combination with a given breakpoint kind (software, hardware,
watchpoints, etc.) when we go and try to insert such a breakpoint kind
the first time.  It's not desirable to make remote_insert_breakpoint
simply return -1 in this case, because if the breakpoint was set in a
shared library, insert_bp_location will assume that the breakpoint
insertion failed because the library wasn't mapped in.

insert_bp_location already handles errors/exceptions thrown from the
target_insert_xxx methods, exactly so the backend can tell the user
the detailed reason the insertion of hw breakpoints failed.  But, in
the case of software breakpoints, it discards the detailed error
message.

So the patch makes insert_bp_location use the error's message for SW
breakpoints too, and, introduces a NOT_SUPPORTED_ERROR error code so
that insert_bp_location doesn't confuse the error for failure due to a
shared library disappearing.

The result is:

(gdb) c
Warning:
Cannot insert breakpoint 2: Target doesn't support breakpoints that have target side commands.

2014-01-09  Pedro Alves  <palves@redhat.com>
	    Hui Zhu  <hui@codesourcery.com>

	PR gdb/16101
	* breakpoint.c (insert_bp_location): Rename hw_bp_err_string to
	bp_err_string.  Don't mark the location shlib_disabled if the
	error thrown wasn't a generic or memory error.  Catch errors
	thrown while inserting breakpoints in overlayed code.  Output
	error message of software breakpoints.
	* remote.c (remote_insert_breakpoint): If this breakpoint has
	target-side commands but this stub doesn't support Z0 packets,
	throw NOT_SUPPORTED_ERROR error.
	* exceptions.h (enum errors) <NOT_SUPPORTED_ERROR>: New error.
	* target.h (target_insert_breakpoint): Extend comment.
	(target_insert_hw_breakpoint): Add comment.
2014-01-09 18:33:45 +00:00
Pedro Alves b7ea362b02 [remote/gdbserver] Don't lose signals when reconnecting.
Currently, when GDB connects in all-stop mode, GDBserver always
responds to the status packet with a GDB_SIGNAL_TRAP, even if the
program is actually stopped for some other signal.

 (gdb) tar rem ...
 ...
 (gdb) c
 Program received signal SIGUSR1, User defined signal 1.
 (gdb) disconnect
 (gdb) tar rem ...
 (gdb) c

(Or a GDB crash instead of an explicit disconnect.)

This results in the program losing that signal on that last continue,
because gdb will tell the target to resume with no signal (to suppress
the GDB_SIGNAL_TRAP, due to 'handle SISGTRAP nopass'), and that will
actually suppress the real signal the program had stopped for
(SIGUSR1).  To fix that, I think we should make GDBserver report the
real signal the thread had stopped for in response to the status
packet:

 @item ?
 @cindex @samp{?} packet
 Indicate the reason the target halted.  The reply is the same as for
 step and continue.

But, that raises the question -- which thread are we reporting the
status for?  Due to how the RSP in all-stop works, we can only report
one status.  The status packet's response is a stop reply packet, so
it includes the thread identifier, so it's not a problem packet-wise.
However, GDBserver is currently always reporting the status for first
thread in the thread list, even though that may well not be the thread
that got the signal that caused the program to stop.  So the next
logical step would be to report the status for the
last_ptid/last_status thread (the last event reported to gdb), if it's
still around; and if not, fallback to some other thread.

There's an issue on the GDB side with that, though...

GDB currently always adds the thread reported in response to the
status query as the first thread in its list.  That means that if we
start with e.g.,

 (gdb) info threads
   3 Thread 1003 ...
 * 2 Thread 1002 ...
   1 Thread 1001 ...

And reconnect:

 (gdb) disconnect
 (gdb) tar rem ...

We end up with:

 (gdb) info threads
   3 Thread 1003 ...
   2 Thread 1001 ...
 * 1 Thread 1002 ...

Not a real big issue, but it's reasonably fixable, by having GDB
fetch/sync the thread list before fetching the status/'?', and then
using the status to select the right thread as current on the GDB
side.  Holes in the thread numbers are squashed before/after
reconnection (e.g., 2,3,5 becomes 1,2,3), but the order is preserved,
which I think is both good, and good enough.

However (yes, there's more...), the previous GDB that was connected
might have had gdbserver running in non-stop mode, or could have left
gdbserver doing disconnected tracing (which also forces non-stop), and
if the new gdb/connection is in all-stop mode, we can end up with more
than one thread with a signal to report back to gdb.  As we can only
report one thread/status (in the all-stop RSP variant; the non-stop
variant doesn't have this issue), we get to do what we do at every
other place we have this situation -- leave events we can't report
right now as pending, so that the next resume picks them up.

Note all this ammounts to a QoI change, within the existing framework.
There's really no RSP change here.

The only user visible change (other than that the signal is program is
stopped at isn't lost / is passed to the program), is in "info
program", that now can show the signal the program stopped for.  Of
course, the next resume will respect the pass/nopass setting for the
signal in question.  It'd be reasonable to have the initial connection
tell the user the program was stopped with a signal, similar to when
we load a core to debug, but I'm leaving that out for a future change.
I think we'll need to either change how handle_inferior_event & co
handle stop_soon, or maybe bypass them completely (like
fork-child.c:startup_inferior) for that.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (struct thread_info) <status_pending_p>: New field.
	* server.c (visit_actioned_threads, handle_pending_status): New
	function.
	(handle_v_cont): Factor out parts to ...
	(resume): ... this new function.  If in all-stop, and a thread
	being resumed has a pending status, report it without actually
	resuming.
	(myresume): Adjust to use the new 'resume' function.
	(clear_pending_status_callback, set_pending_status_callback)
	(find_status_pending_thread_callback): New functions.
	(handle_status): Handle the case of multiple threads having
	interesting statuses to report.  Report threads' real last signal
	instead of always reporting GDB_SIGNAL_TRAP.  Look for a thread
	with an interesting thread to report the status for, instead of
	always reporting the status of the first thread.

gdb/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_add_thread): Add threads silently if starting
	up.
	(remote_notice_new_inferior): If in all-stop, and starting up,
	don't call notice_new_inferior.
	(get_current_thread): New function, factored out from ...
	(add_current_inferior_and_thread): ... this.  Adjust.
	(remote_start_remote) <all-stop>: Fetch the thread list.  If we
	found any thread, then select the remote's current thread as GDB's
	current thread too.

gdb/testsuite/
2014-01-08  Pedro Alves  <palves@redhat.com>

	* gdb.threads/reconnect-signal.c: New file.
	* gdb.threads/reconnect-signal.exp: New file.
2014-01-08 18:55:51 +00:00
Honggyu Kim e261678878 Remove duplicated #include's from GDB
This patch simply removes duplicated #include statements in the gdb/
directory.  If there are two duplicated #include statements, this patch
keeps the first #include and removes the second.

Those duplicates have been found by using the checkincludes.pl tool from
the Linux kernel and double checked manually once again if the #include
statements are affected by #ifdef macros.

2014-01-06  Honggyu Kim  <hong.gyu.kim@lge.com>

	* ada-lang.c: Remove duplicated include statements.
	* alphabsd-nat.c: Ditto.
	* amd64-darwin-tdep.c: Ditto.
	* amd64fbsd-nat.c: Ditto.
	* auto-load.c: Ditto.
	* ax-gdb.c: Ditto.
	* breakpoint.c: Ditto.
	* dbxread.c: Ditto.
	* fork-child.c: Ditto.
	* gdb_usleep.c: Ditto.
	* i386-darwin-tdep.c: Ditto.
	* i386fbsd-nat.c: Ditto.
	* infcmd.c: Ditto.
	* inferior.c: Ditto.
	* jv-lang.c: Ditto.
	* linux-nat.c: Ditto.
	* linux-tdep.c: Ditto.
	* m68kbsd-nat.c: Ditto.
	* m68klinux-nat.c: Ditto.
	* microblaze-tdep.c: Ditto.
	* mips-linux-tdep.c: Ditto.
	* mn10300-tdep.c: Ditto.
	* nto-tdep.c: Ditto.
	* opencl-lang.c: Ditto.
	* osdata.c: Ditto.
	* printcmd.c: Ditto.
	* regcache.c: Ditto.
	* remote-m32r-sdi.c: Ditto.
	* remote.c: Ditto.
	* symfile.c: Ditto.
	* symtab.c: Ditto.
	* tilegx-linux-nat.c: Ditto.
	* tilegx-tdep.c: Ditto.
	* tracepoint.c: Ditto.
	* valops.c: Ditto.
	* vaxbsd-nat.c: Ditto.
	* windows-nat.c: Ditto.
	* xtensa-tdep.c: Ditto.
2014-01-07 14:14:30 -02:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Pedro Alves 0fdf84ca4b Handle 'k' packet TARGET_CLOSE_ERROR gracefully.
Remote servers may cut the connection abruptly since they are not
required to reply to a 'k' (Kill) packet sent from GDB.

This patch addresses any issues arising from such scenario, which
leads to a GDB internal error due to an attempt to pop the target more
than once.  With the patch, this failure is handled gracefully.

Here's the GDB backtrace Maciej got running the testsuite against
QEMU.  Full paths edited out for brevity.

#0  0x55573430 in __kernel_vsyscall ()
#1  0x557a2951 in raise () from /lib32/libc.so.6
#2  0x557a5d82 in abort () from /lib32/libc.so.6
#3  0x0826e2e4 in dump_core ()
    at .../gdb/utils.c:635
#4  0x0826e5b6 in internal_vproblem (problem=0x85200c0,
    file=0x8416be8 ".../gdb/target.c", line=2861,
    fmt=0x84174ac "could not find a target to follow mourn inferior",
    ap=0xffa4796c "\f")
    at .../gdb/utils.c:804
#5  0x0826e5fb in internal_verror (
    file=0x8416be8 ".../gdb/target.c", line=2861,
    fmt=0x84174ac "could not find a target to follow mourn inferior",
    ap=0xffa4796c "\f")
    at .../gdb/utils.c:820
#6  0x0826e633 in internal_error (
    file=0x8416be8 ".../gdb/target.c", line=2861,
    string=0x84174ac "could not find a target to follow mourn inferior")
    at .../gdb/utils.c:830
#7  0x081b4ad0 in target_mourn_inferior ()
    at .../gdb/target.c:2861
#8  0x08082283 in remote_kill (ops=0x85245e0)
    at .../gdb/remote.c:7840
#9  0x081b06d1 in target_kill ()
    at .../gdb/target.c:486
#10 0x081b42f6 in dispose_inferior (inf=0xa501c60, args=0x0)
    at .../gdb/target.c:2570
#11 0x08290cfc in iterate_over_inferiors (
    callback=0x81b42af <dispose_inferior>, data=0x0)
    at .../gdb/inferior.c:396
#12 0x081b435a in target_preopen (from_tty=1)
    at .../gdb/target.c:2591
#13 0x0807c2c6 in remote_open_1 (name=0xa5538b6 "localhost:1237", from_tty=1,
    target=0x85245e0, extended_p=0)
    at .../gdb/remote.c:4292
#14 0x0807b7a8 in remote_open (name=0xa5538b6 "localhost:1237", from_tty=1)
    at .../gdb/remote.c:3655
#15 0x080a23d4 in do_cfunc (c=0xa464f30, args=0xa5538b6 "localhost:1237",
    from_tty=1)
    at .../gdb/cli/cli-decode.c:107
#16 0x080a4c3b in cmd_func (cmd=0xa464f30, args=0xa5538b6 "localhost:1237",
    from_tty=1)
    at .../gdb/cli/cli-decode.c:1882
#17 0x0826bebf in execute_command (p=0xa5538c3 "7", from_tty=1)
    at .../gdb/top.c:467
#18 0x08193f2d in command_handler (command=0xa5538a8 "")
    at .../gdb/event-top.c:435
#19 0x08194463 in command_line_handler (
    rl=0xa778198 "target remote localhost:1237")
    at .../gdb/event-top.c:633
#20 0x082ba92b in rl_callback_read_char ()
    at .../readline/callback.c:220
#21 0x08193adf in rl_callback_read_char_wrapper (client_data=0x0)
    at .../gdb/event-top.c:164
#22 0x08193e57 in stdin_event_handler (error=0, client_data=0x0)
    at .../gdb/event-top.c:375
#23 0x08192f29 in handle_file_event (data=...)
    at .../gdb/event-loop.c:768
#24 0x0819266a in process_event ()
    at .../gdb/event-loop.c:342
#25 0x08192708 in gdb_do_one_event ()
    at .../gdb/event-loop.c:394
#26 0x08192781 in start_event_loop ()
    at .../gdb/event-loop.c:431
#27 0x08193b08 in cli_command_loop (data=0x0)
    at .../gdb/event-top.c:179
#28 0x0818bc26 in current_interp_command_loop ()
    at .../gdb/interps.c:327
#29 0x0818c4e5 in captured_command_loop (data=0x0)
    at .../gdb/main.c:267
#30 0x0818a37f in catch_errors (func=0x818c4d0 <captured_command_loop>,
    func_args=0x0, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
    at .../gdb/exceptions.c:524
#31 0x0818d736 in captured_main (data=0xffa47f10)
    at .../gdb/main.c:1067
#32 0x0818a37f in catch_errors (func=0x818c723 <captured_main>,
    func_args=0xffa47f10, errstring=0x8402108 "", mask=RETURN_MASK_ALL)
    at .../gdb/exceptions.c:524
#33 0x0818d76c in gdb_main (args=0xffa47f10)
    at .../gdb/main.c:1076
#34 0x0804dd1b in main (argc=5, argv=0xffa47fd4)
    at .../gdb/gdb.c:34

The corresponding gdb.log excerpt:

(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (u9)
cont
Continuing.

Breakpoint 1, break1 () at .../gdb/testsuite/gdb.base/bitfields.c:44
44	}
(gdb) PASS: gdb.base/bitfields.exp: continuing to break1 #9
print flags
$10 = {uc = 0 '\000', s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1 '\001'}
(gdb) PASS: gdb.base/bitfields.exp: bitfield uniqueness (sc)
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break2
Breakpoint 2 at 0x85f8: file .../gdb/testsuite/gdb.base/bitfields.c, line 48.
(gdb) entering gdb_reload
target remote localhost:1235
A program is being debugged already.  Kill it? (y or n) y
Remote connection closed
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) ^Ccontinue
Please answer y or n.
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) Resyncing due to internal error.
n
.../gdb/target.c:2861: internal-error: could not find a target to follow mourn inferior
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
Command aborted.
(gdb) print/x flags
$11 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #1
cont
The program is not being run.
(gdb) FAIL: gdb.base/bitfields.exp: continuing to break2 (the program is no longer running)
print/x flags
$12 = {uc = 0x0, s1 = 0x0, u1 = 0x0, s2 = 0x0, u2 = 0x0, s3 = 0x0, u3 = 0x0, s9 = 0x0, u9 = 0x0, sc = 0x0}
(gdb) FAIL: gdb.base/bitfields.exp: bitfield containment #2
delete breakpoints
Delete all breakpoints? (y or n) y
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break break3
Breakpoint 3 at 0x8604: file .../gdb/testsuite/gdb.base/bitfields.c, line 52.
(gdb) entering gdb_reload
target remote localhost:1236
Remote debugging using localhost:1236
Reading symbols from .../lib/ld-linux.so.3...done.
Loaded symbols for .../lib/ld-linux.so.3
0x41001b80 in _start () from .../lib/ld-linux.so.3
(gdb) continue
Continuing.

Breakpoint 3, break3 () at .../gdb/testsuite/gdb.base/bitfields.c:52
52	}
(gdb) print flags
$13 = {uc = 0 '\000', s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0 '\000'}
(gdb) PASS: gdb.base/bitfields.exp: unsigned bitfield ranges

gdb/
2013-12-02  Pedro Alves  <pedro@codesourcery.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

	* remote.c (putpkt_for_catch_errors): Remove function.
	(remote_kill): Handle TARGET_CLOSE_ERROR from the kill packet
	gracefully.
2013-12-02 10:42:02 +00:00
Yao Qi d9c4392818 Fix typo "checksm"
Fix typo "checksm".

gdb:

2013-11-30  Yao Qi  <yao@codesourcery.com>

	* remote.c (getpkt_or_notif_sane_1): Fix typo "checksm".
2013-11-30 11:17:16 +08:00
Pedro Alves 8b4f3082d8 Plug target side conditions and commands leaks.
The memory management of bp_location->target_info.conditions|tcommands
is currently a little fragile.  If the target reports support for
target conditions or commands, and then target side breakpoint support
is disabled, or some error is thrown before remote_add_target_side_XXX
is called, we'll leak these lists.  This patch makes us free these
lists when the locations are deleted, and also, just before recreating
the commands|conditions lists.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-11-29  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (build_target_condition_list): Release previous
	conditions.
	(build_target_command_list): Release previous commands.
	(bp_location_dtor): Release target conditions and commands.
	* remote.c (remote_add_target_side_condition): Don't release
	conditions.
	(remote_add_target_side_commands): Don't release commands.
2013-11-29 14:50:26 +00:00
Tom Tromey 53ce3c3929 remove gdb_stat.h
This patch is purely mechanical.  It removes gdb_stat.h and changes
the code to use sys/stat.h.

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_stat.h: Remove.
	* ada-lang.c: Use sys/stat.h, not gdb_stat.h.
	* common/filestuff.c: Use sys/stat.h, not gdb_stat.h.
	* common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h.
	* corefile.c: Use sys/stat.h, not gdb_stat.h.
	* ctf.c: Use sys/stat.h, not gdb_stat.h.
	* darwin-nat.c: Use sys/stat.h, not gdb_stat.h.
	* dbxread.c: Use sys/stat.h, not gdb_stat.h.
	* dwarf2read.c: Use sys/stat.h, not gdb_stat.h.
	* exec.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h.
	* gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h.
	* inf-child.c: Use sys/stat.h, not gdb_stat.h.
	* jit.c: Use sys/stat.h, not gdb_stat.h.
	* linux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h.
	* main.c: Use sys/stat.h, not gdb_stat.h.
	* mdebugread.c: Use sys/stat.h, not gdb_stat.h.
	* mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h.
	* nto-tdep.c: Use sys/stat.h, not gdb_stat.h.
	* objfiles.c: Use sys/stat.h, not gdb_stat.h.
	* procfs.c: Use sys/stat.h, not gdb_stat.h.
	* remote-fileio.c: Use sys/stat.h, not gdb_stat.h.
	* remote-mips.c: Use sys/stat.h, not gdb_stat.h.
	* remote.c: Use sys/stat.h, not gdb_stat.h.
	* rs6000-nat.c: Use sys/stat.h, not gdb_stat.h.
	* sol-thread.c: Use sys/stat.h, not gdb_stat.h.
	* solib-spu.c: Use sys/stat.h, not gdb_stat.h.
	* source.c: Use sys/stat.h, not gdb_stat.h.
	* symfile.c: Use sys/stat.h, not gdb_stat.h.
	* symmisc.c: Use sys/stat.h, not gdb_stat.h.
	* symtab.c: Use sys/stat.h, not gdb_stat.h.
	* top.c: Use sys/stat.h, not gdb_stat.h.
	* xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-18 13:29:02 -07:00
Tom Tromey 0e9f083f4c remove gdb_string.h
This removes gdb_string.h.  This patch is purely mechanical.  I
created it by running the two commands:

    git rm common/gdb_string.h
    perl -pi -e's/"gdb_string.h"/<string.h>/;'  *.[chyl] */*.[chyl]

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_string.h: Remove.
	* aarch64-tdep.c: Use string.h, not gdb_string.h.
	* ada-exp.y: Use string.h, not gdb_string.h.
	* ada-lang.c: Use string.h, not gdb_string.h.
	* ada-lex.l: Use string.h, not gdb_string.h.
	* ada-typeprint.c: Use string.h, not gdb_string.h.
	* ada-valprint.c: Use string.h, not gdb_string.h.
	* aix-thread.c: Use string.h, not gdb_string.h.
	* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
	* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
	* alpha-nat.c: Use string.h, not gdb_string.h.
	* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
	* alpha-tdep.c: Use string.h, not gdb_string.h.
	* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
	* amd64-linux-nat.c: Use string.h, not gdb_string.h.
	* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
	* amd64-nat.c: Use string.h, not gdb_string.h.
	* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
	* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
	* arch-utils.c: Use string.h, not gdb_string.h.
	* arm-linux-nat.c: Use string.h, not gdb_string.h.
	* arm-linux-tdep.c: Use string.h, not gdb_string.h.
	* arm-tdep.c: Use string.h, not gdb_string.h.
	* arm-wince-tdep.c: Use string.h, not gdb_string.h.
	* armbsd-tdep.c: Use string.h, not gdb_string.h.
	* armnbsd-nat.c: Use string.h, not gdb_string.h.
	* armnbsd-tdep.c: Use string.h, not gdb_string.h.
	* armobsd-tdep.c: Use string.h, not gdb_string.h.
	* avr-tdep.c: Use string.h, not gdb_string.h.
	* ax-gdb.c: Use string.h, not gdb_string.h.
	* ax-general.c: Use string.h, not gdb_string.h.
	* bcache.c: Use string.h, not gdb_string.h.
	* bfin-tdep.c: Use string.h, not gdb_string.h.
	* breakpoint.c: Use string.h, not gdb_string.h.
	* build-id.c: Use string.h, not gdb_string.h.
	* buildsym.c: Use string.h, not gdb_string.h.
	* c-exp.y: Use string.h, not gdb_string.h.
	* c-lang.c: Use string.h, not gdb_string.h.
	* c-typeprint.c: Use string.h, not gdb_string.h.
	* c-valprint.c: Use string.h, not gdb_string.h.
	* charset.c: Use string.h, not gdb_string.h.
	* cli-out.c: Use string.h, not gdb_string.h.
	* cli/cli-cmds.c: Use string.h, not gdb_string.h.
	* cli/cli-decode.c: Use string.h, not gdb_string.h.
	* cli/cli-dump.c: Use string.h, not gdb_string.h.
	* cli/cli-interp.c: Use string.h, not gdb_string.h.
	* cli/cli-logging.c: Use string.h, not gdb_string.h.
	* cli/cli-script.c: Use string.h, not gdb_string.h.
	* cli/cli-setshow.c: Use string.h, not gdb_string.h.
	* cli/cli-utils.c: Use string.h, not gdb_string.h.
	* coffread.c: Use string.h, not gdb_string.h.
	* common/common-utils.c: Use string.h, not gdb_string.h.
	* common/filestuff.c: Use string.h, not gdb_string.h.
	* common/linux-procfs.c: Use string.h, not gdb_string.h.
	* common/linux-ptrace.c: Use string.h, not gdb_string.h.
	* common/signals.c: Use string.h, not gdb_string.h.
	* common/vec.h: Use string.h, not gdb_string.h.
	* core-regset.c: Use string.h, not gdb_string.h.
	* corefile.c: Use string.h, not gdb_string.h.
	* corelow.c: Use string.h, not gdb_string.h.
	* cp-abi.c: Use string.h, not gdb_string.h.
	* cp-support.c: Use string.h, not gdb_string.h.
	* cp-valprint.c: Use string.h, not gdb_string.h.
	* cris-tdep.c: Use string.h, not gdb_string.h.
	* d-lang.c: Use string.h, not gdb_string.h.
	* dbxread.c: Use string.h, not gdb_string.h.
	* dcache.c: Use string.h, not gdb_string.h.
	* demangle.c: Use string.h, not gdb_string.h.
	* dicos-tdep.c: Use string.h, not gdb_string.h.
	* disasm.c: Use string.h, not gdb_string.h.
	* doublest.c: Use string.h, not gdb_string.h.
	* dsrec.c: Use string.h, not gdb_string.h.
	* dummy-frame.c: Use string.h, not gdb_string.h.
	* dwarf2-frame.c: Use string.h, not gdb_string.h.
	* dwarf2loc.c: Use string.h, not gdb_string.h.
	* dwarf2read.c: Use string.h, not gdb_string.h.
	* elfread.c: Use string.h, not gdb_string.h.
	* environ.c: Use string.h, not gdb_string.h.
	* eval.c: Use string.h, not gdb_string.h.
	* event-loop.c: Use string.h, not gdb_string.h.
	* exceptions.c: Use string.h, not gdb_string.h.
	* exec.c: Use string.h, not gdb_string.h.
	* expprint.c: Use string.h, not gdb_string.h.
	* f-exp.y: Use string.h, not gdb_string.h.
	* f-lang.c: Use string.h, not gdb_string.h.
	* f-typeprint.c: Use string.h, not gdb_string.h.
	* f-valprint.c: Use string.h, not gdb_string.h.
	* fbsd-nat.c: Use string.h, not gdb_string.h.
	* findcmd.c: Use string.h, not gdb_string.h.
	* findvar.c: Use string.h, not gdb_string.h.
	* fork-child.c: Use string.h, not gdb_string.h.
	* frame.c: Use string.h, not gdb_string.h.
	* frv-linux-tdep.c: Use string.h, not gdb_string.h.
	* frv-tdep.c: Use string.h, not gdb_string.h.
	* gdb.c: Use string.h, not gdb_string.h.
	* gdb_bfd.c: Use string.h, not gdb_string.h.
	* gdbarch.c: Use string.h, not gdb_string.h.
	* gdbtypes.c: Use string.h, not gdb_string.h.
	* gnu-nat.c: Use string.h, not gdb_string.h.
	* gnu-v2-abi.c: Use string.h, not gdb_string.h.
	* gnu-v3-abi.c: Use string.h, not gdb_string.h.
	* go-exp.y: Use string.h, not gdb_string.h.
	* go-lang.c: Use string.h, not gdb_string.h.
	* go32-nat.c: Use string.h, not gdb_string.h.
	* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
	* hppa-linux-nat.c: Use string.h, not gdb_string.h.
	* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
	* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
	* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
	* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
	* i386-linux-nat.c: Use string.h, not gdb_string.h.
	* i386-linux-tdep.c: Use string.h, not gdb_string.h.
	* i386-nto-tdep.c: Use string.h, not gdb_string.h.
	* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
	* i386-tdep.c: Use string.h, not gdb_string.h.
	* i386bsd-tdep.c: Use string.h, not gdb_string.h.
	* i386gnu-nat.c: Use string.h, not gdb_string.h.
	* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
	* i386obsd-tdep.c: Use string.h, not gdb_string.h.
	* i387-tdep.c: Use string.h, not gdb_string.h.
	* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
	* ia64-linux-nat.c: Use string.h, not gdb_string.h.
	* inf-child.c: Use string.h, not gdb_string.h.
	* inf-ptrace.c: Use string.h, not gdb_string.h.
	* inf-ttrace.c: Use string.h, not gdb_string.h.
	* infcall.c: Use string.h, not gdb_string.h.
	* infcmd.c: Use string.h, not gdb_string.h.
	* inflow.c: Use string.h, not gdb_string.h.
	* infrun.c: Use string.h, not gdb_string.h.
	* interps.c: Use string.h, not gdb_string.h.
	* iq2000-tdep.c: Use string.h, not gdb_string.h.
	* irix5-nat.c: Use string.h, not gdb_string.h.
	* jv-exp.y: Use string.h, not gdb_string.h.
	* jv-lang.c: Use string.h, not gdb_string.h.
	* jv-typeprint.c: Use string.h, not gdb_string.h.
	* jv-valprint.c: Use string.h, not gdb_string.h.
	* language.c: Use string.h, not gdb_string.h.
	* linux-fork.c: Use string.h, not gdb_string.h.
	* linux-nat.c: Use string.h, not gdb_string.h.
	* lm32-tdep.c: Use string.h, not gdb_string.h.
	* m2-exp.y: Use string.h, not gdb_string.h.
	* m2-typeprint.c: Use string.h, not gdb_string.h.
	* m32c-tdep.c: Use string.h, not gdb_string.h.
	* m32r-linux-nat.c: Use string.h, not gdb_string.h.
	* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
	* m32r-rom.c: Use string.h, not gdb_string.h.
	* m32r-tdep.c: Use string.h, not gdb_string.h.
	* m68hc11-tdep.c: Use string.h, not gdb_string.h.
	* m68k-tdep.c: Use string.h, not gdb_string.h.
	* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
	* m68klinux-nat.c: Use string.h, not gdb_string.h.
	* m68klinux-tdep.c: Use string.h, not gdb_string.h.
	* m88k-tdep.c: Use string.h, not gdb_string.h.
	* macrocmd.c: Use string.h, not gdb_string.h.
	* main.c: Use string.h, not gdb_string.h.
	* mdebugread.c: Use string.h, not gdb_string.h.
	* mem-break.c: Use string.h, not gdb_string.h.
	* memattr.c: Use string.h, not gdb_string.h.
	* memory-map.c: Use string.h, not gdb_string.h.
	* mep-tdep.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
	* mi/mi-cmds.c: Use string.h, not gdb_string.h.
	* mi/mi-console.c: Use string.h, not gdb_string.h.
	* mi/mi-getopt.c: Use string.h, not gdb_string.h.
	* mi/mi-interp.c: Use string.h, not gdb_string.h.
	* mi/mi-main.c: Use string.h, not gdb_string.h.
	* mi/mi-parse.c: Use string.h, not gdb_string.h.
	* microblaze-rom.c: Use string.h, not gdb_string.h.
	* microblaze-tdep.c: Use string.h, not gdb_string.h.
	* mingw-hdep.c: Use string.h, not gdb_string.h.
	* minidebug.c: Use string.h, not gdb_string.h.
	* minsyms.c: Use string.h, not gdb_string.h.
	* mips-irix-tdep.c: Use string.h, not gdb_string.h.
	* mips-linux-tdep.c: Use string.h, not gdb_string.h.
	* mips-tdep.c: Use string.h, not gdb_string.h.
	* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsread.c: Use string.h, not gdb_string.h.
	* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
	* mn10300-tdep.c: Use string.h, not gdb_string.h.
	* monitor.c: Use string.h, not gdb_string.h.
	* moxie-tdep.c: Use string.h, not gdb_string.h.
	* mt-tdep.c: Use string.h, not gdb_string.h.
	* nbsd-tdep.c: Use string.h, not gdb_string.h.
	* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
	* nto-procfs.c: Use string.h, not gdb_string.h.
	* nto-tdep.c: Use string.h, not gdb_string.h.
	* objc-lang.c: Use string.h, not gdb_string.h.
	* objfiles.c: Use string.h, not gdb_string.h.
	* opencl-lang.c: Use string.h, not gdb_string.h.
	* osabi.c: Use string.h, not gdb_string.h.
	* osdata.c: Use string.h, not gdb_string.h.
	* p-exp.y: Use string.h, not gdb_string.h.
	* p-lang.c: Use string.h, not gdb_string.h.
	* p-typeprint.c: Use string.h, not gdb_string.h.
	* parse.c: Use string.h, not gdb_string.h.
	* posix-hdep.c: Use string.h, not gdb_string.h.
	* ppc-linux-nat.c: Use string.h, not gdb_string.h.
	* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
	* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
	* printcmd.c: Use string.h, not gdb_string.h.
	* procfs.c: Use string.h, not gdb_string.h.
	* prologue-value.c: Use string.h, not gdb_string.h.
	* python/py-auto-load.c: Use string.h, not gdb_string.h.
	* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
	* ravenscar-thread.c: Use string.h, not gdb_string.h.
	* regcache.c: Use string.h, not gdb_string.h.
	* registry.c: Use string.h, not gdb_string.h.
	* remote-fileio.c: Use string.h, not gdb_string.h.
	* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
	* remote-mips.c: Use string.h, not gdb_string.h.
	* remote-sim.c: Use string.h, not gdb_string.h.
	* remote.c: Use string.h, not gdb_string.h.
	* reverse.c: Use string.h, not gdb_string.h.
	* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
	* ser-base.c: Use string.h, not gdb_string.h.
	* ser-go32.c: Use string.h, not gdb_string.h.
	* ser-mingw.c: Use string.h, not gdb_string.h.
	* ser-pipe.c: Use string.h, not gdb_string.h.
	* ser-tcp.c: Use string.h, not gdb_string.h.
	* ser-unix.c: Use string.h, not gdb_string.h.
	* serial.c: Use string.h, not gdb_string.h.
	* sh-tdep.c: Use string.h, not gdb_string.h.
	* sh64-tdep.c: Use string.h, not gdb_string.h.
	* shnbsd-tdep.c: Use string.h, not gdb_string.h.
	* skip.c: Use string.h, not gdb_string.h.
	* sol-thread.c: Use string.h, not gdb_string.h.
	* solib-dsbt.c: Use string.h, not gdb_string.h.
	* solib-frv.c: Use string.h, not gdb_string.h.
	* solib-osf.c: Use string.h, not gdb_string.h.
	* solib-spu.c: Use string.h, not gdb_string.h.
	* solib-target.c: Use string.h, not gdb_string.h.
	* solib.c: Use string.h, not gdb_string.h.
	* somread.c: Use string.h, not gdb_string.h.
	* source.c: Use string.h, not gdb_string.h.
	* sparc-nat.c: Use string.h, not gdb_string.h.
	* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
	* sparc-tdep.c: Use string.h, not gdb_string.h.
	* sparc64-tdep.c: Use string.h, not gdb_string.h.
	* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* spu-linux-nat.c: Use string.h, not gdb_string.h.
	* spu-multiarch.c: Use string.h, not gdb_string.h.
	* spu-tdep.c: Use string.h, not gdb_string.h.
	* stabsread.c: Use string.h, not gdb_string.h.
	* stack.c: Use string.h, not gdb_string.h.
	* std-regs.c: Use string.h, not gdb_string.h.
	* symfile.c: Use string.h, not gdb_string.h.
	* symmisc.c: Use string.h, not gdb_string.h.
	* symtab.c: Use string.h, not gdb_string.h.
	* target.c: Use string.h, not gdb_string.h.
	* thread.c: Use string.h, not gdb_string.h.
	* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
	* tilegx-tdep.c: Use string.h, not gdb_string.h.
	* top.c: Use string.h, not gdb_string.h.
	* tracepoint.c: Use string.h, not gdb_string.h.
	* tui/tui-command.c: Use string.h, not gdb_string.h.
	* tui/tui-data.c: Use string.h, not gdb_string.h.
	* tui/tui-disasm.c: Use string.h, not gdb_string.h.
	* tui/tui-file.c: Use string.h, not gdb_string.h.
	* tui/tui-layout.c: Use string.h, not gdb_string.h.
	* tui/tui-out.c: Use string.h, not gdb_string.h.
	* tui/tui-regs.c: Use string.h, not gdb_string.h.
	* tui/tui-source.c: Use string.h, not gdb_string.h.
	* tui/tui-stack.c: Use string.h, not gdb_string.h.
	* tui/tui-win.c: Use string.h, not gdb_string.h.
	* tui/tui-windata.c: Use string.h, not gdb_string.h.
	* tui/tui-winsource.c: Use string.h, not gdb_string.h.
	* typeprint.c: Use string.h, not gdb_string.h.
	* ui-file.c: Use string.h, not gdb_string.h.
	* ui-out.c: Use string.h, not gdb_string.h.
	* user-regs.c: Use string.h, not gdb_string.h.
	* utils.c: Use string.h, not gdb_string.h.
	* v850-tdep.c: Use string.h, not gdb_string.h.
	* valarith.c: Use string.h, not gdb_string.h.
	* valops.c: Use string.h, not gdb_string.h.
	* valprint.c: Use string.h, not gdb_string.h.
	* value.c: Use string.h, not gdb_string.h.
	* varobj.c: Use string.h, not gdb_string.h.
	* vax-tdep.c: Use string.h, not gdb_string.h.
	* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
	* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
	* windows-nat.c: Use string.h, not gdb_string.h.
	* xcoffread.c: Use string.h, not gdb_string.h.
	* xml-support.c: Use string.h, not gdb_string.h.
	* xstormy16-tdep.c: Use string.h, not gdb_string.h.
	* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-18 13:29:00 -07:00
Tom Tromey 52554a0e32 constify to_detach
This patch constifies the target_ops method to_detach.

This is a small cleanup, but also, I think, a bug-prevention fix,
since gdb already acts as if the "args" argument here was const.

In particular, top.c:quit_force calls kill_or_detach via
iterate_over_inferiors.  kill_or_detach calls target_detach, passing
the same argument each time.  So, if one of these methods was not
const-correct, then kill_or_detach would change its behavior in a
strange way.

I could not build every target I modified in this patch.  I've
inspected them all by hand, though.  Many targets do not use the
"args" parameter; a couple pass it to atoi; and a few pass it on to
the to_detach method of the target beneath.  The only code that
required a real change was in linux-nat.c, and that only needed the
introduction of a temporary variable for const-correctness.

2013-11-08  Tom Tromey  <tromey@redhat.com>

	* aix-thread.c (aix_thread_detach): Update.
	* corelow.c (core_detach): Update.
	* darwin-nat.c (darwin_detach): Update.
	* dec-thread.c (dec_thread_detach): Update.
	* gnu-nat.c (gnu_detach): Update.
	* go32-nat.c (go32_detach): Update.
	* inf-ptrace.c (inf_ptrace_detach): Update.
	* inf-ttrace.c (inf_ttrace_detach): Update.
	* linux-fork.c (linux_fork_detach): Update.
	* linux-fork.h (linux_fork_detach): Update.
	* linux-nat.c (linux_nat_detach): Update.  Introduce "tem"
	local for const-correctness.
	* linux-thread-db.c (thread_db_detach): Update.
	* monitor.c (monitor_detach): Update.
	* nto-procfs.c (procfs_detach): Update.
	* procfs.c (procfs_detach): Update.
	* record.c (record_detach): Update.
	* record.h (record_detach): Update.
	* remote-m32r-sdi.c (m32r_detach): Update.
	* remote-mips.c (mips_detach): Update.
	* remote-sim.c (gdbsim_detach): Update.
	* remote.c (remote_detach_1, remote_detach)
	(extended_remote_detach): Update.
	* sol-thread.c (sol_thread_detach): Update.
	* target.c (target_detach): Make "args" const.
	(init_dummy_target): Update.
	* target.h (struct target_ops) <to_detach>: Make argument const.
	(target_detach): Likewise.
	* windows-nat.c (windows_detach): Update.
2013-11-08 09:38:41 -07:00
Yao Qi 6c177e28ea Send qXfer:traceframe-info:read when traceframe is selected.
When I do 'si', I find many 'qXfer:traceframe-info:read' packets are sent,
which is not necessary.  It slows down the single step.
(gdb) si
Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::
Sending packet: $Z0,80483c7,1#b4...Packet received: OK
Sending packet: $Z0,4ce5b6b0,1#6e...Packet received: OK
Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
Sending packet: $vCont;s:p1b15.1b15;c#20...Packet received: T0505:44efffbf;04:44efffbf;08:d1830408;thread:p1b15.1b15;core:3;
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $mbfffef40,40#c0...Packet received: d183040878efffbf2e840408030000000000a040030000000500000070efffbf07000000010000004984040807000000030000000500000000000000b396e84c
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $z0,80483c7,1#d4...Packet received: OK
Sending packet: $z0,4ce5b6b0,1#8e...Packet received: OK
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01
Sending packet: $qXfer:traceframe-info:read::0,fff#0b...Packet received: E01

This problem was introduced by this patch
(https://sourceware.org/ml/gdb-patches/2013-04/msg00000.html), in
which get_traceframe_number is not checked before calling
traceframe_available_memory.  This patch moves the check to
remote_traceframe_info, say, if GDB doesn't have traceframe selected, GDB
doesn't need to send qXfer:traceframe-info:read packets.

With this patch applied, there is no qXfer:traceframe-info:read sent
out and single step is speed up a little bit.

Here is the experiment I did:

	   Num of single step	Original	Patched

single-step cpu_time 10000	8.08		7.57
single-step cpu_time 20000	16.23		14.23
single-step cpu_time 30000	24.19		21.59
single-step cpu_time 40000	32.49		28.0
single-step wall_time 10000	14.1974210739	13.2641420364
single-step wall_time 20000	28.5278921127	25.0541369915
single-step wall_time 30000	42.5864038467	38.0038759708
single-step wall_time 40000	57.2107698917	49.2350611687
single-step vmsize 10000	16128		16388
single-step vmsize 20000	16128		16388
single-step vmsize 30000	16260		16520
single-step vmsize 40000	16444		16704

The patch is tested on x86_64-linux.

gdb:

2013-10-24  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_traceframe_info): Return early if
	traceframe is not selected.
2013-10-25 14:03:01 +00:00
Pedro Alves 3a09da4102 remote: Map invalid signal numbers to GDB_SIGNAL_UNKNOWN.
I realized that remote.c is not validating input here.  Currently, if
a remote stub sends in an invalid signal number (or put another way,
if a future stub sends a new signal an old GDB doesn't know about),
GDB will do out of bounds accesses in the
signal_pass/signal_stop/signal_program arrays.  It'll probably be a
long while before we add another signal number (and buggy stubs should
just be fixed), but can't hurt to be defensive.

Tested on x86_64 Fedora 17, native gdbserver.

gdb/
2013-10-22  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_parse_stop_reply) <'T'/'S'/'X' replies>: Map
	invalid signal numbers to GDB_SIGNAL_UNKNOWN.
2013-10-25 14:02:59 +00:00
Yao Qi 340e3c99cb gdb/
Typo fix in my previous commit.
2013-10-11 03:01:09 +00:00
Yao Qi bcc75809a4 gdb/
* remote.c (discard_pending_stop_replies_in_queue): Update
	declaration.
	(struct stop_reply) <rs>: New field.
	(remove_stop_reply_of_remote_state): New function.
	(discard_pending_stop_replies_in_queue): Add parameter 'rs'.
	Callers update.  Pass remove_stop_reply_of_remote_state to
	QUEUE_iterate.
	(remote_parse_stop_reply): Initialize field 'rs'.
2013-10-11 02:54:44 +00:00
Yao Qi f48ff2a7d3 Move pending_event to remote_notif_state.
This patch moves pending_event to remote_notif_state.  All pending
events are destroyed in remote_notif_state_xfree.  However,
discard_pending_stop_replies release pending event too, so the pending
event of stop notification is released twice, we need some refactor
here.  We add a new function discard_pending_stop_replies_in_queue
which only discard events in stop_reply_queue, and let
remote_notif_state_xfree release pending event for all notif_client.

After this change, discard_pending_stop_replies is only attached to
ifnerior_exit observer, so the INF can't be NULL any more.  The
NULL checking is removed too.

gdb:

2013-10-04  Yao Qi  <yao@codesourcery.com>

	* remote-notif.h (REMOTE_NOTIF_ID): New enum.
	(struct notif_client) <pending_event>: Moved
	to struct remote_notif_state.
	<id>: New field.
	(struct remote_notif_state) <pending_event>: New field.
	(notif_event_xfree): Declare.
	* remote-notif.c (handle_notification): Adjust.
	(notif_event_xfree): New function.
	(do_notif_event_xfree): Call notif_event_xfree.
	(remote_notif_state_xfree): Call notif_event_xfree to free
	each element in field pending_event.
	* remote.c (discard_pending_stop_replies): Remove declaration.
	(discard_pending_stop_replies_in_queue): Declare.
	(remote_close): Call discard_pending_stop_replies_in_queue
	instead of discard_pending_stop_replies.
	(remote_start_remote): Adjust.
	(stop_reply_xfree): Call notif_event_xfree.
	(notif_client_stop): Adjust initialization.
	(remote_notif_remove_all): Rename it to ...
	(remove_stop_reply_for_inferior): ... this.  Update comments.
	Don't check INF is NULL.
	(discard_pending_stop_replies): Return early if notif_state is
	NULL.  Adjust.  Don't check INF is NULL.
	(remote_notif_get_pending_events): Adjust.
 	(discard_pending_stop_replies_in_queue): New function.
	(remote_wait_ns): Likewise.
2013-10-04 07:42:06 +00:00
Yao Qi 5965e02896 Move notif_queue and remote_async_get_pending_events_token to remote_state
This patch also removes notif_xfree, and don't pass it QUEUE_alloc, because
we don't have to free notif_client when the remote_notif_state is freed.

gdb:

2013-10-04  Yao Qi  <yao@codesourcery.com>

	* remote-notif.c (DECLARE_QUEUE_P): Remove.
	(notif_queue): Remove.
	(remote_notif_process): Add one parameter 'notif_queue'.
	Update comments.  Callers update.
	(remote_async_get_pending_events_token): Remove.
	(remote_notif_register_async_event_handler): Remove.
	(remote_notif_unregister_async_event_handler): Remove.
	(handle_notification): Add parameter 'notif_queue'.  Update
	comments.  Callers update.
	(notif_xfree): Remove.
	(remote_notif_state_allocate): New function.
	(remote_notif_state_xfree): New function.
	(_initialize_notif): Remove code to allocate queue.
	* remote-notif.h (DECLARE_QUEUE_P): Moved from remote-notif.c.
	(struct remote_notif_state): New.
	(handle_notification): Update declaration.
	(remote_notif_process): Likewise.
	(remote_notif_register_async_event_handler): Remove.
	(remote_notif_unregister_async_event_handler): Remove.
	(remote_notif_state_allocate): Declare.
	(remote_notif_state_xfree): Declare.
	* remote.c (struct remote_state) <notif_state>: New field.
	(remote_close): Don't call
	remote_notif_unregister_async_event_handler.  Call
	remote_notif_state_xfree.
	(remote_open_1): Don't call
	remote_notif_register_async_event_handler.  Call
	remote_notif_state_allocate.
2013-10-04 07:32:56 +00:00
Pedro Alves 3736004f01 Fix regular /path/to/directory sysroots and target reported dll paths with drive specs.
I tried debugging a remote Windows program on Linux host, and pointed the
sysroot to "/some/path/" rather than "remote:", and I found GDB couldn't
find the dlls in the sysroot.  If the dll name is
"C:/Windows/system32/ntdll.dll", I end up with the sysroot+in_pathname
concatenated this way:

 (top-gdb) p temp_pathname
 $1 = 0x228b690 "/some/pathC:/Windows/system32/ntdll.dll"
                          ^^

That is, a directory separator is missing.  This is a regression.

The problem is that solib_find decides that since the target path has
a drive spec, a separator is not necessary, which is clearly wrong in
this case.  That check was added in
<https://sourceware.org/ml/gdb-patches/2013-06/msg00028.html>, to
handle the case of sysroot being "remote:".  This patch fixes that
original issue in a different way.  Instead of checking whether the
path has a drive spec, check whether the sysroot is "remote:".  The
patch adds a table that helps visualize the cases that need a
separator.  I also confirmed the original issue is still handled as
expected.  That is, that "set sysroot remote:" still does the right
thing.

remote_filename_p returns true if the filename is prefixed with
"remote:".  In this case, we need to check whether the filename is
exactly "remote:".  I thought of different ways or either changing
remote_filename_p or adding another convenience function to remote.c
to avoid exposing the "remote:" prefix out of remote.c.  But all
attempts turned out adding lot of over needless complication.  So the
patch just exposes the prefix behind a new macro, which allows using a
straighforward strcmp.

gdb/
2013-09-27  Pedro Alves  <palves@redhat.com>

	* remote.h (REMOTE_SYSROOT_PREFIX): New define.
	(remote_filename_p): Add comment.
	* remote.c (remote_filename_p): Adjust to use
	REMOTE_SYSROOT_PREFIX.
	* solib.c (solib_find): When deciding whether we need to add a
	directory separator, check whether the sysroot is "remote:"
	instead of checking whether the patch has a drive spec.  Add
	comments.
2013-09-27 15:29:06 +00:00
Pedro Alves 5b5596ff6b remote.c: Remove unnecessary fields from 'struct stop_reply'.
I noticed these fields aren't really necessary -- if the T stop reply
indicated any we have any special event, the fallthrough doesn't
really do anything.

Tested on x86_64 Fedora 17 w/ local gdbserver, and also confirmed
"catch load" against a Windows gdbserver running under Wine, which
exercises TARGET_WAITKIND_LOADED, still works as expected.

gdb/
2013-09-27  Pedro Alves  <palves@redhat.com>

	* remote.c (struct stop_reply) <solibs_changed, replay_event>:
	Delete fields.
	(remote_parse_stop_reply): Adjust, setting event->ws.kind
	directly.
2013-09-27 13:23:32 +00:00
Pedro Alves 00d8452480 remote.c: don't install a deprecated_xfer_memory hook.
There's no need for deprecated_xfer_memory nowadays.  Memory access
goes through target_xfer_partial/TARGET_OBJECT_MEMORY, etc.  In fact,
the remote target already handles that, and is deferring to the same
helpers the deprecated_xfer_memory hook is.  Basically, only a few
adjustments to make these helper routines's interfaces closer to
target_xfer_partial's were necessary.

Tested on x86_64 Fedora 17 w/ gdbserver.

gdb/
2013-08-23  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_write_bytes_aux, remote_write_bytes)
	(remote_read_bytes): Change return type to LONGEST, and adjust to
	return a target_xfer_error on error.
	(remote_xfer_memory): Delete.
	(remote_flash_write): Change type of 'ret' local to LONGEST.
	(remote_xfer_partial, remote_xfer_partial): Adjust.
	(init_remote_ops): Don't install a deprecated_xfer_memory hook.
2013-08-23 13:12:17 +00:00
Tom Tromey 0d031856d8 move some static thread state into remote_state
This moves a few static variables from thread-info functions into
remote_state.  Pedro said on irc that these functions implement the
ancient thread-discovery method and that he wouldn't be surprised if
they had rotted; nevertheless it seems safer to me to make them
explicitly per-remote.

This necessitated moving a couple of macros and a typedef earlier in
the file.

	* remote.c (struct remote_state) <echo_nextthread, nextthread,
	resultthreadlist>: New fields.
	(OPAQUETHREADBYTES, threadref, MAXTHREADLISTRESULTS): Move earlier.
	(remote_get_threadlist, remote_threadlist_iterator): Use
	new fields.  Remove static variables.
2013-08-14 18:17:50 +00:00
Tom Tromey ee154beebf move remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state
This moves the globals remote_stopped_by_watchpoint_p and
remote_watch_data_address into remote_state.

	* remote.c (struct remote_state) <remote_stopped_by_watchpoint_p,
	remote_watch_data_address>: New fields.
	(remote_stopped_by_watchpoint_p, remote_watch_data_address): Remove.
	(process_stop_reply, remote_wait_as)
	(remote_check_watch_resources, remote_stopped_data_address): Update.
2013-08-14 18:17:13 +00:00
Tom Tromey 88b496c367 move async_client_callback and async_client_context into remote_state
This moves async_client_callback and async_client_context into
remote_state.

	* remote.c (struct remote_state) <async_client_callback,
	async_client_context>: New fields.
	(async_client_callback, async_client_context): Remove.
	(remote_async_serial_handler, remote_async): Update.
2013-08-14 18:16:30 +00:00
Tom Tromey 2f65bcb75d move sizeof_pkt into remote_trace_find
The global sizeof_pkt is only used in remote_trace_find, like so:

  reply = remote_get_noisy_reply (&(rs->buf), &sizeof_pkt);

I think in this situation it is more correct to use the recorded size
of the buffer.  Otherwise it seems that some skew could result.

	* remote.c (sizeof_pkt): Remove.
	(remote_trace_find): Use rs->buf_size, not sizeof_pkt.
2013-08-14 18:15:48 +00:00
Tom Tromey b80fafe375 move use_threadinfo_query and use_threadextra_query into struct remote_state
This moves the use_threadextra_query and use_threadinfo_query globals
into remote_state.

	* remote.c (struct remote_state) <use_threadinfo_query,
	use_threadextra_query>: New fields.
	(remote_threads_info, remote_threads_extra_info)
	(remote_open_1): Update.
2013-08-14 18:15:01 +00:00
Tom Tromey 8e88304f57 move some statics from remote_read_qxfer into struct remote_state
This moves a few static variables out of remote_read_qxfer and into
remote_state.

	* remote.c (struct remote_state) <finished_object,
	finished_annex, finished_offset>: New fields.
	(remote_read_qxfer): Use remote_state fields; remove static
	variables.
2013-08-14 18:08:48 +00:00
Tom Tromey 280ceea309 push last_sent_step into struct remote_state
This moves the global last_sent_step into remote_state.

	* remote.c (struct remote_state) <last_sent_step>:
	New field.
	(last_sent_step): Remove.
	(remote_resume, remote_wait_as): Update.
2013-08-14 18:07:45 +00:00
Tom Tromey b73be47123 push last_sent_signal into struct remote_state
This moves the global last_sent_signal into remote_state.

	* remote.c (struct remote_state) <last_sent_signal>:
	New field.
	(last_sent_signal): Remove.
	(new_remote_state, remote_resume, remote_wait_as): Update.
2013-08-14 18:06:49 +00:00
Tom Tromey 5e4a05c431 push last_program_signals_packet into struct remote_state
This moves the global last_program_signals_packet into remote_state.

	* remote.c (struct remote_state) <last_program_signals_packet>:
	New field.
	(last_program_signals_packet): Remove.
	(remote_program_signals, remote_open_1): Update.
2013-08-14 18:05:51 +00:00
Tom Tromey 747dc59d20 push last_pass_packet into struct remote_state
This moves the global last_pass_packet into remote_state.

	* remote.c (struct remote_state) <last_pass_packet>:
	New field.
	(last_pass_packet): Remove.
	(remote_pass_signals, remote_open_1): Update.
2013-08-14 18:04:52 +00:00
Tom Tromey 262e11744a push remote_traceframe_number into struct remote_state
This moves the global remote_traceframe_number into remote_state.

	* remote.c (struct remote_state) <remote_traceframe_number>:
	New field.
	(remote_traceframe_number): Remove.
	(new_remote_state, remote_open_1, set_remote_traceframe)
	(remote_trace_find): Update.
2013-08-14 18:03:50 +00:00
Tom Tromey 47f8a51d47 push general_thread and continue_thread into struct remote_state
This moves the globals general_thread and continue_thread into
remote_state.

	* remote.c (struct remote_state) <general_thread, continue_thread>:
	New fields.
	(general_thread, continue_thread): Remove.
	(record_currthread, set_thread, set_general_process)
	(remote_open_1, extended_remote_attach_1, remote_wait_as)
	(extended_remote_mourn_1): Update.
2013-08-14 18:03:00 +00:00
Tom Tromey 5d93a237b0 push remote_desc into struct remote_state
This moves the "remote_desc" global into remote_state.

	* remote.c (struct remote_state) <remote_desc>: New field.
	(remote_desc): Remove.
	(remote_threads_info, remote_threads_extra_info, remote_close)
	(send_interrupt_sequence, remote_start_remote, remote_open_1)
	(readchar, remote_xfer_partial, remote_rcmd, packet_command)
	(remote_hostio_send_command, remote_file_put, remote_file_get)
	(remote_file_delete, remote_can_async_p, remote_is_async_p)
	(remote_async, remote_new_objfile, set_range_stepping): Update.
2013-08-14 18:01:33 +00:00
Tom Tromey cf79286214 Add new_remote_state
Add new_remote_state and change remote_state to be a pointer.  This is
a preparatory patch for a later series.  It could perhaps be omitted,
but new_remote_state also does some initialization that was previously
done for the globals.

	* remote.c (remote_state): Now a pointer.
	(get_remote_state_raw): Update.
	(new_remote_state): New function.
	(_initialize_remote): Use new_remote_state.
2013-08-14 18:00:34 +00:00
Tom Tromey dc473cfbf9 make remote_protocol_features "const"
This is a trivial patch to make remote_protocol_features "const".

	* remote.c (remote_protocol_features): Now const.
2013-08-14 17:58:53 +00:00
Tom Tromey 85ec6ce7d5 use the libiberty crc code
gdb has a copy of some CRC code that also appears in libiberty.
This patch just removes the local copy.

You may notice that "crc32" returns unsigned long but "xcrc32" returns
unsigned int.  However, this does not matter, because crc32 actually
does all its operations in unsigned int type, and only the return
result is widened.  So, the difference does not matter.

	* remote.c (crc32_table, crc32): Remove.
	(remote_verify_memory): Use xcrc32.
2013-08-14 17:57:09 +00:00
Jan Kratochvil 934b9bace2 gdb/
Code cleanup.
	* remote.c (cleanup_sigint_signal_handler): Rename the declaration
	to ...
	(async_cleanup_sigint_signal_handler): ... this.
	(initialize_sigint_signal_handler): Remove declaration.
	(handle_remote_sigint): Rename the declaration to ...
	(async_handle_remote_sigint): ... this.
	(handle_remote_sigint_twice): Rename the declaration to ...
	(async_handle_remote_sigint_twice): ... this.
	(async_remote_interrupt, async_remote_interrupt_twice)
	(remote_interrupt): Remove the declarations.
	(remote_interrupt_twice): Rename the declaration ...
	(sync_remote_interrupt_twice): ... this.
	(sigint_remote_twice_token): Rename the variable to ...
	(async_sigint_remote_twice_token): ... this.
	(sigint_remote_token): Rename the variable to ...
	(async_sigint_remote_token): ... this.
	(initialize_sigint_signal_handler): Rename the function to ...
	(async_initialize_sigint_signal_handler): ... this.  Update the name
	inside.
	(handle_remote_sigint): Rename the function to ...
	(async_handle_remote_sigint): ... this.  Update the names inside.
	(handle_remote_sigint_twice): Rename the function to ...
	(async_handle_remote_sigint_twice): ... this.  Update the names inside.
	(cleanup_sigint_signal_handler): Rename the function to ...
	(async_cleanup_sigint_signal_handler): ... this.
	(remote_interrupt): Rename the function to ...
	(sync_remote_interrupt): this.  Update the names inside.
	(remote_interrupt_twice): Rename the function to ...
	(sync_remote_interrupt_twice): this.  Update the names inside.
	(remote_terminal_inferior, remote_terminal_ours, remote_wait_as)
	(_initialize_remote): Update the names inside.
2013-08-05 15:03:06 +00:00
Andrew Burgess 039e3c2282 Replace most uses of deprecated_throw_reason with quit.
http://sourceware.org/ml/gdb-patches/2013-07/msg00778.html

gdb/ChangeLog

        * monitor.c (monitor_interrupt_query): Replace use of
        deprecated_throw_reason with quit.
        * nto-procfs.c (interrupt_query): Likewise.
        * remote-fileio.c (remote_fileio_sig_exit): Likewise.
        * remote-mips.c (mips_kill): Likewise.
        * remote.c (interrupt_query): Likewise.
2013-07-31 12:44:33 +00:00
Jan Kratochvil 47e1ce27f4 gdb/
Code cleanup.
	* remote.c (async_remote_interrupt_twice): Make it static.
	* remote.h (async_remote_interrupt_twice): Remove the declaration.
2013-06-30 17:14:59 +00:00