Commit Graph

984 Commits

Author SHA1 Message Date
Ulrich Weigand 4ac33720d6 gdb/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* NEWS: Mention TDB support.
	* features/s390-tdb.xml: New file.
	* features/s390-te-linux64.xml: New file.
	* features/s390x-te-linux64.xml: New file.
	* features/Makefile (WHICH): Add new tdescs above.
	(s390-te-linux64-expedite): Set.
	(s390x-te-linux64-expedite): Set.
	* features/s390-te-linux64.c: New file (generated).
	* features/s390x-te-linux64.c: New file (generated).
	* regformats/s390-te-linux64.dat: New file (generated).
	* regformats/s390x-te-linux64.dat: New file (generated).
	* s390-tdep.h (HWCAP_S390_HIGH_GPRS): Define.
	(HWCAP_S390_TE): Likewise.
	(S390_TDB_DWORD0_REGNUM): Likewise.
	(S390_TDB_DWORD0_REGNUM): Likewise.
	(S390_TDB_ABORT_CODE_REGNUM): Likewise.
	(S390_TDB_CONFLICT_TOKEN_REGNUM): Likewise.
	(S390_TDB_ATIA_REGNUM): Likewise.
	(S390_TDB_R0_REGNUM): Likewise.
	(S390_TDB_R1_REGNUM): Likewise.
	(S390_TDB_R2_REGNUM): Likewise.
	(S390_TDB_R3_REGNUM): Likewise.
	(S390_TDB_R4_REGNUM): Likewise.
	(S390_TDB_R5_REGNUM): Likewise.
	(S390_TDB_R6_REGNUM): Likewise.
	(S390_TDB_R7_REGNUM): Likewise.
	(S390_TDB_R8_REGNUM): Likewise.
	(S390_TDB_R9_REGNUM): Likewise.
	(S390_TDB_R10_REGNUM): Likewise.
	(S390_TDB_R11_REGNUM): Likewise.
	(S390_TDB_R12_REGNUM): Likewise.
	(S390_TDB_R13_REGNUM): Likewise.
	(S390_TDB_R14_REGNUM): Likewise.
	(S390_TDB_R15_REGNUM): Likewise.
	(S390_NUM_REGS): Increase.
	(S390_IS_TDBREGSET_REGNUM): New macro.
	(s390_regmap_tdb): Declare.
	(s390_sizeof_tdbregset): Define.
	(tdesc_s390_te_linux64): Declare.
	(tdesc_s390x_te_linux64): Likewise.
	* s390-tdep.c: Add includes for "auxv.h", <elf.h>,
	"features/s390-te-linux64.c", and "features/s390x-te-linux64.c".
	(s390_regmap_tdb): New regmap.
	(s390_supply_tdb_regset): New function.
	(s390_tdb_regset): New regset.
	(s390_linux64v2_regset_sections): Add TDB regset to list.
	(s390x_linux64v2_regset_sections): Likewise.
	(s390_regset_from_core_section): Recognize TDB core note section.
	(s390_core_read_description): If HWCAP indicates TE support,
	select tdesc_s390_te_linux64 or tdesc_s390_s390x_te_linux64.
	(s390_gdbarch_init): Handle TDB regset.
	(_initialize_s390_tdep): Initialize new tdescs.
	* s390-nat.c (HWCAP_S390_HIGH_GPRS): Remove define.
	(have_regset_tdb): New variable.
	(s390_native_supply): Support register invalidation.
	(fetch_regset): Invalidate registers if ptrace yields ENODATA.
	(check_regset): Treat ENODATA as "regset exists".
	(s390_linux_fetch_inferior_registers): Add TDB.
	(s390_read_description): Check for TDB existence and select
	appropriate tdesc.
	* gdbserver/Makefile.in (clean): Add removal of new makefile
	targets.
	(s390-te-linux64.c): New makefile target.
	(s390x-te-linux64.c): Likewise.
	* gdbserver/configure.srv (srv_regobj): Append new objects
	s390-te-linux64.o and s390x-te-linux64.o.
	(srv_xmlfiles): Append new files s390-te-linux64.xml,
	s390x-te-linux64.xml, and s390-tdb.xml.
	* gdbserver/linux-s390-low.c (init_registers_s390_te_linux64): New
	declaration.
	(tdesc_s390_te_linux64): Likewise.
	(init_registers_s390x_te_linux64): Likewise.
	(tdesc_s390x_te_linux64): Likewise.
	(s390_check_regset): Treat ENODATA as "regset exists".
	(s390_arch_setup): Add TDB regset support.
	(initialize_low_arch): Initialize registers for new tdescs.

gdb/doc/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* gdb.texinfo (Decimal Floating Point format): Mention S/390.
	(Standard Target Features): Add new node to menu.
	(S/390 and System z Features): New node.

gdb/testsuite/ChangeLog:
2013-09-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* gdb.arch/s390-tdbregs.c: New file.
	* gdb.arch/s390-tdbregs.exp: New file.
2013-09-13 14:17:31 +00:00
Pedro Alves fb71d39e8c [gdbserver] Garbage collect unused dependency-tracking Makefile variables.
These used to be necessary for manual rule dependency tracking.
Nothing uses them anymore.  (regdat_sh is still needed.)

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

	* Makefile.in (gdb_proc_service_h, regdef_h, regcache_h)
	(signals_def, signals_h, ptid_h, ax_h, agent_h, linux_btrace_h)
	(linux_osdata_h, vec_h, gdb_vecs_h, host_defs_h, libiberty_h)
	(server_h, gdbthread_h, linux_low_h, linux_ptrace_h)
	(gdb_thread_db_h, linux_procfs_h, lynx_low_h, nto_low_h)
	(mips_linux_watch_h, i386_low_h, win32_low_h): Delete.
2013-09-06 12:04:56 +00:00
Pedro Alves 8e7e991006 [gdbserver] Update a couple Makefile rules.
These two are still written in the pre-auto-dependency-tracking style.
They probably were written before that, and committed afterwards
without adjustment.  An easy oversight to make.

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

	* Makefile.in (linux-btrace.o, mips-linux-watch.o): Remove
	explicit header dependencies and use $COMPILE/$POSTCOMPILE.
2013-09-06 11:54:07 +00:00
Pedro Alves 7c3a12caf5 [gdbserver] Fix IPA build.
Somehow, my builds yesterdays didn't trip on this...

../src/gdb/gdbserver/linux-amd64-ipa.c: In function ‘initialize_low_tracepoint’:
../src/gdb/gdbserver/linux-amd64-ipa.c:172:3: error: ‘ipa_tdesc’ undeclared (first use in this function)
../src/gdb/gdbserver/linux-amd64-ipa.c:172:3: note: each undeclared identifier is reported only once for each function it appears in

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

	* linux-amd64-ipa.c: Include tracepoint.h.
	* linux-i386-ipa.c: Include tracepoint.h.
2013-09-06 10:58:11 +00:00
Ricard Wanderlof 8eb3d7b6ca Add support for threaded debugging for CRISv32.
2013-09-06  Ricard Wanderlof  <ricardw@axis.com>

	* cris-tdep.c (cris_gdbarch_init): Add call to
	get_gdbarch_fetch_tls_load_module_address.

gdbserver

	* linux-crisv32-low.c (PTRACE_GET_THREAD_AREA): New macro.
	(ps_get_thread_area): New function.
2013-09-06 08:37:17 +00:00
Ricard Wanderlof eddddb9d52 Fix compilation for target gdbserver on CRISv32 platform.
One misspelled function call, and one superfluous typedef. The latter
causes an error of the following type when building:

linux-crisv32-low.c:372: error: conflicting types for 'elf_gregset_t'
/.../target/include/asm/elf.h:36:
error: previous declaration of 'elf_gregset_t' was here

2013-09-06  Ricard Wanderlof  <ricardw@axis.com>

	* linux-crisv32-low.c (elf_gregset_t): Delete typedef.
	(initialize_low_arch): Call init_registers_crisv32 rather than
	init_register_crisv32.
2013-09-06 08:04:19 +00:00
Pedro Alves 270c6aeaf2 Add missing new files from these previous commits:
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (handle_vFile, hostio_last_error_from_errno): Move
	to ...
	* hostio.h: ... this new file.
	* hostio.c, server.c, linux-low.c, nto-low.c, spu-low,
	win32-low.c: Include hostio.h.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (gdb_client_data, handler_func, callback_handler_func)
	(delete_file_handler, add_file_handler, append_callback_event)
	(delete_callback_event, start_event_loop, initialize_event_loop):
	Move to event-loop.h and include it.
	* event-loop.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* dll.c, inferiors.c, remote-utils.c, server.c: Include "dll.h".
	* server.h (struct dll_info, all_dlls, dlls_changed, clear_dlls)
	(loaded_dll, unloaded_dll): Move to ...
	* dll.h: ... this new file.
	* inferiors.c, remote-utils.c, win32-low.c: Include "dll.h".

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (current_process, get_thread_process, all_processes)
	(add_inferior_to_list, for_each_inferior, current_inferior)
	(remove_inferior, add_process, remove_process, find_process_pid)
	(have_started_inferiors_p, have_attached_inferiors_p)
	(thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id)
	(clear_inferiors, find_inferior, find_inferior_id)
	(inferior_target_data, set_inferior_target_data)
	(inferior_regcache_data, set_inferior_regcache_data): Move to
	inferiors.h, and include it.
	* inferiors.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* ax.c, linux-low.c, linux-x86-low.c, server.c: Include
	tracepoint.h.
	* server.h (IPA_BUFSIZ, initialize_tracepoint, tracing)
	(disconnected_tracing, tracepoint_look_up_symbols, stop_tracing
	(handle_tracepoint_general_set, handle_tracepoint_query)
	(tracepoint_finished_step, tracepoint_was_hit)
	(release_while_stepping_state_list, current_traceframe)
	(in_readonly_region, traceframe_read_mem)
	(fetch_traceframe_registers, traceframe_read_sdata)
	(traceframe_read_info, struct fast_tpoint_collect_status)
	(fast_tracepoint_collecting, force_unlock_trace_buffer)
	(handle_tracepoit_bkpts, initialize_low_tracepoint)
	(supply_fast_tracepoint_registers)
	(supply_static_tracepoint_registers, set_trampoline_buffer_space)
	(ipa_tdesc, claim_trampoline_space)
	(have_fast_tracepoint_trampoline_buffer, gdb_agent_about_to_close)
	(agent_mem_read, agent_get_trace_state_variable_value)
	(agent_set_trace_state_variable_value, agent_tsv_read)
	(agent_mem_read_string, get_raw_reg_func_addr)
	(get_get_tsv_func_addr, get_set_tsv_func_addr): Move to ...
	* tracepoint.h: ... this new file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (perror_with_name, error, fatal, warning, paddress)
	(pulongest, plongest, phex_nz, pfildes): Move to utils.h, and
	include it.
	* utils.h: New file.

2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (remote_debug, noack_mode, transport_is_reliable)
	(gdb_connected, STDIO_CONNECTION_NAME, remote_connection_is_stdio)
	(read_ptid, write_ptid, putpkt, putpkt_binary, putpkt_notif)
	(getpkt, remote_prepare, remote_open, remote_close, write_ok)
	(write_enn, initialize_async_io, enable_async_io)
	(disable_async_io, check_remote_input_interrupt_request)
	(convert_ascii_to_int, convert_int_to_ascii, new_thread_notify)
	(dead_thread_notify, prepare_resume_reply)
	(decode_address_to_semicolon, decode_address, decode_m_packet)
	(decode_M_packet, decode_X_packet, decode_xfer_write)
	(decode_search_memory_packet, unhexify, hexify)
	(remote_escape_output, unpack_varlen_hex, clear_symbol_cache)
	(look_up_one_symbol, relocate_instruction)
	(monitor_output): Move to remote-utils.h, and include it.
	* remote-utils.h: New file.
2013-09-05 22:18:48 +00:00
Pedro Alves 533b06003e [gdbserver] Split a new hostio.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (handle_vFile, hostio_last_error_from_errno): Move
	to ...
	* hostio.h: ... this new file.
	* hostio.c, server.c, linux-low.c, nto-low.c, spu-low,
	win32-low.c: Include hostio.h.
2013-09-05 20:45:39 +00:00
Pedro Alves 0ce3d3b5aa [gdbserver] Split a new event-loop.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (gdb_client_data, handler_func, callback_handler_func)
	(delete_file_handler, add_file_handler, append_callback_event)
	(delete_callback_event, start_event_loop, initialize_event_loop):
	Move to event-loop.h and include it.
	* event-loop.h: New file.
2013-09-05 20:42:52 +00:00
Pedro Alves 799cdc3728 [gdbserver] Split a new dll.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* dll.c, inferiors.c, remote-utils.c, server.c: Include "dll.h".
	* server.h (struct dll_info, all_dlls, dlls_changed, clear_dlls)
	(loaded_dll, unloaded_dll): Move to ...
	* dll.h: ... this new file.
	* inferiors.c, remote-utils.c, win32-low.c: Include "dll.h".
2013-09-05 20:41:55 +00:00
Pedro Alves 6a6bbd9d76 [gdbserver] Split a new inferiors.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (current_process, get_thread_process, all_processes)
	(add_inferior_to_list, for_each_inferior, current_inferior)
	(remove_inferior, add_process, remove_process, find_process_pid)
	(have_started_inferiors_p, have_attached_inferiors_p)
	(thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id)
	(clear_inferiors, find_inferior, find_inferior_id)
	(inferior_target_data, set_inferior_target_data)
	(inferior_regcache_data, set_inferior_regcache_data): Move to
	inferiors.h, and include it.
	* inferiors.h: New file.
2013-09-05 20:41:22 +00:00
Pedro Alves f699aaba87 [gdbserver] Move bytecode compilation bits from server.h to ax.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (struct emit_ops, current_insn_ptr, emit_error):
	Move ...
        * ax.h: ... here.
2013-09-05 20:40:58 +00:00
Pedro Alves c144c7a0b7 [gdbserver] Split a new tracepoint.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* ax.c, linux-low.c, linux-x86-low.c, server.c: Include
	tracepoint.h.
	* server.h (IPA_BUFSIZ, initialize_tracepoint, tracing)
	(disconnected_tracing, tracepoint_look_up_symbols, stop_tracing
	(handle_tracepoint_general_set, handle_tracepoint_query)
	(tracepoint_finished_step, tracepoint_was_hit)
	(release_while_stepping_state_list, current_traceframe)
	(in_readonly_region, traceframe_read_mem)
	(fetch_traceframe_registers, traceframe_read_sdata)
	(traceframe_read_info, struct fast_tpoint_collect_status)
	(fast_tracepoint_collecting, force_unlock_trace_buffer)
	(handle_tracepoit_bkpts, initialize_low_tracepoint)
	(supply_fast_tracepoint_registers)
	(supply_static_tracepoint_registers, set_trampoline_buffer_space)
	(ipa_tdesc, claim_trampoline_space)
	(have_fast_tracepoint_trampoline_buffer, gdb_agent_about_to_close)
	(agent_mem_read, agent_get_trace_state_variable_value)
	(agent_set_trace_state_variable_value, agent_tsv_read)
	(agent_mem_read_string, get_raw_reg_func_addr)
	(get_get_tsv_func_addr, get_set_tsv_func_addr): Move to ...
	* tracepoint.h: ... this new file.
2013-09-05 20:40:33 +00:00
Pedro Alves ff42e6abac [gdbserver] Split a new utils.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (perror_with_name, error, fatal, warning, paddress)
	(pulongest, plongest, phex_nz, pfildes): Move to utils.h, and
	include it.
	* utils.h: New file.
2013-09-05 20:39:48 +00:00
Pedro Alves 541af0f44b [gdbserver] Split a new remote-utils.h file out of server.h.
gdb/gdbserver/
2013-09-05  Pedro Alves  <palves@redhat.com>

	* server.h (remote_debug, noack_mode, transport_is_reliable)
	(gdb_connected, STDIO_CONNECTION_NAME, remote_connection_is_stdio)
	(read_ptid, write_ptid, putpkt, putpkt_binary, putpkt_notif)
	(getpkt, remote_prepare, remote_open, remote_close, write_ok)
	(write_enn, initialize_async_io, enable_async_io)
	(disable_async_io, check_remote_input_interrupt_request)
	(convert_ascii_to_int, convert_int_to_ascii, new_thread_notify)
	(dead_thread_notify, prepare_resume_reply)
	(decode_address_to_semicolon, decode_address, decode_m_packet)
	(decode_M_packet, decode_X_packet, decode_xfer_write)
	(decode_search_memory_packet, unhexify, hexify)
	(remote_escape_output, unpack_varlen_hex, clear_symbol_cache)
	(look_up_one_symbol, relocate_instruction)
	(monitor_output): Move to remote-utils.h, and include it.
	* remote-utils.h: New file.
2013-09-05 20:39:17 +00:00
Pedro Alves eebdf26b45 [gdbserver] Delete _ macro (gettext).
server.h nowadays includes gdb_locale.h, which already brings this in.

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

	* server.h (_): Delete.
2013-09-05 20:38:45 +00:00
Pedro Alves 3aafd2ffb6 [gdbserver] Fix trace-buffer-size.exp FAILs.
I'm seeing trace-buffer-size.exp failing (with gdbserver):

  (gdb) PASS: gdb.trace/trace-buffer-size.exp: tstatus check 2
  show trace-buffer-size 4
  Requested size of trace buffer is 4.
  (gdb) PASS: gdb.trace/trace-buffer-size.exp: show trace buffer size
  set trace-buffer-size -1
  memory clobbered past end of allocated block
  Remote connection closed
  (gdb) FAIL: gdb.trace/trace-buffer-size.exp: set trace buffer size 2
  set trace-buffer-size unlimited
  (gdb) PASS: gdb.trace/trace-buffer-size.exp: set trace-buffer-size unlimited

That "memory clobbered past end of allocated block" is mcheck triggering.

Valgrind shows:

  ==23624== Invalid write of size 1
  ==23624==    at 0x418DD8: clear_trace_buffer (tracepoint.c:1443)
  ==23624==    by 0x418F3A: init_trace_buffer (tracepoint.c:1497)
  ==23624==    by 0x41D95B: cmd_bigqtbuffer_size (tracepoint.c:4061)
  ==23624==    by 0x41DEEC: handle_tracepoint_general_set (tracepoint.c:4193)

clear_trace_buffer does:

  static void
  clear_trace_buffer (void)
  {
    trace_buffer_start = trace_buffer_lo;
    trace_buffer_free = trace_buffer_lo;
    trace_buffer_end_free = trace_buffer_hi;
    trace_buffer_wrap = trace_buffer_hi;
    /* A traceframe with zeroed fields marks the end of trace data.  */
    ((struct traceframe *) trace_buffer_free)->tpnum = 0;
    ((struct traceframe *) trace_buffer_free)->data_size = 0;
    traceframe_read_count = traceframe_write_count = 0;
    traceframes_created = 0;
  }

And the tpnum+data_size fields are over 4 bytes...  This fixes it by
ensuring we allocate space at least for an EOB.  We have code
elsewhere that relies on the EOB being present (like e.g.,
find_traceframe), so this seems simplest.

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

	* tracepoint.c (TRACEFRAME_EOB_MARKER_SIZE): New macro.
	(init_trace_buffer): Ensure at least TRACEFRAME_EOB_MARKER_SIZE is
	allocated.
	(trace_buffer_alloc): Use TRACEFRAME_EOB_MARKER_SIZE.
2013-09-02 15:15:57 +00:00
Pierre Muller cee83bcb49 * win32-low.c (child_xfer_memory): Check if ReadProcessMemory
or WriteProcessMemory complete successfully and handle
	ERROR_PARTIAL_COPY error.
2013-09-02 14:32:19 +00:00
Pedro Alves 9a13b2fa01 server.c:gdb_read_memory: Fix error return.
When I added gdb_read_memory, with bits factored out from elsewhere, I
missed adjusting this error return.  gdb_read_memory has an interface
similar to Like GDB's xfer_partial:

> /* Read trace frame or inferior memory.  Returns the number of bytes
>   actually read, zero when no further transfer is possible, and -1 on
>   error.  Return of a positive value smaller than LEN does not
>   indicate there's no more to be read, only the end of the transfer.

Returning EIO, a positive value, is obviously bogus, for the caller
will confuse it with a successful partial transfer.

Found by inspection.

Tested on x86_64 Fedora 17.

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

	* server.c (gdb_read_memory): Return -1 on traceframe memory read
	error instead of EIO.
2013-09-02 14:14:58 +00:00
Jan Kratochvil 602e3198bc PR server/15604
gdb/gdbserver/
2013-08-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR server/15604
	* linux-low.c: Include filestuff.h.
	(linux_create_inferior) <pid == 0>: Call close_most_fds.
	* lynx-low.c: Include filestuff.h.
	(lynx_create_inferior) <pid == 0>: Call close_most_fds.
	* server.c: Include filestuff.h.
	(main): Call notice_open_fds.
	* spu-low.c: Include filestuff.h.
	(spu_create_inferior) <pid == 0>: Call close_most_fds.
2013-08-28 17:40:58 +00:00
Luis Machado 96d7229d2a Unify ptrace options discovery code and make both GDB and
gdbserver use it.

	gdb/
	* Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-nat.h and
	nat/linux-waitpid.h.
	(linux-waitpid.o): New object file rule.
	* common/linux-ptrace.c: Include nat/linux-waitpid.h.
	(current_ptrace_options): Moved from linux-nat.c.
	(linux_ptrace_test_ret_to_nx): Use type casts for ptrace
	parameters.
	(linux_fork_to_function): New function.
	(linux_grandchild_function): Likewise.
	(linux_child_function): Likewise.
	(linux_check_ptrace_features): New function, heavily
	based on linux-nat.c:linux_test_for_tracefork.
	(linux_enable_event_reporting): New function.
	(ptrace_supports_feature): Likewise.
	(linux_supports_tracefork): Likewise.
	(linux_supports_traceclone): Likewise.
	(linux_supports_tracevforkdone): Likewise.
	(linux_supports_tracesysgood): Likewise.
	* common/linux-ptrace.h (HAS_NOMMU): Moved from
	gdbserver/linux-low.c.
	(linux_enable_event_reporting): New declaration.
	(linux_supports_tracefork): Likewise.
	(linux_supports_traceclone): Likewise.
	(linux_supports_tracevforkdone): Likewise.
	(linux_supports_tracesysgood): Likewise.
	* config.in (PTRACE_TYPE_ARG4): Regenerate.
	* config/aarch64/linux.mh (NATDEPFILES): Add linux-waitpid.o.
	* config/alpha/alpha-linux.mh (NATDEPFILES): Likewise.
	* config/arm/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* config/ia64/linux.mh (NATDEPFILES): Likewise.
	* config/m32r/linux.mh (NATDEPFILES): Likewise.
	* config/m68k/linux.mh (NATDEPFILES): Likewise.
	* config/mips/linux.mh (NATDEPFILES): Likewise.
	* config/pa/linux.mh (NATDEPFILES): Likewise..
	* config/powerpc/linux.mh (NATDEPFILES): Likewise..
	* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/spu-linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux64.mh (NATDEPFILES): Likewise.
	* config/tilegx/linux.mh (NATDEPFILES): Likewise.
	* config/xtensa/linux.mh (NATDEPFILES): Likewise.
	* configure.ac (AC_CACHE_CHECK): Add void * to the list of
	ptrace's 4th argument's types.
	Check the type of PTRACE_TYPE_ARG4.
	* configure: Regenerate.
	* linux-nat.c: Include nat/linux-nat.h and nat/linux-waitpid.h.
	(SYSCALL_SIGTRAP): Moved to nat/linux-nat.h.
	(linux_supports_tracefork_flag): Remove.
	(linux_supports_tracesysgood_flag): Likewise.
	(linux_supports_tracevforkdone_flag): Likewise.
	(current_ptrace_options): Moved to
	common/linux-ptrace.c.
	(linux_tracefork_child): Remove.
	(my_waitpid): Remove.
	(linux_test_for_tracefork): Renamed to
	linux_check_ptrace_features and moved to common/linux-ptrace.c.
	(linux_test_for_tracesysgood): Remove.
	(linux_supports_tracesysgood): Remove.
	(linux_supports_tracefork): Remove.
	(linux_supports_tracevforkdone): Remove.
	(linux_enable_tracesysgood): Remove.
	(linux_enable_event_reporting): Remove.
	(linux_init_ptrace): New function.
	(linux_child_post_attach): Call linux_init_ptrace.
	(linux_child_post_startup_inferior): Call linux_init_ptrace.
	(linux_child_follow_fork): Call linux_supports_tracefork
	and linux_supports_tracevforkdone.
	(linux_child_insert_fork_catchpoint): Call
	linux_supports_tracefork.
	(linux_child_insert_vfork_catchpoint): Likewise.
	(linux_child_set_syscall_catchpoint): Call
	linux_supports_tracesysgood.
	(lin_lwp_attach_lwp): Call linux_supports_tracefork.
	* nat/linux-nat.h: New file.
	* nat/linux-waitpid.c: New file.
	* nat/linux-waitpid.h: New file.

	gdb/gdbserver/
	* Makefile.in: Explain why ../target and ../nat are not
	listed as include file search paths.
	(linux-waitpid.o): New object file rule.
	* configure.srv (srv_native_linux_obj): New variable.
	Replace all occurrences of linux native object files with
	$srv_native_linux_obj.
	* linux-low.c: Include nat/linux-nat.h and nat/linux-waitpid.h.
	(HAS_NOMMU): Move defining logic to common/linux-ptrace.c.
	(linux_enable_event_reporting): Remove declaration.
	(my_waitpid): Moved to common/linux-waitpid.c.
	(linux_wait_for_event): Pass ptid when calling
	linux_enable_event_reporting.
	(linux_supports_tracefork_flag): Remove.
	(linux_enable_event_reporting): Likewise.
	(linux_tracefork_grandchild): Remove.
	(STACK_SIZE): Moved to common/linux-ptrace.c.
	(linux_tracefork_child): Remove.
	(linux_test_for_tracefork): Remove.
	(linux_look_up_symbols): Call linux_supports_traceclone.
	(initialize_low): Remove call to linux_test_for_tracefork.
	* linux-low.h (PTRACE_TYPE_ARG3): Move to
	common/linux-ptrace.h.
	(PTRACE_TYPE_ARG4): Likewise.
	Include linux-ptrace.h.
2013-08-22 23:46:30 +00:00
Pedro Alves 329400732e Renegerate gdbserver/config.in.
In:
    gdb/gdbserver/
    2013-07-03  Pedro Alves  <palves@redhat.com>

        * Makefile.in (config.status): Depend on development.sh.
        * acinclude.m4: Include libmcheck.m4.
        * configure: Regenerate.

I missed regenerating config.in...

Tested on x86_64 Fedora 17.

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

	* config.in: Renegerate.
2013-08-21 21:32:42 +00:00
Pedro Alves a261b8f5be Fix whitespace. 2013-08-21 21:31:45 +00:00
Luis Machado 33b60d5831 gdb/
* Makefile.in (SFILES): Remove common/target-common.c and
	add target/waitstatus.c.
	(HFILES_NO_SRCDIR): Remove common/target-common.h and add
	target/resume.h, target/wait.h and target/waitstatus.h.
	(COMMON_OBS): Remove target-common.o and add
	waitstatus.o.
	(target-common.o): Remove.
	(waitstatus.o): New target object file.
	* common/target-common.c: Move contents to
	target/waitstatus.c and remove.
	* common/target-common.h: Move contents to other files and
	remove.
	(enum resume_kind: Move to target/resume.h.
	(TARGET_WNOHANG): Move to target/wait.h.
	(enum target_waitkind): Move to target/waitstatus.h.
	(struct target_waitstatus): Likewise.
	* target.h: Do not include target-common.h and
	include target/resume.h, target/wait.h and
	target/waitstatus.h.
	* target/resume.h: New file.
	* target/wait.h: New file.
	* target/waitstatus.h: New file.
	* target/waitstatus.c: New file.

	gdb/gdbserver/
	* Makefile.in (INCLUDE_CFLAGS): Include -I$(srcdir)/../.
	(SFILES): Remove $(srcdir)/common/target-common.c and
	add $(srcdir)/target/waitstatus.c.
	(OBS): Remove target-common.o and add waitstatus.o.
	(server_h): Remove $(srcdir)/../common/target-common.h and
	add $(srcdir)/../target/resume.h, $(srcdir)/../target/wait.h
	and $(srcdir)/../target/waitstatus.h.
	(target-common.o): Remove.
	(waitstatus.o): New target object file.
	* target.h: Do not include target-common.h and
	include target/resume.h, target/wait.h and
	target/waitstatus.h.
2013-08-19 16:54:11 +00:00
Luis Machado b8e1b30ec5 * linux-arm-low.c: Rename all occurrences of PTRACE_ARG3_TYPE
to PTRACE_TYPE_ARG3.
	* linux-low.c: Rename all occurrences of PTRACE_ARG3_TYPE
	to PTRACE_TYPE_ARG3 and PTRACE_ARG4_TYPE to
	PTRACE_TYPE_ARG4.
	* linux-low.h (PTRACE_ARG3_TYPE): Rename to PTRACE_TYPE_ARG3.
	(PTRACE_ARG4_TYPE): Rename to PTRACE_TYPE_ARG4.
2013-08-14 02:22:19 +00:00
Yao Qi 7a60ad4017 gdb/gdbserver/
* Makefile.in (SFILES): Add common/mips-linux-watch.c.
	(mips-linux-watch.o): New rule.
	(mips_linux_watch_h): New variable.
	* configure.srv <mips*-*-linux*>: Add mips-linux-watch.o to
	srv_tgtobj.
	* linux-mips-low.c: Include mips-linux-watch.h.
	(struct arch_process_info, struct arch_lwp_info): New.
	(update_watch_registers_callback): New function.
	(mips_linux_new_process, mips_linux_new_thread) New functions.
	(mips_linux_prepare_to_resume, mips_insert_point): New
	functions.
	(mips_remove_point, mips_stopped_by_watchpoint): New
	functions.
	(rsp_bp_type_to_target_hw_bp_type): New function.
	(mips_stopped_data_address): New function.
	(the_low_target): Add watchpoint support functions.

gdb/

	* NEWS: Mention that GDBserver now supports hardware
	watchpoints on the MIPS GNU/Linux target.
2013-07-27 07:59:49 +00:00
Yao Qi de6f69ad33 gdb/
* breakpoint.h: Include break-common.h.
	(enum target_hw_bp_type): Move to ...
	* common/break-common.h: ... here.  New.

gdb/gdbserver/

	* i386-low.c: Include break-common.h.
	(enum target_hw_bp_type): Remove.
2013-07-27 07:11:46 +00:00
Luis Machado 3360c0bf75 gdb/
* Makefile.in (SFILES): Add common/target-common.c.
	Add common/target-common.h to headers.
	(COMMON_OBS): Add target-common.o.
	(target-common.o): New target.
	* linux-nat.h (resume_kind): Move to common/target-common.h.
	* target.c (target_waitstatus_to_string): Move to
	common/target-common.c.
	* target.h: Include target-common.h.
	(target_waitkind): Move to common/target-common.h.
	(target_waitstatus): Likewise.
	(TARGET_WNOHANG): Likewise.
	* common/target-common.c: New file.
	* common/target-common.h: New file.

	gdb/gdbserver/
	* Makefile.in (SFILES): /common/target-common.c.
	(OBS): Add target-common.o.
	(server_h): Add $(srcdir)/../common/target-common.h.
	(target-common.o): New target.
	* server.c (queue_stop_reply_callback): Free
	status string after use.
	* target.c (target_waitstatus_to_string): Remove.
	* target.h: Include target-common.h.
	(resume_kind): Likewise.
	(target_waitkind): Likewise.
	(target_waitstatus): Likewise.
	(TARGET_WNOHANG): Likewise.
2013-07-24 16:20:12 +00:00
Yao Qi bd88542004 gdb/
2013-07-04  Yao Qi  <yao@codesourcery.com>

	Revert:
	2013-06-27  Yao Qi  <yao@codesourcery.com>

	* common/create-version.sh: Update comments.  Handle the case
	that TARGET_ALIAS is empty.

gdb/gdbserver/

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

	* Makefile.in (host_alias): Use @host_noncanonical@.
	(target_alias): Use @target_noncanonical@.
	* configure.ac: Use ACX_NONCANONICAL_TARGET and
	ACX_NONCANONICAL_HOST.
	* configure: Regenerated.

	Revert:
	2013-06-28  Mircea Gherzan  <mircea.gherzan@intel.com>

	* configure.ac (version_host, version_target): Set and AC_SUBST them.
	* configure: Rebuild.
	* Makefile.in (version_host, version_target): Get from configure.
	(version.c): Use $(version_host) and $(version_target).
2013-07-04 01:22:38 +00:00
Pedro Alves 17ef446eed On mainline/development, also link GDBserver with -lmcheck.
This factors --enable-libmcheck related bits from GDB's configure.ac
and makes GDBserver use them too.  Specifically, the 'development'
global is moved to a separate script to it can be sourced by both GDB
and GDBserver, and the --enable-libmcheck/--disable-libmcheck bits
proper are moved to a new m4 file.

I started out by defining 'development' in the m4 file, but in the end
decided against it, as a separate script has the advantage that
changing it in release branches does not require regenerating
configure, unlike today.

I had also started out by making the new GDB_AC_LIBMCHECK itself
handle the yes/no default fallback depending on release/developement,
but since I had split out 'development' to a separate script, and, GDB
needs the python checks anyway (hence we'd need to do the python
checks in gdb's configure.ac, and pass in a 'default lmcheck yes/no'
parameter to GDB_AC_LIBMCHECK anyway), I ended up keeping
GDB_AC_LIBMCHECK isolated from the 'development' global.  IOW, it's
the caller's business to handle it.

Tested on x86_64 Fedora 17.  Built GDB and GDBserver with and without
--enable-libmcheck, and observed --enable-libmcheck overrides the
disablement of -lmcheck caused by python supporting threads, and that
GDBserver links with -lmcheck when expected.  Also observed that
changing the 'development' global, and issuing "make" triggers a
relink, and '-lmcheck' is included or not from the link accordingly.

gdb/
2013-07-03  Pedro Alves  <palves@redhat.com>

	* Makefile.in (config.status): Depend on development.sh.
	(aclocal_m4_deps): Add libmcheck.m4.
	* acinclude.m4: Include libmcheck.m4.
	* configure.ac: Source development.sh instead of setting
	'development' here.  --enable-libmcheck/--disable-libmcheck code
	factored out to GDB_AC_LIBMCHECK.  Run it.
	* development.sh: New file.
	* libmcheck.m4: New file.
	* configure: Regenerate.

gdb/gdbserver/
2013-07-03  Pedro Alves  <palves@redhat.com>

	* Makefile.in (config.status): Depend on development.sh.
	* acinclude.m4: Include libmcheck.m4.
	* configure: Regenerate.
2013-07-03 13:25:46 +00:00
Mircea Gherzan 7a9a748743 gdbserver, win32: fix some function typedefs
2013-05-25  Mircea Gherzan  <mircea.gherzan@intel.com>

gdbserver/
	* win32-low.c (winapi_DebugActiveProcessStop): Move the WINAPI
	attribute inside the parentheses.
	(winapi_DebugSetProcessKillOnExit): Ditto.
	(winapi_DebugBreakProcess): Ditto.
	(winapi_GenerateConsoleCtrlEvent): Ditto.

Change-Id: I3aab72f2a1725a46b9da0e41a4ba08d7886284b9
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
2013-07-02 11:59:24 +00:00
Mircea Gherzan 49b64de6e4 gdbserver: avoid empty structs
2013-06-25  Mircea Gherzan  <mircea.gherzan@intel.com>

gdbserver/

	* notif.h (notif_event): Add a dummy member to avoid compiler
	errors.

Change-Id: I490dbdb70a24f52b3947371f7c0397bf7a18423c
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
2013-07-02 10:08:01 +00:00
Pedro Alves d5749ee715 [GDBserver] hostio.c: Fallback to packet buffer size if PATH_MAX is not available.
PATH_MAX is not defined on systems which have no limit on filename
length, such as GNU/Hurd.  As designed, the hostio RSP packets carry
the paths as parameters in the request/reply packets, which themselves
have an upper size limit, so lifting the filename limit completely
would require a redesign with new hostio packets.  While that doesn't
happen, we can at least support filename lengths as long as the packet
buffer can fit.

gdb/gdbserver/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* hostio.c (HOSTIO_PATH_MAX): Define.
	(require_filename, handle_open, handle_unlink, handle_readlink):
	Use it.
2013-07-01 11:29:17 +00:00
Pedro Alves d8d2a3ee47 Normalize on PATH_MAX instead of MAXPATHLEN throughout.
With the pathmax gnulib module in place, we can use PATH_MAX
consistently throughout, instead of the current mixbag of PATH_MAX and
MAXPATHLEN uses.  It's no longer necessary to include sys/param.h
(supposedly, I can't check all ports touched here) for MAXPATHLEN.

Don't remove sys/param.h from GDB's configure.ac, as later tests in
the file use HAVE_SYS_PARAM_H checks.

Tested on x86_64 Fedora 17.

Also cross-built for --host=i686-w64-mingw32, and --host=i586-pc-msdosdjgpp.

gdb/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* defs.h: Include "pathmax.h".
	* utils.c: Don't include sys/param.h.
	(gdb_realpath): Remove code that checks for MAXPATHLEN.
	* solib-ia64-hpux.c (ia64_hpux_handle_load_event): Use PATH_MAX
	instead of MAXPATHLEN.
	* solib-sunos.c: Don't include sys/param.h.
	* xcoffread.c: Don't include sys/param.h.
	* bsd-kvm.c: Don't include sys/param.h.
	* darwin-nat.c: Don't include sys/param.h.
	(darwin_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
	* darwin-nat-info.c: Don't include sys/param.h.
	* fbsd-nat.c (fbsd_pid_to_exec_file): Use PATH_MAX instead of
	MAXPATHLEN.
	* i386obsd-nat.c: Don't include sys/param.h.
	* inf-child.c: Don't include sys/param.h.
	(inf_child_fileio_readlink): Use PATH_MAX instead of MAXPATHLEN.
	* linux-fork.c: Don't include sys/param.h.
	(fork_save_infrun_state): Use PATH_MAX instead of MAXPATHLEN.
	* linux-nat.c: Don't include sys/param.h.
	(linux_child_pid_to_exec_file, linux_proc_pending_signals)
	(linux_proc_pending_signals): Use PATH_MAX instead of MAXPATHLEN.
	* m68klinux-nat.c: Don't include sys/param.h.
	* nbsd-nat.c: Don't include sys/param.h.
	(nbsd_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
	* ppc-linux-nat.c: Don't include sys/param.h.
	* rs6000-nat.c: Don't include sys/param.h.
	* spu-linux-nat.c. Don't include sys/param.h.
	* windows-nat.c: Don't include sys/param.h.
	* xtensa-linux-nat.c: Don't include sys/param.h.
	* config/i386/nm-fbsd.h: Don't include sys/param.h.

gdb/gdbserver/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* server.h: Include "pathmax.h".
	* linux-low.c: Don't include sys/param.h.
	(linux_pid_exe_is_elf_64_file): Use PATH_MAX instead of
	MAXPATHLEN.
	* win32-low.c: Don't include sys/param.h.
	(win32_create_inferior): Use PATH_MAX instead of MAXPATHLEN.
2013-07-01 11:28:30 +00:00
Pedro Alves bc7dea8de9 Rely on gnulib's unistd.h replacement.
With gnulib's unistd module, we can assume unistd.h is always present, and that
STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO are always defined.

Don't remove unistd.h from GDB's configure.ac, as later tests in the
file use HAVE_UNISTD_H checks.

gdb/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* defs.h: Don't check HAVE_UNISTD_H before including <unistd.h>.
	(STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO): Delete.
	* tracepoint.c: Don't check HAVE_UNISTD_H before including
	<unistd.h>.

gdb/gdbserver/
2013-07-01  Pedro Alves  <palves@redhat.com>

	* event-loop.c: Don't check HAVE_UNISTD_H before including
	<unistd.h>.
	* gdbreplay.c: Likewise.
	* remote-utils.c: Likewise.
	* server.c: Likewise.
	* configure.ac: Don't check for unistd.h.
	* configure: Regenerate.
2013-07-01 11:19:27 +00:00
Tom Tromey d6c2da5446 move version.in from gdb/common back to gdb
This reverts part of the earlier version.in change.  It moves
version.in back to the gdb directory.  This works around the CVS bug
we've found.

gdb
	* Makefile.in (version.c): Use version.in, not
	common/version.in.
	* common/create-version.sh: Likewise.
	* common/version.in: Move...
	* version.in: ...here.
gdb/doc
	* Makefile.in (version.subst): Use version.in, not
	common/version.in.
	* gdbint.texinfo (Versions and Branches, Releasing GDB):
	Likewise.
gdb/gdbserver
	* Makefile.in (version.c): Use version.in, not
	common/version.in.
sim/common
	* Make-common.in (version.c): Use version.in, not
	common/version.in.
	* create-version.sh: Likewise.
sim/ppc:
	* Make-common.in (version.c): Use version.in, not
	common/version.in.
2013-06-28 18:59:51 +00:00
Mircea Gherzan 257b6bec77 gdbserver: fix the standalone build
When directly invoking gdb/gdbserver/configure && make, the build will
fail because the $(host_alias) is empty and thus create-version.sh does
not get enough parameters.

The output of gdbserver --version without this patch (built like above):

  [...]
  This gdbserver was configured as ""

After applying this patch:

  [...]
  This gdbserver was configured as "x86_64-unknown-linux-gnu"

2013-06-28  Mircea Gherzan  <mircea.gherzan@intel.com>

gdbserver:

	* configure.ac (version_host, version_target): Set and AC_SUBST
	them.
	* configure: Rebuild.
	* Makefile.in (version_host, version_target): Get from
	configure.
	(version.c): Use $(version_host) and $(version_target).

Change-Id: Id48240532ad3d624ec78867a6db5ebd4c09583ff
Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
2013-06-28 12:29:15 +00:00
Dmitry Kozlov 86ebe1497f Fix trace status to output username without trailing colon. 2013-06-26 15:24:10 +00:00
Dmitry Kozlov f30aa5affe Fix trace-status to output proper start-time and stop-time. 2013-06-26 15:14:39 +00:00
Yao Qi 28a9351183 gdb/
2013-06-26  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* ctf.c (ctf_traceframe_info): Push trace state variables
	present in the trace data into the traceframe info object.
	* breakpoint.c (DEF_VEC_I): Remove.
	* common/filestuff.c (DEF_VEC_I): Likewise.
	* dwarf2loc.c (DEF_VEC_I): Likewise.
	* mi/mi-main.c (DEF_VEC_I): Likewise.
	* common/gdb_vecs.h (DEF_VEC_I): Define vector for int.
	* features/traceframe-info.dtd: Add tvar element and its
	attributes.
	* tracepoint.c (free_traceframe_info): Free vector 'tvars'.
	(build_traceframe_info): Push trace state variables present in the
	trace data into the traceframe info object.
	(traceframe_info_start_tvar): New function.
	(tvar_attributes): New.
	(traceframe_info_children): Add "tvar" element.
	* tracepoint.h (struct traceframe_info) <tvars>: New field.

	* NEWS: Mention the change in GDB and GDBserver.

gdb/doc:

2013-06-26  Pedro Alves  <pedro@codesourcery.com>

	* gdb.texinfo (Traceframe Info Format): Document tvar element and
	its attributes.

gdb/gdbserver:

2013-06-26  Pedro Alves  <pedro@codesourcery.com>

	* tracepoint.c (build_traceframe_info_xml): Output trace state
	variables present in the trace buffer.
2013-06-26 08:01:57 +00:00
Tom Tromey 0120846339 don't keep a gdb-specific date
Right now there are two nightly commits to update a file in the tree
with the current date.  One commit is for BFD, one is for gdb.

It seems unnecessary to me to do this twice.  We can make do with a
single such commit.

This patch changes gdb in a minimal way to reuse the BFD date -- it
extracts it from bfd/version.h and changes version.in to use the
placeholder string "DATE" for those times when a date is wanted.

I propose removing the cron job that updates the version on trunk, and
then check in this patch.

For release branches, we can keep the cron job, but just tell it to
rewrite bfd/version.h.  I believe this is a simple change in the
crontab -- the script will work just fine on this file.

This also moves version.in and version.h into common/, to reflect
their shared status; and updates gdbserver to use version.h besides.

	* common/create-version.sh: New file.
	* Makefile.in (version.c): Use bfd/version.h, common/version.in,
	create-version.sh.
	(HFILES_NO_SRCDIR): Use common/version.h.
	* version.in: Move to ...
	* common/version.in: ... here.  Replace date with "DATE".
	* version.h: Move to ...
	* common/version.h: ... here.
gdbserver:
	* Makefile.in (version.c): Use bfd/version.h, common/version.in,
	create-version.sh.
	(version.o): Remove.
	* gdbreplay.c: Include version.h.
	(version, host_name): Don't declare.
	* server.h: Include version.h.
	(version, host_name): Don't declare.
doc:
	* Makefile.in (POD2MAN1, POD2MAN5): Use version.subst.
	(GDBvn.texi): Use version.subst.
	(version.subst): New target.
	(mostlyclean): Remove version.subst.
2013-06-24 15:06:27 +00:00
Pedro Alves 760256f967 [GDBserver] Fix gdb.threads/siginfo-threads.exp, gdb.base/siginfo-obj.exp regressions.
This fixes the regressions reported at
<http://sourceware.org/ml/gdb-patches/2013-06/msg00280.html>:

 $ runtest-gdbserver gdb.base/siginfo-obj.exp gdb.base/siginfo-thread.exp gdb.threads/siginfo-threads.exp
 Running ./gdb.base/siginfo-thread.exp ...
 FAIL: gdb.base/siginfo-thread.exp: p ssi_addr
 Running ./gdb.threads/siginfo-threads.exp ...
 FAIL: gdb.threads/siginfo-threads.exp: signal 0 si_pid
 FAIL: gdb.threads/siginfo-threads.exp: signal 1 si_pid
 FAIL: gdb.threads/siginfo-threads.exp: signal 2 si_pid
 FAIL: gdb.threads/siginfo-threads.exp: signal 3 si_pid
 Running ./gdb.base/siginfo-obj.exp ...
 FAIL: gdb.base/siginfo-obj.exp: p ssi_addr
 FAIL: gdb.base/siginfo-obj.exp: p ssi_addr

The multi-arch patch made GDBserver do the the wrong siginfo layout
conversion, because most uses of `linux_is_elf64' were removed, and it
ended up never set.  A global really is the wrong thing to use as
elf64-ness is a per-process property; `linux_is_elf64' was just
accidentally left behind.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2013-06-12  Pedro Alves  <palves@redhat.com>

	* linux-x86-low.c (linux_is_elf64): Delete global.
	(x86_siginfo_fixup): Replace reference to `linux_is_elf64' global
	with local linux_pid_exe_is_elf_64_file use.
2013-06-12 16:05:39 +00:00
Pedro Alves 030031eed5 Lazily allocate 'struct regsets_info'::disabled_regsets.
There's no need for every arch to pre-allocate disabled_regsets.
Chances are the array won't be used.

(I have a hunch that with some more work we could dispense with
initialize_regsets_info.)

Tested on x86_64 Fedora 17 w/ -lmcheck.

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

	* linux-low.c (regset_disabled, disable_regset): New functions.
	(regsets_fetch_inferior_registers)
	(regsets_store_inferior_registers): Use them.
	(initialize_regsets_info); Don't allocate the disabled_regsets
	array here.
	* linux-low.h (struct regsets_info) <disabled_regsets>: Extend
	comment.
2013-06-11 18:05:57 +00:00
Pedro Alves 5da6eb0a10 Fix regression from multi-arch patch.
This fixes the regression reported at
<http://sourceware.org/ml/gdb-patches/2013-06/msg00185.html>.

GDBserver was reaching:

static int
regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
				  struct regcache *regcache)
{
  struct regset_info *regset;
  int saw_general_regs = 0;
  int pid;
  struct iovec iov;

  regset = regsets_info->regsets;

  pid = lwpid_of (get_thread_lwp (current_inferior));
  while (regset->size >= 0)
    {
      void *buf, *data;
      int nt_type, res;

      if (regset->size == 0
	  || regsets_info->disabled_regsets[regset - regsets_info->regsets])
	{
>>>>>>>	  regset ++;      <<<<<<<  HERE
	  continue;
	}

Because info->disabled_regsets[] was not being initialized, and that
causes all sorts of wrong.

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

	* linux-low.c (initialize_regsets_info): Use xcalloc instead of
	xmalloc.
2013-06-11 17:26:25 +00:00
Pedro Alves 7e5aaa093c [GDBserver] Initialize the x32 avx target description.
All target descriptions must be initialized at startup, but this one was forgotten.

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

	* linux-x86-low.c (initialize_low_arch): Call
	init_registers_x32_avx_linux.
2013-06-11 13:32:52 +00:00
Jan Kratochvil d878444cd9 gdb/gdbserver/
Fix compatibility with Android Bionic.
	* linux-low.c (linux_qxfer_libraries_svr4): Ignore first entry even if
	it is not empty.
2013-06-09 17:08:47 +00:00
Pedro Alves 5f2b57b5ec Mention PR server/14823 in ChangeLogs. 2013-06-07 10:55:22 +00:00
Pedro Alves 3aee891821 [GDBserver] Multi-process + multi-arch
This patch makes GDBserver support multi-process + biarch.

Currently, if you're debugging more than one process at once with a
single gdbserver (in extended-remote mode), then all processes must
have the same architecture (e.g., 64-bit vs 32-bit).  Otherwise, you
see this:

Added inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
Reading symbols from /home/pedro/gdb/tests/main32...done.
Temporary breakpoint 2 at 0x4004cf: main. (2 locations)
Starting program: /home/pedro/gdb/tests/main32
warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
... etc, etc ...

Even though the process was running a 32-bit program, GDBserver sent
back to GDB a register set in 64-bit layout.

A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a
while ago made GDB track a target_gdbarch per inferior, and as
consequence, fetch a target description per-inferior.  This patch is
the GDBserver counterpart, that makes GDBserver keep track of each
process'es XML target description and register layout.  So in the
example above, GDBserver will send the correct register set in 32-bit
layout to GDB.

A new "struct target_desc" object (tdesc for short) is added, that
holds the target description and register layout information about
each process.  Each `struct process_info' holds a pointer to a target
description.  The regcache also gains a pointer to a target
description, mainly for convenience, and parallel with GDB (and
possible future support for programs that flip processor modes).

The low target's arch_setup routines are responsible for setting the
process'es correct tdesc.  This isn't that much different to how
things were done before, except that instead of detecting the inferior
process'es architecture and calling the corresponding
init_registers_FOO routine, which would change the regcache layout
globals and recreate the threads' regcaches, the regcache.c globals
are gone, and the init_registers_$BAR routines now each initialize a
separate global struct target_desc object (one for each arch variant
GDBserver supports), and so all the init_registers_$BAR routines that
are built into GDBserver are called early at GDBserver startup time
(similarly to how GDB handles its built-in target descriptions), and
then the arch_setup routine is responsible for making
process_info->tdesc point to one of these target description globals.
The regcache module is all parameterized to get the regcache's layout
from the tdesc object instead of the old register_bytes, etc. globals.

The threads' regcaches are now created lazily.  The old scheme where
we created each of them when we added a new thread doesn't work
anymore, because we add the main thread/lwp before we see it stop for
the first time, and it is only when we see the thread stop for the
first time that we have a chance of determining the inferior's
architecture (through the_low_target.arch_setup).  Therefore when we
add the main thread we don't know which architecture/tdesc its
regcache should have.

This patch makes the gdb.multi/multi-arch.exp test now pass against
(extended-remote) GDBserver.  It currently fails, without this patch.

The IPA also uses the regcache, so it gains a new global struct
target_desc pointer, which points at the description of the process it
is loaded in.

Re. the linux-low.c & friends changes.  Since the register map
etc. may differ between processes (64-bit vs 32-bit) etc., the
linux_target_ops num_regs, regmap and regset_bitmap data fields are no
longer sufficient.  A new method is added in their place that returns
a pointer to a new struct that includes all info linux-low.c needs to
access registers of the current inferior.

The patch/discussion that originally introduced
linux-low.c:disabled_regsets mentions that the disabled_regsets set
may be different per mode (in a biarch setup), and indeed that is
cleared whenever we start a new (first) inferior, so that global is
moved as well behind the new `struct regs_info'.

On the x86 side:

I simply replaced the i387-fp.c:num_xmm_registers global with a check
for 64-bit or 32-bit process, which is equivalent to how the global
was set.  This avoided coming up with some more general mechanism that
would work for all targets that use this module (GNU/Linux, Windows,
etc.).

Tested:

  GNU/Linux IA64
  GNU/Linux MIPS64
  GNU/Linux PowerPC (Fedora 16)
  GNU/Linux s390x (Fedora 16)
  GNU/Linux sparc64 (Debian)
  GNU/Linux x86_64, -m64 and -m32 (Fedora 17)

Cross built, and smoke tested:

  i686-w64-mingw32, under Wine.
  GNU/Linux TI C6x, by Yao Qi.

Cross built but otherwise not tested:

  aarch64-linux-gnu
  arm-linux-gnu
  m68k-linux
  nios2-linux-gnu
  sh-linux-gnu
  spu
  tilegx-unknown-linux-gnu

Completely untested:

  GNU/Linux Blackfin
  GNU/Linux CRIS
  GNU/Linux CRISv32
  GNU/Linux TI Xtensa
  GNU/Linux M32R
  LynxOS
  QNX NTO

gdb/gdbserver/
2013-06-07  Pedro Alves  <palves@redhat.com>

	* Makefile.in (OBS): Add tdesc.o.
	(IPA_OBJS): Add tdesc-ipa.o.
	(tdesc-ipa.o): New rule.
	* ax.c (gdb_eval_agent_expr): Adjust register_size call to new
	interface.
	* linux-low.c (new_inferior): Delete.
	(disabled_regsets, num_regsets): Delete.
	(linux_add_process): Adjust to set the new per-process
	new_inferior flag.
	(linux_detach_one_lwp): Adjust to call regcache_invalidate_thread.
	(linux_wait_for_lwp): Adjust.  Only call arch_setup if the event
	was a stop.  When calling arch_setup, switch the current inferior
	to the thread that got an event.
	(linux_resume_one_lwp): Adjust to call regcache_invalidate_thread.
	(regsets_fetch_inferior_registers)
	(regsets_store_inferior_registers): New regsets_info parameter.
	Adjust to use it.
	(linux_register_in_regsets): New regs_info parameter.  Adjust to
	use it.
	(register_addr, fetch_register, store_register): New usrregs_info
	parameter.  Adjust to use it.
	(usr_fetch_inferior_registers, usr_store_inferior_registers): New
	parameter regs_info.  Adjust to use it.
	(linux_fetch_registers): Get the current inferior's regs_info, and
	adjust to use it.
	(linux_store_registers): Ditto.
	[HAVE_LINUX_REGSETS] (initialize_regsets_info): New.
	(initialize_low): Don't initialize the target_regsets here.  Call
	initialize_low_arch.
	* linux-low.h (target_regsets): Delete declaration.
	(struct regsets_info): New.
	(struct usrregs_info): New.
	(struct regs_info): New.
	(struct process_info_private) <new_inferior>: New field.
	(struct linux_target_ops): Delete the num_regs, regmap, and
	regset_bitmap fields.  New field regs_info.
	[HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare.
	* i387-fp.c (num_xmm_registers): Delete.
	(i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno
	calls to new interface.
	(i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache)
	(i387_xsave_to_cache): Adjust find_regno calls to new interface.
	Infer the number of xmm registers from the regcache's target
	description.
	* i387-fp.h (num_xmm_registers): Delete.
	* inferiors.c (add_thread): Don't install the thread's regcache
	here.
	* proc-service.c (gregset_info): Fetch the current inferior's
	regs_info.  Adjust to use it.
	* regcache.c: Include tdesc.h.
	(register_bytes, reg_defs, num_registers)
	(gdbserver_expedite_regs): Delete.
	(get_thread_regcache): If the thread doesn't have a regcache yet,
	create one, instead of aborting gdbserver.
	(regcache_invalidate_one): Rename to ...
	(regcache_invalidate_thread): ... this.
	(regcache_invalidate_one): New.
	(regcache_invalidate): Only invalidate registers of the current
	process.
	(init_register_cache): Add target_desc parameter, and use it.
	(new_register_cache): Ditto.  Assert the target description has a
	non zero registers_size.
	(regcache_cpy): Add assertions.  Adjust.
	(realloc_register_cache, set_register_cache): Delete.
	(registers_to_string, registers_from_string): Adjust.
	(find_register_by_name, find_regno, find_register_by_number)
	(register_cache_size): Add target_desc parameter, and use it.
	(free_register_cache_thread, free_register_cache_thread_one)
	(regcache_release, register_cache_size): New.
	(register_size): Add target_desc parameter, and use it.
	(register_data, supply_register, supply_register_zeroed)
	(supply_regblock, supply_register_by_name, collect_register)
	(collect_register_as_string, collect_register_by_name): Adjust.
	* regcache.h (struct target_desc): Forward declare.
	(struct regcache) <tdesc>: New field.
	(init_register_cache, new_register_cache): Add target_desc
	parameter.
	(regcache_invalidate_thread): Declare.
	(regcache_invalidate_one): Delete declaration.
	(regcache_release): Declare.
	(find_register_by_number, register_cache_size, register_size)
	(find_regno): Add target_desc parameter.
	(gdbserver_expedite_regs, gdbserver_xmltarget): Delete
	declarations.
	* remote-utils.c: Include tdesc.h.
	(outreg, prepare_resume_reply): Adjust.
	* server.c: Include tdesc.h.
	(gdbserver_xmltarget): Delete declaration.
	(get_features_xml, process_serial_event): Adjust.
	* server.h [IN_PROCESS_AGENT] (struct target_desc): Forward
	declare.
	(struct process_info) <tdesc>: New field.
	(ipa_tdesc): Declare.
	* tdesc.c: New file.
	* tdesc.h: New file.
	* tracepoint.c: Include tdesc.h.
	[IN_PROCESS_AGENT] (ipa_tdesc): Define.
	(get_context_regcache): Adjust to pass ipa_tdesc down.
	(do_action_at_tracepoint): Adjust to get the register cache size
	from the context regcache's description.
	(traceframe_walk_blocks): Adjust to get the register cache size
	from the current trace frame's description.
	(traceframe_get_pc): Adjust to get current trace frame's
	description and pass it down.
	(gdb_collect): Adjust to get the register cache size from the
	IPA's description.
	* linux-amd64-ipa.c (tdesc_amd64_linux): Declare.
	(gdbserver_xmltarget): Delete.
	(initialize_low_tracepoint): Set the ipa's target description.
	* linux-i386-ipa.c (tdesc_i386_linux): Declare.
	(initialize_low_tracepoint): Set the ipa's target description.
	* linux-x86-low.c: Include tdesc.h.
	[__x86_64__] (is_64bit_tdesc): New.
	(ps_get_thread_area, x86_get_thread_area): Use it.
	(i386_cannot_store_register): Rename to ...
	(x86_cannot_store_register): ... this.  Use is_64bit_tdesc.
	(i386_cannot_fetch_register): Rename to ...
	(x86_cannot_fetch_register): ... this.  Use is_64bit_tdesc.
	(x86_fill_gregset, x86_store_gregset): Adjust register_size calls
	to new interface.
	(target_regsets): Rename to ...
	(x86_regsets): ... this.
	(x86_get_pc, x86_set_pc): Adjust register_size calls to new
	interface.
	(x86_siginfo_fixup): Use is_64bit_tdesc.
	[__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux)
	(tdesc_x32_avx_linux, tdesc_x32_linux)
	(tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux):
	Declare.
	(x86_linux_update_xmltarget): Delete.
	(I386_LINUX_XSAVE_XCR0_OFFSET): Define.
	(have_ptrace_getfpxregs, have_ptrace_getregset): New.
	(AMD64_LINUX_USER64_CS): New.
	(x86_linux_read_description): New, based on
	x86_linux_update_xmltarget.
	(same_process_callback): New.
	(x86_arch_setup_process_callback): New.
	(x86_linux_update_xmltarget): New.
	(x86_regsets_info): New.
	(amd64_linux_regs_info): New.
	(i386_linux_usrregs_info): New.
	(i386_linux_regs_info): New.
	(x86_linux_regs_info): New.
	(x86_arch_setup): Reimplement.
	(x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc.
	(x86_emit_ops): Ditto.
	(the_low_target): Adjust.  Install x86_linux_regs_info,
	x86_cannot_fetch_register, and x86_cannot_store_register.
	(initialize_low_arch): New.
	* linux-ia64-low.c (tdesc_ia64): Declare.
	(ia64_fetch_register): Adjust.
	(ia64_usrregs_info, regs_info): New globals.
	(ia64_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-sparc-low.c (tdesc_sparc64): Declare.
	(sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack):
	Adjust.
	(sparc_arch_setup): New function.
	(sparc_regsets_info, sparc_usrregs_info, regs_info): New globals.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l)
	(tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l)
	(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l)
	(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l)
	(tdesc_powerpc_64l, tdesc_powerpc_altivec64l)
	(tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l)
	(tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l)
	(tdesc_powerpc_isa205_vsx64l): Declare.
	(ppc_cannot_store_register, ppc_collect_ptrace_register)
	(ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc)
	(ppc_set_pc, ppc_get_hwcap): Adjust.
	(ppc_usrregs_info): Forward declare.
	(!__powerpc64__) ppc_regmap_adjusted: New global.
	(ppc_arch_setup): Adjust to the current process'es target
	description.
	(ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset)
	(ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse)
	(ppc_store_evrregset): Adjust.
	(target_regsets): Rename to ...
	(ppc_regsets): ... this, and make static.
	(ppc_usrregs_info, ppc_regsets_info, regs_info): New globals.
	(ppc_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1)
	(tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1)
	(tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1)
	(tdesc_s390x_linux64v2): Declare.
	(s390_collect_ptrace_register, s390_supply_ptrace_register)
	(s390_fill_gregset, s390_store_last_break): Adjust.
	(target_regsets): Rename to ...
	(s390_regsets): ... this, and make static.
	(s390_get_pc, s390_set_pc): Adjust.
	(s390_get_hwcap): New target_desc parameter, and use it.
	[__s390x__] (have_hwcap_s390_high_gprs): New global.
	(s390_arch_setup): Adjust to set the current process'es target
	description.  Don't adjust the regmap.
	(s390_usrregs_info, s390_regsets_info, regs_info): New globals.
	[__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264)
	(regs_info_3264): New globals.
	(s390_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux)
	(tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare.
	[__mips64] (init_registers_mips_linux)
	(init_registers_mips_dsp_linux): Delete defines.
	[__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines.
	(have_dsp): New global.
	(mips_read_description): New, based on mips_arch_setup.
	(mips_arch_setup): Reimplement.
	(get_usrregs_info): New function.
	(mips_cannot_fetch_register, mips_cannot_store_register)
	(mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset)
	(mips_fill_fpregset, mips_store_fpregset): Adjust.
	(target_regsets): Rename to ...
	(mips_regsets): ... this, and make static.
	(mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info)
	(dsp_regs_info, regs_info): New globals.
	(mips_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt)
	(tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon):
	Declare.
	(arm_fill_vfpregset, arm_store_vfpregset): Adjust.
	(arm_read_description): New, with bits factored from
	arm_arch_setup.
	(arm_arch_setup): Reimplement.
	(target_regsets): Rename to ...
	(arm_regsets): ... this, and make static.
	(arm_regsets_info, arm_usrregs_info, regs_info): New globals.
	(arm_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-m68k-low.c (tdesc_m68k): Declare.
	(target_regsets): Rename to ...
	(m68k_regsets): ... this, and make static.
	(m68k_regsets_info, m68k_usrregs_info, regs_info): New globals.
	(m68k_regs_info): New function.
	(m68k_arch_setup): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-sh-low.c (tdesc_sharch): Declare.
	(target_regsets): Rename to ...
	(sh_regsets): ... this, and make static.
	(sh_regsets_info, sh_usrregs_info, regs_info): New globals.
	(sh_regs_info, sh_arch_setup): New functions.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-bfin-low.c (tdesc_bfin): Declare.
	(bfin_arch_setup): New function.
	(bfin_usrregs_info, regs_info): New globals.
	(bfin_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-cris-low.c (tdesc_cris): Declare.
	(cris_arch_setup): New function.
	(cris_usrregs_info, regs_info): New globals.
	(cris_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-cris-low.c (tdesc_crisv32): Declare.
	(cris_arch_setup): New function.
	(cris_regsets_info, cris_usrregs_info, regs_info): New globals.
	(cris_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-m32r-low.c (tdesc_m32r): Declare.
	(m32r_arch_setup): New function.
	(m32r_usrregs_info, regs_info): New globals.
	(m32r_regs_info): Adjust.
	(initialize_low_arch): New function.
	* linux-tic6x-low.c (tdesc_tic6x_c64xp_linux)
	(tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare.
	(tic6x_usrregs_info): Forward declare.
	(tic6x_read_description): New function, based on ...
	(tic6x_arch_setup): ... this.  Reimplement.
	(target_regsets): Rename to ...
	(tic6x_regsets): ... this, and make static.
	(tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals.
	(tic6x_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-xtensa-low.c (tdesc_xtensa): Declare.
	(xtensa_fill_gregset, xtensa_store_gregset): Adjust.
	(target_regsets): Rename to ...
	(xtensa_regsets): ... this, and make static.
	(xtensa_regsets_info, xtensa_usrregs_info, regs_info): New
	globals.
	(xtensa_arch_setup, xtensa_regs_info): New functions.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* linux-nios2-low.c (tdesc_nios2_linux): Declare.
	(nios2_arch_setup): Set the current process'es tdesc.
	(target_regsets): Rename to ...
	(nios2_regsets): ... this.
	(nios2_regsets_info, nios2_usrregs_info, regs_info): New globals.
	(nios2_regs_info): New function.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
        * linux-aarch64-low.c (tdesc_aarch64): Declare.
        (aarch64_arch_setup): Set the current process'es tdesc.
        (target_regsets): Rename to ...
        (aarch64_regsets): ... this.
        (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals.
        (aarch64_regs_info): New function.
        (the_low_target): Adjust.
        (initialize_low_arch): New function.
	* linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare
	globals.
	(target_regsets): Rename to ...
	(tile_regsets): ... this.
	(tile_regsets_info, tile_usrregs_info, regs_info): New globals.
	(tile_regs_info): New function.
	(tile_arch_setup): Set the current process'es tdesc.
	(the_low_target): Adjust.
	(initialize_low_arch): New function.
	* spu-low.c (tdesc_spu): Declare.
	(spu_create_inferior, spu_attach): Set the new process'es tdesc.
	* win32-arm-low.c (tdesc_arm): Declare.
	(arm_arch_setup): New function.
	(the_low_target): Install arm_arch_setup instead of
	init_registers_arm.
	* win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare.
	(init_windows_x86): Rename to ...
	(i386_arch_setup): ... this.  Set `win32_tdesc'.
	(the_low_target): Adjust.
	* win32-low.c (win32_tdesc): New global.
	(child_add_thread): Don't create the thread cache here.
	(do_initial_child_stuff): Set the new process'es tdesc.
	* win32-low.h (struct target_desc): Forward declare.
	(win32_tdesc): Declare.
	* lynx-i386-low.c (tdesc_i386): Declare global.
	(lynx_i386_arch_setup): Set `lynx_tdesc'.
	* lynx-low.c (lynx_tdesc): New global.
	(lynx_add_process): Set the new process'es tdesc.
	* lynx-low.h (struct target_desc): Forward declare.
	(lynx_tdesc): Declare global.
	* lynx-ppc-low.c (tdesc_powerpc_32): Declare global.
	(lynx_ppc_arch_setup): Set `lynx_tdesc'.
	* nto-low.c (nto_tdesc): New global.
	(do_attach): Set the new process'es tdesc.
	* nto-low.h (struct target_desc): Forward declare.
	(nto_tdesc): Declare.
	* nto-x86-low.c (tdesc_i386): Declare.
	(nto_x86_arch_setup): Set `nto_tdesc'.

gdb/
2013-06-07  Pedro Alves  <palves@redhat.com>

	* regformats/regdat.sh: Output #include tdesc.h.  Make globals
	static.  Output a global target description pointer.
	(init_registers_${name}): Adjust to initialize a
	target description structure.
2013-06-07 10:46:59 +00:00
Doug Evans ac44adcb6a Add PR number to this entry:
PR server/15594
	* linux-x86-low.c (ps_get_thread_area): Properly extend address to
	64 bits in 64-cross-32 environment.
2013-06-06 18:02:48 +00:00
Gary Benson b1fbec6251 2013-06-04 Gary Benson <gbenson@redhat.com>
* server.c (handle_query): Add "augmented-libraries-svr4-read+"
	to qSupported response when appropriate.
	(handle_qxfer_libraries_svr4): Allow qXfer:libraries-svr4:read
	with nonzero-length annex.
	* linux-low.c (linux_qxfer_libraries_svr4): Parse and handle
	arguments supplied in annex.
2013-06-04 12:59:21 +00:00
Doug Evans d1ec4ce7c9 * linux-x86-low.c (ps_get_thread_area): Properly extend address to
64 bits in 64-cross-32 environment.
2013-05-31 19:14:33 +00:00
Pedro Alves 9b25f2d30c [GDBserver][AArch64] Remove references to aarch64-without-fpu.xml.
The GDBserver Aarch64 port includes the aarch64-without-fpu
description in the build, but doesn't actually use it anywhere.  As
Linux always requires an FPU, just remove the dead code.

gdb/gdbserver/
2013-05-28  Pedro Alves  <palves@redhat.com>

	* Makefile.in (clean): Remove reference to aarch64-without-fpu.c.
	(aarch64-without-fpu.c): Delete rule.
	* configure.srv (aarch64*-*-linux*): Remove references to
	aarch64-without-fpu.o and aarch64-without-fpu.xml.
	* linux-aarch64-low.c (init_registers_aarch64_without_fpu): Remove
	declaration.
2013-05-28 10:41:17 +00:00
Pedro Alves 6740dc9c3e [gdbserver] Don't assume vCont;r ADDR1,ADDR2 comes with a ptid attached.
This bit:

+	  p1 = strchr (p, ':');
+	  decode_address (&resume_info[i].step_range_end, p, p1 - p);

should not expect the ':' to be there.  An action without a ptid is
valid:

 "If an action is specified with no thread-id, then it is applied to any
 threads that don't have a specific action specified"

This is handled further below:

      if (p[0] == 0)
	{
	  resume_info[i].thread = minus_one_ptid;
	  default_action = resume_info[i];

	  /* Note: we don't increment i here, we'll overwrite this entry
	     the next time through.  */
	}
      else if (p[0] == ':')

A stub that doesn't support and report to gdb thread ids at all (like
metal metal targets) only will always only see a single default action
with no ptid.

