This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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.

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.

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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]