Commit Graph

872 Commits

Author SHA1 Message Date
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
Marcus Shawcroft 56f7af9cb0 Ensure ptrace() calls cast arguments 3 and 4 appropriately.
* linux-low.c (handle_extended_wait, linux_create_inferior)
        (linux_attach_lwp_1, linux_kill_one_lwp, linux_attach_one_lwp)
        (dequeue_one_deferred_signal, linux_resume_one_thread)
        (fetch_register, linux_write_memory, linux_enable_event_reporting)
        (linux_tracefork_grandchild, linux_test_for_tracefork)
        (linux_read_offsets, linux_xfer_siginfo, linux_xfer_siginfo ): Add
        PTRACE_ARG3_TYPE and PTRACE_ARG4_TYPE cast to ptrace arguments
        where the argument is 0.
2013-02-04 17:47:00 +00:00
Yao Qi 60f662b0e8 gdb/gdbserver
* event-loop.c: Include "queue.h".
	(gdb_event_p): New typedef.
	(struct gdb_event) <next_event>: Remove.
	(event_queue): Change to QUEUE(gdb_event_p).
	(async_queue_event): Remove.
	(gdb_event_xfree): New.
	(initialize_event_loop): New.
	(process_event): Use API from QUEUE.
	(wait_for_event): Likewise.
	* server.c (main): Call initialize_event_loop.
	* server.h (initialize_event_loop): Declare.
2013-01-25 14:12:02 +00:00
Yao Qi 5ae4861a11 gdb/gdbserver:
* ax.h (struct eval_agent_expr_context): New.
	(gdb_eval_agent_expr): Update declaration.
	* ax.c (gdb_eval_agent_expr): Remove argument REGCACHE and
	TFRAME.  Add new argument CTX.
	* server.h (struct eval_agent_expr_context): Declare.
	(agent_mem_read, agent_tsv_read): Update declaration.
	(agent_mem_read_string): Likewise.
	* tracepoint.c (eval_tracepoint_agent_expr): Remove.
	(add_traceframe_block): Add new argument TPOINT.
	Increase TPOINT->traceframe_usage.
	(do_action_at_tracepoint): Call gdb_eval_agent_expr instead of
	eval_tracepoint_agent_expr.
	(condition_true_at_tracepoint): Likewise.
	(agent_mem_read): Remove argument TFRAME.  Add argument CTX.
	(agent_mem_read_string, agent_tsv_read): Likewise.
	Callers update.

gdb/testsuite:

	* gdb.trace/infotrace.exp: Check 'traceframe usage' in the
	output of 'info tracepoints'.
	* gdb.trace/disconnected-tracing.exp (disconnected_tracing):
	Likewise.
	* gdb.trace/tstatus.exp (run_trace_experiment): Likewise.
	* gdb.trace/disconnected-tracing.c (struct foo): New.
2013-01-18 06:40:58 +00:00
Yao Qi 85e00e8548 gdb/gdbserver/
* linux-low.c (linux_resume_one_lwp): Don't check
	'lwp->bp_reinsert != 0'.
2013-01-16 14:46:17 +00:00
Joel Brobecker 4039cf45c2 Simplifly ptrace_request_to_str's implementation...
... following Pedro's advice of using a temporary macro.

gdb/gdbserver/ChangeLog:

        * lynx-low.c (ptrace_request_to_str): Define a temporary
        macro and use it to simplify this function's implementation.
2013-01-07 11:43:42 +00:00
Joel Brobecker 9044dee230 Add ptrace error handling in lynx_resume
gdb/gdbserver/ChangeLog:

        * lynx-low.c (lynx_resume): Call perror_with_name if lynx_ptrace
        sets errno.
2013-01-07 11:43:16 +00:00
Joel Brobecker e6352c8f63 Make x86-lynx GDBserver pass XML register map to GDB.
This is not strictly needed, since both GDB and GDBserver seem
to agree on the register numbering without this.  But this allows
us to make sure that this is always going to be the case.

gdb/gdbserver/ChangeLog:

        * configure.srv (i[34567]86-*-lynxos*): Set srv_xmlfiles.
2013-01-07 11:42:53 +00:00
Joel Brobecker 50681a2705 Allow powerpc-*-lynxos* GDBserver to send register map via XML...
... back to GDB.  The transfer occurs when GDB sends the
'qXfer:features:read:target.xml' packet.  This allows us to make
sure that GDB and GDBserver use the same register numbering.
This is important on Lynx 178, where GDB selects the rs6000:6000
architecture by default instead of the powerpc:common architecture.

gdb/gdbserver/ChangeLog:

        * configure.srv (powerpc-*-lynxos*): Set srv_xmlfiles.
2013-01-07 11:39:25 +00:00
Joel Brobecker 3f6e77ef16 LynxOS: Resume the same thread when receiving a thread create/exit event.
Before this patch, the ptid passed to lynx_resume was completely
ignored, and we used the current_inferior. This resulted in trying
to resume the inferior execution using the wrong ptid after having
received a thread create/exit event, because the inferior_ptid
was still set to the ptid prior to receiving the signal.

gdb/gdbserver/ChangeLog:

        * lynx-low.c (lynx_resume): Use the resume_info parameter
        to determine the ptid for the lynx_ptrace call, unless
        it is equal to minus_one_ptid, in which case we use the
        ptid of the current_inferior.
        (lynx_wait_1): After having received a thread create/exit
        event, resume the inferior's execution using the signaling
        thread's ptid, rather than the old ptid.
2013-01-07 11:39:00 +00:00
Joel Brobecker 7fda33ae8d Delete unused variable in lynx_resume
gdb/gdbserver/ChangeLog:

        * lynx-low.c (lynx_resume): Delete variable ret.
2013-01-07 11:38:35 +00:00
Joel Brobecker 28e7fd6234 Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:33:28 +00:00
Joel Brobecker b9786c7408 Update copyright year in gdb/gdbserver/gdbreplay version output.
gdb/ChangeLog:

        * top.c (print_gdb_version): Update copyright year.

gdb/gdbserver/ChangeLog:

        * gdbreplay.c (gdbreplay_version): Update copyright year.
        * server.c (gdbserver_version): Likewise.
2013-01-01 05:45:22 +00:00