From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27833 invoked by alias); 2 Oct 2012 17:58:51 -0000 Received: (qmail 27825 invoked by uid 22791); 2 Oct 2012 17:58:49 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-da0-f41.google.com (HELO mail-da0-f41.google.com) (209.85.210.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Oct 2012 17:58:44 +0000 Received: by dadi14 with SMTP id i14so2155385dad.0 for ; Tue, 02 Oct 2012 10:58:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.202.6 with SMTP id ke6mr6213431pbc.82.1349200723548; Tue, 02 Oct 2012 10:58:43 -0700 (PDT) Received: by 10.68.218.41 with HTTP; Tue, 2 Oct 2012 10:58:43 -0700 (PDT) Date: Tue, 02 Oct 2012 17:58:00 -0000 Message-ID: Subject: [PATCH] Add option to control checking of inner frames when doing a backtrace From: Joshua Watt To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00024.txt.bz2 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. 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."),