[PATCH 1/2] New field stop_pc in tracepoint_hit_ctx

Yao Qi
2012-03-02T01:00:46Z

This patch is to add a new field `stop_pc' in tracepoint_hit_ctx, so
parameter `stop_pc' used here and there can be removed. This change
allows us to give a clean interface in next patch.

Note the name `tracepoint_hit_ctx' is not very accurate, because it
has been used in collect_data_at_step for "while-stepping" action also.
It may be renamed to `tracepoint_action_ctx', which is about the
context of doing tracepoint actions. I don't rename `tracepoint_hit_ctx'
to keep this patch as readable as possible. I can send a follow-up
patch to rename it if this change is reasonable.

As `tracepoint_hit_ctx' is about the context of doing tracepoint
actions, it is natural to add field `stop_pc' to show the pc value when
to do tracepoint actions.

gdb/gdbserver:
* tracepoint (struct tracepoint_hit_ctx) <stop_pc>: New field.
(collect_data_at_tracepoint): Remove parameter `stop_pc'.
Update callers.
(collect_data_at_step): Remove parameter `stop_pc'. Update
callers.
(do_action_at_tracepoint): Remove parameter `stop_pc'.
---
gdb/gdbserver/tracepoint.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 7167876..5dcc7a4 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -1125,6 +1125,7 @@ char *tracing_stop_note;
struct tracepoint_hit_ctx
{
enum tracepoint_type type;
+ CORE_ADDR stop_pc;
};

#ifdef IN_PROCESS_AGENT
@@ -1205,17 +1206,14 @@ static void clear_installed_tracepoints (void);
#endif

static void collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
struct tracepoint *tpoint);
#ifndef IN_PROCESS_AGENT
static void collect_data_at_step (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
struct tracepoint *tpoint, int current_step);
static void compile_tracepoint_condition (struct tracepoint *tpoint,
CORE_ADDR *jump_entry);
#endif
static void do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
struct tracepoint *tpoint,
struct traceframe *tframe,
struct tracepoint_action *taction);
@@ -4051,6 +4049,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
wstep->tp_number, paddress (wstep->tp_address));

ctx.base.type = trap_tracepoint;
+ ctx.base.stop_pc = stop_pc;
ctx.regcache = get_thread_regcache (tinfo, 1);

while (wstep != NULL)
@@ -4074,7 +4073,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)

/* Collect data. */
collect_data_at_step ((struct tracepoint_hit_ctx *) &ctx,
- stop_pc, tpoint, wstep->current_step);
+ tpoint, wstep->current_step);

if (wstep->current_step >= tpoint->step_count)
{
@@ -4213,6 +4212,7 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
return 0;

ctx.base.type = trap_tracepoint;
+ ctx.base.stop_pc = stop_pc;
ctx.regcache = get_thread_regcache (tinfo, 1);

for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
@@ -4235,7 +4235,7 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
|| (condition_true_at_tracepoint
((struct tracepoint_hit_ctx *) &ctx, tpoint)))
collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- stop_pc, tpoint);
+ tpoint);

if (stopping_tracepoint
|| trace_buffer_is_full
@@ -4271,7 +4271,7 @@ static void collect_ust_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
given thread. */

static void
-collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
+collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx,
struct tracepoint *tpoint)
{
struct traceframe *tframe;
@@ -4305,7 +4305,7 @@ collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,
tpoint->actions_str[acti]);
#endif

- do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
+ do_action_at_tracepoint (ctx, tpoint, tframe,
tpoint->actions[acti]);
}

@@ -4320,7 +4320,6 @@ collect_data_at_tracepoint (struct tracepoint_hit_ctx *ctx, CORE_ADDR stop_pc,

static void
collect_data_at_step (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
struct tracepoint *tpoint, int current_step)
{
struct traceframe *tframe;
@@ -4342,7 +4341,7 @@ collect_data_at_step (struct tracepoint_hit_ctx *ctx,
tpoint->number, paddress (tpoint->address),
tpoint->step_actions_str[acti]);

- do_action_at_tracepoint (ctx, stop_pc, tpoint, tframe,
+ do_action_at_tracepoint (ctx, tpoint, tframe,
tpoint->step_actions[acti]);
}

@@ -4409,7 +4408,6 @@ get_context_regcache (struct tracepoint_hit_ctx *ctx)

static void
do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
- CORE_ADDR stop_pc,
struct tracepoint *tpoint,
struct traceframe *tframe,
struct tracepoint_action *taction)
@@ -4473,11 +4471,11 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
preemptively), since the PC had already been adjusted to
contain the tracepoint's address by the jump pad. */
trace_debug ("Storing stop pc (0x%s) in regblock",
- paddress (stop_pc));
+ paddress (ctx->stop_pc));

/* This changes the regblock, not the thread's
regcache. */
- regcache_write_pc (&tregcache, stop_pc);
+ regcache_write_pc (&tregcache, ctx->stop_pc);
#endif
}
break;
@@ -5411,6 +5409,7 @@ gdb_collect (struct tracepoint *tpoint, unsigned char *regs)
return;

ctx.base.type = fast_tracepoint;
+ ctx.base.stop_pc = tpoint->address;
ctx.regs = regs;
ctx.regcache_initted = 0;
/* Wrap the regblock in a register cache (in the stack, we don't
@@ -5440,7 +5439,7 @@ gdb_collect (struct tracepoint *tpoint, unsigned char *regs)
ctx.tpoint))
{
collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- ctx.tpoint->address, ctx.tpoint);
+ ctx.tpoint);

/* Note that this will cause original insns to be written back
to where we jumped from, but that's OK because we're jumping
@@ -6280,6 +6279,8 @@ gdb_probe (const struct marker *mdata, void *probe_private,
}

tpoint = ust_marker_to_static_tracepoint (mdata);
+ ctx.base.stop_pc = tpoint->address;
+
if (tpoint == NULL)
{
trace_debug ("gdb_probe: marker not known: "
@@ -6308,7 +6309,7 @@ gdb_probe (const struct marker *mdata, void *probe_private,
tpoint))
{
collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx,
- tpoint->address, tpoint);
+ tpoint);

if (stopping_tracepoint
|| trace_buffer_is_full
--
1.7.0.4