Use unpack_varlen_hex instead of decode_address.  The former doesn't
need to be told where the hex number ends, and it actually returns
that info instead, which we can use for validation.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2013-05-24  Pedro Alves  <palves@redhat.com>

	* server.c (handle_v_cont) <vCont;r>: Use unpack_varlen_hex
	instead of strchr/decode_address.  Error if the range isn't split
	with a ','.  Don't assume there's be a ':' in the action.
2013-05-24 11:28:06 +00:00
Pedro Alves c2d6af84da range stepping: gdbserver (x86 GNU/Linux)
This patch adds support for range stepping to GDBserver, teaching it
about vCont;r.

It'd be easy to enable this for all hardware single-step targets
without needing the linux_target_ops hook, however, at least PPC needs
special care, due to the fact that PPC atomic sequences can't be
hardware single-stepped through, a thing which GDBserver doesn't know
about.  So this leaves the support limited to x86/x86_64.

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

	* NEWS: Mention GDBserver range stepping support.

gdb/gdbserver/
2013-05-23  Yao Qi  <yao@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	* linux-low.c (lwp_in_step_range): New function.
	(linux_wait_1): If the thread was range stepping and stopped
	outside the stepping range, report the stop to GDB.  Otherwise,
	continue stepping.  Add range stepping debug output.
	(linux_set_resume_request): Copy the step range from the resume
	request to the lwp.
	(linux_supports_range_stepping): New.
	(linux_target_ops) <supports_range_stepping>: Set to
	linux_supports_range_stepping.
	* linux-low.h (struct linux_target_ops)
	<supports_range_stepping>: New field.
	(struct lwp_info) <step_range_start, step_range_end>: New fields.
	* linux-x86-low.c (x86_supports_range_stepping): New.
	(the_low_target) <supports_range_stepping>: Set to
	x86_supports_range_stepping.
	* server.c (handle_v_cont): Handle 'r' action.
	(handle_v_requests): Append ";r" if the target supports range
	stepping.
	* target.h (struct thread_resume) <step_range_start,
	step_range_end>: New fields.
	(struct target_ops) <supports_range_stepping>:
	New field.
	(target_supports_range_stepping): New macro.
