* [patch 1/5] Call update_global_location_list conditionally in install_breakpoint
2011-11-15 7:01 [patch 0/5] pending tracepoint Yao Qi
@ 2011-11-15 7:30 ` Yao Qi
2011-11-16 19:04 ` Pedro Alves
2011-11-15 7:43 ` [patch 2/5] allow pending tracepoint Yao Qi
` (3 subsequent siblings)
4 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-15 7:30 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 888 bytes --]
During `pending tracepoint' work, we find install_breakpoint calls
update_global_location_list(1), which may throw error, and we have (at
the end of create_break() ):
/* That's it. Discard the cleanups for data inserted into the
breakpoint. */
discard_cleanups (bkpt_chain);
/* But cleanup everything else. */
do_cleanups (old_chain);
/* error call may happen here - have BKPT_CHAIN already discarded. */
update_global_location_list (1);
return 1;
So, we should make sure that install_breakpoint called in
create_breakpoint doesn't call update_global_location_list(1), so that
update_global_location_list can be deferred to call at the end of
create_breakpoint.
In this patch, we add a new parameter to determine to call
update_global_location_list. We pass 0 to install_breakpoint when it is
used in create_breakpoint and its callee.
--
Yao (é½å°§)
[-- Attachment #2: 0001-refactor-add-one-more-param-in-install_breakpoint.patch --]
[-- Type: text/x-patch, Size: 4054 bytes --]
* ada-lang.c (create_ada_exception_catchpoint):
* breakpoint.c (install_breakpoint): Add one more parameter so that
update_global_location_list is called conditionally.
(create_fork_vfork_event_catchpoint): Update.
(create_syscall_event_catchpoint): Update.
(create_breakpoint_sal): Update.
(create_breakpoint_sal): Update. Call do_cleanups before
install_breakpoint.
* breakpoint.h (install_breakpoint): Update declaration.
---
gdb/ada-lang.c | 2 +-
gdb/breakpoint.c | 18 ++++++++++--------
gdb/breakpoint.h | 6 ++++--
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1dabd0f..2edbe7f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11705,7 +11705,7 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch,
ops, tempflag, from_tty);
c->excep_string = excep_string;
create_excep_cond_exprs (c);
- install_breakpoint (0, &c->base);
+ install_breakpoint (0, &c->base, 1);
}
/* Implement the "catch exception" command. */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8f09296..2554337 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6680,14 +6680,16 @@ init_catchpoint (struct breakpoint *b,
}
void
-install_breakpoint (int internal, struct breakpoint *b)
+install_breakpoint (int internal, struct breakpoint *b, int update_gll)
{
add_to_breakpoint_chain (b);
set_breakpoint_number (internal, b);
if (!internal)
mention (b);
observer_notify_breakpoint_created (b);
- update_global_location_list (1);
+
+ if (update_gll)
+ update_global_location_list (1);
}
static void
@@ -6701,7 +6703,7 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
c->forked_inferior_pid = null_ptid;
- install_breakpoint (0, &c->base);
+ install_breakpoint (0, &c->base, 1);
}
/* Exec catchpoints. */
@@ -6822,7 +6824,7 @@ create_syscall_event_catchpoint (int tempflag, VEC(int) *filter,
init_catchpoint (&c->base, gdbarch, tempflag, NULL, ops);
c->syscalls_to_be_caught = filter;
- install_breakpoint (0, &c->base);
+ install_breakpoint (0, &c->base, 1);
}
static int
@@ -7331,7 +7333,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
enabled, internal, display_canonical);
discard_cleanups (old_chain);
- install_breakpoint (internal, b);
+ install_breakpoint (internal, b, 0);
}
/* Remove element at INDEX_TO_REMOVE from SAL, shifting other
@@ -7961,7 +7963,7 @@ create_breakpoint (struct gdbarch *gdbarch,
corresponds to this one */
tp->static_trace_marker_id_idx = i;
- install_breakpoint (internal, &tp->base);
+ install_breakpoint (internal, &tp->base, 0);
do_cleanups (old_chain);
}
@@ -9397,7 +9399,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty,
throw_exception (e);
}
- install_breakpoint (internal, b);
+ install_breakpoint (internal, b, 1);
}
/* Return count of debug registers needed to watch the given expression.
@@ -9795,7 +9797,7 @@ catch_exec_command_1 (char *arg, int from_tty,
&catch_exec_breakpoint_ops);
c->exec_pathname = NULL;
- install_breakpoint (0, &c->base);
+ install_breakpoint (0, &c->base, 1);
}
static enum print_stop_action
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 506ae80..8e03264 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1098,9 +1098,11 @@ extern void
/* Add breakpoint B on the breakpoint list, and notify the user, the
target and breakpoint_created observers of its existence. If
INTERNAL is non-zero, the breakpoint number will be allocated from
- the internal breakpoint count. */
+ the internal breakpoint count. If UPDATE_GLL is non-zero,
+ update_global_location_list will be called. */
-extern void install_breakpoint (int internal, struct breakpoint *b);
+extern void install_breakpoint (int internal, struct breakpoint *b,
+ int update_gll);
extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
char *cond_string, int thread,
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 1/5] Call update_global_location_list conditionally in install_breakpoint
2011-11-15 7:30 ` [patch 1/5] Call update_global_location_list conditionally in install_breakpoint Yao Qi
@ 2011-11-16 19:04 ` Pedro Alves
0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2011-11-16 19:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi
On Tuesday 15 November 2011 07:29:52, Yao Qi wrote:
> During `pending tracepoint' work, we find install_breakpoint calls
> update_global_location_list(1), which may throw error, and we have (at
> the end of create_break() ):
>
> /* That's it. Discard the cleanups for data inserted into the
> breakpoint. */
> discard_cleanups (bkpt_chain);
> /* But cleanup everything else. */
> do_cleanups (old_chain);
>
> /* error call may happen here - have BKPT_CHAIN already discarded. */
> update_global_location_list (1);
>
> return 1;
>
> So, we should make sure that install_breakpoint called in
> create_breakpoint doesn't call update_global_location_list(1), so that
> update_global_location_list can be deferred to call at the end of
> create_breakpoint.
>
> In this patch, we add a new parameter to determine to call
> update_global_location_list. We pass 0 to install_breakpoint when it is
> used in create_breakpoint and its callee.
Okay.
> * ada-lang.c (create_ada_exception_catchpoint):
> * breakpoint.c (install_breakpoint): Add one more parameter so that
> update_global_location_list is called conditionally.
> (create_fork_vfork_event_catchpoint): Update.
> (create_syscall_event_catchpoint): Update.
> (create_breakpoint_sal): Update.
> (create_breakpoint_sal): Update. Call do_cleanups before
> install_breakpoint.
> * breakpoint.h (install_breakpoint): Update declaration.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread
* [patch 2/5] allow pending tracepoint
2011-11-15 7:01 [patch 0/5] pending tracepoint Yao Qi
2011-11-15 7:30 ` [patch 1/5] Call update_global_location_list conditionally in install_breakpoint Yao Qi
@ 2011-11-15 7:43 ` Yao Qi
2011-11-16 19:04 ` Pedro Alves
2011-11-15 7:47 ` [patch 3/5] Print a message on gdb disconnected Yao Qi
` (2 subsequent siblings)
4 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-15 7:43 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
Existing breakpoint infrastructure in gdb makes easier to do pending
tracepoint. We just create right type (tracepoint) for pending state.
Note that we don't check/validate SALs for pending fast tracepoint,
because inferior may not be ready to access at that moment.
--
Yao (é½å°§)
[-- Attachment #2: 0002-allow-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 2746 bytes --]
gdb/
* breakpoint.c (create_breakpoint): Produce query message according to
breakpoint's type.
Allocate tracepoint per correct type.
Don't check SALs for pending fast tracepoints.
---
gdb/breakpoint.c | 30 +++++++++++++++++-------------
1 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2554337..38639be 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7836,8 +7836,8 @@ create_breakpoint (struct gdbarch *gdbarch,
/* If pending breakpoint support is auto query and the user
selects no, then simply return the error code. */
if (pending_break_support == AUTO_BOOLEAN_AUTO
- && !nquery (_("Make breakpoint pending on "
- "future shared library load? ")))
+ && !nquery (_("Make %s pending on future shared library load? "),
+ bptype_string (type_wanted)))
return 0;
/* At this point, either the user was queried about setting
@@ -7894,7 +7894,7 @@ create_breakpoint (struct gdbarch *gdbarch,
breakpoint_sals_to_pc (&sals);
/* Fast tracepoints may have additional restrictions on location. */
- if (type_wanted == bp_fast_tracepoint)
+ if (!pending && type_wanted == bp_fast_tracepoint)
check_fast_tracepoint_sals (gdbarch, &sals);
/* Verify that condition can be parsed, before setting any
@@ -7977,13 +7977,22 @@ create_breakpoint (struct gdbarch *gdbarch,
}
else
{
- struct breakpoint *b;
+ struct breakpoint *b = NULL;
make_cleanup (xfree, copy_arg);
- b = set_raw_breakpoint_without_location (gdbarch, type_wanted, ops);
- set_breakpoint_number (internal, b);
- b->thread = -1;
+ if (is_tracepoint_type (type_wanted))
+ {
+ struct tracepoint *t;
+
+ t = XCNEW (struct tracepoint);
+ b = &t->base;
+ }
+ else
+ b = XNEW (struct breakpoint);
+
+ init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops);
+
b->addr_string = canonical.canonical[0];
b->cond_string = NULL;
b->ignore_count = ignore_count;
@@ -7991,18 +8000,13 @@ create_breakpoint (struct gdbarch *gdbarch,
b->condition_not_parsed = 1;
b->enable_state = enabled ? bp_enabled : bp_disabled;
b->pspace = current_program_space;
- b->py_bp_object = NULL;
if (enabled && b->pspace->executing_startup
&& (b->type == bp_breakpoint
|| b->type == bp_hardware_breakpoint))
b->enable_state = bp_startup_disabled;
- if (!internal)
- /* Do not mention breakpoints with a negative number,
- but do notify observers. */
- mention (b);
- observer_notify_breakpoint_created (b);
+ install_breakpoint (internal, b, 0);
}
if (sals.nelts > 1)
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 2/5] allow pending tracepoint
2011-11-15 7:43 ` [patch 2/5] allow pending tracepoint Yao Qi
@ 2011-11-16 19:04 ` Pedro Alves
2011-11-17 1:12 ` Yao Qi
0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-16 19:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi
On Tuesday 15 November 2011 07:43:27, Yao Qi wrote:
> Existing breakpoint infrastructure in gdb makes easier to do pending
> tracepoint. We just create right type (tracepoint) for pending state.
> Note that we don't check/validate SALs for pending fast trace point,
> because inferior may not be ready to access at that moment.
Hmm, confusing comment. You don't validate the SALs for pending
tracepoints because a pending tracepoint has only one dummy sal,
and it makes no sense to validate a dummy sal.
> - struct breakpoint *b;
> + struct breakpoint *b = NULL;
Unnecessary initialization.
Okay.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [patch 2/5] allow pending tracepoint
2011-11-16 19:04 ` Pedro Alves
@ 2011-11-17 1:12 ` Yao Qi
0 siblings, 0 replies; 32+ messages in thread
From: Yao Qi @ 2011-11-17 1:12 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 11/17/2011 03:03 AM, Pedro Alves wrote:
>> > Note that we don't check/validate SALs for pending fast trace point,
>> > because inferior may not be ready to access at that moment.
> Hmm, confusing comment. You don't validate the SALs for pending
> tracepoints because a pending tracepoint has only one dummy sal,
> and it makes no sense to validate a dummy sal.
>
Yes, the sal->pc is 0x0, and we'll get this error from GDB:
"Cannot access memory at address 0x0"
You are right, and my description is confusing/misleading.
>> > - struct breakpoint *b;
>> > + struct breakpoint *b = NULL;
> Unnecessary initialization.
Removed.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 32+ messages in thread
* [patch 3/5] Print a message on gdb disconnected.
2011-11-15 7:01 [patch 0/5] pending tracepoint Yao Qi
2011-11-15 7:30 ` [patch 1/5] Call update_global_location_list conditionally in install_breakpoint Yao Qi
2011-11-15 7:43 ` [patch 2/5] allow pending tracepoint Yao Qi
@ 2011-11-15 7:47 ` Yao Qi
2011-11-15 15:32 ` Tom Tromey
2011-11-16 19:04 ` Pedro Alves
2011-11-15 8:03 ` [patch 4/5] Test cases Yao Qi
2011-11-15 8:08 ` [patch 5/5] Document Yao Qi
4 siblings, 2 replies; 32+ messages in thread
From: Yao Qi @ 2011-11-15 7:47 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
This patch is to print a warning when gdb disconnects from remote stub,
while there are still pending tracepoints, because pending tracepoints
can't be resolved without gdb.
--
Yao (é½å°§)
[-- Attachment #2: 0003-pending-tracepoint-on-disconnect.patch --]
[-- Type: text/x-patch, Size: 1508 bytes --]
gdb/
* tracepoint.c (process_tracepoint_on_disconnect): New.
(disconnect_tracing): Call process_tracepoint_on_disconnect.
---
gdb/tracepoint.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e155515..c0b5231 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1642,6 +1642,32 @@ add_aexpr (struct collection_list *collect, struct agent_expr *aexpr)
collect->next_aexpr_elt++;
}
+static void
+process_tracepoint_on_disconnect (void)
+{
+ VEC(breakpoint_p) *tp_vec = NULL;
+ int ix;
+ struct breakpoint *b;
+ int has_pending_p = 0;
+
+ /* Check whether we still have pending tracepoint. If we have, warn the
+ user that pending tracepoint will no longer work. */
+ tp_vec = all_tracepoints ();
+ for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+ {
+ if (b->loc == NULL || b->loc->shlib_disabled)
+ {
+ has_pending_p = 1;
+ break;
+ }
+ }
+ VEC_free (breakpoint_p, tp_vec);
+
+ if (has_pending_p)
+ warning (_("Pending tracepoint will not be resolved while"
+ " GBD is disconnected\n"));
+}
+
void
start_tracing (void)
@@ -2020,6 +2046,8 @@ disconnect_tracing (int from_tty)
disconnected-tracing. */
if (current_trace_status ()->running && from_tty)
{
+ process_tracepoint_on_disconnect ();
+
if (current_trace_status ()->disconnected_tracing)
{
if (!query (_("Trace is running and will "
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 3/5] Print a message on gdb disconnected.
2011-11-15 7:47 ` [patch 3/5] Print a message on gdb disconnected Yao Qi
@ 2011-11-15 15:32 ` Tom Tromey
2011-11-16 3:17 ` Yao Qi
2011-11-16 19:04 ` Pedro Alves
1 sibling, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2011-11-15 15:32 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
Yao> + " GBD is disconnected\n"));
Typo, should be "GDB".
Tom
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [patch 3/5] Print a message on gdb disconnected.
2011-11-15 7:47 ` [patch 3/5] Print a message on gdb disconnected Yao Qi
2011-11-15 15:32 ` Tom Tromey
@ 2011-11-16 19:04 ` Pedro Alves
2011-11-17 3:32 ` Yao Qi
1 sibling, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-16 19:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi
On Tuesday 15 November 2011 07:46:52, Yao Qi wrote:
> +static void
> +process_tracepoint_on_disconnect (void)
> +{
> + VEC(breakpoint_p) *tp_vec = NULL;
> + int ix;
> + struct breakpoint *b;
> + int has_pending_p = 0;
> +
> + /* Check whether we still have pending tracepoint. If we have, warn the
> + user that pending tracepoint will no longer work. */
> + tp_vec = all_tracepoints ();
> + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
> + {
> + if (b->loc == NULL || b->loc->shlib_disabled)
It's not garanteed that the first location is the one that
is shlib_disabled. If you want the warning for the shlib_disabled
cases, you'll need to iterate over the breakpoint's locations.
> + {
> + has_pending_p = 1;
> + break;
> + }
> + }
> + VEC_free (breakpoint_p, tp_vec);
> +
> + if (has_pending_p)
> + warning (_("Pending tracepoint will not be resolved while"
> + " GBD is disconnected\n"));
Plural, "Pending tracepoints".
Otherwise okay.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 3/5] Print a message on gdb disconnected.
2011-11-16 19:04 ` Pedro Alves
@ 2011-11-17 3:32 ` Yao Qi
2011-11-17 11:08 ` Pedro Alves
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-17 3:32 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]
On 11/17/2011 03:04 AM, Pedro Alves wrote:
>> > + /* Check whether we still have pending tracepoint. If we have, warn the
>> > + user that pending tracepoint will no longer work. */
>> > + tp_vec = all_tracepoints ();
>> > + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
>> > + {
>> > + if (b->loc == NULL || b->loc->shlib_disabled)
> It's not garanteed that the first location is the one that
> is shlib_disabled. If you want the warning for the shlib_disabled
> cases, you'll need to iterate over the breakpoint's locations.
>
Yes. I am still unable to keep it in mind that there may be multiple
locations for one breakpoint :)
>> > + {
>> > + has_pending_p = 1;
>> > + break;
>> > + }
>> > + }
>> > + VEC_free (breakpoint_p, tp_vec);
>> > +
>> > + if (has_pending_p)
>> > + warning (_("Pending tracepoint will not be resolved while"
>> > + " GBD is disconnected\n"));
> Plural, "Pending tracepoints".
Fixed.
--
Yao (é½å°§)
[-- Attachment #2: 0003-pending-tracepoint-on-disconnect.patch --]
[-- Type: text/x-patch, Size: 1734 bytes --]
gdb/
* tracepoint.c (process_tracepoint_on_disconnect): New.
(disconnect_tracing): Call process_tracepoint_on_disconnect.
---
gdb/tracepoint.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e155515..97ab633 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1642,6 +1642,48 @@ add_aexpr (struct collection_list *collect, struct agent_expr *aexpr)
collect->next_aexpr_elt++;
}
+static void
+process_tracepoint_on_disconnect (void)
+{
+ VEC(breakpoint_p) *tp_vec = NULL;
+ int ix;
+ struct breakpoint *b;
+ int has_pending_p = 0;
+
+ /* Check whether we still have pending tracepoint. If we have, warn the
+ user that pending tracepoint will no longer work. */
+ tp_vec = all_tracepoints ();
+ for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
+ {
+ if (b->loc == NULL)
+ {
+ has_pending_p = 1;
+ break;
+ }
+ else
+ {
+ struct bp_location *loc1;
+
+ for (loc1 = b->loc; loc1; loc1 = loc1->next)
+ {
+ if (loc1->shlib_disabled)
+ {
+ has_pending_p = 1;
+ break;
+ }
+ }
+
+ if (has_pending_p)
+ break;
+ }
+ }
+ VEC_free (breakpoint_p, tp_vec);
+
+ if (has_pending_p)
+ warning (_("Pending tracepoints will not be resolved while"
+ " GDB is disconnected\n"));
+}
+
void
start_tracing (void)
@@ -2020,6 +2062,8 @@ disconnect_tracing (int from_tty)
disconnected-tracing. */
if (current_trace_status ()->running && from_tty)
{
+ process_tracepoint_on_disconnect ();
+
if (current_trace_status ()->disconnected_tracing)
{
if (!query (_("Trace is running and will "
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 3/5] Print a message on gdb disconnected.
2011-11-17 3:32 ` Yao Qi
@ 2011-11-17 11:08 ` Pedro Alves
0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2011-11-17 11:08 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On Thursday 17 November 2011 03:32:31, Yao Qi wrote:
> + /* Check whether we still have pending tracepoint. If we have, warn the
Check whether we still have any pending tracepoint. If we have, warn the
> + user that pending tracepoint will no longer work. */
user that pending tracepoints will no longer work. */
or "will not resolve while GDB is disconnected."
> gdb/
> * tracepoint.c (process_tracepoint_on_disconnect): New.
> (disconnect_tracing): Call process_tracepoint_on_disconnect.
Okay.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread
* [patch 4/5] Test cases
2011-11-15 7:01 [patch 0/5] pending tracepoint Yao Qi
` (2 preceding siblings ...)
2011-11-15 7:47 ` [patch 3/5] Print a message on gdb disconnected Yao Qi
@ 2011-11-15 8:03 ` Yao Qi
2011-11-16 19:05 ` Pedro Alves
2011-11-15 8:08 ` [patch 5/5] Document Yao Qi
4 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-15 8:03 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 77 bytes --]
This is about the test cases for pending tracepoint.
--
Yao (é½å°§)
[-- Attachment #2: 0004-testcase-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 27025 bytes --]
gdb/testsuite/
* gdb.trace/pending.exp: New.
* gdb.trace/pending.c: New.
* gdb.trace/pendshr1.c: New.
* gdb.trace/pendshr2.c: New.
* gdb.trace/change-loc.exp (tracepoint_change_loc_1): Handle kfail more
wisely.
Check one tracepoint location becomes pending.
(tracepoint_change_loc_2): New.
---
gdb/testsuite/gdb.trace/change-loc.exp | 129 ++++++++-
gdb/testsuite/gdb.trace/pending.c | 50 +++
gdb/testsuite/gdb.trace/pending.exp | 514 ++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.trace/pendshr1.c | 43 +++
gdb/testsuite/gdb.trace/pendshr2.c | 40 +++
5 files changed, 771 insertions(+), 5 deletions(-)
create mode 100644 gdb/testsuite/gdb.trace/pending.c
create mode 100644 gdb/testsuite/gdb.trace/pending.exp
create mode 100644 gdb/testsuite/gdb.trace/pendshr1.c
create mode 100644 gdb/testsuite/gdb.trace/pendshr2.c
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index e125024..d01f71c 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -118,27 +118,145 @@ proc tracepoint_change_loc_1 { trace_type } {
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
"tracepoint with two locations"
- setup_kfail "gdb/13392" x86_64-*-*
- gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
- "continue to marker 2"
-
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
# tracepoint has three locations after shlib change-loc-2 is loaded.
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
"tracepoint with three locations"
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
gdb_test_no_output "tstop"
- setup_kfail "gdb/13392" x86_64-*-*
gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0"
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
set pf_prefix $old_pf_prefix
}
+# Set pending tracepoint.
+
+proc tracepoint_change_loc_2 { trace_type } {
+ global srcdir
+ global srcfile
+ global subdir
+ global pcreg
+ global binfile
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ set pf_prefix "$pf_prefix 2 $trace_type:"
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
+ -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_trace_setactions "set action for tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ # tracepoint has no location information now.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+ # tracepoint has one location after executable is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
+ "tracepoint with one location"
+
+ set main_bp 0
+ gdb_test_multiple "break main" "set breakpoint on main" {
+ -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
+ set main_bp $expect_out(1,string)
+ }
+ }
+ gdb_run_cmd
+
+ gdb_test "" \
+ ".*Breakpoint.*main.*at.*$srcfile.*" \
+ "run to main"
+ gdb_test_no_output "delete break $main_bp"
+
+ # tracepoint has two locations after shlib change-loc-1 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \
+ "tracepoint with two locations"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ # tracepoint with two locations will be downloaded and installed.
+ gdb_test_no_output "tstart"
+
+ gdb_test_multiple "continue" "continue to marker 1" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 1"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 1"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 2"
+
+ # tracepoint has three locations after shlib change-loc-2 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \
+ "tracepoint with three locations"
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
+ gdb_test_no_output "tstop"
+
+ gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame\\..*"
+
+ set pf_prefix $old_pf_prefix
+}
tracepoint_change_loc_1 "trace"
+tracepoint_change_loc_2 "trace"
# Re-compile test case with IPA.
set libipa $objdir/../gdbserver/libinproctrace.so
@@ -151,3 +269,4 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
}
tracepoint_change_loc_1 "ftrace"
+tracepoint_change_loc_2 "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pending.c b/gdb/testsuite/gdb.trace/pending.c
new file mode 100644
index 0000000..08c751b
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.c
@@ -0,0 +1,50 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+extern void pendfunc (int x);
+
+static void
+marker () {}
+
+int main()
+{
+ const char *libname = "pendshr2.sl";
+ void *h;
+ int (*p_func) (int);
+
+ pendfunc (3);
+ pendfunc (4);
+ pendfunc (3);
+
+ marker ();
+
+ h = dlopen (libname, RTLD_LAZY);
+ if (h == NULL) return 1;
+
+ p_func = dlsym (h, "pendfunc2");
+ if (p_func == NULL) return 2;
+
+ (*p_func) (4);
+
+ marker ();
+
+ dlclose (h);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
new file mode 100644
index 0000000..e472bb4
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -0,0 +1,514 @@
+# Copyright 2011 Free Software Foundation, Inc.
+# 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/>.
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+set testfile "pending"
+set libfile1 "pendshr1"
+set libfile2 "pendshr2"
+set executable $testfile
+set srcfile $testfile.c
+set libsrc1 $srcdir/$subdir/$libfile1.c
+set libsrc2 $srcdir/$subdir/$libfile2.c
+set binfile $objdir/$subdir/$testfile
+set lib_sl1 $objdir/$subdir/$libfile1.sl
+set lib_sl2 $objdir/$subdir/$libfile2.sl
+
+set lib_opts [gdb_target_symbol_prefix_flags]
+
+if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
+ || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
+ untested "Could not compile either $libsrc1 or $libsrc2"
+ return -1
+}
+
+set exec_opts [list debug shlib=$lib_sl1 shlib_load]
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+clean_restart $executable
+
+gdb_load_shlibs $lib_sl1
+gdb_load_shlibs $lib_sl2
+
+if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+}
+
+if ![gdb_target_supports_trace] {
+ unsupported "Current target does not support trace"
+ return -1;
+}
+
+# Verify pending tracepoint is resolved to running to main.
+
+proc pending_tracepoint_resolved { trace_type } {
+ global srcdir
+ global subdir
+ global binfile
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved:"
+
+ # Start with a fresh gdb.
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc.*" \
+ "single tracepoint info"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and works as expected.
+
+proc pending_tracepoint_works { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "works:"
+
+ # Restart with a fresh gdb.
+ clean_restart $executable
+
+ # Test setting and querying pending tracepoints
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test_multiple "continue" "continue to marker" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind test frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind test frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved during trace.
+
+proc pending_tracepoint_resolved_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global gdb_prompt
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and installed during trace.
+
+proc pending_tracepoint_installed_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+ global hex
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "installed_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ return -1
+ }
+
+ gdb_test "next" ".*"
+ gdb_test "trace main" "Tracepoint \[0-9\] at .*" "set tracepoint on main"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*${srcfile}.*" \
+ "continue to marker 1"
+
+ # Set a pending tracepoint during a tracing experiment.
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \t\]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 $hex in pendfunc2 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify pending tracepoint will no longer work if we disconnect during tracing.
+
+proc pending_tracepoint_disconnect_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ return -1
+ }
+
+ gdb_test_multiple "trace pendfunc3" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*pendfunc3.*pending." \
+ "set pending tracepoint on pendfun3"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker"
+
+ send_gdb "disconnect\n"
+ gdb_expect {
+ -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*Ending remote debugging.*$gdb_prompt $" {
+ pass "disconnect with pending tracepoint"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "disconnect with pending tracepoint"
+ }
+ }
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify disconnect after pending tracepoint has been resolved.
+
+proc pending_tracepoint_disconnect_after_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ return -1
+ }
+
+ gdb_test_multiple "trace set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint on pendfun2"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 2"
+
+ # There should be no pending tracepoint, so no warning should be emitted.
+ send_gdb "disconnect\n"
+ gdb_expect {
+ -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*$gdb_prompt $" {
+ fail "disconnect with resolved tracepoint"
+ }
+ -re "Ending remote debugging\\..*$gdb_prompt $" {
+ pass "disconnect with resolved tracepoint"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "disconnect with resolved tracepoint"
+ }
+ }
+
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify action works properly in resolved tracepoint.
+
+proc pending_tracepoint_with_action_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "action_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ set pcreg "pc"
+ if [is_amd64_regs_target] {
+ set pcreg "rip"
+ } elseif [is_x86_like_target] {
+ set pcreg "eip"
+ }
+
+ gdb_trace_setactions "set action for pending tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tdump" "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+pending_tracepoint_resolved "trace"
+
+pending_tracepoint_works "trace"
+
+pending_tracepoint_resolved_during_trace "trace"
+
+pending_tracepoint_disconnect_during_trace "trace"
+
+pending_tracepoint_disconnect_after_resolved "trace"
+
+pending_tracepoint_with_action_resolved "trace"
+
+pending_tracepoint_installed_during_trace "trace"
+
+# Re-compile test case with IPA.
+set libipa $objdir/../gdbserver/libinproctrace.so
+gdb_load_shlibs $libipa
+
+lappend exec_opts "shlib=$libipa"
+
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+pending_tracepoint_resolved "ftrace"
+pending_tracepoint_works "ftrace"
+pending_tracepoint_resolved_during_trace "ftrace"
+pending_tracepoint_disconnect_during_trace "ftrace"
+pending_tracepoint_disconnect_after_resolved "ftrace"
+pending_tracepoint_with_action_resolved "ftrace"
+pending_tracepoint_installed_during_trace "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pendshr1.c b/gdb/testsuite/gdb.trace/pendshr1.c
new file mode 100644
index 0000000..f2826c6
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr1.c
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+pendfunc1 (void)
+{
+ int x = 0;
+ int y = x + 4;
+}
+
+void
+pendfunc (int x)
+{
+ /* `set_point1' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point1) "\n"
+ SYMBOL(set_point1) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(pendfunc1) "\n"
+#endif
+ );
+}
diff --git a/gdb/testsuite/gdb.trace/pendshr2.c b/gdb/testsuite/gdb.trace/pendshr2.c
new file mode 100644
index 0000000..46eedee
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr2.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+foo ()
+{}
+
+void
+pendfunc2 (int x)
+{
+ /* `set_point2' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point2) "\n"
+ SYMBOL(set_point2) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(foo) "\n"
+#endif
+ );
+}
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 4/5] Test cases
2011-11-15 8:03 ` [patch 4/5] Test cases Yao Qi
@ 2011-11-16 19:05 ` Pedro Alves
2011-11-17 3:27 ` Yao Qi
0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-16 19:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi
On Tuesday 15 November 2011 08:03:27, Yao Qi wrote:
> + if ![runto_main] {
> + fail "Can't run to main"
> + return -1
> + }
Should restore pf_prefix. More instances of this.
> + send_gdb "disconnect\n"
> + gdb_expect {
> + -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*Ending remote debugging.*$gdb_prompt $" {
> + pass "disconnect with pending tracepoint"
> + }
> + -re ".*$gdb_prompt $" {
> + fail "disconnect with pending tracepoint"
> + }
> + }
Why send_gdb/gdb_expect?
Otherwise looks okay.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 4/5] Test cases
2011-11-16 19:05 ` Pedro Alves
@ 2011-11-17 3:27 ` Yao Qi
2011-11-17 12:08 ` Pedro Alves
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-17 3:27 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 848 bytes --]
On 11/17/2011 03:04 AM, Pedro Alves wrote:
>> > + if ![runto_main] {
>> > + fail "Can't run to main"
>> > + return -1
>> > + }
> Should restore pf_prefix. More instances of this.
>
Oh, yes, it should be restored on return.
>> > + send_gdb "disconnect\n"
>> > + gdb_expect {
>> > + -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*Ending remote debugging.*$gdb_prompt $" {
>> > + pass "disconnect with pending tracepoint"
>> > + }
>> > + -re ".*$gdb_prompt $" {
>> > + fail "disconnect with pending tracepoint"
>> > + }
>> > + }
> Why send_gdb/gdb_expect?
Because gdb_test_multiple doesn't match pattern in output when "Ending
remote debugging" appeared in the output. We have to resort to
send_gdb/gdb_expect here.
--
Yao (é½å°§)
[-- Attachment #2: 0004-testcase-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 27226 bytes --]
gdb/testsuite/
* gdb.trace/pending.exp: New.
* gdb.trace/pending.c: New.
* gdb.trace/pendshr1.c: New.
* gdb.trace/pendshr2.c: New.
* gdb.trace/change-loc.exp (tracepoint_change_loc_1): Check one
tracepoint location becomes pending.
(tracepoint_change_loc_2): New.
---
gdb/testsuite/gdb.trace/change-loc.exp | 129 ++++++++-
gdb/testsuite/gdb.trace/pending.c | 50 +++
gdb/testsuite/gdb.trace/pending.exp | 518 ++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.trace/pendshr1.c | 43 +++
gdb/testsuite/gdb.trace/pendshr2.c | 40 +++
5 files changed, 775 insertions(+), 5 deletions(-)
create mode 100644 gdb/testsuite/gdb.trace/pending.c
create mode 100644 gdb/testsuite/gdb.trace/pending.exp
create mode 100644 gdb/testsuite/gdb.trace/pendshr1.c
create mode 100644 gdb/testsuite/gdb.trace/pendshr2.c
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index e125024..d01f71c 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -118,27 +118,145 @@ proc tracepoint_change_loc_1 { trace_type } {
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
"tracepoint with two locations"
- setup_kfail "gdb/13392" x86_64-*-*
- gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
- "continue to marker 2"
-
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
# tracepoint has three locations after shlib change-loc-2 is loaded.
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
"tracepoint with three locations"
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
gdb_test_no_output "tstop"
- setup_kfail "gdb/13392" x86_64-*-*
gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0"
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
set pf_prefix $old_pf_prefix
}
+# Set pending tracepoint.
+
+proc tracepoint_change_loc_2 { trace_type } {
+ global srcdir
+ global srcfile
+ global subdir
+ global pcreg
+ global binfile
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ set pf_prefix "$pf_prefix 2 $trace_type:"
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
+ -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_trace_setactions "set action for tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ # tracepoint has no location information now.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+ # tracepoint has one location after executable is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
+ "tracepoint with one location"
+
+ set main_bp 0
+ gdb_test_multiple "break main" "set breakpoint on main" {
+ -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
+ set main_bp $expect_out(1,string)
+ }
+ }
+ gdb_run_cmd
+
+ gdb_test "" \
+ ".*Breakpoint.*main.*at.*$srcfile.*" \
+ "run to main"
+ gdb_test_no_output "delete break $main_bp"
+
+ # tracepoint has two locations after shlib change-loc-1 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \
+ "tracepoint with two locations"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ # tracepoint with two locations will be downloaded and installed.
+ gdb_test_no_output "tstart"
+
+ gdb_test_multiple "continue" "continue to marker 1" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 1"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 1"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 2"
+
+ # tracepoint has three locations after shlib change-loc-2 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \
+ "tracepoint with three locations"
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
+ gdb_test_no_output "tstop"
+
+ gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame\\..*"
+
+ set pf_prefix $old_pf_prefix
+}
tracepoint_change_loc_1 "trace"
+tracepoint_change_loc_2 "trace"
# Re-compile test case with IPA.
set libipa $objdir/../gdbserver/libinproctrace.so
@@ -151,3 +269,4 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
}
tracepoint_change_loc_1 "ftrace"
+tracepoint_change_loc_2 "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pending.c b/gdb/testsuite/gdb.trace/pending.c
new file mode 100644
index 0000000..08c751b
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.c
@@ -0,0 +1,50 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+extern void pendfunc (int x);
+
+static void
+marker () {}
+
+int main()
+{
+ const char *libname = "pendshr2.sl";
+ void *h;
+ int (*p_func) (int);
+
+ pendfunc (3);
+ pendfunc (4);
+ pendfunc (3);
+
+ marker ();
+
+ h = dlopen (libname, RTLD_LAZY);
+ if (h == NULL) return 1;
+
+ p_func = dlsym (h, "pendfunc2");
+ if (p_func == NULL) return 2;
+
+ (*p_func) (4);
+
+ marker ();
+
+ dlclose (h);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
new file mode 100644
index 0000000..543ba61
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -0,0 +1,518 @@
+# Copyright 2011 Free Software Foundation, Inc.
+# 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/>.
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+set testfile "pending"
+set libfile1 "pendshr1"
+set libfile2 "pendshr2"
+set executable $testfile
+set srcfile $testfile.c
+set libsrc1 $srcdir/$subdir/$libfile1.c
+set libsrc2 $srcdir/$subdir/$libfile2.c
+set binfile $objdir/$subdir/$testfile
+set lib_sl1 $objdir/$subdir/$libfile1.sl
+set lib_sl2 $objdir/$subdir/$libfile2.sl
+
+set lib_opts [gdb_target_symbol_prefix_flags]
+
+if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
+ || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
+ untested "Could not compile either $libsrc1 or $libsrc2"
+ return -1
+}
+
+set exec_opts [list debug shlib=$lib_sl1 shlib_load]
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+clean_restart $executable
+
+gdb_load_shlibs $lib_sl1
+gdb_load_shlibs $lib_sl2
+
+if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+}
+
+if ![gdb_target_supports_trace] {
+ unsupported "Current target does not support trace"
+ return -1;
+}
+
+# Verify pending tracepoint is resolved to running to main.
+
+proc pending_tracepoint_resolved { trace_type } {
+ global srcdir
+ global subdir
+ global binfile
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved:"
+
+ # Start with a fresh gdb.
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc.*" \
+ "single tracepoint info"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and works as expected.
+
+proc pending_tracepoint_works { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "works:"
+
+ # Restart with a fresh gdb.
+ clean_restart $executable
+
+ # Test setting and querying pending tracepoints
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test_multiple "continue" "continue to marker" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind test frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind test frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved during trace.
+
+proc pending_tracepoint_resolved_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global gdb_prompt
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and installed during trace.
+
+proc pending_tracepoint_installed_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+ global hex
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "installed_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test "next" ".*"
+ gdb_test "trace main" "Tracepoint \[0-9\] at .*" "set tracepoint on main"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*${srcfile}.*" \
+ "continue to marker 1"
+
+ # Set a pending tracepoint during a tracing experiment.
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \t\]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 $hex in pendfunc2 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify pending tracepoint will no longer work if we disconnect during tracing.
+
+proc pending_tracepoint_disconnect_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "trace pendfunc3" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*pendfunc3.*pending." \
+ "set pending tracepoint on pendfun3"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker"
+
+ send_gdb "disconnect\n"
+ gdb_expect {
+ -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
+ pass "disconnect with pending tracepoint"
+
+ send_gdb "y\n"
+ }
+ timeout {fail "(timeout) disconnect with pending tracepoint"}
+ }
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify disconnect after pending tracepoint has been resolved.
+
+proc pending_tracepoint_disconnect_after_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "trace set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint on pendfun2"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 2"
+
+ # There should be no pending tracepoint, so no warning should be emitted.
+ send_gdb "disconnect\n"
+ gdb_expect {
+ -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*$" {
+ fail "disconnect with resolved tracepoint"
+ }
+ -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
+ pass "disconnect with resolved tracepoint"
+ send_gdb "y\n"
+ }
+ timeout {fail "(timeout) disconnect with resolved tracepoint"}
+ }
+
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify action works properly in resolved tracepoint.
+
+proc pending_tracepoint_with_action_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "action_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ set pcreg "pc"
+ if [is_amd64_regs_target] {
+ set pcreg "rip"
+ } elseif [is_x86_like_target] {
+ set pcreg "eip"
+ }
+
+ gdb_trace_setactions "set action for pending tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tdump" "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+pending_tracepoint_resolved "trace"
+
+pending_tracepoint_works "trace"
+
+pending_tracepoint_resolved_during_trace "trace"
+
+pending_tracepoint_disconnect_during_trace "trace"
+
+pending_tracepoint_disconnect_after_resolved "trace"
+
+pending_tracepoint_with_action_resolved "trace"
+
+pending_tracepoint_installed_during_trace "trace"
+
+# Re-compile test case with IPA.
+set libipa $objdir/../gdbserver/libinproctrace.so
+gdb_load_shlibs $libipa
+
+lappend exec_opts "shlib=$libipa"
+
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+pending_tracepoint_resolved "ftrace"
+pending_tracepoint_works "ftrace"
+pending_tracepoint_resolved_during_trace "ftrace"
+pending_tracepoint_disconnect_during_trace "ftrace"
+pending_tracepoint_disconnect_after_resolved "ftrace"
+pending_tracepoint_with_action_resolved "ftrace"
+pending_tracepoint_installed_during_trace "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pendshr1.c b/gdb/testsuite/gdb.trace/pendshr1.c
new file mode 100644
index 0000000..f2826c6
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr1.c
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+pendfunc1 (void)
+{
+ int x = 0;
+ int y = x + 4;
+}
+
+void
+pendfunc (int x)
+{
+ /* `set_point1' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point1) "\n"
+ SYMBOL(set_point1) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(pendfunc1) "\n"
+#endif
+ );
+}
diff --git a/gdb/testsuite/gdb.trace/pendshr2.c b/gdb/testsuite/gdb.trace/pendshr2.c
new file mode 100644
index 0000000..46eedee
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr2.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+foo ()
+{}
+
+void
+pendfunc2 (int x)
+{
+ /* `set_point2' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point2) "\n"
+ SYMBOL(set_point2) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(foo) "\n"
+#endif
+ );
+}
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 4/5] Test cases
2011-11-17 3:27 ` Yao Qi
@ 2011-11-17 12:08 ` Pedro Alves
2011-11-17 14:09 ` Yao Qi
0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-17 12:08 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On Thursday 17 November 2011 03:26:37, Yao Qi wrote:
> On 11/17/2011 03:04 AM, Pedro Alves wrote:
> >> > + send_gdb "disconnect\n"
> >> > + gdb_expect {
> >> > + -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*Ending remote debugging.*$gdb_prompt $" {
> >> > + pass "disconnect with pending tracepoint"
> >> > + }
> >> > + -re ".*$gdb_prompt $" {
> >> > + fail "disconnect with pending tracepoint"
> >> > + }
> >> > + }
> > Why send_gdb/gdb_expect?
>
> Because gdb_test_multiple doesn't match pattern in output when "Ending
> remote debugging" appeared in the output. We have to resort to
> send_gdb/gdb_expect here.
Hmm, I'm confused. In this new revision the test is now:
send_gdb "disconnect\n"
gdb_expect {
-re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
pass "disconnect with pending tracepoint"
send_gdb "y\n"
}
timeout {fail "(timeout) disconnect with pending tracepoint"}
}
No "Ending remote debugging" in sight. GDB outputs that string
after the "detach anyway" query, so I think gdb_test_multiple
should just work. Also, we should always make sure to eat the prompt
after the "y", so that it doesn't remain in expect's buffer and
confuse following tests. Something like:
set test "disconnect with pending tracepoint"
gdb_test_multiple "disconnect" $test {
-re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
pass $test
set test "disconnected"
gdb_test_multiple "y" $test {
-re "$gdb_prompt $" {
pass "$test"
}
}
}
}
Note that "$gdb_prompt $" match takes precedence over
gdb_test_multiple's internal "Ending remote debugging.*$gdb_prompt $"
match.
Want to try that?
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 4/5] Test cases
2011-11-17 12:08 ` Pedro Alves
@ 2011-11-17 14:09 ` Yao Qi
2011-11-17 14:54 ` Pedro Alves
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-17 14:09 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2616 bytes --]
On 11/17/2011 08:07 PM, Pedro Alves wrote:
>> > Because gdb_test_multiple doesn't match pattern in output when "Ending
>> > remote debugging" appeared in the output. We have to resort to
>> > send_gdb/gdb_expect here.
> Hmm, I'm confused. In this new revision the test is now:
>
> send_gdb "disconnect\n"
> gdb_expect {
> -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
> pass "disconnect with pending tracepoint"
>
> send_gdb "y\n"
> }
> timeout {fail "(timeout) disconnect with pending tracepoint"}
> }
>
> No "Ending remote debugging" in sight. GDB outputs that string
> after the "detach anyway" query, so I think gdb_test_multiple
> should just work. Also, we should always make sure to eat the prompt
> after the "y", so that it doesn't remain in expect's buffer and
> confuse following tests. Something like:
This is a good tip.
>
> set test "disconnect with pending tracepoint"
> gdb_test_multiple "disconnect" $test {
> -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
> pass $test
>
> set test "disconnected"
> gdb_test_multiple "y" $test {
> -re "$gdb_prompt $" {
> pass "$test"
> }
> }
> }
> }
My original attempt on using gdb_test is like this,
set test "disconnect with pending tracepoint"
gdb_test "disconnect" \
"warning: Pending tracepoint will not be resolved while GDB is
disconnected" \
$test \
"Trace is running but will stop on detach; detach anyway\\? \\(y or
n\\) $" \
"y"
in proc gdb_test
return [gdb_test_multiple $command $message {
-re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
if ![string match "" $message] then {
pass "$message"
}
}
-re "(${question_string})$" {
send_gdb "$response_string\n";
exp_continue;
}
}]
Query comes out prior to "warning:", so query matches, and there is no
PASS and FAIL in gdb.sum. PATTERN passed to gdb_test is for matching
the output _after_ query, and I used gdb_test in a wrong way.
>
> Note that "$gdb_prompt $" match takes precedence over
> gdb_test_multiple's internal "Ending remote debugging.*$gdb_prompt $"
> match.
Is this precedence determined by the order of appending ${code} in proc
gdb_test_multiple?
>
> Want to try that?
Sure, they work. Updated patch as you suggested.
--
Yao (é½å°§)
[-- Attachment #2: 0004-testcase-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 27409 bytes --]
gdb/testsuite/
* gdb.trace/pending.exp: New.
* gdb.trace/pending.c: New.
* gdb.trace/pendshr1.c: New.
* gdb.trace/pendshr2.c: New.
* gdb.trace/change-loc.exp (tracepoint_change_loc_1): Check one
tracepoint location becomes pending.
(tracepoint_change_loc_2): New.
---
gdb/testsuite/gdb.trace/change-loc.exp | 129 ++++++++-
gdb/testsuite/gdb.trace/pending.c | 50 +++
gdb/testsuite/gdb.trace/pending.exp | 525 ++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.trace/pendshr1.c | 43 +++
gdb/testsuite/gdb.trace/pendshr2.c | 40 +++
5 files changed, 782 insertions(+), 5 deletions(-)
create mode 100644 gdb/testsuite/gdb.trace/pending.c
create mode 100644 gdb/testsuite/gdb.trace/pending.exp
create mode 100644 gdb/testsuite/gdb.trace/pendshr1.c
create mode 100644 gdb/testsuite/gdb.trace/pendshr2.c
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index e125024..d01f71c 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -118,27 +118,145 @@ proc tracepoint_change_loc_1 { trace_type } {
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
"tracepoint with two locations"
- setup_kfail "gdb/13392" x86_64-*-*
- gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
- "continue to marker 2"
-
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
# tracepoint has three locations after shlib change-loc-2 is loaded.
gdb_test "info trace" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
"tracepoint with three locations"
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
gdb_test_no_output "tstop"
- setup_kfail "gdb/13392" x86_64-*-*
gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0"
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
set pf_prefix $old_pf_prefix
}
+# Set pending tracepoint.
+
+proc tracepoint_change_loc_2 { trace_type } {
+ global srcdir
+ global srcfile
+ global subdir
+ global pcreg
+ global binfile
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ set pf_prefix "$pf_prefix 2 $trace_type:"
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
+ -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_trace_setactions "set action for tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ # tracepoint has no location information now.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+ # tracepoint has one location after executable is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
+ "tracepoint with one location"
+
+ set main_bp 0
+ gdb_test_multiple "break main" "set breakpoint on main" {
+ -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
+ set main_bp $expect_out(1,string)
+ }
+ }
+ gdb_run_cmd
+
+ gdb_test "" \
+ ".*Breakpoint.*main.*at.*$srcfile.*" \
+ "run to main"
+ gdb_test_no_output "delete break $main_bp"
+
+ # tracepoint has two locations after shlib change-loc-1 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \
+ "tracepoint with two locations"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ # tracepoint with two locations will be downloaded and installed.
+ gdb_test_no_output "tstart"
+
+ gdb_test_multiple "continue" "continue to marker 1" {
+ -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 1"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 1"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 2"
+
+ # tracepoint has three locations after shlib change-loc-2 is loaded.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \
+ "tracepoint with three locations"
+
+ gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+ "continue to marker 3"
+
+ # shlib is unloaded, there are still three locations, but one is pending.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
+ "tracepoint with two locations (unload)"
+
+ gdb_test_no_output "tstop"
+
+ gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame\\..*"
+
+ set pf_prefix $old_pf_prefix
+}
tracepoint_change_loc_1 "trace"
+tracepoint_change_loc_2 "trace"
# Re-compile test case with IPA.
set libipa $objdir/../gdbserver/libinproctrace.so
@@ -151,3 +269,4 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
}
tracepoint_change_loc_1 "ftrace"
+tracepoint_change_loc_2 "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pending.c b/gdb/testsuite/gdb.trace/pending.c
new file mode 100644
index 0000000..08c751b
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.c
@@ -0,0 +1,50 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+extern void pendfunc (int x);
+
+static void
+marker () {}
+
+int main()
+{
+ const char *libname = "pendshr2.sl";
+ void *h;
+ int (*p_func) (int);
+
+ pendfunc (3);
+ pendfunc (4);
+ pendfunc (3);
+
+ marker ();
+
+ h = dlopen (libname, RTLD_LAZY);
+ if (h == NULL) return 1;
+
+ p_func = dlsym (h, "pendfunc2");
+ if (p_func == NULL) return 2;
+
+ (*p_func) (4);
+
+ marker ();
+
+ dlclose (h);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
new file mode 100644
index 0000000..5851f04
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -0,0 +1,525 @@
+# Copyright 2011 Free Software Foundation, Inc.
+# 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/>.
+
+load_lib "trace-support.exp";
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+set testfile "pending"
+set libfile1 "pendshr1"
+set libfile2 "pendshr2"
+set executable $testfile
+set srcfile $testfile.c
+set libsrc1 $srcdir/$subdir/$libfile1.c
+set libsrc2 $srcdir/$subdir/$libfile2.c
+set binfile $objdir/$subdir/$testfile
+set lib_sl1 $objdir/$subdir/$libfile1.sl
+set lib_sl2 $objdir/$subdir/$libfile2.sl
+
+set lib_opts [gdb_target_symbol_prefix_flags]
+
+if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
+ || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
+ untested "Could not compile either $libsrc1 or $libsrc2"
+ return -1
+}
+
+set exec_opts [list debug shlib=$lib_sl1 shlib_load]
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+clean_restart $executable
+
+gdb_load_shlibs $lib_sl1
+gdb_load_shlibs $lib_sl2
+
+if ![runto_main] {
+ fail "Can't run to main to check for trace support"
+ return -1
+}
+
+if ![gdb_target_supports_trace] {
+ unsupported "Current target does not support trace"
+ return -1;
+}
+
+# Verify pending tracepoint is resolved to running to main.
+
+proc pending_tracepoint_resolved { trace_type } {
+ global srcdir
+ global subdir
+ global binfile
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved:"
+
+ # Start with a fresh gdb.
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info (without symbols)"
+
+ gdb_load ${binfile}
+
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc.*" \
+ "single tracepoint info"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and works as expected.
+
+proc pending_tracepoint_works { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "works:"
+
+ # Restart with a fresh gdb.
+ clean_restart $executable
+
+ # Test setting and querying pending tracepoints
+
+ gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \
+ "single pending tracepoint info"
+
+ # Run to main which should resolve a pending tracepoint
+ gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint function"
+ gdb_run_cmd
+ gdb_test "" "Breakpoint 2, main.*"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test_multiple "continue" "continue to marker" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind test frame 1"
+ gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind test frame 2"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved during trace.
+
+proc pending_tracepoint_resolved_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global gdb_prompt
+ global lib_sl1
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "resolved_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify pending tracepoint is resolved and installed during trace.
+
+proc pending_tracepoint_installed_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+ global hex
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "installed_in_trace:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test "next" ".*"
+ gdb_test "trace main" "Tracepoint \[0-9\] at .*" "set tracepoint on main"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*${srcfile}.*" \
+ "continue to marker 1"
+
+ # Set a pending tracepoint during a tracing experiment.
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint"
+ }
+ }
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \t\]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 $hex in pendfunc2 .*" "tfind test frame 0"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify pending tracepoint will no longer work if we disconnect during tracing.
+
+proc pending_tracepoint_disconnect_during_trace { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global pf_prefix
+ global gdb_prompt
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "trace pendfunc3" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*pendfunc3.*pending." \
+ "set pending tracepoint on pendfun3"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker"
+
+ set test "disconnect with pending tracepoint"
+ gdb_test_multiple "disconnect" $test {
+ -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
+ pass $test
+
+ set test "disconnected"
+ gdb_test_multiple "y" $test {
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+ }
+ }
+
+ set pf_prefix $old_pf_prefix
+}
+
+
+# Verify disconnect after pending tracepoint has been resolved.
+
+proc pending_tracepoint_disconnect_after_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "disconn_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "trace set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint on pendfun2"
+ }
+ }
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 2"
+
+ # There should be no pending tracepoint, so no warning should be emitted.
+ set test "disconnect with resolved tracepoint"
+ gdb_test_multiple "disconnect" $test {
+ -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
+ fail $test
+ }
+ -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
+ pass $test
+ }
+ }
+ set test "disconnected"
+ gdb_test_multiple "y" $test {
+ -re "$gdb_prompt $" {
+ pass "$test"
+ }
+ }
+
+ set pf_prefix $old_pf_prefix
+}
+
+# Verify action works properly in resolved tracepoint.
+
+proc pending_tracepoint_with_action_resolved { trace_type } {
+ global executable
+ global srcfile
+ global lib_sl1
+ global gdb_prompt
+ global pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ lappend pf_prefix "$trace_type" "action_resolved:"
+
+ # Start with a fresh gdb.
+ clean_restart $executable
+ if ![runto_main] {
+ fail "Can't run to main"
+ set pf_prefix $old_pf_prefix
+ return -1
+ }
+
+ gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" {
+ -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \
+ "set pending tracepoint (without symbols)"
+ }
+ }
+
+ set pcreg "pc"
+ if [is_amd64_regs_target] {
+ set pcreg "rip"
+ } elseif [is_x86_like_target] {
+ set pcreg "eip"
+ }
+
+ gdb_trace_setactions "set action for pending tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \
+ "single pending tracepoint on set_point2"
+
+ gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "breakpoint on marker"
+
+ gdb_test_no_output "tstart" "start trace experiment"
+
+ gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \
+ "continue to marker 1"
+
+ gdb_test_multiple "continue" "continue to marker 2" {
+ -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
+ pass "continue to marker 2"
+ }
+ -re ".*$gdb_prompt $" {
+ kfail "gdb/13392" "continue to marker 2"
+ set pf_prefix $old_pf_prefix
+ return
+ }
+ }
+
+ gdb_test "tstop" "\[\r\n\]+" "stop trace experiment"
+
+ # tracepoint should be resolved.
+ gdb_test "info trace" \
+ "Num Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \
+ "tracepoint is resolved"
+
+ gdb_test "tfind start" "#0 .*" "tfind test frame 0"
+ gdb_test "tdump" "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*"
+ gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame"
+
+ set pf_prefix $old_pf_prefix
+}
+
+pending_tracepoint_resolved "trace"
+
+pending_tracepoint_works "trace"
+
+pending_tracepoint_resolved_during_trace "trace"
+
+pending_tracepoint_disconnect_during_trace "trace"
+
+pending_tracepoint_disconnect_after_resolved "trace"
+
+pending_tracepoint_with_action_resolved "trace"
+
+pending_tracepoint_installed_during_trace "trace"
+
+# Re-compile test case with IPA.
+set libipa $objdir/../gdbserver/libinproctrace.so
+gdb_load_shlibs $libipa
+
+lappend exec_opts "shlib=$libipa"
+
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
+ untested "Failed to compile $srcfile"
+ return -1
+}
+
+pending_tracepoint_resolved "ftrace"
+pending_tracepoint_works "ftrace"
+pending_tracepoint_resolved_during_trace "ftrace"
+pending_tracepoint_disconnect_during_trace "ftrace"
+pending_tracepoint_disconnect_after_resolved "ftrace"
+pending_tracepoint_with_action_resolved "ftrace"
+pending_tracepoint_installed_during_trace "ftrace"
diff --git a/gdb/testsuite/gdb.trace/pendshr1.c b/gdb/testsuite/gdb.trace/pendshr1.c
new file mode 100644
index 0000000..f2826c6
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr1.c
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+pendfunc1 (void)
+{
+ int x = 0;
+ int y = x + 4;
+}
+
+void
+pendfunc (int x)
+{
+ /* `set_point1' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point1) "\n"
+ SYMBOL(set_point1) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(pendfunc1) "\n"
+#endif
+ );
+}
diff --git a/gdb/testsuite/gdb.trace/pendshr2.c b/gdb/testsuite/gdb.trace/pendshr2.c
new file mode 100644
index 0000000..46eedee
--- /dev/null
+++ b/gdb/testsuite/gdb.trace/pendshr2.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ 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/>. */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str) SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str) #str
+#endif
+
+static void
+foo ()
+{}
+
+void
+pendfunc2 (int x)
+{
+ /* `set_point2' is the label where we'll set multiple tracepoints and
+ breakpoints at. The insn at the label must the large enough to
+ fit a fast tracepoint jump. */
+ asm (" .global " SYMBOL(set_point2) "\n"
+ SYMBOL(set_point2) ":\n"
+#if (defined __x86_64__ || defined __i386__)
+ " call " SYMBOL(foo) "\n"
+#endif
+ );
+}
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 4/5] Test cases
2011-11-17 14:09 ` Yao Qi
@ 2011-11-17 14:54 ` Pedro Alves
0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2011-11-17 14:54 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On Thursday 17 November 2011 14:09:13, Yao Qi wrote:
> On 11/17/2011 08:07 PM, Pedro Alves wrote:
> >
> > Note that "$gdb_prompt $" match takes precedence over
> > gdb_test_multiple's internal "Ending remote debugging.*$gdb_prompt $"
> > match.
>
> Is this precedence determined by the order of appending ${code} in proc
> gdb_test_multiple?
Yes. You end up with the equivalent of:
gdb_expect $tmt {
-re "$gdb_prompt $" {
}
-re "Ending remote debugging.*$gdb_prompt $" {
}
}
And the first regex that matches (top to bottom order) wins.
> > Want to try that?
>
> Sure, they work. Updated patch as you suggested.
Okay.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread
* [patch 5/5] Document
2011-11-15 7:01 [patch 0/5] pending tracepoint Yao Qi
` (3 preceding siblings ...)
2011-11-15 8:03 ` [patch 4/5] Test cases Yao Qi
@ 2011-11-15 8:08 ` Yao Qi
2011-11-15 14:29 ` Luis Machado
2011-11-15 17:06 ` Eli Zaretskii
4 siblings, 2 replies; 32+ messages in thread
From: Yao Qi @ 2011-11-15 8:08 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 76 bytes --]
This is the documentation about pending tracepoint.
--
Yao (é½å°§)
[-- Attachment #2: 0005-doc-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 1175 bytes --]
* gdb.texinfo (Create and Delete Tracepoints): Mention pending
tracepoint.
---
gdb/doc/gdb.texinfo | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0cadc96..979b2e4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -10337,7 +10337,13 @@ in tracing}).
If remote stub doesn't support the @samp{InstallInTrace} feature, all
these changes don't take effect until the next @code{tstart}
command, and once a trace experiment is running, further changes will
-not have any effect until the next trace experiment starts.
+not have any effect until the next trace experiment starts. Similar
+to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
+not yet resolved, is supported as well. Pending tracepoint is not
+downloaded to target and not installed until it is resolved. The
+resolution of pending tracepoint requires @value{GDBN} support. In
+remote target, when @value{GDBN} disconnects from remote stub, pending
+tracepoint still exists but can not be resolved during disconnection.
Here are some examples of using the @code{trace} command:
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-15 8:08 ` [patch 5/5] Document Yao Qi
@ 2011-11-15 14:29 ` Luis Machado
2011-11-15 14:57 ` Yao Qi
2011-11-15 17:06 ` Eli Zaretskii
1 sibling, 1 reply; 32+ messages in thread
From: Luis Machado @ 2011-11-15 14:29 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
Hi,
Just a suggestion on the documentation text.
On 11/15/2011 06:07 AM, Yao Qi wrote:
> This is the documentation about pending tracepoint.
>
> -- Yao (é½å°§)
>
>
> 0005-doc-pending-tracepoint.patch
>
>
>
> * gdb.texinfo (Create and Delete Tracepoints): Mention pending
> tracepoint.
> ---
> gdb/doc/gdb.texinfo | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 0cadc96..979b2e4 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -10337,7 +10337,13 @@ in tracing}).
> If remote stub doesn't support the @samp{InstallInTrace} feature, all
> these changes don't take effect until the next @code{tstart}
> command, and once a trace experiment is running, further changes will
> -not have any effect until the next trace experiment starts.
> +not have any effect until the next trace experiment starts. Similar
> +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
to breakpoints, @dfn{pending tracepoint}---tracepoints whose addresses are
> +not yet resolved, is supported as well. Pending tracepoint is not
not yet resolved are supported as well. Pending tracepoints are not
> +downloaded to target and not installed until it is resolved. The
downloaded to and installed on the target until they are resolved. The
> +resolution of pending tracepoint requires @value{GDBN} support. In
resolution of pending tracepoints require @value{GDBN} support. In
> +remote target, when @value{GDBN} disconnects from remote stub, pending
the remote target, when @value{GDBN} disconnects from the remote stub,
pending
> +tracepoint still exists but can not be resolved during disconnection.
tracepoints still exist but will not be resolved until @value{GDBN}
reconnects to it.
>
> Here are some examples of using the @code{trace} command:
>
> -- 1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-15 14:29 ` Luis Machado
@ 2011-11-15 14:57 ` Yao Qi
2011-11-15 15:04 ` Luis Machado
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-15 14:57 UTC (permalink / raw)
To: luis_gustavo; +Cc: gdb-patches
On 11/15/2011 10:33 PM, Luis Machado wrote:
>> +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
> to breakpoints, @dfn{pending tracepoint}---tracepoints whose addresses are
>
>> +not yet resolved, is supported as well. Pending tracepoint is not
> not yet resolved are supported as well. Pending tracepoints are not
>
>> +downloaded to target and not installed until it is resolved. The
> downloaded to and installed on the target until they are resolved. The
>
>> +resolution of pending tracepoint requires @value{GDBN} support. In
> resolution of pending tracepoints require @value{GDBN} support. In
>
I noticed that `pending breakpoint' is in singular form in document, so
I choose singular form for `pending tracepoint' as well. I am OK with
either of them.
>> +remote target, when @value{GDBN} disconnects from remote stub, pending
> the remote target, when @value{GDBN} disconnects from the remote stub,
> pending
>
Right, we need "the" here.
>> +tracepoint still exists but can not be resolved during disconnection.
> tracepoints still exist but will not be resolved until @value{GDBN}
> reconnects to it.
There is a minor difference between yours and mine, IIUC. "will not be
resolved until GDB reconnects to it" means "pending tracepoints will be
resolved immediately after GDB reconnects to it", which is not true. We
don't know when a pending tracepoint can be resolved, but we are sure
that the pending tracepoint can not be resolved when gdb disconnects.
What do you think?
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-15 14:57 ` Yao Qi
@ 2011-11-15 15:04 ` Luis Machado
2011-11-15 17:02 ` Eli Zaretskii
0 siblings, 1 reply; 32+ messages in thread
From: Luis Machado @ 2011-11-15 15:04 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 11/15/2011 12:56 PM, Yao Qi wrote:
> On 11/15/2011 10:33 PM, Luis Machado wrote:
>>> +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
>> to breakpoints, @dfn{pending tracepoint}---tracepoints whose addresses are
>>
>>> +not yet resolved, is supported as well. Pending tracepoint is not
>> not yet resolved are supported as well. Pending tracepoints are not
>>
>>> +downloaded to target and not installed until it is resolved. The
>> downloaded to and installed on the target until they are resolved. The
>>
>>> +resolution of pending tracepoint requires @value{GDBN} support. In
>> resolution of pending tracepoints require @value{GDBN} support. In
>>
> I noticed that `pending breakpoint' is in singular form in document, so
> I choose singular form for `pending tracepoint' as well. I am OK with
> either of them.
Should be OK as well. This is a minor suggestion. It just sounded a bit
more natural.
>>> +remote target, when @value{GDBN} disconnects from remote stub, pending
>> the remote target, when @value{GDBN} disconnects from the remote stub,
>> pending
>>
> Right, we need "the" here.
>
>>> +tracepoint still exists but can not be resolved during disconnection.
>> tracepoints still exist but will not be resolved until @value{GDBN}
>> reconnects to it.
> There is a minor difference between yours and mine, IIUC. "will not be
> resolved until GDB reconnects to it" means "pending tracepoints will be
> resolved immediately after GDB reconnects to it", which is not true. We
> don't know when a pending tracepoint can be resolved, but we are sure
> that the pending tracepoint can not be resolved when gdb disconnects.
> What do you think
"will not be resolved until GDB reconnects to it" meant to say that
while GDB is disconnected from the remote target, pending tracepoints
won't be resolved. We can be more explicit about this if the phrasing
isn't clear.
"during disconnection" made it sound like something happens while GDB is
disconnecting.
Maybe "tracepoints still exist but cannot be resolved while GDB is
disconnected?"
Again, these are minor details.
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-15 15:04 ` Luis Machado
@ 2011-11-15 17:02 ` Eli Zaretskii
0 siblings, 0 replies; 32+ messages in thread
From: Eli Zaretskii @ 2011-11-15 17:02 UTC (permalink / raw)
To: luis_gustavo; +Cc: yao, gdb-patches
> Date: Tue, 15 Nov 2011 13:08:18 -0200
> From: Luis Machado <luis_gustavo@mentor.com>
> CC: gdb-patches@sourceware.org
>
> On 11/15/2011 12:56 PM, Yao Qi wrote:
> > On 11/15/2011 10:33 PM, Luis Machado wrote:
> >>> +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
> >> to breakpoints, @dfn{pending tracepoint}---tracepoints whose addresses are
> >>
> >>> +not yet resolved, is supported as well. Pending tracepoint is not
> >> not yet resolved are supported as well. Pending tracepoints are not
> >>
> >>> +downloaded to target and not installed until it is resolved. The
> >> downloaded to and installed on the target until they are resolved. The
> >>
> >>> +resolution of pending tracepoint requires @value{GDBN} support. In
> >> resolution of pending tracepoints require @value{GDBN} support. In
> >>
> > I noticed that `pending breakpoint' is in singular form in document, so
> > I choose singular form for `pending tracepoint' as well. I am OK with
> > either of them.
>
> Should be OK as well. This is a minor suggestion. It just sounded a bit
> more natural.
I agree: plural is better.
> >>> +tracepoint still exists but can not be resolved during disconnection.
> >> tracepoints still exist but will not be resolved until @value{GDBN}
> >> reconnects to it.
> > There is a minor difference between yours and mine, IIUC. "will not be
> > resolved until GDB reconnects to it" means "pending tracepoints will be
> > resolved immediately after GDB reconnects to it", which is not true. We
> > don't know when a pending tracepoint can be resolved, but we are sure
> > that the pending tracepoint can not be resolved when gdb disconnects.
> > What do you think
> "will not be resolved until GDB reconnects to it" meant to say that
> while GDB is disconnected from the remote target, pending tracepoints
> won't be resolved. We can be more explicit about this if the phrasing
> isn't clear.
>
> "during disconnection" made it sound like something happens while GDB is
> disconnecting.
>
> Maybe "tracepoints still exist but cannot be resolved while GDB is
> disconnected?"
Yes.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [patch 5/5] Document
2011-11-15 8:08 ` [patch 5/5] Document Yao Qi
2011-11-15 14:29 ` Luis Machado
@ 2011-11-15 17:06 ` Eli Zaretskii
2011-11-16 3:13 ` Yao Qi
1 sibling, 1 reply; 32+ messages in thread
From: Eli Zaretskii @ 2011-11-15 17:06 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
> Date: Tue, 15 Nov 2011 16:07:43 +0800
> From: Yao Qi <yao@codesourcery.com>
>
> This is the documentation about pending tracepoint.
Thanks.
> + Similar
> +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
> +not yet resolved, is supported as well.
Putting verbs at the end of the sentence produces awkward and hard to
understand sentences (unless you talk in German or Japanese ;-).
Using passive tense makes it even more so. I would reword like this:
In addition, @value{GDBN} supports @dfn{pending tracepoints}---
tracepoints whose address is not yet resolved. (This is similar to
pending breakpoints.)
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-15 17:06 ` Eli Zaretskii
@ 2011-11-16 3:13 ` Yao Qi
2011-11-16 4:01 ` Eli Zaretskii
2011-11-16 19:04 ` Pedro Alves
0 siblings, 2 replies; 32+ messages in thread
From: Yao Qi @ 2011-11-16 3:13 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, Luis Machado
[-- Attachment #1: Type: text/plain, Size: 763 bytes --]
On 11/16/2011 01:03 AM, Eli Zaretskii wrote:
>> > + Similar
>> > +to breakpoint, @dfn{pending tracepoint}---tracepoint whose address is
>> > +not yet resolved, is supported as well.
> Putting verbs at the end of the sentence produces awkward and hard to
> understand sentences (unless you talk in German or Japanese ;-).
This applies to Chinese as well :)
> Using passive tense makes it even more so. I would reword like this:
>
> In addition, @value{GDBN} supports @dfn{pending tracepoints}---
> tracepoints whose address is not yet resolved. (This is similar to
> pending breakpoints.)
That looks good.
Eli, Luis,
Thanks for your suggestions. Here is a new one.
--
Yao (é½å°§)
[-- Attachment #2: 0005-doc-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 1236 bytes --]
* gdb.texinfo (Create and Delete Tracepoints): Mention pending
tracepoint.
---
gdb/doc/gdb.texinfo | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0cadc96..6882b78 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -10337,7 +10337,14 @@ in tracing}).
If remote stub doesn't support the @samp{InstallInTrace} feature, all
these changes don't take effect until the next @code{tstart}
command, and once a trace experiment is running, further changes will
-not have any effect until the next trace experiment starts.
+not have any effect until the next trace experiment starts. In addition,
+@value{GDBN} supports @dfn{pending tracepoints}---tracepoints whose
+address is not yet resolved. (This is similar to pending breakpoints.)
+Pending tracepoints are not downloaded to target and not installed until
+they are resolved. The resolution of pending tracepoints requires
+@value{GDBN} support. In the remote target, when @value{GDBN}
+disconnects from remote stub, pending tracepoints still exists but can
+not be resolved while @value{GDBN} is disconnected.
Here are some examples of using the @code{trace} command:
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-16 3:13 ` Yao Qi
@ 2011-11-16 4:01 ` Eli Zaretskii
2011-11-16 19:04 ` Pedro Alves
1 sibling, 0 replies; 32+ messages in thread
From: Eli Zaretskii @ 2011-11-16 4:01 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, luis_gustavo
> Date: Wed, 16 Nov 2011 11:13:06 +0800
> From: Yao Qi <yao@codesourcery.com>
> CC: gdb-patches@sourceware.org, Luis Machado <luis_gustavo@mentor.com>
>
> Eli, Luis,
> Thanks for your suggestions. Here is a new one.
Fine with me. Thanks.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [patch 5/5] Document
2011-11-16 3:13 ` Yao Qi
2011-11-16 4:01 ` Eli Zaretskii
@ 2011-11-16 19:04 ` Pedro Alves
2011-11-17 3:25 ` Yao Qi
1 sibling, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-16 19:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi, Eli Zaretskii, Luis Machado
On Wednesday 16 November 2011 03:13:06, Yao Qi wrote:
> +Pending tracepoints are not downloaded to target and not installed until
to the target
> +they are resolved. The resolution of pending tracepoints requires
> +@value{GDBN} support.
This sentence confused me a little. Everything in GDB requires GDB
support. :-) I suggest joining it with the following sentence, like
say:
The resolution of pending tracepoints requires
@value{GDBN} support---in the remote target, when @value{GDBN}
disconnects from the remote stub, pending tracepoints still exist
but can not be resolved while @value{GDBN} is disconnected.
> +disconnects from remote stub, pending tracepoints still exists but can
from the remote stub still exist
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-16 19:04 ` Pedro Alves
@ 2011-11-17 3:25 ` Yao Qi
2011-11-17 12:28 ` Pedro Alves
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-17 3:25 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Eli Zaretskii, Luis Machado
[-- Attachment #1: Type: text/plain, Size: 929 bytes --]
On 11/17/2011 03:03 AM, Pedro Alves wrote:
> On Wednesday 16 November 2011 03:13:06, Yao Qi wrote:
>> +Pending tracepoints are not downloaded to target and not installed until
>
> to the target
>
>> +they are resolved. The resolution of pending tracepoints requires
>> +@value{GDBN} support.
>
> This sentence confused me a little. Everything in GDB requires GDB
> support. :-) I suggest joining it with the following sentence, like
> say:
>
> The resolution of pending tracepoints requires
> @value{GDBN} support---in the remote target, when @value{GDBN}
> disconnects from the remote stub, pending tracepoints still exist
> but can not be resolved while @value{GDBN} is disconnected.
>
>> +disconnects from remote stub, pending tracepoints still exists but can
> from the remote stub still exist
>
These definite article are needed. Here is a new one.
--
Yao (é½å°§)
[-- Attachment #2: 0005-doc-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 1242 bytes --]
* gdb.texinfo (Create and Delete Tracepoints): Mention pending
tracepoint.
---
gdb/doc/gdb.texinfo | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0cadc96..7cbf037 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -10337,7 +10337,14 @@ in tracing}).
If remote stub doesn't support the @samp{InstallInTrace} feature, all
these changes don't take effect until the next @code{tstart}
command, and once a trace experiment is running, further changes will
-not have any effect until the next trace experiment starts.
+not have any effect until the next trace experiment starts. In addition,
+@value{GDBN} supports @dfn{pending tracepoints}---tracepoints whose
+address is not yet resolved. (This is similar to pending breakpoints.)
+Pending tracepoints are not downloaded to the target and not installed
+until they are resolved. The resolution of pending tracepoints requires
+@value{GDBN} support--in the remote target, when @value{GDBN}
+disconnects from the remote stub, pending tracepoints still exist but
+can not be resolved while @value{GDBN} is disconnected.
Here are some examples of using the @code{trace} command:
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-17 3:25 ` Yao Qi
@ 2011-11-17 12:28 ` Pedro Alves
2011-11-17 14:31 ` Yao Qi
0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-17 12:28 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, Eli Zaretskii, Luis Machado
On Thursday 17 November 2011 03:24:47, Yao Qi wrote:
> +until they are resolved. The resolution of pending tracepoints requires
> +@value{GDBN} support--in the remote target, when @value{GDBN}
I think it really needs to be three dashes.
> +disconnects from the remote stub, pending tracepoints still exist but
> +can not be resolved while @value{GDBN} is disconnected.
Sorry to be picky, but I'm trying to read this from a user's perspective,
and it still confuses me. What does "pending tracepoints still exist"
mean? Do you mean they still exist in GDB? That's true for all kinds
of breakpoints, so it doesn't add anything. If you mean that they exist
on the target, then what does it mean for a pending tracepoint to exist
on the target? What we're really trying to say is that pending tracepoints
don't work with disconnected tracing. How about:
The resolution of pending tracepoints requires @value{GDBN} support---
when debugging with the remote target, and @value{GDBN} disconnects from the
remote stub (@pxref{disconnected tracing}), pending tracepoints can not be
resolved (and downloaded to the remote stub) while @value{GDBN} is
disconnected.
?
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-17 12:28 ` Pedro Alves
@ 2011-11-17 14:31 ` Yao Qi
2011-11-17 14:41 ` Pedro Alves
0 siblings, 1 reply; 32+ messages in thread
From: Yao Qi @ 2011-11-17 14:31 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Eli Zaretskii, Luis Machado
On 11/17/2011 08:28 PM, Pedro Alves wrote:
>> > +disconnects from the remote stub, pending tracepoints still exist but
>> > +can not be resolved while @value{GDBN} is disconnected.
> Sorry to be picky, but I'm trying to read this from a user's perspective,
> and it still confuses me. What does "pending tracepoints still exist"
> mean? Do you mean they still exist in GDB? That's true for all kinds
> of breakpoints, so it doesn't add anything. If you mean that they exist
> on the target, then what does it mean for a pending tracepoint to exist
> on the target? What we're really trying to say is that pending tracepoints
> don't work with disconnected tracing. How about:
>
I agree that "pending tracepoints still exist" is confusing, and we
should remove this sentence. However, I don't think we should express
"pending tracepoints don't work with disconnected tracing.", because,
"pending tracepoints" and "disconnected tracing" are orthogonal to each
other. A remote stub can support either/both/none of them.
> The resolution of pending tracepoints requires @value{GDBN} support---
> when debugging with the remote target, and @value{GDBN} disconnects from the
> remote stub (@pxref{disconnected tracing}), pending tracepoints can not be
...so I suggest remove "(@pxref{disconnected tracing})" here. What do
you think?
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-17 14:31 ` Yao Qi
@ 2011-11-17 14:41 ` Pedro Alves
2011-11-17 15:17 ` Yao Qi
0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2011-11-17 14:41 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches, Eli Zaretskii, Luis Machado
On Thursday 17 November 2011 14:30:37, Yao Qi wrote:
> On 11/17/2011 08:28 PM, Pedro Alves wrote:
> >> > +disconnects from the remote stub, pending tracepoints still exist but
> >> > +can not be resolved while @value{GDBN} is disconnected.
> > Sorry to be picky, but I'm trying to read this from a user's perspective,
> > and it still confuses me. What does "pending tracepoints still exist"
> > mean? Do you mean they still exist in GDB? That's true for all kinds
> > of breakpoints, so it doesn't add anything. If you mean that they exist
> > on the target, then what does it mean for a pending tracepoint to exist
> > on the target? What we're really trying to say is that pending tracepoints
> > don't work with disconnected tracing. How about:
> >
>
> I agree that "pending tracepoints still exist" is confusing, and we
> should remove this sentence. However, I don't think we should express
> "pending tracepoints don't work with disconnected tracing.", because,
> "pending tracepoints" and "disconnected tracing" are orthogonal to each
> other. A remote stub can support either/both/none of them.
But if the target doesn't support disconnected tracing, tracing always
stops on disconnection, and so mentioning that pending tracepoints don't
resolve isn't interesting for that case. The ability to resolve or not
pending tracepoints while gdb is disconnected is only interesting from the
target's perpective _while_ a trace run is ongoing. From gdb's
perspective, once the remote target goes away, there's nothing special about
pending tracepoints compared to other types of breakpoints.
> > The resolution of pending tracepoints requires @value{GDBN} support---
> > when debugging with the remote target, and @value{GDBN} disconnects from the
> > remote stub (@pxref{disconnected tracing}), pending tracepoints can not be
>
> ...so I suggest remove "(@pxref{disconnected tracing})" here. What do
> you think?
I do think we should have that reference there.
--
Pedro Alves
^ permalink raw reply [flat|nested] 32+ messages in thread* Re: [patch 5/5] Document
2011-11-17 14:41 ` Pedro Alves
@ 2011-11-17 15:17 ` Yao Qi
0 siblings, 0 replies; 32+ messages in thread
From: Yao Qi @ 2011-11-17 15:17 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Eli Zaretskii, Luis Machado
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
On 11/17/2011 10:41 PM, Pedro Alves wrote:
>>> > > The resolution of pending tracepoints requires @value{GDBN} support---
>>> > > when debugging with the remote target, and @value{GDBN} disconnects from the
>>> > > remote stub (@pxref{disconnected tracing}), pending tracepoints can not be
>> >
>> > ...so I suggest remove "(@pxref{disconnected tracing})" here. What do
>> > you think?
> I do think we should have that reference there.
That is fine to me. Here is the final version of doc patch.
--
Yao (é½å°§)
[-- Attachment #2: 0005-doc-pending-tracepoint.patch --]
[-- Type: text/x-patch, Size: 1312 bytes --]
* gdb.texinfo (Create and Delete Tracepoints): Mention pending
tracepoint.
---
gdb/doc/gdb.texinfo | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0cadc96..60a2927 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -10337,7 +10337,15 @@ in tracing}).
If remote stub doesn't support the @samp{InstallInTrace} feature, all
these changes don't take effect until the next @code{tstart}
command, and once a trace experiment is running, further changes will
-not have any effect until the next trace experiment starts.
+not have any effect until the next trace experiment starts. In addition,
+@value{GDBN} supports @dfn{pending tracepoints}---tracepoints whose
+address is not yet resolved. (This is similar to pending breakpoints.)
+Pending tracepoints are not downloaded to the target and not installed
+until they are resolved. The resolution of pending tracepoints requires
+@value{GDBN} support---when debugging with the remote target, and
+@value{GDBN} disconnects from the remote stub (@pxref{disconnected
+tracing}), pending tracepoints can not be resolved (and downloaded to
+the remote stub) while @value{GDBN} is disconnected.
Here are some examples of using the @code{trace} command:
--
1.7.0.4
^ permalink raw reply [flat|nested] 32+ messages in thread