Re: [patch] Implement qXfer:libraries for Linux/gdbserver

Paul Pluzhnikov
2011-08-08T21:31:46Z

On Mon, Aug 8, 2011 at 2:09 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:

> with:
> ./gdbserver :1234 ~/t/pause64
> ../gdb ~/t/pause64 -ex 'target remote localhost:1234' -ex 'b main' -ex c
>
> it falls back back memory-transfers as DT_DEBUG is zero initially at _start.
>
> just to get the patch integrated on some final patches assembly.

Thanks.

A patch incorporating that change is attached. Or not.

I see you've reworked some of the gdbserver code as well. I'll update
the original thread with a unified patch.

> gdb/gdbserver/
> 2011-08-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        Fix initial zero DT_DEBUG.
>        * linux-low.c (linux_add_process): Remove r_debug initialization.
>        (get_r_debug): Update function comment.  Return -1 when DT_DEBUG is not
>        found.
>        (linux_qxfer_libraries): Call get_r_debug on -1 (not 0).  Return on
>        both -1 or 0.
>
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -264,7 +264,6 @@ linux_add_process (int pid, int attached)
>
>   proc = add_process (pid, attached);
>   proc->private = xcalloc (1, sizeof (*proc->private));
> -  proc->private->r_debug = (CORE_ADDR) -1;
>
>   if (the_low_target.new_process != NULL)
>     proc->private->arch_private = the_low_target.new_process ();
> @@ -4863,7 +4862,8 @@ get_dynamic (const int pid, const int is_elf64)
>   return 0;
>  }
>
> -/* Return &_r_debug in the inferior, or 0 if not present.  */
> +/* Return &_r_debug in the inferior, or -1 if not present.  Return value
> +   can be 0 if the inferior does not yet have the library list initialized.  */
>
>  static CORE_ADDR
>  get_r_debug (const int pid, const int is_elf64)
> @@ -4874,7 +4874,7 @@ get_r_debug (const int pid, const int is_elf64)
>
>   dynamic_memaddr = get_dynamic (pid, is_elf64);
>   if (dynamic_memaddr == 0)
> -    return 0;
> +    return (CORE_ADDR) -1;

I've updated the other return from get_r_debug() (if no DT_DEBUG
found) to also return -1.

Thanks,
--
Paul Pluzhnikov