|
|
861f93 |
http://sourceware.org/ml/gdb-cvs/2013-05/msg00141.html
|
|
|
861f93 |
|
|
|
861f93 |
### src/gdb/ChangeLog 2013/05/17 06:58:33 1.15565
|
|
|
861f93 |
### src/gdb/ChangeLog 2013/05/17 08:34:18 1.15566
|
|
|
861f93 |
## -1,3 +1,18 @@
|
|
|
861f93 |
+2013-05-17 Phil Muldoon <pmuldoon@redhat.com>
|
|
|
861f93 |
+
|
|
|
861f93 |
+ * frame.c (frame_stash): Convert to htab.
|
|
|
861f93 |
+ (frame_addr_hash): New function.
|
|
|
861f93 |
+ (frame_addr_hash_eq): New function.
|
|
|
861f93 |
+ (frame_stash_create): Convert function to create
|
|
|
861f93 |
+ a hash table.
|
|
|
861f93 |
+ (frame_stash_add): Convert function to add an entry to a hash
|
|
|
861f93 |
+ table.
|
|
|
861f93 |
+ (frame_stash_find): Convert function to search the hash table.
|
|
|
861f93 |
+ (frame_stash_invalidate): Convert function to empty the hash
|
|
|
861f93 |
+ table.
|
|
|
861f93 |
+ (get_frame_id): Only add to stash if a frame_id is created.
|
|
|
861f93 |
+ (_initialize_frame): Call frame_stash_create.
|
|
|
861f93 |
+
|
|
|
861f93 |
2013-05-16 Yue Lu <hacklu.newborn@gmail.com> (tiny change)
|
|
|
861f93 |
|
|
|
861f93 |
* configure.ac: Ensure MIG is available when building for GNU Hurd
|
|
|
861f93 |
--- src/gdb/frame.c 2013/04/10 15:11:11 1.317
|
|
|
861f93 |
+++ src/gdb/frame.c 2013/05/17 08:34:18 1.318
|
|
|
861f93 |
@@ -43,6 +43,7 @@
|
|
|
861f93 |
#include "block.h"
|
|
|
861f93 |
#include "inline-frame.h"
|
|
|
861f93 |
#include "tracepoint.h"
|
|
|
861f93 |
+#include "hashtab.h"
|
|
|
861f93 |
|
|
|
861f93 |
static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
|
|
|
861f93 |
static struct frame_info *get_prev_frame_raw (struct frame_info *this_frame);
|
|
|
861f93 |
@@ -128,38 +129,107 @@
|
|
|
861f93 |
enum unwind_stop_reason stop_reason;
|
|
|
861f93 |
};
|
|
|
861f93 |
|
|
|
861f93 |
-/* A frame stash used to speed up frame lookups. */
|
|
|
861f93 |
+/* A frame stash used to speed up frame lookups. Create a hash table
|
|
|
861f93 |
+ to stash frames previously accessed from the frame cache for
|
|
|
861f93 |
+ quicker subsequent retrieval. The hash table is emptied whenever
|
|
|
861f93 |
+ the frame cache is invalidated. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+static htab_t frame_stash;
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Internal function to calculate a hash from the frame_id addresses,
|
|
|
861f93 |
+ using as many valid addresses as possible. Frames below level 0
|
|
|
861f93 |
+ are not stored in the hash table. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+static hashval_t
|
|
|
861f93 |
+frame_addr_hash (const void *ap)
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ const struct frame_info *frame = ap;
|
|
|
861f93 |
+ const struct frame_id f_id = frame->this_id.value;
|
|
|
861f93 |
+ hashval_t hash = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ gdb_assert (f_id.stack_addr_p || f_id.code_addr_p
|
|
|
861f93 |
+ || f_id.special_addr_p);
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if (f_id.stack_addr_p)
|
|
|
861f93 |
+ hash = iterative_hash (&f_id.stack_addr,
|
|
|
861f93 |
+ sizeof (f_id.stack_addr), hash);
|
|
|
861f93 |
+ if (f_id.code_addr_p)
|
|
|
861f93 |
+ hash = iterative_hash (&f_id.code_addr,
|
|
|
861f93 |
+ sizeof (f_id.code_addr), hash);
|
|
|
861f93 |
+ if (f_id.special_addr_p)
|
|
|
861f93 |
+ hash = iterative_hash (&f_id.special_addr,
|
|
|
861f93 |
+ sizeof (f_id.special_addr), hash);
|
|
|
861f93 |
|
|
|
861f93 |
-/* We currently only stash one frame at a time, as this seems to be
|
|
|
861f93 |
- sufficient for now. */
|
|
|
861f93 |
-static struct frame_info *frame_stash = NULL;
|
|
|
861f93 |
+ return hash;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Internal equality function for the hash table. This function
|
|
|
861f93 |
+ defers equality operations to frame_id_eq. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+static int
|
|
|
861f93 |
+frame_addr_hash_eq (const void *a, const void *b)
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ const struct frame_info *f_entry = a;
|
|
|
861f93 |
+ const struct frame_info *f_element = b;
|
|
|
861f93 |
|
|
|
861f93 |
-/* Add the following FRAME to the frame stash. */
|
|
|
861f93 |
+ return frame_id_eq (f_entry->this_id.value,
|
|
|
861f93 |
+ f_element->this_id.value);
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Internal function to create the frame_stash hash table. 100 seems
|
|
|
861f93 |
+ to be a good compromise to start the hash table at. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+static void
|
|
|
861f93 |
+frame_stash_create (void)
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ frame_stash = htab_create (100,
|
|
|
861f93 |
+ frame_addr_hash,
|
|
|
861f93 |
+ frame_addr_hash_eq,
|
|
|
861f93 |
+ NULL);
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Internal function to add a frame to the frame_stash hash table. Do
|
|
|
861f93 |
+ not store frames below 0 as they may not have any addresses to
|
|
|
861f93 |
+ calculate a hash. */
|
|
|
861f93 |
|
|
|
861f93 |
static void
|
|
|
861f93 |
frame_stash_add (struct frame_info *frame)
|
|
|
861f93 |
{
|
|
|
861f93 |
- frame_stash = frame;
|
|
|
861f93 |
+ /* Do not stash frames below level 0. */
|
|
|
861f93 |
+ if (frame->level >= 0)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ struct frame_info **slot;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ slot = (struct frame_info **) htab_find_slot (frame_stash,
|
|
|
861f93 |
+ frame,
|
|
|
861f93 |
+ INSERT);
|
|
|
861f93 |
+ *slot = frame;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
}
|
|
|
861f93 |
|
|
|
861f93 |
-/* Search the frame stash for an entry with the given frame ID.
|
|
|
861f93 |
- If found, return that frame. Otherwise return NULL. */
|
|
|
861f93 |
+/* Internal function to search the frame stash for an entry with the
|
|
|
861f93 |
+ given frame ID. If found, return that frame. Otherwise return
|
|
|
861f93 |
+ NULL. */
|
|
|
861f93 |
|
|
|
861f93 |
static struct frame_info *
|
|
|
861f93 |
frame_stash_find (struct frame_id id)
|
|
|
861f93 |
{
|
|
|
861f93 |
- if (frame_stash && frame_id_eq (frame_stash->this_id.value, id))
|
|
|
861f93 |
- return frame_stash;
|
|
|
861f93 |
+ struct frame_info dummy;
|
|
|
861f93 |
+ struct frame_info *frame;
|
|
|
861f93 |
|
|
|
861f93 |
- return NULL;
|
|
|
861f93 |
+ dummy.this_id.value = id;
|
|
|
861f93 |
+ frame = htab_find (frame_stash, &dummy);
|
|
|
861f93 |
+ return frame;
|
|
|
861f93 |
}
|
|
|
861f93 |
|
|
|
861f93 |
-/* Invalidate the frame stash by removing all entries in it. */
|
|
|
861f93 |
+/* Internal function to invalidate the frame stash by removing all
|
|
|
861f93 |
+ entries in it. This only occurs when the frame cache is
|
|
|
861f93 |
+ invalidated. */
|
|
|
861f93 |
|
|
|
861f93 |
static void
|
|
|
861f93 |
frame_stash_invalidate (void)
|
|
|
861f93 |
{
|
|
|
861f93 |
- frame_stash = NULL;
|
|
|
861f93 |
+ htab_empty (frame_stash);
|
|
|
861f93 |
}
|
|
|
861f93 |
|
|
|
861f93 |
/* Flag to control debugging. */
|
|
|
861f93 |
@@ -345,10 +415,9 @@
|
|
|
861f93 |
fprint_frame_id (gdb_stdlog, fi->this_id.value);
|
|
|
861f93 |
fprintf_unfiltered (gdb_stdlog, " }\n");
|
|
|
861f93 |
}
|
|
|
861f93 |
+ frame_stash_add (fi);
|
|
|
861f93 |
}
|
|
|
861f93 |
|
|
|
861f93 |
- frame_stash_add (fi);
|
|
|
861f93 |
-
|
|
|
861f93 |
return fi->this_id.value;
|
|
|
861f93 |
}
|
|
|
861f93 |
|
|
|
861f93 |
@@ -2451,6 +2520,8 @@
|
|
|
861f93 |
{
|
|
|
861f93 |
obstack_init (&frame_cache_obstack);
|
|
|
861f93 |
|
|
|
861f93 |
+ frame_stash_create ();
|
|
|
861f93 |
+
|
|
|
861f93 |
observer_attach_target_changed (frame_observer_target_changed);
|
|
|
861f93 |
|
|
|
861f93 |
add_prefix_cmd ("backtrace", class_maintenance, set_backtrace_cmd, _("\
|