• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisiónf4ab3f81e8643c5b4c865df463f0cba56062ba96 (tree)
Tiempo2003-03-07 04:21:30
AutorAndrew Cagney <cagney@redh...>
CommiterAndrew Cagney

Log Message

2003-03-06 Andrew Cagney <cagney@redhat.com>

* gdbarch.sh (gdbarch_unwind_pc): New method.
* gdbarch.h, gdbarch.c: Regenerate.
* frame.c (frame_pc_unwind): Rewrite. Prefer gdbarch_unwind_pc,
but use read_pc and FRAME_SAVED_PC as fall backs.
(frame_saved_regs_pc_unwind): Delete function.
(trad_frame_unwinder): Update.
* frame-unwind.h (frame_unwind_pc_ftype): Delete declaration.
(struct frame_unwind): Update.
* dummy-frame.c (dummy_frame_pc_unwind): Delete function.
(dummy_frame_unwind): Update.
* sentinel-frame.c (sentinel_frame_pc_unwind): Delete function.
(sentinel_frame_unwinder): Update.
* d10v-tdep.c (d10v_frame_pc_unwind): Delete function.
(d10v_frame_unwind): Update.
(d10v_unwind_pc): New function.
(d10v_gdbarch_init): Set unwind_pc.

2003-03-05 Andrew Cagney <cagney@redhat.com>

