From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YBemFwMfJ2hUQiUAWB0awg (envelope-from ) for ; Fri, 16 May 2025 07:18:27 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=aw9lABYX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 45AFA1E10E; Fri, 16 May 2025 07:18:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 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 A63291E092 for ; Fri, 16 May 2025 07:18:26 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 448553857432 for ; Fri, 16 May 2025 11:18:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 448553857432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1747394306; bh=g3IWYzqeZLZuBXGUgd013HhiEJkKKd9WJo5TpYJGjUk=; h=References:In-Reply-To:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aw9lABYXygCD5TXqjXmaHR8Sbqr3ps5QWXna/6Stq3TD9zfBH4X41xtL/3eKEc0WO Wrh5DFBPfcSKYEODFe9+GgTLar2MHwf7vWa6x6qVqA/LEBs2MaVJwADWIYxZpWWVEC Yl9xD2q1FSrDdeAATnrErMQBiQkwbstJQpYEKsjU= Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by sourceware.org (Postfix) with ESMTPS id 006073858C56 for ; Fri, 16 May 2025 11:17:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 006073858C56 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 006073858C56 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747394260; cv=none; b=WPqHiYAWfsZIGJrI6a1+Con5GKM6AeQ6EgoeKoEUi1K5FohKRCIqob4ClwXy4DmweqJHTMIeVnSw6ChMo9vPPQiwVxh4pKbKotq5EEaI4bpyIzGs99DUN63176hnyI0WLpMSXA1frO74/tqxefU8E3or0ii8S+EDoQnNcQ1ZVb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747394260; c=relaxed/simple; bh=GJtV59lpVmzadIHjVBIfr/xxWINV5ClK9ijVrTSIqZE=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=pYGX0FiOFtUGcXQ9YxZrQwYa7dU3/bDfAcCqCcja9xvztYhLKxNMAJMUbGzbZDpFAjLulOpCYtkoAaLDO84TBm/RZzPrrd877qEQhALy7MP6JH3PI0WUpls+s0RFqm80xLfkRn7HGmbhP+XbMGhcNwcWxGrjU1lucUEkf56cqXM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 006073858C56 Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5efe8d9ebdfso3599280a12.3 for ; Fri, 16 May 2025 04:17:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747394259; x=1747999059; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wX1olnHlBxSosWX9rU6JnWuFd0PldYym427TwusniZ8=; b=hRpJyVeMKYVYUStxtBBRDLtv8PC936M1nHvprpE1b1Un3yKNFk/RrQovpXeIpfLQ3q lSU1EutMA7BMzBWHI6US3faacIBjRotAWOHa+mZd2IBKBuCoJ64j93olka+y1ed82XmZ JPLsnkhAxUOJhD5Ou+KuwDnWMaYR+w1JKvYIxRlQF4DxfqIMEsos8s6brh9t0b8fVp2B y7gJVjGFv/Nntl+6JwOARe6p6R6oJY7J/knUI/bHXr90YYAjHZMqkq2r9c1KhoJAF1Fq B8Z+cOlGmjLX/0nRxOh8h8mi3T+W/rrQetdrD6b1dHxpzMX84YqrwwoJm3NIyxDo71+C 3zVQ== X-Forwarded-Encrypted: i=1; AJvYcCV/kWUponSsNZhBIX/y61M3+e0CVW10LmV0NFKFOAYAUMR8GHt4fHwmXa0aFaxpp2vsJ/A=@sourceware.org X-Gm-Message-State: AOJu0Yw/tyKYgtfG6qVR5TG6w8/cF81bRzfzmmzWieI5BQYyLUPbH5Vi DYRcNL4mWRjlL033e4rsSX2Oa7yGVjgDvt5jBDjBCSO4xwSzDyhC3074ji+CJ6Z8yPl/I8JBEN7 X3WU52lS44ZW9uwk1IqOgNBawUyGzduTeoAfJ X-Gm-Gg: ASbGncuGKxAwGJSjp1kxrDkDLwl11Fw0c08VSRnDl+rafLO3Ha03EBQ3uUKIkpCtaHR CA54J3SioMCZH80AUZ1zB/Ig6SV7uJoqtze7ehlQN+7QUk2hN0XIOxsY4Y1EFuiDyPSuoq0E7Md I2O+Mb8r35JNYIhjNqo3cQGJ14YbCWeKn1xg== X-Google-Smtp-Source: AGHT+IFGv050UqwQCvYbS0FBtjmv9NdP8lJ4GozVx4lM6BDd/WQxfnDcFwpZ/FNM5ukBY/d+K6jzyvA1jUxgdKQflvE= X-Received: by 2002:a17:906:ef07:b0:ace:bead:5ee6 with SMTP id a640c23a62f3a-ad536f9d461mr138874366b.37.1747394258371; Fri, 16 May 2025 04:17:38 -0700 (PDT) MIME-Version: 1.0 References: <875xi0onpo.fsf@redhat.com> In-Reply-To: <875xi0onpo.fsf@redhat.com> Date: Fri, 16 May 2025 13:17:27 +0200 X-Gm-Features: AX0GCFtmxM151uTFYVbi26acoivH2VuvcNgDBKtDfrMPM-BpFl1n7HpiorT96SQ Message-ID: Subject: Re: Breakpoints in shared address space To: Andrew Burgess Cc: Andreas Schwab , Max Larsson via Gdb Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.30 X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Max Larsson via Gdb Reply-To: Max Larsson Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" Hi Andrew, thanks for the explanation. That help a lot. And even for the patch. I think I will in cooperate that in our port. KR Max Larsson On Fri, 16 May 2025 at 12:26, Andrew Burgess wrote: > Max Larsson via Gdb writes: > > > On Thu, 15 May 2025 at 13:46, Andreas Schwab wrote: > > > >> On Mai 15 2025, Max Larsson via Gdb wrote: > >> > >> > So if gdb file command is use to read an exe, gdb uses the address for > >> the > >> > exe as defined in the elf file. So if i disas the _start function > >> > it show me all the assembler code starting with an address > 0x010000054. > >> So > >> > long everything is fine. Now I tell gdb to set an break point > >> > on that address and run the exe. > >> > >> How do you set the breakpoint exactly? > >> > >> > > Like this "b *0x010000054" > > GDB doesn't adjust breakpoint placed by address when an inferior is > relocated during startup. > > The same problems you are encountering can (and often is) hit on Linux > system if the executable is compiled as PIE (position independent > executable). > > I did, long ago, propose a patch to GDB that would specifically warn > about this issue: > > > https://inbox.sourceware.org/gdb-patches/20200202011022.11357-1-andrew.burgess@embecosm.com/ > > But it never got merged. > > If you place the breakpoint based on function name, or file/line, then > GDB will update the breakpoints location. > > Alternatively, you could start the inferior, but halt before the first > instruction using `starti`, then disassemble, at which point the > addresses should be correct, you can then place a breakpoint by address. > > Your next question is likely to be: why don't address breakpoints get > updated? The answer is that GDB doesn't want to make assumptions about > what the user intends. What if they _really_ do want a b/p at that > address? Given there are easy solutions (`starti`) that allow the user > to place on the correct address, right now, address breakpoints just > don't move. > > Thanks, > Andrew > > > > > KR > > > > Max Larsson > > > > BTW: Edit the subject which I forget in my initial email > >