This is the mail archive of the 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, 2014-03-04 at 11:40 +0100, Mark Wielaard wrote:
> On Mon, 2014-03-03 at 16:48 +0100, Mark Wielaard wrote:
> > Lets see how to combine the approaches most effectively.
> > I'll try and cleanup my patch to linux-proc-maps.c to make it possible
> > to use elf_from_remote_memory for "(deleted)" files to make it easier to
> > test things out.
> Attached is a patch that does this. I'll push it to the mjw/pending
> branch. For now only tested on a RHEL6 x86_64 2.6.32 kernel. It does
> seem to work at least for that setup. I'll try on some other setups
> later.

A bit more testing revealed a small issue in case of error. We must make
sure to always detach. Fixed as follows:

diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 8d18274..55edd7c 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -395,22 +395,23 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)),
       char *fname;
       if (asprintf (&fname, PROCMEMFMT, pid) < 0)
-       return -1;
+       goto detach;
       int fd = open64 (fname, O_RDONLY);
       free (fname);
       if (fd < 0)
-       return -1;
+       goto detach;
       *elfp = elf_from_remote_memory (base, getpagesize (), NULL,
                                      &read_proc_memory, &fd);
       close (fd);
+      *file_name = NULL;
+    detach:
       if (detach)
        __libdwfl_ptrace_detach (pid, tid_was_stopped);
-      *file_name = NULL;
       return -1;
Fixed up the patch as pushed to mjw/pending.



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