* common/agent.c (agent_loaded_p): New.
        (agent_look_up_symbols): New global.
        * common/agent.h: Declare agent_loaded_p.

gdb/gdbserver:

        * Makefile.in (linux-low.o): Keep dependence on agent.h.
        (linux-x86-low.o): Likewise.
        * server.h: Remove in_process_agent_loaded.
        * tracepoint.c (in_process_agent_loaded): Removed.  Moved it
        common/agent.c.
        Update callers.
This commit is contained in:
Yao Qi 2012-03-03 04:34:52 +00:00
parent 8ffcbaaf40
commit 58b4daa56a
9 changed files with 49 additions and 32 deletions

View File

@ -1,3 +1,9 @@
2012-03-03 Yao Qi <yao@codesourcery.com>
* common/agent.c (agent_loaded_p): New.
(agent_look_up_symbols): New global.
* common/agent.h: Declare agent_loaded_p.
2012-03-03 Yao Qi <yao@codesourcery.com> 2012-03-03 Yao Qi <yao@codesourcery.com>
* common/agent.c (struct ipa_sym_addresses) <addr_capability>: New. * common/agent.c (struct ipa_sym_addresses) <addr_capability>: New.

View File

@ -71,6 +71,14 @@ static struct
static struct ipa_sym_addresses ipa_sym_addrs; static struct ipa_sym_addresses ipa_sym_addrs;
static int all_agent_symbols_looked_up = 0;
int
agent_loaded_p (void)
{
return all_agent_symbols_looked_up;
}
/* Look up all symbols needed by agent. Return 0 if all the symbols are /* Look up all symbols needed by agent. Return 0 if all the symbols are
found, return non-zero otherwise. */ found, return non-zero otherwise. */
@ -79,6 +87,8 @@ agent_look_up_symbols (void)
{ {
int i; int i;
all_agent_symbols_looked_up = 0;
for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++) for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
{ {
CORE_ADDR *addrp = CORE_ADDR *addrp =
@ -100,6 +110,7 @@ agent_look_up_symbols (void)
} }
} }
all_agent_symbols_looked_up = 1;
return 0; return 0;
} }

View File

@ -33,6 +33,8 @@ int agent_look_up_symbols (void);
thread. */ thread. */
#define IPA_CMD_BUF_SIZE 1024 #define IPA_CMD_BUF_SIZE 1024
int agent_loaded_p (void);
extern int debug_agent; extern int debug_agent;
extern int use_agent; extern int use_agent;

View File

@ -1,3 +1,12 @@
2012-03-03 Yao Qi <yao@codesourcery.com>
* Makefile.in (linux-low.o): Keep dependence on agent.h.
(linux-x86-low.o): Likewise.
* server.h: Remove in_process_agent_loaded.
* tracepoint.c (in_process_agent_loaded): Removed. Moved it
common/agent.c.
Update callers.
2012-03-03 Yao Qi <yao@codesourcery.com> 2012-03-03 Yao Qi <yao@codesourcery.com>
* tracepoint.c (gdb_agent_capability): New global. * tracepoint.c (gdb_agent_capability): New global.

View File

@ -457,7 +457,7 @@ i386-low.o: i386-low.c $(i386_low_h) $(server_h) $(target_h)
i387-fp.o: i387-fp.c $(server_h) i387-fp.o: i387-fp.c $(server_h)
linux-low.o: linux-low.c $(linux_low_h) $(linux_ptrace_h) $(linux_procfs_h) \ linux-low.o: linux-low.c $(linux_low_h) $(linux_ptrace_h) $(linux_procfs_h) \
$(server_h) $(linux_osdata_h) $(server_h) $(linux_osdata_h) $(agent_h)
$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< @USE_THREAD_DB@ $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< @USE_THREAD_DB@
linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) \ linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) \
@ -474,7 +474,7 @@ linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h) linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
linux-tic6x-low.o: linux-tic6x-low.c $(linux_low_h) $(server_h) linux-tic6x-low.o: linux-tic6x-low.c $(linux_low_h) $(server_h)
linux-x86-low.o: linux-x86-low.c $(linux_low_h) $(server_h) \ linux-x86-low.o: linux-x86-low.c $(linux_low_h) $(server_h) \
$(gdb_proc_service_h) $(i386_low_h) $(gdb_proc_service_h) $(i386_low_h) $(agent_h)
linux-xtensa-low.o: linux-xtensa-low.c xtensa-xtregs.c $(linux_low_h) $(server_h) linux-xtensa-low.o: linux-xtensa-low.c xtensa-xtregs.c $(linux_low_h) $(server_h)
lynx-low.o: lynx-low.c $(server_h) $(target_h) $(lynx_low_h) lynx-low.o: lynx-low.c $(server_h) $(target_h) $(lynx_low_h)

