From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 85F7E3857C61 for ; Thu, 25 Mar 2021 03:47:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85F7E3857C61 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 12P3lXWX028320 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Mar 2021 23:47:38 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 12P3lXWX028320 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 2C9221E590; Wed, 24 Mar 2021 23:47:33 -0400 (EDT) Subject: Re: Need help with understanding truncated and corrupted backtraces To: Eli Zaretskii , gdb-patches@sourceware.org References: <83lfandydz.fsf@gnu.org> From: Simon Marchi Message-ID: <6c4e73b8-6c0d-4c9c-a4ae-8de85976fde1@polymtl.ca> Date: Wed, 24 Mar 2021 23:47:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 25 Mar 2021 03:47:33 +0000 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Mar 2021 03:47:45 -0000 > It would therefore be interesting to know which unwinder is selected for > each frame: the unwinder that uses the DWARF debug info or the heuristic > unwinder. Unfortunately, "set debug frame 1" doesn't seem to show any > information about that. You could always break on the > frame_unwind_find_by_frame function to find that out. But I think it > would be benificial to everyone to add some debug output in that > function, to say things like: > > Trying unwinder foo for frame 1 -> nope > Trying unwinder bar for frame 1 -> yes! I implemented this, it is available on the users/simark/frame-debug branch on sourceware: https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/simark/frame-debug It is not suitable for an upstream submission yet, but you can give it a try. I converted the "debug frame" messages to the new-ish system, which nests messages. It dramatically improves readability, IMO. Here's a small example of what you can expect: [frame] get_prev_frame: enter [frame] get_prev_frame_always_1: enter [frame] get_prev_frame_always_1: this_frame=-1 [frame] get_prev_frame_always_1: -> {level=0, type=, unwind=, pc=0x7ffff7fd08e8, id=, func=} // cached [frame] get_prev_frame_always_1: exit [frame] get_prev_frame: exit [frame] compute_frame_id: enter [frame] compute_frame_id: fi=0 [frame] frame_unwind_find_by_frame: enter [frame] frame_unwind_find_by_frame: this_frame=0 [frame] frame_unwind_try_unwinder: trying unwinder "dummy" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "dwarf2 tailcall" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "inline" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "jit" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "python" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "amd64 epilogue" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "i386 epilogue" [frame] frame_unwind_try_unwinder: no [frame] frame_unwind_try_unwinder: trying unwinder "dwarf2" [frame] frame_unwind_try_unwinder: yes [frame] frame_unwind_find_by_frame: exit [frame] get_frame_func_if_available: this_frame=0 -> 0x7ffff7fce4c0 [frame] frame_id_p: l={!stack, !code, !special} -> 0 [frame] frame_unwind_register_value: frame=-1, regnum=6(rbp) [frame] frame_unwind_register_value: -> register=6 bytes=[b0ddffffff7f0000] [frame] frame_unwind_arch: next_frame=0 -> i386:x86-64 [frame] frame_unwind_register_value: frame=0, regnum=16(rip) [frame] frame_unwind_register_value: -> address=0x7fffffffddb8 bytes=[9f86fef7ff7f0000] [frame] frame_id_p: l={stack=0x7fffffffddc0, code=0x7ffff7fce4c0, !special} -> 1 [frame] compute_frame_id: -> {stack=0x7fffffffddc0, code=0x7ffff7fce4c0, !special} [frame] compute_frame_id: exit > > Once you know which unwinder is selected for each frame, you can try to > find starting at which unwind things went wrong and focus on that one. > > And if this is indeed what is happening to you (the heuristic unwinder > gets things wrong), I see two choices: > > - make the JIT producer generate DWARF info for the JIT-ed code, which > will make GDB use the DWARF-based unwinder > - improve the heuristic-based unwinder While doing this work, I saw and remembered that another possibility is to provide a custom unwinder: https://sourceware.org/gdb/current/onlinedocs/gdb/Custom-Debug-Info.html#Custom-Debug-Info But anyway, let's start with figuring out what goes wrong. Simon