From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BACEE3857B86; Fri, 16 Feb 2024 18:17:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BACEE3857B86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708107475; bh=HaDrPvAqZRtp77kYXhFma6pycpzngYRdOQSPaUtnJPs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Mgcd/1WI5ytShdTeXzJJUUkyozoIDL9DjpdiHQGwpezvhE/Dk33SkvahsPdXO3h8c tvEPkFCditz0f/pnO5eWPKYmRKPLOLt8+yBLm8LdsbYcbY2G1FI2S44pDA4Go+uXaJ 9xapOrMqlrAU/hb6niylzLHu528+km8+CA5Jr1y8= From: "pedro at palves dot net" To: gdb-prs@sourceware.org Subject: [Bug server/30453] gdbserver cannot set breakpoints when /proc/pid/mem is not writable Date: Fri, 16 Feb 2024 18:17:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: server X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pedro at palves dot net X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30453 --- Comment #23 from Pedro Alves --- > /proc/pid/mem is also a lot more efficient. The ptrace interface only le= ts you=20 > peek/poke one word at a time. So a lot of context switching.=20 I should also mention, for completeness. ptrace peek/poke requires that you pass down a pid of a live task. So you end up with a race where the task m= ay die while you're ptracing it, and the memory access fails. /proc/pid/mem d= oes not have this problem, as we open the file as soon as we start debugging the inferior, and keep it open until the inferior exits or execs (at which poin= t we need to open another file). We can always access /proc/pid/mem without hav= ing to worry about these cases of the thread that you pass down to ptrace vanis= hes. Note the same can happen with the main thread, it can go zombie without the rest of the process exiting. Again, /proc/pid/mem works in that corner cas= e. --=20 You are receiving this mail because: You are on the CC list for the bug.=