Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: Felix Lee <felix.1@canids.net>
Cc: gdb-patches@sources.redhat.com
Subject: Re: backtrace changes current source location
Date: Mon, 01 Nov 2004 16:04:00 -0000	[thread overview]
Message-ID: <4186462E.5080103@gnu.org> (raw)
In-Reply-To: <20041101043803.A261E50346B@stray.canids>

Felix Lee wrote:
> ok, here's a new patch and testcase.  built and tested on
> i686-pc-linux-gnu.  the testcase adds 7 PASS and 1 FAIL, which
> becomes 8 PASS with the patch.
> 
> gdb/ChangeLog
> 2004-10-31  Felix Lee  <felix+log1@specifixinc.com>
> 
>         * stack.c (set_current_sal_from_frame): New function.
>         (print_args_stub): Use it.
>         (print_frame_info): Don't set sal here.

Hey, cute.  Yes, thanks!

Andrew

> gdb/testsuite/ChangeLog
> 2004-10-31  Felix Lee  <felix+log1@specifixinc.com>
> 
>         * gdb.base/cursal.exp: New file.
>         * gdb.base/cursal.c: New file.
> 
> Index: gdb/stack.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stack.c,v
> retrieving revision 1.115
> diff -p -u -r1.115 stack.c
> --- gdb/stack.c	30 Oct 2004 21:16:10 -0000	1.115
> +++ gdb/stack.c	31 Oct 2004 10:42:55 -0000
> @@ -100,6 +100,8 @@ static void print_frame (struct frame_in
>  			 int print_args, 
>  			 struct symtab_and_line sal);
>  
> +static void set_current_sal_from_frame (struct frame_info *, int);
> +
>  static void backtrace_command (char *, int);
>  
>  static void frame_info (char *, int);
> @@ -128,9 +130,12 @@ struct print_stack_frame_args
>  static int
>  print_stack_frame_stub (void *args)
>  {
> -  struct print_stack_frame_args *p = (struct print_stack_frame_args *) args;
> +  struct print_stack_frame_args *p = args;
> +  int center = (p->print_what == SRC_LINE
> +                || p->print_what == SRC_AND_LOC);
>  
>    print_frame_info (p->fi, p->print_level, p->print_what, p->print_args);
> +  set_current_sal_from_frame (p->fi, center);
>    return 0;
>  }
>  
> @@ -401,6 +406,24 @@ print_args_stub (void *args)
>    return 0;
>  }
>  
> +/* Set the current source and line to the location of the given
> +   frame, if possible.  When CENTER is true, adjust so the
> +   relevant line is in the center of the next 'list'. */
> +
> +static void
> +set_current_sal_from_frame (struct frame_info *fi, int center)
> +{
> +  struct symtab_and_line sal;
> +
> +  find_frame_sal (fi, &sal);
> +  if (sal.symtab)
> +    {
> +      if (center)
> +        sal.line = max (sal.line - get_lines_to_list () / 2, 1);
> +      set_current_source_symtab_and_line (&sal);
> +    }
> +}
> +
>  /* Print information about a frame for frame "fi" at level "level".
>     Used in "where" output, also used to emit breakpoint or step
>     messages.  
> @@ -477,12 +500,8 @@ print_frame_info (struct frame_info *fi,
>  
>    source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC);
>  
> -  if (sal.symtab)
> -    set_current_source_symtab_and_line (&sal);
> -
>    if (source_print && sal.symtab)
>      {
> -      struct symtab_and_line cursal;
>        int done = 0;
>        int mid_statement = ((print_what == SRC_LINE)
>  			   && (get_frame_pc (fi) != sal.pc));
> @@ -513,11 +532,6 @@ print_frame_info (struct frame_info *fi,
>  	      print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
>  	    }
>  	}
> -      /* Make sure we have at least a default source file */
> -      set_default_source_symtab_and_line ();
> -      cursal = get_current_source_symtab_and_line ();
> -      cursal.line = max (sal.line - get_lines_to_list () / 2, 1);
> -      set_current_source_symtab_and_line (&cursal);
>      }
>  
>    if (print_what != LOCATION)
> Index: gdb/testsuite/gdb.base/cursal.c
> ===================================================================
> RCS file: gdb/testsuite/gdb.base/cursal.c
> diff -N gdb/testsuite/gdb.base/cursal.c
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gdb/testsuite/gdb.base/cursal.c	31 Oct 2004 10:42:55 -0000
> @@ -0,0 +1,19 @@
> +void
> +func2 ()
> +{
> +  int v2 = 2;
> +}
> +
> +void
> +func1 ()
> +{
> +  func2 ();
> +}
> +
> +
> +int
> +main ()
> +{
> +  int v0 = 0;
> +  func1 ();
> +}
> Index: gdb/testsuite/gdb.base/cursal.exp
> ===================================================================
> RCS file: gdb/testsuite/gdb.base/cursal.exp
> diff -N gdb/testsuite/gdb.base/cursal.exp
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gdb/testsuite/gdb.base/cursal.exp	31 Oct 2004 10:42:55 -0000
> @@ -0,0 +1,78 @@
> +# Copyright 2004 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 2 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, write to the Free Software
> +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
> +
> +if $tracelevel {
> +    strace $tracelevel
> +}
> +
> +set prms_id 0
> +set bug_id 0
> +
> +set testfile "cursal"
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
> +
> +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != ""} {
> +    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> +}
> +
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +gdb_load ${binfile}
> +
> +gdb_test "set listsize 1" \
> +    ".*"
> +
> +# initial sal should be first statement in main
> +gdb_test "list" \
> +    "v0 = 0;" \
> +    "list before run"
> +
> +if {! [runto_main]} {
> +    gdb_suppress_tests
> +}
> +
> +gdb_test "list" \
> +    "v0 = 0;" \
> +    "list in main"
> +
> +if {! [runto "func2"]} {
> +    gdb_suppress_tests
> +}
> +
> +gdb_test "list" \
> +    "v2 = 2;" \
> +    "list in func2"
> +
> +# make sure backtrace doesn't change current source location.
> +gdb_test "backtrace" \
> +    ".*"
> +gdb_test "list -1" \
> +    "v2 = 2;" \
> +    "list after backtrace"
> +
> +# check the window
> +gdb_test "set listsize 3" \
> +    ".*"
> +if {! [runto_main]} {
> +    gdb_suppress_tests
> +}
> +gdb_test "list" \
> +    "func1 \\(\\);" \
> +    "list size 3"
> +
> +return 0
> 


  reply	other threads:[~2004-11-01 16:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041026075115.4A2C354AAB5@stray.canids>
     [not found] ` <20041026132924.GA26886@nevyn.them.org>
     [not found]   ` <drow@false.org>
2004-10-26 15:01     ` Felix Lee
2004-10-27 17:35       ` Andrew Cagney
2004-10-27 17:40         ` Daniel Jacobowitz
2004-10-28  0:52         ` Felix Lee
2004-10-29 15:22           ` Andrew Cagney
2004-10-29 15:36             ` Daniel Jacobowitz
2004-10-29 22:07             ` Felix Lee
2004-10-30  0:02               ` Andrew Cagney
2004-10-30  3:28                 ` Felix Lee
2004-11-01  4:38                   ` Felix Lee
2004-11-01 16:04                     ` Andrew Cagney [this message]
2004-11-01 16:13                     ` Daniel Jacobowitz
2004-11-05  8:51     ` Felix Lee
2006-10-04 20:43     ` [patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines David Edelsohn
2006-10-04 20:52       ` Daniel Jacobowitz
2005-08-15 13:37 Procedure for large drop? Paul Hilfinger
2005-08-15 14:15 ` Daniel Jacobowitz
2005-08-15 21:50   ` Paul Hilfinger
2005-08-16  2:36     ` Jason Molenda
2005-08-20 22:15   ` Paul Hilfinger
2005-08-22 19:00     ` Daniel Jacobowitz
2006-10-04 19:00 [patch] Pushing Inferior Function Arguments onto Stack on PowerPC64 machines janani
2006-10-04 19:11 ` Daniel Jacobowitz
2006-10-04 19:14   ` Daniel Jacobowitz
2006-10-04 20:19   ` Mark Kettenis
2006-10-04 20:27     ` Andreas Schwab
     [not found]   ` <OFE88464A1.C58B072A-ON872571FD.006ABA69-862571FD.006C7CFB@us.ibm.com>
2006-10-04 20:26     ` Daniel Jacobowitz

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=4186462E.5080103@gnu.org \
    --to=cagney@gnu.org \
    --cc=felix.1@canids.net \
    --cc=gdb-patches@sources.redhat.com \
    /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