* [PATCH] No resuming while tfinding
@ 2010-03-17 1:59 Stan Shebs
2010-03-17 13:51 ` Marc Khouzam
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Stan Shebs @ 2010-03-17 1:59 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]
After going in and out of tfind mode about a thousand times in the past
few months :-), it's become apparent that we don't want to allow
resumption while looking at traceframes.
It often works now, to single-step the current thread while looking at a
random trace frame, and it could probably be made to work reliably.
However, it is incredibly confusing - for instance, after that
single-step, are you now looking at the live thread? If so, then you
switched yourself out of tfind mode, and your next print commands are
displaying current state, not trace frame contents. If instead you stay
in tfind mode, then you have the single-step stop printing a source line
that has nothing to do with the trace frame. Quite likely that you just
absent-mindedly typed "s" instead of "tfind" that you really wanted to
go to the next frame... Calling functions in the inferior has similar
issues. Sure, if you have a utility function that prettyprints a piece
of collected data, you'd want to use it---but the function runs on the
target using the live memory data, not the trace frame data! And since
the trace frame is typically incomplete, stuffing the trace frame
contents into live memory is not going to go well... :-)
So I propose that we make an executive decision to disable all the
resumption commands while in tfind mode. Does this make sense to everyone?
Stan
2010-03-16 Stan Shebs <stan@codesourcery.com>
* infcall.c: Include tracepoint.h.
(call_function_by_hand): Disallow calls in tfind mode.
* infcmd.c (ensure_not_tfind_mode): New function.
(continue_1): Call it.
(step_1) Ditto.
(jump_command): Ditto.
(signal_command): Ditto.
(until_command): Ditto.
(finish_command): Ditto.
[-- Attachment #2: tfindmode-patch-1 --]
[-- Type: text/plain, Size: 3245 bytes --]
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.127
diff -p -r1.127 infcall.c
*** infcall.c 28 Feb 2010 17:56:36 -0000 1.127
--- infcall.c 17 Mar 2010 01:34:00 -0000
***************
*** 21,26 ****
--- 21,27 ----
#include "defs.h"
#include "breakpoint.h"
+ #include "tracepoint.h"
#include "target.h"
#include "regcache.h"
#include "inferior.h"
*************** call_function_by_hand (struct value *fun
*** 453,458 ****
--- 454,462 ----
if (!target_has_execution)
noprocess ();
+ if (get_traceframe_number () >= 0)
+ error (_("May not call functions while looking at trace frames."));
+
frame = get_current_frame ();
gdbarch = get_frame_arch (frame);
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.259
diff -p -r1.259 infcmd.c
*** infcmd.c 16 Feb 2010 21:18:46 -0000 1.259
--- infcmd.c 17 Mar 2010 01:34:00 -0000
***************
*** 56,61 ****
--- 56,62 ----
#include "inline-frame.h"
extern void disconnect_or_stop_tracing (int from_tty);
+ extern int get_traceframe_number (void);
/* Functions exported for general use, in inferior.h: */
*************** ensure_valid_thread (void)
*** 648,657 ****
--- 649,671 ----
Cannot execute this command without a live selected thread."));
}
+ /* If the user is looking at trace frames, any resumption of execution
+ is likely to mix up recorded and live target data. So simply
+ disallow those commands. */
+
+ void
+ ensure_not_tfind_mode (void)
+ {
+ if (get_traceframe_number () >= 0)
+ error (_("\
+ Cannot execute this command while looking at trace frames."));
+ }
+
void
continue_1 (int all_threads)
{
ERROR_NO_INFERIOR;
+ ensure_not_tfind_mode ();
if (non_stop && all_threads)
{
*************** step_1 (int skip_subroutines, int single
*** 825,830 ****
--- 839,845 ----
int thread = -1;
ERROR_NO_INFERIOR;
+ ensure_not_tfind_mode ();
ensure_valid_thread ();
ensure_not_running ();
*************** jump_command (char *arg, int from_tty)
*** 1046,1051 ****
--- 1061,1067 ----
int async_exec = 0;
ERROR_NO_INFERIOR;
+ ensure_not_tfind_mode ();
ensure_valid_thread ();
ensure_not_running ();
*************** signal_command (char *signum_exp, int fr
*** 1148,1153 ****
--- 1164,1170 ----
dont_repeat (); /* Too dangerous. */
ERROR_NO_INFERIOR;
+ ensure_not_tfind_mode ();
ensure_valid_thread ();
ensure_not_running ();
*************** until_command (char *arg, int from_tty)
*** 1262,1267 ****
--- 1279,1286 ----
if (!target_has_execution)
error (_("The program is not running."));
+ ensure_not_tfind_mode ();
+
/* Find out whether we must run in the background. */
if (arg != NULL)
async_exec = strip_bg_char (&arg);
*************** finish_command (char *arg, int from_tty)
*** 1546,1551 ****
--- 1565,1572 ----
int async_exec = 0;
+ ensure_not_tfind_mode ();
+
/* Find out whether we must run in the background. */
if (arg != NULL)
async_exec = strip_bg_char (&arg);
^ permalink raw reply [flat|nested] 13+ messages in thread* RE: [PATCH] No resuming while tfinding
2010-03-17 1:59 [PATCH] No resuming while tfinding Stan Shebs
@ 2010-03-17 13:51 ` Marc Khouzam
2010-03-17 15:19 ` Joel Brobecker
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Marc Khouzam @ 2010-03-17 13:51 UTC (permalink / raw)
To: Stan Shebs, gdb-patches
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org
> [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Stan Shebs
> Sent: March-16-10 9:59 PM
> To: gdb-patches@sourceware.org
> Subject: [PATCH] No resuming while tfinding
>
> After going in and out of tfind mode about a thousand times
> in the past
> few months :-), it's become apparent that we don't want to allow
> resumption while looking at traceframes.
I've also been concerned about this. I was going to do exactly what
you suggest in the frontend. The user should conciously get out
of tfind-mode to be able to get back to the execution.
Marc
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] No resuming while tfinding
2010-03-17 1:59 [PATCH] No resuming while tfinding Stan Shebs
2010-03-17 13:51 ` Marc Khouzam
@ 2010-03-17 15:19 ` Joel Brobecker
2010-03-17 17:36 ` Michael Snyder
2010-03-17 15:22 ` Pedro Alves
2010-03-18 16:05 ` Tom Tromey
3 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2010-03-17 15:19 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches
> So I propose that we make an executive decision to disable all the
> resumption commands while in tfind mode. Does this make sense to
> everyone?
FWIW, no objection on my end... (anyone has an aspirin?)
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 15:19 ` Joel Brobecker
@ 2010-03-17 17:36 ` Michael Snyder
2010-03-17 23:40 ` Stan Shebs
0 siblings, 1 reply; 13+ messages in thread
From: Michael Snyder @ 2010-03-17 17:36 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Stan Shebs, gdb-patches
Joel Brobecker wrote:
>> So I propose that we make an executive decision to disable all the
>> resumption commands while in tfind mode. Does this make sense to
>> everyone?
>
> FWIW, no objection on my end... (anyone has an aspirin?)
>
For my part, I thought it was always that way.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 17:36 ` Michael Snyder
@ 2010-03-17 23:40 ` Stan Shebs
2010-03-17 23:44 ` Pedro Alves
0 siblings, 1 reply; 13+ messages in thread
From: Stan Shebs @ 2010-03-17 23:40 UTC (permalink / raw)
To: Michael Snyder; +Cc: Joel Brobecker, Stan Shebs, gdb-patches
Michael Snyder wrote:
> Joel Brobecker wrote:
>>> So I propose that we make an executive decision to disable all the
>>> resumption commands while in tfind mode. Does this make sense to
>>> everyone?
>>
>> FWIW, no objection on my end... (anyone has an aspirin?)
>>
>
> For my part, I thought it was always that way.
>
If there was code to prevent it, it must have disappeared some time ago;
somewhere in the single-step path, you'd have to test whether there is a
current traceframe.
Stan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 23:40 ` Stan Shebs
@ 2010-03-17 23:44 ` Pedro Alves
0 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2010-03-17 23:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Stan Shebs, Michael Snyder, Joel Brobecker
On Wednesday 17 March 2010 23:40:17, Stan Shebs wrote:
> If there was code to prevent it, it must have disappeared some time ago;
> somewhere in the single-step path, you'd have to test whether there is a
> current traceframe.
Maybe it was on the remote stub side only? (s or c packet handler would
error out)
--
Pedro Alves
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 1:59 [PATCH] No resuming while tfinding Stan Shebs
2010-03-17 13:51 ` Marc Khouzam
2010-03-17 15:19 ` Joel Brobecker
@ 2010-03-17 15:22 ` Pedro Alves
2010-03-17 17:31 ` Stan Shebs
2010-03-18 0:59 ` Stan Shebs
2010-03-18 16:05 ` Tom Tromey
3 siblings, 2 replies; 13+ messages in thread
From: Pedro Alves @ 2010-03-17 15:22 UTC (permalink / raw)
To: gdb-patches, Marc Khouzam; +Cc: Stan Shebs
On Wednesday 17 March 2010 01:59:24, Stan Shebs wrote:
> So I propose that we make an executive decision to disable all the
> resumption commands while in tfind mode. Does this make sense to everyone?
I object to not making this change. :-)
We should look at tfind mode as sort of a different
target. It's is kind of similar to debugging a core dump
while still connecting to a live target. (yay, GDB has
gone multi-target already :-D) Execution commands aren't allowed
when debugging a core dump either. At most, some could map some
of those commands to browsing through the traceframes, like
"stepi" (heuristically) following while-stepping traceframes,
but, never to running the live target. Execution commands
are prohibited when debugging core dumps by having the
core_ops target return false to target_has_execution,
instead of having checks in every command though. We could
try just installing a remote.c:remote_has_execution callback
that returns false when in tfind mode, but, it would
automatically prohibit e.g., "kill", "attach", "detach", "run",
etc. as well, which is not clear we do want to prohibit those
in tfind mode, and the resulting "The program is not being run."
error looks confusing in that case. We could always tweak
ERROR_NO_INFERIOR though.
> 2010-03-16 Stan Shebs <stan@codesourcery.com>
>
> * infcall.c: Include tracepoint.h.
> (call_function_by_hand): Disallow calls in tfind mode.
> * infcmd.c (ensure_not_tfind_mode): New function.
> (continue_1): Call it.
> (step_1) Ditto.
> (jump_command): Ditto.
> (signal_command): Ditto.
> (until_command): Ditto.
> (finish_command): Ditto.
This misses the "until" command, in breakpoint.c.
> *** infcmd.c 16 Feb 2010 21:18:46 -0000 1.259
> --- infcmd.c 17 Mar 2010 01:34:00 -0000
> ***************
> *** 56,61 ****
> --- 56,62 ----
> #include "inline-frame.h"
>
> extern void disconnect_or_stop_tracing (int from_tty);
> + extern int get_traceframe_number (void);
This is unnecessary, get_traceframe_number is declared in
tracepoint.h. The disconnect_or_stop_tracing declaration
shown above could use moving there as well...
--
Pedro Alves
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 15:22 ` Pedro Alves
@ 2010-03-17 17:31 ` Stan Shebs
2010-03-18 0:59 ` Stan Shebs
1 sibling, 0 replies; 13+ messages in thread
From: Stan Shebs @ 2010-03-17 17:31 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Marc Khouzam, Stan Shebs
Pedro Alves wrote:
> On Wednesday 17 March 2010 01:59:24, Stan Shebs wrote:
>
>> So I propose that we make an executive decision to disable all the
>> resumption commands while in tfind mode. Does this make sense to everyone?
>>
>
> I object to not making this change. :-)
>
> We should look at tfind mode as sort of a different
> target. It's is kind of similar to debugging a core dump
> while still connecting to a live target.
Yeah, this is one of those places where we wish the target stack was
actually as flexible as it was envisioned to be.
Once we get a tracepoint-supporting gdbserver, perhaps someone can just
try the experiment of creating a tfind target. It might not need
anything more hairy than some explicit calls down into the target stack,
for instance to read memory using the target that is actually storing
the collected data.
I can see users really really liking it if resumption commands were to
work and do the expected things - and now we have reverse execution
commands that could be used to find previous trace frames....
Stan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 15:22 ` Pedro Alves
2010-03-17 17:31 ` Stan Shebs
@ 2010-03-18 0:59 ` Stan Shebs
2010-03-18 12:19 ` Pedro Alves
1 sibling, 1 reply; 13+ messages in thread
From: Stan Shebs @ 2010-03-18 0:59 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Marc Khouzam, Stan Shebs
Pedro Alves wrote:
>
>> (until_command): Ditto.
>>
>>
> This misses the "until" command, in breakpoint.c.
>
I'm guessing you mean until_break_command? It looks like it's lower
level to until_command and advance_command, and I'd like to keep this
test at the outermost levels, similarly to the "program is not running"
error.
>>
>> extern void disconnect_or_stop_tracing (int from_tty);
>> + extern int get_traceframe_number (void);
>>
>
> This is unnecessary, get_traceframe_number is declared in
> tracepoint.h. The disconnect_or_stop_tracing declaration
> shown above could use moving there as well...
>
Good idea, I'll fold that in.
Stan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-18 0:59 ` Stan Shebs
@ 2010-03-18 12:19 ` Pedro Alves
2010-03-18 13:23 ` Pedro Alves
0 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2010-03-18 12:19 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches, Marc Khouzam, Stan Shebs
On Thursday 18 March 2010 00:59:37, Stan Shebs wrote:
> > This misses the "until" command, in breakpoint.c.
> >
> I'm guessing you mean until_break_command? It looks like it's lower
> level to until_command and advance_command, and I'd like to keep this
> test at the outermost levels, similarly to the "program is not running"
> error.
Ah, indeed. Thanks.
Hmm, it seems I missed adding ensure_not_running to those then. Also, this
in both until_command and advance_command:
if (!target_has_execution)
error (_("The program is not running."));
could be replaced by ERROR_NO_INFERIOR.
> >>
> >> extern void disconnect_or_stop_tracing (int from_tty);
> >> + extern int get_traceframe_number (void);
> >>
> >
> > This is unnecessary, get_traceframe_number is declared in
> > tracepoint.h. The disconnect_or_stop_tracing declaration
> > shown above could use moving there as well...
> >
> Good idea, I'll fold that in.
Thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] No resuming while tfinding
2010-03-18 12:19 ` Pedro Alves
@ 2010-03-18 13:23 ` Pedro Alves
0 siblings, 0 replies; 13+ messages in thread
From: Pedro Alves @ 2010-03-18 13:23 UTC (permalink / raw)
To: gdb-patches; +Cc: Stan Shebs, Marc Khouzam, Stan Shebs
On Thursday 18 March 2010 12:19:11, Pedro Alves wrote:
> Hmm, it seems I missed adding ensure_not_running to those then. Also, this
> in both until_command and advance_command:
>
> if (!target_has_execution)
> error (_("The program is not running."));
>
> could be replaced by ERROR_NO_INFERIOR.
This is fixed now with the patch below. Tested on x86_64-linux and
checked in.
--
Pedro Alves
2010-03-18 Pedro Alves <pedro@codesourcery.com>
gdb/
* infcmd.c (until_command): Use ERROR_NO_INFERIOR. Ensure there's
a valid selected thread, and that it is not running.
(advance_command): Ditto.
(finish_command): Ditto.
gdb/testsuite/
* gdb.base/default.exp: Adjust.
---
gdb/infcmd.c | 17 +++++++++--------
gdb/testsuite/gdb.base/default.exp | 6 +++---
2 files changed, 12 insertions(+), 11 deletions(-)
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c 2010-03-18 12:33:16.000000000 +0000
+++ src/gdb/infcmd.c 2010-03-18 13:01:35.000000000 +0000
@@ -1274,10 +1274,10 @@ until_command (char *arg, int from_tty)
{
int async_exec = 0;
- if (!target_has_execution)
- error (_("The program is not running."));
-
+ ERROR_NO_INFERIOR;
ensure_not_tfind_mode ();
+ ensure_valid_thread ();
+ ensure_not_running ();
/* Find out whether we must run in the background. */
if (arg != NULL)
@@ -1307,10 +1307,10 @@ advance_command (char *arg, int from_tty
{
int async_exec = 0;
- if (!target_has_execution)
- error (_("The program is not running."));
-
+ ERROR_NO_INFERIOR;
ensure_not_tfind_mode ();
+ ensure_valid_thread ();
+ ensure_not_running ();
if (arg == NULL)
error_no_arg (_("a location"));
@@ -1565,7 +1565,10 @@ finish_command (char *arg, int from_tty)
int async_exec = 0;
+ ERROR_NO_INFERIOR;
ensure_not_tfind_mode ();
+ ensure_valid_thread ();
+ ensure_not_running ();
/* Find out whether we must run in the background. */
if (arg != NULL)
@@ -1590,8 +1593,6 @@ finish_command (char *arg, int from_tty)
if (arg)
error (_("The \"finish\" command does not take any arguments."));
- if (!target_has_execution)
- error (_("The program is not running."));
frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
if (frame == 0)
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp 2010-03-18 12:56:43.000000000 +0000
+++ src/gdb/testsuite/gdb.base/default.exp 2010-03-18 12:58:07.000000000 +0000
@@ -250,7 +250,7 @@ gdb_expect {
}
#test finish
-gdb_test "finish" "The program is not running." "finish"
+gdb_test "finish" "The program is not being run." "finish"
#test forward-search
# The message here comes from the regexp library, not gdb, and so can
# vary on different systems.
@@ -753,9 +753,9 @@ gdb_test "tbreak" "No default breakpoint
#test tty
gdb_test "tty" "Argument required .filename to set it to\..*" "tty"
#test until "u" abbreviation
-gdb_test "u" "The program is not running." "until \"u\" abbreviation"
+gdb_test "u" "The program is not being run." "until \"u\" abbreviation"
#test until
-gdb_test "until" "The program is not running." "until"
+gdb_test "until" "The program is not being run." "until"
#test undisplay
# FIXME -- need to dump full output to detailed log
send_gdb "undisplay\n"
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] No resuming while tfinding
2010-03-17 1:59 [PATCH] No resuming while tfinding Stan Shebs
` (2 preceding siblings ...)
2010-03-17 15:22 ` Pedro Alves
@ 2010-03-18 16:05 ` Tom Tromey
2010-03-18 17:47 ` Stan Shebs
3 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2010-03-18 16:05 UTC (permalink / raw)
To: Stan Shebs; +Cc: gdb-patches
>>>>> "Stan" == Stan Shebs <stan@codesourcery.com> writes:
Stan> * infcmd.c (ensure_not_tfind_mode): New function.
Stan> (continue_1): Call it.
Stan> (step_1) Ditto.
Stan> (jump_command): Ditto.
Stan> (signal_command): Ditto.
Stan> (until_command): Ditto.
Stan> (finish_command): Ditto.
Does return_command also need to call ensure_not_tfind_mode?
Tom
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] No resuming while tfinding
2010-03-18 16:05 ` Tom Tromey
@ 2010-03-18 17:47 ` Stan Shebs
0 siblings, 0 replies; 13+ messages in thread
From: Stan Shebs @ 2010-03-18 17:47 UTC (permalink / raw)
To: tromey; +Cc: Stan Shebs, gdb-patches
Tom Tromey wrote:
> Does return_command also need to call ensure_not_tfind_mode?
>
It seemed less necessary, because it doesn't resume, it just scribbles
on the stack - in tfind mode the target kicks it back with write errors.
The previous discussion has gotten me to wondering whether it would be a
good idea to allow the user to write into a trace buffer. While it
sounds crazy at first, it can make sense for the same reasons that it
does in a live target; you have a hypothesis about how an expression
calculates out, stuff the hypothesized value in memory, and print the
expression.
It's a little more farfetched that return would be useful if writing
worked; if you had collected enough stack, you would see a backtrace
displayed as if the return had been done, but since you can't resume,
the exercise seems pointless.
Stan
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-03-18 17:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-17 1:59 [PATCH] No resuming while tfinding Stan Shebs
2010-03-17 13:51 ` Marc Khouzam
2010-03-17 15:19 ` Joel Brobecker
2010-03-17 17:36 ` Michael Snyder
2010-03-17 23:40 ` Stan Shebs
2010-03-17 23:44 ` Pedro Alves
2010-03-17 15:22 ` Pedro Alves
2010-03-17 17:31 ` Stan Shebs
2010-03-18 0:59 ` Stan Shebs
2010-03-18 12:19 ` Pedro Alves
2010-03-18 13:23 ` Pedro Alves
2010-03-18 16:05 ` Tom Tromey
2010-03-18 17:47 ` Stan Shebs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox