From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 941F23858C00 for ; Mon, 26 Sep 2022 16:08:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 941F23858C00 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-587-L1AiYRKkNrettJ08P-9c0Q-1; Mon, 26 Sep 2022 12:08:51 -0400 X-MC-Unique: L1AiYRKkNrettJ08P-9c0Q-1 Received: by mail-wm1-f71.google.com with SMTP id r7-20020a1c4407000000b003b3f017f259so4358007wma.3 for ; Mon, 26 Sep 2022 09:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=25XpUleVb6p23hsIapqyB0x2jKOuHcX6mNbGF5gFiiU=; b=x3vFjeD30SuT+HntgN7v8nPN/Xa9YK0WK3qzAc0HnB7Z/kDU4crZd32qSVGlvtZV2n pNBtrM3c3/DbaIM9QmWIRH8zcv1I3sYgR1yM4hWuOPpzwtMcn8ot+ilbNtHD8PkTcY7S lFgY5vAek7xC1COnS+aQIYlQOAZHU6sDad/IJAoNRDM9yrwnWS/P6rJsWDMCeVCpifcZ Few7EUzf+Ftsl4Bg5OWOK4B4MbFQIrbO3+ctZdltqb5BsQuTV2ji4VRPGARBHzH4JKDw L3/QFtuIAWlsvqQW72CNTmG0ZFGA1w9fLmsaXPlWhI2zwyZq3rcXZgTOmVlGDjIigVHg c9tQ== X-Gm-Message-State: ACrzQf31ykaNOEOTvw6V0rj5qtOckpVwcMTCxe9zwH5bo9PeG/meBPGm 5fJGdbfrFuY5YkI8JgEcg7ZJdVfIDKFmHKQDc4ykCRsMAopv39L3ZtgB+q9ksg10zEw4gSm3/k8 nm6wt0HrR2axGy3AtIT2lIQ== X-Received: by 2002:a05:6000:cf:b0:228:e37b:361b with SMTP id q15-20020a05600000cf00b00228e37b361bmr14272573wrx.374.1664208529403; Mon, 26 Sep 2022 09:08:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MFH9c9NHDep6VgRRtTUNs8zt6uS2wuErtVgJ+B+mbYBimGBw6HMiNliJPYxXQBcRDbN4ETw== X-Received: by 2002:a05:6000:cf:b0:228:e37b:361b with SMTP id q15-20020a05600000cf00b00228e37b361bmr14272554wrx.374.1664208529121; Mon, 26 Sep 2022 09:08:49 -0700 (PDT) Received: from [192.168.0.45] (ip-213-220-232-121.bb.vodafone.cz. [213.220.232.121]) by smtp.gmail.com with ESMTPSA id v4-20020a5d4a44000000b002238ea5750csm16896743wrs.72.2022.09.26.09.08.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 09:08:48 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 18:08:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: Questions on how best to fix two gdb tests gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp To: Carl Love , Ulrich Weigand , "gdb-patches@sourceware.org" , "luis.machado@arm.com" References: <1398bb10-2ed9-c074-0627-43d7e2feddea@arm.com> <4bb7ce2d41f5623a8866a9e631e3cda48a6a0e04.camel@us.ibm.com> From: Bruno Larsen In-Reply-To: <4bb7ce2d41f5623a8866a9e631e3cda48a6a0e04.camel@us.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Sep 2022 16:08:57 -0000 On 26/09/2022 17:30, Carl Love via Gdb-patches wrote: > Ulrich, Luis: > > On Mon, 2022-09-26 at 14:36 +0000, Ulrich Weigand wrote: >> Luis Machado wrote: >> >>> gdbarch has a hook to adjust the breakpoint address >>> (gdbarch_adjust_breakpoint_address). Can this be used to bend >>> commands >>> like "b *func" so they behave the same as other architectures? >> I don't think this works. The problem is that "b *func" is a weird >> hack that combines two aspects: use of "func" as a value that at this >> point is just a plain symbol table lookup; and use of "*" to set a >> breakpoint at an explicitly specified absolute address. >> >> Neither of these aspects is something we want to change on its own. >> We do want a plain symbol, if used as a value, to return the >> address that is in the symbol table. Everything else would just >> be confusing, and could also break things if "if ptr == func" >> where "ptr" is a function pointer variable. >> >> On the other hand, when using "b *" with some hard-coded >> address, we actually want the breakpoint to be exactly there >> and nowhere else; that is usually used by someone familiar with >> the platform who want to set the breakpoint exactly there. (Or, >> possibly, by clicking on "set breakpoint" in a GUI switched to >> the assembly view.) Automatically moving this to a different >> address would be weird, when the whole point of "*" is that it >> *isn't* trying to be clever, unlike say "b func". >> >> It is an unfortunate fact that these two properties, which are >> each desired on their own, combine to yield an undesirable >> effect when used as "b *func" on Power. But I think the root >> cause of this is that "b *func" is used here in a way that is >> not justified by the actual specification of those features. >> >> Actually, I'm not seeing much use of this particular construct >> at all, outside of the GDB test suite. And here, it is used >> in the idiosyncratic manner of "do a 'b func' but just without >> skipping the prolog", usually because of some GDB test suite >> internal reason why we want to avoid prolog skipping just here. >> >> It seems to me that the real fix would be some new syntax that >> makes this goal explicit, maybe along the lines of >> b -entrypoint func >> >> (It would still be preferable to me to investigate use of this >> construct throughout the test suite to see if it is *really* >> necessary or if the tests can simply be rewritten in a way >> that they don't need the "skip prolog" feature anyway ...) > I looked at the suggestion from Luis. In the end, I really didn't > think changing gdb to make the test work is really the best idea. The > issue is that there are cases, as Ulrich said, where someone who knows > the details may actually want to set the breakpoint on the first > instruction. If I change gdb, to fix the test by "adjusting" the > desired breakpoint then the user is no longer able to stop where they > want to. > > I am not sure why the original test was concerned about the prolog. > The original author doesn't seem to be around anymore. I will think > about how to change the first test some more. From what I could see in the comments of the test, the problem was that reverse-finishing out of the function would ignore breakpoints that were set before the prologue. In case you aren't familiar with how GDB does a reverse-finish (and sorry if you are), it decides what is the first instruction executed in the current frame, places a breakpoint there, and reverse-continues until that breakpoint is hit. GDB then removes that breakpoint and does a reverse-stepi to leave the function call. If there was already a user breakpoint at that instruction, GDB should _not_ do the reverse-stepi. For this test, it seems imperative that the breakpoint is placed before the prologue, since it is where GDB would place the step-resume-breakpoint that reverse-finish uses. > > I don't see any issues with changing the second test to just break on > the function callee rather than *callee. I will submit a patch to > change the second test. Same goes for the second test. It explicitly states that GDB was removing the user-placed breakpoint if it was placed at the exact same instruction as step-resume-breakpoint would be hit, so moving the breakpoint to after the prologue would render the test useless, as the bug conditions wouldn't be met anymore. What you probably want to do in both cases is find a way to get the addresses of the functions and set a breakpoint there as "b *(address)" instead, though I'm not sure how I'd suggest you do it. Cheers, Bruno > > Carl >