* dummy-frame.c (dummy_frame_id_unwind): Abort if called.
(cached_find_dummy_frame): Add hack to obtain this thread's id
without calling id unwind.
* frame.h: Merge with mainline.
* d10v-tdep.c: Merge with mainline.
* frame.c: Merge with mainline.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,31 @@
1+2003-03-06 Andrew Cagney <cagney@redhat.com>
2+
3+ * gdbarch.sh (gdbarch_unwind_pc): New method.
4+ * gdbarch.h, gdbarch.c: Regenerate.
5+ * frame.c (frame_pc_unwind): Rewrite. Prefer gdbarch_unwind_pc,
6+ but use read_pc and FRAME_SAVED_PC as fall backs.
7+ (frame_saved_regs_pc_unwind): Delete function.
8+ (trad_frame_unwinder): Update.
9+ * frame-unwind.h (frame_unwind_pc_ftype): Delete declaration.
10+ (struct frame_unwind): Update.
11+ * dummy-frame.c (dummy_frame_pc_unwind): Delete function.
12+ (dummy_frame_unwind): Update.
13+ * sentinel-frame.c (sentinel_frame_pc_unwind): Delete function.
14+ (sentinel_frame_unwinder): Update.
15+ * d10v-tdep.c (d10v_frame_pc_unwind): Delete function.
16+ (d10v_frame_unwind): Update.
17+ (d10v_unwind_pc): New function.
18+ (d10v_gdbarch_init): Set unwind_pc.
19+
20+2003-03-05 Andrew Cagney <cagney@redhat.com>
21+
22+ * dummy-frame.c (dummy_frame_id_unwind): Abort if called.
23+ (cached_find_dummy_frame): Add hack to obtain this thread's id
24+ without calling id unwind.
25+ * frame.h: Merge with mainline.
26+ * d10v-tdep.c: Merge with mainline.
27+ * frame.c: Merge with mainline.
28+
129 2003-03-04 Andrew Cagney <cagney@redhat.com>
230
331 * d10v-tdep.c (struct d10v_unwind_cache): Add field "r11_addr",
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -616,8 +616,11 @@ struct d10v_unwind_cache
616616 CORE_ADDR base;
617617 int size;
618618 CORE_ADDR *saved_regs;
619- LONGEST next_addr;
620- LONGEST r11_addr;
619+ /* How far the SP and r11 (FP) have been offset from the start of
620+ the stack frame (as defined by the previous frame's stack
621+ pointer). */
622+ LONGEST sp_offset;
623+ LONGEST r11_offset;
621624 int uses_frame;
622625 void **regs;
623626 };
@@ -632,8 +635,8 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
632635 if ((op & 0x7E1F) == 0x6C1F)
633636 {
634637 n = (op & 0x1E0) >> 5;
635- info->next_addr -= 2;
636- info->saved_regs[n] = info->next_addr;
638+ info->sp_offset -= 2;
639+ info->saved_regs[n] = info->sp_offset;
637640 return 1;
638641 }
639642
@@ -641,9 +644,9 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
641644 else if ((op & 0x7E3F) == 0x6E1F)
642645 {
643646 n = (op & 0x1E0) >> 5;
644- info->next_addr -= 4;
645- info->saved_regs[n] = info->next_addr;
646- info->saved_regs[n + 1] = info->next_addr + 2;
647+ info->sp_offset -= 4;
648+ info->saved_regs[n] = info->sp_offset;
649+ info->saved_regs[n + 1] = info->sp_offset + 2;
647650 return 1;
648651 }
649652
@@ -653,7 +656,7 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
653656 n = (op & 0x1E) >> 1;
654657 if (n == 0)
655658 n = 16;
656- info->next_addr -= n;
659+ info->sp_offset -= n;
657660 return 1;
658661 }
659662
@@ -661,7 +664,7 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
661664 if (op == 0x417E)
662665 {
663666 info->uses_frame = 1;
664- info->r11_addr = info->next_addr;
667+ info->r11_offset = info->sp_offset;
665668 return 1;
666669 }
667670
@@ -669,7 +672,7 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
669672 if ((op & 0x7E1F) == 0x6816)
670673 {
671674 n = (op & 0x1E0) >> 5;
672- info->saved_regs[n] = info->r11_addr;
675+ info->saved_regs[n] = info->r11_offset;
673676 return 1;
674677 }
675678
@@ -681,7 +684,7 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
681684 if ((op & 0x7E1F) == 0x681E)
682685 {
683686 n = (op & 0x1E0) >> 5;
684- info->saved_regs[n] = info->next_addr;
687+ info->saved_regs[n] = info->sp_offset;
685688 return 1;
686689 }
687690
@@ -689,8 +692,8 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
689692 if ((op & 0x7E3F) == 0x3A1E)
690693 {
691694 n = (op & 0x1E0) >> 5;
692- info->saved_regs[n] = info->next_addr;
693- info->saved_regs[n + 1] = info->next_addr + 2;
695+ info->saved_regs[n] = info->sp_offset;
696+ info->saved_regs[n + 1] = info->sp_offset + 2;
694697 return 1;
695698 }
696699
@@ -708,8 +711,8 @@ d10v_frame_unwind_cache (struct frame_info *next_frame,
708711 void **this_cache)
709712 {
710713 CORE_ADDR pc;
711- ULONGEST sp;
712- ULONGEST base;
714+ ULONGEST prev_sp;
715+ ULONGEST this_base;
713716 unsigned long op;
714717 unsigned short op1, op2;
715718 int i;
@@ -724,7 +727,7 @@ d10v_frame_unwind_cache (struct frame_info *next_frame,
724727
725728 info->size = 0;
726729
727- info->next_addr = 0;
730+ info->sp_offset = 0;
728731
729732 pc = get_pc_function_start (frame_pc_unwind (next_frame));
730733
@@ -739,22 +742,22 @@ d10v_frame_unwind_cache (struct frame_info *next_frame,
739742 {
740743 /* add3 sp,sp,n */
741744 short n = op & 0xFFFF;
742- info->next_addr += n;
745+ info->sp_offset += n;
743746 }
744747 else if ((op & 0x3F0F0000) == 0x340F0000)
745748 {
746749 /* st rn, @(offset,sp) */
747750 short offset = op & 0xFFFF;
748751 short n = (op >> 20) & 0xF;
749- info->saved_regs[n] = info->next_addr + offset;
752+ info->saved_regs[n] = info->sp_offset + offset;
750753 }
751754 else if ((op & 0x3F1F0000) == 0x350F0000)
752755 {
753756 /* st2w rn, @(offset,sp) */
754757 short offset = op & 0xFFFF;
755758 short n = (op >> 20) & 0xF;
756- info->saved_regs[n] = info->next_addr + offset;
757- info->saved_regs[n + 1] = info->next_addr + offset + 2;
759+ info->saved_regs[n] = info->sp_offset + offset;
760+ info->saved_regs[n + 1] = info->sp_offset + offset + 2;
758761 }
759762 else
760763 break;
@@ -779,52 +782,50 @@ d10v_frame_unwind_cache (struct frame_info *next_frame,
779782 pc += 4;
780783 }
781784
782- info->size = -info->next_addr;
785+ info->size = -info->sp_offset;
783786
784- /* Compute the frame's base. */
787+ /* Compute the frame's base, and the previous frame's SP. */
785788 if (info->uses_frame)
786789 {
787- /* The SP was moved into the FP. This indicates that a new
788- frame was created. Get THIS frame's FP value by unwinding it
789- from the next frame. */
790- frame_unwind_unsigned_register (next_frame, FP_REGNUM, &base);
790+ /* The SP was moved to the FP. This indicates that a new frame
791+ was created. Get THIS frame's FP value by unwinding it from
792+ the next frame. */
793+ frame_unwind_unsigned_register (next_frame, FP_REGNUM, &this_base);
791794 /* The FP points at the last saved register. Adjust the FP back
792795 to before the first saved register giving the SP. */
793- sp = base + info->size;
796+ prev_sp = this_base + info->size;
794797 }
795798 else if (info->saved_regs[SP_REGNUM])
796799 {
797800 /* The SP was saved (which is very unusual), the frame base is
798801 just the PREV's frame's TOP-OF-STACK. */
799- base = read_memory_unsigned_integer (info->saved_regs[SP_REGNUM],
800- register_size (current_gdbarch,
801- SP_REGNUM));
802- sp = base;
802+ this_base = read_memory_unsigned_integer (info->saved_regs[SP_REGNUM],
803+ register_size (current_gdbarch,
804+ SP_REGNUM));
805+ prev_sp = this_base;
803806 }
804807 else
805808 {
806809 /* Assume that the FP is this frame's SP but with that pushed
807810 stack space added back. */
808- frame_unwind_unsigned_register (next_frame, SP_REGNUM, &base);
809- sp = base + info->size;
811+ frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base);
812+ prev_sp = this_base + info->size;
810813 }
811814
812- info->base = d10v_make_daddr (base);
813- sp = d10v_make_daddr (sp);
815+ info->base = d10v_make_daddr (this_base);
816+ prev_sp = d10v_make_daddr (prev_sp);
814817
815818 /* Adjust all the saved registers so that they contain addresses and
816819 not offsets. */
817820 for (i = 0; i < NUM_REGS - 1; i++)
818- {
819- if (info->saved_regs[i])
820- {
821- info->saved_regs[i] = (sp + info->saved_regs[i]);
822- }
823- }
821+ if (info->saved_regs[i])
822+ {
823+ info->saved_regs[i] = (prev_sp + info->saved_regs[i]);
824+ }
824825
825826 /* The SP_REGNUM is special. Instead of the address of the SP, the
826827 previous frame's SP value is saved. */
827- info->saved_regs[SP_REGNUM] = sp;
828+ info->saved_regs[SP_REGNUM] = prev_sp;
828829
829830 return info;
830831 }
@@ -1432,22 +1433,12 @@ display_trace (int low, int high)
14321433 }
14331434 }
14341435
1435-
14361436 static CORE_ADDR
1437-d10v_frame_pc_unwind (struct frame_info *next_frame,
1438- void **this_cache)
1437+d10v_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
14391438 {
1440- /* FIXME: This shouldn't be needed. Instead single per-architecture
1441- method should be called for all frames. */
1442- CORE_ADDR lr;
1443- struct d10v_unwind_cache *info
1444- = d10v_frame_unwind_cache (next_frame, this_cache);
1445- void *buffer = alloca (max_register_size (current_gdbarch));
1446- saved_regs_unwind (next_frame, info->saved_regs, LR_REGNUM, buffer);
1447- lr = extract_unsigned_integer (buffer, register_size (current_gdbarch,
1448- LR_REGNUM));
1449- return d10v_make_iaddr (lr);
1450-
1439+ ULONGEST pc;
1440+ frame_unwind_unsigned_register (next_frame, PC_REGNUM, &pc);
1441+ return d10v_make_iaddr (pc);
14511442 }
14521443
14531444 /* Given the next frame, determine the address of this function's
@@ -1587,18 +1578,6 @@ d10v_frame_register_unwind (struct frame_info *next_frame,
15871578 lvalp, addrp, realnump, bufferp);
15881579 }
15891580
1590-
1591-static struct frame_id
1592-d10v_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
1593-{
1594- ULONGEST base;
1595- struct frame_id id;
1596- id.pc = frame_pc_unwind (next_frame);
1597- frame_unwind_unsigned_register (next_frame, SP_REGNUM, &base);
1598- id.base = d10v_make_daddr (base);
1599- return id;
1600-}
1601-
16021581 static void
16031582 d10v_frame_pop (struct frame_info *next_frame, void **this_cache,
16041583 struct regcache *regcache)
@@ -1635,7 +1614,6 @@ d10v_frame_pop (struct frame_info *next_frame, void **this_cache,
16351614
16361615 static struct frame_unwind d10v_frame_unwind = {
16371616 d10v_frame_pop,
1638- d10v_frame_pc_unwind,
16391617 d10v_frame_id_unwind,
16401618 d10v_frame_register_unwind
16411619 };
@@ -1646,6 +1624,22 @@ d10v_frame_p (CORE_ADDR pc)
16461624 return &d10v_frame_unwind;
16471625 }
16481626
1627+/* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that
1628+ dummy frame. The frame ID's base needs to match the TOS value
1629+ saved by save_dummy_frame_tos(), and the PC match the dummy frame's
1630+ breakpoint. */
1631+
1632+static struct frame_id
1633+d10v_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
1634+{
1635+ ULONGEST base;
1636+ struct frame_id id;
1637+ id.pc = frame_pc_unwind (next_frame);
1638+ frame_unwind_unsigned_register (next_frame, SP_REGNUM, &base);
1639+ id.base = d10v_make_daddr (base);
1640+ return id;
1641+}
1642+
16491643 static gdbarch_init_ftype d10v_gdbarch_init;
16501644
16511645 static struct gdbarch *
@@ -1782,9 +1776,14 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
17821776 set_gdbarch_print_registers_info (gdbarch, d10v_print_registers_info);
17831777
17841778 frame_unwind_append_predicate (gdbarch, d10v_frame_p);
1779+
1780+ /* Methods for saving / extracting a dummy frame's ID. */
17851781 set_gdbarch_unwind_dummy_id (gdbarch, d10v_unwind_dummy_id);
17861782 set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
17871783
1784+ /* Return the unwound PC value. */
1785+ set_gdbarch_unwind_pc (gdbarch, d10v_unwind_pc);
1786+
17881787 return gdbarch;
17891788 }
17901789
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -108,8 +108,13 @@ struct dummy_frame *
108108 cached_find_dummy_frame (struct frame_info *next_frame, void **this_cache)
109109 {
110110 if ((*this_cache) == NULL)
111- (*this_cache) = find_dummy_frame (frame_pc_unwind (next_frame),
112- frame_id_unwind (next_frame).base);
111+ {
112+ /* FIXME: hack to find the frame ID of this frame. Need to do
113+ this better. */
114+ gdb_assert (next_frame->prev != NULL);
115+ (*this_cache) = find_dummy_frame (frame_pc_unwind (next_frame),
116+ next_frame->prev->frame);
117+ }
113118 return (*this_cache);
114119 }
115120
@@ -371,23 +376,6 @@ dummy_frame_register_unwind (struct frame_info *next_frame, void **this_cache,
371376 }
372377 }
373378
374-/* Assuming that FRAME is a dummy, return the resume address for the
375- previous frame. */
376-
377-static CORE_ADDR
378-dummy_frame_pc_unwind (struct frame_info *next_frame,
379- void **this_cache)
380-{
381- struct dummy_frame *dummy = cached_find_dummy_frame (next_frame, this_cache);
382- /* Oops! In a dummy-frame but can't find the stack dummy. Pretend
383- that the frame doesn't unwind. Should this function instead
384- return a has-no-caller indication? */
385- if (dummy == NULL)
386- return 0;
387- return dummy->pc;
388-}
389-
390-
391379 /* Assuming that FRAME is a dummy, return the ID of the calling frame
392380 (the frame that the dummy has the saved state of). */
393381
@@ -396,6 +384,7 @@ dummy_frame_id_unwind (struct frame_info *next_frame,
396384 void **this_cache,
397385 struct frame_id *this_id)
398386 {
387+#if 0
399388 struct dummy_frame *dummy = cached_find_dummy_frame (next_frame, this_cache);
400389 /* Oops! In a dummy-frame but can't find the stack dummy. Pretend
401390 that the frame doesn't unwind. Should this function instead
@@ -404,12 +393,19 @@ dummy_frame_id_unwind (struct frame_info *next_frame,
404393 (*this_id) = null_frame_id;
405394 else
406395 (*this_id) = dummy->id;
396+#else
397+ /* FIXME - with all the frames shuffled by one, it becomes possible
398+ to move the dummy frame unwind code to here. This is because,
399+ unlike the mainline, this function is called when determining the
400+ ID of the dummy, and not the ID of the dummy's caller. For the
401+ moment, this function is never called. */
402+ internal_error (__FILE__, __LINE__, "dummy_frame_pc_unwind called");
403+#endif
407404 }
408405
409406 static struct frame_unwind dummy_frame_unwind =
410407 {
411408 dummy_frame_pop,
412- dummy_frame_pc_unwind,
413409 dummy_frame_id_unwind,
414410 dummy_frame_register_unwind
415411 };
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -104,26 +104,6 @@ typedef void (frame_unwind_reg_ftype) (struct frame_info *next_frame,
104104
105105 /* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
106106 use the NEXT frame, and its register unwind method, to unwind THIS
107- frame's PC, returning the value of PC (the return address) in PREV
108- frame.
109-
110- Traditionally, THIS frame's PC was unwound by examining THIS
111- frame's function prolog and identifying where (in a register or on
112- the stack) that return address was saved.
113-
114- Please note that this per-frame method may be superseeded by an
115- architecture specific method that determines the unwound PC (aka
116- return address) using just the register unwind methods.
117-
118- THIS_CACHE can be used to share any prologue analysis data with the
119- other unwind methods. Memory for that cache should be allocated
120- using frame_obstack_zalloc(). */
121-
122-typedef CORE_ADDR (frame_unwind_pc_ftype) (struct frame_info *next_frame,
123- void **this_cache);
124-
125-/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
126- use the NEXT frame, and its register unwind method, to unwind THIS
127107 frame's entire stack, writing PREV's frames register values into
128108 REGCACHE.
129109
@@ -151,7 +131,6 @@ struct frame_unwind
151131 /* Should an attribute indicating the frame's address-in-block go
152132 here? */
153133 frame_unwind_pop_ftype *pop;
154- frame_unwind_pc_ftype *pc;
155134 frame_unwind_id_ftype *id;
156135 frame_unwind_reg_ftype *reg;
157136 };
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -135,27 +135,54 @@ frame_find_by_id (struct frame_id id)
135135 }
136136
137137 CORE_ADDR
138-frame_pc_unwind (struct frame_info *this_frame)
138+frame_pc_unwind (struct frame_info *next_frame)
139139 {
140- if (!this_frame->pc_unwind_cache_p)
140+ if (!next_frame->pc_unwind_cache_p)
141141 {
142- this_frame->pc_unwind_cache
143- = this_frame->unwind->pc (this_frame->next, &this_frame->unwind_cache);
144- this_frame->pc_unwind_cache_p = 1;
145- }
146- return this_frame->pc_unwind_cache;
147-}
148-
149-struct frame_id
150-frame_id_unwind (struct frame_info *this_frame)
151-{
152- if (!this_frame->id_unwind_cache_p)
153- {
154- this_frame->unwind->id (this_frame->next, &this_frame->unwind_cache,
155- &this_frame->id_unwind_cache);
156- this_frame->id_unwind_cache_p = 1;
142+ CORE_ADDR pc;
143+ if (gdbarch_unwind_pc_p (current_gdbarch))
144+ {
145+ /* The right way. The `pure' way. The one true way. This
146+ method depends solely on the register-unwind code to
147+ determine the value of registers in THIS frame, and hence
148+ the value of this frame's PC (resume address). A typical
149+ implementation is no more than:
150+
151+ frame_unwind_register (next_frame, ISA_PC_REGNUM, buf);
152+ return extract_address (buf, size of ISA_PC_REGNUM);
153+
154+ Note: this method is very heavily dependent on a correct
155+ register-unwind implementation, it pays to fix that
156+ method first; this method is frame type agnostic, since
157+ it only deals with register values, it works with any
158+ frame. This is all in stark contrast to the old
159+ FRAME_SAVED_PC which would try to directly handle all the
160+ different ways that a PC could be unwound. */
161+ pc = gdbarch_unwind_pc (current_gdbarch, next_frame);
162+ }
163+ else if (next_frame->level < 0)
164+ {
165+ /* FIXME: cagney/2003-03-06: Old code and and a sentinel
166+ frame. Do like was always done. Fetch the PC's value
167+ direct from the global registers array (via read_pc).
168+ This assumes that this frame belongs to the current
169+ global register cache. The assumption is dangerous. */
170+ pc = read_pc ();
171+ }
172+ else if (FRAME_SAVED_PC_P ())
173+ {
174+ /* FIXME: cagney/2003-03-06: Old code, but not a sentinel
175+ frame. Do like was always done. Note that this method,
176+ unlike unwind_pc(), tries to handle all the different
177+ frame cases directly. It fails. */
178+ pc = FRAME_SAVED_PC (next_frame);
179+ }
180+ else
181+ internal_error (__FILE__, __LINE__, "No gdbarch_unwind_pc method");
182+ next_frame->pc_unwind_cache = pc;
183+ next_frame->pc_unwind_cache_p = 1;
157184 }
158- return this_frame->id_unwind_cache;
185+ return next_frame->pc_unwind_cache;
159186 }
160187
161188 void
@@ -682,13 +709,6 @@ frame_saved_regs_register_unwind (struct frame_info *frame, void **cache,
682709 bufferp);
683710 }
684711
685-static CORE_ADDR
686-frame_saved_regs_pc_unwind (struct frame_info *frame, void **cache)
687-{
688- gdb_assert (FRAME_SAVED_PC_P ());
689- return FRAME_SAVED_PC (frame);
690-}
691-
692712 static void
693713 frame_saved_regs_id_unwind (struct frame_info *next_frame, void **cache,
694714 struct frame_id *id)
@@ -760,7 +780,6 @@ frame_saved_regs_pop (struct frame_info *fi, void **cache,
760780
761781 const struct frame_unwind trad_frame_unwinder = {
762782 frame_saved_regs_pop,
763- frame_saved_regs_pc_unwind,
764783 frame_saved_regs_id_unwind,
765784 frame_saved_regs_register_unwind
766785 };
@@ -1346,83 +1365,87 @@ get_prev_frame (struct frame_info *next_frame)
13461365 prev_frame->pc);
13471366
13481367 /* Find the prev's frame's ID. */
1349- {
1350- switch (prev_frame->type)
1351- {
1352- case DUMMY_FRAME:
1353- /* A dummy doesn't have anything resembling either a sane
1354- frame or PC. The PC is sitting in the entry code and the
1355- stack, which has nothing to do with that entry address, is
1356- a down right mess. Trying to use the standard frame ID
1357- unwind code to get the previous frame ID is just asking for
1358- trouble. */
1359- if (gdbarch_unwind_dummy_id_p (current_gdbarch))
1360- {
1361- /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS,
1362- previously saved the dummy ID that is being obtained
1363- here. Things only work if the two match. */
1364- gdb_assert (SAVE_DUMMY_FRAME_TOS_P ());
1365- /* Use an architecture specific method to extract the
1366- prev's dummy ID from the next frame. Note that this
1367- method typically uses frame_register_unwind to obtain
1368- register values needed to determine the dummy ID. */
1369- next_frame->id_unwind_cache =
1370- gdbarch_unwind_dummy_id (current_gdbarch, next_frame);
1371- }
1372- else if (next_frame->level == 0)
1373- {
1374- /* We're `unwinding' the sentinel frame. Just fake up the
1375- ID the same way that the traditional hacks did it. */
1376- next_frame->id_unwind_cache.pc = read_pc ();
1377- next_frame->id_unwind_cache.pc = read_fp ();
1378- }
1379- else
1380- {
1381- /* Outch! We're not on the innermost frame yet we're
1382- trying to unwind to a dummy. The architecture must
1383- provide the unwind_dummy_id() method. */
1384- internal_error (__FILE__, __LINE__,
1368+ switch (prev_frame->type)
1369+ {
1370+ case DUMMY_FRAME:
1371+ /* When unwinding a normal frame, the stack structure is
1372+ determined by analyzing the frame's function's code (be it
1373+ using brute force prologue analysis, or the dwarf2 CFI). In
1374+ the case of a dummy frame, that simply isn't possible. The
1375+ The PC is either the program entry point, or some random
1376+ address on the stack. Trying to use that PC to apply
1377+ standard frame ID unwind techniques is just asking for
1378+ trouble. */
1379+ if (gdbarch_unwind_dummy_id_p (current_gdbarch))
1380+ {
1381+ /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS,
1382+ previously saved the dummy frame's ID. Things only work
1383+ if the two return the same value. */
1384+ gdb_assert (SAVE_DUMMY_FRAME_TOS_P ());
1385+ /* Use an architecture specific method to extract the prev's
1386+ dummy ID from the next frame. Note that this method uses
1387+ frame_register_unwind to obtain the register values
1388+ needed to determine the dummy frame's ID. */
1389+ prev_frame->id = gdbarch_unwind_dummy_id (current_gdbarch,
1390+ next_frame);
1391+ }
1392+ else if (next_frame->level < 0)
1393+ {
1394+ /* We're unwinding a sentinel frame, the PC of which is
1395+ pointing at a stack dummy. Fake up the dummy frame's ID
1396+ using the same sequence as is found a traditional
1397+ unwinder. Once all architectures supply the
1398+ unwind_dummy_id method, this code can go away. */
1399+ prev_frame->id.base = read_fp ();
1400+ prev_frame->id.pc = read_pc ();
1401+ }
1402+ else
1403+ {
1404+ /* Outch! We're not on the innermost frame yet we're trying
1405+ to unwind to a dummy. The architecture must provide the
1406+ unwind_dummy_id() method. Abandon the unwind process but
1407+ only after first warning the user. */
1408+ internal_warning (__FILE__, __LINE__,
13851409 "Missing unwind_dummy_id architecture method");
1386- }
1387- break;
1388- case NORMAL_FRAME:
1389- case SIGTRAMP_FRAME:
1390- prev_frame->unwind->id (next_frame, &prev_frame->unwind_cache,
1391- &next_frame->id_unwind_cache);
1392- /* Check that the unwound ID is valid. */
1393- if (!frame_id_p (next_frame->id_unwind_cache))
1394- {
1395- if (frame_debug)
1396- fprintf_unfiltered (gdb_stdlog,
1397- "Outermost frame - unwound frame ID invalid\n");
1398- return NULL;
1399- }
1400- /* Check that the new frame isn't inner to (younger, below,
1401- next) the old frame. If that happens the frame unwind is
1402- going backwards. */
1403- /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since
1404- that doesn't have a valid frame ID. Should instead set the
1405- sentinel frame's frame ID to a `sentinel'. Leave it until
1406- after the switch to storing the frame ID, instead of the
1407- frame base, in the frame object. */
1408- if (next_frame->level >= 0
1409- && frame_id_inner (next_frame->id_unwind_cache,
1410- get_frame_id (next_frame)))
1411- error ("Unwound frame inner-to selected frame (corrupt stack?)");
1412- /* Note that, due to frameless functions, the stronger test of
1413- the new frame being outer to the old frame can't be used -
1414- frameless functions differ by only their PC value. */
1415- break;
1416- default:
1417- internal_error (__FILE__, __LINE__, "bad switch");
1418- }
1419- /* FIXME: cagney/2002-12-18: Instead of this hack, the frame ID
1420- should be directly stored in the `struct frame_info'.
1421- Unfortunatly, GDB isn't quite ready for this, need to get HP/UX
1422- multi-arch and make 'struct frame_info' opaque. */
1423- next_frame->id_unwind_cache_p = 1;
1424- prev_frame->frame = next_frame->id_unwind_cache.base;
1425- }
1410+ return NULL;
1411+ }
1412+ break;
1413+ case NORMAL_FRAME:
1414+ case SIGTRAMP_FRAME:
1415+ prev_frame->unwind->id (next_frame, &prev_frame->unwind_cache,
1416+ &prev_frame->id);
1417+ /* Check that the unwound ID is valid. */
1418+ if (!frame_id_p (prev_frame->id))
1419+ {
1420+ if (frame_debug)
1421+ fprintf_unfiltered (gdb_stdlog,
1422+ "Outermost frame - unwound frame ID invalid\n");
1423+ return NULL;
1424+ }
1425+ /* Check that the new frame isn't inner to (younger, below,
1426+ next) the old frame. If that happens the frame unwind is
1427+ going backwards. */
1428+ /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since
1429+ that doesn't have a valid frame ID. Should instead set the
1430+ sentinel frame's frame ID to a `sentinel'. Leave it until
1431+ after the switch to storing the frame ID, instead of the
1432+ frame base, in the frame object. */
1433+ if (next_frame->level >= 0
1434+ && frame_id_inner (prev_frame->id, get_frame_id (next_frame)))
1435+ error ("Unwound frame inner-to selected frame (corrupt stack?)");
1436+ /* Note that, due to frameless functions, the stronger test of
1437+ the new frame being outer to the old frame can't be used -
1438+ frameless functions differ by only their PC value. */
1439+ break;
1440+ default:
1441+ internal_error (__FILE__, __LINE__, "bad switch");
1442+ }
1443+
1444+ /* FIXME: cagney/2002-12-18: Instead of this hack, should only store
1445+ the frame ID in PREV_FRAME. Unfortunatly, some architectures
1446+ (HP/UX) still reply on EXTRA_FRAME_INFO and, hence, still poke at
1447+ the "struct frame_info" object directly. */
1448+ prev_frame->frame = prev_frame->id.base;
14261449
14271450 /* Link it in. */
14281451 next_frame->prev = prev_frame;
@@ -1557,11 +1580,11 @@ void
15571580 deprecated_update_frame_pc_hack (struct frame_info *frame, CORE_ADDR pc)
15581581 {
15591582 /* See comment in "frame.h". */
1560- gdb_assert (frame->next != NULL);
1561- /* Fix up this PC's value. */
15621583 frame->pc = pc;
1563- /* While we're at it, also update the cache, in NEXT, that also
1564- contains that value. */
1584+ /* While we're at it, update this frame's cached PC value, found in
1585+ the next frame. Oh, for the day when "struct frame_info" is
1586+ opaque and this hack on hack can go. */
1587+ gdb_assert (frame->next != NULL);
15651588 frame->next->pc_unwind_cache = pc;
15661589 frame->next->pc_unwind_cache_p = 1;
15671590 }
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -310,10 +310,6 @@ extern const char *frame_map_regnum_to_name (int regnum);
310310
311311 extern CORE_ADDR frame_pc_unwind (struct frame_info *frame);
312312
313-/* Unwind the frame ID. Return an ID that uniquely identifies the
314- caller's frame. */
315-extern struct frame_id frame_id_unwind (struct frame_info *frame);
316-
317313 /* Discard the specified frame. Restoring the registers to the state
318314 of the caller. */
319315 extern void frame_pop (struct frame_info *frame);
@@ -412,9 +408,9 @@ struct frame_info
412408 int pc_unwind_cache_p;
413409 CORE_ADDR pc_unwind_cache;
414410
415- /* Cached copy of the previous frame's ID. */
416- int id_unwind_cache_p;
417- struct frame_id id_unwind_cache;
411+ /* This frame's ID. Note that the frame's ID, base and PC contain
412+ redundant information. */
413+ struct frame_id id;
418414
419415 /* Pointers to the next (down, inner, younger) and previous (up,
420416 outer, older) frame_info's in the frame cache. */
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -242,6 +242,7 @@ struct gdbarch
242242 gdbarch_frame_chain_ftype *frame_chain;
243243 gdbarch_frame_chain_valid_ftype *frame_chain_valid;
244244 gdbarch_frame_saved_pc_ftype *frame_saved_pc;
245+ gdbarch_unwind_pc_ftype *unwind_pc;
245246 gdbarch_frame_args_address_ftype *frame_args_address;
246247 gdbarch_frame_locals_address_ftype *frame_locals_address;
247248 gdbarch_saved_pc_after_call_ftype *saved_pc_after_call;
@@ -433,6 +434,7 @@ struct gdbarch startup_gdbarch =
433434 0,
434435 0,
435436 0,
437+ 0,
436438 generic_in_function_epilogue_p,
437439 construct_inferior_arguments,
438440 0,
@@ -759,6 +761,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
759761 /* Skip verify of frame_chain, has predicate */
760762 /* Skip verify of frame_chain_valid, has predicate */
761763 /* Skip verify of frame_saved_pc, has predicate */
764+ /* Skip verify of unwind_pc, has predicate */
762765 /* Skip verify of frame_args_address, invalid_p == 0 */
763766 /* Skip verify of frame_locals_address, invalid_p == 0 */
764767 if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
@@ -2578,6 +2581,14 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
25782581 fprintf_unfiltered (file,
25792582 "gdbarch_dump: unwind_dummy_id = 0x%08lx\n",
25802583 (long) current_gdbarch->unwind_dummy_id);
2584+ if (GDB_MULTI_ARCH)
2585+ fprintf_unfiltered (file,
2586+ "gdbarch_dump: gdbarch_unwind_pc_p() = %d\n",
2587+ gdbarch_unwind_pc_p (current_gdbarch));
2588+ if (GDB_MULTI_ARCH)
2589+ fprintf_unfiltered (file,
2590+ "gdbarch_dump: unwind_pc = 0x%08lx\n",
2591+ (long) current_gdbarch->unwind_pc);
25812592 #ifdef USE_STRUCT_CONVENTION
25822593 fprintf_unfiltered (file,
25832594 "gdbarch_dump: %s # %s\n",
@@ -4845,6 +4856,32 @@ set_gdbarch_frame_saved_pc (struct gdbarch *gdbarch,
48454856 gdbarch->frame_saved_pc = frame_saved_pc;
48464857 }
48474858
4859+int
4860+gdbarch_unwind_pc_p (struct gdbarch *gdbarch)
4861+{
4862+ gdb_assert (gdbarch != NULL);
4863+ return gdbarch->unwind_pc != 0;
4864+}
4865+
4866+CORE_ADDR
4867+gdbarch_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
4868+{
4869+ gdb_assert (gdbarch != NULL);
4870+ if (gdbarch->unwind_pc == 0)
4871+ internal_error (__FILE__, __LINE__,
4872+ "gdbarch: gdbarch_unwind_pc invalid");
4873+ if (gdbarch_debug >= 2)
4874+ fprintf_unfiltered (gdb_stdlog, "gdbarch_unwind_pc called\n");
4875+ return gdbarch->unwind_pc (gdbarch, next_frame);
4876+}
4877+
4878+void
4879+set_gdbarch_unwind_pc (struct gdbarch *gdbarch,
4880+ gdbarch_unwind_pc_ftype unwind_pc)
4881+{
4882+ gdbarch->unwind_pc = unwind_pc;
4883+}
4884+
48484885 CORE_ADDR
48494886 gdbarch_frame_args_address (struct gdbarch *gdbarch, struct frame_info *fi)
48504887 {
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -2230,6 +2230,8 @@ extern void set_gdbarch_frame_chain_valid (struct gdbarch *gdbarch, gdbarch_fram
22302230 #endif
22312231 #endif
22322232
2233+/* NOTE: FRAME_SAVED_PC is replaced by UNWIND_PC */
2234+
22332235 #if defined (FRAME_SAVED_PC)
22342236 /* Legacy for systems yet to multi-arch FRAME_SAVED_PC */
22352237 #if !defined (FRAME_SAVED_PC_P)
@@ -2267,6 +2269,12 @@ extern void set_gdbarch_frame_saved_pc (struct gdbarch *gdbarch, gdbarch_frame_s
22672269 #endif
22682270 #endif
22692271
2272+extern int gdbarch_unwind_pc_p (struct gdbarch *gdbarch);
2273+
2274+typedef CORE_ADDR (gdbarch_unwind_pc_ftype) (struct gdbarch *gdbarch, struct frame_info *next_frame);
2275+extern CORE_ADDR gdbarch_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame);
2276+extern void set_gdbarch_unwind_pc (struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc);
2277+
22702278 /* Default (function) for non- multi-arch platforms. */
22712279 #if (!GDB_MULTI_ARCH) && !defined (FRAME_ARGS_ADDRESS)
22722280 #define FRAME_ARGS_ADDRESS(fi) (get_frame_base (fi))
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -591,7 +591,9 @@ v:2:FRAME_ARGS_SKIP:CORE_ADDR:frame_args_skip::::0:-1
591591 f:2:FRAMELESS_FUNCTION_INVOCATION:int:frameless_function_invocation:struct frame_info *fi:fi:::generic_frameless_function_invocation_not::0
592592 F:2:FRAME_CHAIN:CORE_ADDR:frame_chain:struct frame_info *frame:frame::0:0
593593 F:2:FRAME_CHAIN_VALID:int:frame_chain_valid:CORE_ADDR chain, struct frame_info *thisframe:chain, thisframe::0:0
594+# NOTE: FRAME_SAVED_PC is replaced by UNWIND_PC
594595 F:2:FRAME_SAVED_PC:CORE_ADDR:frame_saved_pc:struct frame_info *fi:fi::0:0
596+M::UNWIND_PC:CORE_ADDR:unwind_pc:struct frame_info *next_frame:next_frame:
595597 f:2:FRAME_ARGS_ADDRESS:CORE_ADDR:frame_args_address:struct frame_info *fi:fi::0:get_frame_base::0
596598 f:2:FRAME_LOCALS_ADDRESS:CORE_ADDR:frame_locals_address:struct frame_info *fi:fi::0:get_frame_base::0
597599 f:2:SAVED_PC_AFTER_CALL:CORE_ADDR:saved_pc_after_call:struct frame_info *frame:frame::0:0
--- a/gdb/sentinel-frame.c
+++ b/gdb/sentinel-frame.c
@@ -76,17 +76,6 @@ sentinel_frame_register_unwind (struct frame_info *next_frame,
7676 }
7777 }
7878
79-CORE_ADDR
80-sentinel_frame_pc_unwind (struct frame_info *next_frame,
81- void **this_cache)
82-{
83- /* FIXME: cagney/2003-01-08: This should be using a per-architecture
84- method that doesn't suffer from DECR_PC_AFTER_BREAK problems.
85- Such a method would take unwind_cache, regcache and stop reason
86- parameters. */
87- return read_pc ();
88-}
89-
9079 void
9180 sentinel_frame_id_unwind (struct frame_info *next_frame,
9281 void **this_cache,
@@ -106,7 +95,6 @@ sentinel_frame_pop (struct frame_info *next_frame,
10695 const struct frame_unwind sentinel_frame_unwinder =
10796 {
10897 sentinel_frame_pop,
109- sentinel_frame_pc_unwind,
11098 sentinel_frame_id_unwind,
11199 sentinel_frame_register_unwind
112100 };