GNU Binutils with patches for OS216
Revisión | a3f41504c1a26f5066953d0ce9b17dd1ff1e9017 (tree) |
---|---|
Tiempo | 2002-07-04 03:43:59 |
Autor | Andrew Cagney <cagney@redh...> |
Commiter | Andrew Cagney |
merge with trunk.
@@ -424,6 +424,7 @@ Alexandre Oliva aoliva@redhat.com | ||
424 | 424 | Tom Rix trix@redhat.com |
425 | 425 | Theodore A. Roth troth@verinet.com |
426 | 426 | Ian Roxborough irox@redhat.com |
427 | +Grace Sainsbury graces@redhat.com | |
427 | 428 | Mark Salter msalter@redhat.com |
428 | 429 | Peter Schauer Peter.Schauer@regent |
429 | 430 | Andreas Schwab schwab@suse.de |
@@ -637,7 +637,7 @@ inferior_h = inferior.h $(breakpoint_h) | ||
637 | 637 | language_h = language.h |
638 | 638 | linespec_h = linespec.h |
639 | 639 | macroexp_h = macroexp.h |
640 | -macrotab_h = macrotab.h $(obstack_h) $(bcache_h) | |
640 | +macrotab_h = macrotab.h | |
641 | 641 | macroscope_h = macroscope.h $(macrotab_h) $(symtab_h) |
642 | 642 | memattr_h = memattr.h |
643 | 643 | monitor_h = monitor.h |
@@ -528,6 +528,26 @@ get_frame_pc (struct frame_info *frame) | ||
528 | 528 | return frame->pc; |
529 | 529 | } |
530 | 530 | |
531 | +/* return the address of the PC for the given FRAME, ie the current PC value | |
532 | + if FRAME is the innermost frame, or the address adjusted to point to the | |
533 | + call instruction if not. */ | |
534 | + | |
535 | +CORE_ADDR | |
536 | +frame_address_in_block (struct frame_info *frame) | |
537 | +{ | |
538 | + CORE_ADDR pc = frame->pc; | |
539 | + | |
540 | + /* If we are not in the innermost frame, and we are not interrupted | |
541 | + by a signal, frame->pc points to the instruction following the | |
542 | + call. As a consequence, we need to get the address of the previous | |
543 | + instruction. Unfortunately, this is not straightforward to do, so | |
544 | + we just use the address minus one, which is a good enough | |
545 | + approximation. */ | |
546 | + if (frame->next != 0 && frame->next->signal_handler_caller == 0) | |
547 | + --pc; | |
548 | + | |
549 | + return pc; | |
550 | +} | |
531 | 551 | |
532 | 552 | #ifdef FRAME_FIND_SAVED_REGS |
533 | 553 | /* XXX - deprecated. This is a compatibility function for targets |
@@ -576,17 +596,7 @@ get_frame_saved_regs (struct frame_info *frame, | ||
576 | 596 | struct block * |
577 | 597 | get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block) |
578 | 598 | { |
579 | - CORE_ADDR pc; | |
580 | - | |
581 | - pc = frame->pc; | |
582 | - if (frame->next != 0 && frame->next->signal_handler_caller == 0) | |
583 | - /* We are not in the innermost frame and we were not interrupted | |
584 | - by a signal. We need to subtract one to get the correct block, | |
585 | - in case the call instruction was the last instruction of the block. | |
586 | - If there are any machines on which the saved pc does not point to | |
587 | - after the call insn, we probably want to make frame->pc point after | |
588 | - the call insn anyway. */ | |
589 | - --pc; | |
599 | + const CORE_ADDR pc = frame_address_in_block (frame); | |
590 | 600 | |
591 | 601 | if (addr_in_block) |
592 | 602 | *addr_in_block = pc; |
@@ -970,6 +980,7 @@ block_innermost_frame (struct block *block) | ||
970 | 980 | struct frame_info *frame; |
971 | 981 | register CORE_ADDR start; |
972 | 982 | register CORE_ADDR end; |
983 | + CORE_ADDR calling_pc; | |
973 | 984 | |
974 | 985 | if (block == NULL) |
975 | 986 | return NULL; |
@@ -983,7 +994,8 @@ block_innermost_frame (struct block *block) | ||
983 | 994 | frame = get_prev_frame (frame); |
984 | 995 | if (frame == NULL) |
985 | 996 | return NULL; |
986 | - if (frame->pc >= start && frame->pc < end) | |
997 | + calling_pc = frame_address_in_block (frame); | |
998 | + if (calling_pc >= start && calling_pc < end) | |
987 | 999 | return frame; |
988 | 1000 | } |
989 | 1001 | } |
@@ -1505,3 +1505,23 @@ complete_on_enum (const char *enumlist[], | ||
1505 | 1505 | return matchlist; |
1506 | 1506 | } |
1507 | 1507 | |
1508 | + | |
1509 | +/* check function pointer */ | |
1510 | +int | |
1511 | +cmd_func_p (struct cmd_list_element *cmd) | |
1512 | +{ | |
1513 | + return (cmd->func != NULL); | |
1514 | +} | |
1515 | + | |
1516 | + | |
1517 | +/* call the command function */ | |
1518 | +void | |
1519 | +cmd_func (struct cmd_list_element *cmd, char *args, int from_tty) | |
1520 | +{ | |
1521 | + if (cmd_func_p (cmd)) | |
1522 | + (*cmd->func) (cmd, args, from_tty); | |
1523 | + else | |
1524 | + error ("Invalid command"); | |
1525 | +} | |
1526 | + | |
1527 | + |
@@ -280,4 +280,10 @@ extern void dont_repeat (void); | ||
280 | 280 | |
281 | 281 | extern void not_just_help_class_command (char *, int); |
282 | 282 | |
283 | +/* check function pointer */ | |
284 | +extern int cmd_func_p (struct cmd_list_element *cmd); | |
285 | + | |
286 | +/* call the command function */ | |
287 | +extern void cmd_func (struct cmd_list_element *cmd, char *args, int from_tty); | |
288 | + | |
283 | 289 | #endif /* !defined (COMMAND_H) */ |
@@ -94,12 +94,12 @@ i[3456]86-*-aix*) gdb_target=i386aix ;; | ||
94 | 94 | i[3456]86-*-bsd*) gdb_target=i386bsd ;; |
95 | 95 | i[3456]86-*-freebsd*) gdb_target=fbsd ;; |
96 | 96 | i[3456]86-*-netbsdelf*) gdb_target=nbsdelf ;; |
97 | -i[3456]86-*-netbsd*) gdb_target=nbsdaout ;; | |
97 | +i[3456]86-*-netbsd* | i[3456]86-*-openbsd*) | |
98 | + gdb_target=nbsdaout ;; | |
98 | 99 | i[3456]86-*-os9k) gdb_target=i386os9k ;; |
99 | 100 | i[3456]86-*-go32*) gdb_target=i386aout ;; |
100 | 101 | i[3456]86-*-msdosdjgpp*) gdb_target=go32 ;; |
101 | 102 | i[3456]86-*-lynxos*) gdb_target=i386lynx ;; |
102 | -i[3456]86-*-openbsd*) gdb_target=obsd ;; | |
103 | 103 | i[3456]86-*-solaris*) gdb_target=i386sol2 ;; |
104 | 104 | i[3456]86-*-sysv4.2*) gdb_target=i386v42mp ;; |
105 | 105 | i[3456]86-*-sysv4*) gdb_target=i386v4 ;; |
@@ -250,6 +250,8 @@ extern struct symbol *get_frame_function (struct frame_info *); | ||
250 | 250 | |
251 | 251 | extern CORE_ADDR get_frame_pc (struct frame_info *); |
252 | 252 | |
253 | +extern CORE_ADDR frame_address_in_block (struct frame_info *); | |
254 | + | |
253 | 255 | extern CORE_ADDR get_pc_function_start (CORE_ADDR); |
254 | 256 | |
255 | 257 | extern struct block *block_for_pc (CORE_ADDR); |
@@ -240,7 +240,7 @@ i386_linux_pc_in_sigtramp (CORE_ADDR pc, char *name) | ||
240 | 240 | /* Assuming FRAME is for a GNU/Linux sigtramp routine, return the |
241 | 241 | address of the associated sigcontext structure. */ |
242 | 242 | |
243 | -CORE_ADDR | |
243 | +static CORE_ADDR | |
244 | 244 | i386_linux_sigcontext_addr (struct frame_info *frame) |
245 | 245 | { |
246 | 246 | CORE_ADDR pc; |
@@ -286,100 +286,6 @@ i386_linux_sigcontext_addr (struct frame_info *frame) | ||
286 | 286 | return 0; |
287 | 287 | } |
288 | 288 | |
289 | -/* Offset to saved PC in sigcontext, from <asm/sigcontext.h>. */ | |
290 | -#define LINUX_SIGCONTEXT_PC_OFFSET (56) | |
291 | - | |
292 | -/* Assuming FRAME is for a GNU/Linux sigtramp routine, return the | |
293 | - saved program counter. */ | |
294 | - | |
295 | -static CORE_ADDR | |
296 | -i386_linux_sigtramp_saved_pc (struct frame_info *frame) | |
297 | -{ | |
298 | - CORE_ADDR addr; | |
299 | - addr = i386_linux_sigcontext_addr (frame); | |
300 | - return read_memory_integer (addr + LINUX_SIGCONTEXT_PC_OFFSET, 4); | |
301 | -} | |
302 | - | |
303 | -/* Offset to saved SP in sigcontext, from <asm/sigcontext.h>. */ | |
304 | -#define LINUX_SIGCONTEXT_SP_OFFSET (28) | |
305 | - | |
306 | -/* Assuming FRAME is for a GNU/Linux sigtramp routine, return the | |
307 | - saved stack pointer. */ | |
308 | - | |
309 | -static CORE_ADDR | |
310 | -i386_linux_sigtramp_saved_sp (struct frame_info *frame) | |
311 | -{ | |
312 | - CORE_ADDR addr; | |
313 | - addr = i386_linux_sigcontext_addr (frame); | |
314 | - return read_memory_integer (addr + LINUX_SIGCONTEXT_SP_OFFSET, 4); | |
315 | -} | |
316 | - | |
317 | -/* Signal trampolines don't have a meaningful frame. As in | |
318 | - "i386/tm-i386.h", the frame pointer value we use is actually the | |
319 | - frame pointer of the calling frame -- that is, the frame which was | |
320 | - in progress when the signal trampoline was entered. GDB mostly | |
321 | - treats this frame pointer value as a magic cookie. We detect the | |
322 | - case of a signal trampoline by looking at the SIGNAL_HANDLER_CALLER | |
323 | - field, which is set based on PC_IN_SIGTRAMP. | |
324 | - | |
325 | - When a signal trampoline is invoked from a frameless function, we | |
326 | - essentially have two frameless functions in a row. In this case, | |
327 | - we use the same magic cookie for three frames in a row. We detect | |
328 | - this case by seeing whether the next frame has | |
329 | - SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the | |
330 | - current frame is actually frameless. In this case, we need to get | |
331 | - the PC by looking at the SP register value stored in the signal | |
332 | - context. | |
333 | - | |
334 | - This should work in most cases except in horrible situations where | |
335 | - a signal occurs just as we enter a function but before the frame | |
336 | - has been set up. */ | |
337 | - | |
338 | -#define FRAMELESS_SIGNAL(frame) \ | |
339 | - ((frame)->next != NULL \ | |
340 | - && (frame)->next->signal_handler_caller \ | |
341 | - && frameless_look_for_prologue (frame)) | |
342 | - | |
343 | -CORE_ADDR | |
344 | -i386_linux_frame_chain (struct frame_info *frame) | |
345 | -{ | |
346 | - if (frame->signal_handler_caller || FRAMELESS_SIGNAL (frame)) | |
347 | - return frame->frame; | |
348 | - | |
349 | - if (! inside_entry_file (frame->pc)) | |
350 | - return read_memory_unsigned_integer (frame->frame, 4); | |
351 | - | |
352 | - return 0; | |
353 | -} | |
354 | - | |
355 | -/* Return the saved program counter for FRAME. */ | |
356 | - | |
357 | -CORE_ADDR | |
358 | -i386_linux_frame_saved_pc (struct frame_info *frame) | |
359 | -{ | |
360 | - if (frame->signal_handler_caller) | |
361 | - return i386_linux_sigtramp_saved_pc (frame); | |
362 | - | |
363 | - if (FRAMELESS_SIGNAL (frame)) | |
364 | - { | |
365 | - CORE_ADDR sp = i386_linux_sigtramp_saved_sp (frame->next); | |
366 | - return read_memory_unsigned_integer (sp, 4); | |
367 | - } | |
368 | - | |
369 | - return read_memory_unsigned_integer (frame->frame + 4, 4); | |
370 | -} | |
371 | - | |
372 | -/* Immediately after a function call, return the saved pc. */ | |
373 | - | |
374 | -CORE_ADDR | |
375 | -i386_linux_saved_pc_after_call (struct frame_info *frame) | |
376 | -{ | |
377 | - if (frame->signal_handler_caller) | |
378 | - return i386_linux_sigtramp_saved_pc (frame); | |
379 | - | |
380 | - return read_memory_unsigned_integer (read_register (SP_REGNUM), 4); | |
381 | -} | |
382 | - | |
383 | 289 | /* Set the program counter for process PTID to PC. */ |
384 | 290 | |
385 | 291 | static void |
@@ -557,16 +463,15 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
557 | 463 | |
558 | 464 | tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */ |
559 | 465 | |
560 | - /* When the i386 Linux kernel calls a signal handler, the return | |
561 | - address points to a bit of code on the stack. These definitions | |
562 | - are used to identify this bit of code as a signal trampoline in | |
563 | - order to support backtracing through calls to signal handlers. */ | |
466 | + tdep->sigcontext_addr = i386_linux_sigcontext_addr; | |
467 | + tdep->sc_pc_offset = 14 * 4; /* From <asm/sigcontext.h>. */ | |
468 | + tdep->sc_sp_offset = 7 * 4; | |
564 | 469 | |
470 | + /* When the i386 Linux kernel calls a signal handler, the return | |
471 | + address points to a bit of code on the stack. This function is | |
472 | + used to identify this bit of code as a signal trampoline in order | |
473 | + to support backtracing through calls to signal handlers. */ | |
565 | 474 | set_gdbarch_pc_in_sigtramp (gdbarch, i386_linux_pc_in_sigtramp); |
566 | - set_gdbarch_frame_chain (gdbarch, i386_linux_frame_chain); | |
567 | - set_gdbarch_frame_saved_pc (gdbarch, i386_linux_frame_saved_pc); | |
568 | - set_gdbarch_saved_pc_after_call (gdbarch, i386_linux_saved_pc_after_call); | |
569 | - tdep->sigtramp_saved_pc = i386_linux_sigtramp_saved_pc; | |
570 | 475 | |
571 | 476 | set_solib_svr4_fetch_link_map_offsets (gdbarch, |
572 | 477 | i386_linux_svr4_fetch_link_map_offsets); |
@@ -19,6 +19,7 @@ | ||
19 | 19 | Boston, MA 02111-1307, USA. */ |
20 | 20 | |
21 | 21 | #include "defs.h" |
22 | +#include "value.h" | |
22 | 23 | |
23 | 24 | #include "i386-tdep.h" |
24 | 25 |
@@ -43,8 +44,13 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
43 | 44 | /* Signal trampolines are different from SVR4, in fact they're |
44 | 45 | rather similar to BSD. */ |
45 | 46 | set_gdbarch_pc_in_sigtramp (gdbarch, i386_sol2_pc_in_sigtramp); |
46 | - tdep->sigtramp_saved_pc = i386bsd_sigtramp_saved_pc; | |
47 | + tdep->sigcontext_addr = i386bsd_sigcontext_addr; | |
47 | 48 | tdep->sc_pc_offset = 36 + 14 * 4; |
49 | + tdep->sc_sp_offset = 36 + 7 * 4; | |
50 | + | |
51 | + /* Assume that the prototype flag can be trusted. */ | |
52 | + set_gdbarch_coerce_float_to_double (gdbarch, | |
53 | + standard_coerce_float_to_double); | |
48 | 54 | } |
49 | 55 | |
50 | 56 |
@@ -452,6 +452,38 @@ i386_get_frame_setup (CORE_ADDR pc) | ||
452 | 452 | return (-1); |
453 | 453 | } |
454 | 454 | |
455 | +/* Signal trampolines don't have a meaningful frame. The frame | |
456 | + pointer value we use is actually the frame pointer of the calling | |
457 | + frame -- that is, the frame which was in progress when the signal | |
458 | + trampoline was entered. GDB mostly treats this frame pointer value | |
459 | + as a magic cookie. We detect the case of a signal trampoline by | |
460 | + looking at the SIGNAL_HANDLER_CALLER field, which is set based on | |
461 | + PC_IN_SIGTRAMP. | |
462 | + | |
463 | + When a signal trampoline is invoked from a frameless function, we | |
464 | + essentially have two frameless functions in a row. In this case, | |
465 | + we use the same magic cookie for three frames in a row. We detect | |
466 | + this case by seeing whether the next frame has | |
467 | + SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the | |
468 | + current frame is actually frameless. In this case, we need to get | |
469 | + the PC by looking at the SP register value stored in the signal | |
470 | + context. | |
471 | + | |
472 | + This should work in most cases except in horrible situations where | |
473 | + a signal occurs just as we enter a function but before the frame | |
474 | + has been set up. */ | |
475 | + | |
476 | +/* Return non-zero if we're dealing with a frameless signal, that is, | |
477 | + a signal trampoline invoked from a frameless function. */ | |
478 | + | |
479 | +static int | |
480 | +i386_frameless_signal_p (struct frame_info *frame) | |
481 | +{ | |
482 | + return (frame->next | |
483 | + && frame->next->signal_handler_caller | |
484 | + && frameless_look_for_prologue (frame)); | |
485 | +} | |
486 | + | |
455 | 487 | /* Return the chain-pointer for FRAME. In the case of the i386, the |
456 | 488 | frame's nominal address is the address of a 4-byte word containing |
457 | 489 | the calling frame's address. */ |
@@ -459,7 +491,8 @@ i386_get_frame_setup (CORE_ADDR pc) | ||
459 | 491 | static CORE_ADDR |
460 | 492 | i386_frame_chain (struct frame_info *frame) |
461 | 493 | { |
462 | - if (frame->signal_handler_caller) | |
494 | + if (frame->signal_handler_caller | |
495 | + || i386_frameless_signal_p (frame)) | |
463 | 496 | return frame->frame; |
464 | 497 | |
465 | 498 | if (! inside_entry_file (frame->pc)) |
@@ -472,7 +505,7 @@ i386_frame_chain (struct frame_info *frame) | ||
472 | 505 | not have a from on the stack associated with it. If it does not, |
473 | 506 | return non-zero, otherwise return zero. */ |
474 | 507 | |
475 | -int | |
508 | +static int | |
476 | 509 | i386_frameless_function_invocation (struct frame_info *frame) |
477 | 510 | { |
478 | 511 | if (frame->signal_handler_caller) |
@@ -481,18 +514,44 @@ i386_frameless_function_invocation (struct frame_info *frame) | ||
481 | 514 | return frameless_look_for_prologue (frame); |
482 | 515 | } |
483 | 516 | |
517 | +/* Assuming FRAME is for a sigtramp routine, return the saved program | |
518 | + counter. */ | |
519 | + | |
520 | +static CORE_ADDR | |
521 | +i386_sigtramp_saved_pc (struct frame_info *frame) | |
522 | +{ | |
523 | + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
524 | + CORE_ADDR addr; | |
525 | + | |
526 | + addr = tdep->sigcontext_addr (frame); | |
527 | + return read_memory_unsigned_integer (addr + tdep->sc_pc_offset, 4); | |
528 | +} | |
529 | + | |
530 | +/* Assuming FRAME is for a sigtramp routine, return the saved stack | |
531 | + pointer. */ | |
532 | + | |
533 | +static CORE_ADDR | |
534 | +i386_sigtramp_saved_sp (struct frame_info *frame) | |
535 | +{ | |
536 | + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
537 | + CORE_ADDR addr; | |
538 | + | |
539 | + addr = tdep->sigcontext_addr (frame); | |
540 | + return read_memory_unsigned_integer (addr + tdep->sc_sp_offset, 4); | |
541 | +} | |
542 | + | |
484 | 543 | /* Return the saved program counter for FRAME. */ |
485 | 544 | |
486 | 545 | static CORE_ADDR |
487 | 546 | i386_frame_saved_pc (struct frame_info *frame) |
488 | 547 | { |
489 | 548 | if (frame->signal_handler_caller) |
490 | - { | |
491 | - CORE_ADDR (*sigtramp_saved_pc) (struct frame_info *); | |
492 | - sigtramp_saved_pc = gdbarch_tdep (current_gdbarch)->sigtramp_saved_pc; | |
549 | + return i386_sigtramp_saved_pc (frame); | |
493 | 550 | |
494 | - gdb_assert (sigtramp_saved_pc != NULL); | |
495 | - return sigtramp_saved_pc (frame); | |
551 | + if (i386_frameless_signal_p (frame)) | |
552 | + { | |
553 | + CORE_ADDR sp = i386_sigtramp_saved_sp (frame->next); | |
554 | + return read_memory_unsigned_integer (sp, 4); | |
496 | 555 | } |
497 | 556 | |
498 | 557 | return read_memory_unsigned_integer (frame->frame + 4, 4); |
@@ -503,13 +562,16 @@ i386_frame_saved_pc (struct frame_info *frame) | ||
503 | 562 | static CORE_ADDR |
504 | 563 | i386_saved_pc_after_call (struct frame_info *frame) |
505 | 564 | { |
565 | + if (frame->signal_handler_caller) | |
566 | + return i386_sigtramp_saved_pc (frame); | |
567 | + | |
506 | 568 | return read_memory_unsigned_integer (read_register (SP_REGNUM), 4); |
507 | 569 | } |
508 | 570 | |
509 | 571 | /* Return number of args passed to a frame. |
510 | 572 | Can return -1, meaning no way to tell. */ |
511 | 573 | |
512 | -int | |
574 | +static int | |
513 | 575 | i386_frame_num_args (struct frame_info *fi) |
514 | 576 | { |
515 | 577 | #if 1 |
@@ -606,7 +668,7 @@ i386_frame_num_args (struct frame_info *fi) | ||
606 | 668 | If the setup sequence is at the end of the function, then the next |
607 | 669 | instruction will be a branch back to the start. */ |
608 | 670 | |
609 | -void | |
671 | +static void | |
610 | 672 | i386_frame_init_saved_regs (struct frame_info *fip) |
611 | 673 | { |
612 | 674 | long locals = -1; |
@@ -666,7 +728,7 @@ i386_frame_init_saved_regs (struct frame_info *fip) | ||
666 | 728 | |
667 | 729 | /* Return PC of first real instruction. */ |
668 | 730 | |
669 | -CORE_ADDR | |
731 | +static CORE_ADDR | |
670 | 732 | i386_skip_prologue (CORE_ADDR pc) |
671 | 733 | { |
672 | 734 | unsigned char op; |
@@ -767,7 +829,7 @@ i386_breakpoint_from_pc (CORE_ADDR *pc, int *len) | ||
767 | 829 | return break_insn; |
768 | 830 | } |
769 | 831 | |
770 | -void | |
832 | +static void | |
771 | 833 | i386_push_dummy_frame (void) |
772 | 834 | { |
773 | 835 | CORE_ADDR sp = read_register (SP_REGNUM); |
@@ -803,7 +865,7 @@ static LONGEST i386_call_dummy_words[] = | ||
803 | 865 | /* Insert the (relative) function address into the call sequence |
804 | 866 | stored at DYMMY. */ |
805 | 867 | |
806 | -void | |
868 | +static void | |
807 | 869 | i386_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, |
808 | 870 | struct value **args, struct type *type, int gcc_p) |
809 | 871 | { |
@@ -820,7 +882,7 @@ i386_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, | ||
820 | 882 | *((char *)(dummy) + 4) = ((delta >> 24) & 0xff); |
821 | 883 | } |
822 | 884 | |
823 | -void | |
885 | +static void | |
824 | 886 | i386_pop_frame (void) |
825 | 887 | { |
826 | 888 | struct frame_info *frame = get_current_frame (); |
@@ -880,7 +942,7 @@ i386_get_longjmp_target (CORE_ADDR *pc) | ||
880 | 942 | } |
881 | 943 | |
882 | 944 | |
883 | -CORE_ADDR | |
945 | +static CORE_ADDR | |
884 | 946 | i386_push_arguments (int nargs, struct value **args, CORE_ADDR sp, |
885 | 947 | int struct_return, CORE_ADDR struct_addr) |
886 | 948 | { |
@@ -898,7 +960,7 @@ i386_push_arguments (int nargs, struct value **args, CORE_ADDR sp, | ||
898 | 960 | return sp; |
899 | 961 | } |
900 | 962 | |
901 | -void | |
963 | +static void | |
902 | 964 | i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) |
903 | 965 | { |
904 | 966 | /* Do nothing. Everything was already done by i386_push_arguments. */ |
@@ -914,7 +976,7 @@ i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) | ||
914 | 976 | function return value of TYPE, and copy that, in virtual format, |
915 | 977 | into VALBUF. */ |
916 | 978 | |
917 | -void | |
979 | +static void | |
918 | 980 | i386_extract_return_value (struct type *type, char *regbuf, char *valbuf) |
919 | 981 | { |
920 | 982 | int len = TYPE_LENGTH (type); |
@@ -965,7 +1027,7 @@ i386_extract_return_value (struct type *type, char *regbuf, char *valbuf) | ||
965 | 1027 | /* Write into the appropriate registers a function return value stored |
966 | 1028 | in VALBUF of type TYPE, given in virtual format. */ |
967 | 1029 | |
968 | -void | |
1030 | +static void | |
969 | 1031 | i386_store_return_value (struct type *type, char *valbuf) |
970 | 1032 | { |
971 | 1033 | int len = TYPE_LENGTH (type); |
@@ -1037,7 +1099,7 @@ i386_store_return_value (struct type *type, char *valbuf) | ||
1037 | 1099 | the address in which a function should return its structure value, |
1038 | 1100 | as a CORE_ADDR. */ |
1039 | 1101 | |
1040 | -CORE_ADDR | |
1102 | +static CORE_ADDR | |
1041 | 1103 | i386_extract_struct_value_address (char *regbuf) |
1042 | 1104 | { |
1043 | 1105 | return extract_address (®buf[REGISTER_BYTE (LOW_RETURN_REGNUM)], |
@@ -1080,7 +1142,7 @@ i386_use_struct_convention (int gcc_p, struct type *type) | ||
1080 | 1142 | register REGNUM. Perhaps %esi and %edi should go here, but |
1081 | 1143 | potentially they could be used for things other than address. */ |
1082 | 1144 | |
1083 | -struct type * | |
1145 | +static struct type * | |
1084 | 1146 | i386_register_virtual_type (int regnum) |
1085 | 1147 | { |
1086 | 1148 | if (regnum == PC_REGNUM || regnum == FP_REGNUM || regnum == SP_REGNUM) |
@@ -1101,7 +1163,7 @@ i386_register_virtual_type (int regnum) | ||
1101 | 1163 | registers need conversion. Even if we can't find a counterexample, |
1102 | 1164 | this is still sloppy. */ |
1103 | 1165 | |
1104 | -int | |
1166 | +static int | |
1105 | 1167 | i386_register_convertible (int regnum) |
1106 | 1168 | { |
1107 | 1169 | return IS_FP_REGNUM (regnum); |
@@ -1110,7 +1172,7 @@ i386_register_convertible (int regnum) | ||
1110 | 1172 | /* Convert data from raw format for register REGNUM in buffer FROM to |
1111 | 1173 | virtual format with type TYPE in buffer TO. */ |
1112 | 1174 | |
1113 | -void | |
1175 | +static void | |
1114 | 1176 | i386_register_convert_to_virtual (int regnum, struct type *type, |
1115 | 1177 | char *from, char *to) |
1116 | 1178 | { |
@@ -1133,7 +1195,7 @@ i386_register_convert_to_virtual (int regnum, struct type *type, | ||
1133 | 1195 | /* Convert data from virtual format with type TYPE in buffer FROM to |
1134 | 1196 | raw format for register REGNUM in buffer TO. */ |
1135 | 1197 | |
1136 | -void | |
1198 | +static void | |
1137 | 1199 | i386_register_convert_to_raw (struct type *type, int regnum, |
1138 | 1200 | char *from, char *to) |
1139 | 1201 | { |
@@ -1244,29 +1306,31 @@ i386_svr4_pc_in_sigtramp (CORE_ADDR pc, char *name) | ||
1244 | 1306 | || strcmp ("sigvechandler", name) == 0)); |
1245 | 1307 | } |
1246 | 1308 | |
1247 | -/* Get saved user PC for sigtramp from the pushed ucontext on the | |
1248 | - stack for all three variants of SVR4 sigtramps. */ | |
1309 | +/* Get address of the pushed ucontext (sigcontext) on the stack for | |
1310 | + all three variants of SVR4 sigtramps. */ | |
1249 | 1311 | |
1250 | -CORE_ADDR | |
1251 | -i386_svr4_sigtramp_saved_pc (struct frame_info *frame) | |
1312 | +static CORE_ADDR | |
1313 | +i386_svr4_sigcontext_addr (struct frame_info *frame) | |
1252 | 1314 | { |
1253 | - CORE_ADDR saved_pc_offset = 4; | |
1315 | + int sigcontext_offset = -1; | |
1254 | 1316 | char *name = NULL; |
1255 | 1317 | |
1256 | 1318 | find_pc_partial_function (frame->pc, &name, NULL, NULL); |
1257 | 1319 | if (name) |
1258 | 1320 | { |
1259 | 1321 | if (strcmp (name, "_sigreturn") == 0) |
1260 | - saved_pc_offset = 132 + 14 * 4; | |
1322 | + sigcontext_offset = 132; | |
1261 | 1323 | else if (strcmp (name, "_sigacthandler") == 0) |
1262 | - saved_pc_offset = 80 + 14 * 4; | |
1324 | + sigcontext_offset = 80; | |
1263 | 1325 | else if (strcmp (name, "sigvechandler") == 0) |
1264 | - saved_pc_offset = 120 + 14 * 4; | |
1326 | + sigcontext_offset = 120; | |
1265 | 1327 | } |
1266 | 1328 | |
1329 | + gdb_assert (sigcontext_offset != -1); | |
1330 | + | |
1267 | 1331 | if (frame->next) |
1268 | - return read_memory_integer (frame->next->frame + saved_pc_offset, 4); | |
1269 | - return read_memory_integer (read_register (SP_REGNUM) + saved_pc_offset, 4); | |
1332 | + return frame->next->frame + sigcontext_offset; | |
1333 | + return read_register (SP_REGNUM) + sigcontext_offset; | |
1270 | 1334 | } |
1271 | 1335 | |
1272 | 1336 |
@@ -1303,14 +1367,16 @@ i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1303 | 1367 | set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid); |
1304 | 1368 | |
1305 | 1369 | set_gdbarch_pc_in_sigtramp (gdbarch, i386_svr4_pc_in_sigtramp); |
1306 | - tdep->sigtramp_saved_pc = i386_svr4_sigtramp_saved_pc; | |
1370 | + tdep->sigcontext_addr = i386_svr4_sigcontext_addr; | |
1371 | + tdep->sc_pc_offset = 14 * 4; | |
1372 | + tdep->sc_sp_offset = 7 * 4; | |
1307 | 1373 | |
1308 | 1374 | tdep->jb_pc_offset = 20; |
1309 | 1375 | } |
1310 | 1376 | |
1311 | 1377 | /* DJGPP. */ |
1312 | 1378 | |
1313 | -void | |
1379 | +static void | |
1314 | 1380 | i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
1315 | 1381 | { |
1316 | 1382 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
@@ -1322,7 +1388,7 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1322 | 1388 | |
1323 | 1389 | /* NetWare. */ |
1324 | 1390 | |
1325 | -void | |
1391 | +static void | |
1326 | 1392 | i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
1327 | 1393 | { |
1328 | 1394 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
@@ -1334,7 +1400,7 @@ i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1334 | 1400 | } |
1335 | 1401 | |
1336 | 1402 | |
1337 | -struct gdbarch * | |
1403 | +static struct gdbarch * | |
1338 | 1404 | i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) |
1339 | 1405 | { |
1340 | 1406 | struct gdbarch_tdep *tdep; |
@@ -1369,17 +1435,18 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1369 | 1435 | |
1370 | 1436 | tdep->jb_pc_offset = -1; |
1371 | 1437 | tdep->struct_return = pcc_struct_return; |
1372 | - tdep->sigtramp_saved_pc = NULL; | |
1373 | 1438 | tdep->sigtramp_start = 0; |
1374 | 1439 | tdep->sigtramp_end = 0; |
1440 | + tdep->sigcontext_addr = NULL; | |
1375 | 1441 | tdep->sc_pc_offset = -1; |
1442 | + tdep->sc_sp_offset = -1; | |
1376 | 1443 | |
1377 | 1444 | /* The format used for `long double' on almost all i386 targets is |
1378 | 1445 | the i387 extended floating-point format. In fact, of all targets |
1379 | 1446 | in the GCC 2.95 tree, only OSF/1 does it different, and insists |
1380 | 1447 | on having a `long double' that's not `long' at all. */ |
1381 | 1448 | set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext); |
1382 | - | |
1449 | + | |
1383 | 1450 | /* Although the i386 extended floating-point has only 80 significant |
1384 | 1451 | bits, a `long double' actually takes up 96, probably to enforce |
1385 | 1452 | alignment. */ |
@@ -1388,7 +1455,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
1388 | 1455 | /* NOTE: tm-i386aix.h, tm-i386bsd.h, tm-i386os9k.h, tm-ptx.h, |
1389 | 1456 | tm-symmetry.h currently override this. Sigh. */ |
1390 | 1457 | set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS); |
1391 | - | |
1458 | + | |
1392 | 1459 | set_gdbarch_sp_regnum (gdbarch, 4); |
1393 | 1460 | set_gdbarch_fp_regnum (gdbarch, 5); |
1394 | 1461 | set_gdbarch_pc_regnum (gdbarch, 8); |
@@ -65,15 +65,16 @@ struct gdbarch_tdep | ||
65 | 65 | /* Convention for returning structures. */ |
66 | 66 | enum struct_return struct_return; |
67 | 67 | |
68 | - /* Get saved PC for sigtramp. */ | |
69 | - CORE_ADDR (*sigtramp_saved_pc) (struct frame_info *); | |
70 | - | |
71 | 68 | /* Address range where sigtramp lives. */ |
72 | 69 | CORE_ADDR sigtramp_start; |
73 | 70 | CORE_ADDR sigtramp_end; |
74 | 71 | |
75 | - /* Offset of saved PC in `struct sigcontext'. */ | |
72 | + /* Get address of sigcontext for sigtramp. */ | |
73 | + CORE_ADDR (*sigcontext_addr) (struct frame_info *); | |
74 | + | |
75 | + /* Offset of saved PC and SP in `struct sigcontext'. */ | |
76 | 76 | int sc_pc_offset; |
77 | + int sc_sp_offset; | |
77 | 78 | }; |
78 | 79 | |
79 | 80 | /* Floating-point registers. */ |
@@ -175,6 +176,6 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *); | ||
175 | 176 | |
176 | 177 | /* Functions exported from i386bsd-tdep.c. */ |
177 | 178 | |
178 | -extern CORE_ADDR i386bsd_sigtramp_saved_pc (struct frame_info *frame); | |
179 | +extern CORE_ADDR i386bsd_sigcontext_addr (struct frame_info *frame); | |
179 | 180 | |
180 | 181 | #endif /* i386-tdep.h */ |
@@ -387,6 +387,7 @@ void | ||
387 | 387 | _initialize_i386bsd_nat (void) |
388 | 388 | { |
389 | 389 | int sc_pc_offset; |
390 | + int sc_sp_offset; | |
390 | 391 | |
391 | 392 | /* To support the recognition of signal handlers, i386bsd-tdep.c |
392 | 393 | hardcodes some constants. Inclusion of this file means that we |
@@ -396,13 +397,19 @@ _initialize_i386bsd_nat (void) | ||
396 | 397 | |
397 | 398 | #if defined (__FreeBSD_version) && __FreeBSD_version >= 400011 |
398 | 399 | extern int i386fbsd4_sc_pc_offset; |
400 | + extern int i386fbsd4_sc_sp_offset; | |
399 | 401 | #define SC_PC_OFFSET i386fbsd4_sc_pc_offset |
400 | -#elif defined (NetBSD) || defined (__NetBSD_Version__) | |
402 | +#define SC_SP_OFFSET i386fbsd4_sc_sp_offset | |
403 | +#elif defined (NetBSD) || defined (__NetBSD_Version__) || defined (OpenBSD) | |
401 | 404 | extern int i386nbsd_sc_pc_offset; |
405 | + extern int i386nbsd_sc_sp_offset; | |
402 | 406 | #define SC_PC_OFFSET i386nbsd_sc_pc_offset |
407 | +#define SC_SP_OFFSET i386nbsd_sc_sp_offset | |
403 | 408 | #else |
404 | 409 | extern int i386bsd_sc_pc_offset; |
410 | + extern int i386bsd_sc_sp_offset; | |
405 | 411 | #define SC_PC_OFFSET i386bsd_sc_pc_offset |
412 | +#define SC_SP_OFFSET i386bsd_sc_sp_offset | |
406 | 413 | #endif |
407 | 414 | |
408 | 415 | /* Override the default value for the offset of the program counter |
@@ -418,4 +425,17 @@ Please report this to <bug-gdb@gnu.org>.", | ||
418 | 425 | } |
419 | 426 | |
420 | 427 | SC_PC_OFFSET = sc_pc_offset; |
428 | + | |
429 | + /* Likewise for the stack pointer. */ | |
430 | + sc_sp_offset = offsetof (struct sigcontext, sc_sp); | |
431 | + | |
432 | + if (SC_SP_OFFSET != sc_sp_offset) | |
433 | + { | |
434 | + warning ("\ | |
435 | +offsetof (struct sigcontext, sc_sp) yields %d instead of %d.\n\ | |
436 | +Please report this to <bug-gdb@gnu.org>.", | |
437 | + sc_sp_offset, SC_SP_OFFSET); | |
438 | + } | |
439 | + | |
440 | + SC_SP_OFFSET = sc_sp_offset; | |
421 | 441 | } |
@@ -19,6 +19,7 @@ | ||
19 | 19 | Boston, MA 02111-1307, USA. */ |
20 | 20 | |
21 | 21 | #include "defs.h" |
22 | +#include "arch-utils.h" | |
22 | 23 | #include "frame.h" |
23 | 24 | #include "gdbcore.h" |
24 | 25 | #include "regcache.h" |
@@ -38,9 +39,12 @@ i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name) | ||
38 | 39 | } |
39 | 40 | |
40 | 41 | /* Assuming FRAME is for a BSD sigtramp routine, return the address of |
41 | - the associated sigcontext structure. */ | |
42 | + the associated sigcontext structure. | |
42 | 43 | |
43 | -static CORE_ADDR | |
44 | + Note: This function is used for Solaris 2 too, so don't make it | |
45 | + static. */ | |
46 | + | |
47 | +CORE_ADDR | |
44 | 48 | i386bsd_sigcontext_addr (struct frame_info *frame) |
45 | 49 | { |
46 | 50 | if (frame->next) |
@@ -54,33 +58,6 @@ i386bsd_sigcontext_addr (struct frame_info *frame) | ||
54 | 58 | return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4); |
55 | 59 | } |
56 | 60 | |
57 | -/* Assuming FRAME is for a BSD sigtramp routine, return the saved | |
58 | - program counter. | |
59 | - | |
60 | - Note: This function is used for Solaris 2 too, so don't make it | |
61 | - static. */ | |
62 | - | |
63 | -CORE_ADDR | |
64 | -i386bsd_sigtramp_saved_pc (struct frame_info *frame) | |
65 | -{ | |
66 | - int sc_pc_offset = gdbarch_tdep (current_gdbarch)->sc_pc_offset; | |
67 | - CORE_ADDR addr; | |
68 | - | |
69 | - addr = i386bsd_sigcontext_addr (frame); | |
70 | - return read_memory_unsigned_integer (addr + sc_pc_offset, 4); | |
71 | -} | |
72 | - | |
73 | -/* Return the saved program counter for FRAME. */ | |
74 | - | |
75 | -static CORE_ADDR | |
76 | -i386bsd_frame_saved_pc (struct frame_info *frame) | |
77 | -{ | |
78 | - if (frame->signal_handler_caller) | |
79 | - return i386bsd_sigtramp_saved_pc (frame); | |
80 | - | |
81 | - return read_memory_unsigned_integer (frame->frame + 4, 4); | |
82 | -} | |
83 | - | |
84 | 61 | /* Return the start address of the sigtramp routine. */ |
85 | 62 | |
86 | 63 | CORE_ADDR |
@@ -98,10 +75,21 @@ i386bsd_sigtramp_end (CORE_ADDR pc) | ||
98 | 75 | } |
99 | 76 | |
100 | 77 | |
78 | +/* Support for shared libraries. */ | |
79 | + | |
80 | +/* Return non-zero if we are in a shared library trampoline code stub. */ | |
81 | + | |
82 | +int | |
83 | +i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name) | |
84 | +{ | |
85 | + return (name && !strcmp (name, "_DYNAMIC")); | |
86 | +} | |
87 | + | |
101 | 88 | /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */ |
102 | 89 | |
103 | 90 | /* From <machine/signal.h>. */ |
104 | 91 | int i386bsd_sc_pc_offset = 20; |
92 | +int i386bsd_sc_sp_offset = 8; | |
105 | 93 | |
106 | 94 | static void |
107 | 95 | i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
@@ -110,18 +98,24 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
110 | 98 | |
111 | 99 | set_gdbarch_pc_in_sigtramp (gdbarch, i386bsd_pc_in_sigtramp); |
112 | 100 | |
101 | + /* Assume SunOS-style shared libraries. */ | |
102 | + set_gdbarch_in_solib_call_trampoline (gdbarch, | |
103 | + i386bsd_aout_in_solib_call_trampoline); | |
104 | + | |
113 | 105 | tdep->jb_pc_offset = 0; |
114 | 106 | |
115 | - tdep->sigtramp_saved_pc = i386bsd_sigtramp_saved_pc; | |
116 | 107 | tdep->sigtramp_start = 0xfdbfdfc0; |
117 | 108 | tdep->sigtramp_end = 0xfdbfe000; |
109 | + tdep->sigcontext_addr = i386bsd_sigcontext_addr; | |
118 | 110 | tdep->sc_pc_offset = i386bsd_sc_pc_offset; |
111 | + tdep->sc_sp_offset = i386bsd_sc_sp_offset; | |
119 | 112 | } |
120 | 113 | |
121 | 114 | /* NetBSD 1.0 or later. */ |
122 | 115 | |
123 | 116 | /* From <machine/signal.h>. */ |
124 | 117 | int i386nbsd_sc_pc_offset = 44; |
118 | +int i386nbsd_sc_sp_offset = 56; | |
125 | 119 | |
126 | 120 | static void |
127 | 121 | i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
@@ -141,6 +135,7 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
141 | 135 | /* NetBSD has a `struct sigcontext' that's different from the |
142 | 136 | origional 4.3 BSD. */ |
143 | 137 | tdep->sc_pc_offset = i386nbsd_sc_pc_offset; |
138 | + tdep->sc_sp_offset = i386nbsd_sc_sp_offset; | |
144 | 139 | } |
145 | 140 | |
146 | 141 | /* NetBSD ELF. */ |
@@ -155,6 +150,10 @@ i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
155 | 150 | /* But ELF-based. */ |
156 | 151 | i386_elf_init_abi (info, gdbarch); |
157 | 152 | |
153 | + /* NetBSD ELF uses SVR4-style shared libraries. */ | |
154 | + set_gdbarch_in_solib_call_trampoline (gdbarch, | |
155 | + generic_in_solib_call_trampoline); | |
156 | + | |
158 | 157 | /* NetBSD ELF uses -fpcc-struct-return by default. */ |
159 | 158 | tdep->struct_return = pcc_struct_return; |
160 | 159 |
@@ -193,12 +192,17 @@ i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
193 | 192 | |
194 | 193 | /* Except that it uses ELF. */ |
195 | 194 | i386_elf_init_abi (info, gdbarch); |
195 | + | |
196 | + /* FreeBSD ELF uses SVR4-style shared libraries. */ | |
197 | + set_gdbarch_in_solib_call_trampoline (gdbarch, | |
198 | + generic_in_solib_call_trampoline); | |
196 | 199 | } |
197 | 200 | |
198 | 201 | /* FreeBSD 4.0-RELEASE or later. */ |
199 | 202 | |
200 | 203 | /* From <machine/signal.h>. */ |
201 | 204 | int i386fbsd4_sc_pc_offset = 76; |
205 | +int i386fbsd4_sc_sp_offset = 88; | |
202 | 206 | |
203 | 207 | static void |
204 | 208 | i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
@@ -211,6 +215,7 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
211 | 215 | |
212 | 216 | /* FreeBSD 4.0 introduced a new `struct sigcontext'. */ |
213 | 217 | tdep->sc_pc_offset = i386fbsd4_sc_pc_offset; |
218 | + tdep->sc_sp_offset = i386fbsd4_sc_sp_offset; | |
214 | 219 | } |
215 | 220 | |
216 | 221 |
@@ -86,8 +86,8 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, | ||
86 | 86 | } |
87 | 87 | |
88 | 88 | static void |
89 | -fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, | |
90 | - CORE_ADDR ignore) | |
89 | +fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, | |
90 | + int which, CORE_ADDR ignore) | |
91 | 91 | { |
92 | 92 | switch (which) |
93 | 93 | { |
@@ -42,17 +42,83 @@ | ||
42 | 42 | #define P_FMOVM 0xf237 |
43 | 43 | #define P_TRAP 0x4e40 |
44 | 44 | |
45 | + | |
46 | +/* Register numbers of various important registers. | |
47 | + Note that some of these values are "real" register numbers, | |
48 | + and correspond to the general registers of the machine, | |
49 | + and some are "phony" register numbers which are too large | |
50 | + to be actual register numbers as far as the user is concerned | |
51 | + but do serve to get the desired values when passed to read_register. */ | |
52 | + | |
53 | +/* Note: Since they are used in files other than this (monitor files), | |
54 | + D0_REGNUM and A0_REGNUM are currently defined in tm-m68k.h. */ | |
55 | + | |
45 | 56 | enum |
46 | 57 | { |
58 | + E_A1_REGNUM = 9, | |
47 | 59 | E_FP_REGNUM = 14, /* Contains address of executing stack frame */ |
48 | 60 | E_SP_REGNUM = 15, /* Contains address of top of stack */ |
49 | 61 | E_PS_REGNUM = 16, /* Contains processor status */ |
50 | 62 | E_PC_REGNUM = 17, /* Contains program counter */ |
51 | - E_FP0_REGNUM = 18 /* Floating point register 0 */ | |
63 | + E_FP0_REGNUM = 18, /* Floating point register 0 */ | |
64 | + E_FPC_REGNUM = 26, /* 68881 control register */ | |
65 | + E_FPS_REGNUM = 27, /* 68881 status register */ | |
66 | + E_FPI_REGNUM = 28 | |
52 | 67 | }; |
53 | 68 | |
69 | +#define REGISTER_BYTES_FP (16*4 + 8 + 8*12 + 3*4) | |
70 | +#define REGISTER_BYTES_NOFP (16*4 + 8) | |
71 | + | |
72 | +#define NUM_FREGS (NUM_REGS-24) | |
73 | + | |
74 | +/* Offset from SP to first arg on stack at first instruction of a function */ | |
75 | + | |
76 | +#define SP_ARG0 (1 * 4) | |
77 | + | |
78 | +/* This was determined by experimentation on hp300 BSD 4.3. Perhaps | |
79 | + it corresponds to some offset in /usr/include/sys/user.h or | |
80 | + something like that. Using some system include file would | |
81 | + have the advantage of probably being more robust in the face | |
82 | + of OS upgrades, but the disadvantage of being wrong for | |
83 | + cross-debugging. */ | |
84 | + | |
85 | +#define SIG_PC_FP_OFFSET 530 | |
86 | + | |
87 | +#define TARGET_M68K | |
88 | + | |
89 | + | |
90 | +#if !defined (BPT_VECTOR) | |
91 | +#define BPT_VECTOR 0xf | |
92 | +#endif | |
93 | + | |
94 | +#if !defined (REMOTE_BPT_VECTOR) | |
95 | +#define REMOTE_BPT_VECTOR 1 | |
96 | +#endif | |
97 | + | |
98 | + | |
54 | 99 | void m68k_frame_init_saved_regs (struct frame_info *frame_info); |
55 | 100 | |
101 | + | |
102 | +/* gdbarch_breakpoint_from_pc is set to m68k_local_breakpoint_from_pc | |
103 | + so m68k_remote_breakpoint_from_pc is currently not used. */ | |
104 | + | |
105 | +const static unsigned char * | |
106 | +m68k_remote_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) | |
107 | +{ | |
108 | + static unsigned char break_insn[] = {0x4e, (0x40 | REMOTE_BPT_VECTOR)}; | |
109 | + *lenptr = sizeof (break_insn); | |
110 | + return break_insn; | |
111 | +} | |
112 | + | |
113 | +const static unsigned char * | |
114 | +m68k_local_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) | |
115 | +{ | |
116 | + static unsigned char break_insn[] = {0x4e, (0x40 | BPT_VECTOR)}; | |
117 | + *lenptr = sizeof (break_insn); | |
118 | + return break_insn; | |
119 | +} | |
120 | + | |
121 | + | |
56 | 122 | static int |
57 | 123 | m68k_register_bytes_ok (numbytes) |
58 | 124 | { |
@@ -92,7 +158,7 @@ m68k_register_virtual_size (int regnum) | ||
92 | 158 | static struct type * |
93 | 159 | m68k_register_virtual_type (int regnum) |
94 | 160 | { |
95 | - if ((unsigned) regnum >= FPC_REGNUM) | |
161 | + if ((unsigned) regnum >= E_FPC_REGNUM) | |
96 | 162 | return lookup_pointer_type (builtin_type_void); |
97 | 163 | else if ((unsigned) regnum >= FP0_REGNUM) |
98 | 164 | return builtin_type_long_double; |
@@ -138,8 +204,8 @@ m68k_stack_align (CORE_ADDR addr) | ||
138 | 204 | static int |
139 | 205 | m68k_register_byte (int regnum) |
140 | 206 | { |
141 | - if (regnum >= FPC_REGNUM) | |
142 | - return (((regnum - FPC_REGNUM) * 4) + 168); | |
207 | + if (regnum >= E_FPC_REGNUM) | |
208 | + return (((regnum - E_FPC_REGNUM) * 4) + 168); | |
143 | 209 | else if (regnum >= FP0_REGNUM) |
144 | 210 | return (((regnum - FP0_REGNUM) * 12) + 72); |
145 | 211 | else |
@@ -152,7 +218,7 @@ m68k_register_byte (int regnum) | ||
152 | 218 | static void |
153 | 219 | m68k_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) |
154 | 220 | { |
155 | - write_register (A1_REGNUM, addr); | |
221 | + write_register (E_A1_REGNUM, addr); | |
156 | 222 | } |
157 | 223 | |
158 | 224 | /* Extract from an array regbuf containing the (raw) register state |
@@ -795,14 +861,14 @@ supply_fpregset (fpregset_t *fpregsetp) | ||
795 | 861 | register int regi; |
796 | 862 | char *from; |
797 | 863 | |
798 | - for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++) | |
864 | + for (regi = FP0_REGNUM; regi < E_FPC_REGNUM; regi++) | |
799 | 865 | { |
800 | 866 | from = (char *) &(fpregsetp->f_fpregs[regi - FP0_REGNUM][0]); |
801 | 867 | supply_register (regi, from); |
802 | 868 | } |
803 | - supply_register (FPC_REGNUM, (char *) &(fpregsetp->f_pcr)); | |
804 | - supply_register (FPS_REGNUM, (char *) &(fpregsetp->f_psr)); | |
805 | - supply_register (FPI_REGNUM, (char *) &(fpregsetp->f_fpiaddr)); | |
869 | + supply_register (E_FPC_REGNUM, (char *) &(fpregsetp->f_pcr)); | |
870 | + supply_register (E_FPS_REGNUM, (char *) &(fpregsetp->f_psr)); | |
871 | + supply_register (E_FPI_REGNUM, (char *) &(fpregsetp->f_fpiaddr)); | |
806 | 872 | } |
807 | 873 | |
808 | 874 | /* Given a pointer to a floating point register set in /proc format |
@@ -817,7 +883,7 @@ fill_fpregset (fpregset_t *fpregsetp, int regno) | ||
817 | 883 | char *to; |
818 | 884 | char *from; |
819 | 885 | |
820 | - for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++) | |
886 | + for (regi = FP0_REGNUM; regi < E_FPC_REGNUM; regi++) | |
821 | 887 | { |
822 | 888 | if ((regno == -1) || (regno == regi)) |
823 | 889 | { |
@@ -826,17 +892,17 @@ fill_fpregset (fpregset_t *fpregsetp, int regno) | ||
826 | 892 | memcpy (to, from, REGISTER_RAW_SIZE (regi)); |
827 | 893 | } |
828 | 894 | } |
829 | - if ((regno == -1) || (regno == FPC_REGNUM)) | |
895 | + if ((regno == -1) || (regno == E_FPC_REGNUM)) | |
830 | 896 | { |
831 | - fpregsetp->f_pcr = *(int *) ®isters[REGISTER_BYTE (FPC_REGNUM)]; | |
897 | + fpregsetp->f_pcr = *(int *) ®isters[REGISTER_BYTE (E_FPC_REGNUM)]; | |
832 | 898 | } |
833 | - if ((regno == -1) || (regno == FPS_REGNUM)) | |
899 | + if ((regno == -1) || (regno == E_FPS_REGNUM)) | |
834 | 900 | { |
835 | - fpregsetp->f_psr = *(int *) ®isters[REGISTER_BYTE (FPS_REGNUM)]; | |
901 | + fpregsetp->f_psr = *(int *) ®isters[REGISTER_BYTE (E_FPS_REGNUM)]; | |
836 | 902 | } |
837 | - if ((regno == -1) || (regno == FPI_REGNUM)) | |
903 | + if ((regno == -1) || (regno == E_FPI_REGNUM)) | |
838 | 904 | { |
839 | - fpregsetp->f_fpiaddr = *(int *) ®isters[REGISTER_BYTE (FPI_REGNUM)]; | |
905 | + fpregsetp->f_fpiaddr = *(int *) ®isters[REGISTER_BYTE (E_FPI_REGNUM)]; | |
840 | 906 | } |
841 | 907 | } |
842 | 908 |
@@ -936,6 +1002,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
936 | 1002 | |
937 | 1003 | set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue); |
938 | 1004 | set_gdbarch_saved_pc_after_call (gdbarch, m68k_saved_pc_after_call); |
1005 | + set_gdbarch_breakpoint_from_pc (gdbarch, m68k_local_breakpoint_from_pc); | |
939 | 1006 | |
940 | 1007 | /* Stack grows down. */ |
941 | 1008 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); |
@@ -22,8 +22,8 @@ | ||
22 | 22 | #ifndef MACROTAB_H |
23 | 23 | #define MACROTAB_H |
24 | 24 | |
25 | -#include "obstack.h" | |
26 | -#include "bcache.h" | |
25 | +struct obstack; | |
26 | +struct bcache; | |
27 | 27 | |
28 | 28 | /* How do we represent a source location? I mean, how should we |
29 | 29 | represent them within GDB; the user wants to use all sorts of |
@@ -76,22 +76,12 @@ void mcore_extract_return_value (struct type *type, char *regbuf, char *valbuf); | ||
76 | 76 | int mcore_debug = 0; |
77 | 77 | #endif |
78 | 78 | |
79 | -/* The registers of the Motorola MCore processors */ | |
80 | -/* *INDENT-OFF* */ | |
81 | -char *mcore_register_names[] = | |
82 | -{ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
83 | - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", | |
84 | - "ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7", | |
85 | - "ar8", "ar9", "ar10", "ar11", "ar12", "ar13", "ar14", "ar15", | |
86 | - "psr", "vbr", "epsr", "fpsr", "epc", "fpc", "ss0", "ss1", | |
87 | - "ss2", "ss3", "ss4", "gcr", "gsr", "cr13", "cr14", "cr15", | |
88 | - "cr16", "cr17", "cr18", "cr19", "cr20", "cr21", "cr22", "cr23", | |
89 | - "cr24", "cr25", "cr26", "cr27", "cr28", "cr29", "cr30", "cr31", | |
90 | - "pc" }; | |
91 | -/* *INDENT-ON* */ | |
92 | - | |
93 | 79 | |
80 | +/* All registers are 4 bytes long. */ | |
81 | +#define MCORE_REG_SIZE 4 | |
82 | +#define MCORE_NUM_REGS 65 | |
94 | 83 | |
84 | + | |
95 | 85 | /* Additional info that we use for managing frames */ |
96 | 86 | struct frame_extra_info |
97 | 87 | { |
@@ -175,6 +165,68 @@ mcore_dump_insn (char *commnt, CORE_ADDR pc, int insn) | ||
175 | 165 | #define mcore_insn_debug(args) {} |
176 | 166 | #endif |
177 | 167 | |
168 | + | |
169 | +static struct type * | |
170 | +mcore_register_virtual_type (int regnum) | |
171 | +{ | |
172 | + if (regnum < 0 || regnum >= MCORE_NUM_REGS) | |
173 | + internal_error (__FILE__, __LINE__, | |
174 | + "mcore_register_virtual_type: illegal register number %d", | |
175 | + regnum); | |
176 | + else | |
177 | + return builtin_type_int; | |
178 | +} | |
179 | + | |
180 | +static int | |
181 | +mcore_register_byte (int regnum) | |
182 | +{ | |
183 | + if (regnum < 0 || regnum >= MCORE_NUM_REGS) | |
184 | + internal_error (__FILE__, __LINE__, | |
185 | + "mcore_register_byte: illegal register number %d", | |
186 | + regnum); | |
187 | + else | |
188 | + return (regnum * MCORE_REG_SIZE); | |
189 | +} | |
190 | + | |
191 | +static int | |
192 | +mcore_register_size (int regnum) | |
193 | +{ | |
194 | + | |
195 | + if (regnum < 0 || regnum >= MCORE_NUM_REGS) | |
196 | + internal_error (__FILE__, __LINE__, | |
197 | + "mcore_register_size: illegal register number %d", | |
198 | + regnum); | |
199 | + else | |
200 | + return MCORE_REG_SIZE; | |
201 | +} | |
202 | + | |
203 | +/* The registers of the Motorola MCore processors */ | |
204 | + | |
205 | +static const char * | |
206 | +mcore_register_name (int regnum) | |
207 | +{ | |
208 | + | |
209 | + static char *register_names[] = { | |
210 | + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
211 | + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", | |
212 | + "ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7", | |
213 | + "ar8", "ar9", "ar10", "ar11", "ar12", "ar13", "ar14", "ar15", | |
214 | + "psr", "vbr", "epsr", "fpsr", "epc", "fpc", "ss0", "ss1", | |
215 | + "ss2", "ss3", "ss4", "gcr", "gsr", "cr13", "cr14", "cr15", | |
216 | + "cr16", "cr17", "cr18", "cr19", "cr20", "cr21", "cr22", "cr23", | |
217 | + "cr24", "cr25", "cr26", "cr27", "cr28", "cr29", "cr30", "cr31", | |
218 | + "pc" | |
219 | + }; | |
220 | + | |
221 | + if (regnum < 0 || | |
222 | + regnum >= sizeof (register_names) / sizeof (register_names[0])) | |
223 | + internal_error (__FILE__, __LINE__, | |
224 | + "mcore_register_name: illegal register number %d", | |
225 | + regnum); | |
226 | + else | |
227 | + return register_names[regnum]; | |
228 | +} | |
229 | + | |
178 | 230 | /* Given the address at which to insert a breakpoint (BP_ADDR), |
179 | 231 | what will that breakpoint be? |
180 | 232 |
@@ -981,10 +1033,59 @@ get_insn (CORE_ADDR pc) | ||
981 | 1033 | return extract_unsigned_integer (buf, 2); |
982 | 1034 | } |
983 | 1035 | |
1036 | +static struct gdbarch * | |
1037 | +mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
1038 | +{ | |
1039 | + static LONGEST call_dummy_words[7] = { }; | |
1040 | + struct gdbarch_tdep *tdep = NULL; | |
1041 | + struct gdbarch *gdbarch; | |
1042 | + | |
1043 | + /* find a candidate among the list of pre-declared architectures. */ | |
1044 | + arches = gdbarch_list_lookup_by_info (arches, &info); | |
1045 | + if (arches != NULL) | |
1046 | + return (arches->gdbarch); | |
1047 | + | |
1048 | + gdbarch = gdbarch_alloc (&info, 0); | |
1049 | + | |
1050 | + /* All registers are 32 bits */ | |
1051 | + set_gdbarch_register_size (gdbarch, MCORE_REG_SIZE); | |
1052 | + set_gdbarch_max_register_raw_size (gdbarch, MCORE_REG_SIZE); | |
1053 | + set_gdbarch_max_register_virtual_size (gdbarch, MCORE_REG_SIZE); | |
1054 | + | |
1055 | + set_gdbarch_register_name (gdbarch, mcore_register_name); | |
1056 | + set_gdbarch_register_virtual_type (gdbarch, mcore_register_virtual_type); | |
1057 | + set_gdbarch_register_virtual_size (gdbarch, mcore_register_size); | |
1058 | + set_gdbarch_register_raw_size (gdbarch, mcore_register_size); | |
1059 | + set_gdbarch_register_byte (gdbarch, mcore_register_byte); | |
1060 | + | |
1061 | + set_gdbarch_call_dummy_p (gdbarch, 1); | |
1062 | + set_gdbarch_use_generic_dummy_frames (gdbarch, 1); | |
1063 | + set_gdbarch_call_dummy_words (gdbarch, call_dummy_words); | |
1064 | + set_gdbarch_sizeof_call_dummy_words (gdbarch, 0); | |
1065 | + set_gdbarch_call_dummy_start_offset (gdbarch, 0); | |
1066 | + set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); | |
1067 | + set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0); | |
1068 | + set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT); | |
1069 | + set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy); | |
1070 | + set_gdbarch_call_dummy_address (gdbarch, entry_point_address); | |
1071 | + set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos); | |
1072 | + set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy); | |
1073 | + set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); | |
1074 | + | |
1075 | + return gdbarch; | |
1076 | +} | |
1077 | + | |
1078 | +static void | |
1079 | +mcore_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) | |
1080 | +{ | |
1081 | + | |
1082 | +} | |
1083 | + | |
984 | 1084 | void |
985 | 1085 | _initialize_mcore_tdep (void) |
986 | 1086 | { |
987 | 1087 | extern int print_insn_mcore (bfd_vma, disassemble_info *); |
1088 | + gdbarch_register (bfd_arch_mcore, mcore_gdbarch_init, mcore_dump_tdep); | |
988 | 1089 | tm_print_insn = print_insn_mcore; |
989 | 1090 | |
990 | 1091 | #ifdef MCORE_DEBUG |
@@ -2619,7 +2619,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
2619 | 2619 | set_gdbarch_register_convert_to_raw (gdbarch, rs6000_register_convert_to_raw); |
2620 | 2620 | set_gdbarch_stab_reg_to_regnum (gdbarch, rs6000_stab_reg_to_regnum); |
2621 | 2621 | |
2622 | - set_gdbarch_deprecated_extract_return_value (gdbarch, rs6000_extract_return_value); | |
2622 | + set_gdbarch_extract_return_value (gdbarch, rs6000_extract_return_value); | |
2623 | 2623 | |
2624 | 2624 | /* Note: kevinb/2002-04-12: I'm not convinced that rs6000_push_arguments() |
2625 | 2625 | is correct for the SysV ABI when the wordsize is 8, but I'm also |
@@ -2635,7 +2635,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
2635 | 2635 | |
2636 | 2636 | set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return); |
2637 | 2637 | set_gdbarch_store_return_value (gdbarch, rs6000_store_return_value); |
2638 | - set_gdbarch_deprecated_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address); | |
2638 | + set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address); | |
2639 | 2639 | set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame); |
2640 | 2640 | |
2641 | 2641 | set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue); |
@@ -359,7 +359,14 @@ static int | ||
359 | 359 | open_map (struct read_map_ctxt *ctxt) |
360 | 360 | { |
361 | 361 | #ifdef USE_LDR_ROUTINES |
362 | - ctxt->proc = ldr_my_process (); | |
362 | + /* Note: As originally written, ldr_my_process() was used to obtain | |
363 | + the value for ctxt->proc. This is incorrect, however, since | |
364 | + ldr_my_process() retrieves the "unique identifier" associated | |
365 | + with the current process (i.e. GDB) and not the one being | |
366 | + debugged. Presumably, the pid of the process being debugged is | |
367 | + compatible with the "unique identifier" used by the ldr_ | |
368 | + routines, so we use that. */ | |
369 | + ctxt->proc = ptid_get_pid (inferior_ptid); | |
363 | 370 | if (ldr_xattach (ctxt->proc) != 0) |
364 | 371 | return 0; |
365 | 372 | ctxt->next = LDR_NULL_MODULE; |
@@ -703,12 +703,12 @@ execute_command (char *p, int from_tty) | ||
703 | 703 | execute_user_command (c, arg); |
704 | 704 | else if (c->type == set_cmd || c->type == show_cmd) |
705 | 705 | do_setshow_command (arg, from_tty & caution, c); |
706 | - else if (c->func == NULL) | |
706 | + else if (!cmd_func_p (c)) | |
707 | 707 | error ("That is not a command, just a help topic."); |
708 | 708 | else if (call_command_hook) |
709 | 709 | call_command_hook (c, arg, from_tty & caution); |
710 | 710 | else |
711 | - (*c->func) (c, arg, from_tty & caution); | |
711 | + cmd_func (c, arg, from_tty & caution); | |
712 | 712 | |
713 | 713 | /* If this command has been post-hooked, run the hook last. */ |
714 | 714 | execute_cmd_post_hook (c); |
@@ -1316,8 +1316,10 @@ hand_function_call (struct value *function, int nargs, struct value **args) | ||
1316 | 1316 | struct type *value_type; |
1317 | 1317 | unsigned char struct_return; |
1318 | 1318 | CORE_ADDR struct_addr = 0; |
1319 | + char *retbuf; | |
1320 | + struct cleanup *retbuf_cleanup; | |
1319 | 1321 | struct inferior_status *inf_status; |
1320 | - struct cleanup *old_chain; | |
1322 | + struct cleanup *inf_status_cleanup; | |
1321 | 1323 | CORE_ADDR funaddr; |
1322 | 1324 | int using_gcc; /* Set to version of gcc in use, or zero if not gcc */ |
1323 | 1325 | CORE_ADDR real_pc; |
@@ -1333,8 +1335,18 @@ hand_function_call (struct value *function, int nargs, struct value **args) | ||
1333 | 1335 | if (!target_has_execution) |
1334 | 1336 | noprocess (); |
1335 | 1337 | |
1338 | + /* Create a cleanup chain that contains the retbuf (buffer | |
1339 | + containing the register values). This chain is create BEFORE the | |
1340 | + inf_status chain so that the inferior status can cleaned up | |
1341 | + (restored or discarded) without having the retbuf freed. */ | |
1342 | + retbuf = xmalloc (REGISTER_BYTES); | |
1343 | + retbuf_cleanup = make_cleanup (xfree, retbuf); | |
1344 | + | |
1345 | + /* A cleanup for the inferior status. Create this AFTER the retbuf | |
1346 | + so that this can be discarded or applied without interfering with | |
1347 | + the regbuf. */ | |
1336 | 1348 | inf_status = save_inferior_status (1); |
1337 | - old_chain = make_cleanup_restore_inferior_status (inf_status); | |
1349 | + inf_status_cleanup = make_cleanup_restore_inferior_status (inf_status); | |
1338 | 1350 | |
1339 | 1351 | /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers |
1340 | 1352 | (and POP_FRAME for restoring them). (At least on most machines) |
@@ -1656,7 +1668,6 @@ You must use a pointer to function type variable. Command ignored.", arg_name); | ||
1656 | 1668 | SAVE_DUMMY_FRAME_TOS (sp); |
1657 | 1669 | |
1658 | 1670 | { |
1659 | - struct regcache *retbuf = NULL; | |
1660 | 1671 | char *name; |
1661 | 1672 | struct symbol *symbol; |
1662 | 1673 |
@@ -1688,7 +1699,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name); | ||
1688 | 1699 | /* Execute the stack dummy routine, calling FUNCTION. |
1689 | 1700 | When it is done, discard the empty frame |
1690 | 1701 | after storing the contents of all regs into retbuf. */ |
1691 | - rc = run_stack_dummy (real_pc + CALL_DUMMY_START_OFFSET, &retbuf); | |
1702 | + rc = run_stack_dummy (real_pc + CALL_DUMMY_START_OFFSET, retbuf); | |
1692 | 1703 | |
1693 | 1704 | if (rc == 1) |
1694 | 1705 | { |
@@ -1715,11 +1726,12 @@ Evaluation of the expression containing the function (%s) will be abandoned.", | ||
1715 | 1726 | { |
1716 | 1727 | /* The user wants to stay in the frame where we stopped (default).*/ |
1717 | 1728 | |
1718 | - /* If we did the cleanups, we would print a spurious error | |
1719 | - message (Unable to restore previously selected frame), | |
1720 | - would write the registers from the inf_status (which is | |
1721 | - wrong), and would do other wrong things. */ | |
1722 | - discard_cleanups (old_chain); | |
1729 | + /* If we restored the inferior status (via the cleanup), | |
1730 | + we would print a spurious error message (Unable to | |
1731 | + restore previously selected frame), would write the | |
1732 | + registers from the inf_status (which is wrong), and | |
1733 | + would do other wrong things. */ | |
1734 | + discard_cleanups (inf_status_cleanup); | |
1723 | 1735 | discard_inferior_status (inf_status); |
1724 | 1736 | |
1725 | 1737 | /* FIXME: Insert a bunch of wrap_here; name can be very long if it's |
@@ -1737,11 +1749,12 @@ Evaluation of the expression containing the function (%s) will be abandoned.", | ||
1737 | 1749 | { |
1738 | 1750 | /* We hit a breakpoint inside the FUNCTION. */ |
1739 | 1751 | |
1740 | - /* If we did the cleanups, we would print a spurious error | |
1741 | - message (Unable to restore previously selected frame), | |
1742 | - would write the registers from the inf_status (which is | |
1743 | - wrong), and would do other wrong things. */ | |
1744 | - discard_cleanups (old_chain); | |
1752 | + /* If we restored the inferior status (via the cleanup), we | |
1753 | + would print a spurious error message (Unable to restore | |
1754 | + previously selected frame), would write the registers from | |
1755 | + the inf_status (which is wrong), and would do other wrong | |
1756 | + things. */ | |
1757 | + discard_cleanups (inf_status_cleanup); | |
1745 | 1758 | discard_inferior_status (inf_status); |
1746 | 1759 | |
1747 | 1760 | /* The following error message used to say "The expression |
@@ -1761,7 +1774,10 @@ the function call).", name); | ||
1761 | 1774 | } |
1762 | 1775 | |
1763 | 1776 | /* If we get here the called FUNCTION run to completion. */ |
1764 | - do_cleanups (old_chain); | |
1777 | + | |
1778 | + /* Restore the inferior status, via its cleanup. At this stage, | |
1779 | + leave the RETBUF alone. */ | |
1780 | + do_cleanups (inf_status_cleanup); | |
1765 | 1781 | |
1766 | 1782 | /* Figure out the value returned by the function. */ |
1767 | 1783 | /* elz: I defined this new macro for the hppa architecture only. |
@@ -1774,10 +1790,17 @@ the function call).", name); | ||
1774 | 1790 | |
1775 | 1791 | #ifdef VALUE_RETURNED_FROM_STACK |
1776 | 1792 | if (struct_return) |
1777 | - return (struct value *) VALUE_RETURNED_FROM_STACK (value_type, struct_addr); | |
1793 | + { | |
1794 | + do_cleanups (retbuf_cleanup); | |
1795 | + return VALUE_RETURNED_FROM_STACK (value_type, struct_addr); | |
1796 | + } | |
1778 | 1797 | #endif |
1779 | 1798 | |
1780 | - return value_being_returned (value_type, retbuf, struct_return); | |
1799 | + { | |
1800 | + struct value *retval = value_being_returned (value_type, retbuf, struct_return); | |
1801 | + do_cleanups (retbuf_cleanup); | |
1802 | + return retval; | |
1803 | + } | |
1781 | 1804 | } |
1782 | 1805 | } |
1783 | 1806 |
@@ -1 +1 @@ | ||
1 | -2002-06-28-cvs | |
1 | +2002-07-03-cvs |