View File

@ -19,6 +19,7 @@
#include "server.h" #include "server.h"
#include "linux-low.h" #include "linux-low.h"
#include "linux-osdata.h" #include "linux-osdata.h"
#include "agent.h"
#include <sys/wait.h> #include <sys/wait.h>
#include <stdio.h> #include <stdio.h>
@ -1390,7 +1391,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
if ((wstat == NULL if ((wstat == NULL
|| (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP)) || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
&& supports_fast_tracepoints () && supports_fast_tracepoints ()
&& in_process_agent_loaded ()) && agent_loaded_p ())
{ {
struct fast_tpoint_collect_status status; struct fast_tpoint_collect_status status;
int r; int r;
@ -2321,7 +2322,7 @@ retry:
if (WIFSTOPPED (w) if (WIFSTOPPED (w)
&& WSTOPSIG (w) != SIGTRAP && WSTOPSIG (w) != SIGTRAP
&& supports_fast_tracepoints () && supports_fast_tracepoints ()
&& in_process_agent_loaded ()) && agent_loaded_p ())
{ {
if (debug_threads) if (debug_threads)
fprintf (stderr, fprintf (stderr,
@ -2875,7 +2876,7 @@ stuck_in_jump_pad_callback (struct inferior_list_entry *entry, void *data)
/* Allow debugging the jump pad, gdb_collect, etc.. */ /* Allow debugging the jump pad, gdb_collect, etc.. */
return (supports_fast_tracepoints () return (supports_fast_tracepoints ()
&& in_process_agent_loaded () && agent_loaded_p ()
&& (gdb_breakpoint_here (lwp->stop_pc) && (gdb_breakpoint_here (lwp->stop_pc)
|| lwp->stopped_by_watchpoint || lwp->stopped_by_watchpoint
|| thread->last_resume_kind == resume_step) || thread->last_resume_kind == resume_step)

View File

@ -28,6 +28,7 @@
#include "elf/common.h" #include "elf/common.h"
#include "gdb_proc_service.h" #include "gdb_proc_service.h"
#include "agent.h"
/* Defined in auto-generated file i386-linux.c. */ /* Defined in auto-generated file i386-linux.c. */
void init_registers_i386_linux (void); void init_registers_i386_linux (void);
@ -1586,7 +1587,7 @@ x86_get_min_fast_tracepoint_insn_len (void)
return 5; return 5;
#endif #endif
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
char errbuf[IPA_BUFSIZ]; char errbuf[IPA_BUFSIZ];

View File

@ -441,8 +441,6 @@ char *pfildes (gdb_fildes_t fd);
agent back to GDBserver. */ agent back to GDBserver. */
#define IPA_BUFSIZ 100 #define IPA_BUFSIZ 100
int in_process_agent_loaded (void);
void initialize_tracepoint (void); void initialize_tracepoint (void);
extern int tracing; extern int tracing;

View File

@ -221,14 +221,6 @@ static struct
static struct ipa_sym_addresses ipa_sym_addrs; static struct ipa_sym_addresses ipa_sym_addrs;
int all_tracepoint_symbols_looked_up;
int
in_process_agent_loaded (void)
{
return all_tracepoint_symbols_looked_up;
}
static int read_inferior_integer (CORE_ADDR symaddr, int *val); static int read_inferior_integer (CORE_ADDR symaddr, int *val);
/* Returns true if both the in-process agent library and the static /* Returns true if both the in-process agent library and the static
@ -240,7 +232,7 @@ in_process_agent_supports_ust (void)
{ {
int loaded = 0; int loaded = 0;
if (!in_process_agent_loaded ()) if (!agent_loaded_p ())
{ {
warning ("In-process agent not loaded"); warning ("In-process agent not loaded");
return 0; return 0;
@ -291,7 +283,7 @@ write_e_ust_not_loaded (char *buffer)
static int static int
maybe_write_ipa_not_loaded (char *buffer) maybe_write_ipa_not_loaded (char *buffer)
{ {
if (!in_process_agent_loaded ()) if (!agent_loaded_p ())
{ {
write_e_ipa_not_loaded (buffer); write_e_ipa_not_loaded (buffer);
return 1; return 1;
@ -306,7 +298,7 @@ maybe_write_ipa_not_loaded (char *buffer)
static int static int
maybe_write_ipa_ust_not_loaded (char *buffer) maybe_write_ipa_ust_not_loaded (char *buffer)
{ {
if (!in_process_agent_loaded ()) if (!agent_loaded_p ())
{ {
write_e_ipa_not_loaded (buffer); write_e_ipa_not_loaded (buffer);
return 1; return 1;
@ -330,7 +322,7 @@ tracepoint_look_up_symbols (void)
{ {
int i; int i;
if (all_tracepoint_symbols_looked_up) if (agent_loaded_p ())
return; return;
for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++) for (i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
@ -346,10 +338,7 @@ tracepoint_look_up_symbols (void)
} }
} }
if (agent_look_up_symbols () != 0) agent_look_up_symbols ();
return;
all_tracepoint_symbols_looked_up = 1;
} }
#endif #endif
@ -2907,7 +2896,7 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
{ {
struct tracepoint *tp; struct tracepoint *tp;
if (!in_process_agent_loaded ()) if (!agent_loaded_p ())
{ {
trace_debug ("Requested a %s tracepoint, but fast " trace_debug ("Requested a %s tracepoint, but fast "
"tracepoints aren't supported.", "tracepoints aren't supported.",
@ -2983,7 +2972,7 @@ cmd_qtstart (char *packet)
pause_all (1); pause_all (1);
/* Sync the fast tracepoints list in the inferior ftlib. */ /* Sync the fast tracepoints list in the inferior ftlib. */
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
download_tracepoints (); download_tracepoints ();
download_trace_state_variables (); download_trace_state_variables ();
@ -3084,7 +3073,7 @@ cmd_qtstart (char *packet)
/* Tracing is now active, hits will now start being logged. */ /* Tracing is now active, hits will now start being logged. */
tracing = 1; tracing = 1;
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1)) if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1))
fatal ("Error setting tracing variable in lib"); fatal ("Error setting tracing variable in lib");
@ -3143,7 +3132,7 @@ stop_tracing (void)
/* Stop logging. Tracepoints can still be hit, but they will not be /* Stop logging. Tracepoints can still be hit, but they will not be
recorded. */ recorded. */
tracing = 0; tracing = 0;
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0)) if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0))
fatal ("Error clearing tracing variable in lib"); fatal ("Error clearing tracing variable in lib");
@ -3191,7 +3180,7 @@ stop_tracing (void)
/* Clear out the tracepoints. */ /* Clear out the tracepoints. */
clear_installed_tracepoints (); clear_installed_tracepoints ();
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
/* Pull in fast tracepoint trace frames from the inferior lib /* Pull in fast tracepoint trace frames from the inferior lib
buffer into our buffer, even if our buffer is already full, buffer into our buffer, even if our buffer is already full,
@ -3354,7 +3343,7 @@ cmd_qtstatus (char *packet)
trace_debug ("Returning trace status as %d, stop reason %s", trace_debug ("Returning trace status as %d, stop reason %s",
tracing, tracing_stop_reason); tracing, tracing_stop_reason);
if (in_process_agent_loaded ()) if (agent_loaded_p ())
{ {
pause_all (1); pause_all (1);
@ -4022,7 +4011,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
/* Pull in fast tracepoint trace frames from the inferior lib buffer into /* Pull in fast tracepoint trace frames from the inferior lib buffer into
our buffer. */ our buffer. */
if (in_process_agent_loaded ()) if (agent_loaded_p ())
upload_fast_traceframes (); upload_fast_traceframes ();
/* Check if we were indeed collecting data for one of more /* Check if we were indeed collecting data for one of more
@ -4123,7 +4112,7 @@ handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc)
/* Pull in fast tracepoint trace frames from the inferior in-process /* Pull in fast tracepoint trace frames from the inferior in-process
agent's buffer into our buffer. */ agent's buffer into our buffer. */
if (!in_process_agent_loaded ()) if (!agent_loaded_p ())
return 0; return 0;
upload_fast_traceframes (); upload_fast_traceframes ();