From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id JWicI7Zqd2qzxxQAWB0awg (envelope-from ) for ; Sat, 08 Aug 2026 13:43:18 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=esQBl4Yg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7E7541E09B; Sat, 08 Aug 2026 13:43:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 5036A1E09B for ; Sat, 08 Aug 2026 13:43:17 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 829794BA902B for ; Sat, 8 Aug 2026 17:43:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 829794BA902B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=esQBl4Yg Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 5D3034BA79A4 for ; Sat, 8 Aug 2026 17:42:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D3034BA79A4 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D3034BA79A4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786210966; cv=none; b=f4qy6ymnOArbXByZpQ61W0Amv/IT2dF+48JrhZFKmoJhsrdXbRtsDjNpdAqG3f3gkRCXSPqsgVfehhNB9DnEibZqK3NF+3+uc0oRS5piKsIhWjQg9LQfHlomgx5nFx48apwYRIUuQTUgoiNIGGedx/f3GOs1nHIfJgfvz39F6lQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786210966; c=relaxed/simple; bh=xg6OJQGqsSu/drXgawNkbPEfc/SO6AeycA+yK8XoxCo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=T3BK5NJOAnjCQTO67cIfukoA7aCExzLcoYNEdQfBZ1gHDuZ6GdoeokJrQWKLZfTpMlsBzbXx2cTa8vC3ANPGuM+gzRGtS8a5yiXM3XcY6l6D1yl6BghFc58letpqlWmFjRs0HqqDW3QxO1lhd3sWdhoxLFdUUArlHk1238fHrco= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=esQBl4Yg DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D3034BA79A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786210965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IvgomAUY2PvQnStM86ViADhISY24LvD9N5iLGE37GOw=; b=esQBl4YgEIltgbSPAwQ89JoCsP2WtZOKeggeLsKpNLvFGx8bbz1W3txNRukRU7an8AlC29 elrlC8GF592eWi1LKfCSJrxN9JABjLMo9KeNasMeWlNRyS54wNRDoGYUnc2/AOznKsQAOc Zb2HzjrdpsRiCteZELufR2MIBPPVO9Q= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-540-ktfGYZctNAOla3N4nY8u5Q-1; Sat, 08 Aug 2026 13:42:42 -0400 X-MC-Unique: ktfGYZctNAOla3N4nY8u5Q-1 X-Mimecast-MFC-AGG-ID: ktfGYZctNAOla3N4nY8u5Q_1786210962 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE6751956041 for ; Sat, 8 Aug 2026 17:42:41 +0000 (UTC) Received: from f44-mesa-1 (unknown [10.22.88.9]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7CE70195DF93; Sat, 8 Aug 2026 17:42:40 +0000 (UTC) Date: Sat, 8 Aug 2026 10:42:36 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Alexandra =?ISO-8859-1?Q?H=E1jkov=E1?= Subject: Re: [PATCH v9] gdb: Add source-tracking breakpoints feature Message-ID: <20260808104236.4f638e2b@f44-mesa-1> In-Reply-To: <20260807104848.497790-1-ahajkova@redhat.com> References: <20260807104848.497790-1-ahajkova@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: yuMgN_xU07AP7gTQ7QYKEyxjJDGapD9sBYdYA2za5_A_1786210962 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Fri, 7 Aug 2026 12:46:37 +0200 Alexandra H=C3=A1jkov=C3=A1 wrote: [...] > +/* Print captured source lines to stdout, marking the breakpoint line wi= th '>'. */ Nit: the captured source lines are actually printed via gdb_printf / uiout. You might just say "Print captured source lines, marking the breakpoint..." > + > +static void > +breakpoint_source_print (const breakpoint_source *src) [...] > +/* See breakpoint.h. */ > + > +void > +code_breakpoint::adjust_bp_for_source_tracking > + (program_space *filter_pspace, > + std::vector &expanded) > +{ > + if (expanded.empty () || expanded[0].symtab =3D=3D nullptr > + || !breakpoint_source_is_tracked (bp_source.get ())) > + return; > + > + struct compunit_symtab &cust =3D expanded[0].symtab->compunit (); > + if (cust.objfile () =3D=3D nullptr) > + return; > + > + bfd *current_bfd =3D cust.objfile ()->obfd.get (); > + if (bp_source->source_bfd.get () =3D=3D current_bfd) > + return; > + > + /* BFD changed - executable was reloaded. */ > + if (expanded.size () !=3D 1) > + { > + warning (_("Breakpoint %d now has multiple locations after reload,= " > +=09=09 "disabling source tracking."), number); > + bp_source.reset (); > + return; > + } > + > + /* If this fails then the location spec has changed since the > + breakpoint's source tracking was initially setup. */ > + gdb_assert (breakpoint_locspec_suitable_for_tracking (locspec.get ()))= ; > + > + std::string line; > + auto restore_styling =3D make_scoped_restore (&source_styling, false); > + if (!g_source_cache.get_source_lines (expanded[0].symtab, > +=09=09=09=09=09expanded[0].line, > +=09=09=09=09=09expanded[0].line, &line)) > + { > + /* Source is unreadable after reload - drop tracking. */ > + bp_source.reset (); > + return; > + } > + > + if (line =3D=3D bp_source->source_lines[bp_source->bp_line_stored]) > + { > + /* Line unchanged - just refresh the capture with the new BFD. */ > + bp_source =3D std::make_unique > +=09(breakpoint_source_capture (expanded, BREAKPOINT_SRC_CTX_LINES)); > + return; > + } > + > + breakpoint_source tmp_source > + =3D breakpoint_source_capture (expanded, > +=09=09=09=09 BREAKPOINT_SRC_CTX_LINES > +=09=09=09=09 * BREAKPOINT_SRC_SEARCH_MULTIPLIER); > + int new_bp_line =3D sliding_window_match (bp_source.get (), &tmp_sourc= e); > + if (new_bp_line =3D=3D -1) > + { > + warning (_("Breakpoint %d source code not found " > +=09=09 "after reload, keeping original location."), number); > + bp_source.reset (); > + return; > + } > + > + auto *explicit_loc =3D as_explicit_location_spec (locspec.get ()); > + location_spec_up new_locspec =3D explicit_loc->clone (); > + auto *new_explicit =3D as_explicit_location_spec (new_locspec.get ()); > + new_explicit->line_offset.offset =3D new_bp_line; > + new_explicit->line_offset.sign =3D LINE_OFFSET_NONE; > + /* Invalidate the cached display string. */ > + new_explicit->set_string (""); > + > + int found; > + expanded =3D location_spec_to_sals (new_locspec.get (), filter_pspace,= &found); This assignment (above) to the reference variable 'expanded'... > + if (!found) > + { > + warning (_("Breakpoint %d adjusted to line %d but location could n= ot " > +=09=09"be resolved; keeping original location."), number, new_bp_line); > + bp_source.reset (); > + return; ...won't actually keep the original locations intact as the message states. In this case, if it's not found, the list of locations returned will be the empty vector and it'll replace the perfectly good list which should be preserved when an error occurs. I recommend doing the initial assignment to a local variable and then making the assignment to 'expanded' after this error handling block. > + } > + locspec =3D std::move (new_locspec); > + if (new_bp_line !=3D bp_source->bp_line) > + { > + gdb_printf (_("Breakpoint %d adjusted from line %d to line %d.\n")= , > +=09=09 number, bp_source->bp_line, new_bp_line); > + notify_breakpoint_modified (this); > + } > + > + bp_source =3D std::make_unique > + (breakpoint_source_capture (expanded, BREAKPOINT_SRC_CTX_LINES)); > +} > + > /* The default re_set method, for typical hardware or software > breakpoints. Reevaluate the breakpoint and recreate its > locations. */ [...]