Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stan Shebs <stan@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Make tfind work if thread is running
Date: Mon, 12 Apr 2010 23:51:00 -0000	[thread overview]
Message-ID: <4BC3B1E7.2050401@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

This patch makes it possible to get into tfind mode even if the current 
thread is running (aka non-stop mode) or has no stack frames for some 
other reason.

It would be good to add a testsuite test for this, but it seems there 
are no tests of non-stop outside of MI?  Are there difficult portability 
issues perhaps?

Stan

2010-04-12  Stan Shebs  <stan@codesourcery.com>

    * frame.c: Include tracepoint.h.
    (get_current_frame): Allow a trace frame to be an alternate source
    of stack frame data.
    * tracepoint.c (tfind_1): Don't try to get current stack frame if
    it won't succeed.




[-- Attachment #2: tfindnonstop-patch-1 --]
[-- Type: text/plain, Size: 4322 bytes --]

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.279
diff -p -r1.279 frame.c
*** frame.c	28 Jan 2010 22:07:58 -0000	1.279
--- frame.c	12 Apr 2010 21:11:25 -0000
***************
*** 43,48 ****
--- 43,49 ----
  #include "gdbthread.h"
  #include "block.h"
  #include "inline-frame.h"
+ #include  "tracepoint.h"
  
  static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
  static struct frame_info *get_prev_frame_raw (struct frame_info *this_frame);
*************** get_current_frame (void)
*** 1144,1155 ****
      error (_("No stack."));
    if (!target_has_memory)
      error (_("No memory."));
!   if (ptid_equal (inferior_ptid, null_ptid))
!     error (_("No selected thread."));
!   if (is_exited (inferior_ptid))
!     error (_("Invalid selected thread."));
!   if (is_executing (inferior_ptid))
!     error (_("Target is executing."));
  
    if (current_frame == NULL)
      {
--- 1145,1160 ----
      error (_("No stack."));
    if (!target_has_memory)
      error (_("No memory."));
!   /* Traceframes are effectively a substitute for the live inferior.  */
!   if (get_traceframe_number () < 0)
!     {
!       if (ptid_equal (inferior_ptid, null_ptid))
! 	error (_("No selected thread."));
!       if (is_exited (inferior_ptid))
! 	error (_("Invalid selected thread."));
!       if (is_executing (inferior_ptid))
! 	error (_("Target is executing."));
!     }
  
    if (current_frame == NULL)
      {
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.177
diff -p -r1.177 tracepoint.c
*** tracepoint.c	9 Apr 2010 20:46:40 -0000	1.177
--- tracepoint.c	12 Apr 2010 21:11:25 -0000
*************** tfind_1 (enum trace_find_type type, int 
*** 1856,1866 ****
  	 int from_tty)
  {
    int target_frameno = -1, target_tracept = -1;
!   struct frame_id old_frame_id;
    char *reply;
    struct breakpoint *tp;
  
!   old_frame_id = get_frame_id (get_current_frame ());
  
    target_frameno = target_trace_find (type, num, addr1, addr2,
  				      &target_tracept);
--- 1856,1874 ----
  	 int from_tty)
  {
    int target_frameno = -1, target_tracept = -1;
!   struct frame_id old_frame_id = null_frame_id;
    char *reply;
    struct breakpoint *tp;
  
!   /* Only try to get the current stack frame if we have a chance of
!      succeeding.  In particular, if we're trying to get a first trace
!      frame while all threads are running, it's not going to succeed,
!      so leave it with a default value and let the frame comparison
!      below (correctly) decide to print out the source location of the
!      trace frame.  */
!   if (!(type == tfind_number && num == -1)
!       && (has_stack_frames () || traceframe_number >= 0))
!     old_frame_id = get_frame_id (get_current_frame ());
  
    target_frameno = target_trace_find (type, num, addr1, addr2,
  				      &target_tracept);
*************** tfind_1 (enum trace_find_type type, int 
*** 1873,1879 ****
      }
    else if (target_frameno == -1)
      {
!       /* A request for a non-existant trace frame has failed.
  	 Our response will be different, depending on FROM_TTY:
  
  	 If FROM_TTY is true, meaning that this command was 
--- 1881,1887 ----
      }
    else if (target_frameno == -1)
      {
!       /* A request for a non-existent trace frame has failed.
  	 Our response will be different, depending on FROM_TTY:
  
  	 If FROM_TTY is true, meaning that this command was 
*************** tfind_1 (enum trace_find_type type, int 
*** 1952,1958 ****
      {
        enum print_what print_what;
  
!       /* NOTE: in immitation of the step command, try to determine
           whether we have made a transition from one function to
           another.  If so, we'll print the "stack frame" (ie. the new
           function and it's arguments) -- otherwise we'll just show the
--- 1960,1966 ----
      {
        enum print_what print_what;
  
!       /* NOTE: in imitation of the step command, try to determine
           whether we have made a transition from one function to
           another.  If so, we'll print the "stack frame" (ie. the new
           function and it's arguments) -- otherwise we'll just show the

             reply	other threads:[~2010-04-12 23:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-12 23:51 Stan Shebs [this message]
2010-04-13 12:45 ` Pedro Alves
2010-04-17 18:26 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BC3B1E7.2050401@codesourcery.com \
    --to=stan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox