This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/PATCH] PR/9711: quadratic slowdown for deep stack traces
- From: Doug Evans <dje at google dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 7 Sep 2009 00:29:53 -0700
- Subject: Re: [RFA/PATCH] PR/9711: quadratic slowdown for deep stack traces
- References: <20090903183658.GJ4343@adacore.com>
On Thu, Sep 3, 2009 at 11:36 AM, Joel Brobecker<brobecker@adacore.com> wrote:
> 2009-09-03 ?Joel Brobecker ?<brobecker@adacore.com>
>
> ? ? ? ?Avoid quadratic behavior when computing the value of a register.
> ? ? ? ?* frame.c (frame_cache): New static constant.
> ? ? ? ?(frame_cache_add, frame_cache_find, frame_cache_invalidate):
> ? ? ? ?New functions.
> ? ? ? ?(get_frame_id): Minor reformatting. Add the frame to the frame cache.
> ? ? ? ?(frame_find_by_id): Search the frame cache first before walking all
> ? ? ? ?frames starting from te current_frame.
> ? ? ? ?(reinit_frame_cache): Add call to frame_cache_invalidate ();
Hi.
Nit: It seems like there's a redundant call to frame_id_eq in frame_find_by_id.
+/* Search the frame cache for an entry with the given frame ID.
+ If found, return that frame. Otherwise return NULL. */
+static struct frame_info *
+frame_cache_find (struct frame_id id)
+{
+ if (frame_cache && frame_id_eq (frame_cache->this_id.value, id))
+ return frame_cache;
+
+ return NULL;
+}
@@ -514,6 +547,11 @@ frame_find_by_id (struct frame_id id)
if (!frame_id_p (id))
return NULL;
+ /* Try using the frame cache first. */
+ frame = frame_cache_find (id);
+ if (frame && frame_id_eq (frame->this_id.value, id))
+ return frame;
+
for (frame = get_current_frame (); ; frame = prev_frame)
{
struct frame_id this = get_frame_id (frame);