public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container
@ 2023-09-18 13:05 vries at gcc dot gnu.org
  2023-09-18 13:08 ` [Bug gdb/30866] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-18 13:05 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30866

            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
<container-id>
$ podman attach <container-id>
...
and:
...
$ podman exec -it <container-id> 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=0 line).

Install glibc-debuginfo.

Create test.c:
...
#include <unistd.h>
#include <stdio.h>

static volatile int hello = 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 another:
...
$ 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, unable
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.so.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.debug...
yes!
Reading symbols from
target:/usr/lib/debug/.build-id/76/7aa1e4d4fc7c106971b202b6b00e92f47411dc.debug...
...

Note that in this case, we didn't follow the symlink.  That is not a problem,
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.debug...
no, unable to open.
  Trying
target:/usr/lib/debug/lib64-symlink//libc-2.31.so-2.31-150300.52.2.x86_64.debug...
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug gdb/30866] [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container
  2023-09-18 13:05 [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container vries at gcc dot gnu.org
@ 2023-09-18 13:08 ` vries at gcc dot gnu.org
  2023-09-18 13:20 ` [Bug symtab/30866] " vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-18 13:08 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30866

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
In commit 07bc701d031 ("Look for build-id-based separate debug files under the
sysroot") we find:
...
+         Don't do it if the sysroot is the target system ("target:").  It
+         could work in theory, but the lrealpath in build_id_to_debug_bfd_1
+         only works with local paths.  */
...
so I think this is a known issue.

AFAIU we need an lrealpath implementation that uses
linux_nat_target::fileio_readlink.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug symtab/30866] [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container
  2023-09-18 13:05 [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container vries at gcc dot gnu.org
  2023-09-18 13:08 ` [Bug gdb/30866] " vries at gcc dot gnu.org
@ 2023-09-18 13:20 ` vries at gcc dot gnu.org
  2023-09-19 11:58 ` tromey at sourceware dot org
  2023-09-19 17:06 ` jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-18 13:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30866

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|gdb                         |symtab

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug symtab/30866] [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container
  2023-09-18 13:05 [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container vries at gcc dot gnu.org
  2023-09-18 13:08 ` [Bug gdb/30866] " vries at gcc dot gnu.org
  2023-09-18 13:20 ` [Bug symtab/30866] " vries at gcc dot gnu.org
@ 2023-09-19 11:58 ` tromey at sourceware dot org
  2023-09-19 17:06 ` jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tromey at sourceware dot org @ 2023-09-19 11:58 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30866

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Bug #30511 may be related?

Also I wonder if a realpath is truly needed.
Maybe just pasting paths together and not canonicalizing is fine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug symtab/30866] [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container
  2023-09-18 13:05 [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-09-19 11:58 ` tromey at sourceware dot org
@ 2023-09-19 17:06 ` jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-09-19 17:06 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30866

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-19 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 13:05 [Bug gdb/30866] New: [gdb/symtab] symbolic links to debuginfo not followed when debugging from outside container vries at gcc dot gnu.org
2023-09-18 13:08 ` [Bug gdb/30866] " vries at gcc dot gnu.org
2023-09-18 13:20 ` [Bug symtab/30866] " vries at gcc dot gnu.org
2023-09-19 11:58 ` tromey at sourceware dot org
2023-09-19 17:06 ` jamborm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).