[PR gdb/13808] gdb.trace: Pass tdesc selected in gdbserver to IPA.
If gdbserver and IPA are using different tdesc, they will disagree about 'R' trace packet size. This results in mangled traces. To make sure they pick the same tdesc, gdbserver pokes the tdesc (specified as an index in a target-specific list) into a global variable in IPA. In theory, IPA could find out the tdesc on its own, but that may be complex (in particular, I don't know how to tell whether we have LAST_BREAK on s390 without messing with ptrace), and we'd have to duplicate the logic. Tested on i386 and x86_64. On i386, it fixes two FAILs in ftrace.exp. On x86_64, these failures have been KFAILed - one of them works now, but the other now fails due to an unrelated reason (ugh). gdb/gdbserver/ChangeLog: PR gdb/13808 * Makefile.in: Add i386-*-linux-ipa.o and amd64-*-linux-ipa.o. * configure.srv: Ditto. * linux-aarch64-ipa.c (get_ipa_tdesc): New function. (initialize_low_tracepoint): Remove ipa_tdesc assignment. * linux-amd64-ipa.c: Add "linux-x86-tdesc.h" include. (init_registers_amd64_linux): Remove prototype. (tdesc_amd64_linux): Remove declaration. (get_ipa_tdesc): New function. (initialize_low_tracepoint): Remove ipa_tdesc assignment, initialize remaining tdescs. * linux-i386-ipa.c: Add "linux-x86-tdesc.h" include. (init_registers_i386_linux): Remove prototype. (tdesc_i386_linux): Remove declaration. (get_ipa_tdesc): New function. (initialize_low_tracepoint): Remove ipa_tdesc assignment, initialize remaining tdescs. * linux-low.c (linux_get_ipa_tdesc_idx): New function. (linux_target_ops): wire in linux_get_ipa_tdesc_idx. * linux-low.h (struct linux_target_ops): Add get_ipa_tdesc_idx. * linux-x86-low.c: Move tdesc declarations to linux-x86-tdesc.h. (x86_get_ipa_tdesc_idx): New function. (the_low_target): Wire in x86_get_ipa_tdesc_idx. * linux-x86-tdesc.h: New file. * target.h (struct target_ops): Add get_ipa_tdesc_idx. (target_get_ipa_tdesc_idx): New macro. * tracepoint.c (ipa_tdesc_idx): New macro. (struct ipa_sym_addresses): Add addr_ipa_tdesc_idx. (symbol_list): Add ipa_tdesc_idx. (cmd_qtstart): Write ipa_tdesc_idx in the target. (ipa_tdesc): Remove. (ipa_tdesc_idx): New variable. (get_context_regcache): Use get_ipa_tdesc. (gdb_collect): Ditto. (gdb_probe): Ditto. * tracepoint.h (get_ipa_tdesc): New prototype. (ipa_tdesc): Remove. gdb/testsuite/ChangeLog: PR gdb/13808 * gdb.trace/ftrace.exp (test_fast_tracepoints): Remove kfail.
This commit is contained in:
parent
e0471c16c5
commit
ae91f62539
15 changed files with 298 additions and 70 deletions
|
@ -134,6 +134,7 @@ trace_vdebug (const char *fmt, ...)
|
|||
# define ust_loaded IPA_SYM_EXPORTED_NAME (ust_loaded)
|
||||
# define helper_thread_id IPA_SYM_EXPORTED_NAME (helper_thread_id)
|
||||
# define cmd_buf IPA_SYM_EXPORTED_NAME (cmd_buf)
|
||||
# define ipa_tdesc_idx IPA_SYM_EXPORTED_NAME (ipa_tdesc_idx)
|
||||
#endif
|
||||
|
||||
#ifndef IN_PROCESS_AGENT
|
||||
|
@ -171,6 +172,7 @@ struct ipa_sym_addresses
|
|||
CORE_ADDR addr_get_trace_state_variable_value;
|
||||
CORE_ADDR addr_set_trace_state_variable_value;
|
||||
CORE_ADDR addr_ust_loaded;
|
||||
CORE_ADDR addr_ipa_tdesc_idx;
|
||||
};
|
||||
|
||||
static struct
|
||||
|
@ -207,6 +209,7 @@ static struct
|
|||
IPA_SYM(get_trace_state_variable_value),
|
||||
IPA_SYM(set_trace_state_variable_value),
|
||||
IPA_SYM(ust_loaded),
|
||||
IPA_SYM(ipa_tdesc_idx),
|
||||
};
|
||||
|
||||
static struct ipa_sym_addresses ipa_sym_addrs;
|
||||
|
@ -3211,6 +3214,11 @@ cmd_qtstart (char *packet)
|
|||
|
||||
*packet = '\0';
|
||||
|
||||
/* Tell IPA about the correct tdesc. */
|
||||
if (write_inferior_integer (ipa_sym_addrs.addr_ipa_tdesc_idx,
|
||||
target_get_ipa_tdesc_idx ()))
|
||||
error ("Error setting ipa_tdesc_idx variable in lib");
|
||||
|
||||
/* Start out empty. */
|
||||
if (agent_loaded_p ())
|
||||
write_inferior_data_pointer (ipa_sym_addrs.addr_tracepoints, 0);
|
||||
|
@ -4694,19 +4702,20 @@ collect_data_at_step (struct tracepoint_hit_ctx *ctx,
|
|||
#endif
|
||||
|
||||
#ifdef IN_PROCESS_AGENT
|
||||
/* The target description used by the IPA. Given that the IPA library
|
||||
is built for a specific architecture that is loaded into the
|
||||
inferior, there only needs to be one such description per
|
||||
build. */
|
||||
const struct target_desc *ipa_tdesc;
|
||||
/* The target description index for IPA. Passed from gdbserver, used
|
||||
to select ipa_tdesc. */
|
||||
EXTERN_C_PUSH
|
||||
IP_AGENT_EXPORT_VAR int ipa_tdesc_idx;
|
||||
EXTERN_C_POP
|
||||
#endif
|
||||
|
||||
static struct regcache *
|
||||
get_context_regcache (struct tracepoint_hit_ctx *ctx)
|
||||
{
|
||||
struct regcache *regcache = NULL;
|
||||
|
||||
#ifdef IN_PROCESS_AGENT
|
||||
const struct target_desc *ipa_tdesc = get_ipa_tdesc (ipa_tdesc_idx);
|
||||
|
||||
if (ctx->type == fast_tracepoint)
|
||||
{
|
||||
struct fast_tracepoint_ctx *fctx = (struct fast_tracepoint_ctx *) ctx;
|
||||
|
@ -5779,11 +5788,13 @@ IP_AGENT_EXPORT_FUNC void
|
|||
gdb_collect (struct tracepoint *tpoint, unsigned char *regs)
|
||||
{
|
||||
struct fast_tracepoint_ctx ctx;
|
||||
const struct target_desc *ipa_tdesc;
|
||||
|
||||
/* Don't do anything until the trace run is completely set up. */
|
||||
if (!tracing)
|
||||
return;
|
||||
|
||||
ipa_tdesc = get_ipa_tdesc (ipa_tdesc_idx);
|
||||
ctx.base.type = fast_tracepoint;
|
||||
ctx.regs = regs;
|
||||
ctx.regcache_initted = 0;
|
||||
|
@ -6629,6 +6640,7 @@ gdb_probe (const struct marker *mdata, void *probe_private,
|
|||
{
|
||||
struct tracepoint *tpoint;
|
||||
struct static_tracepoint_ctx ctx;
|
||||
const struct target_desc *ipa_tdesc;
|
||||
|
||||
/* Don't do anything until the trace run is completely set up. */
|
||||
if (!tracing)
|
||||
|
@ -6637,6 +6649,7 @@ gdb_probe (const struct marker *mdata, void *probe_private,
|
|||
return;
|
||||
}
|
||||
|
||||
ipa_tdesc = get_ipa_tdesc (ipa_tdesc_idx);
|
||||
ctx.base.type = static_tracepoint;
|
||||
ctx.regcache_initted = 0;
|
||||
ctx.regs = regs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue