From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55764 invoked by alias); 11 Sep 2015 18:50:09 -0000 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 Received: (qmail 55733 invoked by uid 89); 11 Sep 2015 18:50:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-wi0-f179.google.com Received: from mail-wi0-f179.google.com (HELO mail-wi0-f179.google.com) (209.85.212.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 11 Sep 2015 18:50:04 +0000 Received: by wicge5 with SMTP id ge5so73838107wic.0 for ; Fri, 11 Sep 2015 11:50:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=yaCaTdLd+e8jpNd+gZYt+L0EDl/OOThiilvi3wjJTLc=; b=foSz1aSJNPtzZg6oIZuncH6qeuIj/CIzuqLK4s0MYGpM1jYYyf8+/lEjkB0A04lcUP gqF48czfv6yTxEYx4MePv2wsoUcbqo5+rTzhXN15Fpn/5WHKdhmFnZR+IPST88cufP66 1gPhlOPZ/b1h8dghjT6NfiUzjxumYf/KgEO4zddMZ+v5A2w4IGqmWSf5yMAMM77Tln+E cpwlLX5ofSLgSkPVOmnFuRlOm851IY5/i8BJ12IEdE4JdDnz4hqrBozwidYppX2XYcCu aUZ113mZabobaQMk/7wPVGq3WYQRtKS1dCKmLAp3zcLqXGnPKmlXMl5CVE/ABKKbKy2y CNvA== X-Gm-Message-State: ALoCoQm+vVbCrifY8oUdtf44OCA/f4NpB8NslxryJiDyTvOreFRA7TyMtlt6YGN75DPkhO4PDNjU X-Received: by 10.180.84.163 with SMTP id a3mr19870414wiz.34.1441997401355; Fri, 11 Sep 2015 11:50:01 -0700 (PDT) Received: from localhost (host81-131-206-173.range81-131.btcentralplus.com. [81.131.206.173]) by smtp.gmail.com with ESMTPSA id uo6sm1702986wjc.1.2015.09.11.11.50.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 11:50:00 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 8/9] gdb: Split func_command into two parts. Date: Fri, 11 Sep 2015 18:50:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00251.txt.bz2 The func_command function is used to emulate the dbx 'func' command. However, finding a stack frame based on function name might be a useful feature, and so the core of func_command is now split out into a separate function. gdb/ChangeLog: * stack.c (select_and_print_frame): Delete. (func_command): Most content moved into new function find_frame_for_function, use new function, print result, add function comment. (find_frame_for_function): New function, now returns a result. --- gdb/ChangeLog | 8 ++++++++ gdb/stack.c | 49 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d530d06..9da954d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2015-09-11 Andrew Burgess + * stack.c (select_and_print_frame): Delete. + (func_command): Most content moved into new function + find_frame_for_function, use new function, print result, add + function comment. + (find_frame_for_function): New function, now returns a result. + +2015-09-11 Andrew Burgess + * stack.c (parse_frame_specification): Remove message parameter, replace with fixed string in function body, update function comment. diff --git a/gdb/stack.c b/gdb/stack.c index 9cde1e5..71e171a 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2211,15 +2211,6 @@ args_info (char *ignore, int from_tty) gdb_stdout); } -/* Select frame FRAME. Also print the stack frame and show the source - if this is the tui version. */ -static void -select_and_print_frame (struct frame_info *frame) -{ - select_frame (frame); - if (frame) - print_stack_frame (frame, 1, SRC_AND_LOC, 1); -} /* Return the symbol-block in which the selected frame is executing. Can return zero under various legitimate circumstances. @@ -2507,8 +2498,11 @@ struct function_bounds CORE_ADDR low, high; }; -static void -func_command (char *arg, int from_tty) +/* Find stack frame for a function matching FUNCTION_NAME. If there is no + matching stack frame then return NULL. */ + +static struct frame_info * +find_frame_for_function (char *function_name) { struct frame_info *frame; int found = 0; @@ -2518,11 +2512,11 @@ func_command (char *arg, int from_tty) struct function_bounds *func_bounds = NULL; struct cleanup *cleanups; - if (arg == NULL) - return; + gdb_assert (function_name != NULL); frame = get_current_frame (); - sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_current_source (function_name, + DECODE_LINE_FUNFIRSTLINE); cleanups = make_cleanup (xfree, sals.sals); func_bounds = XNEWVEC (struct function_bounds, sals.nelts); make_cleanup (xfree, func_bounds); @@ -2555,10 +2549,31 @@ func_command (char *arg, int from_tty) do_cleanups (cleanups); if (!found) - printf_filtered (_("'%s' not within current stack frame.\n"), arg); - else if (frame != get_selected_frame (NULL)) - select_and_print_frame (frame); + frame = NULL; + + return frame; } + +/* Implements the dbx 'func' command. */ + +static void +func_command (char *arg, int from_tty) +{ + struct frame_info *frame; + + if (arg == NULL) + return; + + frame = find_frame_for_function (arg); + if (frame == NULL) + error (_("'%s' not within current stack frame.\n"), arg); + if (frame != get_selected_frame (NULL)) + { + select_frame (frame); + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); + } +} + /* Provide a prototype to silence -Wmissing-prototypes. */ -- 2.5.1