From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [209.51.188.92]) by sourceware.org (Postfix) with ESMTPS id 97EB43858402 for ; Sun, 28 Nov 2021 15:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97EB43858402 Received: from [2001:470:142:3::e] (port=36466 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrMI9-0000eN-Q7 for gdb@sourceware.org; Sun, 28 Nov 2021 10:40:37 -0500 Received: from ip5f5a8896.dynamic.kabel-deutschland.de ([95.90.136.150]:51021 helo=[192.168.111.41]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mrMI9-0004uZ-L5 for gdb@sourceware.org; Sun, 28 Nov 2021 10:40:37 -0500 Message-ID: <0a462ccc-d5ca-1b82-8dd2-646491b81944@gnu.org> Date: Sun, 28 Nov 2021 16:40:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US From: Simon Sobisch To: gdb@sourceware.org References: Subject: Re: Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2021 15:40:40 -0000 To answer my answer: No, it is currently not possible to do this via the frame decorator, there is a gdb.FrameDecoratpr.SymValueWrapper (which allows to add synthetic variables for frame locals), but nothing like a SymFrameWrapper which would allow to insert a synthetic frame. So the option I've used is to 1st create a frame filter with eliding frames, like below (#0, #2, #4 sample), which is by default deactivated 2nd add a new gdb.command of type gdb.COMMAND_STACK that does ffilter = gdb.frame_filters["my-eliding-filter"] ffilter.enabled = True btlines = gdb.execute("backtrace", True, True).split("\n") for line in btlines: print (line) # then print additional content ffilter.enabled = False This has the down-side that the coloring gets lost, but is otherwise "working". Simon Am 25.06.2021 um 00:24 schrieb Simon Sobisch: > Scenario: > > the current call-stack currently looks like > > #0 func3 > #1 func3_wrapper > #2 func2 > #3 func2_wrapper > #4 func1 > #5 func1_wrapper > #6 main > > > Using frame filters it is no problem to change that to either > > #0 func3 > #2 func2 > #4 func1 > > or > > #0 func3 >    #1 func3_wrapper > #2 func2 >    #3 func2_wrapper > #4 func1 >    #5 func1_wrapper > #6 main > > > Question: Is it possibly to also add a "virtual" stack entry (one could > select/up/down to), or at least show it in the backtrace? > > Something like the following: > > #0 func3 at ... >    #0.1  func3_part_a at ... >    #0.2  func3_part_c at ... >    #0.3  func3_part_b at ... >    #0.4  func3_part_a at ... >    #0.5  func3_start at ... > #2 func2 at ... > > > Background: > Each of those "func" entries in the stack have an internal frame > handling using a linked list that contains label address pointers. It > would be very cool to list those directly (currently only done with > additional commands local-backtrace and list-local-frame which I'd like > to drop). > > I _guess_ adding those to the shown stack may be possible, but likely > only with telling GDB about those (patching GDB), but maybe there's a > way to at least print those with their positions in "bt" using a frame > decorator? > > Thanks for answers, > Simon > >