This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] attach_command: clear solib state before attaching toprocess
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: vinschen at redhat dot com
- Date: Mon, 17 Jan 2005 09:27:24 -0700
- Subject: Re: [RFA] attach_command: clear solib state before attaching toprocess
- Organization: Red Hat
- References: <20050117145425.GP3113@cygbert.vinschen.de>
On Mon, 17 Jan 2005 15:54:25 +0100
Corinna Vinschen <vinschen@redhat.com> wrote:
> Hi,
>
> I've observed a FAIL of the following test in gdb.base/attach.exp:
>
> (gdb) attach 4711
> Cannot access memory at address 0xwhatever
> FAIL: gdb.base/attach.exp: attach when process' a.out not in cwd
>
> This happened on a machine running GNU/Linux with glibc 2.3.2.
> Further debugging showed that the function first_link_map_member()
> in solib-svr4.c happened to access memory which is not in the memory
> map of the process which GDB tried to attach to.
>
> What happens is that shared libs are not necessarily mapped to the same
> virtual address in different processes. But GDB does not invalidate
> the solib state or in other words, does not reset the static variable
> debug_base back to 0 to force to reload the address information when
> attaching to another process. Therefore there's a pretty good chance
> for the debug_base pointer to point into nirvana when attaching to
> another process, leading to the above problem.
>
> The below patch avoids that problem by calling CLEAR_SOLIB in attach_command,
> before the target process gets attached to.
>
> Ok to apply?
>
>
> Corinna
>
> * infcmd.c (attach_command): Call CLEAR_SOLIB if available.
Okay.
Kevin