]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: don't bother freeing frames outside of dwfl_thread_getframes
authorOmar Sandoval <osandov@fb.com>
Mon, 7 Oct 2019 09:05:35 +0000 (02:05 -0700)
committerMark Wielaard <mark@klomp.org>
Tue, 29 Oct 2019 16:48:05 +0000 (17:48 +0100)
dwfl_thread_getframes always frees the state before returning, so
dwfl_getthreads and getthread don't need to do it. The only place
we allocate the state is from dwfl_thread_getframes and we always
free it before returning from that function.

Signed-off-by: Omar Sandoval <osandov@fb.com>
libdwfl/ChangeLog
libdwfl/dwfl_frame.c

index 04a39637e9a4b5dc925bf1551e9b8ae13fc16194..f4a3cad9af87c4a54fa70517ce11e391e34323bc 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-07  Omar Sandoval  <osandov@fb.com>
+
+       * dwfl_frame.c (dwfl_getthreads): Get rid of unnecessary
+       thread_free_all_states calls.
+       (getthread): Ditto.
+
 2019-08-12  Mark Wielaard  <mark@klomp.org>
 
        * gzip.c (open_stream): Return DWFL_E_ERRNO on bad file operation.
index 881f735af24d71dd38647c1f8932a109d21321df..20bdbd9b27d453e1a64c575a9da99d08fc8cd87b 100644 (file)
@@ -279,24 +279,15 @@ dwfl_getthreads (Dwfl *dwfl, int (*callback) (Dwfl_Thread *thread, void *arg),
                                                    process->callbacks_arg,
                                                    &thread.callbacks_arg);
       if (thread.tid < 0)
-       {
-         Dwfl_Error saved_errno = dwfl_errno ();
-         thread_free_all_states (&thread);
-         __libdwfl_seterrno (saved_errno);
-         return -1;
-       }
+       return -1;
       if (thread.tid == 0)
        {
-         thread_free_all_states (&thread);
          __libdwfl_seterrno (DWFL_E_NOERROR);
          return 0;
        }
       int err = callback (&thread, arg);
       if (err != DWARF_CB_OK)
-       {
-         thread_free_all_states (&thread);
-         return err;
-       }
+       return err;
       assert (thread.unwound == NULL);
     }
   /* NOTREACHED */
@@ -356,11 +347,8 @@ getthread (Dwfl *dwfl, pid_t tid,
       if (process->callbacks->get_thread (dwfl, tid, process->callbacks_arg,
                                          &thread.callbacks_arg))
        {
-         int err;
          thread.tid = tid;
-         err = callback (&thread, arg);
-         thread_free_all_states (&thread);
-         return err;
+         return callback (&thread, arg);
        }
 
       return -1;