GNU Binutils with patches for OS216
修订版 | 5422b5d2fa74279625100e408edc6e31b9e57b03 (tree) |
---|---|
时间 | 2003-03-14 06:43:34 |
作者 | Andrew Cagney <cagney@redh...> |
Commiter | Andrew Cagney |
2003-03-13 Andrew Cagney <cagney@redhat.com>
* frame.c (legacy_saved_regs_this_id): Handle a sentinel frame.
(get_prev_frame): Simplify. Frame ID logic moved to
dummy_frame_this_id and legacy_saved_regs_this_id.
@@ -1,5 +1,9 @@ | ||
1 | 1 | 2003-03-13 Andrew Cagney <cagney@redhat.com> |
2 | 2 | |
3 | + * frame.c (legacy_saved_regs_this_id): Handle a sentinel frame. | |
4 | + (get_prev_frame): Simplify. Frame ID logic moved to | |
5 | + dummy_frame_this_id and legacy_saved_regs_this_id. | |
6 | + | |
3 | 7 | * d10v-tdep.c (d10v_frame_this_id): Replace d10v_frame_id_unwind. |
4 | 8 | (d10v_frame_unwind): Update. |
5 | 9 | (d10v_frame_prev_register): Replace d10v_frame_register_unwind. |
@@ -745,30 +745,40 @@ legacy_saved_regs_this_id (struct frame_info *next_frame, | ||
745 | 745 | void **this_prologue_cache, |
746 | 746 | struct frame_id *id) |
747 | 747 | { |
748 | - int fromleaf; | |
749 | 748 | CORE_ADDR base; |
750 | 749 | CORE_ADDR pc; |
751 | 750 | |
752 | 751 | /* Start out by assuming it's NULL. */ |
753 | 752 | (*id) = null_frame_id; |
754 | 753 | |
755 | - if (frame_relative_level (next_frame) <= 0) | |
756 | - /* FIXME: 2002-11-09: Frameless functions can occure anywhere in | |
757 | - the frame chain, not just the inner most frame! The generic, | |
758 | - per-architecture, frame code should handle this and the below | |
759 | - should simply be removed. */ | |
760 | - fromleaf = FRAMELESS_FUNCTION_INVOCATION (next_frame); | |
761 | - else | |
762 | - fromleaf = 0; | |
763 | - | |
764 | - if (fromleaf) | |
765 | - /* A frameless inner-most frame. The `FP' (which isn't an | |
766 | - architecture frame-pointer register!) of the caller is the same | |
767 | - as the callee. */ | |
768 | - /* FIXME: 2002-11-09: There isn't any reason to special case this | |
769 | - edge condition. Instead the per-architecture code should hande | |
770 | - it locally. */ | |
771 | - base = get_frame_base (next_frame); | |
754 | + if (frame_relative_level (next_frame) < 0) | |
755 | + { | |
756 | + /* We're unwinding a sentinel frame, the PC of which is pointing | |
757 | + at a stack dummy. Fake up the dummy frame's ID using the | |
758 | + same sequence as is found a traditional unwinder. Once all | |
759 | + architectures supply the unwind_dummy_id method, this code | |
760 | + can go away. */ | |
761 | + base = read_fp (); | |
762 | + pc = read_pc (); | |
763 | + } | |
764 | + else if (frame_relative_level (next_frame) == 0 | |
765 | + && FRAMELESS_FUNCTION_INVOCATION (next_frame)) | |
766 | + { | |
767 | + /* FIXME: 2002-11-09: Frameless functions can occure anywhere in | |
768 | + the frame chain, not just the inner most frame! The generic, | |
769 | + per-architecture, frame code should handle this and the below | |
770 | + should simply be removed. */ | |
771 | + /* A frameless inner-most frame. The `FP' (which isn't an | |
772 | + architecture frame-pointer register!) of the caller is the | |
773 | + same as the callee. */ | |
774 | + /* FIXME: 2002-11-09: There isn't any reason to special case | |
775 | + this edge condition. Instead the per-architecture code | |
776 | + should hande it locally. */ | |
777 | + base = get_frame_base (next_frame); | |
778 | + /* FIXME: cagney/2002-06-08: This should probably return the frame's | |
779 | + function and not the PC (a.k.a. resume address). */ | |
780 | + pc = frame_pc_unwind (next_frame); | |
781 | + } | |
772 | 782 | else |
773 | 783 | { |
774 | 784 | /* Two macros defined in tm.h specify the machine-dependent |
@@ -788,16 +798,12 @@ legacy_saved_regs_this_id (struct frame_info *next_frame, | ||
788 | 798 | main. */ |
789 | 799 | gdb_assert (FRAME_CHAIN_P ()); |
790 | 800 | base = FRAME_CHAIN (next_frame); |
791 | - | |
792 | 801 | if (!frame_chain_valid (base, next_frame)) |
793 | 802 | return; |
803 | + /* FIXME: cagney/2002-06-08: This should probably return the | |
804 | + frame's function and not the PC (a.k.a. resume address). */ | |
805 | + pc = frame_pc_unwind (next_frame); | |
794 | 806 | } |
795 | - if (base == 0) | |
796 | - return; | |
797 | - | |
798 | - /* FIXME: cagney/2002-06-08: This should probably return the frame's | |
799 | - function and not the PC (a.k.a. resume address). */ | |
800 | - pc = frame_pc_unwind (next_frame); | |
801 | 807 | id->pc = pc; |
802 | 808 | id->base = base; |
803 | 809 | } |
@@ -1385,97 +1391,49 @@ get_prev_frame (struct frame_info *this_frame) | ||
1385 | 1391 | prev_frame->pc); |
1386 | 1392 | |
1387 | 1393 | /* Find the prev's frame's ID. */ |
1388 | - switch (prev_frame->type) | |
1389 | - { | |
1390 | - case DUMMY_FRAME: | |
1391 | - /* When unwinding a normal frame, the stack structure is | |
1392 | - determined by analyzing the frame's function's code (be it | |
1393 | - using brute force prologue analysis, or the dwarf2 CFI). In | |
1394 | - the case of a dummy frame, that simply isn't possible. The | |
1395 | - The PC is either the program entry point, or some random | |
1396 | - address on the stack. Trying to use that PC to apply | |
1397 | - standard frame ID unwind techniques is just asking for | |
1398 | - trouble. */ | |
1399 | - if (gdbarch_unwind_dummy_id_p (current_gdbarch)) | |
1400 | - { | |
1401 | - /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS, | |
1402 | - previously saved the dummy frame's ID. Things only work | |
1403 | - if the two return the same value. */ | |
1404 | - gdb_assert (SAVE_DUMMY_FRAME_TOS_P ()); | |
1405 | - /* Use an architecture specific method to extract the prev's | |
1406 | - dummy ID from the next frame. Note that this method uses | |
1407 | - frame_register_unwind to obtain the register values | |
1408 | - needed to determine the dummy frame's ID. */ | |
1409 | - prev_frame->id = gdbarch_unwind_dummy_id (current_gdbarch, | |
1410 | - this_frame); | |
1411 | - } | |
1412 | - else if (this_frame->level < 0) | |
1413 | - { | |
1414 | - /* We're unwinding a sentinel frame, the PC of which is | |
1415 | - pointing at a stack dummy. Fake up the dummy frame's ID | |
1416 | - using the same sequence as is found a traditional | |
1417 | - unwinder. Once all architectures supply the | |
1418 | - unwind_dummy_id method, this code can go away. */ | |
1419 | - prev_frame->id.base = read_fp (); | |
1420 | - prev_frame->id.pc = read_pc (); | |
1421 | - } | |
1422 | - else | |
1423 | - { | |
1424 | - /* Outch! We're not on the innermost frame yet we're trying | |
1425 | - to unwind to a dummy. The architecture must provide the | |
1426 | - unwind_dummy_id() method. Abandon the unwind process but | |
1427 | - only after first warning the user. */ | |
1428 | - internal_warning (__FILE__, __LINE__, | |
1429 | - "Missing unwind_dummy_id architecture method"); | |
1430 | - return NULL; | |
1431 | - } | |
1432 | - break; | |
1433 | - case NORMAL_FRAME: | |
1434 | - case SIGTRAMP_FRAME: | |
1435 | - /* The callee expects to be invoked with: | |
1436 | 1394 | |
1437 | - this->unwind->this_id (this->next, &this->cache, &this->id); | |
1395 | + /* The callee expects to be invoked with: | |
1438 | 1396 | |
1439 | - The below is carefully shifted one frame `to the left' so | |
1440 | - that both the unwind->this_id and unwind->prev_register | |
1441 | - methods are consistently invoked with NEXT_FRAME and | |
1442 | - THIS_PROLOGUE_CACHE. | |
1397 | + this->unwind->this_id (this->next, &this->cache, &this->id); | |
1398 | + | |
1399 | + The below is carefully shifted one frame `to the left' so that | |
1400 | + both the unwind->this_id and unwind->prev_register methods are | |
1401 | + consistently invoked with NEXT_FRAME and THIS_PROLOGUE_CACHE. | |
1443 | 1402 | |
1444 | - Also note that, while the PC for this new previous frame was | |
1445 | - unwound first (see above), the below is the first call that | |
1446 | - [potentially] requires analysis of the new previous frame's | |
1447 | - prologue. Consequently, it is this call, that typically ends | |
1448 | - up initializing the previous frame's prologue cache. */ | |
1449 | - prev_frame->unwind->this_id (this_frame, | |
1450 | - &prev_frame->prologue_cache, | |
1451 | - &prev_frame->id); | |
1452 | - /* Check that the unwound ID is valid. */ | |
1453 | - if (!frame_id_p (prev_frame->id)) | |
1454 | - { | |
1455 | - if (frame_debug) | |
1456 | - fprintf_unfiltered (gdb_stdlog, | |
1457 | - "Outermost frame - unwound frame ID invalid\n"); | |
1458 | - return NULL; | |
1459 | - } | |
1460 | - /* Check that the new frame isn't inner to (younger, below, | |
1461 | - next) the old frame. If that happens the frame unwind is | |
1462 | - going backwards. */ | |
1463 | - /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since | |
1464 | - that doesn't have a valid frame ID. Should instead set the | |
1465 | - sentinel frame's frame ID to a `sentinel'. Leave it until | |
1466 | - after the switch to storing the frame ID, instead of the | |
1467 | - frame base, in the frame object. */ | |
1468 | - if (this_frame->level >= 0 | |
1469 | - && frame_id_inner (prev_frame->id, get_frame_id (this_frame))) | |
1470 | - error ("Unwound frame inner-to selected frame (corrupt stack?)"); | |
1471 | - /* Note that, due to frameless functions, the stronger test of | |
1472 | - the new frame being outer to the old frame can't be used - | |
1473 | - frameless functions differ by only their PC value. */ | |
1474 | - break; | |
1475 | - default: | |
1476 | - internal_error (__FILE__, __LINE__, "bad switch"); | |
1403 | + Also note that, while the PC for this new previous frame was | |
1404 | + unwound first (see above), the below is the first call that | |
1405 | + [potentially] requires analysis of the new previous frame's | |
1406 | + prologue. Consequently, it is this call, that typically ends up | |
1407 | + initializing the previous frame's prologue cache. */ | |
1408 | + prev_frame->unwind->this_id (this_frame, | |
1409 | + &prev_frame->prologue_cache, | |
1410 | + &prev_frame->id); | |
1411 | + | |
1412 | + /* Check that the unwound ID is valid. */ | |
1413 | + if (!frame_id_p (prev_frame->id)) | |
1414 | + { | |
1415 | + if (frame_debug) | |
1416 | + fprintf_unfiltered (gdb_stdlog, | |
1417 | + "Outermost frame - unwound frame ID invalid\n"); | |
1418 | + return NULL; | |
1477 | 1419 | } |
1478 | 1420 | |
1421 | + /* Check that the new frame isn't inner to (younger, below, next) | |
1422 | + the old frame. If that happens the frame unwind is going | |
1423 | + backwards. */ | |
1424 | + /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since that | |
1425 | + doesn't have a valid frame ID. Should instead set the sentinel | |
1426 | + frame's frame ID to a true `sentinel'. Leave it until after the | |
1427 | + switch to storing the frame ID, instead of the frame base, in the | |
1428 | + frame object. */ | |
1429 | + if (this_frame->level >= 0 | |
1430 | + && frame_id_inner (prev_frame->id, get_frame_id (this_frame))) | |
1431 | + error ("Unwound frame inner-to selected frame (corrupt stack?)"); | |
1432 | + | |
1433 | + /* Note that, due to frameless functions, the stronger test of the | |
1434 | + new frame being outer to the old frame can't be used - frameless | |
1435 | + functions differ by only their PC value. */ | |
1436 | + | |
1479 | 1437 | /* FIXME: cagney/2002-12-18: Instead of this hack, should only store |
1480 | 1438 | the frame ID in PREV_FRAME. Unfortunatly, some architectures |
1481 | 1439 | (HP/UX) still reply on EXTRA_FRAME_INFO and, hence, still poke at |