This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] backtrace in mixed language applications
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Jerome Guitton <guitton at adacore dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Wed, 15 Aug 2007 12:18:34 -0700
- Subject: Re: [RFA] backtrace in mixed language applications
- References: <20070810100313.GA29799@adacore.com>
[I told Jerome about his attachments being encoded as video/dv]
> 2007-08-10 Jerome Guitton <guitton@adacore.com>
>
> * stack.c (backtrace_command_1): select the frame that we are
> about to print.
I'm uncertain about this one. I should have reviewed it when it was
checked in our tree...
> Index: stack.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stack.c,v
> retrieving revision 1.150
> diff -u -p -r1.150 stack.c
> --- stack.c 25 Jul 2007 00:28:25 -0000 1.150
> +++ stack.c 10 Aug 2007 09:41:20 -0000
> @@ -1104,12 +1104,14 @@ backtrace_command_1 (char *count_exp, in
> struct frame_info *fi;
> int count;
> int i;
> - struct frame_info *trailing;
> + struct frame_info *trailing, *selected_frame;
> int trailing_level;
>
> if (!target_has_stack)
> error (_("No stack."));
>
> + selected_frame = get_selected_frame (NULL);
> +
> /* The following code must do two things. First, it must set the
> variable TRAILING to the frame from which we should start
> printing. Second, it must set the variable count to the number
> @@ -1177,6 +1179,10 @@ backtrace_command_1 (char *count_exp, in
> {
> QUIT;
>
> + /* Select the frame that we are printing, so that the parameters
> + are displayed using the appropriate language. */
> + select_frame (fi);
> +
> /* Don't use print_stack_frame; if an error() occurs it probably
> means further attempts to backtrace would fail (on the other
> hand, perhaps the code does or could be fixed to make sure
> @@ -1188,6 +1194,7 @@ backtrace_command_1 (char *count_exp, in
> /* Save the last frame to check for error conditions. */
> trailing = fi;
> }
> + select_frame (selected_frame);
I think this opens the chance for the debugger to change the selected
frame if something goes wrong (or the user presses controlC), which is an
unexpected side-effect.
Also, I'm thinking this is the wrong place for doing this frame switch.
How about doing it inside print_frame? I think this would make sure
we cover all the cases where we print a frame, such as after an "up",
"down", or a "frame" command. And I think the frame selection needs
to be protected against error raising.
What do others think?
--
Joel