public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes
@ 2023-06-04 22:48 two at envs dot net
  2023-06-05 12:23 ` [Bug symtab/30511] " tromey at sourceware dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: two at envs dot net @ 2023-06-04 22:48 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30511
           Summary: feature: set sysroot and file by default for attached
                    containerized processes
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: two at envs dot net
  Target Milestone: ---

after starting gdb with `gdb --attach PID` for a process running in a different
root (such as a flatpak), it's necessary to do `set sysroot /proc/PID/root` and
`set file /proc/PID/exe` to get debug symbols. can this be done by default?

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
@ 2023-06-05 12:23 ` tromey at sourceware dot org
  2023-06-05 12:28 ` mark at klomp dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at sourceware dot org @ 2023-06-05 12:23 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-06-05
                 CC|                            |tromey at sourceware dot org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
FWIW it seems reasonable to me.
sysroot already defaults to "target:", so it's maybe just a matter of the
linux-nat target knowing how to do this under the hood.

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
  2023-06-05 12:23 ` [Bug symtab/30511] " tromey at sourceware dot org
@ 2023-06-05 12:28 ` mark at klomp dot org
  2023-06-06  0:40 ` tromey at sourceware dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mark at klomp dot org @ 2023-06-05 12:28 UTC (permalink / raw)
  To: gdb-prs

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ahajkova at redhat dot com,
                   |                            |mark at klomp dot org

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
This sounds like a good idea.

Adding myself and Sasha to CC to see how this is done (we would like something
similar for a "target valgrind", but then set sysroot / and set remote
exec-file ...).

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
  2023-06-05 12:23 ` [Bug symtab/30511] " tromey at sourceware dot org
  2023-06-05 12:28 ` mark at klomp dot org
@ 2023-06-06  0:40 ` tromey at sourceware dot org
  2023-06-06 21:26 ` two at envs dot net
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at sourceware dot org @ 2023-06-06  0:40 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Mark Wielaard from comment #2)
> This sounds like a good idea.
> 
> Adding myself and Sasha to CC to see how this is done (we would like
> something similar for a "target valgrind", but then set sysroot / and set
> remote exec-file ...).

Unfortunately this is a different situation.
Probably you should file a separate bug for that one.

For this bug, I don't really know how to implement it.
I don't know how to detect if a process needs this treatment.

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (2 preceding siblings ...)
  2023-06-06  0:40 ` tromey at sourceware dot org
@ 2023-06-06 21:26 ` two at envs dot net
  2023-06-07  8:38 ` sam at gentoo dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: two at envs dot net @ 2023-06-06 21:26 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from two at envs dot net <two at envs dot net> ---
(In reply to Tom Tromey from comment #3)
> I don't know how to detect if a process needs this treatment.

compare device and inode of / and /proc/PID/root/ to see if they're different?

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (3 preceding siblings ...)
  2023-06-06 21:26 ` two at envs dot net
@ 2023-06-07  8:38 ` sam at gentoo dot org
  2023-06-09 21:47 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sam at gentoo dot org @ 2023-06-07  8:38 UTC (permalink / raw)
  To: gdb-prs

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

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gentoo dot org

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (4 preceding siblings ...)
  2023-06-07  8:38 ` sam at gentoo dot org
@ 2023-06-09 21:47 ` tromey at sourceware dot org
  2023-06-09 21:52 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at sourceware dot org @ 2023-06-09 21:47 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
linux-nat already seems to have code for this, at least somewhat,
so I wonder where the missing bit is.
See gdb/nat/linux-namespaces.c

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (5 preceding siblings ...)
  2023-06-09 21:47 ` tromey at sourceware dot org
@ 2023-06-09 21:52 ` tromey at sourceware dot org
  2023-06-10 22:16 ` two at envs dot net
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at sourceware dot org @ 2023-06-09 21:52 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
BTW which version of gdb are you using?
I'm not sure how to set up to try this out, but the code
seems to be there.
e.g., linux_proc_pid_to_exec_file does:

  xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
  len = readlink (name, buf, PATH_MAX - 1);

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (6 preceding siblings ...)
  2023-06-09 21:52 ` tromey at sourceware dot org
@ 2023-06-10 22:16 ` two at envs dot net
  2023-06-11 17:43 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: two at envs dot net @ 2023-06-10 22:16 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from two at envs dot net <two at envs dot net> ---
(In reply to Tom Tromey from comment #6)
>   xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
>   len = readlink (name, buf, PATH_MAX - 1);

readlink reads symbolic links.

```
$ readlink /proc/$(pidof epiphany)/exe
/app/bin/epiphany
$ file /app/bin/epiphany
/app/bin/epiphany: cannot open `/app/bin/epiphany' (No such file or directory)
```

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (7 preceding siblings ...)
  2023-06-10 22:16 ` two at envs dot net
@ 2023-06-11 17:43 ` tromey at sourceware dot org
  2023-06-12 13:18 ` mark at klomp dot org
  2023-06-12 13:30 ` mark at klomp dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at sourceware dot org @ 2023-06-11 17:43 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Tom Tromey <tromey at sourceware dot org> ---
Yeah.  Funny, it's a symlink that can't be resolved?
Anyway, like I said, I don't know anything about flatpak,
someone else will have to figure this out.

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (8 preceding siblings ...)
  2023-06-11 17:43 ` tromey at sourceware dot org
@ 2023-06-12 13:18 ` mark at klomp dot org
  2023-06-12 13:30 ` mark at klomp dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mark at klomp dot org @ 2023-06-12 13:18 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #9 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Tom Tromey from comment #3)
> (In reply to Mark Wielaard from comment #2)
> > This sounds like a good idea.
> > 
> > Adding myself and Sasha to CC to see how this is done (we would like
> > something similar for a "target valgrind", but then set sysroot / and set
> > remote exec-file ...).
> 
> Unfortunately this is a different situation.
> Probably you should file a separate bug for that one.

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

> For this bug, I don't really know how to implement it.
> I don't know how to detect if a process needs this treatment.

Do you need any detection?
Can't you simply always set sysroot /proc/PID/root if it exists?

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

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

* [Bug symtab/30511] feature: set sysroot and file by default for attached containerized processes
  2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
                   ` (9 preceding siblings ...)
  2023-06-12 13:18 ` mark at klomp dot org
@ 2023-06-12 13:30 ` mark at klomp dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mark at klomp dot org @ 2023-06-12 13:30 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #10 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Tom Tromey from comment #8)
> Yeah.  Funny, it's a symlink that can't be resolved?
> Anyway, like I said, I don't know anything about flatpak,
> someone else will have to figure this out.

The symlink resolves "inside" the sysroot.
So the exe can be found as:
file /proc/$(pidof epiphany)/root$(readlink /proc/$(pidof epiphany)/exe)

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

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

end of thread, other threads:[~2023-06-12 13:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-04 22:48 [Bug symtab/30511] New: feature: set sysroot and file by default for attached containerized processes two at envs dot net
2023-06-05 12:23 ` [Bug symtab/30511] " tromey at sourceware dot org
2023-06-05 12:28 ` mark at klomp dot org
2023-06-06  0:40 ` tromey at sourceware dot org
2023-06-06 21:26 ` two at envs dot net
2023-06-07  8:38 ` sam at gentoo dot org
2023-06-09 21:47 ` tromey at sourceware dot org
2023-06-09 21:52 ` tromey at sourceware dot org
2023-06-10 22:16 ` two at envs dot net
2023-06-11 17:43 ` tromey at sourceware dot org
2023-06-12 13:18 ` mark at klomp dot org
2023-06-12 13:30 ` mark at klomp dot 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).