]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: dwfl_standard_argp should not fail when not able to attach Dwfl.
authorMark Wielaard <mjw@redhat.com>
Tue, 10 Jun 2014 13:09:23 +0000 (15:09 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 11 Jun 2014 13:14:00 +0000 (15:14 +0200)
As pointed out in https://bugzilla.redhat.com/show_bug.cgi?id=1107654
commit 191080 introduced a thinko that caused dwfl_standard_argp
to fail if the Dwfl couldn't be attached. Instead of generating a warning
as the comment intended, the failure would be fatal. But even warning
about dwfl_core_file_attach () or dwfl_linux_proc_attach () failing
would be a mistake. The caller/user might not be interested in such
a non-fatal issue. So just ignore if the call failed for whatever reason.
If the caller is interested in warning up front about this issue, then
dwfl_pid () should be called to check the Dwfl is attached. Things should
work just fine for anything that doesn't call any of the dwfl_state related
functions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/argp-std.c

index 2fd2a1a35b605cb0a8232fd0ff4f26ba0960624e..c13e01fed456861df3ef838e81549db8dcafb7b6 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-10  Mark Wielaard  <mjw@redhat.com>
+
+       * argp-std.c (parse_opt): Ignore errors from dwfl_core_file_attach
+       or dwfl_linux_proc_attach.
+
 2014-05-15  Mark Wielaard  <mjw@redhat.com>
 
        * linux-proc-maps.c (grovel_auxv): Close fd on error.
index 8d2bc6aab285d3735e457e49a98c0ad952a07b66..42b7e78380047ae67560eb77d7ad8ed9b621ae67 100644 (file)
@@ -171,10 +171,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
            if (result != 0)
              return fail (dwfl, result, arg);
 
-           result = INTUSE(dwfl_linux_proc_attach) (dwfl, atoi (arg), false);
-           if (result != 0)
-             /* Non-fatal to not be able to attach to process.  */
-             failure (dwfl, result, _("cannot attach to process"));
+           /* Non-fatal to not be able to attach to process, ignore error.  */
+           INTUSE(dwfl_linux_proc_attach) (dwfl, atoi (arg), false);
+
            opt->dwfl = dwfl;
          }
        else
@@ -301,10 +300,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
                return fail (dwfl, result, opt->core);
              }
 
-           result = INTUSE(dwfl_core_file_attach) (dwfl, core);
-           if (result < 0)
-             /* Non-fatal to not be able to attach to core.  */
-             failure (dwfl, result, _("cannot attach to core"));
+           /* Non-fatal to not be able to attach to core, ignore error.  */
+           INTUSE(dwfl_core_file_attach) (dwfl, core);
 
            /* From now we leak FD and CORE.  */