mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
3c14e5a39b
Functions and variables that are exported by the IPA DSO (that GDBserver needs to look up) should have "C" mangling, thus be declared with extern "C". Function and variable declarations need the extern "C" marker, but variable definitions can't be marked extern, so the patch splits IP_AGENT_EXPORT into three. Building in C++ mode revealed that a few variables were missing IP_AGENT_EXPORT, thus the IPA has been broken when stripped, even in C mode... So this ends being a bug fix as well. gdb/ChangeLog: 2015-02-27 Pedro Alves <palves@redhat.com> * common/agent.h (IPA_SYM_EXPORTED_NAME): New. (IPA_SYM): Use it. * common/common-defs.h (EXTERN_C_PUSH, EXTERN_C_POP): New macros. gdb/gdbserver/ChangeLog: 2015-02-27 Pedro Alves <palves@redhat.com> * linux-amd64-ipa.c (gdb_agent_get_raw_reg): Use IP_AGENT_EXPORT_FUNC. * linux-i386-ipa.c (gdb_agent_get_raw_reg): Use IP_AGENT_EXPORT_FUNC. * tracepoint.c (ATTR_USED, ATTR_NOINLINE, ATTR_CONSTRUCTOR) (IP_AGENT_EXPORT): Delete. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (gdb_trampoline_buffer, gdb_trampoline_buffer_end) (gdb_trampoline_buffer_error, collecting, gdb_collect) (stop_tracing, flush_trace_buffer, about_to_request_buffer_space) (trace_buffer_is_full, stopping_tracepoint, expr_eval_result) (error_tracepoint, tracepoints, tracing, trace_buffer_ctrl) (trace_buffer_ctrl_curr, trace_buffer_lo, trace_buffer_hi) (traceframe_read_count, traceframe_write_count) (traceframes_created, trace_state_variables, get_raw_reg) (get_trace_state_variable_value, set_trace_state_variable_value) (ust_loaded, helper_thread_id, cmd_buf): Use IPA_SYM_EXPORTED_NAME. (stop_tracing, flush_trace_buffer): Use IP_AGENT_EXPORT_FUNC. (tracepoints) Use IP_AGENT_EXPORT_VAR. (stopping_tracepoint, trace_buffer_is_full, expr_eval_result): Use IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP. (last_tracepoint): Move into !IN_PROCESS_AGENT block. (error_tracepoint): Use IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP. (trace_state_variables): Use IP_AGENT_EXPORT_VAR. (trace_buffer_lo, trace_buffer_hi): Use IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP. (trace_buffer_ctrl, trace_buffer_ctrl_curr) (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT_VAR. (about_to_request_buffer_space, get_trace_state_variable_value) (set_trace_state_variable_value): Use IP_AGENT_EXPORT_FUNC. (collecting): Use IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP. (gdb_collect): Use IP_AGENT_EXPORT_FUNC. (ust_loaded, cmd_buf): Use IP_AGENT_EXPORT_VAR. (helper_thread_id, gdb_agent_capability): Use IP_AGENT_EXPORT_VAR and wrap in EXTERN_C_PUSH/EXTERN_C_POP. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (gdb_trampoline_buffer, gdb_trampoline_buffer_end) (gdb_trampoline_buffer_error): Use IP_AGENT_EXPORT_VAR. * tracepoint.h (ATTR_USED, ATTR_NOINLINE, EXPORTED_SYMBOL): Define. (IP_AGENT_EXPORT_FUNC, IP_AGENT_EXPORT_VAR) (IP_AGENT_EXPORT_VAR_DECL): Define. (tracing): Declare. (gdb_agent_get_raw_reg): Declare.
181 lines
5.8 KiB
C
181 lines
5.8 KiB
C
/* Tracepoint code for remote server for GDB.
|
|
Copyright (C) 1993-2015 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef TRACEPOINT_H
|
|
#define TRACEPOINT_H
|
|
|
|
/* Size for a small buffer to report problems from the in-process
|
|
agent back to GDBserver. */
|
|
#define IPA_BUFSIZ 100
|
|
|
|
void initialize_tracepoint (void);
|
|
|
|
#if defined(__GNUC__)
|
|
# define ATTR_USED __attribute__((used))
|
|
# define ATTR_NOINLINE __attribute__((noinline))
|
|
#else
|
|
# define ATTR_USED
|
|
# define ATTR_NOINLINE
|
|
#endif
|
|
|
|
/* How to make symbol public/exported. */
|
|
|
|
#if defined _WIN32 || defined __CYGWIN__
|
|
# define EXPORTED_SYMBOL __declspec (dllexport)
|
|
#else
|
|
# if __GNUC__ >= 4
|
|
# define EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
|
# else
|
|
# define EXPORTED_SYMBOL
|
|
# endif
|
|
#endif
|
|
|
|
/* Use these to make sure the functions and variables the IPA needs to
|
|
export (symbols GDBserver needs to query GDB about) are visible and
|
|
have C linkage.
|
|
|
|
Tag exported functions with IP_AGENT_EXPORT_FUNC, tag the
|
|
definitions of exported variables with IP_AGENT_EXPORT_VAR, and
|
|
variable declarations with IP_AGENT_EXPORT_VAR_DECL. Variables
|
|
must also be exported with C linkage. As we can't both use extern
|
|
"C" and initialize a variable in the same statement, variables that
|
|
don't have a separate declaration must use
|
|
EXTERN_C_PUSH/EXTERN_C_POP around their definition. */
|
|
|
|
#ifdef IN_PROCESS_AGENT
|
|
# define IP_AGENT_EXPORT_FUNC EXTERN_C EXPORTED_SYMBOL ATTR_NOINLINE ATTR_USED
|
|
# define IP_AGENT_EXPORT_VAR EXPORTED_SYMBOL ATTR_USED
|
|
# define IP_AGENT_EXPORT_VAR_DECL EXTERN_C EXPORTED_SYMBOL
|
|
#else
|
|
# define IP_AGENT_EXPORT_FUNC
|
|
# define IP_AGENT_EXPORT_VAR
|
|
# define IP_AGENT_EXPORT_VAR_DECL extern
|
|
#endif
|
|
|
|
IP_AGENT_EXPORT_VAR_DECL int tracing;
|
|
|
|
extern int disconnected_tracing;
|
|
|
|
void tracepoint_look_up_symbols (void);
|
|
|
|
void stop_tracing (void);
|
|
|
|
int handle_tracepoint_general_set (char *own_buf);
|
|
int handle_tracepoint_query (char *own_buf);
|
|
|
|
int tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc);
|
|
int tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc);
|
|
|
|
void release_while_stepping_state_list (struct thread_info *tinfo);
|
|
|
|
extern int current_traceframe;
|
|
|
|
int in_readonly_region (CORE_ADDR addr, ULONGEST length);
|
|
int traceframe_read_mem (int tfnum, CORE_ADDR addr,
|
|
unsigned char *buf, ULONGEST length,
|
|
ULONGEST *nbytes);
|
|
int fetch_traceframe_registers (int tfnum,
|
|
struct regcache *regcache,
|
|
int regnum);
|
|
|
|
int traceframe_read_sdata (int tfnum, ULONGEST offset,
|
|
unsigned char *buf, ULONGEST length,
|
|
ULONGEST *nbytes);
|
|
|
|
int traceframe_read_info (int tfnum, struct buffer *buffer);
|
|
|
|
/* If a thread is determined to be collecting a fast tracepoint, this
|
|
structure holds the collect status. */
|
|
|
|
struct fast_tpoint_collect_status
|
|
{
|
|
/* The tracepoint that is presently being collected. */
|
|
int tpoint_num;
|
|
CORE_ADDR tpoint_addr;
|
|
|
|
/* The address range in the jump pad of where the original
|
|
instruction the tracepoint jump was inserted was relocated
|
|
to. */
|
|
CORE_ADDR adjusted_insn_addr;
|
|
CORE_ADDR adjusted_insn_addr_end;
|
|
};
|
|
|
|
int fast_tracepoint_collecting (CORE_ADDR thread_area,
|
|
CORE_ADDR stop_pc,
|
|
struct fast_tpoint_collect_status *status);
|
|
void force_unlock_trace_buffer (void);
|
|
|
|
int handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc);
|
|
|
|
#ifdef IN_PROCESS_AGENT
|
|
void initialize_low_tracepoint (void);
|
|
void supply_fast_tracepoint_registers (struct regcache *regcache,
|
|
const unsigned char *regs);
|
|
void supply_static_tracepoint_registers (struct regcache *regcache,
|
|
const unsigned char *regs,
|
|
CORE_ADDR pc);
|
|
void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end,
|
|
char *errmsg);
|
|
|
|
extern const struct target_desc *ipa_tdesc;
|
|
|
|
#else
|
|
void stop_tracing (void);
|
|
|
|
int claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline);
|
|
int have_fast_tracepoint_trampoline_buffer (char *msgbuf);
|
|
void gdb_agent_about_to_close (int pid);
|
|
#endif
|
|
|
|
struct traceframe;
|
|
struct eval_agent_expr_context;
|
|
|
|
/* Do memory copies for bytecodes. */
|
|
/* Do the recording of memory blocks for actions and bytecodes. */
|
|
|
|
int agent_mem_read (struct eval_agent_expr_context *ctx,
|
|
unsigned char *to, CORE_ADDR from,
|
|
ULONGEST len);
|
|
|
|
LONGEST agent_get_trace_state_variable_value (int num);
|
|
void agent_set_trace_state_variable_value (int num, LONGEST val);
|
|
|
|
/* Record the value of a trace state variable. */
|
|
|
|
int agent_tsv_read (struct eval_agent_expr_context *ctx, int n);
|
|
int agent_mem_read_string (struct eval_agent_expr_context *ctx,
|
|
unsigned char *to,
|
|
CORE_ADDR from,
|
|
ULONGEST len);
|
|
|
|
/* The prototype the get_raw_reg function in the IPA. Each arch's
|
|
bytecode compiler emits calls to this function. */
|
|
IP_AGENT_EXPORT_FUNC ULONGEST gdb_agent_get_raw_reg
|
|
(const unsigned char *raw_regs, int regnum);
|
|
|
|
/* Returns the address of the get_raw_reg function in the IPA. */
|
|
CORE_ADDR get_raw_reg_func_addr (void);
|
|
/* Returns the address of the get_trace_state_variable_value
|
|
function in the IPA. */
|
|
CORE_ADDR get_get_tsv_func_addr (void);
|
|
/* Returns the address of the set_trace_state_variable_value
|
|
function in the IPA. */
|
|
CORE_ADDR get_set_tsv_func_addr (void);
|
|
|
|
#endif /* TRACEPOINT_H */
|