From patchwork Sun Oct 20 06:48:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 35179 Received: (qmail 130871 invoked by alias); 20 Oct 2019 06:48:50 -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 130846 invoked by uid 89); 20 Oct 2019 06:48:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=Previously, H*r:sk:DB5EUR0, safer, infcmdc X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-oln040092065076.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.92.65.76) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 20 Oct 2019 06:48:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elb+GTSJh+48OBcSs9drFNPFZnWShasfUlktKf1DFWJbMJWvY+gB/p/D66eHXsrtN0dCYwWQYU9rsOEWMasmGYxxAeSGm21XinyywSp1P5N74LRK25QHkqmL/m/eXTBmGs6IyYTByyexLmcdlkRYKaiD4dCTnkRicrLXqJfo449y7w8JViKsIclRRYv1MMcdAimRV+1HUXURAajk04IqrWilLuIhiWyfBVBxgn+VJJbxk1Yj3hF0pW4tCtomZLYaqslnaM+y7cyo62PAniKFBPbre4uZT2d0kLVK1X9p4+qVtN4hX4V1upuQs9ldX3PybTzoLjyQWaHSSSoysAXDWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RI0u2/kpVOwbltw1gomNOMrnL4hxJ/QXThUAt4r0luA=; b=eLW2XeOeUNXYJi+bt0nLu60Dx+M6mLzxv0VebOG0wcGdCSAdDoAgTuMcXxKOVvDa7x2PDIn2eZdnStcQuAN+us8qCw1YWxC7AomQVJ3ozCc6ReDF/tljVb5CpbbIIfeNShwsmLT/08cQ+dpP6TVlRu8o2tYs9FZlI+H4GYso1XNlwGR2QDVz46wfW2rvv1NcXYAYB/CmMRJC5zaN4EeGBrioJnQYq4vR7Rn5YDXFF+mCaLEYvC7QJFnMK8UYgSRc3PcV6MiEUkc5vtJ+aBtX8ik+PK2MPtV+Vho7YtM4eYVRUQrKf1cjH+uM4WmhfPYdDitdMXzjsaOhCJCT775Kcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DB5EUR01FT035.eop-EUR01.prod.protection.outlook.com (10.152.4.55) by DB5EUR01HT145.eop-EUR01.prod.protection.outlook.com (10.152.5.239) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.14; Sun, 20 Oct 2019 06:48:44 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com (10.152.4.54) by DB5EUR01FT035.mail.protection.outlook.com (10.152.4.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.14 via Frontend Transport; Sun, 20 Oct 2019 06:48:44 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::f12a:6f14:2368:e758]) by VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::f12a:6f14:2368:e758%4]) with mapi id 15.20.2347.028; Sun, 20 Oct 2019 06:48:44 +0000 From: Bernd Edlinger To: "gdb-patches@sourceware.org" Subject: [PATCHv2] Make "skip" work on inline frames Date: Sun, 20 Oct 2019 06:48:44 +0000 Message-ID: References: In-Reply-To: x-microsoft-original-message-id: <369d3970-0dc2-fba0-a9b9-4ec929f63297@hotmail.de> x-ms-exchange-transport-forked: True MIME-Version: 1.0 On 10/19/19 6:38 AM, Bernd Edlinger wrote: > Hmm, > > I noticed that the patch does not yet handle > the step correctly, the count is decremented > although the inline frame is skipped and should not be > counted... > > Thus I will need to change at least this: > > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -1122,7 +1122,6 @@ prepare_one_step (struct step_command_fsm *sm) > set_running (resume_ptid, 1); > > step_into_inline_frame (tp); > - sm->count--; > > sal = find_frame_sal (frame); > sym = get_frame_function (frame); > @@ -1132,13 +1131,17 @@ prepare_one_step (struct step_command_fsm *sm) > > if (sal.line == 0 > || !function_name_is_marked_for_skip (fn, sal)) > - return prepare_one_step (sm); > + { > + sm->count--; > + return prepare_one_step (sm); > + } > } > > Attached is an updated patch that fixes this issue, and also adds the following after step_into_inline_frame (): frame = get_current_frame (); That I consider safer, since this function calls reinit_frame_cache (). It was probably just by chance that this did not seem to cause any problems for me. Thanks Bernd. From fa00b1890e525b4e8e9a8397bddfa9963c253080 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Fri, 18 Oct 2019 14:28:45 +0200 Subject: [PATCH] Check all inline frames if they are marked for skip. This makes the skip command work in optimized builds, where skipped functions may be inlined. Previously that was only working when stepping into a non-inlined function. --- gdb/infcmd.c | 20 ++++++++++++++++++-- gdb/infrun.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 7105774..f4c183c 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -58,6 +58,7 @@ #include "thread-fsm.h" #include "top.h" #include "interps.h" +#include "skip.h" #include "gdbsupport/gdb_optional.h" #include "source.h" #include "cli/cli-style.h" @@ -1112,14 +1113,29 @@ prepare_one_step (struct step_command_fsm *sm) && inline_skipped_frames (tp)) { ptid_t resume_ptid; + const char *fn = NULL; + symtab_and_line sal; + struct symbol *sym; /* Pretend that we've ran. */ resume_ptid = user_visible_resume_ptid (1); set_running (resume_ptid, 1); step_into_inline_frame (tp); - sm->count--; - return prepare_one_step (sm); + + frame = get_current_frame (); + sal = find_frame_sal (frame); + sym = get_frame_function (frame); + + if (sym != NULL) + fn = SYMBOL_PRINT_NAME (sym); + + if (sal.line == 0 + || !function_name_is_marked_for_skip (fn, sal)) + { + sm->count--; + return prepare_one_step (sm); + } } pc = get_frame_pc (frame); diff --git a/gdb/infrun.c b/gdb/infrun.c index 07aebfa..04c1eee 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4041,6 +4041,45 @@ stepped_in_from (struct frame_info *frame, struct frame_id step_frame_id) return 0; } +/* Look for an inline frame that is marked for skip. + If PREV_FRAME is TRUE start at the previous frame, + otherwise start at the current frame. Stop at the + first non-inline frame, or at the frame where the + step started. */ + +static bool +inline_frame_is_marked_for_skip (bool prev_frame, struct thread_info *tp) +{ + struct frame_info *frame = get_current_frame (); + + if (prev_frame) + frame = get_prev_frame (frame); + + for (; frame != NULL; frame = get_prev_frame (frame)) + { + const char *fn = NULL; + symtab_and_line sal; + struct symbol *sym; + + if (frame_id_eq (get_frame_id (frame), tp->control.step_frame_id)) + break; + if (get_frame_type (frame) != INLINE_FRAME) + break; + + sal = find_frame_sal (frame); + sym = get_frame_function (frame); + + if (sym != NULL) + fn = SYMBOL_PRINT_NAME (sym); + + if (sal.line != 0 + && function_name_is_marked_for_skip (fn, sal)) + return true; + } + + return false; +} + /* If the event thread has the stop requested flag set, pretend it stopped for a GDB_SIGNAL_0 (i.e., as if it stopped due to target_stop). */ @@ -6531,7 +6570,8 @@ process_event_stop_test (struct execution_control_state *ecs) tmp_sal = find_pc_line (ecs->stop_func_start, 0); if (tmp_sal.line != 0 && !function_name_is_marked_for_skip (ecs->stop_func_name, - tmp_sal)) + tmp_sal) + && !inline_frame_is_marked_for_skip (true, ecs->event_thread)) { if (execution_direction == EXEC_REVERSE) handle_step_into_function_backward (gdbarch, ecs); @@ -6697,7 +6737,14 @@ process_event_stop_test (struct execution_control_state *ecs) if (call_sal.line == ecs->event_thread->current_line && call_sal.symtab == ecs->event_thread->current_symtab) - step_into_inline_frame (ecs->event_thread); + { + step_into_inline_frame (ecs->event_thread); + if (inline_frame_is_marked_for_skip (false, ecs->event_thread)) + { + keep_going (ecs); + return; + } + } end_stepping_range (ecs); return; @@ -6731,7 +6778,8 @@ process_event_stop_test (struct execution_control_state *ecs) fprintf_unfiltered (gdb_stdlog, "infrun: stepping through inlined function\n"); - if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL) + if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL + || inline_frame_is_marked_for_skip (false, ecs->event_thread)) keep_going (ecs); else end_stepping_range (ecs); -- 1.9.1