* mem-break.c (inc_ref_fast_tracepoint_jump): New.
* mem-break.h: Declare. * tracepoint.c (cmd_qtstart): Move some code to ... (clone_fast_tracepoint, install_fast_tracepoint): ... here. New. (download_tracepoints): Move some code to ... (download_tracepoint_1): ... here. New.
This commit is contained in:
parent
e8ba31153a
commit
5c73ff4ec2
4 changed files with 211 additions and 168 deletions
|
@ -1,3 +1,13 @@
|
|||
2011-11-14 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* mem-break.c (inc_ref_fast_tracepoint_jump): New.
|
||||
* mem-break.h: Declare.
|
||||
* tracepoint.c (cmd_qtstart): Move some code to ...
|
||||
(clone_fast_tracepoint, install_fast_tracepoint): ... here.
|
||||
New.
|
||||
(download_tracepoints): Move some code to ...
|
||||
(download_tracepoint_1): ... here. New.
|
||||
|
||||
2011-11-08 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* remote-utils.c (relocate_instruction): A comment fix.
|
||||
|
|
|
@ -302,6 +302,12 @@ delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel)
|
|||
return ENOENT;
|
||||
}
|
||||
|
||||
void
|
||||
inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp)
|
||||
{
|
||||
jp->refcount++;
|
||||
}
|
||||
|
||||
struct fast_tracepoint_jump *
|
||||
set_fast_tracepoint_jump (CORE_ADDR where,
|
||||
unsigned char *insn, ULONGEST length)
|
||||
|
|
|
@ -137,6 +137,9 @@ struct fast_tracepoint_jump *set_fast_tracepoint_jump (CORE_ADDR where,
|
|||
unsigned char *insn,
|
||||
ULONGEST length);
|
||||
|
||||
/* Increment reference counter of JP. */
|
||||
void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp);
|
||||
|
||||
/* Delete fast tracepoint jump TODEL from our tables, and uninsert if
|
||||
from memory. */
|
||||
|
||||
|
|
|
@ -1245,6 +1245,7 @@ static void do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
|
|||
|
||||
#ifndef IN_PROCESS_AGENT
|
||||
static struct tracepoint *fast_tracepoint_from_ipa_tpoint_address (CORE_ADDR);
|
||||
static int install_fast_tracepoint (struct tracepoint *);
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
@ -2737,18 +2738,70 @@ probe_marker_at (CORE_ADDR address, char *errout)
|
|||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
clone_fast_tracepoint (struct tracepoint *to, const struct tracepoint *from)
|
||||
{
|
||||
to->jump_pad = from->jump_pad;
|
||||
to->jump_pad_end = from->jump_pad_end;
|
||||
to->adjusted_insn_addr = from->adjusted_insn_addr;
|
||||
to->adjusted_insn_addr_end = from->adjusted_insn_addr_end;
|
||||
to->handle = from->handle;
|
||||
|
||||
gdb_assert (from->handle);
|
||||
inc_ref_fast_tracepoint_jump ((struct fast_tracepoint_jump *) from->handle);
|
||||
}
|
||||
|
||||
#define MAX_JUMP_SIZE 20
|
||||
|
||||
/* Install fast tracepoint. Return 0 if successful, otherwise return
|
||||
non-zero. */
|
||||
|
||||
static int
|
||||
install_fast_tracepoint (struct tracepoint *tpoint)
|
||||
{
|
||||
CORE_ADDR jentry, jump_entry;
|
||||
int err = 0;
|
||||
/* The jump to the jump pad of the last fast tracepoint
|
||||
installed. */
|
||||
unsigned char fjump[MAX_JUMP_SIZE];
|
||||
ULONGEST fjump_size;
|
||||
|
||||
jentry = jump_entry = get_jump_space_head ();
|
||||
|
||||
/* Install the jump pad. */
|
||||
err = install_fast_tracepoint_jump_pad (tpoint->obj_addr_on_target,
|
||||
tpoint->address,
|
||||
ipa_sym_addrs.addr_gdb_collect,
|
||||
ipa_sym_addrs.addr_collecting,
|
||||
tpoint->orig_size,
|
||||
&jentry, fjump, &fjump_size,
|
||||
&tpoint->adjusted_insn_addr,
|
||||
&tpoint->adjusted_insn_addr_end);
|
||||
|
||||
if (err)
|
||||
return 1;
|
||||
|
||||
/* Wire it in. */
|
||||
tpoint->handle = set_fast_tracepoint_jump (tpoint->address, fjump,
|
||||
fjump_size);
|
||||
|
||||
if (tpoint->handle != NULL)
|
||||
{
|
||||
tpoint->jump_pad = jump_entry;
|
||||
tpoint->jump_pad_end = jentry;
|
||||
|
||||
/* Pad to 8-byte alignment. */
|
||||
jentry = ((jentry + 7) & ~0x7);
|
||||
claim_jump_space (jentry - jump_entry);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_qtstart (char *packet)
|
||||
{
|
||||
struct tracepoint *tpoint, *prev_ftpoint, *prev_stpoint;
|
||||
CORE_ADDR jump_entry;
|
||||
|
||||
/* The jump to the jump pad of the last fast tracepoint
|
||||
installed. */
|
||||
unsigned char fjump[MAX_JUMP_SIZE];
|
||||
ULONGEST fjump_size;
|
||||
|
||||
trace_debug ("Starting the trace");
|
||||
|
||||
|
@ -2808,55 +2861,12 @@ cmd_qtstart (char *packet)
|
|||
}
|
||||
|
||||
if (prev_ftpoint != NULL && prev_ftpoint->address == tpoint->address)
|
||||
{
|
||||
tpoint->handle = set_fast_tracepoint_jump (tpoint->address,
|
||||
fjump,
|
||||
fjump_size);
|
||||
tpoint->jump_pad = prev_ftpoint->jump_pad;
|
||||
tpoint->jump_pad_end = prev_ftpoint->jump_pad_end;
|
||||
tpoint->adjusted_insn_addr = prev_ftpoint->adjusted_insn_addr;
|
||||
tpoint->adjusted_insn_addr_end
|
||||
= prev_ftpoint->adjusted_insn_addr_end;
|
||||
}
|
||||
clone_fast_tracepoint (tpoint, prev_ftpoint);
|
||||
else
|
||||
{
|
||||
CORE_ADDR jentry;
|
||||
int err = 0;
|
||||
|
||||
prev_ftpoint = NULL;
|
||||
|
||||
jentry = jump_entry = get_jump_space_head ();
|
||||
|
||||
/* Install the jump pad. */
|
||||
err = install_fast_tracepoint_jump_pad
|
||||
(tpoint->obj_addr_on_target,
|
||||
tpoint->address,
|
||||
ipa_sym_addrs.addr_gdb_collect,
|
||||
ipa_sym_addrs.addr_collecting,
|
||||
tpoint->orig_size,
|
||||
&jentry,
|
||||
fjump, &fjump_size,
|
||||
&tpoint->adjusted_insn_addr,
|
||||
&tpoint->adjusted_insn_addr_end);
|
||||
|
||||
/* Wire it in. */
|
||||
if (!err)
|
||||
tpoint->handle = set_fast_tracepoint_jump (tpoint->address,
|
||||
fjump, fjump_size);
|
||||
|
||||
if (tpoint->handle != NULL)
|
||||
{
|
||||
tpoint->jump_pad = jump_entry;
|
||||
tpoint->jump_pad_end = jentry;
|
||||
|
||||
/* Pad to 8-byte alignment. */
|
||||
jentry = ((jentry + 7) & ~0x7);
|
||||
claim_jump_space (jentry - jump_entry);
|
||||
|
||||
/* So that we can handle multiple fast tracepoints
|
||||
at the same address easily. */
|
||||
if (install_fast_tracepoint (tpoint) == 0)
|
||||
prev_ftpoint = tpoint;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (tpoint->type == static_tracepoint)
|
||||
|
@ -6325,24 +6335,17 @@ download_agent_expr (struct agent_expr *expr)
|
|||
/* Align V up to N bits. */
|
||||
#define UALIGN(V, N) (((V) + ((N) - 1)) & ~((N) - 1))
|
||||
|
||||
/* Sync tracepoint with IPA, but leave maintenance of linked list to caller. */
|
||||
|
||||
static void
|
||||
download_tracepoints (void)
|
||||
{
|
||||
CORE_ADDR tpptr = 0, prev_tpptr = 0;
|
||||
struct tracepoint *tpoint;
|
||||
|
||||
/* Start out empty. */
|
||||
write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, 0);
|
||||
|
||||
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
|
||||
download_tracepoint_1 (struct tracepoint *tpoint)
|
||||
{
|
||||
struct tracepoint target_tracepoint;
|
||||
CORE_ADDR tpptr = 0;
|
||||
|
||||
if (tpoint->type != fast_tracepoint
|
||||
&& tpoint->type != static_tracepoint)
|
||||
continue;
|
||||
gdb_assert (tpoint->type == fast_tracepoint
|
||||
|| tpoint->type == static_tracepoint);
|
||||
|
||||
/* Maybe download a compiled condition. */
|
||||
if (tpoint->cond != NULL && target_emit_ops () != NULL)
|
||||
{
|
||||
CORE_ADDR jentry, jump_entry;
|
||||
|
@ -6366,23 +6369,9 @@ download_tracepoints (void)
|
|||
|
||||
target_tracepoint = *tpoint;
|
||||
|
||||
prev_tpptr = tpptr;
|
||||
tpptr = target_malloc (sizeof (*tpoint));
|
||||
tpoint->obj_addr_on_target = tpptr;
|
||||
|
||||
if (tpoint == tracepoints)
|
||||
{
|
||||
/* First object in list, set the head pointer in the
|
||||
inferior. */
|
||||
write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, tpptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
write_inferior_data_ptr (prev_tpptr + offsetof (struct tracepoint,
|
||||
next),
|
||||
tpptr);
|
||||
}
|
||||
|
||||
/* Write the whole object. We'll fix up its pointers in a bit.
|
||||
Assume no next for now. This is fixed up above on the next
|
||||
iteration, if there's any. */
|
||||
|
@ -6471,6 +6460,41 @@ download_tracepoints (void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
download_tracepoints (void)
|
||||
{
|
||||
CORE_ADDR tpptr = 0, prev_tpptr = 0;
|
||||
struct tracepoint *tpoint;
|
||||
|
||||
/* Start out empty. */
|
||||
write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, 0);
|
||||
|
||||
for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
|
||||
{
|
||||
if (tpoint->type != fast_tracepoint
|
||||
&& tpoint->type != static_tracepoint)
|
||||
continue;
|
||||
|
||||
prev_tpptr = tpptr;
|
||||
|
||||
download_tracepoint_1 (tpoint);
|
||||
|
||||
tpptr = tpoint->obj_addr_on_target;
|
||||
|
||||
if (tpoint == tracepoints)
|
||||
{
|
||||
/* First object in list, set the head pointer in the
|
||||
inferior. */
|
||||
write_inferior_data_ptr (ipa_sym_addrs.addr_tracepoints, tpptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
write_inferior_data_ptr (prev_tpptr + offsetof (struct tracepoint,
|
||||
next),
|
||||
tpptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue