aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2012-03-03 09:51:29 +0000
committerYao Qi <yao@codesourcery.com>2012-03-03 09:51:29 +0000
commit5808517f9a2a8588228bd760c9e6a3a231f4f292 (patch)
treeec158109b2b63424bdc368877dd4e0fd74e2847a /gdb
parentdfe2ac14962dac8aaf1484dac1419c0bc88de3a7 (diff)
downloadgdb-5808517f9a2a8588228bd760c9e6a3a231f4f292.zip
gdb-5808517f9a2a8588228bd760c9e6a3a231f4f292.tar.gz
gdb-5808517f9a2a8588228bd760c9e6a3a231f4f292.tar.bz2
gdb:
* common/agent.c (agent_look_up_symbols): Add one parameter 'arg'. * common/agent.h: Update declaration. * inf-child.c (inf_child_use_agent): New. (inf_child_can_use_agent): New. (inf_child_target): Initialize fields `to_use_agent' and `to_can_use_agent'. * agent.c (agent_new_objfile): New. (_initialize_agent): Add agent_new_objfile to new_objfile observer. * linux-nat.c (linux_child_static_tracepoint_markers_by_strid): New. (linux_target_install_ops): Initialize field `to_static_tracepoint_markers_by_strid'. * remote.c (free_current_marker): Move it to ... * tracepoint.c (free_current_marker): ... here. New. (cleanup_target_stop): New. * tracepoint.h: Declare free_current_marker. * NEWS: Add one entry about `info static-tracepoint-marker'. gdb/gdbserver: * tracepoint.c (tracepoint_look_up_symbols): Update call to agent_look_up_symbols. gdb/testsuite: * gdb.trace/strace.exp: run strace_info_marker in linux native gdb.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog22
-rw-r--r--gdb/NEWS3
-rw-r--r--gdb/agent.c14
-rw-r--r--gdb/common/agent.c7
-rw-r--r--gdb/common/agent.h2
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/tracepoint.c2
-rw-r--r--gdb/inf-child.c20
-rw-r--r--gdb/linux-nat.c72
-rw-r--r--gdb/remote.c14
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.trace/strace.exp35
-rw-r--r--gdb/tracepoint.c14
-rw-r--r--gdb/tracepoint.h1
14 files changed, 182 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 26dc2ab..87b7bda 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,27 @@
2012-03-03 Yao Qi <yao@codesourcery.com>
+ * common/agent.c (agent_look_up_symbols): Add one parameter 'arg'.
+ * common/agent.h: Update declaration.
+ * inf-child.c (inf_child_use_agent): New.
+ (inf_child_can_use_agent): New.
+ (inf_child_target): Initialize fields `to_use_agent'
+ and `to_can_use_agent'.
+ * agent.c (agent_new_objfile): New.
+ (_initialize_agent): Add agent_new_objfile to new_objfile
+ observer.
+
+ * linux-nat.c (linux_child_static_tracepoint_markers_by_strid):
+ New.
+ (linux_target_install_ops): Initialize field
+ `to_static_tracepoint_markers_by_strid'.
+ * remote.c (free_current_marker): Move it to ...
+ * tracepoint.c (free_current_marker): ... here. New.
+ (cleanup_target_stop): New.
+ * tracepoint.h: Declare free_current_marker.
+ * NEWS: Add one entry about `info static-tracepoint-marker'.
+
+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.
diff --git a/gdb/NEWS b/gdb/NEWS
index 4b2c819..c9218ad 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -57,6 +57,9 @@
but it had to be done as a second step, after the catchpoint had been
created, using the "condition" command.
+* The "info static-tracepoint-marker" command will now also work on
+ native Linux targets with in-process agent.
+
* New commands
** "catch load" and "catch unload" can be used to stop when a shared
diff --git a/gdb/agent.c b/gdb/agent.c
index b751cfe..a8958d7 100644
--- a/gdb/agent.c
+++ b/gdb/agent.c
@@ -54,9 +54,23 @@ set_can_use_agent (char *args, int from_tty, struct cmd_list_element *c)
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_agent;
+#include "observer.h"
+#include "objfiles.h"
+
+static void
+agent_new_objfile (struct objfile *objfile)
+{
+ if (objfile == NULL || agent_loaded_p ())
+ return;
+
+ agent_look_up_symbols (objfile);
+}
+
void
_initialize_agent (void)
{
+ observer_attach_new_objfile (agent_new_objfile);
+
add_setshow_enum_cmd ("agent", class_run,
can_use_agent_enum,
&can_use_agent, _("\
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
index 70a6de7..5c90822 100644
--- a/gdb/common/agent.c
+++ b/gdb/common/agent.c
@@ -83,7 +83,7 @@ agent_loaded_p (void)
found, return non-zero otherwise. */
int
-agent_look_up_symbols (void)
+agent_look_up_symbols (void *arg)
{
int i;
@@ -97,8 +97,9 @@ agent_look_up_symbols (void)
if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
#else
- struct minimal_symbol *sym = lookup_minimal_symbol (symbol_list[i].name,
- NULL, NULL);
+ struct minimal_symbol *sym =
+ lookup_minimal_symbol (symbol_list[i].name, NULL,
+ (struct objfile *) arg);
if (sym != NULL)
*addrp = SYMBOL_VALUE_ADDRESS (sym);
diff --git a/gdb/common/agent.h b/gdb/common/agent.h
index b89d111..fa8bc36 100644
--- a/gdb/common/agent.h
+++ b/gdb/common/agent.h
@@ -19,7 +19,7 @@
int agent_run_command (int pid, const char *cmd);
-int agent_look_up_symbols (void);
+int agent_look_up_symbols (void *);
#define STRINGIZE_1(STR) #STR
#define STRINGIZE(STR) STRINGIZE_1(STR)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 2443037..db1fa92 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
2012-03-03 Yao Qi <yao@codesourcery.com>
+ * tracepoint.c (tracepoint_look_up_symbols): Update call to
+ agent_look_up_symbols.
+
+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.
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index ac3312f..21e58ff 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -338,7 +338,7 @@ tracepoint_look_up_symbols (void)
}
}
- agent_look_up_symbols ();
+ agent_look_up_symbols (NULL);
}
#endif
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 96c1157..5531102 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -29,6 +29,7 @@
#include "gdb_stat.h"
#include "inf-child.h"
#include "gdb/fileio.h"
+#include "agent.h"
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> /* for MAXPATHLEN */
@@ -332,6 +333,23 @@ inf_child_fileio_readlink (const char *filename, int *target_errno)
#endif
}
+static int
+inf_child_use_agent (int use)
+{
+ if (agent_loaded_p ())
+ {
+ use_agent = use;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+static int
+inf_child_can_use_agent (void)
+{
+ return agent_loaded_p ();
+}
struct target_ops *
inf_child_target (void)
@@ -371,5 +389,7 @@ inf_child_target (void)
t->to_fileio_unlink = inf_child_fileio_unlink;
t->to_fileio_readlink = inf_child_fileio_readlink;
t->to_magic = OPS_MAGIC;
+ t->to_use_agent = inf_child_use_agent;
+ t->to_can_use_agent = inf_child_can_use_agent;
return t;
}
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index dd6b689..553dfdb 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -60,6 +60,8 @@
#include "linux-osdata.h"
#include "linux-tdep.h"
#include "symfile.h"
+#include "agent.h"
+#include "tracepoint.h"
#ifndef SPUFS_MAGIC
#define SPUFS_MAGIC 0x23c9b64e
@@ -4772,6 +4774,73 @@ linux_xfer_partial (struct target_ops *ops, enum target_object object,
offset, len);
}
+static void
+cleanup_target_stop (void *arg)
+{
+ ptid_t *ptid = (ptid_t *) arg;
+
+ gdb_assert (arg != NULL);
+
+ /* Unpause all */
+ target_resume (*ptid, 0, TARGET_SIGNAL_0);
+}
+
+static VEC(static_tracepoint_marker_p) *
+linux_child_static_tracepoint_markers_by_strid (const char *strid)
+{
+ char s[IPA_CMD_BUF_SIZE];
+ struct cleanup *old_chain;
+ int pid = ptid_get_pid (inferior_ptid);
+ VEC(static_tracepoint_marker_p) *markers = NULL;
+ struct static_tracepoint_marker *marker = NULL;
+ char *p = s;
+ ptid_t ptid = ptid_build (pid, 0, 0);
+
+ /* Pause all */
+ target_stop (ptid);
+
+ memcpy (s, "qTfSTM", sizeof ("qTfSTM"));
+ s[sizeof ("qTfSTM")] = 0;
+
+ agent_run_command (pid, s);
+
+ old_chain = make_cleanup (free_current_marker, &marker);
+ make_cleanup (cleanup_target_stop, &ptid);
+
+ while (*p++ == 'm')
+ {
+ if (marker == NULL)
+ marker = XCNEW (struct static_tracepoint_marker);
+
+ do
+ {
+ parse_static_tracepoint_marker_definition (p, &p, marker);
+
+ if (strid == NULL || strcmp (strid, marker->str_id) == 0)
+ {
+ VEC_safe_push (static_tracepoint_marker_p,
+ markers, marker);
+ marker = NULL;
+ }
+ else
+ {
+ release_static_tracepoint_marker (marker);
+ memset (marker, 0, sizeof (*marker));
+ }
+ }
+ while (*p++ == ','); /* comma-separated list */
+
+ memcpy (s, "qTsSTM", sizeof ("qTsSTM"));
+ s[sizeof ("qTsSTM")] = 0;
+ agent_run_command (pid, s);
+ p = s;
+ }
+
+ do_cleanups (old_chain);
+
+ return markers;
+}
+
/* Create a prototype generic GNU/Linux target. The client can override
it with local methods. */
@@ -4793,6 +4862,9 @@ linux_target_install_ops (struct target_ops *t)
super_xfer_partial = t->to_xfer_partial;
t->to_xfer_partial = linux_xfer_partial;
+
+ t->to_static_tracepoint_markers_by_strid
+ = linux_child_static_tracepoint_markers_by_strid;
}
struct target_ops *
diff --git a/gdb/remote.c b/gdb/remote.c
index 8eb975f..61bb2bb 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2850,20 +2850,6 @@ remote_static_tracepoint_marker_at (CORE_ADDR addr,
return 0;
}
-static void
-free_current_marker (void *arg)
-{
- struct static_tracepoint_marker **marker_p = arg;
-
- if (*marker_p != NULL)
- {
- release_static_tracepoint_marker (*marker_p);
- xfree (*marker_p);
- }
- else
- *marker_p = NULL;
-}
-
static VEC(static_tracepoint_marker_p) *
remote_static_tracepoint_markers_by_strid (const char *strid)
{
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 26705ed..f2436d3 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-03 Yao Qi <yao@codesourcery.com>
+
+ * gdb.trace/strace.exp: run strace_info_marker in linux native gdb.
+
2012-03-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Setup KFAIL for PR server/13796.
diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
index 7f4551e..88039ff 100644
--- a/gdb/testsuite/gdb.trace/strace.exp
+++ b/gdb/testsuite/gdb.trace/strace.exp
@@ -38,20 +38,6 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags
return -1
}
-clean_restart $executable
-
-if ![runto_main] {
- fail "Can't run to main to check for trace support"
- return -1
-}
-
-if { ![gdb_target_supports_trace] } then {
- unsupported "Current target does not support trace"
- return -1;
-}
-
-gdb_load_shlibs $libipa
-
proc strace_info_marker { } { with_test_prefix "info_marker" {
global executable
global gdb_prompt
@@ -248,6 +234,27 @@ proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" {
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
}}
+clean_restart $executable
+
+if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+}
+
+# Run it on native x86/x86_64 linux.
+if { ![is_remote target]
+ && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } {
+ strace_info_marker
+ return
+}
+
+if { ![gdb_target_supports_trace] } then {
+ unsupported "Current target does not support trace"
+ return -1;
+}
+
+gdb_load_shlibs $libipa
+
strace_info_marker
strace_probe_marker
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index a519ed3..89f75b6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4701,6 +4701,20 @@ init_tfile_ops (void)
tfile_ops.to_magic = OPS_MAGIC;
}
+void
+free_current_marker (void *arg)
+{
+ struct static_tracepoint_marker **marker_p = arg;
+
+ if (*marker_p != NULL)
+ {
+ release_static_tracepoint_marker (*marker_p);
+ xfree (*marker_p);
+ }
+ else
+ *marker_p = NULL;
+}
+
/* Given a line of text defining a static tracepoint marker, parse it
into a "static tracepoint marker" object. Throws an error is
parsing fails. If PP is non-null, it points to one past the end of
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 4003c66..ced29fa 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -209,6 +209,7 @@ extern void parse_static_tracepoint_marker_definition
(char *line, char **pp,
struct static_tracepoint_marker *marker);
extern void release_static_tracepoint_marker (struct static_tracepoint_marker *);
+extern void free_current_marker (void *arg);
/* A hook used to notify the UI of tracepoint operations. */