From patchwork Fri Sep 11 18:49:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 8651 Received: (qmail 55562 invoked by alias); 11 Sep 2015 18:50:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 55397 invoked by uid 89); 11 Sep 2015 18:50:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.1 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-f171.google.com Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 11 Sep 2015 18:50:01 +0000 Received: by wiclk2 with SMTP id lk2so68250743wic.1 for ; Fri, 11 Sep 2015 11:49:58 -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=AyuHga1rXBtIH0aJvT7teI/WStlDuZRm32jn1XJNxLo=; b=OeYU4Z4K02OiAS3bz5QchBEhEoQbDsfpnFoLXaMpYJlqWuY0curWCZjNqxdVwqQpvY ZNvrUfkGNOYKri3FxrKNUaVAJI7eXz7h2CquuWb2XI3610SMI6e9FeQB1Pt6PW4f0T9L Uu0CHKw6xBb3RK+uekv84KWbUzIEtx2u2bMyHhU4GG86bEfNdWOSBKgNun3hYDPzu4xo zPrR1bEI6bbQsBccLvry64nX9PZ6j80+xzfpqv8i6DKOuuLtQa5yoXZLnDuaMEZct4x6 T5pm+AWoRD7stBsAR2KAVPsIgBIuG7cZ7o+uUqT4nII+V4XS4dkz1z+Nu6R9uWXG4TVf gUVA== X-Gm-Message-State: ALoCoQkGUWVSO0vsyMxQF9VfK9V6KWFMV/yZ/gTOFvVWWUusL/Bbkc7fpCBh7poEZf35Lm/Q77aD X-Received: by 10.180.20.166 with SMTP id o6mr6820725wie.48.1441997398092; Fri, 11 Sep 2015 11:49:58 -0700 (PDT) Received: from localhost (host81-131-206-173.range81-131.btcentralplus.com. [81.131.206.173]) by smtp.gmail.com with ESMTPSA id pg5sm1678021wjb.21.2015.09.11.11.49.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 11:49:57 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 6/9] gdb: Avoid unneeded calls to parse_frame_specification. Date: Fri, 11 Sep 2015 19:49:40 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Within the stack command there are a couple of places where fixed strings are passed into functions that are really intended for processing user input. These fixed strings are then processed and the result returned. Given that the input strings in these cases are fixed, and are always "0", then the result will always be the same, the current frame. By switching to using get_current_frame instead the code can be simplified, and the intention of the code is clearer. gdb/ChangeLog: * stack.c (parse_frame_specification): Delete. (parse_frame_specification_1): Rename to parse_frame_specification. (frame_info): Use parse_frame_specification. (select_frame_command): Likewise. (return_command): Use select_frame and print_stack_frame rather than frame_command and select_frame_command. (func_command): Use get_current_frame rather than parse_frame_specification. --- gdb/ChangeLog | 12 ++++++++++++ gdb/stack.c | 21 +++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7c4b567..dccac52 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2015-09-11 Andrew Burgess + * stack.c (parse_frame_specification): Delete. + (parse_frame_specification_1): Rename to + parse_frame_specification. + (frame_info): Use parse_frame_specification. + (select_frame_command): Likewise. + (return_command): Use select_frame and print_stack_frame rather + than frame_command and select_frame_command. + (func_command): Use get_current_frame rather than + parse_frame_specification. + +2015-09-11 Andrew Burgess + * stack.c (func_command): Return early when there is no ARG string. diff --git a/gdb/stack.c b/gdb/stack.c index 1049995..1bc1fe6 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1280,8 +1280,8 @@ print_frame (struct frame_info *frame, int print_level, the default selected frame was used. */ static struct frame_info * -parse_frame_specification_1 (const char *frame_exp, const char *message, - int *selected_frame_p) +parse_frame_specification (const char *frame_exp, const char *message, + int *selected_frame_p) { int numargs; struct value *args[4]; @@ -1401,12 +1401,6 @@ parse_frame_specification_1 (const char *frame_exp, const char *message, error (_("Too many args in frame specification")); } -static struct frame_info * -parse_frame_specification (char *frame_exp) -{ - return parse_frame_specification_1 (frame_exp, NULL, NULL); -} - /* Print verbosely the selected frame or the frame at address ADDR_EXP. Absolutely all information in the frame is printed. */ @@ -1431,7 +1425,7 @@ frame_info (char *addr_exp, int from_tty) CORE_ADDR caller_pc = 0; int caller_pc_p = 0; - fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p); + fi = parse_frame_specification (addr_exp, "No stack.", &selected_frame_p); gdbarch = get_frame_arch (fi); /* During the following value will be created and then displayed. @@ -2293,7 +2287,7 @@ find_relative_frame (struct frame_info *frame, int *level_offset_ptr) void select_frame_command (char *level_exp, int from_tty) { - select_frame (parse_frame_specification_1 (level_exp, "No stack.", NULL)); + select_frame (parse_frame_specification (level_exp, "No stack.", NULL)); } /* The "frame" command. With no argument, print the selected frame @@ -2501,11 +2495,10 @@ return_command (char *retval_exp, int from_tty) if (get_frame_type (get_current_frame ()) == DUMMY_FRAME) frame_pop (get_current_frame ()); + select_frame (get_current_frame ()); /* If interactive, print the frame that is now current. */ if (from_tty) - frame_command ("0", 1); - else - select_frame_command ("0", 0); + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); } /* Sets the scope to input function name, provided that the function @@ -2530,7 +2523,7 @@ func_command (char *arg, int from_tty) if (arg == NULL) return; - frame = parse_frame_specification ("0"); + frame = get_current_frame (); sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE); cleanups = make_cleanup (xfree, sals.sals); func_bounds = XNEWVEC (struct function_bounds, sals.nelts);