This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 0/3] Live PIDs with deleted files by /dev/PID/mem


On Tue, 04 Mar 2014 11:40:21 +0100, Mark Wielaard wrote:
[...]
> --- a/libdwfl/libdwflP.h
> +++ b/libdwfl/libdwflP.h
[...]
> @@ -387,6 +388,39 @@ struct dwfl_arange
>  };
>  
>  
> +/* Structure used for keeping track of ptrace attaching a thread.
> +   Shared by linux-pid-attach and linux-proc-maps.  If it has been setup
> +   then get the instance through __libdwfl_get_pid_arg.  */
> +struct pid_arg

IMO the namespace should be 'struct __libdwfl_pid_arg'.


[...]
> --- a/libdwfl/linux-proc-maps.c
> +++ b/libdwfl/linux-proc-maps.c
> @@ -339,34 +339,60 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
[...]
> +      bool detach = false;
> +      bool tid_was_stopped = false;
> +      struct pid_arg *pid_arg = __libdwfl_get_pid_arg (mod->dwfl);
> +      if (pid_arg != NULL && ! pid_arg->assume_ptrace_stopped)
> +	{
> +	  pid_t tid = pid_arg->tid_attached;
> +	  if (tid != 0)
> +	    {
> +	      /* If the pid already is attached we are fine, otherwise
> +		 just read through the thread that is attached.  */
> +	      if (tid != pid)
> +		pid = tid;

The 'if' conditional has no meaning but it is probably meant for possible
better code readability.


> +	    }
> +	  else
> +	    detach = __libdwfl_ptrace_attach (pid, &tid_was_stopped);
> +	}
> +
>        char *fname;
>        if (asprintf (&fname, PROCMEMFMT, pid) < 0)
>  	return -1;
[...]


In general I believe reading /proc/PID/maps is safer than the guessing by
elf_from_remote_memory(), for example because the image may come from mmap()
and not from dlopen().  But I guess it may be the common disagreement.
I do not mind much using elf_from_remote_memory() instead.


Jan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]