summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobody <>2003-03-17 14:23:51 +0000
committernobody <>2003-03-17 14:23:51 +0000
commit5f04291e65feecc0683332aa2f39d25ebaf1c31c (patch)
tree0e895656b2b3a7fdb8b834325eb4e65980e21f94
parentab015601f0f6fc053476cad220d7f7908fdcd850 (diff)
downloadbinutils-gdb-5f04291e65feecc0683332aa2f39d25ebaf1c31c.tar.gz
This commit was manufactured by cvs2svn to create branchcagney_lazyid-20030317-branchpoint
'cagney_lazyid-20030317-branch'. Sprout from offbyone-20030313-branch 2003-03-13 15:09:31 UTC nobody 'This commit was manufactured by cvs2svn to create branch' Cherrypick from master 2003-03-17 14:23:50 UTC Andrew Cagney <cagney@redhat.com> '2003-03-17 Andrew Cagney <cagney@redhat.com>': ChangeLog Makefile.in Makefile.tpl bfd/ChangeLog bfd/ieee.c bfd/version.h gdb/ChangeLog gdb/alpha-tdep.c gdb/arm-tdep.c gdb/avr-tdep.c gdb/breakpoint.c gdb/config/pa/tm-hppa.h gdb/config/sparc/tm-sparc.h gdb/cris-tdep.c gdb/d10v-tdep.c gdb/doc/ChangeLog gdb/doc/gdbint.texinfo gdb/dummy-frame.c gdb/findvar.c gdb/frame-unwind.c gdb/frame-unwind.h gdb/frame.c gdb/frame.h gdb/frv-tdep.c gdb/gdbarch.c gdb/gdbarch.h gdb/gdbarch.sh gdb/h8300-tdep.c gdb/hppa-tdep.c gdb/i386-tdep.c gdb/ia64-tdep.c gdb/m68hc11-tdep.c gdb/m68k-tdep.c gdb/mcore-tdep.c gdb/mi/ChangeLog gdb/mi/mi-main.c gdb/mips-tdep.c gdb/mn10300-tdep.c gdb/ns32k-tdep.c gdb/regcache.h gdb/rs6000-tdep.c gdb/s390-tdep.c gdb/sentinel-frame.c gdb/sh-tdep.c gdb/sparc-tdep.c gdb/stack.c gdb/tui/ChangeLog gdb/tui/tui-out.c gdb/tui/tuiRegs.c gdb/v850-tdep.c gdb/valops.c gdb/vax-tdep.c gdb/version.in gdb/x86-64-tdep.c gdb/xstormy16-tdep.c include/opcode/ChangeLog include/opcode/h8300.h opcodes/ChangeLog opcodes/ppc-opc.c sim/h8300/ChangeLog sim/h8300/compile.c
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.in82
-rw-r--r--Makefile.tpl12
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/ieee.c530
-rw-r--r--bfd/version.h2
-rw-r--r--gdb/ChangeLog139
-rw-r--r--gdb/alpha-tdep.c3
-rw-r--r--gdb/arm-tdep.c2
-rw-r--r--gdb/avr-tdep.c2
-rw-r--r--gdb/breakpoint.c2
-rw-r--r--gdb/config/pa/tm-hppa.h2
-rw-r--r--gdb/config/sparc/tm-sparc.h16
-rw-r--r--gdb/cris-tdep.c4
-rw-r--r--gdb/d10v-tdep.c120
-rw-r--r--gdb/doc/ChangeLog11
-rw-r--r--gdb/doc/gdbint.texinfo18
-rw-r--r--gdb/dummy-frame.c109
-rw-r--r--gdb/findvar.c18
-rw-r--r--gdb/frame-unwind.c9
-rw-r--r--gdb/frame-unwind.h110
-rw-r--r--gdb/frame.c423
-rw-r--r--gdb/frame.h31
-rw-r--r--gdb/frv-tdep.c3
-rw-r--r--gdb/gdbarch.c140
-rw-r--r--gdb/gdbarch.h80
-rwxr-xr-xgdb/gdbarch.sh4
-rw-r--r--gdb/h8300-tdep.c2
-rw-r--r--gdb/hppa-tdep.c2
-rw-r--r--gdb/i386-tdep.c8
-rw-r--r--gdb/ia64-tdep.c6
-rw-r--r--gdb/m68hc11-tdep.c6
-rw-r--r--gdb/m68k-tdep.c2
-rw-r--r--gdb/mcore-tdep.c2
-rw-r--r--gdb/mi/ChangeLog5
-rw-r--r--gdb/mi/mi-main.c9
-rw-r--r--gdb/mips-tdep.c4
-rw-r--r--gdb/mn10300-tdep.c2
-rw-r--r--gdb/ns32k-tdep.c2
-rw-r--r--gdb/regcache.h2
-rw-r--r--gdb/rs6000-tdep.c2
-rw-r--r--gdb/s390-tdep.c2
-rw-r--r--gdb/sentinel-frame.c32
-rw-r--r--gdb/sh-tdep.c8
-rw-r--r--gdb/sparc-tdep.c53
-rw-r--r--gdb/stack.c10
-rw-r--r--gdb/tui/ChangeLog9
-rw-r--r--gdb/tui/tui-out.c2
-rw-r--r--gdb/tui/tuiRegs.c8
-rw-r--r--gdb/v850-tdep.c2
-rw-r--r--gdb/valops.c2
-rw-r--r--gdb/vax-tdep.c3
-rw-r--r--gdb/version.in2
-rw-r--r--gdb/x86-64-tdep.c4
-rw-r--r--gdb/xstormy16-tdep.c24
-rw-r--r--include/opcode/ChangeLog5
-rw-r--r--include/opcode/h8300.h2
-rw-r--r--opcodes/ChangeLog8
-rw-r--r--opcodes/ppc-opc.c126
-rw-r--r--sim/h8300/ChangeLog9
-rw-r--r--sim/h8300/compile.c313
61 files changed, 1654 insertions, 911 deletions
diff --git a/ChangeLog b/ChangeLog
index 6755512749f..326297949df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-14 Nathanael Nerode <neroden@gcc.gnu.org>
+
+ * Makefile.tpl: Move .NOEXPORT, MAKEOVERRIDES back down.
+ * Makefile.in: Regenerate.
+
+2003-03-14 Michael Chastain <mec@shout.net>
+
+ * Makefile.in: Regenerate with correct Makefile.def.
+
2003-03-12 Nathanael Nerode <neroden@gcc.gnu.org>
* Makefile.tpl: Move .NOEXPORT, MAKEOVERRIDES up. Delete unused
diff --git a/Makefile.in b/Makefile.in
index c9bc160df98..f70250dd8d7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -20,10 +20,6 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# Don't pass command-line variables to submakes.
-.NOEXPORT:
-MAKEOVERRIDES=
-
# -------------------------------
# Standard Autoconf-set variables
# -------------------------------
@@ -641,7 +637,8 @@ CLEAN_X11_MODULES = \
clean-gdb \
clean-expect \
clean-guile \
- clean-tk
+ clean-tk \
+ clean-tix
# The target built for a native build.
# This list only includes modules actually being configured and built.
@@ -5404,6 +5401,73 @@ install-tk: installdirs
(cd tk && $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install)
+.PHONY: configure-tix maybe-configure-tix
+maybe-configure-tix:
+configure-tix:
+ @test ! -f tix/Makefile || exit 0; \
+ [ -d tix ] || mkdir tix; \
+ r=`${PWD}`; export r; \
+ s=`cd $(srcdir); ${PWD}`; export s; \
+ CC="$(CC)"; export CC; \
+ CFLAGS="$(CFLAGS)"; export CFLAGS; \
+ CXX="$(CXX)"; export CXX; \
+ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
+ if [ z$(build_canonical) != z$(host_canoncial) ] ; then \
+ AR="$(AR)"; export AR; \
+ AS="$(AS)"; export AS; \
+ CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
+ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
+ LD="$(LD)"; export LD; \
+ NM="$(NM)"; export NM; \
+ RANLIB="$(RANLIB)"; export RANLIB; \
+ WINDRES="$(WINDRES)"; export WINDRES; \
+ OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
+ OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
+ fi; \
+ echo Configuring in tix; \
+ cd tix || exit 1; \
+ case $(srcdir) in \
+ \.) \
+ srcdiroption="--srcdir=."; \
+ libsrcdir=".";; \
+ /* | [A-Za-z]:[\\/]*) \
+ srcdiroption="--srcdir=$(srcdir)/tix"; \
+ libsrcdir="$$s/tix";; \
+ *) \
+ srcdiroption="--srcdir=../$(srcdir)/tix"; \
+ libsrcdir="$$s/tix";; \
+ esac; \
+ $(SHELL) $${libsrcdir}/configure \
+ $(HOST_CONFIGARGS) $${srcdiroption} \
+ || exit 1
+
+.PHONY: all-tix maybe-all-tix
+maybe-all-tix:
+all-tix: configure-tix
+ @r=`${PWD}`; export r; \
+ s=`cd $(srcdir); ${PWD}`; export s; \
+ $(SET_LIB_PATH) \
+ (cd tix && $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) all)
+
+
+.PHONY: check-tix
+check-tix:
+ @r=`${PWD}`; export r; \
+ s=`cd $(srcdir); ${PWD}`; export s; \
+ $(SET_LIB_PATH) \
+ (cd tix && $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check)
+
+
+
+.PHONY: install-tix maybe-install-tix
+maybe-install-tix:
+install-tix: installdirs
+ @r=`${PWD}`; export r; \
+ s=`cd $(srcdir); ${PWD}`; export s; \
+ $(SET_LIB_PATH) \
+ (cd tix && $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install)
+
+
.PHONY: configure-libtermcap maybe-configure-libtermcap
maybe-configure-libtermcap:
configure-libtermcap:
@@ -7461,10 +7525,18 @@ AUTOCONF = autoconf
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/config/acx.m4
cd $(srcdir) && $(AUTOCONF)
+# ------------------------------
+# Special directives to GNU Make
+# ------------------------------
+
# Tell GNU make 3.79 not to run the top level in parallel. This
# prevents contention for $builddir/$target/config.cache, as well
# as minimizing scatter in file system caches.
NOTPARALLEL = .NOTPARALLEL
$(NOTPARALLEL):
+# Don't pass command-line variables to submakes.
+.NOEXPORT:
+MAKEOVERRIDES=
+
# end of Makefile.in
diff --git a/Makefile.tpl b/Makefile.tpl
index ab37bdf2beb..72e24983c57 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -23,10 +23,6 @@ in
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# Don't pass command-line variables to submakes.
-.NOEXPORT:
-MAKEOVERRIDES=
-
# -------------------------------
# Standard Autoconf-set variables
# -------------------------------
@@ -1454,10 +1450,18 @@ AUTOCONF = autoconf
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/config/acx.m4
cd $(srcdir) && $(AUTOCONF)
+# ------------------------------
+# Special directives to GNU Make
+# ------------------------------
+
# Tell GNU make 3.79 not to run the top level in parallel. This
# prevents contention for $builddir/$target/config.cache, as well
# as minimizing scatter in file system caches.
NOTPARALLEL = .NOTPARALLEL
$(NOTPARALLEL):
+# Don't pass command-line variables to submakes.
+.NOEXPORT:
+MAKEOVERRIDES=
+
# end of Makefile.in
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index edd9e751f60..bc78750d5b8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2003-03-14 Gene Smith <gene.smith@siemens.com>
+
+ * ieee.c (ieee_write_expression): Handle the case where symbol is
+ NULL.
+ General formatting improvements.
+
2003-03-13 Nick Clifton <nickc@redhat.com>
* configure.in (LINGUAS): Add zh_CN.
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 08119528c4e..59d57430d89 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -225,8 +225,8 @@ ieee_write_int (abfd, value)
{
unsigned int length;
- /* How many significant bytes ? */
- /* FIXME FOR LONGER INTS */
+ /* How many significant bytes ? */
+ /* FIXME FOR LONGER INTS. */
if (value & 0xff000000)
length = 4;
else if (value & 0x00ff0000)
@@ -301,10 +301,8 @@ ieee_write_id (abfd, id)
return TRUE;
}
-/***************************************************************************
-Functions for reading from ieee files in the strange way that the
-standard requires:
-*/
+/* Functions for reading from ieee files in the strange way that the
+ standard requires. */
#define this_byte(ieee) *((ieee)->input_p)
#define next_byte(ieee) ((ieee)->input_p++)
@@ -316,6 +314,7 @@ read_2bytes (ieee)
{
unsigned char c1 = this_byte_and_next (ieee);
unsigned char c2 = this_byte_and_next (ieee);
+
return (c1 << 8) | c2;
}
@@ -326,10 +325,9 @@ bfd_get_string (ieee, string, length)
size_t length;
{
size_t i;
+
for (i = 0; i < length; i++)
- {
- string[i] = this_byte_and_next (ieee);
- }
+ string[i] = this_byte_and_next (ieee);
}
static char *
@@ -338,23 +336,25 @@ read_id (ieee)
{
size_t length;
char *string;
+
length = this_byte_and_next (ieee);
if (length <= 0x7f)
{
- /* Simple string of length 0 to 127 */
+ /* Simple string of length 0 to 127. */
}
else if (length == 0xde)
{
- /* Length is next byte, allowing 0..255 */
+ /* Length is next byte, allowing 0..255. */
length = this_byte_and_next (ieee);
}
else if (length == 0xdf)
{
- /* Length is next two bytes, allowing 0..65535 */
+ /* Length is next two bytes, allowing 0..65535. */
length = this_byte_and_next (ieee);
length = (length * 256) + this_byte_and_next (ieee);
}
- /* Buy memory and read string */
+
+ /* Buy memory and read string. */
string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1);
if (!string)
return NULL;
@@ -380,57 +380,63 @@ ieee_write_expression (abfd, value, symbol, pcrel, index)
term_count++;
}
- if (bfd_is_com_section (symbol->section)
- || bfd_is_und_section (symbol->section))
- {
- /* Def of a common symbol */
- if (! ieee_write_byte (abfd, ieee_variable_X_enum)
- || ! ieee_write_int (abfd, symbol->value))
- return FALSE;
- term_count++;
- }
- else if (! bfd_is_abs_section (symbol->section))
+ /* Badly formatted binaries can have a missing symbol,
+ so test here to prevent a seg fault. */
+ if (symbol != NULL)
{
- /* Ref to defined symbol - */
-
- if (symbol->flags & BSF_GLOBAL)
+ if (bfd_is_com_section (symbol->section)
+ || bfd_is_und_section (symbol->section))
{
- if (! ieee_write_byte (abfd, ieee_variable_I_enum)
+ /* Def of a common symbol. */
+ if (! ieee_write_byte (abfd, ieee_variable_X_enum)
|| ! ieee_write_int (abfd, symbol->value))
return FALSE;
- term_count++;
+ term_count ++;
}
- else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
+ else if (! bfd_is_abs_section (symbol->section))
{
- /* This is a reference to a defined local symbol. We can
- easily do a local as a section+offset. */
- if (! ieee_write_byte (abfd, ieee_variable_R_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (symbol->section->index
- + IEEE_SECTION_NUMBER_BASE)))
- return FALSE;
- term_count++;
- if (symbol->value != 0)
+ /* Ref to defined symbol - */
+
+ if (symbol->flags & BSF_GLOBAL)
{
- if (! ieee_write_int (abfd, symbol->value))
+ if (! ieee_write_byte (abfd, ieee_variable_I_enum)
+ || ! ieee_write_int (abfd, symbol->value))
return FALSE;
term_count++;
}
- }
- else
- {
- (*_bfd_error_handler)
- (_("%s: unrecognized symbol `%s' flags 0x%x"),
- bfd_get_filename (abfd), bfd_asymbol_name (symbol),
- symbol->flags);
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
+ else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
+ {
+ /* This is a reference to a defined local symbol. We can
+ easily do a local as a section+offset. */
+ if (! ieee_write_byte (abfd, ieee_variable_R_enum)
+ || ! ieee_write_byte (abfd,
+ (bfd_byte) (symbol->section->index
+ + IEEE_SECTION_NUMBER_BASE)))
+ return FALSE;
+
+ term_count++;
+ if (symbol->value != 0)
+ {
+ if (! ieee_write_int (abfd, symbol->value))
+ return FALSE;
+ term_count++;
+ }
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: unrecognized symbol `%s' flags 0x%x"),
+ bfd_get_filename (abfd), bfd_asymbol_name (symbol),
+ symbol->flags);
+ bfd_set_error (bfd_error_invalid_operation);
+ return FALSE;
+ }
}
}
if (pcrel)
{
- /* subtract the pc from here by asking for PC of this section*/
+ /* Subtract the pc from here by asking for PC of this section. */
if (! ieee_write_byte (abfd, ieee_variable_P_enum)
|| ! ieee_write_byte (abfd,
(bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
@@ -440,10 +446,8 @@ ieee_write_expression (abfd, value, symbol, pcrel, index)
/* Handle the degenerate case of a 0 address. */
if (term_count == 0)
- {
- if (! ieee_write_int (abfd, (bfd_vma) 0))
- return FALSE;
- }
+ if (! ieee_write_int (abfd, (bfd_vma) 0))
+ return FALSE;
while (term_count > 1)
{
@@ -455,11 +459,8 @@ ieee_write_expression (abfd, value, symbol, pcrel, index)
return TRUE;
}
-/*****************************************************************************/
+/* Writes any integer into the buffer supplied and always takes 5 bytes. */
-/*
-writes any integer into the buffer supplied and always takes 5 bytes
-*/
static void
ieee_write_int5 (buffer, value)
bfd_byte *buffer;
@@ -492,6 +493,7 @@ parse_int (ieee, value_ptr)
{
int value = this_byte (ieee);
int result;
+
if (value >= 0 && value <= 127)
{
*value_ptr = value;
@@ -501,6 +503,7 @@ parse_int (ieee, value_ptr)
else if (value >= 0x80 && value <= 0x88)
{
unsigned int count = value & 0xf;
+
result = 0;
next_byte (ieee);
while (count)
@@ -664,7 +667,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
bfd_boolean loop = TRUE;
ieee_value_type stack[10];
- /* The stack pointer always points to the next unused location */
+ /* The stack pointer always points to the next unused location. */
#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
ieee_value_type *sp = stack;
@@ -675,9 +678,10 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
switch (this_byte (&(ieee->h)))
{
case ieee_variable_P_enum:
- /* P variable, current program counter for section n */
+ /* P variable, current program counter for section n. */
{
int section_n;
+
next_byte (&(ieee->h));
*pcrel = TRUE;
section_n = must_parse_int (&(ieee->h));
@@ -685,25 +689,25 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
break;
}
case ieee_variable_L_enum:
- /* L variable address of section N */
+ /* L variable address of section N. */
next_byte (&(ieee->h));
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
break;
case ieee_variable_R_enum:
- /* R variable, logical address of section module */
- /* FIXME, this should be different to L */
+ /* R variable, logical address of section module. */
+ /* FIXME, this should be different to L. */
next_byte (&(ieee->h));
PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
break;
case ieee_variable_S_enum:
- /* S variable, size in MAUS of section module */
+ /* S variable, size in MAUS of section module. */
next_byte (&(ieee->h));
PUSH (NOSYMBOL,
0,
ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size);
break;
case ieee_variable_I_enum:
- /* Push the address of variable n */
+ /* Push the address of variable n. */
{
ieee_symbol_index_type sy;
next_byte (&(ieee->h));
@@ -714,7 +718,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
}
break;
case ieee_variable_X_enum:
- /* Push the address of external variable n */
+ /* Push the address of external variable n. */
{
ieee_symbol_index_type sy;
next_byte (&(ieee->h));
@@ -776,7 +780,6 @@ parse_expression (ieee, value, symbol, pcrel, extra, section)
terms. We can tell if that's the case by ensuring that
sp == stack here. If not, then we've pushed something too far,
so we keep adding. */
-
while (sp != stack + 1)
{
asection *section1;
@@ -822,7 +825,7 @@ ieee_part_after (ieee, here)
}
static unsigned int last_index;
-static char last_type; /* is the index for an X or a D */
+static char last_type; /* Is the index for an X or a D. */
static ieee_symbol_type *
get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type)
@@ -834,8 +837,9 @@ get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type)
unsigned int *max_index;
int this_type;
{
- /* Need a new symbol */
+ /* Need a new symbol. */
unsigned int new_index = must_parse_int (&(ieee->h));
+
if (new_index != last_index || this_type != last_type)
{
ieee_symbol_type *new_symbol;
@@ -851,9 +855,8 @@ get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type)
**pptr = new_symbol;
*pptr = &new_symbol->next;
if (new_index > *max_index)
- {
- *max_index = new_index;
- }
+ *max_index = new_index;
+
last_type = this_type;
new_symbol->symbol.section = bfd_abs_section_ptr;
return new_symbol;
@@ -941,7 +944,7 @@ ieee_slurp_external_symbols (abfd)
}
break;
case ieee_external_reference_info_record_enum:
- /* Skip over ATX record. */
+ /* Skip over ATX record. */
parse_int (&(ieee->h), &value);
parse_int (&(ieee->h), &value);
parse_int (&(ieee->h), &value);
@@ -950,7 +953,7 @@ ieee_slurp_external_symbols (abfd)
case ieee_atn_record_enum:
/* We may get call optimization information here,
which we just ignore. The format is
- {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs} */
+ {$F1}${CE}{index}{$00}{$3F}{$3F}{#_of_ASNs}. */
parse_int (&ieee->h, &value);
parse_int (&ieee->h, &value);
parse_int (&ieee->h, &value);
@@ -1036,16 +1039,16 @@ ieee_slurp_external_symbols (abfd)
bfd_vma size;
bfd_vma value;
next_byte (&(ieee->h));
- /* Throw away the external reference index */
+ /* Throw away the external reference index. */
(void) must_parse_int (&(ieee->h));
- /* Fetch the default size if not resolved */
+ /* Fetch the default size if not resolved. */
size = must_parse_int (&(ieee->h));
- /* Fetch the defautlt value if available */
+ /* Fetch the defautlt value if available. */
if (! parse_int (&(ieee->h), &value))
{
value = 0;
}
- /* This turns into a common */
+ /* This turns into a common. */
symbol->symbol.section = bfd_com_section_ptr;
symbol->symbol.value = size;
}
@@ -1136,10 +1139,8 @@ ieee_get_symtab_upper_bound (abfd)
(abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
}
-/*
-Move from our internal lists to the canon table, and insert in
-symbol index order
-*/
+/* Move from our internal lists to the canon table, and insert in
+ symbol index order. */
extern const bfd_target ieee_vec;
@@ -1172,41 +1173,35 @@ ieee_get_symtab (abfd, location)
if (! ieee->symbol_table_full)
{
- /* Arrgh - there are gaps in the table, run through and fill them */
- /* up with pointers to a null place */
+ /* Arrgh - there are gaps in the table, run through and fill them
+ up with pointers to a null place. */
unsigned int i;
+
for (i = 0; i < abfd->symcount; i++)
- {
- location[i] = &empty_symbol;
- }
+ location[i] = &empty_symbol;
}
ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
for (symp = IEEE_DATA (abfd)->external_symbols;
symp != (ieee_symbol_type *) NULL;
symp = symp->next)
- {
- /* Place into table at correct index locations */
- location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
- }
+ /* Place into table at correct index locations. */
+ location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
- /* The external refs are indexed in a bit */
+ /* The external refs are indexed in a bit. */
ieee->external_reference_base_offset =
-ieee->external_reference_min_index + ieee->external_symbol_count;
for (symp = IEEE_DATA (abfd)->external_reference;
symp != (ieee_symbol_type *) NULL;
symp = symp->next)
- {
- location[symp->index + ieee->external_reference_base_offset] =
- &symp->symbol;
-
- }
+ location[symp->index + ieee->external_reference_base_offset] =
+ &symp->symbol;
}
+
if (abfd->symcount)
- {
- location[abfd->symcount] = (asymbol *) NULL;
- }
+ location[abfd->symcount] = (asymbol *) NULL;
+
return abfd->symcount;
}
@@ -1286,34 +1281,33 @@ ieee_slurp_sections (abfd)
section_type[0] = this_byte_and_next (&(ieee->h));
/* Set minimal section attributes. Attributes are
- extended later, based on section contents. */
-
+ extended later, based on section contents. */
switch (section_type[0])
{
case 0xC1:
- /* Normal attributes for absolute sections */
+ /* Normal attributes for absolute sections. */
section_type[1] = this_byte (&(ieee->h));
section->flags = SEC_ALLOC;
switch (section_type[1])
{
- case 0xD3: /* AS Absolute section attributes */
+ case 0xD3: /* AS Absolute section attributes. */
next_byte (&(ieee->h));
section_type[2] = this_byte (&(ieee->h));
switch (section_type[2])
{
case 0xD0:
- /* Normal code */
+ /* Normal code. */
next_byte (&(ieee->h));
section->flags |= SEC_CODE;
break;
case 0xC4:
- /* Normal data */
+ /* Normal data. */
next_byte (&(ieee->h));
section->flags |= SEC_DATA;
break;
case 0xD2:
next_byte (&(ieee->h));
- /* Normal rom data */
+ /* Normal rom data. */
section->flags |= SEC_ROM | SEC_DATA;
break;
default:
@@ -1321,20 +1315,20 @@ ieee_slurp_sections (abfd)
}
}
break;
- case 0xC3: /* Named relocatable sections (type C) */
+ case 0xC3: /* Named relocatable sections (type C). */
section_type[1] = this_byte (&(ieee->h));
section->flags = SEC_ALLOC;
switch (section_type[1])
{
- case 0xD0: /* Normal code (CP) */
+ case 0xD0: /* Normal code (CP). */
next_byte (&(ieee->h));
section->flags |= SEC_CODE;
break;
- case 0xC4: /* Normal data (CD) */
+ case 0xC4: /* Normal data (CD). */
next_byte (&(ieee->h));
section->flags |= SEC_DATA;
break;
- case 0xD2: /* Normal rom data (CR) */
+ case 0xD2: /* Normal rom data (CR). */
next_byte (&(ieee->h));
section->flags |= SEC_ROM | SEC_DATA;
break;
@@ -1343,12 +1337,12 @@ ieee_slurp_sections (abfd)
}
}
- /* Read section name, use it if non empty. */
+ /* Read section name, use it if non empty. */
name = read_id (&ieee->h);
if (name[0])
section->name = name;
- /* Skip these fields, which we don't care about */
+ /* Skip these fields, which we don't care about. */
{
bfd_vma parent, brother, context;
parse_int (&(ieee->h), &parent);
@@ -1452,9 +1446,7 @@ ieee_slurp_debug (abfd)
return TRUE;
}
-/***********************************************************************
-* archive stuff
-*/
+/* Archive stuff. */
const bfd_target *
ieee_archive_p (abfd)
@@ -1640,11 +1632,9 @@ ieee_object_p (abfd)
goto got_wrong_format;
ieee->mb.module_name = read_id (&(ieee->h));
if (abfd->filename == (const char *) NULL)
- {
- abfd->filename = ieee->mb.module_name;
- }
- /* Determine the architecture and machine type of the object file.
- */
+ abfd->filename = ieee->mb.module_name;
+
+ /* Determine the architecture and machine type of the object file. */
{
const bfd_arch_info_type *arch;
char family[10];
@@ -1685,7 +1675,7 @@ ieee_object_p (abfd)
}
else if (TOUPPER (processor[3]) == 'F') /* 68F333 */
strcpy (family, "68332"); /* CPU32 */
- else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers */
+ else if ((TOUPPER (processor[3]) == 'C') /* Embedded controllers. */
&& ((TOUPPER (processor[2]) == 'E')
|| (TOUPPER (processor[2]) == 'H')
|| (TOUPPER (processor[2]) == 'L')))
@@ -1694,7 +1684,7 @@ ieee_object_p (abfd)
strncat (family, processor + 4, 7);
family[9] = '\0';
}
- else /* "Regular" processors */
+ else /* "Regular" processors. */
{
strncpy (family, processor, 9);
family[9] = '\0';
@@ -1716,43 +1706,34 @@ ieee_object_p (abfd)
}
if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
- {
- goto fail;
- }
+ goto fail;
+
next_byte (&(ieee->h));
if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau))
- {
- goto fail;
- }
+ goto fail;
+
if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address))
- {
- goto fail;
- }
+ goto fail;
- /* If there is a byte order info, take it */
- if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum ||
- this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
+ /* If there is a byte order info, take it. */
+ if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum
+ || this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
next_byte (&(ieee->h));
for (part = 0; part < N_W_VARIABLES; part++)
{
bfd_boolean ok;
+
if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
- {
- goto fail;
- }
+ goto fail;
+
if (this_byte_and_next (&(ieee->h)) != part)
- {
- goto fail;
- }
+ goto fail;
ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
if (! ok)
- {
- goto fail;
- }
-
+ goto fail;
}
if (ieee->w.r.external_part != 0)
@@ -1761,7 +1742,7 @@ ieee_object_p (abfd)
/* By now we know that this is a real IEEE file, we're going to read
the whole thing into memory so that we can run up and down it
quickly. We can work out how big the file is from the trailer
- record */
+ record. */
amt = ieee->w.r.me_record + 1;
IEEE_DATA (abfd)->h.first_byte =
@@ -1782,7 +1763,6 @@ ieee_object_p (abfd)
/* Parse section data to activate file and section flags implied by
section contents. */
-
if (! ieee_slurp_section_data (abfd))
goto fail;
@@ -1835,6 +1815,7 @@ ieee_print_symbol (abfd, afile, symbol, how)
(symbol->section == (asection *) NULL
? "*abs"
: symbol->section->name);
+
if (symbol->name[0] == ' ')
{
fprintf (file, "* empty table entry ");
@@ -1868,6 +1849,7 @@ do_one (ieee, current_map, location_ptr, s, iterations)
{
unsigned int number_of_maus;
unsigned int i;
+
next_byte (&(ieee->h));
number_of_maus = must_parse_int (&(ieee->h));
@@ -1882,6 +1864,7 @@ do_one (ieee, current_map, location_ptr, s, iterations)
case ieee_load_with_relocation_enum:
{
bfd_boolean loop = TRUE;
+
next_byte (&(ieee->h));
while (loop)
{
@@ -1923,7 +1906,7 @@ do_one (ieee, current_map, location_ptr, s, iterations)
if (this_byte (&(ieee->h)) == (int) ieee_comma)
{
next_byte (&(ieee->h));
- /* Fetch number of bytes to pad */
+ /* Fetch number of bytes to pad. */
extra = must_parse_int (&(ieee->h));
};
@@ -1941,7 +1924,7 @@ do_one (ieee, current_map, location_ptr, s, iterations)
default:
break;
}
- /* Build a relocation entry for this type */
+ /* Build a relocation entry for this type. */
/* If pc rel then stick -ve pc into instruction
and take out of reloc ..
@@ -2053,7 +2036,8 @@ do_one (ieee, current_map, location_ptr, s, iterations)
return TRUE;
}
-/* Read in all the section data and relocation stuff too */
+/* Read in all the section data and relocation stuff too. */
+
static bfd_boolean
ieee_slurp_section_data (abfd)
bfd *abfd;
@@ -2064,14 +2048,13 @@ ieee_slurp_section_data (abfd)
ieee_per_section_type *current_map = (ieee_per_section_type *) NULL;
asection *s;
- /* Seek to the start of the data area */
+ /* Seek to the start of the data area. */
if (ieee->read_data)
return TRUE;
ieee->read_data = TRUE;
ieee_seek (ieee, ieee->w.r.data_part);
- /* Allocate enough space for all the section contents */
-
+ /* Allocate enough space for all the section contents. */
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
ieee_per_section_type *per = ieee_per_section (s);
@@ -2080,7 +2063,6 @@ ieee_slurp_section_data (abfd)
per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
if (!per->data)
return FALSE;
- /*SUPPRESS 68*/
per->reloc_tail_ptr =
(ieee_reloc_type **) & (s->relocation);
}
@@ -2089,7 +2071,7 @@ ieee_slurp_section_data (abfd)
{
switch (this_byte (&(ieee->h)))
{
- /* IF we see anything strange then quit */
+ /* IF we see anything strange then quit. */
default:
return TRUE;
@@ -2100,9 +2082,9 @@ ieee_slurp_section_data (abfd)
s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
current_map = ieee_per_section (s);
location_ptr = current_map->data - s->vma;
- /* The document I have says that Microtec's compilers reset */
- /* this after a sec section, even though the standard says not */
- /* to. SO .. */
+ /* The document I have says that Microtec's compilers reset
+ this after a sec section, even though the standard says not
+ to, SO... */
current_map->pc = s->vma;
break;
@@ -2116,8 +2098,9 @@ ieee_slurp_section_data (abfd)
ieee_symbol_index_type symbol;
unsigned int extra;
bfd_boolean pcrel;
+
next_byte (&(ieee->h));
- must_parse_int (&(ieee->h)); /* Throw away section #*/
+ must_parse_int (&(ieee->h)); /* Throw away section #. */
parse_expression (ieee, &value,
&symbol,
&pcrel, &extra,
@@ -2132,7 +2115,7 @@ ieee_slurp_section_data (abfd)
if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum)
next_byte (&(ieee->h));
abfd->start_address = must_parse_int (&(ieee->h));
- /* We've got to the end of the data now - */
+ /* We've got to the end of the data now - */
return TRUE;
default:
BFD_FAIL ();
@@ -2142,18 +2125,17 @@ ieee_slurp_section_data (abfd)
case ieee_repeat_data_enum:
{
/* Repeat the following LD or LR n times - we do this by
- remembering the stream pointer before running it and
- resetting it and running it n times. We special case
- the repetition of a repeat_data/load_constant
- */
-
+ remembering the stream pointer before running it and
+ resetting it and running it n times. We special case
+ the repetition of a repeat_data/load_constant. */
unsigned int iterations;
unsigned char *start;
+
next_byte (&(ieee->h));
iterations = must_parse_int (&(ieee->h));
start = ieee->h.input_p;
- if (start[0] == (int) ieee_load_constant_bytes_enum &&
- start[1] == 1)
+ if (start[0] == (int) ieee_load_constant_bytes_enum
+ && start[1] == 1)
{
while (iterations != 0)
{
@@ -2179,10 +2161,8 @@ ieee_slurp_section_data (abfd)
break;
case ieee_load_constant_bytes_enum:
case ieee_load_with_relocation_enum:
- {
- if (!do_one (ieee, current_map, location_ptr, s, 1))
- return FALSE;
- }
+ if (!do_one (ieee, current_map, location_ptr, s, 1))
+ return FALSE;
}
}
}
@@ -2245,7 +2225,7 @@ ieee_canonicalize_reloc (abfd, section, relptr, symbols)
while (src != (ieee_reloc_type *) NULL)
{
- /* Work out which symbol to attach it this reloc to */
+ /* Work out which symbol to attach it this reloc to. */
switch (src->symbol.letter)
{
case 'I':
@@ -2304,7 +2284,7 @@ ieee_write_section_part (abfd)
if (abfd->flags & EXEC_P)
{
- /* This image is executable, so output absolute sections */
+ /* This image is executable, so output absolute sections. */
if (! ieee_write_byte (abfd, ieee_variable_A_enum)
|| ! ieee_write_byte (abfd, ieee_variable_S_enum))
return FALSE;
@@ -2343,7 +2323,7 @@ ieee_write_section_part (abfd)
ieee_write_int (abfd, 0); /* Brother */
ieee_write_int (abfd, 0); /* Context */
#endif
- /* Alignment */
+ /* Alignment. */
if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
|| ! ieee_write_byte (abfd,
(bfd_byte) (s->index
@@ -2351,7 +2331,7 @@ ieee_write_section_part (abfd)
|| ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power))
return FALSE;
- /* Size */
+ /* Size. */
if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
|| ! ieee_write_byte (abfd,
(bfd_byte) (s->index
@@ -2360,8 +2340,8 @@ ieee_write_section_part (abfd)
return FALSE;
if (abfd->flags & EXEC_P)
{
- /* Relocateable sections don't have asl records */
- /* Vma */
+ /* Relocateable sections don't have asl records. */
+ /* Vma. */
if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
|| ! ieee_write_byte (abfd,
((bfd_byte)
@@ -2394,7 +2374,7 @@ do_with_relocs (abfd, s)
sizeof (arelent **),
comp);
- /* Output the section preheader */
+ /* Output the section preheader. */
if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
|| ! ieee_write_byte (abfd,
(bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
@@ -2417,23 +2397,21 @@ do_with_relocs (abfd, s)
if (relocs_to_go == 0)
{
/* If there aren't any relocations then output the load constant
- byte opcode rather than the load with relocation opcode */
-
+ byte opcode rather than the load with relocation opcode. */
while (current_byte_index < s->_raw_size)
{
bfd_size_type run;
unsigned int MAXRUN = 127;
+
run = MAXRUN;
if (run > s->_raw_size - current_byte_index)
- {
- run = s->_raw_size - current_byte_index;
- }
+ run = s->_raw_size - current_byte_index;
if (run != 0)
{
if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
return FALSE;
- /* Output a stream of bytes */
+ /* Output a stream of bytes. */
if (! ieee_write_int (abfd, run))
return FALSE;
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd)
@@ -2454,7 +2432,7 @@ do_with_relocs (abfd, s)
if ((PTR) stream == (PTR) NULL)
{
- /* Outputting a section without data, fill it up */
+ /* Outputting a section without data, fill it up. */
stream = (unsigned char *) bfd_zalloc (abfd, s->_raw_size);
if (!stream)
return FALSE;
@@ -2463,6 +2441,7 @@ do_with_relocs (abfd, s)
{
bfd_size_type run;
unsigned int MAXRUN = 127;
+
if (relocs_to_go)
{
run = (*p)->address - current_byte_index;
@@ -2470,17 +2449,14 @@ do_with_relocs (abfd, s)
run = MAXRUN;
}
else
- {
- run = MAXRUN;
- }
+ run = MAXRUN;
+
if (run > s->_raw_size - current_byte_index)
- {
- run = s->_raw_size - current_byte_index;
- }
+ run = s->_raw_size - current_byte_index;
if (run != 0)
{
- /* Output a stream of bytes */
+ /* Output a stream of bytes. */
if (! ieee_write_int (abfd, run))
return FALSE;
if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd)
@@ -2488,7 +2464,8 @@ do_with_relocs (abfd, s)
return FALSE;
current_byte_index += run;
}
- /* Output any relocations here */
+
+ /* Output any relocations here. */
if (relocs_to_go && (*p) && (*p)->address == current_byte_index)
{
while (relocs_to_go
@@ -2496,14 +2473,10 @@ do_with_relocs (abfd, s)
{
arelent *r = *p;
bfd_signed_vma ov;
-
#if 0
if (r->howto->pc_relative)
- {
- r->addend += current_byte_index;
- }
+ r->addend += current_byte_index;
#endif
-
switch (r->howto->size)
{
case 2:
@@ -2638,6 +2611,7 @@ do_without_relocs (abfd, s)
else
{
unsigned int i;
+
for (i = 0; i < s->_raw_size; i++)
{
if (stream[i] != 0)
@@ -2699,6 +2673,7 @@ static void
flush ()
{
bfd_size_type amt = output_ptr - output_ptr_start;
+
if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt)
abort ();
output_ptr = output_ptr_start;
@@ -2720,20 +2695,14 @@ write_int (value)
else
{
unsigned int length;
- /* How many significant bytes ? */
- /* FIXME FOR LONGER INTS */
+ /* How many significant bytes ? */
+ /* FIXME FOR LONGER INTS. */
if (value & 0xff000000)
- {
- length = 4;
- }
+ length = 4;
else if (value & 0x00ff0000)
- {
- length = 3;
- }
+ length = 3;
else if (value & 0x0000ff00)
- {
- length = 2;
- }
+ length = 2;
else
length = 1;
@@ -2749,7 +2718,6 @@ write_int (value)
case 1:
OUT (value);
}
-
}
}
@@ -2758,6 +2726,7 @@ copy_id ()
{
int length = THIS ();
char ch;
+
OUT (length);
NEXT ();
while (length--)
@@ -2775,6 +2744,7 @@ copy_expression ()
int stack[10];
int *tos = stack;
int value;
+
while (1)
{
switch (THIS ())
@@ -2822,7 +2792,7 @@ copy_expression ()
default:
if (THIS () > 0x84)
{
- /* Not a number, just bug out with the answer */
+ /* Not a number, just bug out with the answer. */
write_int (*(--tos));
return;
}
@@ -2830,7 +2800,7 @@ copy_expression ()
NEXT ();
break;
case 0xa5:
- /* PLUS anything */
+ /* PLUS anything. */
value = *(--tos);
value += *(--tos);
*tos++ = value;
@@ -2841,6 +2811,7 @@ copy_expression ()
int section_number;
ieee_data_type *ieee;
asection *s;
+
NEXT ();
section_number = THIS ();
@@ -2874,7 +2845,7 @@ fill_int (buf)
{
if (buf->buffer == output_buffer)
{
- /* Still a chance to output the size */
+ /* Still a chance to output the size. */
int value = output_ptr - buf->ptrp + 3;
buf->ptrp[0] = value >> 24;
buf->ptrp[1] = value >> 16;
@@ -2889,6 +2860,7 @@ drop_int (buf)
{
int type = THIS ();
int ch;
+
if (type <= 0x84)
{
NEXT ();
@@ -2962,7 +2934,8 @@ static void
f1_record ()
{
int ch;
- /* ATN record */
+
+ /* ATN record. */
NEXT ();
ch = THIS ();
switch (ch)
@@ -3002,7 +2975,7 @@ f1_record ()
}
break;
case 0xd8:
- /* EXternal ref */
+ /* EXternal ref. */
NEXT ();
OUT (0xf1);
OUT (0xd8);
@@ -3056,13 +3029,12 @@ f1_record ()
break;
}
}
-
}
static void
f0_record ()
{
- /* Attribute record */
+ /* Attribute record. */
NEXT ();
OUT (0xf0);
INTn (Symbol name);
@@ -3073,6 +3045,7 @@ static void
copy_till_end ()
{
int ch = THIS ();
+
while (1)
{
while (ch <= 0x80)
@@ -3131,11 +3104,12 @@ f8_record ()
case 0x01:
case 0x02:
case 0x03:
- /* Unique typedefs for module */
- /* GLobal typedefs */
- /* High level module scope beginning */
+ /* Unique typedefs for module. */
+ /* GLobal typedefs. */
+ /* High level module scope beginning. */
{
struct output_buffer_struct ob;
+
NEXT ();
OUT (0xf8);
OUT (ch);
@@ -3150,9 +3124,10 @@ f8_record ()
}
break;
case 0x04:
- /* Global function */
+ /* Global function. */
{
struct output_buffer_struct ob;
+
NEXT ();
OUT (0xf8);
OUT (0x04);
@@ -3172,9 +3147,10 @@ f8_record ()
break;
case 0x05:
- /* File name for source line numbers */
+ /* File name for source line numbers. */
{
struct output_buffer_struct ob;
+
NEXT ();
OUT (0xf8);
OUT (0x05);
@@ -3194,9 +3170,10 @@ f8_record ()
break;
case 0x06:
- /* Local function */
+ /* Local function. */
{
struct output_buffer_struct ob;
+
NEXT ();
OUT (0xf8);
OUT (0x06);
@@ -3214,7 +3191,7 @@ f8_record ()
break;
case 0x0a:
- /* Assembler module scope beginning -*/
+ /* Assembler module scope beginning - */
{
struct output_buffer_struct ob;
@@ -3243,6 +3220,7 @@ f8_record ()
case 0x0b:
{
struct output_buffer_struct ob;
+
NEXT ();
OUT (0xf8);
OUT (0x0b);
@@ -3279,6 +3257,7 @@ static void
block ()
{
int ch;
+
while (1)
{
ch = THIS ();
@@ -3310,11 +3289,8 @@ block ()
}
-
-/* relocate_debug,
- moves all the debug information from the source bfd to the output
- bfd, and relocates any expressions it finds
-*/
+/* Moves all the debug information from the source bfd to the output
+ bfd, and relocates any expressions it finds. */
static void
relocate_debug (output, input)
@@ -3375,6 +3351,7 @@ ieee_write_debug_part (abfd)
{
bfd *entry = chain->this;
ieee_data_type *entry_ieee = IEEE_DATA (entry);
+
if (entry_ieee->w.r.debug_information_part)
{
if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
@@ -3385,14 +3362,11 @@ ieee_write_debug_part (abfd)
chain = chain->next;
}
+
if (some_debug)
- {
- ieee->w.r.debug_information_part = here;
- }
+ ieee->w.r.debug_information_part = here;
else
- {
- ieee->w.r.debug_information_part = 0;
- }
+ ieee->w.r.debug_information_part = 0;
flush ();
}
@@ -3407,8 +3381,10 @@ ieee_write_data_part (abfd)
bfd *abfd;
{
asection *s;
+
ieee_data_type *ieee = IEEE_DATA (abfd);
ieee->w.r.data_part = bfd_tell (abfd);
+
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
/* Skip sections that have no loadable contents (.bss,
@@ -3439,6 +3415,7 @@ init_for_output (abfd)
bfd *abfd;
{
asection *s;
+
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
if ((s->flags & SEC_DEBUGGING) != 0)
@@ -3454,11 +3431,11 @@ init_for_output (abfd)
return TRUE;
}
-/** exec and core file sections */
+/* Exec and core file sections. */
+
+/* Set section contents is complicated with IEEE since the format is
+ not a byte image, but a record stream. */
-/* set section contents is complicated with IEEE since the format is
-* not a byte image, but a record stream.
-*/
static bfd_boolean
ieee_set_section_contents (abfd, section, location, offset, count)
bfd *abfd;
@@ -3504,20 +3481,21 @@ ieee_write_external_part (abfd)
{
asymbol **q;
ieee_data_type *ieee = IEEE_DATA (abfd);
-
unsigned int reference_index = IEEE_REFERENCE_BASE;
unsigned int public_index = IEEE_PUBLIC_BASE + 2;
file_ptr here = bfd_tell (abfd);
bfd_boolean hadone = FALSE;
+
if (abfd->outsymbols != (asymbol **) NULL)
{
for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++)
{
asymbol *p = *q;
+
if (bfd_is_und_section (p->section))
{
- /* This must be a symbol reference .. */
+ /* This must be a symbol reference. */
if (! ieee_write_byte (abfd, ieee_external_reference_enum)
|| ! ieee_write_int (abfd, (bfd_vma) reference_index)
|| ! ieee_write_id (abfd, p->name))
@@ -3528,7 +3506,7 @@ ieee_write_external_part (abfd)
}
else if (bfd_is_com_section (p->section))
{
- /* This is a weak reference */
+ /* This is a weak reference. */
if (! ieee_write_byte (abfd, ieee_external_reference_enum)
|| ! ieee_write_int (abfd, (bfd_vma) reference_index)
|| ! ieee_write_id (abfd, p->name)
@@ -3543,8 +3521,7 @@ ieee_write_external_part (abfd)
}
else if (p->flags & BSF_GLOBAL)
{
- /* This must be a symbol definition */
-
+ /* This must be a symbol definition. */
if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
|| ! ieee_write_int (abfd, (bfd_vma) public_index)
|| ! ieee_write_id (abfd, p->name)
@@ -3555,7 +3532,7 @@ ieee_write_external_part (abfd)
|| ! ieee_write_byte (abfd, 1)) /* one of them */
return FALSE;
- /* Write out the value */
+ /* Write out the value. */
if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
|| ! ieee_write_int (abfd, (bfd_vma) public_index))
return FALSE;
@@ -3564,7 +3541,7 @@ ieee_write_external_part (abfd)
if (abfd->flags & EXEC_P)
{
/* If fully linked, then output all symbols
- relocated */
+ relocated. */
if (! (ieee_write_int
(abfd,
(p->value
@@ -3596,8 +3573,8 @@ ieee_write_external_part (abfd)
}
else
{
- /* This can happen - when there are gaps in the symbols read */
- /* from an input ieee file */
+ /* This can happen - when there are gaps in the symbols read
+ from an input ieee file. */
}
}
}
@@ -3611,9 +3588,9 @@ ieee_write_external_part (abfd)
static const unsigned char exten[] =
{
0xf0, 0x20, 0x00,
- 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
- 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
- 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
+ 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3. */
+ 0xf1, 0xce, 0x20, 0x00, 39, 2, /* Keep symbol in original case. */
+ 0xf1, 0xce, 0x20, 0x00, 38 /* Set object type relocateable to x. */
};
static const unsigned char envi[] =
@@ -3746,7 +3723,7 @@ ieee_write_object_contents (abfd)
unsigned int i;
file_ptr old;
- /* Fast forward over the header area */
+ /* Fast forward over the header area. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return FALSE;
@@ -3755,14 +3732,14 @@ ieee_write_object_contents (abfd)
|| ! ieee_write_id (abfd, abfd->filename))
return FALSE;
- /* Fast forward over the variable bits */
+ /* Fast forward over the variable bits. */
if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
return FALSE;
- /* Bits per MAU */
+ /* Bits per MAU. */
if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
return FALSE;
- /* MAU's per address */
+ /* MAU's per address. */
if (! ieee_write_byte (abfd,
(bfd_byte) (bfd_arch_bits_per_address (abfd)
/ bfd_arch_bits_per_byte (abfd))))
@@ -3823,11 +3800,6 @@ ieee_write_object_contents (abfd)
if (! ieee_write_external_part (abfd))
return FALSE;
- /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
-
- /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
-
-
/* Write any debugs we have been told about. */
if (! ieee_write_debug_part (abfd))
return FALSE;
@@ -3842,7 +3814,7 @@ ieee_write_object_contents (abfd)
if (! ieee_write_me_part (abfd))
return FALSE;
- /* Generate the header */
+ /* Generate the header. */
if (bfd_seek (abfd, old, SEEK_SET) != 0)
return FALSE;
@@ -3861,7 +3833,7 @@ ieee_write_object_contents (abfd)
/* We read the symbols into a buffer, which is discarded when this
function exits. We read the strings into a buffer large enough to
- hold them all plus all the cached symbol entries. */
+ hold them all plus all the cached symbol entries. */
static asymbol *
ieee_make_empty_symbol (abfd)
@@ -3869,6 +3841,7 @@ ieee_make_empty_symbol (abfd)
{
bfd_size_type amt = sizeof (ieee_symbol_type);
ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt);
+
if (!new)
return NULL;
new->symbol.the_bfd = abfd;
@@ -3881,15 +3854,16 @@ ieee_openr_next_archived_file (arch, prev)
bfd *prev;
{
ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
- /* take the next one from the arch state, or reset */
+
+ /* Take the next one from the arch state, or reset. */
if (prev == (bfd *) NULL)
- {
- /* Reset the index - the first two entries are bogus*/
- ar->element_index = 2;
- }
+ /* Reset the index - the first two entries are bogus. */
+ ar->element_index = 2;
+
while (TRUE)
{
ieee_ar_obstack_type *p = ar->elements + ar->element_index;
+
ar->element_index++;
if (ar->element_index <= ar->element_count)
{
@@ -3908,7 +3882,6 @@ ieee_openr_next_archived_file (arch, prev)
bfd_set_error (bfd_error_no_more_archived_files);
return (bfd *) NULL;
}
-
}
}
@@ -3986,8 +3959,7 @@ ieee_bfd_debug_info_end (abfd)
/* Add this section to the list of sections we have debug info for, to
- be ready to output it at close time
- */
+ be ready to output it at close time. */
static void
ieee_bfd_debug_info_accumulate (abfd, section)
bfd *abfd;
@@ -3995,37 +3967,34 @@ ieee_bfd_debug_info_accumulate (abfd, section)
{
ieee_data_type *ieee = IEEE_DATA (section->owner);
ieee_data_type *output_ieee = IEEE_DATA (abfd);
- /* can only accumulate data from other ieee bfds */
+
+ /* Can only accumulate data from other ieee bfds. */
if (section->owner->xvec != abfd->xvec)
return;
- /* Only bother once per bfd */
+ /* Only bother once per bfd. */
if (ieee->done_debug)
return;
ieee->done_debug = TRUE;
- /* Don't bother if there is no debug info */
+ /* Don't bother if there is no debug info. */
if (ieee->w.r.debug_information_part == 0)
return;
-
- /* Add to chain */
+ /* Add to chain. */
{
bfd_size_type amt = sizeof (bfd_chain_type);
bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, amt);
+
if (!n)
abort (); /* FIXME */
n->this = section->owner;
n->next = (bfd_chain_type *) NULL;
if (output_ieee->chain_head)
- {
- output_ieee->chain_head->next = n;
- }
+ output_ieee->chain_head->next = n;
else
- {
- output_ieee->chain_root = n;
+ output_ieee->chain_root = n;
- }
output_ieee->chain_head = n;
}
}
@@ -4075,7 +4044,6 @@ ieee_bfd_debug_info_accumulate (abfd, section)
#define ieee_bfd_final_link _bfd_generic_final_link
#define ieee_bfd_link_split_section _bfd_generic_link_split_section
-/*SUPPRESS 460 */
const bfd_target ieee_vec =
{
"ieee", /* name */
diff --git a/bfd/version.h b/bfd/version.h
index 933a0782ba4..c42c4496ab5 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1,3 +1,3 @@
-#define BFD_VERSION_DATE 20030313
+#define BFD_VERSION_DATE 20030317
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_string@
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c9ec531b46d..bec734b8c2a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,142 @@
+2003-03-17 Andrew Cagney <cagney@redhat.com>
+
+ Fix frame off-by-one bug.
+ * frame-unwind.h (frame_this_id_ftype): Replace
+ frame_unwind_id_ftype.
+ (frame_prev_register_ftype): Replace frame_unwind_reg_ftype.
+ (struct frame_unwind): Replace "id" with "this_id". Replace "reg"
+ with "prev_register".
+ * frame-unwind.c (frame_unwind_find_by_pc): Return
+ legacy_saved_regs_unwind instead of trad_frame_unwind. Update
+ comment.
+ * dummy-frame.c (cached_find_dummy_frame): Delete function.
+ (dummy_frame_this_id): Replace dummy_frame_id_unwind.
+ (dummy_frame_prev_register): Replace dummy_frame_register_unwind.
+ (dummy_frame_unwind): Update.
+ * sentinel-frame.c (sentinel_frame_prev_register): Replace
+ sentinel_frame_register_unwind.
+ (sentinel_frame_this_id): Replace sentinel_frame_id_unwind.
+ (sentinel_frame_unwinder): Update.
+ * frame.h (legacy_saved_regs_unwind): Replace trad_frame_unwind.
+ (struct frame_info): Rename "unwind_cache" to "prologue_cache".
+ * frame.c (create_sentinel_frame): Update. Initialize
+ "prologue_cache" instead of "unwind_cache".
+ (frame_register_unwind): Call this frame's prev_register with the
+ next frame and this frame's prologue cache.
+ (get_prev_frame): Simplify. Always call prev frame's this_id with
+ this frame and prev frame's prologue cache. Document that this
+ call is shifted one to the left when compared to the
+ frame_register_unwind call.
+ (legacy_saved_regs_prev_register): Replace
+ frame_saved_regs_register_unwind.
+ (legacy_saved_regs_this_id): Replace frame_saved_regs_id_unwind.
+ (legacy_saved_regs_unwinder): Replace trad_frame_unwinder.
+ (legacy_saved_regs_unwind): Replace trad_frame_unwind.
+ * d10v-tdep.c (d10v_frame_this_id): Replace d10v_frame_id_unwind.
+ (d10v_frame_unwind): Update.
+ (d10v_frame_prev_register): Replace d10v_frame_register_unwind.
+ (d10v_frame_unwind_cache): Replace this "fi" with "next_frame".
+ (saved_regs_unwinder): Replace this "frame" with "next_frame", and
+ "saved_regs" with "this_saved_regs".
+
+2003-03-16 Andrew Cagney <cagney@redhat.com>
+
+ * frame.c (frame_pop): Don't call target_store_registers. Fix
+ problem reported by Mark Kettenis.
+
+2003-03-16 Mark Kettenis <kettenis@gnu.org>
+
+ * i386-tdep.c (i386_register_type): Renamed from
+ i386_register_virtual_type. Adjust function signature.
+ (i386_gdbarch_init): Set register_type instead of
+ deprecated_max_register_raw_size,
+ deprecated_max_register_virtual_size and register_virtual_type.
+
+2003-03-14 Andrew Cagney <cagney@redhat.com>
+
+ * frame.c (get_prev_frame): When a legacy frame, always call
+ legacy_get_prev_frame. Simplify unwind code using assumption that
+ the unwinder is new.
+ (legacy_get_prev_frame): Handle legacy sentinel frame unwind here.
+ (legacy_frame_p): When no gdbarch_unwind_dummy_id, or
+ SAVED_DUMMY_FRAME_TOS, assume a legacy frame.
+
+2003-03-14 Andrew Cagney <cagney@redhat.com>
+
+ * frame.c (get_saved_register): Delete function.
+ * frame.h (get_saved_register): Delete declaration.
+ * xstormy16-tdep.c: Update comment.
+ * regcache.h: Update comments.
+ * sparc-tdep.c (sparc_init_extra_frame_info): Instead of
+ get_saved_register and extract_address, use
+ frame_read_unsigned_register.
+ (sparc_frame_saved_pc): Ditto.
+ (sparc_get_saved_register): Instead of get_saved_register, use
+ frame_register.
+ (sparc_pop_frame): Ditto.
+ * findvar.c: Update comments.
+ (value_of_register): Call frame_register instead of
+ get_saved_register.
+ (value_from_register): Ditto.
+ * config/sparc/tm-sparc.h: Update comment.
+ * breakpoint.c: Update comment.
+
+2003-03-14 Andrew Cagney <cagney@redhat.com>
+
+ * gdbarch.sh (DEPRECATED_GET_SAVED_REGISTER): Replace
+ GET_SAVED_REGISTER.
+ * gdbarch.h, gdbarch.c: Re-generate.
+ * frame.h: Update comments.
+ * xstormy16-tdep.c (xstormy16_gdbarch_init): Update.
+ * x86-64-tdep.c (x86_64_init_abi): Update.
+ * sparc-tdep.c (sparc_gdbarch_init): Update.
+ * sh-tdep.c (sh_gdbarch_init): Update.
+ * mips-tdep.c (mips_gdbarch_init): Update.
+ * m68hc11-tdep.c (m68hc11_gdbarch_init): Update.
+ * cris-tdep.c (cris_gdbarch_init): Update.
+ * ia64-tdep.c (ia64_gdbarch_init): Update.
+ * frame.c (frame_register): Update.
+ (get_saved_register): Update.
+ * config/sparc/tm-sparc.h (DEPRECATED_GET_SAVED_REGISTER): Update.
+
+2003-03-13 Andrew Cagney <cagney@redhat.com>
+
+ * gdbarch.sh (DEPRECATED_POP_FRAME): Replace POP_FRAME.
+ * gdbarch.h, gdbarch.c: Regenerate.
+ * valops.c (hand_function_call): Update comment.
+ * stack.c (return_command): Update comment.
+ * config/sparc/tm-sparc.h (DEPRECATED_POP_FRAME): Update.
+ * config/pa/tm-hppa.h (DEPRECATED_POP_FRAME): Update.
+ * xstormy16-tdep.c (xstormy16_gdbarch_init): Update.
+ * x86-64-tdep.c (x86_64_init_abi): Update.
+ * vax-tdep.c (vax_gdbarch_init): Update.
+ * v850-tdep.c (v850_gdbarch_init): Update.
+ * sparc-tdep.c (sparc_gdbarch_init): Update.
+ * sh-tdep.c (sh_gdbarch_init): Update.
+ * s390-tdep.c (s390_gdbarch_init): Update.
+ * rs6000-tdep.c (rs6000_gdbarch_init): Update.
+ * ns32k-tdep.c (ns32k_gdbarch_init): Update.
+ * mn10300-tdep.c (mn10300_gdbarch_init): Update.
+ * mips-tdep.c (mips_gdbarch_init): Update.
+ * mcore-tdep.c (mcore_gdbarch_init): Update.
+ * m68k-tdep.c (m68k_gdbarch_init): Update.
+ * m68hc11-tdep.c (m68hc11_gdbarch_init): Update.
+ * ia64-tdep.c (ia64_gdbarch_init): Update.
+ * i386-tdep.c (i386_gdbarch_init): Update.
+ * hppa-tdep.c (hppa_gdbarch_init): Update.
+ * h8300-tdep.c (h8300_gdbarch_init): Update.
+ * frv-tdep.c (frv_gdbarch_init): Update.
+ * cris-tdep.c (cris_gdbarch_init): Update.
+ * avr-tdep.c (avr_gdbarch_init): Update.
+ * arm-tdep.c (arm_gdbarch_init): Update.
+ * alpha-tdep.c (alpha_gdbarch_init): Update.
+
+2003-03-13 Andrew Cagney <cagney@redhat.com>
+
+ * frame.c (legacy_frame_p): New function.
+ (get_prev_frame): Use legacy_frame_p.
+ * frame.h (legacy_frame_p): Declare.
+
2003-03-13 D. Venkatasubramanian <dvenkat@noida.hcltech.com>
* MAINTAINERS (write after approval): Alphabetically
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 43c2273b981..57cd8936e99 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -70,7 +70,6 @@ static gdbarch_saved_pc_after_call_ftype alpha_saved_pc_after_call;
static gdbarch_frame_chain_ftype alpha_frame_chain;
static gdbarch_push_arguments_ftype alpha_push_arguments;
-static gdbarch_pop_frame_ftype alpha_pop_frame;
static gdbarch_fix_call_dummy_ftype alpha_fix_call_dummy;
static gdbarch_get_longjmp_target_ftype alpha_get_longjmp_target;
@@ -1857,7 +1856,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0);
set_gdbarch_call_dummy_length (gdbarch, 0);
set_gdbarch_push_arguments (gdbarch, alpha_push_arguments);
- set_gdbarch_pop_frame (gdbarch, alpha_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, alpha_pop_frame);
/* On the Alpha, the call dummy code is never copied to user space,
stopping the user call is achieved via a bp_call_dummy breakpoint.
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 93051059b41..e1d19c89c68 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -2915,7 +2915,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_num_args (gdbarch, arm_frame_num_args);
set_gdbarch_frame_args_skip (gdbarch, 0);
set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, arm_frame_init_saved_regs);
- set_gdbarch_pop_frame (gdbarch, arm_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, arm_pop_frame);
/* Address manipulation. */
set_gdbarch_smash_text_address (gdbarch, arm_smash_text_address);
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index a242d6b5a91..75707fef9f5 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1183,7 +1183,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_pointer_to_address (gdbarch, avr_pointer_to_address);
set_gdbarch_push_arguments (gdbarch, avr_push_arguments);
set_gdbarch_push_return_address (gdbarch, avr_push_return_address);
- set_gdbarch_pop_frame (gdbarch, avr_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, avr_pop_frame);
set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention);
set_gdbarch_store_struct_return (gdbarch, avr_store_struct_return);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 1ff80d779b1..491766d67ea 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1679,7 +1679,7 @@ breakpoint_inserted_here_p (CORE_ADDR pc)
/* Return nonzero if FRAME is a dummy frame. We can't use
DEPRECATED_PC_IN_CALL_DUMMY because figuring out the saved SP would
- take too much time, at least using get_saved_register on the 68k.
+ take too much time, at least using frame_register() on the 68k.
This means that for this function to work right a port must use the
bp_call_dummy breakpoint. */
diff --git a/gdb/config/pa/tm-hppa.h b/gdb/config/pa/tm-hppa.h
index 4616bdd6960..4b196dcd19a 100644
--- a/gdb/config/pa/tm-hppa.h
+++ b/gdb/config/pa/tm-hppa.h
@@ -463,7 +463,7 @@ extern void hppa_push_dummy_frame (struct inferior_status *);
/* Discard from the stack the innermost frame,
restoring all saved registers. */
#if !GDB_MULTI_ARCH
-#define POP_FRAME hppa_pop_frame ()
+#define DEPRECATED_POP_FRAME hppa_pop_frame ()
extern void hppa_pop_frame (void);
#endif
diff --git a/gdb/config/sparc/tm-sparc.h b/gdb/config/sparc/tm-sparc.h
index f0267d00202..8ab7401bd82 100644
--- a/gdb/config/sparc/tm-sparc.h
+++ b/gdb/config/sparc/tm-sparc.h
@@ -199,10 +199,10 @@ extern int sparc_intreg_size (void);
stack rather than with the other registers, and this causes hair
and confusion in places like pop_frame. It might be better to
remove the ins and locals from `registers', make sure that
- get_saved_register can get them from the stack (even in the
- innermost frame), and make this the way to access them. For the
- frame pointer we would do that via TARGET_READ_FP. On the other
- hand, that is likely to be confusing or worse for flat frames. */
+ frame_register() can get them from the stack (even in the innermost
+ frame), and make this the way to access them. For the frame
+ pointer we would do that via TARGET_READ_FP. On the other hand,
+ that is likely to be confusing or worse for flat frames. */
#define REGISTER_BYTES (32*4+32*4+8*4)
@@ -453,8 +453,8 @@ extern CORE_ADDR sparc_pc_adjust (CORE_ADDR);
/* time of the register saves. */ \
int sp_offset;
-/* We need to override GET_SAVED_REGISTER so that we can deal with the
- way outs change into ins in different frames. */
+/* We need to override DEPRECATED_GET_SAVED_REGISTER so that we can
+ deal with the way outs change into ins in different frames. */
void sparc_get_saved_register (char *raw_buffer,
int *optimized,
@@ -462,7 +462,7 @@ void sparc_get_saved_register (char *raw_buffer,
struct frame_info *frame,
int regnum, enum lval_type *lvalp);
-#define GET_SAVED_REGISTER(RAW_BUFFER, OPTIMIZED, ADDRP, FRAME, REGNUM, LVAL) \
+#define DEPRECATED_GET_SAVED_REGISTER(RAW_BUFFER, OPTIMIZED, ADDRP, FRAME, REGNUM, LVAL) \
sparc_get_saved_register (RAW_BUFFER, OPTIMIZED, ADDRP, \
FRAME, REGNUM, LVAL)
@@ -683,7 +683,7 @@ void sparc_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun,
/* Push an empty stack frame, to record the current PC, etc. */
#define DEPRECATED_PUSH_DUMMY_FRAME sparc_push_dummy_frame ()
-#define POP_FRAME sparc_pop_frame ()
+#define DEPRECATED_POP_FRAME sparc_pop_frame ()
void sparc_push_dummy_frame (void);
void sparc_pop_frame (void);
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index fae9958e80f..c71c12f17f3 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -4279,13 +4279,13 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
- set_gdbarch_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
/* No register requires conversion from raw format to virtual format. */
set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not);
set_gdbarch_push_return_address (gdbarch, cris_push_return_address);
- set_gdbarch_pop_frame (gdbarch, cris_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, cris_pop_frame);
set_gdbarch_store_struct_return (gdbarch, cris_store_struct_return);
set_gdbarch_deprecated_extract_struct_value_address
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index b60ce7fad3a..f443ceff8dd 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -705,8 +705,8 @@ prologue_find_regs (struct d10v_unwind_cache *info, unsigned short op,
for it IS the sp for the next frame. */
struct d10v_unwind_cache *
-d10v_frame_unwind_cache (struct frame_info *fi,
- void **cache)
+d10v_frame_unwind_cache (struct frame_info *next_frame,
+ void **this_prologue_cache)
{
CORE_ADDR pc;
ULONGEST prev_sp;
@@ -716,18 +716,18 @@ d10v_frame_unwind_cache (struct frame_info *fi,
int i;
struct d10v_unwind_cache *info;
- if ((*cache))
- return (*cache);
+ if ((*this_prologue_cache))
+ return (*this_prologue_cache);
info = FRAME_OBSTACK_ZALLOC (struct d10v_unwind_cache);
- (*cache) = info;
+ (*this_prologue_cache) = info;
info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS);
info->size = 0;
info->return_pc = 0;
info->sp_offset = 0;
- pc = get_pc_function_start (get_frame_pc (fi));
+ pc = get_pc_function_start (frame_pc_unwind (next_frame));
info->uses_frame = 0;
while (1)
@@ -788,7 +788,7 @@ d10v_frame_unwind_cache (struct frame_info *fi,
/* The SP was moved to the FP. This indicates that a new frame
was created. Get THIS frame's FP value by unwinding it from
the next frame. */
- frame_read_unsigned_register (fi, FP_REGNUM, &this_base);
+ frame_unwind_unsigned_register (next_frame, FP_REGNUM, &this_base);
/* The FP points at the last saved register. Adjust the FP back
to before the first saved register giving the SP. */
prev_sp = this_base + info->size;
@@ -806,7 +806,7 @@ d10v_frame_unwind_cache (struct frame_info *fi,
{
/* Assume that the FP is this frame's SP but with that pushed
stack space added back. */
- frame_read_unsigned_register (fi, SP_REGNUM, &this_base);
+ frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base);
prev_sp = this_base + info->size;
}
@@ -831,7 +831,7 @@ d10v_frame_unwind_cache (struct frame_info *fi,
else
{
ULONGEST return_pc;
- frame_read_unsigned_register (fi, LR_REGNUM, &return_pc);
+ frame_unwind_unsigned_register (next_frame, LR_REGNUM, &return_pc);
info->return_pc = d10v_make_iaddr (return_pc);
}
@@ -1457,58 +1457,55 @@ d10v_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
frame. This will be used to create a new GDB frame struct. */
static void
-d10v_frame_id_unwind (struct frame_info *frame,
- void **cache,
- struct frame_id *id)
+d10v_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
{
- struct d10v_unwind_cache *info = d10v_frame_unwind_cache (frame, cache);
- CORE_ADDR addr;
+ struct d10v_unwind_cache *info
+ = d10v_frame_unwind_cache (next_frame, this_prologue_cache);
+ CORE_ADDR base;
+ CORE_ADDR pc;
/* Start with a NULL frame ID. */
- (*id) = null_frame_id;
+ (*this_id) = null_frame_id;
- if (info->return_pc == IMEM_START
- || info->return_pc <= IMEM_START
- || inside_entry_file (info->return_pc))
- {
- /* This is meant to halt the backtrace at "_start".
- Make sure we don't halt it at a generic dummy frame. */
- return;
- }
+ /* The PC is easy. */
+ pc = frame_pc_unwind (next_frame);
- if (!info->saved_regs[FP_REGNUM])
- {
- if (!info->saved_regs[SP_REGNUM]
- || info->saved_regs[SP_REGNUM] == STACK_START)
- return;
+ /* This is meant to halt the backtrace at "_start". Make sure we
+ don't halt it at a generic dummy frame. */
+ if (pc == IMEM_START || pc <= IMEM_START || inside_entry_file (pc))
+ return;
- id->base = info->saved_regs[SP_REGNUM];
- id->pc = info->return_pc;
- }
+ /* Hopefully the prologue analysis either correctly determined the
+ frame's base (which is the SP from the previous frame), or set
+ that base to "NULL". */
+ base = info->base;
+ if (base == STACK_START || base == 0)
+ return;
- addr = read_memory_unsigned_integer (info->saved_regs[FP_REGNUM],
- register_size (current_gdbarch, FP_REGNUM));
- if (addr == 0)
+ /* Check that we're not going round in circles with the same frame
+ ID (but avoid applying the test to sentinel frames which do go
+ round in circles). Can't use frame_id_eq() as that doesn't yet
+ compare the frame's PC value. */
+ if (frame_relative_level (next_frame) >= 0
+ && get_frame_type (next_frame) != DUMMY_FRAME
+ && get_frame_id (next_frame).pc == pc
+ && get_frame_id (next_frame).base == base)
return;
- id->base = d10v_make_daddr (addr);
- id->pc = info->return_pc;
+ this_id->base = base;
+ this_id->pc = pc;
}
static void
-saved_regs_unwinder (struct frame_info *frame,
- CORE_ADDR *saved_regs,
+saved_regs_unwinder (struct frame_info *next_frame,
+ CORE_ADDR *this_saved_regs,
int regnum, int *optimizedp,
enum lval_type *lvalp, CORE_ADDR *addrp,
int *realnump, void *bufferp)
{
- /* If we're using generic dummy frames, we'd better not be in a call
- dummy. (generic_call_dummy_register_unwind ought to have been called
- instead.) */
- gdb_assert (!(DEPRECATED_USE_GENERIC_DUMMY_FRAMES
- && (get_frame_type (frame) == DUMMY_FRAME)));
-
- if (saved_regs[regnum] != 0)
+ if (this_saved_regs[regnum] != 0)
{
if (regnum == SP_REGNUM)
{
@@ -1519,7 +1516,7 @@ saved_regs_unwinder (struct frame_info *frame,
*realnump = -1;
if (bufferp != NULL)
store_address (bufferp, register_size (current_gdbarch, regnum),
- saved_regs[regnum]);
+ this_saved_regs[regnum]);
}
else
{
@@ -1527,12 +1524,12 @@ saved_regs_unwinder (struct frame_info *frame,
a local copy of its value. */
*optimizedp = 0;
*lvalp = lval_memory;
- *addrp = saved_regs[regnum];
+ *addrp = this_saved_regs[regnum];
*realnump = -1;
if (bufferp != NULL)
{
/* Read the value in from memory. */
- read_memory (saved_regs[regnum], bufferp,
+ read_memory (this_saved_regs[regnum], bufferp,
register_size (current_gdbarch, regnum));
}
}
@@ -1543,38 +1540,39 @@ saved_regs_unwinder (struct frame_info *frame,
value. If a value is needed, pass the request on down the chain;
otherwise just return an indication that the value is in the same
register as the next frame. */
- frame_register (frame, regnum, optimizedp, lvalp, addrp,
- realnump, bufferp);
+ frame_register_unwind (next_frame, regnum, optimizedp, lvalp, addrp,
+ realnump, bufferp);
}
static void
-d10v_frame_register_unwind (struct frame_info *frame,
- void **cache,
- int regnum, int *optimizedp,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnump, void *bufferp)
-{
- struct d10v_unwind_cache *info = d10v_frame_unwind_cache (frame, cache);
+d10v_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *bufferp)
+{
+ struct d10v_unwind_cache *info
+ = d10v_frame_unwind_cache (next_frame, this_prologue_cache);
if (regnum == PC_REGNUM)
{
/* The call instruction saves the caller's PC in LR. The
function prologue of the callee may then save the LR on the
stack. Find that possibly saved LR value and return it. */
- saved_regs_unwinder (frame, info->saved_regs, LR_REGNUM, optimizedp,
+ saved_regs_unwinder (next_frame, info->saved_regs, LR_REGNUM, optimizedp,
lvalp, addrp, realnump, bufferp);
}
else
{
- saved_regs_unwinder (frame, info->saved_regs, regnum, optimizedp,
+ saved_regs_unwinder (next_frame, info->saved_regs, regnum, optimizedp,
lvalp, addrp, realnump, bufferp);
}
}
static struct frame_unwind d10v_frame_unwind = {
- d10v_frame_id_unwind,
- d10v_frame_register_unwind
+ d10v_frame_this_id,
+ d10v_frame_prev_register
};
const struct frame_unwind *
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c6e1c61b54f..982322d4bb1 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,5 +1,16 @@
2003-03-12 Andrew Cagney <cagney@redhat.com>
+ * gdbint.texinfo (Target Architecture Definition): Delete
+ references to get_saved_register. Rename GET_SAVED_REGISTER to
+ DEPRECATED_GET_SAVED_REGISTER.
+
+2003-03-13 Andrew Cagney <cagney@redhat.com>
+
+ * gdbint.texinfo (Target Architecture Definition): Replace
+ POP_FRAME with DEPRECATED_POP_FRAME. Update description.
+
+2003-03-12 Andrew Cagney <cagney@redhat.com>
+
* gdbint.texinfo (Target Architecture Definition): Rename
FRAME_SAVED_PC to DEPRECATED_FRAME_SAVED_PC.
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index 60d6c9dd0b7..186d9e7308c 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -3352,11 +3352,10 @@ assuming that we have just stopped at a @code{longjmp} breakpoint. It takes a
@code{CORE_ADDR *} as argument, and stores the target PC value through this
pointer. It examines the current state of the machine as needed.
-@item GET_SAVED_REGISTER
-@findex GET_SAVED_REGISTER
-@findex get_saved_register
+@item DEPRECATED_GET_SAVED_REGISTER
+@findex DEPRECATED_GET_SAVED_REGISTER
Define this if you need to supply your own definition for the function
-@code{get_saved_register}.
+@code{DEPRECATED_GET_SAVED_REGISTER}.
@item IBM6000_TARGET
@findex IBM6000_TARGET
@@ -3680,12 +3679,11 @@ A hook defined for XCOFF reading.
If defined, this is the number of the processor status register. (This
definition is only used in generic code when parsing "$ps".)
-@item POP_FRAME
-@findex POP_FRAME
-@findex call_function_by_hand
-@findex return_command
-Used in @samp{call_function_by_hand} to remove an artificial stack
-frame and in @samp{return_command} to remove a real stack frame.
+@item DEPRECATED_POP_FRAME
+@findex DEPRECATED_POP_FRAME
+@findex frame_pop
+If defined, used by @code{frame_pop} to remove a stack frame. This
+method has been superseeded by generic code.
@item PUSH_ARGUMENTS (@var{nargs}, @var{args}, @var{sp}, @var{struct_return}, @var{struct_addr})
@findex PUSH_ARGUMENTS
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index bf4a31c1ef4..3f7746f235d 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -30,6 +30,10 @@
#include "gdb_assert.h"
#include "frame-unwind.h"
+static void dummy_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id);
+
/* Dummy frame. This saves the processor state just prior to setting
up the inferior function call. Older targets save the registers
on the target stack (but that really slows down function calls). */
@@ -104,14 +108,6 @@ find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
return NULL;
}
-struct dummy_frame *
-cached_find_dummy_frame (struct frame_info *frame, void **cache)
-{
- if ((*cache) == NULL)
- (*cache) = find_dummy_frame (get_frame_pc (frame), get_frame_base (frame));
- return (*cache);
-}
-
struct regcache *
generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
{
@@ -313,12 +309,19 @@ generic_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
register value is taken from the local copy of the register buffer. */
static void
-dummy_frame_register_unwind (struct frame_info *frame, void **cache,
- int regnum, int *optimized,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnum, void *bufferp)
+dummy_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimized,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnum, void *bufferp)
{
- struct dummy_frame *dummy = cached_find_dummy_frame (frame, cache);
+ struct dummy_frame *dummy;
+ struct frame_id id;
+
+ /* Call the ID method which, if at all possible, will set the
+ prologue cache. */
+ dummy_frame_this_id (next_frame, this_prologue_cache, &id);
+ dummy = (*this_prologue_cache);
gdb_assert (dummy != NULL);
/* Describe the register's location. Generic dummy frames always
@@ -339,28 +342,80 @@ dummy_frame_register_unwind (struct frame_info *frame, void **cache,
}
}
-/* Assuming that FRAME is a dummy, return the ID of the calling frame
- (the frame that the dummy has the saved state of). */
+/* Assuming that THIS frame is a dummy (remember, the NEXT and not
+ THIS frame is passed in), return the ID of THIS frame. That ID is
+ determined by examining the NEXT frame's unwound registers using
+ the method unwind_dummy_id(). As a side effect, THIS dummy frame's
+ dummy cache is located and and saved in THIS_PROLOGUE_CACHE. */
static void
-dummy_frame_id_unwind (struct frame_info *frame,
- void **cache,
- struct frame_id *id)
+dummy_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
{
- struct dummy_frame *dummy = cached_find_dummy_frame (frame, cache);
- /* Oops! In a dummy-frame but can't find the stack dummy. Pretend
- that the frame doesn't unwind. Should this function instead
- return a has-no-caller indication? */
- if (dummy == NULL)
- (*id) = null_frame_id;
+ struct dummy_frame *dummy = (*this_prologue_cache);
+ if (dummy != NULL)
+ {
+ (*this_id) = dummy->id;
+ return;
+ }
+ /* When unwinding a normal frame, the stack structure is determined
+ by analyzing the frame's function's code (be it using brute force
+ prologue analysis, or the dwarf2 CFI). In the case of a dummy
+ frame, that simply isn't possible. The The PC is either the
+ program entry point, or some random address on the stack. Trying
+ to use that PC to apply standard frame ID unwind techniques is
+ just asking for trouble. */
+ if (gdbarch_unwind_dummy_id_p (current_gdbarch))
+ {
+ /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS,
+ previously saved the dummy frame's ID. Things only work if
+ the two return the same value. */
+ gdb_assert (SAVE_DUMMY_FRAME_TOS_P ());
+ /* Use an architecture specific method to extract the prev's
+ dummy ID from the next frame. Note that this method uses
+ frame_register_unwind to obtain the register values needed to
+ determine the dummy frame's ID. */
+ (*this_id) = gdbarch_unwind_dummy_id (current_gdbarch, next_frame);
+ }
+ else if (frame_relative_level (next_frame) < 0)
+ {
+ /* We're unwinding a sentinel frame, the PC of which is pointing
+ at a stack dummy. Fake up the dummy frame's ID using the
+ same sequence as is found a traditional unwinder. Once all
+ architectures supply the unwind_dummy_id method, this code
+ can go away. */
+ (*this_id).base = read_fp ();
+ (*this_id).pc = read_pc ();
+ }
+ else if (legacy_frame_p (current_gdbarch)
+ && get_prev_frame (next_frame))
+ {
+ /* Things are looking seriously grim! Assume that the legacy
+ get_prev_frame code has already created THIS frame and linked
+ it in to the frame chain (a pretty bold assumption), extract
+ the ID from THIS base / pc. */
+ (*this_id).base = get_frame_base (get_prev_frame (next_frame));
+ (*this_id).pc = get_frame_pc (get_prev_frame (next_frame));
+ }
else
- (*id) = dummy->id;
+ {
+ /* Outch! We're not trying to find the innermost frame's ID yet
+ we're trying to unwind to a dummy. The architecture must
+ provide the unwind_dummy_id() method. Abandon the unwind
+ process but only after first warning the user. */
+ internal_warning (__FILE__, __LINE__,
+ "Missing unwind_dummy_id architecture method");
+ (*this_id) = null_frame_id;
+ return;
+ }
+ (*this_prologue_cache) = find_dummy_frame ((*this_id).pc, (*this_id).base);
}
static struct frame_unwind dummy_frame_unwind =
{
- dummy_frame_id_unwind,
- dummy_frame_register_unwind
+ dummy_frame_this_id,
+ dummy_frame_prev_register
};
const struct frame_unwind *
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 38d01cd51cf..93c4d8a6e83 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -299,6 +299,7 @@ value_of_register (int regnum, struct frame_info *frame)
CORE_ADDR addr;
int optim;
struct value *reg_val;
+ int realnum;
char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
enum lval_type lval;
@@ -307,8 +308,7 @@ value_of_register (int regnum, struct frame_info *frame)
if (regnum >= NUM_REGS + NUM_PSEUDO_REGS)
return value_of_builtin_reg (regnum, frame);
- get_saved_register (raw_buffer, &optim, &addr,
- frame, regnum, &lval);
+ frame_register (frame, regnum, &optim, &lval, &addr, &realnum, raw_buffer);
/* FIXME: cagney/2002-05-15: This test is just bogus.
@@ -780,12 +780,9 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
(value_bytes_copied += REGISTER_RAW_SIZE (local_regnum),
++local_regnum))
{
- get_saved_register (value_bytes + value_bytes_copied,
- &optim,
- &addr,
- frame,
- local_regnum,
- &lval);
+ int realnum;
+ frame_register (frame, local_regnum, &optim, &lval, &addr,
+ &realnum, value_bytes + value_bytes_copied);
if (register_cached (local_regnum) == -1)
return NULL; /* register value not available */
@@ -851,7 +848,10 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
register's contents in a real register or in core;
read the data in raw format. */
- get_saved_register (raw_buffer, &optim, &addr, frame, regnum, &lval);
+ {
+ int realnum;
+ frame_register (frame, regnum, &optim, &lval, &addr, &realnum, raw_buffer);
+ }
if (register_cached (regnum) == -1)
return NULL; /* register value not available */
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index a889f955d84..c72d24a0b23 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -83,16 +83,19 @@ frame_unwind_find_by_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
int i;
struct frame_unwind_table *table =
gdbarch_data (gdbarch, frame_unwind_data);
- /* Seriously old code. Don't even try to use this new mechanism. */
if (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
- return trad_frame_unwind;
+ /* Seriously old code. Don't even try to use this new mechanism.
+ (Note: The variable USE_GENERIC_DUMMY_FRAMES is deprecated, not
+ the dummy frame mechanism. All architectures should be using
+ generic dummy frames). */
+ return legacy_saved_regs_unwind;
for (i = 0; i < table->nr; i++)
{
const struct frame_unwind *desc = table->p[i] (pc);
if (desc != NULL)
return desc;
}
- return trad_frame_unwind;
+ return legacy_saved_regs_unwind;
}
void
diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h
index 5d85efe9c09..099f9dee420 100644
--- a/gdb/frame-unwind.h
+++ b/gdb/frame-unwind.h
@@ -47,42 +47,92 @@ extern const struct frame_unwind *frame_unwind_find_by_pc (struct gdbarch
*gdbarch,
CORE_ADDR pc);
-/* Return the location (and possibly value) of REGNUM for the previous
- (older, up) frame. All parameters except VALUEP can be assumed to
- be non NULL. When VALUEP is NULL, just the location of the
- register should be returned.
-
- UNWIND_CACHE is provided as mechanism for implementing a per-frame
- local cache. It's initial value being NULL. Memory for that cache
- should be allocated using frame_obstack_zalloc().
-
- Register window architectures (eg SPARC) should note that REGNUM
- identifies the register for the previous frame. For instance, a
- request for the value of "o1" for the previous frame would be found
- in the register "i1" in this FRAME. */
-
-typedef void (frame_unwind_reg_ftype) (struct frame_info * frame,
- void **unwind_cache,
- int regnum,
- int *optimized,
- enum lval_type * lvalp,
- CORE_ADDR *addrp,
- int *realnump, void *valuep);
-
-/* Same as for registers above, but return the ID of the frame that
- called this one. */
-
-typedef void (frame_unwind_id_ftype) (struct frame_info * frame,
- void **unwind_cache,
- struct frame_id * id);
+/* The following unwind functions assume a chain of frames forming the
+ sequence: (outer) prev <-> this <-> next (inner). All the
+ functions are called with called with the next frame's `struct
+ frame_info' and and this frame's prologue cache.
+
+ THIS frame's register values can be obtained by unwinding NEXT
+ frame's registers (a recursive operation).
+
+ THIS frame's prologue cache can be used to cache information such
+ as where this frame's prologue stores the previous frame's
+ registers. */
+
+/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
+ use the NEXT frame, and its register unwind method, to determine
+ the frame ID of THIS frame.
+
+ A frame ID provides an invariant that can be used to re-identify an
+ instance of a frame. It is a combination of the frame's `base' and
+ the frame's function's code address.
+
+ Traditionally, THIS frame's ID was determined by examining THIS
+ frame's function's prologue, and identifying the register/offset
+ used as THIS frame's base.
+
+ Example: An examination of THIS frame's prologue reveals that, on
+ entry, it saves the PC(+12), SP(+8), and R1(+4) registers
+ (decrementing the SP by 12). Consequently, the frame ID's base can
+ be determined by adding 12 to the THIS frame's stack-pointer, and
+ the value of THIS frame's SP can be obtained by unwinding the NEXT
+ frame's SP.
+
+ THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
+ with the other unwind methods. Memory for that cache should be
+ allocated using frame_obstack_zalloc(). */
+
+typedef void (frame_this_id_ftype) (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id);
+
+/* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
+ use the NEXT frame, and its register unwind method, to unwind THIS
+ frame's registers (returning the value of the specified register
+ REGNUM in the previous frame).
+
+ Traditionally, THIS frame's registers were unwound by examining
+ THIS frame's function's prologue and identifying which registers
+ that prolog code saved on the stack.
+
+ Example: An examination of THIS frame's prologue reveals that, on
+ entry, it saves the PC(+12), SP(+8), and R1(+4) registers
+ (decrementing the SP by 12). Consequently, the value of the PC
+ register in the previous frame is found in memory at SP+12, and
+ THIS frame's SP can be obtained by unwinding the NEXT frame's SP.
+
+ Why not pass in THIS_FRAME? By passing in NEXT frame and THIS
+ cache, the supplied parameters are consistent with the sibling
+ function THIS_ID.
+
+ Can the code call ``frame_register (get_prev_frame (NEXT_FRAME))''?
+ Won't the call frame_register (THIS_FRAME) be faster? Well,
+ ignoring the possability that the previous frame does not yet
+ exist, the ``frame_register (FRAME)'' function is expanded to
+ ``frame_register_unwind (get_next_frame (FRAME)'' and hence that
+ call will expand to ``frame_register_unwind (get_next_frame
+ (get_prev_frame (NEXT_FRAME)))''. Might as well call
+ ``frame_register_unwind (NEXT_FRAME)'' directly.
+
+ THIS_PROLOGUE_CACHE can be used to share any prolog analysis data
+ with the other unwind methods. Memory for that cache should be
+ allocated using frame_obstack_zalloc(). */
+
+typedef void (frame_prev_register_ftype) (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int prev_regnum,
+ int *optimized,
+ enum lval_type * lvalp,
+ CORE_ADDR *addrp,
+ int *realnump, void *valuep);
struct frame_unwind
{
/* Should the frame's type go here? */
/* Should an attribute indicating the frame's address-in-block go
here? */
- frame_unwind_id_ftype *id;
- frame_unwind_reg_ftype *reg;
+ frame_this_id_ftype *this_id;
+ frame_prev_register_ftype *prev_register;
};
#endif
diff --git a/gdb/frame.c b/gdb/frame.c
index 267d484b606..900b51518c5 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -198,12 +198,12 @@ frame_pop (struct frame_info *this_frame)
struct regcache *scratch_regcache;
struct cleanup *cleanups;
- if (POP_FRAME_P ())
+ if (DEPRECATED_POP_FRAME_P ())
{
/* A legacy architecture that has implemented a custom pop
function. All new architectures should instead be using the
generic code below. */
- POP_FRAME;
+ DEPRECATED_POP_FRAME;
}
else
{
@@ -215,6 +215,14 @@ frame_pop (struct frame_info *this_frame)
struct regcache *scratch = regcache_xmalloc (current_gdbarch);
struct cleanup *cleanups = make_cleanup_regcache_xfree (scratch);
regcache_save (scratch, do_frame_unwind_register, this_frame);
+ /* FIXME: cagney/2003-03-16: It should be possible to tell the
+ target's register cache that it is about to be hit with a
+ burst register transfer and that the sequence of register
+ writes should be batched. The pair target_prepare_to_store()
+ and target_store_registers() kind of suggest this
+ functionality. Unfortunatly, they don't implement it. Their
+ lack of a formal definition can lead to targets writing back
+ bogus values (arguably a bug in the target code mind). */
/* Now copy those saved registers into the current regcache.
Here, regcache_cpy() calls regcache_restore(). */
regcache_cpy (current_regcache, scratch);
@@ -222,7 +230,6 @@ frame_pop (struct frame_info *this_frame)
}
/* We've made right mess of GDB's local state, just discard
everything. */
- target_store_registers (-1);
flush_cached_frames ();
}
@@ -247,9 +254,12 @@ frame_register_unwind (struct frame_info *frame, int regnum,
detected the problem before calling here. */
gdb_assert (frame != NULL);
- /* Ask this frame to unwind its register. */
- frame->unwind->reg (frame, &frame->unwind_cache, regnum,
- optimizedp, lvalp, addrp, realnump, bufferp);
+ /* Ask this frame to unwind its register. See comment in
+ "frame-unwind.h" for why NEXT frame and this unwind cace are
+ passed in. */
+ frame->unwind->prev_register (frame->next, &frame->prologue_cache, regnum,
+ optimizedp, lvalp, addrp, realnump, bufferp);
+
}
void
@@ -268,9 +278,10 @@ frame_register (struct frame_info *frame, int regnum,
/* Ulgh! Old code that, for lval_register, sets ADDRP to the offset
of the register in the register cache. It should instead return
the REGNUM corresponding to that register. Translate the . */
- if (GET_SAVED_REGISTER_P ())
+ if (DEPRECATED_GET_SAVED_REGISTER_P ())
{
- GET_SAVED_REGISTER (bufferp, optimizedp, addrp, frame, regnum, lvalp);
+ DEPRECATED_GET_SAVED_REGISTER (bufferp, optimizedp, addrp, frame,
+ regnum, lvalp);
/* Compute the REALNUM if the caller wants it. */
if (*lvalp == lval_register)
{
@@ -398,23 +409,6 @@ generic_unwind_get_saved_register (char *raw_buffer,
&realnumx, raw_buffer);
}
-void
-get_saved_register (char *raw_buffer,
- int *optimized,
- CORE_ADDR *addrp,
- struct frame_info *frame,
- int regnum,
- enum lval_type *lval)
-{
- if (GET_SAVED_REGISTER_P ())
- {
- GET_SAVED_REGISTER (raw_buffer, optimized, addrp, frame, regnum, lval);
- return;
- }
- generic_unwind_get_saved_register (raw_buffer, optimized, addrp, frame,
- regnum, lval);
-}
-
/* frame_register_read ()
Find and return the value of REGNUM for the specified stack frame.
@@ -499,7 +493,7 @@ create_sentinel_frame (struct regcache *regcache)
/* Explicitly initialize the sentinel frame's cache. Provide it
with the underlying regcache. In the future additional
information, such as the frame's thread will be added. */
- frame->unwind_cache = sentinel_frame_cache (regcache);
+ frame->prologue_cache = sentinel_frame_cache (regcache);
/* For the moment there is only one sentinel frame implementation. */
frame->unwind = sentinel_frame_unwind;
/* Link this frame back to itself. The frame is self referential
@@ -656,19 +650,20 @@ select_frame (struct frame_info *fi)
most frame. */
static void
-frame_saved_regs_register_unwind (struct frame_info *frame, void **cache,
- int regnum, int *optimizedp,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnump, void *bufferp)
+legacy_saved_regs_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *bufferp)
{
- /* There is always a frame at this point. And THIS is the frame
- we're interested in. */
+ /* HACK: New code is passed the next frame and this cache.
+ Unfortunatly, old code expects this frame. Since this is a
+ backward compatibility hack, cheat by walking one level along the
+ prologue chain to the frame the old code expects.
+
+ Do not try this at home. Professional driver, closed course. */
+ struct frame_info *frame = next_frame->prev;
gdb_assert (frame != NULL);
- /* If we're using generic dummy frames, we'd better not be in a call
- dummy. (generic_call_dummy_register_unwind ought to have been called
- instead.) */
- gdb_assert (!(DEPRECATED_USE_GENERIC_DUMMY_FRAMES
- && (get_frame_type (frame) == DUMMY_FRAME)));
/* Only (older) architectures that implement the
DEPRECATED_FRAME_INIT_SAVED_REGS method should be using this
@@ -706,13 +701,13 @@ frame_saved_regs_register_unwind (struct frame_info *frame, void **cache,
#if 1
/* Save each register value, as it is read in, in a
frame based cache. */
- void **regs = (*cache);
+ void **regs = (*this_prologue_cache);
if (regs == NULL)
{
int sizeof_cache = ((NUM_REGS + NUM_PSEUDO_REGS)
* sizeof (void *));
regs = frame_obstack_zalloc (sizeof_cache);
- (*cache) = regs;
+ (*this_prologue_cache) = regs;
}
if (regs[regnum] == NULL)
{
@@ -732,22 +727,33 @@ frame_saved_regs_register_unwind (struct frame_info *frame, void **cache,
return;
}
- /* No luck, assume this and the next frame have the same register
- value. Pass the request down the frame chain to the next frame.
- Hopefully that will find the register's location, either in a
- register or in memory. */
- frame_register (frame, regnum, optimizedp, lvalp, addrp, realnump,
- bufferp);
+ /* No luck. Assume this and the next frame have the same register
+ value. Pass the unwind request down the frame chain to the next
+ frame. Hopefully that frame will find the register's location. */
+ frame_register_unwind (next_frame, regnum, optimizedp, lvalp, addrp,
+ realnump, bufferp);
}
static void
-frame_saved_regs_id_unwind (struct frame_info *next_frame, void **cache,
- struct frame_id *id)
+legacy_saved_regs_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *id)
{
int fromleaf;
CORE_ADDR base;
CORE_ADDR pc;
+ if (frame_relative_level (next_frame) < 0)
+ {
+ /* FIXME: cagney/2003-03-14: We've got the extra special case of
+ unwinding a sentinel frame, the PC of which is pointing at a
+ stack dummy. Fake up the dummy frame's ID using the same
+ sequence as is found a traditional unwinder. */
+ (*id).base = read_fp ();
+ (*id).pc = read_pc ();
+ return;
+ }
+
/* Start out by assuming it's NULL. */
(*id) = null_frame_id;
@@ -801,16 +807,16 @@ frame_saved_regs_id_unwind (struct frame_info *next_frame, void **cache,
id->base = base;
}
-const struct frame_unwind trad_frame_unwinder = {
- frame_saved_regs_id_unwind,
- frame_saved_regs_register_unwind
+const struct frame_unwind legacy_saved_regs_unwinder = {
+ legacy_saved_regs_this_id,
+ legacy_saved_regs_prev_register
};
-const struct frame_unwind *trad_frame_unwind = &trad_frame_unwinder;
+const struct frame_unwind *legacy_saved_regs_unwind = &legacy_saved_regs_unwinder;
-/* Function: get_saved_register
+/* Function: deprecated_generic_get_saved_register
Find register number REGNUM relative to FRAME and put its (raw,
- target format) contents in *RAW_BUFFER.
+ target format) contents in *RAW_BUFFER.
Set *OPTIMIZED if the variable was optimized out (and thus can't be
fetched). Note that this is never set to anything other than zero
@@ -826,10 +832,6 @@ const struct frame_unwind *trad_frame_unwind = &trad_frame_unwinder;
offset into the registers array. If the value is stored in a dummy
frame, set *ADDRP to zero.
- To use this implementation, define a function called
- "get_saved_register" in your target code, which simply passes all
- of its arguments to this function.
-
The argument RAW_BUFFER must point to aligned memory. */
void
@@ -1011,6 +1013,142 @@ legacy_get_prev_frame (struct frame_info *this_frame)
struct frame_info *prev;
int fromleaf;
+ /* Allocate the new frame but do not wire it in to the frame chain.
+ Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
+ frame->next to pull some fancy tricks (of course such code is, by
+ definition, recursive). Try to prevent it.
+
+ There is no reason to worry about memory leaks, should the
+ remainder of the function fail. The allocated memory will be
+ quickly reclaimed when the frame cache is flushed, and the `we've
+ been here before' check, in get_prev_frame will stop repeated
+ memory allocation calls. */
+ prev = FRAME_OBSTACK_ZALLOC (struct frame_info);
+ prev->level = this_frame->level + 1;
+
+ /* NOTE: cagney/2002-11-18: Should have been correctly setting the
+ frame's type here, before anything else, and not last, at the
+ bottom of this function. The various
+ DEPRECATED_INIT_EXTRA_FRAME_INFO, DEPRECATED_INIT_FRAME_PC,
+ DEPRECATED_INIT_FRAME_PC_FIRST and
+ DEPRECATED_FRAME_INIT_SAVED_REGS methods are full of work-arounds
+ that handle the frame not being correctly set from the start.
+ Unfortunatly those same work-arounds rely on the type defaulting
+ to NORMAL_FRAME. Ulgh! The new frame code does not have this
+ problem. */
+ prev->type = NORMAL_FRAME;
+
+ /* Handle sentinel frame unwind as a special case. */
+ if (this_frame->level < 0)
+ {
+ /* Try to unwind the PC. If that doesn't work, assume we've reached
+ the oldest frame and simply return. Is there a better sentinal
+ value? The unwound PC value is then used to initialize the new
+ previous frame's type.
+
+ Note that the pc-unwind is intentionally performed before the
+ frame chain. This is ok since, for old targets, both
+ frame_pc_unwind (nee, FRAME_SAVED_PC) and FRAME_CHAIN()) assume
+ THIS_FRAME's data structures have already been initialized (using
+ DEPRECATED_INIT_EXTRA_FRAME_INFO) and hence the call order
+ doesn't matter.
+
+ By unwinding the PC first, it becomes possible to, in the case of
+ a dummy frame, avoid also unwinding the frame ID. This is
+ because (well ignoring the PPC) a dummy frame can be located
+ using THIS_FRAME's frame ID. */
+
+ prev->pc = frame_pc_unwind (this_frame);
+ if (prev->pc == 0)
+ {
+ /* The allocated PREV_FRAME will be reclaimed when the frame
+ obstack is next purged. */
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - unwound PC zero\n");
+ return NULL;
+ }
+ prev->type = frame_type_from_pc (prev->pc);
+
+ /* Set the unwind functions based on that identified PC. */
+ prev->unwind = frame_unwind_find_by_pc (current_gdbarch, prev->pc);
+
+ /* Find the prev's frame's ID. */
+ if (prev->type == DUMMY_FRAME
+ && gdbarch_unwind_dummy_id_p (current_gdbarch))
+ {
+ /* When unwinding a normal frame, the stack structure is
+ determined by analyzing the frame's function's code (be
+ it using brute force prologue analysis, or the dwarf2
+ CFI). In the case of a dummy frame, that simply isn't
+ possible. The The PC is either the program entry point,
+ or some random address on the stack. Trying to use that
+ PC to apply standard frame ID unwind techniques is just
+ asking for trouble. */
+ /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS,
+ previously saved the dummy frame's ID. Things only work
+ if the two return the same value. */
+ gdb_assert (SAVE_DUMMY_FRAME_TOS_P ());
+ /* Use an architecture specific method to extract the prev's
+ dummy ID from the next frame. Note that this method uses
+ frame_register_unwind to obtain the register values
+ needed to determine the dummy frame's ID. */
+ prev->id = gdbarch_unwind_dummy_id (current_gdbarch, this_frame);
+ }
+ else
+ {
+ /* We're unwinding a sentinel frame, the PC of which is
+ pointing at a stack dummy. Fake up the dummy frame's ID
+ using the same sequence as is found a traditional
+ unwinder. Once all architectures supply the
+ unwind_dummy_id method, this code can go away. */
+ prev->id.base = read_fp ();
+ prev->id.pc = read_pc ();
+ }
+
+ /* Check that the unwound ID is valid. */
+ if (!frame_id_p (prev->id))
+ {
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost legacy sentinel frame - unwound frame ID invalid\n");
+ return NULL;
+ }
+
+ /* Check that the new frame isn't inner to (younger, below,
+ next) the old frame. If that happens the frame unwind is
+ going backwards. */
+ /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since
+ that doesn't have a valid frame ID. Should instead set the
+ sentinel frame's frame ID to a `sentinel'. Leave it until
+ after the switch to storing the frame ID, instead of the
+ frame base, in the frame object. */
+
+ /* FIXME: cagney/2002-12-18: Instead of this hack, should only
+ store the frame ID in PREV_FRAME. Unfortunatly, some
+ architectures (HP/UX) still reply on EXTRA_FRAME_INFO and,
+ hence, still poke at the "struct frame_info" object directly. */
+ prev->frame = prev->id.base;
+
+ /* Link it in. */
+ this_frame->prev = prev;
+ prev->next = this_frame;
+
+ /* FIXME: cagney/2002-01-19: This call will go away. Instead of
+ initializing extra info, all frames will use the frame_cache
+ (passed to the unwind functions) to store additional frame
+ info. Unfortunatly legacy targets can't use
+ legacy_get_prev_frame() to unwind the sentinel frame and,
+ consequently, are forced to take this code path and rely on
+ the below call to DEPRECATED_INIT_EXTRA_FRAME_INFO to
+ initialize the inner-most frame. */
+ if (DEPRECATED_INIT_EXTRA_FRAME_INFO_P ())
+ {
+ DEPRECATED_INIT_EXTRA_FRAME_INFO (0, prev);
+ }
+ return prev;
+ }
+
/* This code only works on normal frames. A sentinel frame, where
the level is -1, should never reach this code. */
gdb_assert (this_frame->level >= 0);
@@ -1067,19 +1205,10 @@ legacy_get_prev_frame (struct frame_info *this_frame)
if (address == 0)
return 0;
- /* Create an initially zero previous frame. */
- prev = frame_obstack_zalloc (sizeof (struct frame_info));
-
- /* Link it in. */
+ /* Link in the already allocated prev frame. */
this_frame->prev = prev;
prev->next = this_frame;
prev->frame = address;
- prev->level = this_frame->level + 1;
- /* FIXME: cagney/2002-11-18: Should be setting the frame's type
- here, before anything else, and not last. Various INIT functions
- are full of work-arounds for the frames type not being set
- correctly from the word go. Ulgh! */
- prev->type = NORMAL_FRAME;
/* This change should not be needed, FIXME! We should determine
whether any targets *need* DEPRECATED_INIT_FRAME_PC to happen
@@ -1324,14 +1453,8 @@ get_prev_frame (struct frame_info *this_frame)
}
/* If any of the old frame initialization methods are around, use
- the legacy get_prev_frame method. Just don't try to unwind a
- sentinel frame using that method - it doesn't work. All sentinal
- frames use the new unwind code. */
- if ((DEPRECATED_INIT_FRAME_PC_P ()
- || DEPRECATED_INIT_FRAME_PC_FIRST_P ()
- || DEPRECATED_INIT_EXTRA_FRAME_INFO_P ()
- || FRAME_CHAIN_P ())
- && this_frame->level >= 0)
+ the legacy get_prev_frame method. */
+ if (legacy_frame_p (current_gdbarch))
{
prev_frame = legacy_get_prev_frame (this_frame);
if (frame_debug && prev_frame == NULL)
@@ -1387,86 +1510,57 @@ get_prev_frame (struct frame_info *this_frame)
prev_frame->pc);
/* Find the prev's frame's ID. */
- switch (prev_frame->type)
+
+ /* The callee expects to be invoked with:
+
+ this->unwind->this_id (this->next, &this->cache, &this->id);
+
+ The below is carefully shifted one frame `to the left' so that
+ both the unwind->this_id and unwind->prev_register methods are
+ consistently invoked with NEXT_FRAME and THIS_PROLOGUE_CACHE.
+
+ Also note that, while the PC for this new previous frame was
+ unwound first (see above), the below is the first call that
+ [potentially] requires analysis of the new previous frame's
+ prologue. Consequently, it is this call, that typically ends up
+ initializing the previous frame's prologue cache. */
+ prev_frame->unwind->this_id (this_frame,
+ &prev_frame->prologue_cache,
+ &prev_frame->id);
+
+ /* Check that the unwound ID is valid. */
+ if (!frame_id_p (prev_frame->id))
{
- case DUMMY_FRAME:
- /* When unwinding a normal frame, the stack structure is
- determined by analyzing the frame's function's code (be it
- using brute force prologue analysis, or the dwarf2 CFI). In
- the case of a dummy frame, that simply isn't possible. The
- The PC is either the program entry point, or some random
- address on the stack. Trying to use that PC to apply
- standard frame ID unwind techniques is just asking for
- trouble. */
- if (gdbarch_unwind_dummy_id_p (current_gdbarch))
- {
- /* Assume hand_function_call(), via SAVE_DUMMY_FRAME_TOS,
- previously saved the dummy frame's ID. Things only work
- if the two return the same value. */
- gdb_assert (SAVE_DUMMY_FRAME_TOS_P ());
- /* Use an architecture specific method to extract the prev's
- dummy ID from the next frame. Note that this method uses
- frame_register_unwind to obtain the register values
- needed to determine the dummy frame's ID. */
- prev_frame->id = gdbarch_unwind_dummy_id (current_gdbarch,
- this_frame);
- }
- else if (this_frame->level < 0)
- {
- /* We're unwinding a sentinel frame, the PC of which is
- pointing at a stack dummy. Fake up the dummy frame's ID
- using the same sequence as is found a traditional
- unwinder. Once all architectures supply the
- unwind_dummy_id method, this code can go away. */
- prev_frame->id.base = read_fp ();
- prev_frame->id.pc = read_pc ();
- }
- else
- {
- /* Outch! We're not on the innermost frame yet we're trying
- to unwind to a dummy. The architecture must provide the
- unwind_dummy_id() method. Abandon the unwind process but
- only after first warning the user. */
- internal_warning (__FILE__, __LINE__,
- "Missing unwind_dummy_id architecture method");
- return NULL;
- }
- break;
- case NORMAL_FRAME:
- case SIGTRAMP_FRAME:
- /* FIXME: cagney/2003-03-04: The below call isn't right. It
- should instead be doing something like "prev_frame -> unwind
- -> id (this_frame, & prev_frame -> unwind_cache, & prev_frame
- -> id)" but that requires more extensive (pending) changes. */
- this_frame->unwind->id (this_frame, &this_frame->unwind_cache,
- &prev_frame->id);
- /* Check that the unwound ID is valid. */
- if (!frame_id_p (prev_frame->id))
- {
- if (frame_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Outermost frame - unwound frame ID invalid\n");
- return NULL;
- }
- /* Check that the new frame isn't inner to (younger, below,
- next) the old frame. If that happens the frame unwind is
- going backwards. */
- /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since
- that doesn't have a valid frame ID. Should instead set the
- sentinel frame's frame ID to a `sentinel'. Leave it until
- after the switch to storing the frame ID, instead of the
- frame base, in the frame object. */
- if (this_frame->level >= 0
- && frame_id_inner (prev_frame->id, get_frame_id (this_frame)))
- error ("Unwound frame inner-to selected frame (corrupt stack?)");
- /* Note that, due to frameless functions, the stronger test of
- the new frame being outer to the old frame can't be used -
- frameless functions differ by only their PC value. */
- break;
- default:
- internal_error (__FILE__, __LINE__, "bad switch");
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - unwound frame ID invalid\n");
+ return NULL;
}
+ /* Check that the new frame isn't inner to (younger, below, next)
+ the old frame. If that happens the frame unwind is going
+ backwards. */
+ /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since that
+ doesn't have a valid frame ID. Should instead set the sentinel
+ frame's frame ID to a true `sentinel'. Leave it until after the
+ switch to storing the frame ID, instead of the frame base, in the
+ frame object. */
+ if (this_frame->level >= 0
+ && frame_id_inner (prev_frame->id, get_frame_id (this_frame)))
+ error ("Unwound frame inner-to selected frame (corrupt stack?)");
+
+ /* FIXME: cagney/2003-03-14: Should check that this and next frame's
+ IDs are different (i.e., !frame_id_eq()). Can't yet do that as
+ the EQ function doesn't yet compare PC values. */
+
+ /* FIXME: cagney/2003-03-14: Should delay the evaluation of the
+ frame ID until when it is needed. That way the inner most frame
+ can be created without needing to do prologue analysis. */
+
+ /* Note that, due to frameless functions, the stronger test of the
+ new frame being outer to the old frame can't be used - frameless
+ functions differ by only their PC value. */
+
/* FIXME: cagney/2002-12-18: Instead of this hack, should only store
the frame ID in PREV_FRAME. Unfortunatly, some architectures
(HP/UX) still reply on EXTRA_FRAME_INFO and, hence, still poke at
@@ -1477,20 +1571,6 @@ get_prev_frame (struct frame_info *this_frame)
this_frame->prev = prev_frame;
prev_frame->next = this_frame;
- /* FIXME: cagney/2002-01-19: This call will go away. Instead of
- initializing extra info, all frames will use the frame_cache
- (passed to the unwind functions) to store additional frame info.
- Unfortunatly legacy targets can't use legacy_get_prev_frame() to
- unwind the sentinel frame and, consequently, are forced to take
- this code path and rely on the below call to
- DEPRECATED_INIT_EXTRA_FRAME_INFO to initialize the inner-most
- frame. */
- if (DEPRECATED_INIT_EXTRA_FRAME_INFO_P ())
- {
- gdb_assert (prev_frame->level == 0);
- DEPRECATED_INIT_EXTRA_FRAME_INFO (0, prev_frame);
- }
-
return prev_frame;
}
@@ -1696,6 +1776,17 @@ deprecated_frame_xmalloc_with_cleanup (long sizeof_saved_regs,
return frame;
}
+int
+legacy_frame_p (struct gdbarch *current_gdbarch)
+{
+ return (DEPRECATED_INIT_FRAME_PC_P ()
+ || DEPRECATED_INIT_FRAME_PC_FIRST_P ()
+ || DEPRECATED_INIT_EXTRA_FRAME_INFO_P ()
+ || FRAME_CHAIN_P ()
+ || !gdbarch_unwind_dummy_id_p (current_gdbarch)
+ || !SAVE_DUMMY_FRAME_TOS_P ());
+}
+
void
_initialize_frame (void)
{
diff --git a/gdb/frame.h b/gdb/frame.h
index 18c4df4397f..ee0fc7e49b1 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -27,8 +27,9 @@ struct symtab_and_line;
struct frame_unwind;
struct block;
-/* The traditional frame unwinder. */
-extern const struct frame_unwind *trad_frame_unwind;
+/* A legacy unwinder to prop up architectures using the old style
+ saved regs array. */
+extern const struct frame_unwind *legacy_saved_regs_unwind;
/* The frame object. */
@@ -397,9 +398,9 @@ struct frame_info
related unwind data. */
struct context *context;
- /* Unwind cache shared between the unwind functions - they had
- better all agree as to the contents. */
- void *unwind_cache;
+ /* Prologue cache shared between the unwind functions. See
+ "frame-unwind.h" for more information. */
+ void *prologue_cache;
/* The frame's unwinder. */
const struct frame_unwind *unwind;
@@ -538,7 +539,7 @@ extern int generic_pc_in_call_dummy (CORE_ADDR pc,
/* NOTE: cagney/2002-06-26: Targets should no longer use this
function. Instead, the contents of a dummy frames registers can be
obtained by applying: frame_register_unwind to the dummy frame; or
- get_saved_register to the next outer frame. */
+ frame_register_unwind() to the next outer frame. */
extern char *deprecated_generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp);
@@ -554,21 +555,17 @@ void generic_unwind_get_saved_register (char *raw_buffer,
enum lval_type *lvalp);
/* The function generic_get_saved_register() has been made obsolete.
- GET_SAVED_REGISTER now defaults to the recursive equivalent -
- generic_unwind_get_saved_register() - so there is no need to even
- set GET_SAVED_REGISTER. Architectures that need to override the
- register unwind mechanism should modify frame->unwind(). */
+ DEPRECATED_GET_SAVED_REGISTER now defaults to the recursive
+ equivalent - generic_unwind_get_saved_register() - so there is no
+ need to even set DEPRECATED_GET_SAVED_REGISTER. Architectures that
+ need to override the register unwind mechanism should modify
+ frame->unwind(). */
extern void deprecated_generic_get_saved_register (char *, int *, CORE_ADDR *,
struct frame_info *, int,
enum lval_type *);
extern void generic_save_call_dummy_addr (CORE_ADDR lo, CORE_ADDR hi);
-extern void get_saved_register (char *raw_buffer, int *optimized,
- CORE_ADDR * addrp,
- struct frame_info *frame,
- int regnum, enum lval_type *lval);
-
/* FIXME: cagney/2003-02-02: Should be deprecated or replaced with a
function called frame_read_register_p(). This slightly weird (and
older) variant of frame_read_register() returns zero (indicating
@@ -701,4 +698,8 @@ extern struct context *deprecated_get_frame_context (struct frame_info *fi);
extern void deprecated_set_frame_context (struct frame_info *fi,
struct context *context);
+/* Return non-zero if the architecture is relying on legacy frame
+ code. */
+extern int legacy_frame_p (struct gdbarch *gdbarch);
+
#endif /* !defined (FRAME_H) */
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index b5bc3352342..2753283d695 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -45,7 +45,6 @@ static gdbarch_init_extra_frame_info_ftype stupid_useless_init_extra_frame_info;
static gdbarch_store_struct_return_ftype frv_store_struct_return;
static gdbarch_push_arguments_ftype frv_push_arguments;
static gdbarch_push_return_address_ftype frv_push_return_address;
-static gdbarch_pop_frame_ftype frv_pop_frame;
static gdbarch_saved_pc_after_call_ftype frv_saved_pc_after_call;
static void frv_pop_frame_regular (struct frame_info *frame);
@@ -1095,7 +1094,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_length (gdbarch, 0);
set_gdbarch_push_arguments (gdbarch, frv_push_arguments);
set_gdbarch_push_return_address (gdbarch, frv_push_return_address);
- set_gdbarch_pop_frame (gdbarch, frv_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, frv_pop_frame);
set_gdbarch_call_dummy_p (gdbarch, 1);
set_gdbarch_call_dummy_words (gdbarch, frv_call_dummy_words);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 6f7587825b6..94e89f3a33b 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -202,7 +202,7 @@ struct gdbarch
gdbarch_deprecated_init_frame_pc_ftype *deprecated_init_frame_pc;
int believe_pcc_promotion;
int believe_pcc_promotion_type;
- gdbarch_get_saved_register_ftype *get_saved_register;
+ gdbarch_deprecated_get_saved_register_ftype *deprecated_get_saved_register;
gdbarch_register_convertible_ftype *register_convertible;
gdbarch_register_convert_to_virtual_ftype *register_convert_to_virtual;
gdbarch_register_convert_to_raw_ftype *register_convert_to_raw;
@@ -216,7 +216,7 @@ struct gdbarch
gdbarch_push_arguments_ftype *push_arguments;
gdbarch_deprecated_push_dummy_frame_ftype *deprecated_push_dummy_frame;
gdbarch_push_return_address_ftype *push_return_address;
- gdbarch_pop_frame_ftype *pop_frame;
+ gdbarch_deprecated_pop_frame_ftype *deprecated_pop_frame;
gdbarch_store_struct_return_ftype *store_struct_return;
gdbarch_extract_return_value_ftype *extract_return_value;
gdbarch_store_return_value_ftype *store_return_value;
@@ -711,7 +711,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
fprintf_unfiltered (log, "\n\tfix_call_dummy");
/* Skip verify of deprecated_init_frame_pc_first, has predicate */
/* Skip verify of deprecated_init_frame_pc, has predicate */
- /* Skip verify of get_saved_register, has predicate */
+ /* Skip verify of deprecated_get_saved_register, has predicate */
/* Skip verify of register_convertible, invalid_p == 0 */
/* Skip verify of register_convert_to_virtual, invalid_p == 0 */
/* Skip verify of register_convert_to_raw, invalid_p == 0 */
@@ -725,7 +725,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of push_arguments, invalid_p == 0 */
/* Skip verify of deprecated_push_dummy_frame, has predicate */
/* Skip verify of push_return_address, has predicate */
- /* Skip verify of pop_frame, has predicate */
+ /* Skip verify of deprecated_pop_frame, has predicate */
if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
&& (gdbarch->store_struct_return == 0))
fprintf_unfiltered (log, "\n\tstore_struct_return");
@@ -1213,6 +1213,29 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
(long) current_gdbarch->deprecated_frame_saved_pc
/*DEPRECATED_FRAME_SAVED_PC ()*/);
#endif
+#ifdef DEPRECATED_GET_SAVED_REGISTER_P
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "DEPRECATED_GET_SAVED_REGISTER_P()",
+ XSTRING (DEPRECATED_GET_SAVED_REGISTER_P ()));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_GET_SAVED_REGISTER_P() = %d\n",
+ DEPRECATED_GET_SAVED_REGISTER_P ());
+#endif
+#ifdef DEPRECATED_GET_SAVED_REGISTER
+#if GDB_MULTI_ARCH
+ /* Macro might contain `[{}]' when not multi-arch */
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "DEPRECATED_GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval)",
+ XSTRING (DEPRECATED_GET_SAVED_REGISTER (raw_buffer, optimized, addrp, frame, regnum, lval)));
+#endif
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_GET_SAVED_REGISTER = <0x%08lx>\n",
+ (long) current_gdbarch->deprecated_get_saved_register
+ /*DEPRECATED_GET_SAVED_REGISTER ()*/);
+#endif
#ifdef DEPRECATED_INIT_EXTRA_FRAME_INFO_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -1330,6 +1353,29 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
(long) current_gdbarch->deprecated_pc_in_call_dummy
/*DEPRECATED_PC_IN_CALL_DUMMY ()*/);
#endif
+#ifdef DEPRECATED_POP_FRAME_P
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "DEPRECATED_POP_FRAME_P()",
+ XSTRING (DEPRECATED_POP_FRAME_P ()));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_POP_FRAME_P() = %d\n",
+ DEPRECATED_POP_FRAME_P ());
+#endif
+#ifdef DEPRECATED_POP_FRAME
+#if GDB_MULTI_ARCH
+ /* Macro might contain `[{}]' when not multi-arch */
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "DEPRECATED_POP_FRAME(-)",
+ XSTRING (DEPRECATED_POP_FRAME (-)));
+#endif
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DEPRECATED_POP_FRAME = <0x%08lx>\n",
+ (long) current_gdbarch->deprecated_pop_frame
+ /*DEPRECATED_POP_FRAME ()*/);
+#endif
#ifdef DEPRECATED_PUSH_DUMMY_FRAME_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -1637,29 +1683,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
(long) current_gdbarch->get_longjmp_target
/*GET_LONGJMP_TARGET ()*/);
#endif
-#ifdef GET_SAVED_REGISTER_P
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "GET_SAVED_REGISTER_P()",
- XSTRING (GET_SAVED_REGISTER_P ()));
- fprintf_unfiltered (file,
- "gdbarch_dump: GET_SAVED_REGISTER_P() = %d\n",
- GET_SAVED_REGISTER_P ());
-#endif
-#ifdef GET_SAVED_REGISTER
-#if GDB_MULTI_ARCH
- /* Macro might contain `[{}]' when not multi-arch */
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval)",
- XSTRING (GET_SAVED_REGISTER (raw_buffer, optimized, addrp, frame, regnum, lval)));
-#endif
- if (GDB_MULTI_ARCH)
- fprintf_unfiltered (file,
- "gdbarch_dump: GET_SAVED_REGISTER = <0x%08lx>\n",
- (long) current_gdbarch->get_saved_register
- /*GET_SAVED_REGISTER ()*/);
-#endif
#ifdef HAVE_NONSTEPPABLE_WATCHPOINT
fprintf_unfiltered (file,
"gdbarch_dump: HAVE_NONSTEPPABLE_WATCHPOINT # %s\n",
@@ -1813,29 +1836,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
(long) current_gdbarch->pointer_to_address
/*POINTER_TO_ADDRESS ()*/);
#endif
-#ifdef POP_FRAME_P
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "POP_FRAME_P()",
- XSTRING (POP_FRAME_P ()));
- fprintf_unfiltered (file,
- "gdbarch_dump: POP_FRAME_P() = %d\n",
- POP_FRAME_P ());
-#endif
-#ifdef POP_FRAME
-#if GDB_MULTI_ARCH
- /* Macro might contain `[{}]' when not multi-arch */
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "POP_FRAME(-)",
- XSTRING (POP_FRAME (-)));
-#endif
- if (GDB_MULTI_ARCH)
- fprintf_unfiltered (file,
- "gdbarch_dump: POP_FRAME = <0x%08lx>\n",
- (long) current_gdbarch->pop_frame
- /*POP_FRAME ()*/);
-#endif
#ifdef PREPARE_TO_PROCEED
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -4013,29 +4013,29 @@ set_gdbarch_believe_pcc_promotion_type (struct gdbarch *gdbarch,
}
int
-gdbarch_get_saved_register_p (struct gdbarch *gdbarch)
+gdbarch_deprecated_get_saved_register_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- return gdbarch->get_saved_register != 0;
+ return gdbarch->deprecated_get_saved_register != 0;
}
void
-gdbarch_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval)
+gdbarch_deprecated_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval)
{
gdb_assert (gdbarch != NULL);
- if (gdbarch->get_saved_register == 0)
+ if (gdbarch->deprecated_get_saved_register == 0)
internal_error (__FILE__, __LINE__,
- "gdbarch: gdbarch_get_saved_register invalid");
+ "gdbarch: gdbarch_deprecated_get_saved_register invalid");
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_get_saved_register called\n");
- gdbarch->get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval);
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_get_saved_register called\n");
+ gdbarch->deprecated_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval);
}
void
-set_gdbarch_get_saved_register (struct gdbarch *gdbarch,
- gdbarch_get_saved_register_ftype get_saved_register)
+set_gdbarch_deprecated_get_saved_register (struct gdbarch *gdbarch,
+ gdbarch_deprecated_get_saved_register_ftype deprecated_get_saved_register)
{
- gdbarch->get_saved_register = get_saved_register;
+ gdbarch->deprecated_get_saved_register = deprecated_get_saved_register;
}
int
@@ -4307,29 +4307,29 @@ set_gdbarch_push_return_address (struct gdbarch *gdbarch,
}
int
-gdbarch_pop_frame_p (struct gdbarch *gdbarch)
+gdbarch_deprecated_pop_frame_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- return gdbarch->pop_frame != 0;
+ return gdbarch->deprecated_pop_frame != 0;
}
void
-gdbarch_pop_frame (struct gdbarch *gdbarch)
+gdbarch_deprecated_pop_frame (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- if (gdbarch->pop_frame == 0)
+ if (gdbarch->deprecated_pop_frame == 0)
internal_error (__FILE__, __LINE__,
- "gdbarch: gdbarch_pop_frame invalid");
+ "gdbarch: gdbarch_deprecated_pop_frame invalid");
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_pop_frame called\n");
- gdbarch->pop_frame ();
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_pop_frame called\n");
+ gdbarch->deprecated_pop_frame ();
}
void
-set_gdbarch_pop_frame (struct gdbarch *gdbarch,
- gdbarch_pop_frame_ftype pop_frame)
+set_gdbarch_deprecated_pop_frame (struct gdbarch *gdbarch,
+ gdbarch_deprecated_pop_frame_ftype deprecated_pop_frame)
{
- gdbarch->pop_frame = pop_frame;
+ gdbarch->deprecated_pop_frame = deprecated_pop_frame;
}
void
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index acb1c336fa1..eb36ebc1499 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1388,40 +1388,40 @@ extern void set_gdbarch_believe_pcc_promotion_type (struct gdbarch *gdbarch, int
#define BELIEVE_PCC_PROMOTION_TYPE (gdbarch_believe_pcc_promotion_type (current_gdbarch))
#endif
-#if defined (GET_SAVED_REGISTER)
-/* Legacy for systems yet to multi-arch GET_SAVED_REGISTER */
-#if !defined (GET_SAVED_REGISTER_P)
-#define GET_SAVED_REGISTER_P() (1)
+#if defined (DEPRECATED_GET_SAVED_REGISTER)
+/* Legacy for systems yet to multi-arch DEPRECATED_GET_SAVED_REGISTER */
+#if !defined (DEPRECATED_GET_SAVED_REGISTER_P)
+#define DEPRECATED_GET_SAVED_REGISTER_P() (1)
#endif
#endif
/* Default predicate for non- multi-arch targets. */
-#if (!GDB_MULTI_ARCH) && !defined (GET_SAVED_REGISTER_P)
-#define GET_SAVED_REGISTER_P() (0)
+#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_GET_SAVED_REGISTER_P)
+#define DEPRECATED_GET_SAVED_REGISTER_P() (0)
#endif
-extern int gdbarch_get_saved_register_p (struct gdbarch *gdbarch);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (GET_SAVED_REGISTER_P)
-#error "Non multi-arch definition of GET_SAVED_REGISTER"
+extern int gdbarch_deprecated_get_saved_register_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_GET_SAVED_REGISTER_P)
+#error "Non multi-arch definition of DEPRECATED_GET_SAVED_REGISTER"
#endif
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (GET_SAVED_REGISTER_P)
-#define GET_SAVED_REGISTER_P() (gdbarch_get_saved_register_p (current_gdbarch))
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DEPRECATED_GET_SAVED_REGISTER_P)
+#define DEPRECATED_GET_SAVED_REGISTER_P() (gdbarch_deprecated_get_saved_register_p (current_gdbarch))
#endif
/* Default (function) for non- multi-arch platforms. */
-#if (!GDB_MULTI_ARCH) && !defined (GET_SAVED_REGISTER)
-#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) (internal_error (__FILE__, __LINE__, "GET_SAVED_REGISTER"), 0)
+#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_GET_SAVED_REGISTER)
+#define DEPRECATED_GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) (internal_error (__FILE__, __LINE__, "DEPRECATED_GET_SAVED_REGISTER"), 0)
#endif
-typedef void (gdbarch_get_saved_register_ftype) (char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval);
-extern void gdbarch_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval);
-extern void set_gdbarch_get_saved_register (struct gdbarch *gdbarch, gdbarch_get_saved_register_ftype *get_saved_register);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (GET_SAVED_REGISTER)
-#error "Non multi-arch definition of GET_SAVED_REGISTER"
+typedef void (gdbarch_deprecated_get_saved_register_ftype) (char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval);
+extern void gdbarch_deprecated_get_saved_register (struct gdbarch *gdbarch, char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval);
+extern void set_gdbarch_deprecated_get_saved_register (struct gdbarch *gdbarch, gdbarch_deprecated_get_saved_register_ftype *deprecated_get_saved_register);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_GET_SAVED_REGISTER)
+#error "Non multi-arch definition of DEPRECATED_GET_SAVED_REGISTER"
#endif
#if GDB_MULTI_ARCH
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (GET_SAVED_REGISTER)
-#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) (gdbarch_get_saved_register (current_gdbarch, raw_buffer, optimized, addrp, frame, regnum, lval))
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DEPRECATED_GET_SAVED_REGISTER)
+#define DEPRECATED_GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) (gdbarch_deprecated_get_saved_register (current_gdbarch, raw_buffer, optimized, addrp, frame, regnum, lval))
#endif
#endif
@@ -1706,40 +1706,40 @@ extern void set_gdbarch_push_return_address (struct gdbarch *gdbarch, gdbarch_pu
#endif
#endif
-#if defined (POP_FRAME)
-/* Legacy for systems yet to multi-arch POP_FRAME */
-#if !defined (POP_FRAME_P)
-#define POP_FRAME_P() (1)
+#if defined (DEPRECATED_POP_FRAME)
+/* Legacy for systems yet to multi-arch DEPRECATED_POP_FRAME */
+#if !defined (DEPRECATED_POP_FRAME_P)
+#define DEPRECATED_POP_FRAME_P() (1)
#endif
#endif
/* Default predicate for non- multi-arch targets. */
-#if (!GDB_MULTI_ARCH) && !defined (POP_FRAME_P)
-#define POP_FRAME_P() (0)
+#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_POP_FRAME_P)
+#define DEPRECATED_POP_FRAME_P() (0)
#endif
-extern int gdbarch_pop_frame_p (struct gdbarch *gdbarch);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (POP_FRAME_P)
-#error "Non multi-arch definition of POP_FRAME"
+extern int gdbarch_deprecated_pop_frame_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_POP_FRAME_P)
+#error "Non multi-arch definition of DEPRECATED_POP_FRAME"
#endif
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (POP_FRAME_P)
-#define POP_FRAME_P() (gdbarch_pop_frame_p (current_gdbarch))
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DEPRECATED_POP_FRAME_P)
+#define DEPRECATED_POP_FRAME_P() (gdbarch_deprecated_pop_frame_p (current_gdbarch))
#endif
/* Default (function) for non- multi-arch platforms. */
-#if (!GDB_MULTI_ARCH) && !defined (POP_FRAME)
-#define POP_FRAME (internal_error (__FILE__, __LINE__, "POP_FRAME"), 0)
+#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_POP_FRAME)
+#define DEPRECATED_POP_FRAME (internal_error (__FILE__, __LINE__, "DEPRECATED_POP_FRAME"), 0)
#endif
-typedef void (gdbarch_pop_frame_ftype) (void);
-extern void gdbarch_pop_frame (struct gdbarch *gdbarch);
-extern void set_gdbarch_pop_frame (struct gdbarch *gdbarch, gdbarch_pop_frame_ftype *pop_frame);
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (POP_FRAME)
-#error "Non multi-arch definition of POP_FRAME"
+typedef void (gdbarch_deprecated_pop_frame_ftype) (void);
+extern void gdbarch_deprecated_pop_frame (struct gdbarch *gdbarch);
+extern void set_gdbarch_deprecated_pop_frame (struct gdbarch *gdbarch, gdbarch_deprecated_pop_frame_ftype *deprecated_pop_frame);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_POP_FRAME)
+#error "Non multi-arch definition of DEPRECATED_POP_FRAME"
#endif
#if GDB_MULTI_ARCH
-#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (POP_FRAME)
-#define POP_FRAME (gdbarch_pop_frame (current_gdbarch))
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DEPRECATED_POP_FRAME)
+#define DEPRECATED_POP_FRAME (gdbarch_deprecated_pop_frame (current_gdbarch))
#endif
#endif
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 2cf9a32e6a3..ff745ef4728 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -541,7 +541,7 @@ F:2:DEPRECATED_INIT_FRAME_PC:CORE_ADDR:deprecated_init_frame_pc:int fromleaf, st
#
v:2:BELIEVE_PCC_PROMOTION:int:believe_pcc_promotion:::::::
v::BELIEVE_PCC_PROMOTION_TYPE:int:believe_pcc_promotion_type:::::::
-F:2:GET_SAVED_REGISTER:void:get_saved_register:char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval:raw_buffer, optimized, addrp, frame, regnum, lval
+F:2:DEPRECATED_GET_SAVED_REGISTER:void:deprecated_get_saved_register:char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval:raw_buffer, optimized, addrp, frame, regnum, lval
#
f:2:REGISTER_CONVERTIBLE:int:register_convertible:int nr:nr:::generic_register_convertible_not::0
f:2:REGISTER_CONVERT_TO_VIRTUAL:void:register_convert_to_virtual:int regnum, struct type *type, char *from, char *to:regnum, type, from, to:::0::0
@@ -559,7 +559,7 @@ f:2:RETURN_VALUE_ON_STACK:int:return_value_on_stack:struct type *type:type:::gen
f:2:PUSH_ARGUMENTS:CORE_ADDR:push_arguments:int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr:nargs, args, sp, struct_return, struct_addr:::default_push_arguments::0
F:2:DEPRECATED_PUSH_DUMMY_FRAME:void:deprecated_push_dummy_frame:void:-:::0
F:2:PUSH_RETURN_ADDRESS:CORE_ADDR:push_return_address:CORE_ADDR pc, CORE_ADDR sp:pc, sp:::0
-F:2:POP_FRAME:void:pop_frame:void:-:::0
+F:2:DEPRECATED_POP_FRAME:void:deprecated_pop_frame:void:-:::0
#
f:2:STORE_STRUCT_RETURN:void:store_struct_return:CORE_ADDR addr, CORE_ADDR sp:addr, sp:::0
#
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 8349322dd7c..415acf8c070 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -1151,7 +1151,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_push_return_address (gdbarch, h8300_push_return_address);
set_gdbarch_deprecated_extract_return_value (gdbarch, h8300_extract_return_value);
set_gdbarch_push_arguments (gdbarch, h8300_push_arguments);
- set_gdbarch_pop_frame (gdbarch, h8300_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, h8300_pop_frame);
set_gdbarch_store_struct_return (gdbarch, h8300_store_struct_return);
set_gdbarch_deprecated_store_return_value (gdbarch, h8300_store_return_value);
set_gdbarch_deprecated_extract_struct_value_address (gdbarch, h8300_extract_struct_value_address);
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 83855967954..9fde53d4a6e 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -5017,7 +5017,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_num_args (gdbarch, hppa_frame_num_args);
set_gdbarch_frame_args_skip (gdbarch, 0);
/* set_gdbarch_deprecated_push_dummy_frame (gdbarch, hppa_push_dummy_frame); */
- set_gdbarch_pop_frame (gdbarch, hppa_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, hppa_pop_frame);
set_gdbarch_call_dummy_length (gdbarch, INSTRUCTION_SIZE * 28);
set_gdbarch_call_dummy_start_offset (gdbarch, 0);
/* set_gdbarch_fix_call_dummy (gdbarch, hppa_fix_call_dummy); */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 4b479cc2fe5..bb588bf72dc 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1129,7 +1129,7 @@ i386_use_struct_convention (int gcc_p, struct type *type)
potentially they could be used for things other than address. */
static struct type *
-i386_register_virtual_type (int regnum)
+i386_register_type (struct gdbarch *gdbarch, int regnum)
{
if (regnum == PC_REGNUM || regnum == FP_REGNUM || regnum == SP_REGNUM)
return lookup_pointer_type (builtin_type_void);
@@ -1558,9 +1558,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_register_name (gdbarch, i386_register_name);
set_gdbarch_register_size (gdbarch, 4);
set_gdbarch_register_bytes (gdbarch, I386_SIZEOF_GREGS + I386_SIZEOF_FREGS);
- set_gdbarch_deprecated_max_register_raw_size (gdbarch, I386_MAX_REGISTER_SIZE);
- set_gdbarch_deprecated_max_register_virtual_size (gdbarch, I386_MAX_REGISTER_SIZE);
- set_gdbarch_register_virtual_type (gdbarch, i386_register_virtual_type);
+ set_gdbarch_register_type (gdbarch, i386_register_type);
set_gdbarch_print_float_info (gdbarch, i387_print_float_info);
@@ -1591,7 +1589,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_extract_return_value (gdbarch, i386_extract_return_value);
set_gdbarch_push_arguments (gdbarch, i386_push_arguments);
set_gdbarch_push_return_address (gdbarch, i386_push_return_address);
- set_gdbarch_pop_frame (gdbarch, i386_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, i386_pop_frame);
set_gdbarch_store_struct_return (gdbarch, i386_store_struct_return);
set_gdbarch_store_return_value (gdbarch, i386_store_return_value);
set_gdbarch_extract_struct_value_address (gdbarch,
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 62cff271b59..069c2e6a0cc 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -93,7 +93,6 @@ static gdbarch_register_byte_ftype ia64_register_byte;
static gdbarch_breakpoint_from_pc_ftype ia64_breakpoint_from_pc;
static gdbarch_frame_chain_ftype ia64_frame_chain;
static gdbarch_skip_prologue_ftype ia64_skip_prologue;
-static gdbarch_get_saved_register_ftype ia64_get_saved_register;
static gdbarch_deprecated_extract_return_value_ftype ia64_extract_return_value;
static gdbarch_deprecated_extract_struct_value_address_ftype ia64_extract_struct_value_address;
static gdbarch_use_struct_convention_ftype ia64_use_struct_convention;
@@ -101,7 +100,6 @@ static gdbarch_frameless_function_invocation_ftype ia64_frameless_function_invoc
static gdbarch_store_struct_return_ftype ia64_store_struct_return;
static gdbarch_push_arguments_ftype ia64_push_arguments;
static gdbarch_push_return_address_ftype ia64_push_return_address;
-static gdbarch_pop_frame_ftype ia64_pop_frame;
static gdbarch_saved_pc_after_call_ftype ia64_saved_pc_after_call;
static void ia64_pop_frame_regular (struct frame_info *frame);
static struct type *is_float_or_hfa_type (struct type *t);
@@ -2199,7 +2197,7 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_frame_saved_pc (gdbarch, ia64_frame_saved_pc);
set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, ia64_frame_init_saved_regs);
- set_gdbarch_get_saved_register (gdbarch, ia64_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, ia64_get_saved_register);
set_gdbarch_register_convertible (gdbarch, ia64_register_convertible);
set_gdbarch_register_convert_to_virtual (gdbarch, ia64_register_convert_to_virtual);
@@ -2222,7 +2220,7 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_length (gdbarch, 0);
set_gdbarch_push_arguments (gdbarch, ia64_push_arguments);
set_gdbarch_push_return_address (gdbarch, ia64_push_return_address);
- set_gdbarch_pop_frame (gdbarch, ia64_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, ia64_pop_frame);
set_gdbarch_call_dummy_p (gdbarch, 1);
set_gdbarch_call_dummy_words (gdbarch, ia64_call_dummy_words);
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index d1173baebe4..7d64860fb8b 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -1390,7 +1390,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
sizeof (m68hc11_call_dummy_words));
set_gdbarch_call_dummy_p (gdbarch, 1);
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
- set_gdbarch_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
set_gdbarch_deprecated_extract_return_value (gdbarch, m68hc11_extract_return_value);
set_gdbarch_push_arguments (gdbarch, m68hc11_push_arguments);
@@ -1410,7 +1410,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
set_gdbarch_saved_pc_after_call (gdbarch, m68hc11_saved_pc_after_call);
set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
- set_gdbarch_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
set_gdbarch_store_struct_return (gdbarch, m68hc11_store_struct_return);
set_gdbarch_deprecated_store_return_value (gdbarch, m68hc11_store_return_value);
@@ -1418,7 +1418,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
(gdbarch, m68hc11_extract_struct_value_address);
set_gdbarch_use_struct_convention (gdbarch, m68hc11_use_struct_convention);
set_gdbarch_deprecated_init_extra_frame_info (gdbarch, m68hc11_init_extra_frame_info);
- set_gdbarch_pop_frame (gdbarch, m68hc11_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, m68hc11_pop_frame);
set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_decr_pc_after_break (gdbarch, 0);
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 1e09cf83480..b79c68a19df 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -1051,7 +1051,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
set_gdbarch_fix_call_dummy (gdbarch, m68k_fix_call_dummy);
set_gdbarch_deprecated_push_dummy_frame (gdbarch, m68k_push_dummy_frame);
- set_gdbarch_pop_frame (gdbarch, m68k_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, m68k_pop_frame);
return gdbarch;
}
diff --git a/gdb/mcore-tdep.c b/gdb/mcore-tdep.c
index a0d86934b00..36dbbdb48a4 100644
--- a/gdb/mcore-tdep.c
+++ b/gdb/mcore-tdep.c
@@ -1151,7 +1151,7 @@ mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_args_address (gdbarch, mcore_frame_args_address);
set_gdbarch_frame_locals_address (gdbarch, mcore_frame_locals_address);
set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
- set_gdbarch_pop_frame (gdbarch, mcore_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, mcore_pop_frame);
set_gdbarch_virtual_frame_pointer (gdbarch, mcore_virtual_frame_pointer);
/* Misc.: */
diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog
index 7290ef9d75d..1785b9b8813 100644
--- a/gdb/mi/ChangeLog
+++ b/gdb/mi/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-12 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Use frame_register instead of
+ get_saved_register.
+
2003-03-08 Andrew Cagney <cagney@redhat.com>
* mi-out.c: Update copyright.
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index f08bd3f5b1c..6ba069821ea 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -514,6 +514,9 @@ get_register (int regnum, int format)
char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
int optim;
+ int realnum;
+ CORE_ADDR addr;
+ enum lval_type lval;
static struct ui_stream *stb = NULL;
stb = ui_out_stream_new (uiout);
@@ -521,9 +524,9 @@ get_register (int regnum, int format)
if (format == 'N')
format = 0;
- get_saved_register (raw_buffer, &optim, (CORE_ADDR *) NULL,
- deprecated_selected_frame,
- regnum, (enum lval_type *) NULL);
+ frame_register (deprecated_selected_frame, regnum, &optim, &lval, &addr,
+ &realnum, raw_buffer);
+
if (optim)
{
xasprintf (&mi_error_message, "Optimized out");
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index ae287902dde..506fd1fe7cf 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6007,7 +6007,7 @@ mips_gdbarch_init (struct gdbarch_info info,
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
set_gdbarch_call_dummy_address (gdbarch, mips_call_dummy_address);
set_gdbarch_push_return_address (gdbarch, mips_push_return_address);
- set_gdbarch_pop_frame (gdbarch, mips_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, mips_pop_frame);
set_gdbarch_call_dummy_start_offset (gdbarch, 0);
set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
@@ -6031,7 +6031,7 @@ mips_gdbarch_init (struct gdbarch_info info,
set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
set_gdbarch_frame_args_skip (gdbarch, 0);
- set_gdbarch_get_saved_register (gdbarch, mips_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, mips_get_saved_register);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_breakpoint_from_pc (gdbarch, mips_breakpoint_from_pc);
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 7996b1e0d06..df6e0439a63 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -1177,7 +1177,7 @@ mn10300_gdbarch_init (struct gdbarch_info info,
(gdbarch, mn10300_extract_struct_value_address);
set_gdbarch_deprecated_store_return_value (gdbarch, mn10300_store_return_value);
set_gdbarch_store_struct_return (gdbarch, mn10300_store_struct_return);
- set_gdbarch_pop_frame (gdbarch, mn10300_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, mn10300_pop_frame);
set_gdbarch_skip_prologue (gdbarch, mn10300_skip_prologue);
set_gdbarch_frame_args_skip (gdbarch, 0);
set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
diff --git a/gdb/ns32k-tdep.c b/gdb/ns32k-tdep.c
index 20696c7c990..9737120bbbd 100644
--- a/gdb/ns32k-tdep.c
+++ b/gdb/ns32k-tdep.c
@@ -593,7 +593,7 @@ ns32k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Call dummy info */
set_gdbarch_deprecated_push_dummy_frame (gdbarch, ns32k_push_dummy_frame);
- set_gdbarch_pop_frame (gdbarch, ns32k_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, ns32k_pop_frame);
set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
set_gdbarch_call_dummy_p (gdbarch, 1);
set_gdbarch_call_dummy_words (gdbarch, ns32k_call_dummy_words);
diff --git a/gdb/regcache.h b/gdb/regcache.h
index bc9757e1d5a..3fb43c437a4 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -98,7 +98,7 @@ extern void regcache_collect (int regnum, void *buf);
/* The register's ``offset''.
- FIXME: cagney/2002-11-07: The get_saved_register() function, when
+ FIXME: cagney/2002-11-07: The frame_register() function, when
specifying the real location of a register, does so using that
registers offset in the register cache. That offset is then used
by valops.c to determine the location of the register. The code
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 72079ce3e9e..46733a3ac57 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2917,7 +2917,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return);
set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
- set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, rs6000_pop_frame);
set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index f26ea1391e5..138ef78be08 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1820,7 +1820,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
This is often the number of bytes in BREAKPOINT
but not always. */
set_gdbarch_decr_pc_after_break (gdbarch, 2);
- set_gdbarch_pop_frame (gdbarch, s390_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, s390_pop_frame);
/* Stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
/* Offset from address of function to start of its code.
diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c
index 961e0300ea6..e4060d27767 100644
--- a/gdb/sentinel-frame.c
+++ b/gdb/sentinel-frame.c
@@ -45,13 +45,13 @@ sentinel_frame_cache (struct regcache *regcache)
/* Here the register value is taken direct from the register cache. */
void
-sentinel_frame_register_unwind (struct frame_info *frame,
- void **unwind_cache,
- int regnum, int *optimized,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnum, void *bufferp)
+sentinel_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimized,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnum, void *bufferp)
{
- struct frame_unwind_cache *cache = *unwind_cache;
+ struct frame_unwind_cache *cache = *this_prologue_cache;
/* Describe the register's location. A reg-frame maps all registers
onto the corresponding hardware register. */
*optimized = 0;
@@ -71,22 +71,20 @@ sentinel_frame_register_unwind (struct frame_info *frame,
}
void
-sentinel_frame_id_unwind (struct frame_info *frame,
- void **cache,
- struct frame_id *id)
+sentinel_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
{
- /* FIXME: cagney/2003-01-08: This should be using a per-architecture
- method that doesn't suffer from DECR_PC_AFTER_BREAK problems.
- Such a method would take unwind_cache, regcache and stop reason
- parameters. */
- id->base = read_fp ();
- id->pc = read_pc ();
+ /* The sentinel frame is used as a starting point for creating the
+ previous (inner most) frame. That frame's THIS_ID method will be
+ called to determine the inner most frame's ID. Not this one. */
+ internal_error (__FILE__, __LINE__, "sentinel_frame_this_id called");
}
const struct frame_unwind sentinel_frame_unwinder =
{
- sentinel_frame_id_unwind,
- sentinel_frame_register_unwind
+ sentinel_frame_this_id,
+ sentinel_frame_prev_register
};
const struct frame_unwind *const sentinel_frame_unwind = &sentinel_frame_unwinder;
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 081c0636837..2a6449f305a 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -4372,14 +4372,14 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_do_registers_info (gdbarch, sh_do_registers_info);
set_gdbarch_breakpoint_from_pc (gdbarch, sh_breakpoint_from_pc);
set_gdbarch_frame_chain (gdbarch, sh_frame_chain);
- set_gdbarch_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
set_gdbarch_deprecated_init_extra_frame_info (gdbarch, sh_init_extra_frame_info);
set_gdbarch_deprecated_extract_return_value (gdbarch, sh_extract_return_value);
set_gdbarch_push_arguments (gdbarch, sh_push_arguments);
set_gdbarch_store_struct_return (gdbarch, sh_store_struct_return);
set_gdbarch_use_struct_convention (gdbarch, sh_use_struct_convention);
set_gdbarch_deprecated_extract_struct_value_address (gdbarch, sh_extract_struct_value_address);
- set_gdbarch_pop_frame (gdbarch, sh_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, sh_pop_frame);
set_gdbarch_print_insn (gdbarch, gdb_print_insn_sh);
set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
skip_prologue_hard_way = sh_skip_prologue_hard_way;
@@ -4615,13 +4615,13 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_breakpoint_from_pc (gdbarch, sh_sh64_breakpoint_from_pc);
set_gdbarch_deprecated_init_extra_frame_info (gdbarch, sh64_init_extra_frame_info);
set_gdbarch_frame_chain (gdbarch, sh64_frame_chain);
- set_gdbarch_get_saved_register (gdbarch, sh64_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, sh64_get_saved_register);
set_gdbarch_deprecated_extract_return_value (gdbarch, sh64_extract_return_value);
set_gdbarch_push_arguments (gdbarch, sh64_push_arguments);
/*set_gdbarch_store_struct_return (gdbarch, sh64_store_struct_return);*/
set_gdbarch_deprecated_extract_struct_value_address (gdbarch, sh64_extract_struct_value_address);
set_gdbarch_use_struct_convention (gdbarch, sh64_use_struct_convention);
- set_gdbarch_pop_frame (gdbarch, sh64_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, sh64_pop_frame);
set_gdbarch_elf_make_msymbol_special (gdbarch,
sh64_elf_make_msymbol_special);
break;
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index be8197f9318..6e1b211f6d5 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -326,9 +326,9 @@ sparc_init_extra_frame_info (int fromleaf, struct frame_info *fi)
else
{
/* Should we adjust for stack bias here? */
- get_saved_register (buf, 0, 0, fi, FP_REGNUM, 0);
- deprecated_update_frame_base_hack (fi, extract_address (buf, REGISTER_RAW_SIZE (FP_REGNUM)));
-
+ ULONGEST tmp;
+ frame_read_unsigned_register (fi, FP_REGNUM, &tmp);
+ deprecated_update_frame_base_hack (fi, tmp);
if (GDB_TARGET_IS_SPARC64 && (get_frame_base (fi) & 1))
deprecated_update_frame_base_hack (fi, get_frame_base (fi) + 2047);
}
@@ -367,8 +367,11 @@ sparc_init_extra_frame_info (int fromleaf, struct frame_info *fi)
get_frame_extra_info (fi)->sp_offset = offset;
/* Overwrite the frame's address with the value in %i7. */
- get_saved_register (buf, 0, 0, fi, I7_REGNUM, 0);
- deprecated_update_frame_base_hack (fi, extract_address (buf, REGISTER_RAW_SIZE (I7_REGNUM)));
+ {
+ ULONGEST tmp;
+ frame_read_unsigned_register (fi, I7_REGNUM, &tmp);
+ deprecated_update_frame_base_hack (fi, tmp);
+ }
if (GDB_TARGET_IS_SPARC64 && (get_frame_base (fi) & 1))
deprecated_update_frame_base_hack (fi, get_frame_base (fi) + 2047);
@@ -487,9 +490,11 @@ sparc_frame_saved_pc (struct frame_info *frame)
saved_pc_offset = 12;
/* The sigcontext address is contained in register O2. */
- get_saved_register (buf, (int *) NULL, (CORE_ADDR *) NULL,
- frame, O0_REGNUM + 2, (enum lval_type *) NULL);
- sigcontext_addr = extract_address (buf, REGISTER_RAW_SIZE (O0_REGNUM + 2));
+ {
+ ULONGEST tmp;
+ frame_read_unsigned_register (frame, O0_REGNUM + 2, &tmp);
+ sigcontext_addr = tmp;
+ }
/* Don't cause a memory_error when accessing sigcontext in case the
stack layout has changed or the stack is corrupt. */
@@ -505,9 +510,9 @@ sparc_frame_saved_pc (struct frame_info *frame)
{
/* A frameless function interrupted by a signal did not save
the PC, it is still in %o7. */
- get_saved_register (buf, (int *) NULL, (CORE_ADDR *) NULL,
- frame, O7_REGNUM, (enum lval_type *) NULL);
- return PC_ADJUST (extract_address (buf, SPARC_INTREG_SIZE));
+ ULONGEST tmp;
+ frame_read_unsigned_register (frame, O7_REGNUM, &tmp);
+ return PC_ADJUST (tmp);
}
if (get_frame_extra_info (frame)->flat)
addr = get_frame_extra_info (frame)->pc_addr;
@@ -936,8 +941,9 @@ sparc_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
else if (regnum >= O0_REGNUM && regnum < O0_REGNUM + 8)
{
/* Outs become ins. */
- get_saved_register (raw_buffer, optimized, addrp, frame1,
- (regnum - O0_REGNUM + I0_REGNUM), lval);
+ int realnum;
+ frame_register (frame1, (regnum - O0_REGNUM + I0_REGNUM),
+ optimized, lval, addrp, &realnum, raw_buffer);
return;
}
}
@@ -1090,10 +1096,10 @@ sparc_push_dummy_frame (void)
I think few ports of GDB get right--if you are popping a frame
which does not save some register that *is* saved by a more inner
frame (such a frame will never be a dummy frame because dummy
- frames save all registers). Rewriting pop_frame to use
- get_saved_register would solve this problem and also get rid of the
- ugly duplication between sparc_frame_find_saved_regs and
- get_saved_register.
+ frames save all registers).
+
+ NOTE: cagney/2003-03-12: Since pop_frame has been rewritten to use
+ frame_unwind_register() the need for this function is questionable.
Stores, into an array of CORE_ADDR,
the addresses of the saved registers of frame described by FRAME_INFO.
@@ -1369,12 +1375,9 @@ sparc_pop_frame (void)
/* I think this happens only in the innermost frame, if so then
it is a complicated way of saying
"pc = read_register (O7_REGNUM);". */
- char *buf;
-
- buf = alloca (MAX_REGISTER_RAW_SIZE);
- get_saved_register (buf, 0, 0, frame, O7_REGNUM, 0);
- pc = PC_ADJUST (extract_address
- (buf, REGISTER_RAW_SIZE (O7_REGNUM)));
+ ULONGEST tmp;
+ frame_read_unsigned_register (frame, O7_REGNUM, &tmp);
+ pc = PC_ADJUST (tmp);
}
write_register (PC_REGNUM, pc);
@@ -3150,7 +3153,7 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_frame_saved_pc (gdbarch, sparc_frame_saved_pc);
set_gdbarch_frameless_function_invocation (gdbarch,
frameless_look_for_prologue);
- set_gdbarch_get_saved_register (gdbarch, sparc_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, sparc_get_saved_register);
set_gdbarch_deprecated_init_extra_frame_info (gdbarch, sparc_init_extra_frame_info);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -3158,7 +3161,7 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_deprecated_max_register_raw_size (gdbarch, 8);
set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 8);
- set_gdbarch_pop_frame (gdbarch, sparc_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, sparc_pop_frame);
set_gdbarch_push_return_address (gdbarch, sparc_push_return_address);
set_gdbarch_deprecated_push_dummy_frame (gdbarch, sparc_push_dummy_frame);
set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
diff --git a/gdb/stack.c b/gdb/stack.c
index 3eab979f6ca..98b8a0f88ce 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1639,9 +1639,13 @@ return_command (char *retval_exp, int from_tty)
that. */
/* Do the real work. Pop until the specified frame is current. We
- use this method because the deprecated_selected_frame is not valid after
- a POP_FRAME. The pc comparison makes this work even if the
- selected frame shares its fp with another frame. */
+ use this method because the deprecated_selected_frame is not
+ valid after a frame_pop(). The pc comparison makes this work
+ even if the selected frame shares its fp with another frame. */
+
+ /* FIXME: cagney/32003-03-12: This code should use frame_id_eq().
+ Unfortunatly, that function doesn't yet include the PC in any
+ frame ID comparison. */
while (selected_frame_addr != get_frame_base (frame = get_current_frame ())
|| selected_frame_pc != get_frame_pc (frame))
diff --git a/gdb/tui/ChangeLog b/gdb/tui/ChangeLog
index a9f918a90a1..7069f965796 100644
--- a/gdb/tui/ChangeLog
+++ b/gdb/tui/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-14 Andrew Cagney <cagney@redhat.com>
+
+ * tuiRegs.c (_tuiGetRegisterRawValue): Use frame_read_register,
+ instead of get_saved_register.
+
+2003-03-13 Stephane Carrez <stcarrez@nerim.fr>
+
+ * tui-out.c (tui_out_data): Fix typedef.
+
2003-03-08 Andrew Cagney <cagney@redhat.com>
* tui-out.c: Update copyright.
diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c
index 1ec6d869a95..94fda09b14c 100644
--- a/gdb/tui/tui-out.c
+++ b/gdb/tui/tui-out.c
@@ -36,7 +36,7 @@ struct ui_out_data
int line;
int start_of_line;
};
-struct ui_out_data tui_out_data;
+typedef struct ui_out_data tui_out_data;
/* These are the CLI output functions */
diff --git a/gdb/tui/tuiRegs.c b/gdb/tui/tuiRegs.c
index 6fc63d9454e..6920d80d975 100644
--- a/gdb/tui/tuiRegs.c
+++ b/gdb/tui/tuiRegs.c
@@ -799,10 +799,10 @@ _tuiGetRegisterRawValue (int regNum, char *regValue, struct frame_info *frame)
if (target_has_registers)
{
- int opt;
-
- get_saved_register (regValue, &opt, (CORE_ADDR*) NULL, frame,
- regNum, (enum lval_type*) NULL);
+ frame_read_register (frame, regNum, regValue);
+ /* NOTE: cagney/2003-03-13: This is bogus. It is refering to
+ the register cache and not the frame which could have pulled
+ the register value off the stack. */
if (register_cached (regNum) >= 0)
ret = TUI_SUCCESS;
}
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 94fcb8167e8..f0c12a223bc 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -1271,7 +1271,7 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_push_return_address (gdbarch, v850_push_return_address);
set_gdbarch_deprecated_extract_return_value (gdbarch, v850_extract_return_value);
set_gdbarch_push_arguments (gdbarch, v850_push_arguments);
- set_gdbarch_pop_frame (gdbarch, v850_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, v850_pop_frame);
set_gdbarch_store_struct_return (gdbarch, v850_store_struct_return);
set_gdbarch_deprecated_store_return_value (gdbarch, v850_store_return_value);
set_gdbarch_deprecated_extract_struct_value_address (gdbarch, v850_extract_struct_value_address);
diff --git a/gdb/valops.c b/gdb/valops.c
index 6dcc6f107c9..f21b781b8ca 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1303,7 +1303,7 @@ hand_function_call (struct value *function, int nargs, struct value **args)
if (DEPRECATED_PUSH_DUMMY_FRAME_P ())
{
/* DEPRECATED_PUSH_DUMMY_FRAME is responsible for saving the
- inferior registers (and POP_FRAME for restoring them). (At
+ inferior registers (and frame_pop() for restoring them). (At
least on most machines) they are saved on the stack in the
inferior. */
DEPRECATED_PUSH_DUMMY_FRAME;
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index 4b1851edbdc..f5cd2676e85 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -52,7 +52,6 @@ static gdbarch_deprecated_extract_struct_value_address_ftype
vax_extract_struct_value_address;
static gdbarch_deprecated_push_dummy_frame_ftype vax_push_dummy_frame;
-static gdbarch_pop_frame_ftype vax_pop_frame;
static gdbarch_fix_call_dummy_ftype vax_fix_call_dummy;
/* Return 1 if P points to an invalid floating point value.
@@ -668,7 +667,7 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Call dummy info */
set_gdbarch_deprecated_push_dummy_frame (gdbarch, vax_push_dummy_frame);
- set_gdbarch_pop_frame (gdbarch, vax_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, vax_pop_frame);
set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
set_gdbarch_call_dummy_p (gdbarch, 1);
set_gdbarch_call_dummy_words (gdbarch, vax_call_dummy_words);
diff --git a/gdb/version.in b/gdb/version.in
index 2f39186bafd..c9ca6c9020d 100644
--- a/gdb/version.in
+++ b/gdb/version.in
@@ -1 +1 @@
-2003-03-13-cvs
+2003-03-17-cvs
diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c
index 85057f7f907..ced11dca01c 100644
--- a/gdb/x86-64-tdep.c
+++ b/gdb/x86-64-tdep.c
@@ -1006,7 +1006,7 @@ x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
x86_64_register_convert_to_raw);
/* Getting saved registers is handled by unwind information. */
- set_gdbarch_get_saved_register (gdbarch, cfi_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, cfi_get_saved_register);
/* FIXME: kettenis/20021026: Should we set parm_boundary to 64 here? */
set_gdbarch_read_fp (gdbarch, cfi_read_fp);
@@ -1015,7 +1015,7 @@ x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_push_arguments (gdbarch, x86_64_push_arguments);
set_gdbarch_push_return_address (gdbarch, x86_64_push_return_address);
- set_gdbarch_pop_frame (gdbarch, x86_64_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, x86_64_pop_frame);
set_gdbarch_store_struct_return (gdbarch, x86_64_store_struct_return);
set_gdbarch_store_return_value (gdbarch, x86_64_store_return_value);
/* Override, since this is handled by x86_64_extract_return_value. */
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index e44b64d9ae0..2ccbb1e60b5 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -723,11 +723,10 @@ xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
actual value of the previous frame's stack register.
This function may be called in any context where the saved register
- values may be needed (backtrace, frame_info, get_saved_register).
- On many targets, it is called directly by init_extra_frame_info,
- in part because the information may be needed immediately by
- frame_chain.
-*/
+ values may be needed (backtrace, frame_info, frame_register). On
+ many targets, it is called directly by init_extra_frame_info, in
+ part because the information may be needed immediately by
+ frame_chain. */
static void
xstormy16_frame_init_saved_regs (struct frame_info *fi)
@@ -841,12 +840,11 @@ xstormy16_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
get_frame_base (thisframe) - get_frame_extra_info (thisframe)->framesize == chain);
}
-/* Function: xstormy16_saved_pc_after_call
- Returns the previous PC immediately after a function call.
- This function is meant to bypass the regular get_saved_register
- mechanism, ie. it is meant to work even if the frame isn't complete.
- Called by step_over_function, and sometimes by get_prev_frame.
-*/
+/* Function: xstormy16_saved_pc_after_call Returns the previous PC
+ immediately after a function call. This function is meant to
+ bypass the regular frame_register() mechanism, ie. it is meant to
+ work even if the frame isn't complete. Called by
+ step_over_function, and sometimes by get_prev_frame. */
static CORE_ADDR
xstormy16_saved_pc_after_call (struct frame_info *ignore)
@@ -1058,7 +1056,7 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_frame_init_saved_regs (gdbarch,
xstormy16_frame_init_saved_regs);
set_gdbarch_frame_chain (gdbarch, xstormy16_frame_chain);
- set_gdbarch_get_saved_register (gdbarch, xstormy16_get_saved_register);
+ set_gdbarch_deprecated_get_saved_register (gdbarch, xstormy16_get_saved_register);
set_gdbarch_saved_pc_after_call (gdbarch, xstormy16_saved_pc_after_call);
set_gdbarch_deprecated_frame_saved_pc (gdbarch, xstormy16_frame_saved_pc);
set_gdbarch_skip_prologue (gdbarch, xstormy16_skip_prologue);
@@ -1089,7 +1087,7 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_push_return_address (gdbarch, xstormy16_push_return_address);
set_gdbarch_deprecated_extract_return_value (gdbarch, xstormy16_extract_return_value);
set_gdbarch_push_arguments (gdbarch, xstormy16_push_arguments);
- set_gdbarch_pop_frame (gdbarch, xstormy16_pop_frame);
+ set_gdbarch_deprecated_pop_frame (gdbarch, xstormy16_pop_frame);
set_gdbarch_store_struct_return (gdbarch, xstormy16_store_struct_return);
set_gdbarch_deprecated_store_return_value (gdbarch, xstormy16_store_return_value);
set_gdbarch_deprecated_extract_struct_value_address (gdbarch, xstormy16_extract_struct_value_address);
diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog
index f04439c3e81..53adca32362 100644
--- a/include/opcode/ChangeLog
+++ b/include/opcode/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-17 D.Venkatasubramanian <dvenkat@noida.hcltech.com>
+
+ * h8300.h (O_SYS_CMDLINE): New pseudo opcode for command line
+ processing.
+
2003-02-21 Noida D.Venkatasubramanian <dvenkat@noida.hcltech.com>
* h8300.h (ldmac, stmac): Replace MACREG with MS32 and MD32.
diff --git a/include/opcode/h8300.h b/include/opcode/h8300.h
index 034c7bc9d15..bdba345674e 100644
--- a/include/opcode/h8300.h
+++ b/include/opcode/h8300.h
@@ -313,6 +313,8 @@ struct h8_opcode
#define O_SYS_CLOSE 105
#define O_SYS_STAT 106
#define O_SYS_FSTAT 107
+/* Space reserved for future file I/O system calls. */
+#define O_SYS_CMDLINE 120
/* End of System Call specific Changes. */
#define SB 0
#define SW 1
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 42cf2571cf5..94d8721984b 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,11 @@
+2003-03-17 Nick Clifton <nickc@redhat.com>
+
+ * ppc-opc.c: Fix formatting. Update copyright date.
+
+2003-03-14 Daniel Jacobowitz <drow@mvista.com>
+
+ * ppc-opc.c (powerpc_opcodes): Readd tlbre for PPC403.
+
2003-02-25 Alan Modra <amodra@bigpond.net.au>
* hppa-dis.c: Formatting.
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
index 1b62f87af99..27eb23e22d8 100644
--- a/opcodes/ppc-opc.c
+++ b/opcodes/ppc-opc.c
@@ -1,24 +1,24 @@
/* ppc-opc.c -- PowerPC opcode list
- Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002
+ Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support
-This file is part of GDB, GAS, and the GNU binutils.
+ This file is part of GDB, GAS, and the GNU binutils.
-GDB, GAS, and the GNU binutils are free software; you can redistribute
-them and/or modify them under the terms of the GNU General Public
-License as published by the Free Software Foundation; either version
-2, or (at your option) any later version.
+ GDB, GAS, and the GNU binutils are free software; you can redistribute
+ them and/or modify them under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either version
+ 2, or (at your option) any later version.
-GDB, GAS, and the GNU binutils are distributed in the hope that they
-will be useful, but WITHOUT ANY WARRANTY; without even the implied
-warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-the GNU General Public License for more details.
+ GDB, GAS, and the GNU binutils are distributed in the hope that they
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ the GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this file; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this file; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#include <stdio.h>
#include "sysdep.h"
@@ -497,52 +497,52 @@ const struct powerpc_operand powerpc_operands[] =
#define UI U + 1
{ 16, 0, 0, 0, 0 },
- /* The VA field in a VA, VX or VXR form instruction. */
+ /* The VA field in a VA, VX or VXR form instruction. */
#define VA UI + 1
#define VA_MASK (0x1f << 16)
{ 5, 16, 0, 0, PPC_OPERAND_VR },
- /* The VB field in a VA, VX or VXR form instruction. */
+ /* The VB field in a VA, VX or VXR form instruction. */
#define VB VA + 1
#define VB_MASK (0x1f << 11)
{ 5, 11, 0, 0, PPC_OPERAND_VR },
- /* The VC field in a VA form instruction. */
+ /* The VC field in a VA form instruction. */
#define VC VB + 1
#define VC_MASK (0x1f << 6)
{ 5, 6, 0, 0, PPC_OPERAND_VR },
- /* The VD or VS field in a VA, VX, VXR or X form instruction. */
+ /* The VD or VS field in a VA, VX, VXR or X form instruction. */
#define VD VC + 1
#define VS VD
#define VD_MASK (0x1f << 21)
{ 5, 21, 0, 0, PPC_OPERAND_VR },
- /* The SIMM field in a VX form instruction. */
+ /* The SIMM field in a VX form instruction. */
#define SIMM VD + 1
{ 5, 16, 0, 0, PPC_OPERAND_SIGNED},
- /* The UIMM field in a VX form instruction. */
+ /* The UIMM field in a VX form instruction. */
#define UIMM SIMM + 1
{ 5, 16, 0, 0, 0 },
- /* The SHB field in a VA form instruction. */
+ /* The SHB field in a VA form instruction. */
#define SHB UIMM + 1
{ 4, 6, 0, 0, 0 },
- /* The other UIMM field in a EVX form instruction. */
+ /* The other UIMM field in a EVX form instruction. */
#define EVUIMM SHB + 1
{ 5, 11, 0, 0, 0 },
- /* The other UIMM field in a half word EVX form instruction. */
+ /* The other UIMM field in a half word EVX form instruction. */
#define EVUIMM_2 EVUIMM + 1
{ 32, 11, insert_ev2, extract_ev2, PPC_OPERAND_PARENS },
- /* The other UIMM field in a word EVX form instruction. */
+ /* The other UIMM field in a word EVX form instruction. */
#define EVUIMM_4 EVUIMM_2 + 1
{ 32, 11, insert_ev4, extract_ev4, PPC_OPERAND_PARENS },
- /* The other UIMM field in a double EVX form instruction. */
+ /* The other UIMM field in a double EVX form instruction. */
#define EVUIMM_8 EVUIMM_4 + 1
{ 32, 11, insert_ev8, extract_ev8, PPC_OPERAND_PARENS },
@@ -1499,22 +1499,22 @@ extract_tbr (insn, dialect, invalid)
#define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1))
#define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1)
-/* An VX form instruction. */
+/* An VX form instruction. */
#define VX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff))
-/* The mask for an VX form instruction. */
+/* The mask for an VX form instruction. */
#define VX_MASK VX(0x3f, 0x7ff)
-/* An VA form instruction. */
+/* An VA form instruction. */
#define VXA(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x03f))
-/* The mask for an VA form instruction. */
+/* The mask for an VA form instruction. */
#define VXA_MASK VXA(0x3f, 0x3f)
-/* An VXR form instruction. */
+/* An VXR form instruction. */
#define VXR(op, xop, rc) (OP (op) | (((rc) & 1) << 10) | (((unsigned long)(xop)) & 0x3ff))
-/* The mask for a VXR form instruction. */
+/* The mask for a VXR form instruction. */
#define VXR_MASK VXR(0x3f, 0x3ff, 1)
/* An X form instruction. */
@@ -1538,7 +1538,7 @@ extract_tbr (insn, dialect, invalid)
/* An X_MASK with the RA and RB fields fixed. */
#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
-/* An XRARB_MASK, but with the L bit clear. */
+/* An XRARB_MASK, but with the L bit clear. */
#define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16))
/* An X_MASK with the RT and RA fields fixed. */
@@ -2349,34 +2349,34 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{ "cau", OP(15), OP_MASK, PWRCOM, { RT,RA,SISIGNOPT } },
{ "subis", OP(15), OP_MASK, PPCCOM, { RT, RA, NSI } },
-{ "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } },
-{ "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } },
-{ "bdnz", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BD } },
-{ "bdn", BBO(16,BODNZ,0,0), BBOATBI_MASK, PWRCOM, { BD } },
-{ "bdnzl-", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } },
-{ "bdnzl+", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } },
-{ "bdnzl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BD } },
-{ "bdnl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PWRCOM, { BD } },
-{ "bdnza-", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } },
-{ "bdnza+", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } },
-{ "bdnza", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDA } },
-{ "bdna", BBO(16,BODNZ,1,0), BBOATBI_MASK, PWRCOM, { BDA } },
-{ "bdnzla-", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } },
-{ "bdnzla+", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } },
-{ "bdnzla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDA } },
-{ "bdnla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PWRCOM, { BDA } },
-{ "bdz-", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } },
-{ "bdz+", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } },
-{ "bdz", BBO(16,BODZ,0,0), BBOATBI_MASK, COM, { BD } },
-{ "bdzl-", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } },
-{ "bdzl+", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } },
-{ "bdzl", BBO(16,BODZ,0,1), BBOATBI_MASK, COM, { BD } },
-{ "bdza-", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } },
-{ "bdza+", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } },
-{ "bdza", BBO(16,BODZ,1,0), BBOATBI_MASK, COM, { BDA } },
-{ "bdzla-", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } },
-{ "bdzla+", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } },
-{ "bdzla", BBO(16,BODZ,1,1), BBOATBI_MASK, COM, { BDA } },
+{ "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } },
+{ "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } },
+{ "bdnz", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BD } },
+{ "bdn", BBO(16,BODNZ,0,0), BBOATBI_MASK, PWRCOM, { BD } },
+{ "bdnzl-", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } },
+{ "bdnzl+", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } },
+{ "bdnzl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BD } },
+{ "bdnl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PWRCOM, { BD } },
+{ "bdnza-", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } },
+{ "bdnza+", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } },
+{ "bdnza", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDA } },
+{ "bdna", BBO(16,BODNZ,1,0), BBOATBI_MASK, PWRCOM, { BDA } },
+{ "bdnzla-", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } },
+{ "bdnzla+", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } },
+{ "bdnzla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDA } },
+{ "bdnla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PWRCOM, { BDA } },
+{ "bdz-", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } },
+{ "bdz+", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } },
+{ "bdz", BBO(16,BODZ,0,0), BBOATBI_MASK, COM, { BD } },
+{ "bdzl-", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } },
+{ "bdzl+", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } },
+{ "bdzl", BBO(16,BODZ,0,1), BBOATBI_MASK, COM, { BD } },
+{ "bdza-", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } },
+{ "bdza+", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } },
+{ "bdza", BBO(16,BODZ,1,0), BBOATBI_MASK, COM, { BDA } },
+{ "bdzla-", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } },
+{ "bdzla+", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } },
+{ "bdzla", BBO(16,BODZ,1,1), BBOATBI_MASK, COM, { BDA } },
{ "blt-", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } },
{ "blt+", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } },
{ "blt", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } },
@@ -2625,7 +2625,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{ "ba", B(18,1,0), B_MASK, COM, { LIA } },
{ "bla", B(18,1,1), B_MASK, COM, { LIA } },
-{ "mcrf", XL(19,0), XLBB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } },
+{ "mcrf", XL(19,0), XLBB_MASK|(3 << 21)|(3 << 16), COM, { BF, BFA } },
{ "blr", XLO(19,BOU,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } },
{ "br", XLO(19,BOU,16,0), XLBOBIBB_MASK, PWRCOM, { 0 } },
@@ -2854,8 +2854,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{ "crnot", XL(19,33), XL_MASK, PPCCOM, { BT, BA, BBA } },
{ "crnor", XL(19,33), XL_MASK, COM, { BT, BA, BB } },
-{ "rfmci", X(19,38), 0xffffffff, PPCRFMCI, { 0 } },
-
+{ "rfmci", X(19,38), 0xffffffff, PPCRFMCI, { 0 } },
{ "rfi", XL(19,50), 0xffffffff, COM, { 0 } },
{ "rfci", XL(19,51), 0xffffffff, PPC403, { 0 } },
@@ -4230,6 +4229,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{ "tlbrehi", XTLB(31,946,0), XTLB_MASK, PPC403, { RT, RA } },
{ "tlbrelo", XTLB(31,946,1), XTLB_MASK, PPC403, { RT, RA } },
+{ "tlbre", X(31,946), X_MASK, PPC403, { RS, RA, SH } },
{ "sraiq", XRC(31,952,0), X_MASK, M601, { RA, RS, SH } },
{ "sraiq.", XRC(31,952,1), X_MASK, M601, { RA, RS, SH } },
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index 0e62569d378..6526a55c164 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-14 D.Venkatasubramanian <dvenkat@noida.hcltech.com>
+
+ * compile.c (decode): Added code for some more magic traps.
+ * compile.c (sim_resume): Added support for File I/O system
+ calls through callback to host_system.
+ System calls provided support for :
+ open, read, write, lseek, close, stat, fstat
+ Only basic support for stat and fstat.
+
2003-02-27 Andrew Cagney <cagney@redhat.com>
* compile.c (sim_open, sim_create_inferior): Rename _bfd to bfd.
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index cd60b86beb0..eb2a03f2f9f 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -35,6 +35,8 @@
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/sim-h8300.h"
+#include "sys/stat.h"
+#include "sys/types.h"
#ifndef SIGTRAP
# define SIGTRAP 5
@@ -447,14 +449,36 @@ decode (int addr, unsigned char *data, decoded_inst *dst)
dst->opcode = q->how;
dst->cycles = q->time;
- /* And a jsr to 0xc4 is turned into a magic trap. */
+ /* And a jsr to these locations are turned into magic
+ traps. */
if (dst->opcode == O (O_JSR, SB))
{
- if (dst->src.literal == 0xc4)
+ switch (dst->src.literal)
{
- dst->opcode = O (O_SYSCALL, SB);
+ case 0xc5:
+ dst->opcode = O (O_SYS_OPEN, SB);
+ break;
+ case 0xc6:
+ dst->opcode = O (O_SYS_READ, SB);
+ break;
+ case 0xc7:
+ dst->opcode = O (O_SYS_WRITE, SB);
+ break;
+ case 0xc8:
+ dst->opcode = O (O_SYS_LSEEK, SB);
+ break;
+ case 0xc9:
+ dst->opcode = O (O_SYS_CLOSE, SB);
+ break;
+ case 0xca:
+ dst->opcode = O (O_SYS_STAT, SB);
+ break;
+ case 0xcb:
+ dst->opcode = O (O_SYS_FSTAT, SB);
+ break;
}
+ /* End of Processing for system calls. */
}
dst->next_pc = addr + len / 2;
@@ -1386,12 +1410,289 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
goto condtrue;
goto next;
- case O (O_SYSCALL, SB):
+ /* System call processing starts. */
+ case O (O_SYS_OPEN, SB):
{
- char c = cpu.regs[2];
- sim_callback->write_stdout (sim_callback, &c, 1);
+ int len = 0; /* Length of filename. */
+ char *filename; /* Filename would go here. */
+ char temp_char; /* Temporary character */
+ int mode = 0; /* Mode bits for the file. */
+ int open_return; /* Return value of open, file descriptor. */
+ int i; /* Loop counter */
+ int filename_ptr; /* Pointer to filename in cpu memory. */
+
+ /* Setting filename_ptr to first argument of open. */
+ filename_ptr = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+
+ /* Trying to get mode. */
+ if (h8300hmode || h8300smode)
+ {
+ mode = GET_MEMORY_L (cpu.regs[7] + 4);
+ }
+ else
+ {
+ mode = GET_MEMORY_W (cpu.regs[7] + 2);
+ }
+
+ /* Trying to find the length of the filename. */
+ temp_char = GET_MEMORY_B (cpu.regs[0]);
+
+ len = 1;
+ while (temp_char != '\0')
+ {
+ temp_char = GET_MEMORY_B (filename_ptr + len);
+ len++;
+ }
+
+ /* Allocating space for the filename. */
+ filename = (char *) malloc (sizeof (char) * len);
+
+ /* String copying the filename from memory. */
+ for (i = 0; i < len; i++)
+ {
+ temp_char = GET_MEMORY_B (filename_ptr + i);
+ filename[i] = temp_char;
+ }
+
+ /* Callback to open and return the file descriptor. */
+ open_return = sim_callback->open (sim_callback, filename, mode);
+
+ /* Return value in register 0. */
+ cpu.regs[0] = open_return;
+
+ /* Freeing memory used for filename. */
+ free (filename);
+ }
+ goto next;
+
+ case O (O_SYS_READ, SB):
+ {
+ char *char_ptr; /* Where characters read would be stored. */
+ int fd; /* File descriptor */
+ int buf_size; /* BUF_SIZE parameter in read. */
+ int i = 0; /* Temporary Loop counter */
+ int read_return = 0; /* Return value from callback to
+ read. */
+
+ fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+ buf_size = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
+
+ char_ptr = (char *) malloc (sizeof (char) * buf_size);
+
+ /* Callback to read and return the no. of characters read. */
+ read_return =
+ sim_callback->read (sim_callback, fd, char_ptr, buf_size);
+
+ /* The characters read are stored in cpu memory. */
+ for (i = 0; i < buf_size; i++)
+ {
+ SET_MEMORY_B ((cpu.regs[1] + (sizeof (char) * i)),
+ *(char_ptr + (sizeof (char) * i)));
+ }
+
+ /* Return value in Register 0. */
+ cpu.regs[0] = read_return;
+
+ /* Freeing memory used as buffer. */
+ free (char_ptr);
+ }
+ goto next;
+
+ case O (O_SYS_WRITE, SB):
+ {
+ int fd; /* File descriptor */
+ char temp_char; /* Temporary character */
+ int len; /* Length of write, Parameter II to write. */
+ int char_ptr; /* Character Pointer, Parameter I of write. */
+ char *ptr; /* Where characters to be written are stored.
+ */
+ int write_return; /* Return value from callback to write. */
+ int i = 0; /* Loop counter */
+
+ fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+ char_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
+ len = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
+
+ /* Allocating space for the characters to be written. */
+ ptr = (char *) malloc (sizeof (char) * len);
+
+ /* Fetching the characters from cpu memory. */
+ for (i = 0; i < len; i++)
+ {
+ temp_char = GET_MEMORY_B (char_ptr + i);
+ ptr[i] = temp_char;
+ }
+
+ /* Callback write and return the no. of characters written. */
+ write_return = sim_callback->write (sim_callback, fd, ptr, len);
+
+ /* Return value in Register 0. */
+ cpu.regs[0] = write_return;
+
+ /* Freeing memory used as buffer. */
+ free (ptr);
+ }
+ goto next;
+
+ case O (O_SYS_LSEEK, SB):
+ {
+ int fd; /* File descriptor */
+ int offset; /* Offset */
+ int origin; /* Origin */
+ int lseek_return; /* Return value from callback to lseek. */
+
+ fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+ offset = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
+ origin = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
+
+ /* Callback lseek and return offset. */
+ lseek_return =
+ sim_callback->lseek (sim_callback, fd, offset, origin);
+
+ /* Return value in register 0. */
+ cpu.regs[0] = lseek_return;
+ }
+ goto next;
+
+ case O (O_SYS_CLOSE, SB):
+ {
+ int fd; /* File descriptor */
+ int close_return; /* Return value from callback to close. */
+
+ fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+
+ /* Callback close and return. */
+ close_return = sim_callback->close (sim_callback, fd);
+
+ /* Return value in register 0. */
+ cpu.regs[0] = close_return;
+ }
+ goto next;
+
+ case O (O_SYS_FSTAT, SB):
+ {
+ int fd; /* File descriptor */
+ struct stat stat_rec; /* Stat record */
+ int fstat_return; /* Return value from callback to stat. */
+ int stat_ptr; /* Pointer to stat record. */
+ char *temp_stat_ptr; /* Temporary stat_rec pointer. */
+
+ fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+
+ /* Setting stat_ptr to second argument of stat. */
+ stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
+
+ /* Callback stat and return. */
+ fstat_return = sim_callback->fstat (sim_callback, fd, &stat_rec);
+
+ /* Have stat_ptr point to starting of stat_rec. */
+ temp_stat_ptr = (char *) (&stat_rec);
+
+ /* Setting up the stat structure returned. */
+ SET_MEMORY_W (stat_ptr, stat_rec.st_dev);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_ino);
+ stat_ptr += 2;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_mode);
+ stat_ptr += 4;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_nlink);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_uid);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_gid);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_rdev);
+ stat_ptr += 2;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_size);
+ stat_ptr += 4;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_atime);
+ stat_ptr += 8;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_mtime);
+ stat_ptr += 8;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_ctime);
+
+ /* Return value in register 0. */
+ cpu.regs[0] = fstat_return;
+ }
+ goto next;
+
+ case O (O_SYS_STAT, SB):
+ {
+ int len = 0; /* Length of filename. */
+ char *filename; /* Filename would go here. */
+ char temp_char; /* Temporary character */
+ int filename_ptr; /* Pointer to filename in cpu memory. */
+ struct stat stat_rec; /* Stat record */
+ int stat_return; /* Return value from callback to stat */
+ int stat_ptr; /* Pointer to stat record. */
+ char *temp_stat_ptr; /* Temporary stat_rec pointer. */
+ int i = 0; /* Loop Counter */
+
+ /* Setting filename_ptr to first argument of open. */
+ filename_ptr = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
+
+ /* Trying to find the length of the filename. */
+ temp_char = GET_MEMORY_B (cpu.regs[0]);
+
+ len = 1;
+ while (temp_char != '\0')
+ {
+ temp_char = GET_MEMORY_B (filename_ptr + len);
+ len++;
+ }
+
+ /* Allocating space for the filename. */
+ filename = (char *) malloc (sizeof (char) * len);
+
+ /* String copying the filename from memory. */
+ for (i = 0; i < len; i++)
+ {
+ temp_char = GET_MEMORY_B (filename_ptr + i);
+ filename[i] = temp_char;
+ }
+
+ /* Setting stat_ptr to second argument of stat. */
+ /* stat_ptr = cpu.regs[1]; */
+ stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
+
+ /* Callback stat and return. */
+ stat_return =
+ sim_callback->stat (sim_callback, filename, &stat_rec);
+
+ /* Have stat_ptr point to starting of stat_rec. */
+ temp_stat_ptr = (char *) (&stat_rec);
+
+ /* Freeing memory used for filename. */
+ free (filename);
+
+ /* Setting up the stat structure returned. */
+ SET_MEMORY_W (stat_ptr, stat_rec.st_dev);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_ino);
+ stat_ptr += 2;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_mode);
+ stat_ptr += 4;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_nlink);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_uid);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_gid);
+ stat_ptr += 2;
+ SET_MEMORY_W (stat_ptr, stat_rec.st_rdev);
+ stat_ptr += 2;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_size);
+ stat_ptr += 4;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_atime);
+ stat_ptr += 8;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_mtime);
+ stat_ptr += 8;
+ SET_MEMORY_L (stat_ptr, stat_rec.st_ctime);
+
+ /* Return value in register 0. */
+ cpu.regs[0] = stat_return;
}
goto next;
+ /* End of system call processing. */
ONOT (O_NOT, rd = ~rd; v = 0;);
OSHIFTS (O_SHLL,