[PATCH v3] gdbserver: pass pointer to struct tracepoint to install_fast_tracepoint_jump_pad

Antoine Tremblay
2016-06-16T17:14:25Z

In this v3:
Added s390 and ppc.

--

We currently pass many values to install_fast_tracepoint_jump_pad that
come from fields of struct tracepoint, and we plan to add another (the
kind field). It would be simpler to just pass a pointer to the
tracepoint and have install_fast_tracepoint_jump_pad fetch the fields
from it.

That requires moving the struct tracepoint definition to tracepoint.h.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c (aarch64_install_fast_tracepoint_jump_pad):
Replaces some parameters with a struct tracepoint *.
* linux-low.c (linux_install_fast_tracepoint_jump_pad):
Likewise.
* linux-low.h (struct linux_target_ops)
<install_fast_tracepoint_jump_pad>: Likewise.
* linux-ppc-low.c (ppc_install_fast_tracepoint_jump_pad):
Likewise.
* linux-s390-low.c (s390_install_fast_tracepoint_jump_pad):
Likewise.
* linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Likewise.
(i386_install_fast_tracepoint_jump_pad): Likewise.
(x86_install_fast_tracepoint_jump_pad): Likewise.
* target.h (struct tracepoint): New forward declaration.
(struct target_ops) <install_fast_tracepoint_jump_pad>: Replace
some parameters with a struct tracepoint *.
(install_fast_tracepoint_jump_pad): Likewise.
* tracepoint.c (enum tracepoint_type): Move to tracepoint.h.
(struct tracepoint): Likewise.
(install_fast_tracepoint): Adapt call to
install_fast_tracepoint_jump_pad.
* tracepoint.h (enum tracepoint_type) Moved from tracepoint.c.
(struct tracepoint): Moved from tracepoint.c.
---
gdb/gdbserver/linux-aarch64-low.c | 26 ++++----
gdb/gdbserver/linux-arm-low.c | 2 +
gdb/gdbserver/linux-low.c | 12 +---
gdb/gdbserver/linux-low.h | 5 +-
gdb/gdbserver/linux-ppc-low.c | 21 +++---
gdb/gdbserver/linux-s390-low.c | 13 ++--
gdb/gdbserver/linux-x86-low.c | 63 ++++++++----------
gdb/gdbserver/target.h | 26 ++++----
gdb/gdbserver/tracepoint.c | 131 +-------------------------------------
gdb/gdbserver/tracepoint.h | 125 ++++++++++++++++++++++++++++++++++++
10 files changed, 195 insertions(+), 229 deletions(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index d237bde..a83459c 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -1766,18 +1766,14 @@ static const struct aarch64_insn_visitor visitor =
"install_fast_tracepoint_jump_pad". */

static int
-aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
- CORE_ADDR tpaddr,
+aarch64_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
uint32_t buf[256];
@@ -1891,7 +1887,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,

*/

- p += emit_mov_addr (p, x3, tpaddr);
+ p += emit_mov_addr (p, x3, tp->address);
p += emit_str (p, x3, sp, offset_memory_operand (3 * 16));

/* Save CPSR (NZCV), FPSR and FPCR:
@@ -1926,7 +1922,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,

*/

- p += emit_mov_addr (p, x0, tpoint);
+ p += emit_mov_addr (p, x0, tp->obj_addr_on_target);
p += emit_mrs (p, x1, TPIDR_EL0);
p += emit_stp (p, x0, x1, sp, preindex_memory_operand (-16));

@@ -2003,7 +1999,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,

*/

- p += emit_mov_addr (p, x0, tpoint);
+ p += emit_mov_addr (p, x0, tp->obj_addr_on_target);
p += emit_add (p, x1, sp, immediate_operand (16));

p += emit_mov_addr (p, ip0, collector);
@@ -2087,10 +2083,10 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
append_insns (&buildaddr, p - buf, buf);

/* Now emit the relocated instruction. */
- *adjusted_insn_addr = buildaddr;
- target_read_uint32 (tpaddr, &insn);
+ tp->adjusted_insn_addr = buildaddr;
+ target_read_uint32 (tp->address, &insn);

- insn_data.base.insn_addr = tpaddr;
+ insn_data.base.insn_addr = tp->address;
insn_data.new_addr = buildaddr;
insn_data.insn_ptr = buf;

@@ -2102,19 +2098,19 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
{
sprintf (err,
"E.Could not relocate instruction from %s to %s.",
- core_addr_to_string_nz (tpaddr),
+ core_addr_to_string_nz (tp->address),
core_addr_to_string_nz (buildaddr));
return 1;
}
else
append_insns (&buildaddr, insn_data.insn_ptr - buf, buf);
- *adjusted_insn_addr_end = buildaddr;
+ tp->adjusted_insn_addr_end = buildaddr;

/* Go back to the start of the buffer. */
p = buf;

/* Emit a branch back from the jump pad. */
- offset = (tpaddr + orig_size - buildaddr);
+ offset = (tp->address + tp->orig_size - buildaddr);
if (!can_encode_int32 (offset, 28))
{
sprintf (err,
@@ -2128,7 +2124,7 @@ aarch64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
append_insns (&buildaddr, p - buf, buf);

/* Give the caller a branch instruction into the jump pad. */
- offset = (*jump_entry - tpaddr);
+ offset = (*jump_entry - tp->address);
if (!can_encode_int32 (offset, 28))
{
sprintf (err,
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 2344b0a..78e3378 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -33,6 +33,8 @@
#include <signal.h>
#include <sys/syscall.h>

+#include "tracepoint.h"
+
/* Defined in auto-generated files. */
void init_registers_arm (void);
extern const struct target_desc *tdesc_arm;
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 81134b0..7fcf36b 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -6473,25 +6473,19 @@ linux_done_accessing_memory (void)
}

static int
-linux_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+linux_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
return (*the_low_target.install_fast_tracepoint_jump_pad)
- (tpoint, tpaddr, collector, lockaddr, orig_size,
- jump_entry, trampoline, trampoline_size,
- jjump_pad_insn, jjump_pad_insn_size,
- adjusted_insn_addr, adjusted_insn_addr_end,
- err);
+ (tp, collector, lockaddr, jump_entry, trampoline, trampoline_size,
+ jjump_pad_insn, jjump_pad_insn_size, err);
}

static struct emit_ops *
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 6e7ddbd..fc487f8 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -211,17 +211,14 @@ struct linux_target_ops

/* Install a fast tracepoint jump pad. See target.h for
comments. */
- int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+ int (*install_fast_tracepoint_jump_pad) (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err);

/* Return the bytecode operations vector for the current inferior.
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index 1d013f1..4cc167c 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -1252,17 +1252,14 @@ ppc_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
See target.h for details. */

static int
-ppc_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+ppc_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
uint32_t buf[256];
@@ -1271,6 +1268,8 @@ ppc_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
CORE_ADDR buildaddr = *jump_entry;
const CORE_ADDR entryaddr = *jump_entry;
int rsz, min_frame, frame_size, tp_reg;
+ CORE_ADDR tpoint = tp->obj_addr_on_target;
+ CORE_ADDR tpaddr = tp->address;
#ifdef __powerpc64__
struct regcache *regcache = get_thread_regcache (current_thread, 0);
int is_64 = register_size (regcache->tdesc, 0) == 8;
@@ -1407,22 +1406,22 @@ ppc_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
write_inferior_memory (buildaddr, (unsigned char *) buf, (p - buf) * 4);

/* Now, insert the original instruction to execute in the jump pad. */
- *adjusted_insn_addr = buildaddr + (p - buf) * 4;
- *adjusted_insn_addr_end = *adjusted_insn_addr;
- ppc_relocate_instruction (adjusted_insn_addr_end, tpaddr);
+ tp->adjusted_insn_addr = buildaddr + (p - buf) * 4;
+ tp->adjusted_insn_addr_end = tp->adjusted_insn_addr;
+ ppc_relocate_instruction (&tp->adjusted_insn_addr_end, tpaddr);

/* Verify the relocation size. If should be 4 for normal copy,
8 or 12 for some conditional branch. */
- if ((*adjusted_insn_addr_end - *adjusted_insn_addr == 0)
- || (*adjusted_insn_addr_end - *adjusted_insn_addr > 12))
+ if ((tp->adjusted_insn_addr_end - tp->adjusted_insn_addr == 0)
+ || (tp->adjusted_insn_addr_end - tp->adjusted_insn_addr > 12))
{
sprintf (err, "E.Unexpected instruction length = %d"
"when relocate instruction.",
- (int) (*adjusted_insn_addr_end - *adjusted_insn_addr));
+ (int) (tp->adjusted_insn_addr_end - tp->adjusted_insn_addr));
return 1;
}

- buildaddr = *adjusted_insn_addr_end;
+ buildaddr = tp->adjusted_insn_addr_end;
p = buf;
/* Finally, write a jump back to the program. */
offset = (tpaddr + 4) - buildaddr;
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index f5a7d85..39754e1 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -1178,18 +1178,14 @@ s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
"install_fast_tracepoint_jump_pad". */

static int
-s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
- CORE_ADDR tpaddr,
+s390_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
int i;
@@ -1197,6 +1193,9 @@ s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
int32_t offset;
unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 }; /* jg ... */
CORE_ADDR buildaddr = *jump_entry;
+ CORE_ADDR tpaddr = tp->address;
+ CORE_ADDR tpoint = tp->obj_addr_on_target;
+ ULONGEST orig_size = tp->orig_size;
#ifdef __s390x__
struct regcache *regcache = get_thread_regcache (current_thread, 0);
int is_64 = register_size (regcache->tdesc, 0) == 8;
@@ -1297,13 +1296,13 @@ s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,

/* Now, adjust the original instruction to execute in the jump
pad. */
- *adjusted_insn_addr = buildaddr;
+ tp->adjusted_insn_addr = buildaddr;
if (s390_relocate_instruction (&buildaddr, tpaddr, is_64))
{
sprintf (err, "E.Could not relocate instruction for tracepoint.");
return 1;
}
- *adjusted_insn_addr_end = buildaddr;
+ tp->adjusted_insn_addr_end = buildaddr;

/* Finally, write a jump back to the program. */

diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 2535959..5d1db6c 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -1053,17 +1053,14 @@ push_opcode (unsigned char *buf, char *op)
tracepoint address. */

static int
-amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+amd64_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
unsigned char buf[40];
@@ -1096,7 +1093,7 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
buf[i++] = 0x9c; /* pushfq */
buf[i++] = 0x48; /* movl <addr>,%rdi */
buf[i++] = 0xbf;
- *((unsigned long *)(buf + i)) = (unsigned long) tpaddr;
+ *((unsigned long *)(buf + i)) = (unsigned long) tp->address;
i += sizeof (unsigned long);
buf[i++] = 0x57; /* push %rdi */
append_insns (&buildaddr, i, buf);
@@ -1105,7 +1102,7 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
i = 0;
i += push_opcode (&buf[i], "48 83 ec 18"); /* sub $0x18,%rsp */
i += push_opcode (&buf[i], "48 b8"); /* mov <tpoint>,%rax */
- memcpy (buf + i, &tpoint, 8);
+ memcpy (buf + i, &tp->obj_addr_on_target, 8);
i += 8;
i += push_opcode (&buf[i], "48 89 04 24"); /* mov %rax,(%rsp) */
i += push_opcode (&buf[i],
@@ -1135,7 +1132,7 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,

/* tpoint address may be 64-bit wide. */
i += push_opcode (&buf[i], "48 bf"); /* movl <addr>,%rdi */
- memcpy (buf + i, &tpoint, 8);
+ memcpy (buf + i, &tp->obj_addr_on_target, 8);
i += 8;
append_insns (&buildaddr, i, buf);

@@ -1188,13 +1185,13 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,

/* Now, adjust the original instruction to execute in the jump
pad. */
- *adjusted_insn_addr = buildaddr;
- relocate_instruction (&buildaddr, tpaddr);
- *adjusted_insn_addr_end = buildaddr;
+ tp->adjusted_insn_addr = buildaddr;
+ relocate_instruction (&buildaddr, tp->address);
+ tp->adjusted_insn_addr_end = buildaddr;

/* Finally, write a jump back to the program. */

- loffset = (tpaddr + orig_size) - (buildaddr + sizeof (jump_insn));
+ loffset = (tp->address + tp->orig_size) - (buildaddr + sizeof (jump_insn));
if (loffset > INT_MAX || loffset < INT_MIN)
{
sprintf (err,
@@ -1212,7 +1209,7 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
is always done last (by our caller actually), so that we can
install fast tracepoints with threads running. This relies on
the agent's atomic write support. */
- loffset = *jump_entry - (tpaddr + sizeof (jump_insn));
+ loffset = *jump_entry - (tp->address + sizeof (jump_insn));
if (loffset > INT_MAX || loffset < INT_MIN)
{
sprintf (err,
@@ -1242,17 +1239,14 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
tracepoint address. */

static int
-i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+i386_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
unsigned char buf[0x100];
@@ -1265,7 +1259,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
i = 0;
buf[i++] = 0x60; /* pushad */
buf[i++] = 0x68; /* push tpaddr aka $pc */
- *((int *)(buf + i)) = (int) tpaddr;
+ *((int *)(buf + i)) = (int) tp->address;
i += 4;
buf[i++] = 0x9c; /* pushf */
buf[i++] = 0x1e; /* push %ds */
@@ -1284,7 +1278,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,

/* Build the object. */
i += push_opcode (&buf[i], "b8"); /* mov <tpoint>,%eax */
- memcpy (buf + i, &tpoint, 4);
+ memcpy (buf + i, &tp->obj_addr_on_target, 4);
i += 4;
i += push_opcode (&buf[i], "89 04 24"); /* mov %eax,(%esp) */

@@ -1319,7 +1313,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,

i = 0;
i += push_opcode (&buf[i], "c7 04 24"); /* movl <addr>,(%esp) */
- memcpy (&buf[i], (void *) &tpoint, 4);
+ memcpy (&buf[i], (void *) &tp->obj_addr_on_target, 4);
i += 4;
append_insns (&buildaddr, i, buf);

@@ -1369,12 +1363,12 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,

/* Now, adjust the original instruction to execute in the jump
pad. */
- *adjusted_insn_addr = buildaddr;
- relocate_instruction (&buildaddr, tpaddr);
- *adjusted_insn_addr_end = buildaddr;
+ tp->adjusted_insn_addr = buildaddr;
+ relocate_instruction (&buildaddr, tp->address);
+ tp->adjusted_insn_addr_end = buildaddr;

/* Write the jump back to the program. */
- offset = (tpaddr + orig_size) - (buildaddr + sizeof (jump_insn));
+ offset = (tp->address + tp->orig_size) - (buildaddr + sizeof (jump_insn));
memcpy (buf, jump_insn, sizeof (jump_insn));
memcpy (buf + 1, &offset, 4);
append_insns (&buildaddr, sizeof (jump_insn), buf);
@@ -1383,7 +1377,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
is always done last (by our caller actually), so that we can
install fast tracepoints with threads running. This relies on
the agent's atomic write support. */
- if (orig_size == 4)
+ if (tp->orig_size == 4)
{
/* Create a trampoline. */
*trampoline_size = sizeof (jump_insn);
@@ -1402,7 +1396,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
write_inferior_memory (*trampoline, buf, sizeof (jump_insn));

/* Use a 16-bit relative jump instruction to jump to the trampoline. */
- offset = (*trampoline - (tpaddr + sizeof (small_jump_insn))) & 0xffff;
+ offset = (*trampoline - (tp->address + sizeof (small_jump_insn))) & 0xffff;
memcpy (buf, small_jump_insn, sizeof (small_jump_insn));
memcpy (buf + 2, &offset, 2);
memcpy (jjump_pad_insn, buf, sizeof (small_jump_insn));
@@ -1411,7 +1405,7 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
else
{
/* Else use a 32-bit relative jump instruction. */
- offset = *jump_entry - (tpaddr + sizeof (jump_insn));
+ offset = *jump_entry - (tp->address + sizeof (jump_insn));
memcpy (buf, jump_insn, sizeof (jump_insn));
memcpy (buf + 1, &offset, 4);
memcpy (jjump_pad_insn, buf, sizeof (jump_insn));
@@ -1425,40 +1419,33 @@ i386_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
}

static int
-x86_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+x86_install_fast_tracepoint_jump_pad (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err)
{
#ifdef __x86_64__
if (is_64bit_tdesc ())
- return amd64_install_fast_tracepoint_jump_pad (tpoint, tpaddr,
+ return amd64_install_fast_tracepoint_jump_pad (tp,
collector, lockaddr,
- orig_size, jump_entry,
+ jump_entry,
trampoline, trampoline_size,
jjump_pad_insn,
jjump_pad_insn_size,
- adjusted_insn_addr,
- adjusted_insn_addr_end,
err);
#endif

- return i386_install_fast_tracepoint_jump_pad (tpoint, tpaddr,
+ return i386_install_fast_tracepoint_jump_pad (tp,
collector, lockaddr,
- orig_size, jump_entry,
+ jump_entry,
trampoline, trampoline_size,
jjump_pad_insn,
jjump_pad_insn_size,
- adjusted_insn_addr,
- adjusted_insn_addr_end,
err);
}

diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index 4c14c20..e6f0542 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -32,6 +32,7 @@
struct emit_ops;
struct buffer;
struct process_info;
+struct tracepoint;

/* This structure describes how to resume a particular thread (or all
threads) based on the client's request. If thread is -1, then this
@@ -358,17 +359,14 @@ struct target_ops
return the address range where the instruction at TPADDR was relocated
to. If an error occurs, the ERR may be used to pass on an error
message. */
- int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
+ int (*install_fast_tracepoint_jump_pad) (struct tracepoint *tp,
CORE_ADDR collector,
CORE_ADDR lockaddr,
- ULONGEST orig_size,
CORE_ADDR *jump_entry,
CORE_ADDR *trampoline,
ULONGEST *trampoline_size,
unsigned char *jjump_pad_insn,
ULONGEST *jjump_pad_insn_size,
- CORE_ADDR *adjusted_insn_addr,
- CORE_ADDR *adjusted_insn_addr_end,
char *err);

/* Return the bytecode operations vector for the current inferior.
@@ -592,25 +590,23 @@ int kill_inferior (int);
(*the_target->stabilize_threads) (); \
} while (0)

-#define install_fast_tracepoint_jump_pad(tpoint, tpaddr, \
- collector, lockaddr, \
- orig_size, \
+#define install_fast_tracepoint_jump_pad(tp, \
+ collector, \
+ lockaddr, \
jump_entry, \
- trampoline, trampoline_size, \
+ trampoline, \
+ trampoline_size, \
jjump_pad_insn, \
jjump_pad_insn_size, \
- adjusted_insn_addr, \
- adjusted_insn_addr_end, \
err) \
- (*the_target->install_fast_tracepoint_jump_pad) (tpoint, tpaddr, \
- collector,lockaddr, \
- orig_size, jump_entry, \
+ (*the_target->install_fast_tracepoint_jump_pad) (tp, \
+ collector, \
+ lockaddr, \
+ jump_entry, \
trampoline, \
trampoline_size, \
jjump_pad_insn, \
jjump_pad_insn_size, \
- adjusted_insn_addr, \
- adjusted_insn_addr_end, \
err)

#define target_emit_ops() \
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index d3ddeaf..a139f67 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -673,136 +673,11 @@ struct source_string
struct source_string *next;
};

-enum tracepoint_type
-{
- /* Trap based tracepoint. */
- trap_tracepoint,
-
- /* A fast tracepoint implemented with a jump instead of a trap. */
- fast_tracepoint,
-
- /* A static tracepoint, implemented by a program call into a tracing
- library. */
- static_tracepoint
-};
-
struct tracepoint_hit_ctx;

typedef enum eval_result_type (*condfn) (unsigned char *,
ULONGEST *);

-/* The definition of a tracepoint. */
-
-/* Tracepoints may have multiple locations, each at a different
- address. This can occur with optimizations, template
- instantiation, etc. Since the locations may be in different
- scopes, the conditions and actions may be different for each
- location. Our target version of tracepoints is more like GDB's
- notion of "breakpoint locations", but we have almost nothing that
- is not per-location, so we bother having two kinds of objects. The
- key consequence is that numbers are not unique, and that it takes
- both number and address to identify a tracepoint uniquely. */
-
-struct tracepoint
-{
- /* The number of the tracepoint, as specified by GDB. Several
- tracepoint objects here may share a number. */
- uint32_t number;
-
- /* Address at which the tracepoint is supposed to trigger. Several
- tracepoints may share an address. */
- CORE_ADDR address;
-
- /* Tracepoint type. */
- enum tracepoint_type type;
-
- /* True if the tracepoint is currently enabled. */
- int8_t enabled;
-
- /* The number of single steps that will be performed after each
- tracepoint hit. */
- uint64_t step_count;
-
- /* The number of times the tracepoint may be hit before it will
- terminate the entire tracing run. */
- uint64_t pass_count;
-
- /* Pointer to the agent expression that is the tracepoint's
- conditional, or NULL if the tracepoint is unconditional. */
- struct agent_expr *cond;
-
- /* The list of actions to take when the tracepoint triggers. */
- uint32_t numactions;
- struct tracepoint_action **actions;
-
- /* Count of the times we've hit this tracepoint during the run.
- Note that while-stepping steps are not counted as "hits". */
- uint64_t hit_count;
-
- /* Cached sum of the sizes of traceframes created by this point. */
- uint64_t traceframe_usage;
-
- CORE_ADDR compiled_cond;
-
- /* Link to the next tracepoint in the list. */
- struct tracepoint *next;
-
- /* Optional kind of the breakpoint to be used. Note this can mean
- different things for different archs as z0 breakpoint command.
- Value is -1 if not persent. */
- int32_t kind;
-
-#ifndef IN_PROCESS_AGENT
- /* The list of actions to take when the tracepoint triggers, in
- string/packet form. */
- char **actions_str;
-
- /* The collection of strings that describe the tracepoint as it was
- entered into GDB. These are not used by the target, but are
- reported back to GDB upon reconnection. */
- struct source_string *source_strings;
-
- /* The number of bytes displaced by fast tracepoints. It may subsume
- multiple instructions, for multi-byte fast tracepoints. This
- field is only valid for fast tracepoints. */
- uint32_t orig_size;
-
- /* Only for fast tracepoints. */
- CORE_ADDR obj_addr_on_target;
-
- /* Address range where the original instruction under a fast
- tracepoint was relocated to. (_end is actually one byte past
- the end). */
- CORE_ADDR adjusted_insn_addr;
- CORE_ADDR adjusted_insn_addr_end;
-
- /* The address range of the piece of the jump pad buffer that was
- assigned to this fast tracepoint. (_end is actually one byte
- past the end).*/
- CORE_ADDR jump_pad;
- CORE_ADDR jump_pad_end;
-
- /* The address range of the piece of the trampoline buffer that was
- assigned to this fast tracepoint. (_end is actually one byte
- past the end). */
- CORE_ADDR trampoline;
- CORE_ADDR trampoline_end;
-
- /* The list of actions to take while in a stepping loop. These
- fields are only valid for patch-based tracepoints. */
- int num_step_actions;
- struct tracepoint_action **step_actions;
- /* Same, but in string/packet form. */
- char **step_actions_str;
-
- /* Handle returned by the breakpoint or tracepoint module when we
- inserted the trap or jump, or hooked into a static tracepoint.
- NULL if we haven't inserted it yet. */
- void *handle;
-#endif
-
-};
-
#ifndef IN_PROCESS_AGENT

/* Given `while-stepping', a thread may be collecting data for more
@@ -3117,16 +2992,12 @@ install_fast_tracepoint (struct tracepoint *tpoint, char *errbuf)
trampoline_size = 0;

/* Install the jump pad. */
- err = install_fast_tracepoint_jump_pad (tpoint->obj_addr_on_target,
- tpoint->address,
+ err = install_fast_tracepoint_jump_pad (tpoint,
collect,
ipa_sym_addrs.addr_collecting,
- tpoint->orig_size,
&jentry,
&trampoline, &trampoline_size,
fjump, &fjump_size,
- &tpoint->adjusted_insn_addr,
- &tpoint->adjusted_insn_addr_end,
errbuf);

if (err)
diff --git a/gdb/gdbserver/tracepoint.h b/gdb/gdbserver/tracepoint.h
index 679a32a..c45a03c 100644
--- a/gdb/gdbserver/tracepoint.h
+++ b/gdb/gdbserver/tracepoint.h
@@ -178,4 +178,129 @@ CORE_ADDR get_get_tsv_func_addr (void);
function in the IPA. */
CORE_ADDR get_set_tsv_func_addr (void);

+enum tracepoint_type
+{
+ /* Trap based tracepoint. */
+ trap_tracepoint,
+
+ /* A fast tracepoint implemented with a jump instead of a trap. */
+ fast_tracepoint,
+
+ /* A static tracepoint, implemented by a program call into a tracing
+ library. */
+ static_tracepoint
+};
+
+/* The definition of a tracepoint. */
+
+/* Tracepoints may have multiple locations, each at a different
+ address. This can occur with optimizations, template
+ instantiation, etc. Since the locations may be in different
+ scopes, the conditions and actions may be different for each
+ location. Our target version of tracepoints is more like GDB's
+ notion of "breakpoint locations", but we have almost nothing that
+ is not per-location, so we bother having two kinds of objects. The
+ key consequence is that numbers are not unique, and that it takes
+ both number and address to identify a tracepoint uniquely. */
+
+struct tracepoint
+{
+ /* The number of the tracepoint, as specified by GDB. Several
+ tracepoint objects here may share a number. */
+ uint32_t number;
+
+ /* Address at which the tracepoint is supposed to trigger. Several
+ tracepoints may share an address. */
+ CORE_ADDR address;
+
+ /* Tracepoint type. */
+ enum tracepoint_type type;
+
+ /* True if the tracepoint is currently enabled. */
+ int8_t enabled;
+
+ /* The number of single steps that will be performed after each
+ tracepoint hit. */
+ uint64_t step_count;
+
+ /* The number of times the tracepoint may be hit before it will
+ terminate the entire tracing run. */
+ uint64_t pass_count;
+
+ /* Pointer to the agent expression that is the tracepoint's
+ conditional, or NULL if the tracepoint is unconditional. */
+ struct agent_expr *cond;
+
+ /* The list of actions to take when the tracepoint triggers. */
+ uint32_t numactions;
+ struct tracepoint_action **actions;
+
+ /* Count of the times we've hit this tracepoint during the run.
+ Note that while-stepping steps are not counted as "hits". */
+ uint64_t hit_count;
+
+ /* Cached sum of the sizes of traceframes created by this point. */
+ uint64_t traceframe_usage;
+
+ CORE_ADDR compiled_cond;
+
+ /* Link to the next tracepoint in the list. */
+ struct tracepoint *next;
+
+ /* Optional kind of the breakpoint to be used
+ note this can mean different things for different archs as z0
+ breakpoint command */
+ uint32_t kind;
+
+#ifndef IN_PROCESS_AGENT
+ /* The list of actions to take when the tracepoint triggers, in
+ string/packet form. */
+ char **actions_str;
+
+ /* The collection of strings that describe the tracepoint as it was
+ entered into GDB. These are not used by the target, but are
+ reported back to GDB upon reconnection. */
+ struct source_string *source_strings;
+
+ /* The number of bytes displaced by fast tracepoints. It may subsume
+ multiple instructions, for multi-byte fast tracepoints. This
+ field is only valid for fast tracepoints. */
+ uint32_t orig_size;
+
+ /* Only for fast tracepoints. */
+ CORE_ADDR obj_addr_on_target;
+
+ /* Address range where the original instruction under a fast
+ tracepoint was relocated to. (_end is actually one byte past
+ the end). */
+ CORE_ADDR adjusted_insn_addr;
+ CORE_ADDR adjusted_insn_addr_end;
+
+ /* The address range of the piece of the jump pad buffer that was
+ assigned to this fast tracepoint. (_end is actually one byte
+ past the end).*/
+ CORE_ADDR jump_pad;
+ CORE_ADDR jump_pad_end;
+
+ /* The address range of the piece of the trampoline buffer that was
+ assigned to this fast tracepoint. (_end is actually one byte
+ past the end). */
+ CORE_ADDR trampoline;
+ CORE_ADDR trampoline_end;
+
+ /* The list of actions to take while in a stepping loop. These
+ fields are only valid for patch-based tracepoints. */
+ int num_step_actions;
+ struct tracepoint_action **step_actions;
+ /* Same, but in string/packet form. */
+ char **step_actions_str;
+
+ /* Handle returned by the breakpoint or tracepoint module when we
+ inserted the trap or jump, or hooked into a static tracepoint.
+ NULL if we haven't inserted it yet. */
+ void *handle;
+#endif
+
+};
+
#endif /* TRACEPOINT_H */
--
2.8.1