From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mEkyJLqMpmDUXwAAWB0awg (envelope-from ) for ; Thu, 20 May 2021 12:22:18 -0400 Received: by simark.ca (Postfix, from userid 112) id 84FA81F11C; Thu, 20 May 2021 12:22:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D411C1E813 for ; Thu, 20 May 2021 12:22:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 701ED395BC51; Thu, 20 May 2021 16:22:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 701ED395BC51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621527737; bh=Xn1tuTrVHWRrRGIgpN4ANzR7PpUClsd/Kjhd8g05rYI=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nINHAXRgkKh0oNHqPeYu/jYHP2oyRIZqEInBfFnxIabwYcdHVqB1Zjgb18hGD9Hz4 7G6qR5hWMQ69aLYc4ag9V2t8RInni90Tvt9pTpr1bniLv4nvD/e4DYupJO/pomQV83 10lqQ5SzdwfME8a882vlVzz48/Noal0oq4dbqb+E= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2E79438515F7 for ; Thu, 20 May 2021 16:22:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2E79438515F7 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 14KGM94u005309 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 May 2021 12:22:14 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14KGM94u005309 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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9D34C1E813; Thu, 20 May 2021 12:22:09 -0400 (EDT) Subject: Re: [PATCH][gdb/breakpoint] Fix assert in jit_event_handler To: Tom de Vries , gdb-patches@sourceware.org References: <20210520152938.GA31635@delia> Message-ID: Date: Thu, 20 May 2021 12:22:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210520152938.GA31635@delia> 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, 20 May 2021 16:22:09 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-05-20 11:29 a.m., Tom de Vries wrote: > Hi, > > Consider a minimal test-case test.c: > ... > int main (void) { return 0; } > ... > which we can compile into llvm byte code using clang: > ... > $ clang -g -S -emit-llvm --target=x86_64-unknown-unknown-elf test.c > ... > and then run using lli, which uses the llvm jit: > ... > $ lli test.ll > ... > > If we run this under gdb, we run into an assert: > ... > $ gdb -q -batch -ex run --args /usr/bin/lli test.ll > Dwarf Error: Cannot not find DIE at 0x18a936e7 \ > [from module libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug] I guess that's unrelated, but do you know if that error is a sign of something wrong in GDB? > > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/lib64/libthread_db.so.1". > src/gdb/jit.c:1178: internal-error: \ > void jit_event_handler(gdbarch*, objfile*): \ > Assertion `jiter->jiter_data != nullptr' failed. > ... > > This is caused by the following. > > When running jit_breakpoint_re_set_internal, we first handle > libLLVM.so.10.debug, and set a jit breakpoint. > > Next we handle libLLVM.so.10: > ... > (gdb) p the_objfile.original_name > $42 = 0x2494170 "libLLVM.so.10" > ... > but the minimal symbols we find are from libLLVM.so.10.debug: > ... > (gdb) p reg_symbol.objfile.original_name > $43 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug" > (gdb) p desc_symbol.objfile.original_name > $44 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug" > ... > and consequently, the objf_data is the one from libLLVM.so.10.debug: > ... > jiter_objfile_data *objf_data > = get_jiter_objfile_data (reg_symbol.objfile); > ... > and so we hit this: > ... > if (objf_data->cached_code_address == addr) > continue; > ... > and no second jit breakpoint is inserted. > > Subsequently, the jit breakpoint is triggered and handled, but when finding > the symbol for the breakpoint address we get: > ... > (gdb) p jit_bp_sym.objfile.original_name > $52 = 0x2494170 "libLLVM.so.10" > ... > > The assert 'jiter->jiter_data != nullptr' triggers because it checks > libLLVM.so.10 while the one with jiter_data setup is libLLVM.so.10.debug. > > This fixes the assert: > ... > jiter_objfile_data *objf_data > - = get_jiter_objfile_data (reg_symbol.objfile); > - = get_jiter_objfile_data (the_objfile); It's quite annoying that separate debug info files are represented by "objfile"s... > ... > but consequently we'll have two jit breakpoints, so we also make sure we don't > set a jit breakpoint on separate debug objects like libLLVM.so.10.debug. > > Tested on x86_64-linux. Does that fix some test when running the testsuite with the fission board or something like that? I think it would be important for this to be tested. Otherwise, LGTM. Simon