From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 481AC3858C66; Mon, 18 Sep 2023 13:05:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 481AC3858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695042342; bh=as1X8eXBpp89T2DGwCB8Grz6azuxMsAodFGPiRy9Bfo=; h=From:To:Subject:Date:From; b=AvxY4pI9SuqfCzfY8yKnvxqloaHbrHZpFP8n+5bkgeu7Goc8to0WcuLBZ01gTlDQJ tsiowLDASvKxGWMxlcogy6PVecTyFQTbxsAe7joj0AzS6i06RAb5N5Lh+NBRJLiOWi NLQkLPRSGgYTi7QyzO4M8g43+kGChiBFduCP9VYo= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container Date: Mon, 18 Sep 2023 13:05:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D30866 Bug ID: 30866 Summary: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container Product: gdb Version: HEAD Status: NEW Severity: enhancement Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider the following session: ... $ podman pull docker.io/opensuse/leap $ podman run -dt --pid host docker.io/opensuse/leap $ podman attach ... and: ... $ podman exec -it bash ... to get two shells. Install emacs, gcc, gdb, sysvinit-tools using "zypper install". Create a symlink /lib64-symlink -> /lib64. Edit /etc/zypp/repos.d to enable debug repositories (open files with debug = in name, replace 0 by 1 in enabled=3D0 line). Install glibc-debuginfo. Create test.c: ... #include #include static volatile int hello =3D 0; int main (void) { while (1) { sleep (1); if (hello) printf ("hello"); } return 0; } ... And compile it: ... $ gcc test.c -g -Wl,-rpath,/lib64-symlink ... Run it in one shell, and find the pid and attach (using system gdb) in anot= her: ... $ gdb -iex "set debug separate-debug-file on" -p $(pidof a.out) ... Looking for separate debug info (build-id) for /lib64-symlink/libc.so.6 Trying /usr/lib/debug/.build-id/76/7aa1e4d4fc7c106971b202b6b00e92f47411dc.debug... yes! Reading symbols from /usr/lib/debug/lib64/libc-2.31.so-2.31-150300.52.2.x86_64.debug... ... Note that gdb manages to follow the symlink of the .build-id file. Likewise, if we move .build-id to .id-build, we get instead: ... Looking for separate debug info (debug link) for /lib64-symlink/libc.so.6 Trying /lib64/libc-2.31.so-2.31-150300.52.2.x86_64.debug... no, unable to open. Trying /lib64/.debug/libc-2.31.so-2.31-150300.52.2.x86_64.debug... no, un= able to open. Trying /usr/lib/debug//lib64/libc-2.31.so-2.31-150300.52.2.x86_64.debug... yes! Reading symbols from /usr/lib/debug//lib64/libc-2.31.so-2.31-150300.52.2.x86_64.debug... ... Note that again gdb manages to follow a symlink. Now try from outside the container (using current gdb build from source) and sudo (and re-enable .build-id): ... Looking for separate debug info (build-id) for target:/lib64-symlink/libc.s= o.6 Trying /usr/lib/debug/.build-id/76/7aa1e4d4fc7c106971b202b6b00e92f47411dc.debug...= no, unable to compute real path Trying target:/usr/lib/debug/.build-id/76/7aa1e4d4fc7c106971b202b6b00e92f47411dc.d= ebug... yes! Reading symbols from target:/usr/lib/debug/.build-id/76/7aa1e4d4fc7c106971b202b6b00e92f47411dc.d= ebug... ... Note that in this case, we didn't follow the symlink. That is not a proble= m, the file system handling follows the symlink and the file is found. Again, move .build-id to .id-build: ... Looking for separate debug info (debug link) for target:/lib64-symlink/libc.so.6 Trying target:/lib64-symlink/libc-2.31.so-2.31-150300.52.2.x86_64.debug... no, unable to open. Trying target:/lib64-symlink/.debug/libc-2.31.so-2.31-150300.52.2.x86_64.debug... = no, unable to open. Trying target:/usr/lib/debug//lib64-symlink/libc-2.31.so-2.31-150300.52.2.x86_64.d= ebug... no, unable to open. Trying target:/usr/lib/debug/lib64-symlink//libc-2.31.so-2.31-150300.52.2.x86_64.d= ebug... no, unable to open. (No debugging symbols found in target:/lib64-symlink/libc.so.6) ... Note that in this case again, we didn't follow the symlink, but this time resulting in not finding the debuginfo file. --=20 You are receiving this mail because: You are on the CC list for the bug.=