2013-05-23 17:17:50 +00:00
Joel Brobecker 58794e1a64 [gdbserver/lynx178]: Fix null_ptid -vs- minus_one_ptid confusion in comment
gdb/gdbserver/ChangeLog:

        * lynx-low.c (lynx_resume): Fix null_ptid/minus_one_ptid
        confusion in comment.
2013-05-17 06:53:53 +00:00
Joel Brobecker d631c5a779 gdbserver/lynx178: spurious SIG61 signal when resuming inferior.
On ppc-lynx178, resuming the execution of a program after hitting
a breakpoint sometimes triggers a spurious SIG61 event:

    (gdb) cont
    Continuing.

    Program received signal SIG61, Real-time event 61.
    [Switching to Thread 39]
    0x10002324 in a_test.task1 (<_task>=0x3ffff774) at a_test.adb:30
    30          select  -- Task 1

From this point on, continuing again lets the signal kill the program.
Using "signal 0" or configuring GDB to discard the signal does not
help either, as the program immediately reports the same signal again.

What happens is the following:

  - GDB sends a single-step order to gdbserver: $vCont;s:31
    This tells GDBserver to do a step using thread 0x31=49.
    GDBserver does the step, and thread 49 receives the SIGTRAP
    indicating that the step has finished.

  - GDB then sends a "continue", but this time does not specify
    which thread to continue: $vCont;c
    GDBserver uses an arbitrary thread's ptid to resume the program's
    execution (the current_inferior's ptid was chosen for that).
    See lynx-low.c:lynx_resume:

        if (ptid_equal (ptid, minus_one_ptid))
          ptid = thread_to_gdb_id (current_inferior);

So far on all LynxOS platforms, this has been good enough. But
not so on LynxOS 178. If the ptid used to resume the execution
is not the same as the thread that did the step, we get the weird
signal.

This patch fixes the problem by saving the ptid of the thread
that last caused an event, received during a call to waitpid.
The ptid is saved in per-process private data.

gdb/gdbserver/ChangeLog:

        * lynx-low.c (struct process_info_private): New type.
        (lynx_add_process): New function.
        (lynx_create_inferior, lynx_attach): Replace calls to
        add_process by calls to lynx_add_process.
        (lynx_resume): If PTID is null, then try using
        current_process()->private->last_wait_event_ptid.
        Add comments.
        (lynx_clear_inferiors): Delete.  The contents of that function
        has been inlined in lynx_mourn;
        (lynx_wait_1): Save the ptid in the process's private data.
        (lynx_mourn): Free the process' private data.  Replace call
        to lynx_clear_inferiors by call to clear_inferiors.
2013-05-17 06:47:44 +00:00
Yao Qi 96f7a20fe9 gdb/gdbserver
* i386-low.c (i386_length_and_rw_bits): Move the comment to
	the right place.
2013-05-17 02:22:52 +00:00
Luis Machado db0dfaa0e6 * linux-low.c: Move definition checks upwards for PT_TEXT_ADDR,
PT_DATA_ADDR and PT_TEXT_END_ADDR.  Update comments.
	(linux_read_offsets): Remove PT_TEXT_ADDR, PT_DATA_ADDR and
	PT_TEXT_END_ADDR guards.  Update comments.
	(linux_target_op) <read_offsets>: Conditionally define to
	linux_read_offsets if the target is UCLIBC and if it defines
	PT_TEXT_ADDR, PT_DATA_ADDR and PT_TEXT_END_ADDR.
2013-05-16 10:31:49 +00:00
Sandra Loosemore 68f5f83833 2013-05-06 Sandra Loosemore <sandra@codesourcery.com>
Andrew Jenner  <andrew@codesourcery.com>

	gdb/gdbserver/
	* Makefile.in (SFILES): Add linux-nios2-low.c.
	(clean): Add action to delete nios2-linux.c.
	(nios2-linux.c): New rule.
	* configure.srv: Add nios2*-*-linux*.
	* linux-nios2-low.c: New.
2013-05-07 01:11:16 +00:00
Hafiz Abid Qadeer 1ebff1fdfd 2013-05-03 Hafiz Abid Qadeer <abidh@codesourcery.com>
* tracepoint.c (cmd_qtinit): Call 'stop_tracing'.

2013-05-03  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* status-stop.exp (test_tstart_tstart): Check for error
	returned by the second 'tstart' command.
2013-05-03 15:43:58 +00:00
Hui Zhu c65e009ff7 Fix format error of ChangeLog. 2013-04-25 08:03:31 +00:00
Hui Zhu f6150862d2 2013-04-25 Hui Zhu <hui@codesourcery.com>
PR gdb/15186

	* ax.c (ax_printf): Add fflush.
2013-04-25 02:58:05 +00:00
Tom Tromey 614c279dda PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
	(COMMON_OBS): Add filestuff.o.
	(filestuff.o): New target.
	* auto-load.c (auto_load_objfile_script_1): Use
	gdb_fopen_cloexec.
	* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
	* cli/cli-cmds.c (shell_escape): Call close_most_fds.
	* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
	* common/agent.c (gdb_connect_sync_socket): Use
	gdb_socket_cloexec.
	* common/filestuff.c: New file.
	* common/filestuff.h: New file.
	* common/linux-osdata.c (linux_common_core_of_thread)
	(command_from_pid, commandline_from_pid, print_source_lines)
	(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
	(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
	gdb_fopen_cloexec.
	* common/linux-procfs.c (linux_proc_get_int)
	(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
	* config.in, configure: Rebuild.
	* configure.ac: Don't check for sys/socket.h.  Check for
	fdwalk, pipe2.
	* corelow.c (core_open): Use gdb_open_cloexec.
	* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
	* fork-child.c (fork_inferior): Call close_most_fds.
	* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
	* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
	* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
	Use gdb_fopen_cloexec.
	(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
	gdb_open_cloexec.
	(linux_async_pipe): Use gdb_pipe_cloexec.
	* remote-fileio.c (remote_fileio_func_open): Use
	gdb_open_cloexec.
	* remote.c (remote_file_put, remote_file_get): Use
	gdb_fopen_cloexec.
	* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
	close_most_fds.
	* ser-tcp.c (net_open): Use gdb_socket_cloexec.
	* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
	* solib.c (solib_find): Use gdb_open_cloexec.
	* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
	* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
	(tfile_open): Use gdb_open_cloexec.
	* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
	* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
	* xml-support.c (xml_fetch_content_from_file): Use
	gdb_fopen_cloexec.
	* main.c (captured_main): Call notice_open_fds.
gdbserver
	* Makefile.in (SFILES): Add filestuff.c.
	(OBS): Add filestuff.o.
	(filestuff.o): New target.
	* config.in, configure: Rebuild.
	* configure.ac: Check for fdwalk, pipe2.
2013-04-22 16:46:15 +00:00
Pedro Alves 7d4e5717e0 Use AC_DEFINE for USE_THREAD_DB
Use AC_DEFINE for USE_THREAD_DB instead of manually passing it down
through -D flags.

gdb/gdbserver/
2013-04-17  Pedro Alves  <palves@redhat.com>

	* configure.ac (USE_THREAD_DB): Delete variable.
	(if test "$srv_linux_thread_db" = "yes"): AC_DEFINE USE_THREAD_DB.
	Don't AC_SUBST USE_THREAD_DB.
	* Makefile.in (INTERNAL_CFLAGS): Remove @USE_THREAD_DB@.
	* config.in, configure: Regenerate.
2013-04-17 09:58:15 +00:00
Pedro Alves d5c93e41a8 Only define 'struct lwp_info'::thread_known if using libthread-db.
A small cleanup.  'struct lwp_info'::thread_known is only useful for
thread-db.c.

gdbserver/
2013-04-16  Pedro Alves  <palves@redhat.com>

	* linux-low.h (struct lwp_info) <thread_known>: Move under
	the USE_THREAD_DB #ifdef.
2013-04-16 18:22:15 +00:00
Pedro Alves 04f5fe89ae Fix remaining GDBserver issues with !HAVE_THREAD_DB_H.
The previous patches are still not sufficient to build gdbserver with
our copy of thread_db.h.

../../../src/gdb/gdbserver/thread-db.c: In function ‘find_one_thread’:
../../../src/gdb/gdbserver/thread-db.c:316:6: error: ‘struct lwp_info’ has no member named ‘th’
../../../src/gdb/gdbserver/thread-db.c: In function ‘attach_thread’:
../../../src/gdb/gdbserver/thread-db.c:341:6: error: ‘struct lwp_info’ has no member named ‘th’
../../../src/gdb/gdbserver/thread-db.c: In function ‘thread_db_get_tls_address’:
../../../src/gdb/gdbserver/thread-db.c:514:47: error: ‘struct lwp_info’ has no member named ‘th’
make: *** [thread-db.o] Error 1

First, linux-low.h is including <thread_db.h> directly instead of our
gdb_thread_db.h, although thread-db.c includes the latter.  Then the
'th' field of struct lwp_info is only defined if HAVE_THREAD_DB_H is
defined, which is not true if we're using our replacement copy of
thread_db.h.  We have a USE_THREAD_DB symbol defined if we're building
thread-db.c that's ideal for this, however, it's currently only
defined when compiling linux-low.c (through a Makefile rule).  The
patch makes it defined when compiling any file.

gdb/gdbserver/
2013-04-16  Pedro Alves  <palves@redhat.com>

	* Makefile.in (INTERNAL_CFLAGS): Add @USE_THREAD_DB@.
	(linux-low.o): Delete rule.
	* linux-low.h: Always include "gdb_thread_db.h" instead of
	conditionally including thread_db.h.
	(struct lwp_info) <th>: Guard with #ifdef USE_THREAD_DB instead of
	HAVE_THREAD_DB_H.
2013-04-16 18:20:40 +00:00
Jan Kratochvil 480b27bfaa gdb/gdbserver/
* Makefile.in (install-only): Fix make install regression.
2013-04-07 05:53:22 +00:00
Jan Kratochvil 43662968f1 gdb/
Convert man pages to texinfo, new gdbinit.5 texinfo page.
	* Makefile.in (gdb.z): Remove.
	(install-only): Remove $(man1dir) and gdb.1 installation.
	* gdb.1: Remove.

gdb/gdbserver/
	Convert man pages to texinfo, new gdbinit.5 texinfo page.
	* Makefile.in (install-only): Remove $(man1dir) and gdbserver.1
	installation.
	* gdbserver.1: Remove.

gdb/doc/
	Convert man pages to texinfo, new gdbinit.5 texinfo page.
	* Makefile.in (mandir, man1dir, man5dir, SYSTEM_GDBINIT, MANCONF,
	(TEXI2POD, POD2MAN1, POD2MAN5, MAN1S, MAN5S, MANS, man): New.
	(diststuff): Add man.
	(install-man, install-man1, install-man5, uninstall-man, uninstall-man1)
	(uninstall-man5): New.
	(STAGESTUFF): Add *.1 and *.5.
	(GDBvn.texi): Add SYSTEM_GDBINIT.
	(gdb.1, gdbserver.1, gdbinit.5): New.
	(maintainer-clean realclean): Add $(MANS).
	(install): Add install-man.
	(uninstall): Add uninstall-man.
	* gdb.texinfo (@include gdb-cfg.texi): Wrap it by @c man begin INCLUDE.
	(@copying): Wrap it by @c man begin COPYRIGHT.
	(Top): Add Man Pages.
	(Man Pages, gdb man, gdbserver man, gdbinit man): New.
2013-04-05 20:01:33 +00:00
Pedro Alves 3e74e146f2 Linux: No need to set ptrace event options in fork/clone children.
Oleg Nesterov told me that the Linux kernel copies the parent's ptrace
options to fork/clone children, so there's no need for GDB to do that
manually.

I was actually a bit surprised, since I thought the ptracer had to
always set the ptrace options itself, and GDB is indeed calling
PTRACE_SETOPTIONS for each new fork child, if it'll stay attached.

Looking at the history of that code, I found that is was actually I
who added that set-ptrace-options-in-children bit, back in
http://sourceware.org/ml/gdb-patches/2009-05/msg00656.html.  But,
honestly, I don't recall why I needed that.  I think I may have just
blindly believed it was necessary.

I then looked back at the history of all the PTRACE_SETOPTIONS code we
have, and found that gdb never did copy the ptrace options before my
patch.  But, when gdbserver learnt to use PTRACE_EVENT_CLONE, at
http://sourceware.org/ml/gdb-patches/2007-10/msg00547.html, it was
made to do 'ptrace (PTRACE_SETOPTIONS, new_pid, 0,
PTRACE_O_TRACECLONE)' for all new clones.  Hmmm.  But, GDB itself
never did that, so it can't really ever have been necessary, I
believe, otherwise GDB should have been doing it too.

(GDBserver doesn't support following forks, and so naturally doesn't
do any PTRACE_SETOPTIONS on fork children.)

So this patch removes the -I believe- unnecessary ptrace syscalls.

Tested on x86_64 Fedora 17, native/gdbserver, and on x86_64 RHEL5
native/gdbserver (Linux 2.6.18, I think a ptrace-on-utrace kernel).
No regressions.

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

	* linux-nat.c (linux_child_follow_fork): Don't call
	linux_enable_event_reporting.
	(linux_handle_extended_wait): Don't call
	linux_enable_event_reporting.

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

	* linux-low.c (handle_extended_wait): Don't call
	linux_enable_event_reporting.
2013-03-22 14:52:26 +00:00
Tom Tromey a8347a2acd 2013-03-15 Tony Theodore <tonyt@logyst.com>
PR build/9098:
	* Makefile.in (SHELL): Use @SHELL@.
2013-03-15 17:30:27 +00:00
Sergio Durigan Junior eeb56fa757 2013-03-14 Sergio Durigan Junior <sergiodj@redhat.com>
* tracepoint.c (cmd_qtv): Initialize `val' with zero, silencing
	compiler warning.
2013-03-14 11:40:08 +00:00
Joel Brobecker 4fa7e2ff22 Extraneous NULL in linux_target_ops when HAVE_LINUX_BTRACE not defined
This fixes the followin error when HAVE_LINUX_BTRACE is not defined:

    linux-low.c:5943: error: excess elements in struct initializer
    linux-low.c:5943: error: (near initialization for 'linux_target_ops')

gdb/gdbserver/ChangeLog:

        * linux-low.c (linux_target_ops) [!HAVE_LINUX_BTRACE]:
        Remove extraneous NULL element.
2013-03-13 18:37:54 +00:00
Yao Qi 8ddb196517 * tracepoint.c (tfile_get_trace_state_variable_value): Look for
the last matched 'V' blcok in trace frame.

gdb/gdbserver:

	* tracepoint.c (traceframe_read_tsv): Look for the last matched
	'V' block in trace frame.

gdb/testsuite:

	* gdb.trace/tsv.exp (check_tsv): New.
	(top level): Save a tfile on current trace session. Call
	check_tsv on live target.  Load the tfile with target tfile
	and call check_tsv again.
2013-03-13 03:40:27 +00:00
Keith Seitz bbc13ae3db * ada-lang.c (ada_read_renaming_var_value): Pass const
pointer to expression string to parse_exp_1.
	(create_excep_cond_exprs): Likewise.
	* ax-gdb.c (agent_eval_command_one): Likewise.
	(maint_agent_printf_command): Likewise.
	Constify much of the string handling/parsing.
	* breakpoint.c (set_breakpoint_condition): Pass const
	pointer to expression string to parse_exp_1.
	(update_watchpoint): Likewise.
	(parse_cmd_to_aexpr): Constify string handling.
	Pass const pointer to parse_exp_1.
	(init_breakpoint_sal): Pass const pointer to parse_exp_1.
	(find_condition_and_thread): Likewise.
	Make TOK const.
	(watch_command_1): Make "arg" const.
	Constify string handling.
	Copy the expression string instead of changing the input
	string.
	(update_breakpoint_location): Pass const pointer to
	parse_exp_1.
	* eval.c (parse_and_eval_address): Make "exp" const.
	(parse_to_comma_and_eval): Make "expp" const.
	(parse_and_eval): Make "exp" const.
	* expression.h (parse_expression): Make argument const.
	(parse_exp_1): Make first argument const.
	* findcmd.c (parse_find_args): Treat "args" as const.
	* linespec.c (parse_linespec): Pass const pointer to
	linespec_expression_to_pc.
	(linespec_expression_to_pc): Make "exp_ptr" const.
	* parse.c (parse_exp_1): Make "stringptr" const.
	Make a copy of the expression to pass to parse_exp_in_context until
	this whole interface can be constified.
	(parse_expression): Make "string" const.
	* printcmd.c (ui_printf): Treat "arg" as const.
	Handle const strings.
	* tracepoint.c (validate_actionline): Pass const pointer to
	all calls to parse_exp_1.
	(encode_actions_1): Likewise.
	* value.h (parse_to_comma_and_eval): Make argument const.
	(parse_and_eval_address): Likewise.
	(parse_and_eval): Likewise.
	* varobj.c (varobj_create): Pass const pointer to parse_exp_1.
	(varobj_set_value): Likewise.
	* cli/cli-cmds.c (disassemble_command): Treat "arg" as const and
	constify string handling.
	Pass const pointers to parse_and_eval_address and
	parse_to_comman_and_eval.
	* cli/cli-utils.c (skip_to_space): Rename to ...
	(skip_to_space_const): ... this. Handle const strings.
	* cli/cli-utils.h (skip_to_space): Turn into macro which invokes
	skip_to_space_const.
	(skip_to_space_const): Declare.
	* common/format.c (parse_format_string): Make "arg" const.
	Handle const strings.
	* common/format.h (parse_format_string): Make "arg" const.
	* gdbserver/ax.c (ax_printf): Make "format" const.
	* python/python.c (gdbpy_parse_and_eval): Do not make a copy
	of the expression string.
2013-03-12 17:39:45 +00:00
Markus Metzger 9accd112a6 Add the gdb remote target operations for branch tracing.
We define the following packets:

  Qbtrace:bts         enable branch tracing for the current thread
                      returns "OK" or "Enn"

  Qbtrace:off         disable branch tracing for the current thread
                      returns "OK" or "Enn"

  qXfer:btrace:read   read the full branch trace data for the current thread

gdb/
	* target.h (enum target_object): Add TARGET_OBJECT_BTRACE.
	* remote.c: Include btrace.h.
	(struct btrace_target_info): New struct.
	(remote_supports_btrace): New function.
	(send_Qbtrace): New function.
	(remote_enable_btrace): New function.
	(remote_disable_btrace): New function.
	(remote_teardown_btrace): New function.
	(remote_read_btrace): New function.
	(init_remote_ops): Add btrace ops.
	(enum <unnamed>): Add btrace packets.
	(struct protocol_feature remote_protocol_features[]): Add btrace packets.
	(_initialize_remote): Add packet configuration for branch tracing.

gdbserver/
	* target.h (struct target_ops): Add btrace ops.
	(target_supports_btrace): New macro.
	(target_enable_btrace): New macro.
	(target_disable_btrace): New macro.
	(target_read_btrace): New macro.
	* gdbthread.h (struct thread_info): Add btrace field.
	* server.c: Include btrace-common.h.
	(handle_btrace_general_set): New function.
	(handle_btrace_enable): New function.
	(handle_btrace_disable): New function.
	(handle_general_set): Call handle_btrace_general_set.
	(handle_qxfer_btrace): New function.
	(struct qxfer qxfer_packets[]): Add btrace entry.
	* inferiors.c (remove_thread): Disable btrace.
	* linux-low: Include linux-btrace.h.
	(linux_low_enable_btrace): New function.
	(linux_low_read_btrace): New function.
	(linux_target_ops): Add btrace ops.
	* configure.srv (i[34567]86-*-linux*): Add linux-btrace.o.
	Add srv_linux_btrace=yes.
	(x86_64-*-linux*): Add linux-btrace.o.
	Add srv_linux_btrace=yes.
	* configure.ac: Define HAVE_LINUX_BTRACE.
	* config.in: Regenerated.
	* configure: Regenerated.
2013-03-11 08:35:11 +00:00
Markus Metzger 5cc22e4cf7 Preserve a verbose error message of xfer functions if they return -3.
gdbserver/
	* server.c (handle_qxfer): Preserve error message if -3 is
	returned.
	(qxfer): Document the -3 return value.
2013-03-11 08:31:48 +00:00
Markus Metzger 7c97f91ebf Implement branch tracing on Linux based on perf_event such that it can be shared
between gdb and gdbserver.

gdb/
	* common/linux_btrace.h: New file.
	* common/linux_btrace.c: New file.
	* Makefile.in (SFILES): Add btrace.c.
	(HFILES_NO_SRCDIR): Add common/linux-btrace.h.
	(COMMON_OBS): Add btrace.o.
	(linux-btrace.o): New rule.

gdbserver/
	* Makefile.in (SFILES): Add $(srcdir)/common/linux-btrace.c.
	(linux_btrace_h): New variable.
	(linux-btrace.o): New rule.
2013-03-11 08:24:07 +00:00
Hafiz Abid Qadeer be9a119c31 2013-03-09 Hafiz Abid Qadeer <abidh@codesourcery.com>
Fixed year number in Changelog files.
2013-03-09 12:05:20 +00:00
Hafiz Abid Qadeer f6f899bfc5 2012-03-08 Stan Shebs <stan@codesourcery.com>
Hafiz Abid Qadeer  <abidh@codesourcery.com>

	gdb/
	* NEWS: Mention set and show trace-buffer-size commands.
	Mention new packet.
	* target.h (struct target_ops): New method
	to_set_trace_buffer_size.
	(target_set_trace_buffer_size): New macro.
	* target.c (update_current_target): Set up new method.
	* tracepoint.c (trace_buffer_size): New global.
	(start_tracing): Send it to the target.
	(set_trace_buffer_size): New function.
	(_initialize_tracepoint): Add new setshow for trace-buffer-size.
	* remote.c (remote_set_trace_buffer_size): New function.
	(_initialize_remote): Use it.
	(QTBuffer:size) New remote command.
	(PACKET_QTBuffer_size): New enum.
	(remote_protocol_features): Add an entry for
	PACKET_QTBuffer_size.

	gdb/gdbserver/
	* tracepoint.c (trace_buffer_size): New global.
	(DEFAULT_TRACE_BUFFER_SIZE): New define.
	(init_trace_buffer): Change to one-argument function. Allocate
	trace buffer memory.
	(handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to
	handle QTBuffer:size packet.
	(cmd_bigqtbuffer_size): New function.
	(initialize_tracepoint): Call init_trace_buffer with
	DEFAULT_TRACE_BUFFER_SIZE.
	* server.c (handle_query): Add QTBuffer:size in the
	supported packets.

	gdb/doc/
	* gdb.texinfo (Starting and Stopping Trace Experiments): Document
	trace-buffer-size set and show commands.
	(Tracepoint Packets): Document QTBuffer:size.
	(General Query Packets): Document QTBuffer:size.

	gdb/testsuite/
	* gdb.trace/trace-buffer-size.exp: New file.
	* gdb.trace/trace-buffer-size.c: New file.
2013-03-08 15:06:39 +00:00
Yao Qi e64f749990 gdb/gdbserver/
* tracepoint.c (cur_action, cur_step_action): Make them unsigned.
	(cmd_qtfp): Initialize cur_action and cur_step_action 0 instead
	of -1.
	(cmd_qtsp): Adjust condition.  Do post increment.
	Set cur_action and cur_step_action back to 0.
2013-03-07 13:17:28 +00:00
Pedro Alves f0ae6fc35c PR gdb/15236: gdbserver write to linux memory with zero length corrupts stack
PROBLEM:

The function linux_write_memory () in linux-low.c allocates a buffer
on the stack to hold a copy of the data to be written.

  register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *)
    alloca (count * sizeof (PTRACE_XFER_TYPE));

"count" is the number of bytes to be written, rounded up to the
nearest multiple of sizeof (PTRACE_XFER_TYPE) and allowing for not
being an aligned address. The function later uses

  buffer[0] = ptrace (PTRACE_PEEKTEXT, pid,
                      (PTRACE_ARG3_TYPE) (uintptr_t) addr, 0);

The problem is that this function can be called to write zero bytes on
an aligned address, for example when receiving an X packet of length 0
(used to test if 8-bit write is supported). Under these circumstances,
count can be zero.

Since in this case, buffer[0] may never have been allocated, the stack
is corrupted and gdbserver may crash.

SOLUTION:

Writing zero bytes should always succeed. The patch below returns
successfully early if the length is zero, so avoiding the stack
corruption.

Verified on the ARC GDB 7.5.1 port.

2013-03-07  Jeremy Bennett  <jeremy.bennett@embecosm.com>

	PR server/15236

	* linux-low.c (linux_write_memory): Return early success if LEN is
	zero.
2013-03-07 09:47:57 +00:00
Corinna Vinschen 334ad4a8e4 Fix ChangeLog entry. 2013-03-05 15:18:10 +00:00
Corinna Vinschen b5b0b0afd0 * configure.host: Add x86_64-*-cygwin* as host.
* configure.tgt: Add x86_64-*-cygwin* as target.
	* config/i386/cygwin64.mh: New file.

	* gdbserver/configure.srv: Add x86_64-*-cygwin* as target.
2013-03-05 13:37:11 +00:00
Tom Tromey 589bc9275a * configure.ac: Invoke AC_SYS_LARGEFILE.
* configure, config.in: Rebuild.
2013-02-28 16:51:19 +00:00
Corinna Vinschen dfe0758235 * win32-low.c: Throughout, fix format strings and casts of
printf-like functions to avoid type related warnings on all
	platforms.
	(get_child_debug_event): Print dwDebugEventCode as hex since
	that's how it's usually documented.
2013-02-28 09:09:02 +00:00
Yao Qi 736cd58526 gdb/gdbserver/
* tracepoint.c (cmd_qtbuffer): Call phex_nz instead of
	pulongest.
2013-02-28 01:21:08 +00:00
Jiong Wang e1f58301dd gdb/
* regformats/reg-tilegx.dat (name): Change abi name to "tilegx".
	* regformats/reg-tilegx32.dat: New.

  gdbserver/

	* Makefile.in (clean): Remove reg-tilegx.c, reg-tilegx32.c.
	(reg-tilegx32.c): New rule.
	* configure.srv (tilegx-*-linux*): Add reg-tilegx32.o to srv_regobj.
	* linux-tile-low.c (tile_arch_setup): New function.  Invoke
	different register info initializer according to elf class.
	(init_registers_tilgx32): New function.  The tilegx32 register info
	initializer.
	(tile_fill_gregset): Use "uint_reg_t" to represent register size.
	(tile_store_gregset): Likewise.
2013-02-27 14:58:18 +00:00
Yao Qi d171ca7803 gdb/gdbserver/
* server.c (process_point_options): Print debug message when
	debug_threads is true.
2013-02-27 13:31:38 +00:00
Yao Qi 282bbdf358 gdb/gdbserver/
* tracepoint.c (cmd_qtbuffer): Don't set '\0' in OWN_BUF.
2013-02-26 14:11:58 +00:00
Pedro Alves aca2255198 gdbserver:server.c - use unpack_varlen_hex to extract hex numbers.
Addresses, as most numbers in the RSP are hex encoded, with variable
length (that just means the width isn't specified, and there's no top
cap.  So they should be extracted with unpack_varlen_hex.

A couple spots in server.c are using strto(u)l, which doesn't work on
LLP64 targets.

This patch fixes it.

Tested on x86_64 Fedora 17.

2013-02-19  Pedro Alves  <palves@redhat.com>
	    Kai Tietz <ktietz@redhat.com>

	PR gdb/15161

	* server.c (handle_query) <CRC check>: Use unpack_varlen_hex
	instead of strtoul to extract address from packet.
	(process_serial_event) <'z'>: Likewise.
2013-02-19 20:52:57 +00:00
Yao Qi 4f3cee1ca1 gdb/gdbserver
* linux-bfin-low.c (the_low_target): Use NULL instead of 0.
2013-02-18 14:54:57 +00:00
Pedro Alves 8e1d55a3df gdbserver: QTNotes, plug memory leak.
The previous notes aren't being released before setting new ones.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2013-02-14  Pedro Alves  <palves@redhat.com>

	Plug memory leak.

	* tracepoint.c (cmd_qtnotes): Free TRACING_USER_NAME,
	TRACING_NOTES and TRACING_STOP_NOTE before clobbering.
2013-02-14 18:07:19 +00:00
Pedro Alves 458820da59 gdbserver:tracepoint.c:cmd_qtdpsrc use savestring.
An obvious use case for savestring.

Tested on x86_64 Fedora 17.

2013-02-14  Pedro Alves  <palves@redhat.com>

	* tracepoint.c (cmd_qtdpsrc): Use savestring.
2013-02-14 17:30:03 +00:00
Pedro Alves baea0daecf Move savestring to common/common-utils.c, make gdbserver use it.
This makes gdbserver share gdb's savestring, instead of baking its own.

Tested on x86_64 Fedora 17.

gdb/
2013-02-14  Pedro Alves  <palves@redhat.com>

	* utils.c (savestring): Don't #undef it.  Move function to
	common/common-utils.c.
	* common/common-utils.c: Include gdb_string.h.
	(savestring): Move here from utils.c.
	* common/common-utils.h (savestring): Declare.

gdb/gdbserver/
2013-02-14  Pedro Alves  <palves@redhat.com>

	* tracepoint.c (save_string): Delete.
	(add_tracepoint_action): Use savestring instead of save_string.
2013-02-14 17:11:41 +00:00
Pedro Alves 0b1afbb37b Consistent use of (C) after "Copyright".
While writing the previous patch, I noticed that we're not consistent
with the (C) in the copyright header.  The maintainers manual prefers
having it, though also says it's optional.  We have over 10x more
files with (C) than without in gdb's code, so I spent a few minutes
grepping and fixing.  Funny enough, the testsuite has it backwards.
I'll leave that for another time.

gdb/
2013-02-12  Pedro Alves  <palves@redhat.com>

	* amd64-darwin-tdep.c: Add (C) after Copyright.
	* cli/cli-cmds.h: Ditto.
	* cli/cli-decode.c: Ditto.
	* cli/cli-decode.h: Ditto.
	* cli/cli-dump.c: Ditto.
	* cli/cli-dump.h: Ditto.
	* cli/cli-interp.c: Ditto.
	* cli/cli-logging.c: Ditto.
	* cli/cli-script.c: Ditto.
	* cli/cli-script.h: Ditto.
	* cli/cli-setshow.c: Ditto.
	* cli/cli-setshow.h: Ditto.
	* cli/cli-utils.c: Ditto.
	* cli/cli-utils.h: Ditto.
	* config/alpha/nm-osf3.h: Ditto.
	* config/djgpp/djconfig.sh: Ditto.
	* config/i386/nm-fbsd.h: Ditto.
	* config/i386/nm-i386gnu.h: Ditto.
	* config/nm-linux.h: Ditto.
	* config/nm-nto.h: Ditto.
	* config/rs6000/nm-rs6000.h: Ditto.
	* config/sparc/nm-sol2.h: Ditto.
	* darwin-nat-info.c: Ditto.
	* dfp.c: Ditto.
	* dfp.h: Ditto.
	* gdb-demangle.h: Ditto.
	* i386-darwin-nat.c: Ditto.
	* i386-darwin-tdep.c: Ditto.
	* linux-fork.h: Ditto.
	* m32c-tdep.c: Ditto.
	* microblaze-linux-tdep.c: Ditto.
	* microblaze-rom.c: Ditto.
	* microblaze-tdep.c: Ditto.
	* microblaze-tdep.h: Ditto.
	* mips-linux-tdep.h: Ditto.
	* ppc-ravenscar-thread.c: Ditto.
	* ppc-ravenscar-thread.h: Ditto.
	* prologue-value.c: Ditto.
	* prologue-value.h: Ditto.
	* ravenscar-thread.c: Ditto.
	* ravenscar-thread.h: Ditto.
	* sparc-ravenscar-thread.c: Ditto.
	* sparc-ravenscar-thread.h: Ditto.
	* tilegx-linux-tdep.c: Ditto.
	* unwind_stop_reasons.def: Ditto.
	* windows-nat.h: Ditto.
	* xtensa-linux-tdep.c: Ditto.
	* xtensa-xtregs.c: Ditto.
	* regformats/regdat.sh: Ditto.
	* regformats/regdef.h: Ditto.

gdb/gdbserver/
2013-02-12  Pedro Alves  <palves@redhat.com>

	* linux-xtensa-low.c: Ditto.
	* xtensa-xtregs.c: Ditto.
2013-02-12 19:03:57 +00:00
Pedro Alves 43aaf8b6d6 Fix whitespace. 2013-02-12 15:18:33 +00:00
Pedro Alves 8a4ac37ef4 From: Sanimir Agovic <sanimir.agovic@intel.com>
null ptr check to prevent gdbserver from crashing

Evaluating a thread local storage variable in a remote scenario crashes
gdbserver if libthread-db could not be loaded.

2013-02-12  Sanimir Agovic  <sanimir.agovic@intel.com>

gdbserver/
	* thread-db.c (thread_db_get_tls_address):
	NULL pointer check thread_db.

testsuite/
	* gdb.server/no-thread-db.exp: New file.
	* gdb.server/no-thread-db.c: New file.
	* gdb.server/Makefile.in (EXECUTABLES): Add no-thread-db.
2013-02-12 15:03:12 +00:00
Marcus Shawcroft 148de6bbb5 2013-02-07 Marcus Shawcroft <marcus.shawcroft@arm.com>
* linux-aarch64-low.c (aarch64_arch_setup): Clamp
        aarch64_num_wp_regs and aarch64_num_bp_regs to
        AARCH64_HWP_MAX_NUM and AARCH64_HBP_MAX_NUM respectively.
2013-02-07 17:32:29 +00:00
Marcus Shawcroft 55fac6e050 Switch AArch64 gdbserver ps_get_thread_area to PTRACE_GETREGSET.
2013-02-06  Marcus Shawcroft  <marcus.shawcroft@arm.com>

       * linux-aarch64-low.c (ps_get_thread_area): Replace
       PTRACE_GET_THREAD_AREA with PTRACE_GETREGSET.
2013-02-07 10:47:40 +00:00
Marcus Shawcroft 176eb98c2f AArch64 GDBserver support.
gdb/
        * configure.tgt (aarch64*-*-linux*): Set build_gdbserver=yes.

gdb/gdbserver/

        * Makefile.in (clean): Remove aarch64.c and aarch64-without-fpu.c.
        (aarch64.c, aarch64-without-fpu.c): New targets.
        * configure.srv (aarch64*-*-linux*): New.
        * linux-aarch64-low.c: New file.
2013-02-04 18:20:05 +00:00