Re: [PATCH 3/7] Use gdb_sysroot for main executable on attach

Gary Benson
2015-04-15T12:45:08Z

Eli Zaretskii wrote:
> > From: Gary Benson <gbenson@redhat.com>
> > Date: Wed, 1 Apr 2015 12:22:17 +0100
> >
> > +* Paths specified by "set sysroot" will be prepended to the path of
> > + the main executable when attaching to already-running processes
> > + (local and remote) if the path of the main executable is reported
> > + to GDB as absolute by the operating system.
>
> Please don't use "path" when you really mean "file name".
>
> > +shared library paths will be prefixed with @var{path}; many runtime
> > +loaders store the absolute paths to the shared library in the target
> > +program's memory. When attaching to already-running processes, their
> > +paths will be prefixed with @var{path} if reported to @value{GDBN} as
> > +absolute by the operating system. If you use @code{set sysroot} to
> > +find executables and shared libraries, they need to be laid out in
> > +the same way that they are on the target, with e.g.@: a @file{/bin},
> > +@file{/lib} and @file{/usr/lib} hierarchy under @var{path}.
>
> Same here. (Yes, I know that the previous text also used "path").

Pedro Alves wrote:
> This "When attaching to already-running processes" part confuses me,
> as the sysroot is also prepended to paths in the "run" case.

How about these replacements for those two chunks:

NEWS:
+* The system root specified by "set sysroot" will be prepended to the
+ filename of the main executable (if reported to GDB as absolute by
+ the operating system) when starting processes remotely, and when
+ attaching to already-running local or remote processes.

gdb.texinfo:
Use @var{path} as the system root for the program being debugged. Any
absolute shared library paths will be prefixed with @var{path}; many
runtime loaders store the absolute paths to the shared library in the
-target program's memory. If you use @code{set sysroot} to find shared
-libraries, they need to be laid out in the same way that they are on
-the target, with e.g.@: a @file{/lib} and @file{/usr/lib} hierarchy
-under @var{path}.
+target program's memory. When starting processes remotely, and when
+attaching to already-running processes (local or remote), their
+filenames will be prefixed with @var{path} if reported to @value{GDBN}
+as absolute by the operating system. If you use @code{set sysroot} to
+find executables and shared libraries, they need to be laid out in the
+same way that they are on the target, with e.g.@: a @file{/bin},
+@file{/lib} and @file{/usr/lib} hierarchy under @var{path}.

At this point in the series the prefixing only happens when attaching
to local processes--attaching to some remote processes appears in
patch 5, and attaching to all remote processes and to remote processes
we start is patch 7--but I didn't want to jiggle the doc at every
step. The above chunks are for the whole thing, which I can leave
here in patch 3 or move to patch 7, whatever people prefer.

Cheers,
Gary

--