+/* Return the dummy frame cache, it contains both the ID, and a
+ pointer to the regcache. */
+struct dummy_frame_cache
+{
+ struct frame_id this_id;
+ struct regcache *prev_regcache;
+};
+
+int
+dummy_frame_sniffer (const struct frame_unwind *self,
+ struct frame_info *next_frame,
+ void **this_prologue_cache)
+{
+ struct dummy_frame *dummyframe;
+ struct frame_id this_id;
+
+ /* When unwinding a normal frame, the stack structure is determined
+ by analyzing the frame's function's code (be it using brute force
+ prologue analysis, or the dwarf2 CFI). In the case of a dummy
+ frame, that simply isn't possible. The PC is either the program
+ entry point, or some random address on the stack. Trying to use
+ that PC to apply standard frame ID unwind techniques is just
+ asking for trouble. */
+ /* Use an architecture specific method to extract the prev's dummy
+ ID from the next frame. Note that this method uses
+ frame_register_unwind to obtain the register values needed to
+ determine the dummy frame's ID. */
+ this_id = gdbarch_unwind_dummy_id (get_frame_arch (next_frame), next_frame);
+
+ /* Use that ID to find the corresponding cache entry. */
+ for (dummyframe = dummy_frame_stack;
+ dummyframe != NULL;
+ dummyframe = dummyframe->next)
+ {
+ /* Does the PC fall within the dummy frame's breakpoint
+ instruction. If not, discard this one. */
+ if (!(this_id.code_addr >= dummyframe->call_lo
+ && this_id.code_addr < dummyframe->call_hi))
+ continue;
+ /* Does the FP match? "infcall.c" explicitly saved the
+ top-of-stack before the inferior function call, assume
+ unwind_dummy_id() returns that same stack value. */
+ if (this_id.stack_addr != dummyframe->top)
+ continue;
+ /* The FP matches this dummy frame. */
+ {
+ struct dummy_frame_cache *cache;
+ cache = FRAME_OBSTACK_ZALLOC (struct dummy_frame_cache);
+ cache->prev_regcache = dummyframe->regcache;
+ cache->this_id = this_id;
+ (*this_prologue_cache) = cache;
+ return 1;
+ }
+ }
+ return 0;
+}
+