From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bVqSH2n3sGbZCj0AWB0awg (envelope-from ) for ; Mon, 05 Aug 2024 12:01:45 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=UBr8ApiF; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=P92rg1XM; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=zKXlnDHq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yHjguaXc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 6E3861E0D0; Mon, 5 Aug 2024 12:01:45 -0400 (EDT) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 446071E08C for ; Mon, 5 Aug 2024 12:01:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0DC5385DDEC for ; Mon, 5 Aug 2024 16:01:42 +0000 (GMT) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 77A41385C6C6 for ; Mon, 5 Aug 2024 16:00:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77A41385C6C6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 77A41385C6C6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722873623; cv=none; b=cEAuqjggh1hRYP71COTEdtrZ4ZGY2TrQnYrajjfY7P3vtDcvRug+71HkaDhF+TMXweyqVrKJiy39yHgyfByan3CLqL7s7635qC2SPh3QjK3o7vmWT/VcR97sVeRFwpOCb82cnFnMHOCt3fG6QcRhFiBXY8ZEnvRM9kSvtG/pajY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722873623; c=relaxed/simple; bh=DeH47fQbPyChpEDa1Qk8o/xiJlUf6hD5NrVXU+LOnZ8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=YoBdCIaIZLhGWqJP5p9Xz1rahSX2clfXASX0ZGwRt8aMEQqbMJCDEjQdk/7nFAAVWWbpjGEl+i3aEmHv9ZH6CiWod8sxGhN2sM8tPK4NFZIg3U8zZTMrdSc3WSAKOhb3N958fhiNL1xuk7RWrtoRMGEtI8PZbhv/zsI6U1PCQLI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5765A1F809 for ; Mon, 5 Aug 2024 16:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722873620; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxO/4efBZgGfTMij6LeCsBfUxQnhabZQoMef1pjVGDQ=; b=UBr8ApiFGElLfZfLBRZov/FqZWA4BrhNdjUMaItI4ocniztxurvpXUEC5wmMac4DvWYZ23 RqJV7mppDiulW12iBim8XGs2TyMFn/EJFqDbYJLpe46SOleUS1V3h7BWxHxAoTXOeifq2k UqNz+elwcM2UoYflfCS/nH5/kOcaZg8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722873620; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxO/4efBZgGfTMij6LeCsBfUxQnhabZQoMef1pjVGDQ=; b=P92rg1XMwsYKWv8aBcya46QQW30KdutMC6o0RROL8+7cDNLbD1OSlIbhCBgkwu8QomHicu bsB1aNT+t+kMF2Cw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1722873619; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxO/4efBZgGfTMij6LeCsBfUxQnhabZQoMef1pjVGDQ=; b=zKXlnDHqVBzzE+ZFd4+xNRzhIbp1nfBUwJEB3NHI3/m5fhWNno1n+R2Bjljw5TrGQJ8tAs +u24nRC3LJsmk5cqfj1MefEIZFjuXy9AY73l6tr3esbhLI/nWyUX3rSEHxKZ7GTC2bk+S5 uhoXKlIrsYOV5nuskPRJpkObmGuVqZQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1722873619; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxO/4efBZgGfTMij6LeCsBfUxQnhabZQoMef1pjVGDQ=; b=yHjguaXcksw0RhxzDGqo27twj4i52mcfncMhEQTGGh+1h9fncRtK9NOL4iH5tu6JH8xwpC 0RAqx6dDfbnH1lCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 45B5013254 for ; Mon, 5 Aug 2024 16:00:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id juuQDxP3sGZvaQAAD6G6ig (envelope-from ) for ; Mon, 05 Aug 2024 16:00:19 +0000 Message-ID: <69569020-ae82-40c5-aad6-9a90099947db@suse.de> Date: Mon, 5 Aug 2024 18:00:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PING][PATCH] [gdb/tdep] Use cached breakpoint kind in breakpoint_kind From: Tom de Vries To: gdb-patches@sourceware.org References: <20240607143821.29797-1-tdevries@suse.de> <5188e7e4-5d7b-4d9a-b81b-9393d7b2ff77@suse.de> Content-Language: en-US In-Reply-To: <5188e7e4-5d7b-4d9a-b81b-9393d7b2ff77@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.29 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+] X-Spam-Score: -4.29 X-Spam-Level: X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 7/31/24 13:26, Tom de Vries wrote: > On 6/7/24 16:38, Tom de Vries wrote: >> With test-case gdb.base/solib-probes-nosharedlibrary.exp on arm-linux, >> I get: >> ... >> (gdb) continue^M >> Continuing.^M >> ^M >> Program received signal SIGILL, Illegal instruction.^M >> 0xf7fd267a in ?? ()^M >> (gdb) FAIL: $exp: continue to breakpoint: main >> ... >> >> This happens as follows: >> - the starti command is called, >> - gdb loads symbols for ld.so, >> - the "shlib events" breakpoint is inserted at the address of >> _dl_debug_state, >> - execution stops at ld.so _start, and the inserted breakpoint is >> removed, >> - the nosharedlibrary command is called, >> - gdb forgets about all shared library symbols, >> - the continue command is called, >> - gdb re-inserts the "shlib events" breakpoint, but the call to >>    breakpoint_kind returns the wrong value: ARM_BP_KIND_ARM instead of >>    ARM_BP_KIND_THUMB, so the wrong type of breakpoint is inserted, and >> - when execution hits the breakpoint, the SIGILL triggers. >> >> In order to correctly set a breakpoint on an address for arm, gdb >> needs to >> known whether that address is in thumb or arm code, and the problem is >> that >> that information is no longer available due to the nosharedlibrary >> command. >> >> However, the breakpoint kind is is available from the previous time the >> breakpoint was inserted. >> >> Fix this in breakpoint_kind, by using the info cached in >> bl->target_info.kind, >> if available. >> > > Ping. > I've given this patch some more thought, and I think I have come up with a counter example. Say you have a breakpoint kind that is different depending on the alignment, one kind for "addr & 0x4 == 0x0" and another kind for "addr & 0x4 == 0x2". Then when relocating the exec, the kind might change, but due to the caching introduced by this patch, we might be incorrectly using the same kind as before the relocation. So, I don't think that this patch is safe. I came up with an alternative solution that doesn't cache the kind, but lets the tdep part cache data alongside an address if that is safe and beneficial. Submitted here ( https://sourceware.org/pipermail/gdb-patches/2024-August/210884.html ). Thanks, - Tom > Thanks, > - Tom > >> Tested on arm-linux. >> >> PR tdep/31817 >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31817 >> --- >>   gdb/breakpoint.c | 6 +++++- >>   1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c >> index a973518ac5f..0c99ccc9568 100644 >> --- a/gdb/breakpoint.c >> +++ b/gdb/breakpoint.c >> @@ -2792,7 +2792,11 @@ breakpoint_kind (const struct bp_location *bl, >> CORE_ADDR *addr) >>                                regcache, addr); >>       } >>     else >> -    return gdbarch_breakpoint_kind_from_pc (bl->gdbarch, addr); >> +    { >> +      if (bl->target_info.kind != 0) >> +    return bl->target_info.kind; >> +      return gdbarch_breakpoint_kind_from_pc (bl->gdbarch, addr); >> +    } >>   } >>   /* Rethrow the currently handled exception, if it's a >> TARGET_CLOSE_ERROR. >> >> base-commit: 3a659c2a30f40c2a734fda5566098804b5ee38fc >