2011-11-14 Stan Shebs <stan@codesourcery.com>

Kwok Cheung Yeung  <kcy@codesourcery.com>

	* NEWS: Document shorter fast tracepoints and qTMinFTPILen packet.
	* i386-tdep.c (i386_fast_tracepoint_valid_at): Query target for
	the minimum instruction size for fast tracepoints.
	* target.h (struct target_ops): Add new method
	to_get_min_fast_tracepoint_insn_len.
	(target_get_min_fast_tracepoint_insn_len): New.
	* target.c (update_current_target): Set up new target operation.
	* remote.c (remote_write_bytes_aux): Fix typo.
	(remote_get_min_fast_tracepoint_insn_len): New.
	(init_remote_ops): Initialize new field.

	* gdb.texinfo (Create and Delete Tracepoints): Describe what is
	needed to get shorter fast tracepoints.
	(Tracepoint Packets): Document new qTMinFTPILen packet.

	* linux-x86-low.c (small_jump_insn): New.
	(i386_install_fast_tracepoint_jump_pad): Add arguments for
	trampoline and error message, build a trampoline and issue a small
	jump instruction to it.
	(x86_install_fast_tracepoint_jump_pad): Add arguments for
	trampoline and error message.
	(x86_get_min_fast_tracepoint_insn_len): New.
	(the_low_target): Add call to x86_get_min_fast_tracepoint_insn_len.
	* linux-low.h (struct linux_target_ops): Add arguments to
	install_fast_tracepoint_jump_pad operation, add new operation.
	* linux-low.c (linux_install_fast_tracepoint_jump_pad): Add
	arguments.
	(linux_get_min_fast_tracepoint_insn_len): New function.
	(linux_target_op): Add new operation.
	* tracepoint.c (gdb_trampoline_buffer): New IPA variable.
	(gdb_trampoline_buffer_end): Ditto.
	(gdb_trampoline_buffer_error): Ditto.
	(struct ipa_sym_addresses): Add fields for new IPA variables.
	(symbol_list): Add entries for new IPA variables.
	(struct tracepoint): Add fields to hold the address range of the
	trampoline used by the tracepoint.
	(trampoline_buffer_head): New static variable.
	(trampoline_buffer_tail): Ditto.
	(claim_trampoline_space): New function.
	(have_fast_tracepoint_trampoline_buffer): New function.
	(clone_fast_tracepoint): Fill in trampoline fields of tracepoint
	structure.
	(install_fast_tracepoint): Ditto, also add error buffer argument.
	(cmd_qtminftpilen): New function.
	(handle_tracepoint_query): Add response to qTMinFTPILen packet.
	(fast_tracepoint_from_trampoline_address): New function.
	(fast_tracepoint_collecting): Handle trampoline as part of jump
	pad space.
	(set_trampoline_buffer_space): New function.
	(initialize_tracepoint): Initialize new IPA variables.
	* target.h (struct target_ops): Add arguments to
	install_fast_tracepoint_jump_pad operation, add new
	get_min_fast_tracepoint_insn_len operation.
	(target_get_min_fast_tracepoint_insn_len): New.
	(install_fast_tracepoint_jump_pad): Add arguments.
	* server.h (IPA_BUFSIZ): Define.
	* linux-i386-ipa.c: Include extra header files.
	(initialize_fast_tracepoint_trampoline_buffer): New function.
	(initialize_low_tracepoint): Call it.
	* server.h (set_trampoline_buffer_space): Declare.
	(claim_trampoline_space): Ditto.
	(have_fast_tracepoint_trampoline_buffer): Ditto.

	* gdb.trace/ftrace.c: New.
	* gdb.trace/ftrace.exp: New.
This commit is contained in:
Stan Shebs 2011-11-14 20:07:25 +00:00
parent 3e05895e9e
commit 405f8e9499
19 changed files with 882 additions and 45 deletions

View file

@ -19,6 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
#include <stdint.h>
#include <sys/mman.h>
/* GDB register numbers. */
@ -191,8 +193,62 @@ supply_static_tracepoint_registers (struct regcache *regcache,
may use it proper at some point. */
const char *gdbserver_xmltarget;
/* Attempt to allocate memory for trampolines in the first 64 KiB of
memory to enable smaller jump patches. */
static void
initialize_fast_tracepoint_trampoline_buffer (void)
{
const CORE_ADDR buffer_end = 64 * 1024;
/* Ensure that the buffer will be at least 1 KiB in size, which is
enough space for over 200 fast tracepoints. */
const int min_buffer_size = 1024;
char buf[IPA_BUFSIZ];
CORE_ADDR mmap_min_addr = buffer_end + 1;
ULONGEST buffer_size;
FILE *f = fopen ("/proc/sys/vm/mmap_min_addr", "r");
if (!f)
{
snprintf (buf, sizeof (buf), "mmap_min_addr open failed: %s",
strerror (errno));
set_trampoline_buffer_space (0, 0, buf);
return;
}
if (fgets (buf, IPA_BUFSIZ, f))
sscanf (buf, "%llu", &mmap_min_addr);
fclose (f);
buffer_size = buffer_end - mmap_min_addr;
if (buffer_size >= min_buffer_size)
{
if (mmap ((void *) (uintptr_t) mmap_min_addr, buffer_size,
PROT_READ | PROT_EXEC | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0)
!= MAP_FAILED)
set_trampoline_buffer_space (mmap_min_addr, buffer_end, NULL);
else
{
snprintf (buf, IPA_BUFSIZ, "low-64K-buffer mmap() failed: %s",
strerror (errno));
set_trampoline_buffer_space (0, 0, buf);
}
}
else
{
snprintf (buf, IPA_BUFSIZ, "mmap_min_addr is %d, must be %d or less",
(int) mmap_min_addr, (int) buffer_end - min_buffer_size);
set_trampoline_buffer_space (0, 0, buf);
}
}
void
initialize_low_tracepoint (void)
{
init_registers_i386_linux ();
initialize_fast_tracepoint_trampoline_buffer ();
}