• 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óna3f41504c1a26f5066953d0ce9b17dd1ff1e9017 (tree)
Tiempo2002-07-04 03:43:59
AutorAndrew Cagney <cagney@redh...>
CommiterAndrew Cagney

Log Message

merge with trunk.

Cambiar Resumen

Diferencia incremental

--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -424,6 +424,7 @@ Alexandre Oliva aoliva@redhat.com
424424 Tom Rix trix@redhat.com
425425 Theodore A. Roth troth@verinet.com
426426 Ian Roxborough irox@redhat.com
427+Grace Sainsbury graces@redhat.com
427428 Mark Salter msalter@redhat.com
428429 Peter Schauer Peter.Schauer@regent
429430 Andreas Schwab schwab@suse.de
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -637,7 +637,7 @@ inferior_h = inferior.h $(breakpoint_h)
637637 language_h = language.h
638638 linespec_h = linespec.h
639639 macroexp_h = macroexp.h
640-macrotab_h = macrotab.h $(obstack_h) $(bcache_h)
640+macrotab_h = macrotab.h
641641 macroscope_h = macroscope.h $(macrotab_h) $(symtab_h)
642642 memattr_h = memattr.h
643643 monitor_h = monitor.h
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -528,6 +528,26 @@ get_frame_pc (struct frame_info *frame)
528528 return frame->pc;
529529 }
530530
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+}
531551
532552 #ifdef FRAME_FIND_SAVED_REGS
533553 /* XXX - deprecated. This is a compatibility function for targets
@@ -576,17 +596,7 @@ get_frame_saved_regs (struct frame_info *frame,
576596 struct block *
577597 get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block)
578598 {
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);
590600
591601 if (addr_in_block)
592602 *addr_in_block = pc;
@@ -970,6 +980,7 @@ block_innermost_frame (struct block *block)
970980 struct frame_info *frame;
971981 register CORE_ADDR start;
972982 register CORE_ADDR end;
983+ CORE_ADDR calling_pc;
973984
974985 if (block == NULL)
975986 return NULL;
@@ -983,7 +994,8 @@ block_innermost_frame (struct block *block)
983994 frame = get_prev_frame (frame);
984995 if (frame == NULL)
985996 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)
987999 return frame;
9881000 }
9891001 }
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1505,3 +1505,23 @@ complete_on_enum (const char *enumlist[],
15051505 return matchlist;
15061506 }
15071507
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+
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -280,4 +280,10 @@ extern void dont_repeat (void);
280280
281281 extern void not_just_help_class_command (char *, int);
282282
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+
283289 #endif /* !defined (COMMAND_H) */
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -94,12 +94,12 @@ i[3456]86-*-aix*) gdb_target=i386aix ;;
9494 i[3456]86-*-bsd*) gdb_target=i386bsd ;;
9595 i[3456]86-*-freebsd*) gdb_target=fbsd ;;
9696 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 ;;
9899 i[3456]86-*-os9k) gdb_target=i386os9k ;;
99100 i[3456]86-*-go32*) gdb_target=i386aout ;;
100101 i[3456]86-*-msdosdjgpp*) gdb_target=go32 ;;
101102 i[3456]86-*-lynxos*) gdb_target=i386lynx ;;
102-i[3456]86-*-openbsd*) gdb_target=obsd ;;
103103 i[3456]86-*-solaris*) gdb_target=i386sol2 ;;
104104 i[3456]86-*-sysv4.2*) gdb_target=i386v42mp ;;
105105 i[3456]86-*-sysv4*) gdb_target=i386v4 ;;
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -250,6 +250,8 @@ extern struct symbol *get_frame_function (struct frame_info *);
250250
251251 extern CORE_ADDR get_frame_pc (struct frame_info *);
252252
253+extern CORE_ADDR frame_address_in_block (struct frame_info *);
254+
253255 extern CORE_ADDR get_pc_function_start (CORE_ADDR);
254256
255257 extern struct block *block_for_pc (CORE_ADDR);
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -240,7 +240,7 @@ i386_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
240240 /* Assuming FRAME is for a GNU/Linux sigtramp routine, return the
241241 address of the associated sigcontext structure. */
242242
243-CORE_ADDR
243+static CORE_ADDR
244244 i386_linux_sigcontext_addr (struct frame_info *frame)
245245 {
246246 CORE_ADDR pc;
@@ -286,100 +286,6 @@ i386_linux_sigcontext_addr (struct frame_info *frame)
286286 return 0;
287287 }
288288
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-
383289 /* Set the program counter for process PTID to PC. */
384290
385291 static void
@@ -557,16 +463,15 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
557463
558464 tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
559465
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;
564469
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. */
565474 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;
570475
571476 set_solib_svr4_fetch_link_map_offsets (gdbarch,
572477 i386_linux_svr4_fetch_link_map_offsets);
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -19,6 +19,7 @@
1919 Boston, MA 02111-1307, USA. */
2020
2121 #include "defs.h"
22+#include "value.h"
2223
2324 #include "i386-tdep.h"
2425
@@ -43,8 +44,13 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
4344 /* Signal trampolines are different from SVR4, in fact they're
4445 rather similar to BSD. */
4546 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;
4748 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);
4854 }
4955
5056
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -452,6 +452,38 @@ i386_get_frame_setup (CORE_ADDR pc)
452452 return (-1);
453453 }
454454
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+
455487 /* Return the chain-pointer for FRAME. In the case of the i386, the
456488 frame's nominal address is the address of a 4-byte word containing
457489 the calling frame's address. */
@@ -459,7 +491,8 @@ i386_get_frame_setup (CORE_ADDR pc)
459491 static CORE_ADDR
460492 i386_frame_chain (struct frame_info *frame)
461493 {
462- if (frame->signal_handler_caller)
494+ if (frame->signal_handler_caller
495+ || i386_frameless_signal_p (frame))
463496 return frame->frame;
464497
465498 if (! inside_entry_file (frame->pc))
@@ -472,7 +505,7 @@ i386_frame_chain (struct frame_info *frame)
472505 not have a from on the stack associated with it. If it does not,
473506 return non-zero, otherwise return zero. */
474507
475-int
508+static int
476509 i386_frameless_function_invocation (struct frame_info *frame)
477510 {
478511 if (frame->signal_handler_caller)
@@ -481,18 +514,44 @@ i386_frameless_function_invocation (struct frame_info *frame)
481514 return frameless_look_for_prologue (frame);
482515 }
483516
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+
484543 /* Return the saved program counter for FRAME. */
485544
486545 static CORE_ADDR
487546 i386_frame_saved_pc (struct frame_info *frame)
488547 {
489548 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);
493550
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);
496555 }
497556
498557 return read_memory_unsigned_integer (frame->frame + 4, 4);
@@ -503,13 +562,16 @@ i386_frame_saved_pc (struct frame_info *frame)
503562 static CORE_ADDR
504563 i386_saved_pc_after_call (struct frame_info *frame)
505564 {
565+ if (frame->signal_handler_caller)
566+ return i386_sigtramp_saved_pc (frame);
567+
506568 return read_memory_unsigned_integer (read_register (SP_REGNUM), 4);
507569 }
508570
509571 /* Return number of args passed to a frame.
510572 Can return -1, meaning no way to tell. */
511573
512-int
574+static int
513575 i386_frame_num_args (struct frame_info *fi)
514576 {
515577 #if 1
@@ -606,7 +668,7 @@ i386_frame_num_args (struct frame_info *fi)
606668 If the setup sequence is at the end of the function, then the next
607669 instruction will be a branch back to the start. */
608670
609-void
671+static void
610672 i386_frame_init_saved_regs (struct frame_info *fip)
611673 {
612674 long locals = -1;
@@ -666,7 +728,7 @@ i386_frame_init_saved_regs (struct frame_info *fip)
666728
667729 /* Return PC of first real instruction. */
668730
669-CORE_ADDR
731+static CORE_ADDR
670732 i386_skip_prologue (CORE_ADDR pc)
671733 {
672734 unsigned char op;
@@ -767,7 +829,7 @@ i386_breakpoint_from_pc (CORE_ADDR *pc, int *len)
767829 return break_insn;
768830 }
769831
770-void
832+static void
771833 i386_push_dummy_frame (void)
772834 {
773835 CORE_ADDR sp = read_register (SP_REGNUM);
@@ -803,7 +865,7 @@ static LONGEST i386_call_dummy_words[] =
803865 /* Insert the (relative) function address into the call sequence
804866 stored at DYMMY. */
805867
806-void
868+static void
807869 i386_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
808870 struct value **args, struct type *type, int gcc_p)
809871 {
@@ -820,7 +882,7 @@ i386_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
820882 *((char *)(dummy) + 4) = ((delta >> 24) & 0xff);
821883 }
822884
823-void
885+static void
824886 i386_pop_frame (void)
825887 {
826888 struct frame_info *frame = get_current_frame ();
@@ -880,7 +942,7 @@ i386_get_longjmp_target (CORE_ADDR *pc)
880942 }
881943
882944
883-CORE_ADDR
945+static CORE_ADDR
884946 i386_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
885947 int struct_return, CORE_ADDR struct_addr)
886948 {
@@ -898,7 +960,7 @@ i386_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
898960 return sp;
899961 }
900962
901-void
963+static void
902964 i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
903965 {
904966 /* Do nothing. Everything was already done by i386_push_arguments. */
@@ -914,7 +976,7 @@ i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
914976 function return value of TYPE, and copy that, in virtual format,
915977 into VALBUF. */
916978
917-void
979+static void
918980 i386_extract_return_value (struct type *type, char *regbuf, char *valbuf)
919981 {
920982 int len = TYPE_LENGTH (type);
@@ -965,7 +1027,7 @@ i386_extract_return_value (struct type *type, char *regbuf, char *valbuf)
9651027 /* Write into the appropriate registers a function return value stored
9661028 in VALBUF of type TYPE, given in virtual format. */
9671029
968-void
1030+static void
9691031 i386_store_return_value (struct type *type, char *valbuf)
9701032 {
9711033 int len = TYPE_LENGTH (type);
@@ -1037,7 +1099,7 @@ i386_store_return_value (struct type *type, char *valbuf)
10371099 the address in which a function should return its structure value,
10381100 as a CORE_ADDR. */
10391101
1040-CORE_ADDR
1102+static CORE_ADDR
10411103 i386_extract_struct_value_address (char *regbuf)
10421104 {
10431105 return extract_address (&regbuf[REGISTER_BYTE (LOW_RETURN_REGNUM)],
@@ -1080,7 +1142,7 @@ i386_use_struct_convention (int gcc_p, struct type *type)
10801142 register REGNUM. Perhaps %esi and %edi should go here, but
10811143 potentially they could be used for things other than address. */
10821144
1083-struct type *
1145+static struct type *
10841146 i386_register_virtual_type (int regnum)
10851147 {
10861148 if (regnum == PC_REGNUM || regnum == FP_REGNUM || regnum == SP_REGNUM)
@@ -1101,7 +1163,7 @@ i386_register_virtual_type (int regnum)
11011163 registers need conversion. Even if we can't find a counterexample,
11021164 this is still sloppy. */
11031165
1104-int
1166+static int
11051167 i386_register_convertible (int regnum)
11061168 {
11071169 return IS_FP_REGNUM (regnum);
@@ -1110,7 +1172,7 @@ i386_register_convertible (int regnum)
11101172 /* Convert data from raw format for register REGNUM in buffer FROM to
11111173 virtual format with type TYPE in buffer TO. */
11121174
1113-void
1175+static void
11141176 i386_register_convert_to_virtual (int regnum, struct type *type,
11151177 char *from, char *to)
11161178 {
@@ -1133,7 +1195,7 @@ i386_register_convert_to_virtual (int regnum, struct type *type,
11331195 /* Convert data from virtual format with type TYPE in buffer FROM to
11341196 raw format for register REGNUM in buffer TO. */
11351197
1136-void
1198+static void
11371199 i386_register_convert_to_raw (struct type *type, int regnum,
11381200 char *from, char *to)
11391201 {
@@ -1244,29 +1306,31 @@ i386_svr4_pc_in_sigtramp (CORE_ADDR pc, char *name)
12441306 || strcmp ("sigvechandler", name) == 0));
12451307 }
12461308
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. */
12491311
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)
12521314 {
1253- CORE_ADDR saved_pc_offset = 4;
1315+ int sigcontext_offset = -1;
12541316 char *name = NULL;
12551317
12561318 find_pc_partial_function (frame->pc, &name, NULL, NULL);
12571319 if (name)
12581320 {
12591321 if (strcmp (name, "_sigreturn") == 0)
1260- saved_pc_offset = 132 + 14 * 4;
1322+ sigcontext_offset = 132;
12611323 else if (strcmp (name, "_sigacthandler") == 0)
1262- saved_pc_offset = 80 + 14 * 4;
1324+ sigcontext_offset = 80;
12631325 else if (strcmp (name, "sigvechandler") == 0)
1264- saved_pc_offset = 120 + 14 * 4;
1326+ sigcontext_offset = 120;
12651327 }
12661328
1329+ gdb_assert (sigcontext_offset != -1);
1330+
12671331 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;
12701334 }
12711335
12721336
@@ -1303,14 +1367,16 @@ i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
13031367 set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
13041368
13051369 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;
13071373
13081374 tdep->jb_pc_offset = 20;
13091375 }
13101376
13111377 /* DJGPP. */
13121378
1313-void
1379+static void
13141380 i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
13151381 {
13161382 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -1322,7 +1388,7 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
13221388
13231389 /* NetWare. */
13241390
1325-void
1391+static void
13261392 i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
13271393 {
13281394 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -1334,7 +1400,7 @@ i386_nw_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
13341400 }
13351401
13361402
1337-struct gdbarch *
1403+static struct gdbarch *
13381404 i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
13391405 {
13401406 struct gdbarch_tdep *tdep;
@@ -1369,17 +1435,18 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
13691435
13701436 tdep->jb_pc_offset = -1;
13711437 tdep->struct_return = pcc_struct_return;
1372- tdep->sigtramp_saved_pc = NULL;
13731438 tdep->sigtramp_start = 0;
13741439 tdep->sigtramp_end = 0;
1440+ tdep->sigcontext_addr = NULL;
13751441 tdep->sc_pc_offset = -1;
1442+ tdep->sc_sp_offset = -1;
13761443
13771444 /* The format used for `long double' on almost all i386 targets is
13781445 the i387 extended floating-point format. In fact, of all targets
13791446 in the GCC 2.95 tree, only OSF/1 does it different, and insists
13801447 on having a `long double' that's not `long' at all. */
13811448 set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
1382-
1449+
13831450 /* Although the i386 extended floating-point has only 80 significant
13841451 bits, a `long double' actually takes up 96, probably to enforce
13851452 alignment. */
@@ -1388,7 +1455,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
13881455 /* NOTE: tm-i386aix.h, tm-i386bsd.h, tm-i386os9k.h, tm-ptx.h,
13891456 tm-symmetry.h currently override this. Sigh. */
13901457 set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS);
1391-
1458+
13921459 set_gdbarch_sp_regnum (gdbarch, 4);
13931460 set_gdbarch_fp_regnum (gdbarch, 5);
13941461 set_gdbarch_pc_regnum (gdbarch, 8);
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -65,15 +65,16 @@ struct gdbarch_tdep
6565 /* Convention for returning structures. */
6666 enum struct_return struct_return;
6767
68- /* Get saved PC for sigtramp. */
69- CORE_ADDR (*sigtramp_saved_pc) (struct frame_info *);
70-
7168 /* Address range where sigtramp lives. */
7269 CORE_ADDR sigtramp_start;
7370 CORE_ADDR sigtramp_end;
7471
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'. */
7676 int sc_pc_offset;
77+ int sc_sp_offset;
7778 };
7879
7980 /* Floating-point registers. */
@@ -175,6 +176,6 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);
175176
176177 /* Functions exported from i386bsd-tdep.c. */
177178
178-extern CORE_ADDR i386bsd_sigtramp_saved_pc (struct frame_info *frame);
179+extern CORE_ADDR i386bsd_sigcontext_addr (struct frame_info *frame);
179180
180181 #endif /* i386-tdep.h */
--- a/gdb/i386bsd-nat.c
+++ b/gdb/i386bsd-nat.c
@@ -387,6 +387,7 @@ void
387387 _initialize_i386bsd_nat (void)
388388 {
389389 int sc_pc_offset;
390+ int sc_sp_offset;
390391
391392 /* To support the recognition of signal handlers, i386bsd-tdep.c
392393 hardcodes some constants. Inclusion of this file means that we
@@ -396,13 +397,19 @@ _initialize_i386bsd_nat (void)
396397
397398 #if defined (__FreeBSD_version) && __FreeBSD_version >= 400011
398399 extern int i386fbsd4_sc_pc_offset;
400+ extern int i386fbsd4_sc_sp_offset;
399401 #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)
401404 extern int i386nbsd_sc_pc_offset;
405+ extern int i386nbsd_sc_sp_offset;
402406 #define SC_PC_OFFSET i386nbsd_sc_pc_offset
407+#define SC_SP_OFFSET i386nbsd_sc_sp_offset
403408 #else
404409 extern int i386bsd_sc_pc_offset;
410+ extern int i386bsd_sc_sp_offset;
405411 #define SC_PC_OFFSET i386bsd_sc_pc_offset
412+#define SC_SP_OFFSET i386bsd_sc_sp_offset
406413 #endif
407414
408415 /* Override the default value for the offset of the program counter
@@ -418,4 +425,17 @@ Please report this to <bug-gdb@gnu.org>.",
418425 }
419426
420427 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;
421441 }
--- a/gdb/i386bsd-tdep.c
+++ b/gdb/i386bsd-tdep.c
@@ -19,6 +19,7 @@
1919 Boston, MA 02111-1307, USA. */
2020
2121 #include "defs.h"
22+#include "arch-utils.h"
2223 #include "frame.h"
2324 #include "gdbcore.h"
2425 #include "regcache.h"
@@ -38,9 +39,12 @@ i386bsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
3839 }
3940
4041 /* Assuming FRAME is for a BSD sigtramp routine, return the address of
41- the associated sigcontext structure. */
42+ the associated sigcontext structure.
4243
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
4448 i386bsd_sigcontext_addr (struct frame_info *frame)
4549 {
4650 if (frame->next)
@@ -54,33 +58,6 @@ i386bsd_sigcontext_addr (struct frame_info *frame)
5458 return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4);
5559 }
5660
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-
8461 /* Return the start address of the sigtramp routine. */
8562
8663 CORE_ADDR
@@ -98,10 +75,21 @@ i386bsd_sigtramp_end (CORE_ADDR pc)
9875 }
9976
10077
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+
10188 /* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
10289
10390 /* From <machine/signal.h>. */
10491 int i386bsd_sc_pc_offset = 20;
92+int i386bsd_sc_sp_offset = 8;
10593
10694 static void
10795 i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -110,18 +98,24 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
11098
11199 set_gdbarch_pc_in_sigtramp (gdbarch, i386bsd_pc_in_sigtramp);
112100
101+ /* Assume SunOS-style shared libraries. */
102+ set_gdbarch_in_solib_call_trampoline (gdbarch,
103+ i386bsd_aout_in_solib_call_trampoline);
104+
113105 tdep->jb_pc_offset = 0;
114106
115- tdep->sigtramp_saved_pc = i386bsd_sigtramp_saved_pc;
116107 tdep->sigtramp_start = 0xfdbfdfc0;
117108 tdep->sigtramp_end = 0xfdbfe000;
109+ tdep->sigcontext_addr = i386bsd_sigcontext_addr;
118110 tdep->sc_pc_offset = i386bsd_sc_pc_offset;
111+ tdep->sc_sp_offset = i386bsd_sc_sp_offset;
119112 }
120113
121114 /* NetBSD 1.0 or later. */
122115
123116 /* From <machine/signal.h>. */
124117 int i386nbsd_sc_pc_offset = 44;
118+int i386nbsd_sc_sp_offset = 56;
125119
126120 static void
127121 i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -141,6 +135,7 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
141135 /* NetBSD has a `struct sigcontext' that's different from the
142136 origional 4.3 BSD. */
143137 tdep->sc_pc_offset = i386nbsd_sc_pc_offset;
138+ tdep->sc_sp_offset = i386nbsd_sc_sp_offset;
144139 }
145140
146141 /* NetBSD ELF. */
@@ -155,6 +150,10 @@ i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
155150 /* But ELF-based. */
156151 i386_elf_init_abi (info, gdbarch);
157152
153+ /* NetBSD ELF uses SVR4-style shared libraries. */
154+ set_gdbarch_in_solib_call_trampoline (gdbarch,
155+ generic_in_solib_call_trampoline);
156+
158157 /* NetBSD ELF uses -fpcc-struct-return by default. */
159158 tdep->struct_return = pcc_struct_return;
160159
@@ -193,12 +192,17 @@ i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
193192
194193 /* Except that it uses ELF. */
195194 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);
196199 }
197200
198201 /* FreeBSD 4.0-RELEASE or later. */
199202
200203 /* From <machine/signal.h>. */
201204 int i386fbsd4_sc_pc_offset = 76;
205+int i386fbsd4_sc_sp_offset = 88;
202206
203207 static void
204208 i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -211,6 +215,7 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
211215
212216 /* FreeBSD 4.0 introduced a new `struct sigcontext'. */
213217 tdep->sc_pc_offset = i386fbsd4_sc_pc_offset;
218+ tdep->sc_sp_offset = i386fbsd4_sc_sp_offset;
214219 }
215220
216221
--- a/gdb/i386nbsd-tdep.c
+++ b/gdb/i386nbsd-tdep.c
@@ -86,8 +86,8 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
8686 }
8787
8888 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)
9191 {
9292 switch (which)
9393 {
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -42,17 +42,83 @@
4242 #define P_FMOVM 0xf237
4343 #define P_TRAP 0x4e40
4444
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+
4556 enum
4657 {
58+ E_A1_REGNUM = 9,
4759 E_FP_REGNUM = 14, /* Contains address of executing stack frame */
4860 E_SP_REGNUM = 15, /* Contains address of top of stack */
4961 E_PS_REGNUM = 16, /* Contains processor status */
5062 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
5267 };
5368
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+
5499 void m68k_frame_init_saved_regs (struct frame_info *frame_info);
55100
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+
56122 static int
57123 m68k_register_bytes_ok (numbytes)
58124 {
@@ -92,7 +158,7 @@ m68k_register_virtual_size (int regnum)
92158 static struct type *
93159 m68k_register_virtual_type (int regnum)
94160 {
95- if ((unsigned) regnum >= FPC_REGNUM)
161+ if ((unsigned) regnum >= E_FPC_REGNUM)
96162 return lookup_pointer_type (builtin_type_void);
97163 else if ((unsigned) regnum >= FP0_REGNUM)
98164 return builtin_type_long_double;
@@ -138,8 +204,8 @@ m68k_stack_align (CORE_ADDR addr)
138204 static int
139205 m68k_register_byte (int regnum)
140206 {
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);
143209 else if (regnum >= FP0_REGNUM)
144210 return (((regnum - FP0_REGNUM) * 12) + 72);
145211 else
@@ -152,7 +218,7 @@ m68k_register_byte (int regnum)
152218 static void
153219 m68k_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
154220 {
155- write_register (A1_REGNUM, addr);
221+ write_register (E_A1_REGNUM, addr);
156222 }
157223
158224 /* Extract from an array regbuf containing the (raw) register state
@@ -795,14 +861,14 @@ supply_fpregset (fpregset_t *fpregsetp)
795861 register int regi;
796862 char *from;
797863
798- for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++)
864+ for (regi = FP0_REGNUM; regi < E_FPC_REGNUM; regi++)
799865 {
800866 from = (char *) &(fpregsetp->f_fpregs[regi - FP0_REGNUM][0]);
801867 supply_register (regi, from);
802868 }
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));
806872 }
807873
808874 /* Given a pointer to a floating point register set in /proc format
@@ -817,7 +883,7 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
817883 char *to;
818884 char *from;
819885
820- for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++)
886+ for (regi = FP0_REGNUM; regi < E_FPC_REGNUM; regi++)
821887 {
822888 if ((regno == -1) || (regno == regi))
823889 {
@@ -826,17 +892,17 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
826892 memcpy (to, from, REGISTER_RAW_SIZE (regi));
827893 }
828894 }
829- if ((regno == -1) || (regno == FPC_REGNUM))
895+ if ((regno == -1) || (regno == E_FPC_REGNUM))
830896 {
831- fpregsetp->f_pcr = *(int *) &registers[REGISTER_BYTE (FPC_REGNUM)];
897+ fpregsetp->f_pcr = *(int *) &registers[REGISTER_BYTE (E_FPC_REGNUM)];
832898 }
833- if ((regno == -1) || (regno == FPS_REGNUM))
899+ if ((regno == -1) || (regno == E_FPS_REGNUM))
834900 {
835- fpregsetp->f_psr = *(int *) &registers[REGISTER_BYTE (FPS_REGNUM)];
901+ fpregsetp->f_psr = *(int *) &registers[REGISTER_BYTE (E_FPS_REGNUM)];
836902 }
837- if ((regno == -1) || (regno == FPI_REGNUM))
903+ if ((regno == -1) || (regno == E_FPI_REGNUM))
838904 {
839- fpregsetp->f_fpiaddr = *(int *) &registers[REGISTER_BYTE (FPI_REGNUM)];
905+ fpregsetp->f_fpiaddr = *(int *) &registers[REGISTER_BYTE (E_FPI_REGNUM)];
840906 }
841907 }
842908
@@ -936,6 +1002,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
9361002
9371003 set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
9381004 set_gdbarch_saved_pc_after_call (gdbarch, m68k_saved_pc_after_call);
1005+ set_gdbarch_breakpoint_from_pc (gdbarch, m68k_local_breakpoint_from_pc);
9391006
9401007 /* Stack grows down. */
9411008 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -22,8 +22,8 @@
2222 #ifndef MACROTAB_H
2323 #define MACROTAB_H
2424
25-#include "obstack.h"
26-#include "bcache.h"
25+struct obstack;
26+struct bcache;
2727
2828 /* How do we represent a source location? I mean, how should we
2929 represent them within GDB; the user wants to use all sorts of
--- a/gdb/mcore-tdep.c
+++ b/gdb/mcore-tdep.c
@@ -76,22 +76,12 @@ void mcore_extract_return_value (struct type *type, char *regbuf, char *valbuf);
7676 int mcore_debug = 0;
7777 #endif
7878
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-
9379
80+/* All registers are 4 bytes long. */
81+#define MCORE_REG_SIZE 4
82+#define MCORE_NUM_REGS 65
9483
84+
9585 /* Additional info that we use for managing frames */
9686 struct frame_extra_info
9787 {
@@ -175,6 +165,68 @@ mcore_dump_insn (char *commnt, CORE_ADDR pc, int insn)
175165 #define mcore_insn_debug(args) {}
176166 #endif
177167
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+
178230 /* Given the address at which to insert a breakpoint (BP_ADDR),
179231 what will that breakpoint be?
180232
@@ -981,10 +1033,59 @@ get_insn (CORE_ADDR pc)
9811033 return extract_unsigned_integer (buf, 2);
9821034 }
9831035
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+
9841084 void
9851085 _initialize_mcore_tdep (void)
9861086 {
9871087 extern int print_insn_mcore (bfd_vma, disassemble_info *);
1088+ gdbarch_register (bfd_arch_mcore, mcore_gdbarch_init, mcore_dump_tdep);
9881089 tm_print_insn = print_insn_mcore;
9891090
9901091 #ifdef MCORE_DEBUG
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2619,7 +2619,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
26192619 set_gdbarch_register_convert_to_raw (gdbarch, rs6000_register_convert_to_raw);
26202620 set_gdbarch_stab_reg_to_regnum (gdbarch, rs6000_stab_reg_to_regnum);
26212621
2622- set_gdbarch_deprecated_extract_return_value (gdbarch, rs6000_extract_return_value);
2622+ set_gdbarch_extract_return_value (gdbarch, rs6000_extract_return_value);
26232623
26242624 /* Note: kevinb/2002-04-12: I'm not convinced that rs6000_push_arguments()
26252625 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)
26352635
26362636 set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return);
26372637 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);
26392639 set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame);
26402640
26412641 set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
--- a/gdb/solib-osf.c
+++ b/gdb/solib-osf.c
@@ -359,7 +359,14 @@ static int
359359 open_map (struct read_map_ctxt *ctxt)
360360 {
361361 #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);
363370 if (ldr_xattach (ctxt->proc) != 0)
364371 return 0;
365372 ctxt->next = LDR_NULL_MODULE;
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -703,12 +703,12 @@ execute_command (char *p, int from_tty)
703703 execute_user_command (c, arg);
704704 else if (c->type == set_cmd || c->type == show_cmd)
705705 do_setshow_command (arg, from_tty & caution, c);
706- else if (c->func == NULL)
706+ else if (!cmd_func_p (c))
707707 error ("That is not a command, just a help topic.");
708708 else if (call_command_hook)
709709 call_command_hook (c, arg, from_tty & caution);
710710 else
711- (*c->func) (c, arg, from_tty & caution);
711+ cmd_func (c, arg, from_tty & caution);
712712
713713 /* If this command has been post-hooked, run the hook last. */
714714 execute_cmd_post_hook (c);
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1316,8 +1316,10 @@ hand_function_call (struct value *function, int nargs, struct value **args)
13161316 struct type *value_type;
13171317 unsigned char struct_return;
13181318 CORE_ADDR struct_addr = 0;
1319+ char *retbuf;
1320+ struct cleanup *retbuf_cleanup;
13191321 struct inferior_status *inf_status;
1320- struct cleanup *old_chain;
1322+ struct cleanup *inf_status_cleanup;
13211323 CORE_ADDR funaddr;
13221324 int using_gcc; /* Set to version of gcc in use, or zero if not gcc */
13231325 CORE_ADDR real_pc;
@@ -1333,8 +1335,18 @@ hand_function_call (struct value *function, int nargs, struct value **args)
13331335 if (!target_has_execution)
13341336 noprocess ();
13351337
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. */
13361348 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);
13381350
13391351 /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers
13401352 (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);
16561668 SAVE_DUMMY_FRAME_TOS (sp);
16571669
16581670 {
1659- struct regcache *retbuf = NULL;
16601671 char *name;
16611672 struct symbol *symbol;
16621673
@@ -1688,7 +1699,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name);
16881699 /* Execute the stack dummy routine, calling FUNCTION.
16891700 When it is done, discard the empty frame
16901701 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);
16921703
16931704 if (rc == 1)
16941705 {
@@ -1715,11 +1726,12 @@ Evaluation of the expression containing the function (%s) will be abandoned.",
17151726 {
17161727 /* The user wants to stay in the frame where we stopped (default).*/
17171728
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);
17231735 discard_inferior_status (inf_status);
17241736
17251737 /* 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.",
17371749 {
17381750 /* We hit a breakpoint inside the FUNCTION. */
17391751
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);
17451758 discard_inferior_status (inf_status);
17461759
17471760 /* The following error message used to say "The expression
@@ -1761,7 +1774,10 @@ the function call).", name);
17611774 }
17621775
17631776 /* 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);
17651781
17661782 /* Figure out the value returned by the function. */
17671783 /* elz: I defined this new macro for the hppa architecture only.
@@ -1774,10 +1790,17 @@ the function call).", name);
17741790
17751791 #ifdef VALUE_RETURNED_FROM_STACK
17761792 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+ }
17781797 #endif
17791798
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+ }
17811804 }
17821805 }
17831806
--- a/gdb/version.in
+++ b/gdb/version.in
@@ -1 +1 @@
1-2002-06-28-cvs
1+2002-07-03-cvs