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]

RE: [PATCH] Add option to control checking of inner frames when doing a backtrace


Hi,
You may need copyright assignment. Also the patch needs change log entry. See some of my comments inline. 


> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Joshua Watt
> Sent: Tuesday, October 02, 2012 6:59 PM
> To: gdb-patches@sourceware.org
> Subject: [PATCH] Add option to control checking of inner frames when
> doing a backtrace
> 
> Please note: this is the first patch I have ever submitted for GDB, so
> please let
> me know if there are any problems. -- Joshua Watt
> 
> 
> This patch allows the user to turn off the checking for inner frames
> when performing
> a backtrace using the command:
> 
> set backtrace check-inner off
> 
> This is useful if a thread is switching execution to run on another
> stack, as this will
> often cause the inner frame condition to fail.

I don't understand the motivation. Can you please explain a bit more.

> 
> diff -U 5 -Nar gdb-7.5.50.20121002-orig/gdb/frame.c
> gdb-7.5.50.20121002/gdb/frame.c
> --- gdb-7.5.50.20121002-orig/gdb/frame.c 2012-09-17 02:15:48 -0500
> +++ gdb-7.5.50.20121002/gdb/frame.c 2012-10-02 12:25:47 -0500
> @@ -205,10 +205,20 @@
>      _("An upper bound on the number "
>        "of backtrace levels is %s.\n"),
>      value);
>  }
> 
> +static unsigned int backtrace_check_inner = TRUE;
> +static void
> +show_backtrace_check_inner (struct ui_file *file, int from_tty,
> +   struct cmd_list_element *c, const char *value)
> +{
> +  fprintf_filtered (file, _("Whether backtraces should check for inner
> "
> +    "frames is %s.\n"),
> +    value);
> +}
> +
> 
>  static void
>  fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR
> addr)
>  {
>    if (p)
> @@ -1670,11 +1680,12 @@
> 
>    /* Check that this frame's ID isn't inner to (younger, below, next)
>       the next frame.  This happens when a frame unwind goes backwards.
>       This check is valid only if this frame and the next frame are
> NORMAL.
>       See the comment at frame_id_inner for details.  */
> -  if (get_frame_type (this_frame) == NORMAL_FRAME
> +  if (backtrace_check_inner
> +      && get_frame_type (this_frame) == NORMAL_FRAME
>        && this_frame->next->unwind->type == NORMAL_FRAME
>        && frame_id_inner (get_frame_arch (this_frame->next), this_id,
>   get_frame_id (this_frame->next)))
>      {
>        CORE_ADDR this_pc_in_block;
> @@ -2504,10 +2515,25 @@
>      NULL,
>      show_backtrace_limit,
>      &set_backtrace_cmdlist,
>      &show_backtrace_cmdlist);
> 
> +  add_setshow_boolean_cmd ("check-inner", class_obscure,
> +   &backtrace_check_inner, _("\
> +Sets whether backtraces will check if a frame is inner to the previous
> frame"),
> +   _("\
> +Shows whether backtraces will check if a frame is inner to the
> previous frame"),
> +   _("\
> +Normally frames are laid out in a specific order on the stack.  This
> controls\n\
> +whether GDB will validate that the frames are in the correct order.
> Frames\n\
> +can commonly be out of order if a thread switches to a different
> stack during\n\
> +execution"),
> +   NULL,
> +   show_backtrace_check_inner,
> +   &set_backtrace_cmdlist,
> +   &show_backtrace_cmdlist);
> +
>    /* Debug this files internals.  */
>    add_setshow_zuinteger_cmd ("frame", class_maintenance, &frame_debug,
> _("\
>  Set frame debugging."), _("\
>  Show frame debugging."), _("\
>  When non-zero, frame specific internal debugging is enabled."),

This command will need documentation(see gdb/doc/gdb.texinfo in GDB source base).
 
Regards,
Abid
--
Hafiz Abid Qadeer
Mentor Graphics
hafiz_abid@mentor.com
+44 161 926 1630


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