public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH 1/5] libdwfl: don't bother freeing frames outside of dwfl_thread_getframes
Date: Mon, 07 Oct 2019 09:05:00 -0000	[thread overview]
Message-ID: <3781a93480de5d91ab8df92a04517654117643d8.1570438723.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1570438723.git.osandov@fb.com>

From: Omar Sandoval <osandov@fb.com>

dwfl_thread_getframes always frees the state before returning, so
dwfl_getthreads and getthread don't need to do it.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdwfl/ChangeLog    |  6 ++++++
 libdwfl/dwfl_frame.c | 18 +++---------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 04a39637..f4a3cad9 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -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.
diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index 881f735a..20bdbd9b 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -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;
-- 
2.23.0

  parent reply	other threads:[~2019-10-07  9:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07  9:05 [PATCH 0/5] libdwfl: expand stack frame interface Omar Sandoval
2019-10-07  9:05 ` [PATCH 2/5] libdwfl: only use thread->unwound for initial frame Omar Sandoval
2019-10-29 22:20   ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 4/5] libdwfl: cache Dwfl_Module and Dwarf_Frame for Dwfl_Frame Omar Sandoval
2019-10-30 13:04   ` Mark Wielaard
2019-10-30 23:55     ` Omar Sandoval
2019-10-31 16:29       ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 5/5] libdwfl: add interface for evaluating DWARF expressions in a frame Omar Sandoval
2019-10-30 13:23   ` Mark Wielaard
2019-10-30 23:59     ` Omar Sandoval
2019-10-31 16:40       ` Mark Wielaard
2019-10-07  9:05 ` Omar Sandoval [this message]
2019-10-29 15:55   ` [PATCH 1/5] libdwfl: don't bother freeing frames outside of dwfl_thread_getframes Mark Wielaard
2019-10-29 16:17     ` Omar Sandoval
2019-10-29 16:52       ` Mark Wielaard
2019-10-07  9:05 ` [PATCH 3/5] libdwfl: add interface for attaching to/detaching from threads Omar Sandoval
2019-10-30 12:47   ` Mark Wielaard
2019-10-30 23:49     ` Omar Sandoval
2019-10-31 16:21       ` Mark Wielaard
2019-10-31 17:13         ` Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3781a93480de5d91ab8df92a04517654117643d8.1570438723.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).