* [PATCH 3/5] sim: sh: fix broken handling in DSR reg
2015-03-28 21:46 [PATCH 1/5] sim: sh: use common configure options Mike Frysinger
@ 2015-03-28 21:45 ` Mike Frysinger
2015-03-28 21:46 ` [PATCH 4/5] sim: sh: clean up some warnings Mike Frysinger
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-03-28 21:45 UTC (permalink / raw)
To: gdb-patches
A missing */ caused a case statement to be incorrect masked out which
also hide an error where the wrong value was being checked. Fix both.
Committed.
---
sim/sh/ChangeLog | 4 ++++
sim/sh/gencode.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 3e0fff1..46b8e53 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,5 +1,9 @@
2015-03-28 Mike Frysinger <vapier@gentoo.org>
+ * gencode.c (ppi_gensim): Add missing */. Change case 4 to case 5.
+
+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
* Makefile.in (gencode): Add $(BUILD_CFLAGS), $(BUILD_LDFLAGS),
and $(WARN_CFLAGS).
* gencode.c: Include ctype.h, stdlib.h, string.h, and unistd.h.
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index 0fb1b87..bcaeb6c 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -3359,11 +3359,11 @@ ppi_gensim (void)
printf (" DSR |= res_grd >> 7 & 1;\n");
printf (" case 2: /* Zero Value Mode */\n");
printf (" DSR |= DSR >> 6 & 1;\n");
- printf (" case 3: /* Overflow mode\n");
+ printf (" case 3: /* Overflow mode */\n");
printf (" DSR |= overflow >> 4;\n");
printf (" case 4: /* Signed Greater Than Mode */\n");
printf (" DSR |= DSR >> 7 & 1;\n");
- printf (" case 4: /* Signed Greater Than Or Equal Mode */\n");
+ printf (" case 5: /* Signed Greater Than Or Equal Mode */\n");
printf (" DSR |= greater_equal >> 7;\n");
printf (" }\n");
printf (" assign_z:\n");
--
2.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/5] sim: sh: use common configure options
@ 2015-03-28 21:46 Mike Frysinger
2015-03-28 21:45 ` [PATCH 3/5] sim: sh: fix broken handling in DSR reg Mike Frysinger
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-03-28 21:46 UTC (permalink / raw)
To: gdb-patches
In preparation for converting to nrun, call the common functions that
are needed. This also produces a bunch of warnings, but one thing at
a time.
Committed.
---
sim/sh/ChangeLog | 7 +
sim/sh/config.in | 15 ++
sim/sh/configure | 528 +++++++++++++++++++++++++++++++++++++++++++++++++++-
sim/sh/configure.ac | 7 +
4 files changed, 555 insertions(+), 2 deletions(-)
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 674a676..810049e 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
+ * config.in, configure: Regenerate.
+ * configure.ac: Call SIM_AC_OPTION_ENDIAN, SIM_AC_OPTION_ALIGNMENT,
+ SIM_AC_OPTION_HOSTENDIAN, SIM_AC_OPTION_ENVIRONMENT,
+ SIM_AC_OPTION_INLINE, SIM_AC_OPTION_WARNINGS.
+
2015-03-16 Mike Frysinger <vapier@gentoo.org>
* config.in, configure: Regenerate.
diff --git a/sim/sh/config.in b/sim/sh/config.in
index 5ded703..6003e58 100644
--- a/sim/sh/config.in
+++ b/sim/sh/config.in
@@ -1,5 +1,8 @@
/* config.in. Generated from configure.ac by autoheader. */
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
@@ -135,6 +138,18 @@
#endif
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+# undef WORDS_BIGENDIAN
+# endif
+#endif
+
/* Define to 1 if on MINIX. */
#undef _MINIX
diff --git a/sim/sh/configure b/sim/sh/configure
index fa26277..af6e579 100755
--- a/sim/sh/configure
+++ b/sim/sh/configure
@@ -759,6 +759,14 @@ enable_sim_trace
enable_sim_profile
with_pkgversion
with_bugurl
+enable_sim_endian
+enable_sim_alignment
+enable_sim_hostendian
+enable_sim_environment
+enable_sim_inline
+enable_werror
+enable_build_warnings
+enable_sim_build_warnings
'
ac_precious_vars='build_alias
host_alias
@@ -1401,6 +1409,16 @@ Optional Features:
--enable-sim-stdio Specify whether to use stdio for console input/output.
--enable-sim-trace=opts Enable tracing flags
--enable-sim-profile=opts Enable profiling flags
+ --enable-sim-endian=endian Specify target byte endian orientation.
+ --enable-sim-alignment=align Specify strict, nonstrict or forced alignment of memory accesses.
+ --enable-sim-hostendian=end Specify host byte endian orientation.
+ --enable-sim-environment=environment Specify mixed, user, virtual or operating environment.
+ --enable-sim-inline=inlines Specify which functions should be inlined.
+ --enable-werror treat compile warnings as errors
+ --enable-build-warnings enable build-time compiler warnings if gcc is used
+ --enable-sim-build-warnings
+ enable SIM specific build-time compiler warnings if
+ gcc is used
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -12354,7 +12372,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12357 "configure"
+#line 12375 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12460,7 +12478,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12463 "configure"
+#line 12481 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12951,6 +12969,511 @@ sim_link_links="${sim_link_links} targ-vals.def"
+wire_endian=""
+default_endian=""
+# Check whether --enable-sim-endian was given.
+if test "${enable_sim_endian+set}" = set; then :
+ enableval=$enable_sim_endian; case "${enableval}" in
+ b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
+ l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
+ yes) if test x"$wire_endian" != x; then
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+ else
+ if test x"$default_endian" != x; then
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
+ else
+ echo "No hard-wired endian for target $target" 1>&6
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
+ fi
+ fi;;
+ no) if test x"$default_endian" != x; then
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+ else
+ if test x"$wire_endian" != x; then
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
+ else
+ echo "No default endian for target $target" 1>&6
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
+ fi
+ fi;;
+ *) as_fn_error "\"Unknown value $enableval for --enable-sim-endian\"" "$LINENO" 5; sim_endian="";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
+ echo "Setting endian flags = $sim_endian" 6>&1
+fi
+else
+ if test x"$default_endian" != x; then
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+else
+ if test x"$wire_endian" != x; then
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+ else
+ sim_endian=
+ fi
+fi
+fi
+
+wire_alignment="STRICT_ALIGNMENT"
+default_alignment="STRICT_ALIGNMENT"
+
+# Check whether --enable-sim-alignment was given.
+if test "${enable_sim_alignment+set}" = set; then :
+ enableval=$enable_sim_alignment; case "${enableval}" in
+ strict | STRICT) sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
+ nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
+ forced | FORCED) sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
+ yes) if test x"$wire_alignment" != x; then
+ sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
+ else
+ if test x"$default_alignment" != x; then
+ sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
+ else
+ echo "No hard-wired alignment for target $target" 1>&6
+ sim_alignment="-DWITH_ALIGNMENT=0"
+ fi
+ fi;;
+ no) if test x"$default_alignment" != x; then
+ sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
+ else
+ if test x"$wire_alignment" != x; then
+ sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
+ else
+ echo "No default alignment for target $target" 1>&6
+ sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
+ fi
+ fi;;
+ *) as_fn_error "\"Unknown value $enableval passed to --enable-sim-alignment\"" "$LINENO" 5; sim_alignment="";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
+ echo "Setting alignment flags = $sim_alignment" 6>&1
+fi
+else
+ if test x"$default_alignment" != x; then
+ sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
+else
+ if test x"$wire_alignment" != x; then
+ sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
+ else
+ sim_alignment=
+ fi
+fi
+fi
+
+
+# Check whether --enable-sim-hostendian was given.
+if test "${enable_sim_hostendian+set}" = set; then :
+ enableval=$enable_sim_hostendian; case "${enableval}" in
+ no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
+ b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
+ l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
+ *) as_fn_error "\"Unknown value $enableval for --enable-sim-hostendian\"" "$LINENO" 5; sim_hostendian="";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
+ echo "Setting hostendian flags = $sim_hostendian" 6>&1
+fi
+else
+
+if test "x$cross_compiling" = "xno"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if test "${ac_cv_c_bigendian+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_bigendian=unknown
+ # See if we're dealing with a universal compiler.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifndef __APPLE_CC__
+ not a universal capable compiler
+ #endif
+ typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ # Check for potential -arch flags. It is not universal unless
+ # there are at least two -arch flags with different values.
+ ac_arch=
+ ac_prev=
+ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
+ if test -n "$ac_prev"; then
+ case $ac_word in
+ i?86 | x86_64 | ppc | ppc64)
+ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
+ ac_arch=$ac_word
+ else
+ ac_cv_c_bigendian=universal
+ break
+ fi
+ ;;
+ esac
+ ac_prev=
+ elif test "x$ac_word" = "x-arch"; then
+ ac_prev=arch
+ fi
+ done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if sys/param.h defines the BYTE_ORDER macro.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+ && LITTLE_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to _BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # Compile a test program.
+ if test "$cross_compiling" = yes; then :
+ # Try to guess by grepping values from an object file.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+short int ascii_mm[] =
+ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+ short int ascii_ii[] =
+ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+ int use_ascii (int i) {
+ return ascii_mm[i] + ascii_ii[i];
+ }
+ short int ebcdic_ii[] =
+ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+ short int ebcdic_mm[] =
+ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+ int use_ebcdic (int i) {
+ return ebcdic_mm[i] + ebcdic_ii[i];
+ }
+ extern int foo;
+
+int
+main ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+ ac_cv_c_bigendian=yes
+ fi
+ if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+ if test "$ac_cv_c_bigendian" = unknown; then
+ ac_cv_c_bigendian=no
+ else
+ # finding both strings is unlikely to happen, but who knows?
+ ac_cv_c_bigendian=unknown
+ fi
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long int l;
+ char c[sizeof (long int)];
+ } u;
+ u.l = 1;
+ return u.c[sizeof (long int) - 1] == 1;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_c_bigendian=no
+else
+ ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+ yes)
+ $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+;; #(
+ no)
+ ;; #(
+ universal)
+
+$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+ ;; #(
+ *)
+ as_fn_error "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
+
+ if test $ac_cv_c_bigendian = yes; then
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
+ else
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
+ fi
+else
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
+fi
+fi
+
+
+# Check whether --enable-sim-environment was given.
+if test "${enable_sim_environment+set}" = set; then :
+ enableval=$enable_sim_environment; case "${enableval}" in
+ all | ALL) sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT";;
+ user | USER) sim_environment="-DWITH_ENVIRONMENT=USER_ENVIRONMENT";;
+ virtual | VIRTUAL) sim_environment="-DWITH_ENVIRONMENT=VIRTUAL_ENVIRONMENT";;
+ operating | OPERATING) sim_environment="-DWITH_ENVIRONMENT=OPERATING_ENVIRONMENT";;
+ *) as_fn_error "\"Unknown value $enableval passed to --enable-sim-environment\"" "$LINENO" 5;
+ sim_environment="";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_environment" != x""; then
+ echo "Setting sim environment = $sim_environment" 6>&1
+fi
+else
+ sim_environment="-DWITH_ENVIRONMENT=ALL_ENVIRONMENT"
+fi
+
+
+default_sim_inline=""
+# Check whether --enable-sim-inline was given.
+if test "${enable_sim_inline+set}" = set; then :
+ enableval=$enable_sim_inline; sim_inline=""
+case "$enableval" in
+ no) sim_inline="-DDEFAULT_INLINE=0";;
+ 0) sim_inline="-DDEFAULT_INLINE=0";;
+ yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";;
+ 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";;
+ *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
+ new_flag=""
+ case "$x" in
+ *_INLINE=*) new_flag="-D$x";;
+ *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
+ *_INLINE) new_flag="-D$x=ALL_C_INLINE";;
+ *) new_flag="-D$x""_INLINE=ALL_C_INLINE";;
+ esac
+ if test x"$sim_inline" = x""; then
+ sim_inline="$new_flag"
+ else
+ sim_inline="$sim_inline $new_flag"
+ fi
+ done;;
+esac
+if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
+ echo "Setting inline flags = $sim_inline" 6>&1
+fi
+else
+
+if test "x$cross_compiling" = "xno"; then
+ if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then
+ sim_inline="${default_sim_inline}"
+ if test x"$silent" != x"yes"; then
+ echo "Setting inline flags = $sim_inline" 6>&1
+ fi
+ else
+ sim_inline=""
+ fi
+else
+ sim_inline="-DDEFAULT_INLINE=0"
+fi
+fi
+
+
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+ enableval=$enable_werror; case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) as_fn_error "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;;
+ esac
+fi
+
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+# NOTE: Disabled in the sim dir due to most sims generating warnings.
+# WERROR_CFLAGS="-Werror"
+ true
+fi
+
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wpointer-sign \
+-Wno-unused -Wunused-value -Wunused-function \
+-Wno-switch -Wno-char-subscripts -Wmissing-prototypes
+-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
+-Wold-style-declaration -Wold-style-definition"
+
+# Enable -Wno-format by default when using gcc on mingw since many
+# GCC versions complain about %I64.
+case "${host}" in
+ *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
+ *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+esac
+
+# Check whether --enable-build-warnings was given.
+if test "${enable_build_warnings+set}" = set; then :
+ enableval=$enable_build_warnings; case "${enableval}" in
+ yes) ;;
+ no) build_warnings="-w";;
+ ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${build_warnings} ${t}";;
+ *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${t} ${build_warnings}";;
+ *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+esac
+if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
+ echo "Setting compiler warning flags = $build_warnings" 6>&1
+fi
+fi
+# Check whether --enable-sim-build-warnings was given.
+if test "${enable_sim_build_warnings+set}" = set; then :
+ enableval=$enable_sim_build_warnings; case "${enableval}" in
+ yes) ;;
+ no) build_warnings="-w";;
+ ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${build_warnings} ${t}";;
+ *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${t} ${build_warnings}";;
+ *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+esac
+if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
+ echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
+fi
+fi
+WARN_CFLAGS=""
+if test "x${build_warnings}" != x -a "x$GCC" = xyes
+then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
+$as_echo_n "checking compiler warning flags... " >&6; }
+ # Separate out the -Werror flag as some files just cannot be
+ # compiled with it enabled.
+ for w in ${build_warnings}; do
+ case $w in
+ -Werr*) WERROR_CFLAGS=-Werror ;;
+ *) # Check that GCC accepts it
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $w"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$saved_CFLAGS"
+ esac
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
+$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
+fi
+
+
+
ac_sources="$sim_link_files"
ac_dests="$sim_link_links"
while test -n "$ac_sources"; do
@@ -13085,6 +13608,7 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
diff --git a/sim/sh/configure.ac b/sim/sh/configure.ac
index 799a5df..96d0ffd 100644
--- a/sim/sh/configure.ac
+++ b/sim/sh/configure.ac
@@ -5,4 +5,11 @@ sinclude(../common/acinclude.m4)
SIM_AC_COMMON
+SIM_AC_OPTION_ENDIAN
+SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
+SIM_AC_OPTION_HOSTENDIAN
+SIM_AC_OPTION_ENVIRONMENT
+SIM_AC_OPTION_INLINE
+SIM_AC_OPTION_WARNINGS
+
SIM_AC_OUTPUT
--
2.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/5] sim: sh: clean up gencode
2015-03-28 21:46 [PATCH 1/5] sim: sh: use common configure options Mike Frysinger
2015-03-28 21:45 ` [PATCH 3/5] sim: sh: fix broken handling in DSR reg Mike Frysinger
2015-03-28 21:46 ` [PATCH 4/5] sim: sh: clean up some warnings Mike Frysinger
@ 2015-03-28 21:46 ` Mike Frysinger
2015-03-28 21:55 ` [PATCH 5/5] sim: sh: convert to nrun Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-03-28 21:46 UTC (permalink / raw)
To: gdb-patches
The build line was missing the normal BUILD_xxx flags. Once we added
that, we get warnings that weren't shown before. As we fix those, we
notice that the -d option segfaults because it tries to write readonly
memory. Fix that too as part of the const/prototype clean up.
Committed.
---
sim/sh/ChangeLog | 22 ++++++++++++
sim/sh/Makefile.in | 3 +-
sim/sh/gencode.c | 104 +++++++++++++++++++----------------------------------
3 files changed, 61 insertions(+), 68 deletions(-)
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 810049e..3e0fff1 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,5 +1,27 @@
2015-03-28 Mike Frysinger <vapier@gentoo.org>
+ * Makefile.in (gencode): Add $(BUILD_CFLAGS), $(BUILD_LDFLAGS),
+ and $(WARN_CFLAGS).
+ * gencode.c: Include ctype.h, stdlib.h, string.h, and unistd.h.
+ (struct op): Mark members const.
+ (tab): Mark static.
+ (nibble_type_list): Mark const.
+ (arg_type_list): Mark const.
+ (make_enum_list): Delete unused func.
+ (qfunc, expand_opcode, dumptable, expand_ppi_code): Convert old
+ style prototype and mark args const.
+ (sorttab, gengastab, conflict_warn, filltable, expand_ppi_movxy,
+ gensim, ppi_filltable): Convert old style prototype.
+ (gensim_caselist): Convert old style prototype. Mark local
+ variables s and r const.
+ (gendefines): Convert old style prototype. Mark s const. Move
+ tolower call into printf statement.
+ (ppi_gensim): Convert old style prototype. Mark local variable
+ s const.
+ (main): Convert old style prototype. Change printf %d to %zu.
+
+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
* config.in, configure: Regenerate.
* configure.ac: Call SIM_AC_OPTION_ENDIAN, SIM_AC_OPTION_ALIGNMENT,
SIM_AC_OPTION_HOSTENDIAN, SIM_AC_OPTION_ENVIRONMENT,
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index 61422ab..0594a6e 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -41,7 +41,8 @@ ppi.c: gencode
./gencode -p >ppi.c
gencode: gencode.c
- $(CC_FOR_BUILD) -o gencode $(srcdir)/gencode.c
+ $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) $(WARN_CFLAGS) \
+ -o gencode $(srcdir)/gencode.c
sh-clean:
rm -f gencode code.c table.c
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index bc65604..0fb1b87 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -30,22 +30,26 @@
*/
+#include <ctype.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#define MAX_NR_STUFF 42
typedef struct
{
- char *defs;
- char *refs;
- char *name;
- char *code;
- char *stuff[MAX_NR_STUFF];
+ const char *defs;
+ const char *refs;
+ const char *name;
+ const char *code;
+ const char * const stuff[MAX_NR_STUFF];
int index;
} op;
-op tab[] =
+static op tab[] =
{
{ "n", "", "add #<imm>,<REG_N>", "0111nnnni8*1....",
@@ -2462,7 +2466,8 @@ op ppi_tab[] =
};
/* Tables of things to put into enums for sh-opc.h */
-static char *nibble_type_list[] =
+static
+const char * const nibble_type_list[] =
{
"HEX_0",
"HEX_1",
@@ -2497,7 +2502,7 @@ static char *nibble_type_list[] =
0
};
static
-char *arg_type_list[] =
+const char * const arg_type_list[] =
{
"A_END",
"A_BDISP12",
@@ -2530,27 +2535,11 @@ char *arg_type_list[] =
0,
};
-static void
-make_enum_list (name, s)
- char *name;
- char **s;
-{
- int i = 1;
- printf ("typedef enum {\n");
- while (*s)
- {
- printf ("\t%s,\n", *s);
- s++;
- i++;
- }
- printf ("} %s;\n", name);
-}
-
static int
-qfunc (a, b)
- op *a;
- op *b;
+qfunc (const void *va, const void *vb)
{
+ const op *a = va;
+ const op *b = vb;
char bufa[9];
char bufb[9];
int diff;
@@ -2569,7 +2558,7 @@ qfunc (a, b)
}
static void
-sorttab ()
+sorttab (void)
{
op *p = tab;
int len = 0;
@@ -2583,7 +2572,7 @@ sorttab ()
}
static void
-gengastab ()
+gengastab (void)
{
op *p;
sorttab ();
@@ -2598,9 +2587,7 @@ static unsigned short table[1 << 16];
static int warn_conflicts = 0;
static void
-conflict_warn (val, i)
- int val;
- int i;
+conflict_warn (int val, int i)
{
int ix, key;
int j = table[val];
@@ -2651,10 +2638,7 @@ conflict_warn (val, i)
right entries in 'table' with the opcode index. */
static void
-expand_opcode (val, i, s)
- int val;
- int i;
- char *s;
+expand_opcode (int val, int i, const char *s)
{
if (*s == 0)
{
@@ -2779,10 +2763,7 @@ expand_opcode (val, i, s)
statement entry. */
static void
-dumptable (name, size, start)
- char *name;
- int size;
- int start;
+dumptable (const char *name, int size, int start)
{
int lump = 256;
int online = 16;
@@ -2817,8 +2798,7 @@ dumptable (name, size, start)
static void
-filltable (p)
- op *p;
+filltable (op *p)
{
static int index = 1;
@@ -2835,7 +2815,7 @@ filltable (p)
processing insns (ppi) for code 0xf800 (ppi nopx nopy). Copy the
latter tag to represent all combinations of ppi with ddt. */
static void
-expand_ppi_movxy ()
+expand_ppi_movxy (void)
{
int i;
@@ -2845,8 +2825,7 @@ expand_ppi_movxy ()
}
static void
-gensim_caselist (p)
- op *p;
+gensim_caselist (op *p)
{
for (; p->name; p++)
{
@@ -2854,8 +2833,7 @@ gensim_caselist (p)
int sextbit = -1;
int needm = 0;
int needn = 0;
-
- char *s = p->code;
+ const char *s = p->code;
printf (" /* %s %s */\n", p->name, p->code);
printf (" case %d: \n", p->index);
@@ -3038,7 +3016,7 @@ gensim_caselist (p)
{
/* Do the refs. */
- char *r;
+ const char *r;
for (r = p->refs; *r; r++)
{
if (*r == 'f') printf (" CREF (15);\n");
@@ -3080,7 +3058,7 @@ gensim_caselist (p)
{
/* Do the defs. */
- char *r;
+ const char *r;
for (r = p->defs; *r; r++)
{
if (*r == 'f') printf (" CDEF (15);\n");
@@ -3114,7 +3092,7 @@ gensim_caselist (p)
}
static void
-gensim ()
+gensim (void)
{
printf ("{\n");
printf ("/* REG_xy = [r4, r5, r0, r1]. */\n");
@@ -3143,19 +3121,17 @@ gensim ()
}
static void
-gendefines ()
+gendefines (void)
{
op *p;
filltable (tab);
for (p = tab; p->name; p++)
{
- char *s = p->name;
+ const char *s = p->name;
printf ("#define OPC_");
while (*s) {
- if (isupper (*s))
- *s = tolower (*s);
if (isalpha (*s))
- printf ("%c", *s);
+ printf ("%c", tolower (*s));
if (*s == ' ')
printf ("_");
if (*s == '@')
@@ -3175,10 +3151,7 @@ static int ppi_index;
NOTE: tail recursion optimization removed for simplicity. */
static void
-expand_ppi_code (val, i, s)
- int val;
- int i;
- char *s;
+expand_ppi_code (int val, int i, const char *s)
{
int j;
@@ -3223,7 +3196,7 @@ expand_ppi_code (val, i, s)
}
static void
-ppi_filltable ()
+ppi_filltable (void)
{
op *p;
ppi_index = 1;
@@ -3236,7 +3209,7 @@ ppi_filltable ()
}
static void
-ppi_gensim ()
+ppi_gensim (void)
{
op *p = ppi_tab;
@@ -3294,8 +3267,7 @@ ppi_gensim ()
int shift, j;
int cond = 0;
int havedecl = 0;
-
- char *s = p->code;
+ const char *s = p->code;
printf (" /* %s %s */\n", p->name, p->code);
printf (" case %d: \n", p->index);
@@ -3406,9 +3378,7 @@ ppi_gensim ()
}
int
-main (ac, av)
- int ac;
- char **av;
+main (int ac, char *av[])
{
/* Verify the table before anything else. */
{
@@ -3418,7 +3388,7 @@ main (ac, av)
/* Check that the code field contains 16 bits. */
if (strlen (p->code) != 16)
{
- fprintf (stderr, "Code `%s' length wrong (%d) for `%s'\n",
+ fprintf (stderr, "Code `%s' length wrong (%zu) for `%s'\n",
p->code, strlen (p->code), p->name);
abort ();
}
--
2.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/5] sim: sh: clean up some warnings
2015-03-28 21:46 [PATCH 1/5] sim: sh: use common configure options Mike Frysinger
2015-03-28 21:45 ` [PATCH 3/5] sim: sh: fix broken handling in DSR reg Mike Frysinger
@ 2015-03-28 21:46 ` Mike Frysinger
2015-03-28 21:46 ` [PATCH 2/5] sim: sh: clean up gencode Mike Frysinger
2015-03-28 21:55 ` [PATCH 5/5] sim: sh: convert to nrun Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-03-28 21:46 UTC (permalink / raw)
To: gdb-patches
Mostly converting old style prototypes. Also include a few missing
headers, and add static/casts where appropriate.
Committed.
---
sim/sh/ChangeLog | 32 ++++++
sim/sh/gencode.c | 3 +-
sim/sh/interp.c | 307 ++++++++++++++++++-------------------------------------
3 files changed, 131 insertions(+), 211 deletions(-)
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 46b8e53..0ee6dac 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,5 +1,37 @@
2015-03-28 Mike Frysinger <vapier@gentoo.org>
+ * gencode.c (ppi_gensim): Convert old style prototype with ppi_insn.
+ * interp.c: Include ctype.h and run-sim.h.
+ [HAVE_TIME_H]: Include time.h
+ [HAVE_SYS_TIME_H]: Include sys/time.h
+ [!_WIN32]: Include utime.h and sys/wait.h.
+ (set_fpscr1, raise_exception, raise_buserror, get_dr, set_dr, set_sr,
+ do_rdat, do_wdat, process_wlat_addr, process_wwat_addr,
+ process_wbat_addr, process_rlat_addr, process_rwat_addr,
+ process_rbat_addr, IOMEM, get_now, now_persec, swapout, swapout16,
+ ptr, strswaplen, strnswap, dmul, macw, macl, get_loop_bounds_ext,
+ get_loop_bounds, sim_size, init_dsp, init_pointers, dump_profile,
+ gotcall, sim_stop, sim_write, sim_read, sim_store_register,
+ sim_fetch_register, sim_trace, sim_stop_reason, sim_info,
+ sim_set_profile, sim_set_profile_size, sim_open,
+ parse_and_set_memory_size, sim_close, sim_load, sim_create_inferior,
+ sim_do_command, sim_set_callbacks): Convert old style prototype.
+ (fail): Delete unused function.
+ (wlat_fast, wwat_fast, wbat_fast, rlat_fast, rwat_fast, rbat_fast):
+ Delete unused prototypes.
+ (wlat_fast, wwat_fast, wbat_fast, rlat_fast, rwat_fast, rbat_fast,
+ swap, swap16):
+ Convert old style prototype and move INLINE before the type.
+ (trap): Convert old style prototype. Add casts to wait and sim_write
+ calls.
+ (div1): Convert old style prototype. Change return to void.
+ (do_long_move_insn, do_blog_insn, fsca_s, fsrra_s, mcalloc): Mark
+ static.
+ (sim_resume): Convert old style prototype. Align printf format and
+ args.
+
+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
* gencode.c (ppi_gensim): Add missing */. Change case 4 to case 5.
2015-03-28 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index bcaeb6c..aa26e6c 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -3240,8 +3240,7 @@ ppi_gensim (void)
printf (" (greater_equal = ~(overflow << 3 & res_grd) & DSR_MASK_G)\n");
printf ("\n");
printf ("static void\n");
- printf ("ppi_insn (iword)\n");
- printf (" int iword;\n");
+ printf ("ppi_insn (int iword)\n");
printf ("{\n");
printf (" /* 'ee' = [x0, x1, y0, a1] */\n");
printf (" static char e_tab[] = { 8, 9, 10, 5};\n");
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index c854174..adf05ee 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
@@ -51,11 +52,22 @@
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifndef _WIN32
+#include <utime.h>
+#include <sys/wait.h>
+#endif
#include "bfd.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/sim-sh.h"
+#include "run-sim.h"
/* This file is local - if newlib changes, then so should this. */
#include "syscall.h"
@@ -345,8 +357,7 @@ count_argc (char **argv)
}
static void
-set_fpscr1 (x)
- int x;
+set_fpscr1 (int x)
{
int old = saved_state.asregs.sregs.named.fpscr;
saved_state.asregs.sregs.named.fpscr = (x);
@@ -370,12 +381,6 @@ do { \
#define DSR (saved_state.asregs.sregs.named.fpscr)
-int
-fail ()
-{
- abort ();
-}
-
#define RAISE_EXCEPTION(x) \
(saved_state.asregs.exception = x, saved_state.asregs.insn_end = 0)
@@ -385,15 +390,14 @@ fail ()
/* This function exists mainly for the purpose of setting a breakpoint to
catch simulated bus errors when running the simulator under GDB. */
-void
-raise_exception (x)
- int x;
+static void
+raise_exception (int x)
{
RAISE_EXCEPTION (x);
}
-void
-raise_buserror ()
+static void
+raise_buserror (void)
{
raise_exception (SIGBUS);
}
@@ -483,12 +487,6 @@ static void process_wbat_addr (int, int);
static int process_rlat_addr (int);
static int process_rwat_addr (int);
static int process_rbat_addr (int);
-static void INLINE wlat_fast (unsigned char *, int, int, int);
-static void INLINE wwat_fast (unsigned char *, int, int, int, int);
-static void INLINE wbat_fast (unsigned char *, int, int, int);
-static int INLINE rlat_fast (unsigned char *, int, int);
-static int INLINE rwat_fast (unsigned char *, int, int, int);
-static int INLINE rbat_fast (unsigned char *, int, int);
static host_callback *callback;
@@ -498,8 +496,7 @@ static host_callback *callback;
#define DR(n) (get_dr (n))
static double
-get_dr (n)
- int n;
+get_dr (int n)
{
n = (n & ~1);
if (host_little_endian)
@@ -519,9 +516,7 @@ get_dr (n)
#define SET_DR(n, EXP) set_dr ((n), (EXP))
static void
-set_dr (n, exp)
- int n;
- double exp;
+set_dr (int n, double exp)
{
n = (n & ~1);
if (host_little_endian)
@@ -614,8 +609,7 @@ set_dr (n, exp)
} while (0)
static void
-set_sr (new_sr)
- int new_sr;
+set_sr (int new_sr)
{
/* do we need to swap banks */
int old_gpr = SR_MD && SR_RB;
@@ -634,9 +628,8 @@ set_sr (new_sr)
SET_MOD (MOD);
}
-static void INLINE
-wlat_fast (memory, x, value, maskl)
- unsigned char *memory;
+static INLINE void
+wlat_fast (unsigned char *memory, int x, int value, int maskl)
{
int v = value;
unsigned int *p = (unsigned int *) (memory + x);
@@ -644,9 +637,8 @@ wlat_fast (memory, x, value, maskl)
*p = v;
}
-static void INLINE
-wwat_fast (memory, x, value, maskw, endianw)
- unsigned char *memory;
+static INLINE void
+wwat_fast (unsigned char *memory, int x, int value, int maskw, int endianw)
{
int v = value;
unsigned short *p = (unsigned short *) (memory + (x ^ endianw));
@@ -654,9 +646,8 @@ wwat_fast (memory, x, value, maskw, endianw)
*p = v;
}
-static void INLINE
-wbat_fast (memory, x, value, maskb)
- unsigned char *memory;
+static INLINE void
+wbat_fast (unsigned char *memory, int x, int value, int maskb)
{
unsigned char *p = memory + (x ^ endianb);
WRITE_BUSERROR (x, maskb, value, process_wbat_addr);
@@ -666,9 +657,8 @@ wbat_fast (memory, x, value, maskb)
/* Read functions */
-static int INLINE
-rlat_fast (memory, x, maskl)
- unsigned char *memory;
+static INLINE int
+rlat_fast (unsigned char *memory, int x, int maskl)
{
unsigned int *p = (unsigned int *) (memory + x);
READ_BUSERROR (x, maskl, process_rlat_addr);
@@ -676,10 +666,8 @@ rlat_fast (memory, x, maskl)
return *p;
}
-static int INLINE
-rwat_fast (memory, x, maskw, endianw)
- unsigned char *memory;
- int x, maskw, endianw;
+static INLINE int
+rwat_fast (unsigned char *memory, int x, int maskw, int endianw)
{
unsigned short *p = (unsigned short *) (memory + (x ^ endianw));
READ_BUSERROR (x, maskw, process_rwat_addr);
@@ -687,18 +675,16 @@ rwat_fast (memory, x, maskw, endianw)
return *p;
}
-static int INLINE
-riat_fast (insn_ptr, endianw)
- unsigned char *insn_ptr;
+static INLINE int
+riat_fast (unsigned char *insn_ptr, int endianw)
{
unsigned short *p = (unsigned short *) ((size_t) insn_ptr ^ endianw);
return *p;
}
-static int INLINE
-rbat_fast (memory, x, maskb)
- unsigned char *memory;
+static INLINE int
+rbat_fast (unsigned char *memory, int x, int maskb)
{
unsigned char *p = memory + (x ^ endianb);
READ_BUSERROR (x, maskb, process_rbat_addr);
@@ -721,11 +707,7 @@ rbat_fast (memory, x, maskb)
#define RDAT(x, n) (do_rdat (memory, (x), (n), (maskl)))
static int
-do_rdat (memory, x, n, maskl)
- char *memory;
- int x;
- int n;
- int maskl;
+do_rdat (unsigned char *memory, int x, int n, int maskl)
{
int f0;
int f1;
@@ -740,11 +722,7 @@ do_rdat (memory, x, n, maskl)
#define WDAT(x, n) (do_wdat (memory, (x), (n), (maskl)))
static int
-do_wdat (memory, x, n, maskl)
- char *memory;
- int x;
- int n;
- int maskl;
+do_wdat (unsigned char *memory, int x, int n, int maskl)
{
int f0;
int f1;
@@ -758,9 +736,7 @@ do_wdat (memory, x, n, maskl)
}
static void
-process_wlat_addr (addr, value)
- int addr;
- int value;
+process_wlat_addr (int addr, int value)
{
unsigned int *ptr;
@@ -769,9 +745,7 @@ process_wlat_addr (addr, value)
}
static void
-process_wwat_addr (addr, value)
- int addr;
- int value;
+process_wwat_addr (int addr, int value)
{
unsigned short *ptr;
@@ -780,9 +754,7 @@ process_wwat_addr (addr, value)
}
static void
-process_wbat_addr (addr, value)
- int addr;
- int value;
+process_wbat_addr (int addr, int value)
{
unsigned char *ptr;
@@ -791,8 +763,7 @@ process_wbat_addr (addr, value)
}
static int
-process_rlat_addr (addr)
- int addr;
+process_rlat_addr (int addr)
{
unsigned char *ptr;
@@ -801,8 +772,7 @@ process_rlat_addr (addr)
}
static int
-process_rwat_addr (addr)
- int addr;
+process_rwat_addr (int addr)
{
unsigned char *ptr;
@@ -811,8 +781,7 @@ process_rwat_addr (addr)
}
static int
-process_rbat_addr (addr)
- int addr;
+process_rbat_addr (int addr)
{
unsigned char *ptr;
@@ -893,10 +862,7 @@ static int nsamples;
#define SCI_TDRE 0x80 /* Transmit data register empty */
static int
-IOMEM (addr, write, value)
- int addr;
- int write;
- int value;
+IOMEM (int addr, int write, int value)
{
if (write)
{
@@ -923,22 +889,21 @@ IOMEM (addr, write, value)
}
static int
-get_now ()
+get_now (void)
{
return time ((long *) 0);
}
static int
-now_persec ()
+now_persec (void)
{
return 1;
}
static FILE *profile_file;
-static unsigned INLINE
-swap (n)
- unsigned n;
+static INLINE unsigned
+swap (unsigned n)
{
if (endianb)
n = (n << 24 | (n & 0xff00) << 8
@@ -946,9 +911,8 @@ swap (n)
return n;
}
-static unsigned short INLINE
-swap16 (n)
- unsigned short n;
+static INLINE unsigned short
+swap16 (unsigned short n)
{
if (endianb)
n = n << 8 | (n & 0xff00) >> 8;
@@ -956,8 +920,7 @@ swap16 (n)
}
static void
-swapout (n)
- int n;
+swapout (int n)
{
if (profile_file)
{
@@ -968,8 +931,7 @@ swapout (n)
}
static void
-swapout16 (n)
- int n;
+swapout16 (int n)
{
union { char b[4]; int n; } u;
u.n = swap16 (n);
@@ -979,8 +941,7 @@ swapout16 (n)
/* Turn a pointer in a register into a pointer into real memory. */
static char *
-ptr (x)
- int x;
+ptr (int x)
{
return (char *) (x + saved_state.asregs.memory);
}
@@ -990,8 +951,7 @@ ptr (x)
to use this string as a zero-terminated string on the host.
(Not counting the rounding up needed to operate on entire words.) */
static int
-strswaplen (str)
- int str;
+strswaplen (int str)
{
unsigned char *memory = saved_state.asregs.memory;
int start, end;
@@ -1005,9 +965,7 @@ strswaplen (str)
}
static void
-strnswap (str, len)
- int str;
- int len;
+strnswap (int str, int len)
{
int *start, *end;
@@ -1029,11 +987,8 @@ strnswap (str, len)
return offset by which to adjust pc. */
static int
-trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
- int i;
- int *regs;
- unsigned char *insn_ptr;
- unsigned char *memory;
+trap (int i, int *regs, unsigned char *insn_ptr, unsigned char *memory,
+ int maskl, int maskw, int endianw)
{
switch (i)
{
@@ -1084,7 +1039,7 @@ trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
break;
case SYS_wait:
- regs[0] = wait (ptr (regs[5]));
+ regs[0] = wait ((int *) ptr (regs[5]));
break;
#endif /* !defined(__GO32__) && !defined(_WIN32) */
@@ -1217,7 +1172,7 @@ trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
{
/* Include the termination byte. */
int i = strlen (prog_argv[regs[5]]) + 1;
- regs[0] = sim_write (0, regs[6], prog_argv[regs[5]], i);
+ regs[0] = sim_write (0, regs[6], (void *) prog_argv[regs[5]], i);
}
else
regs[0] = -1;
@@ -1261,12 +1216,8 @@ trap (i, regs, insn_ptr, memory, maskl, maskw, endianw)
return 0;
}
-static int
-div1 (R, iRn2, iRn1/*, T*/)
- int *R;
- int iRn1;
- int iRn2;
- /* int T;*/
+static void
+div1 (int *R, int iRn2, int iRn1/*, int T*/)
{
unsigned long tmp0;
unsigned char old_q, tmp1;
@@ -1351,10 +1302,7 @@ div1 (R, iRn2, iRn1/*, T*/)
}
static void
-dmul (sign, rm, rn)
- int sign;
- unsigned int rm;
- unsigned int rn;
+dmul (int sign, unsigned int rm, unsigned int rn)
{
unsigned long RnL, RnH;
unsigned long RmL, RmH;
@@ -1392,11 +1340,7 @@ dmul (sign, rm, rn)
}
static void
-macw (regs, memory, n, m, endianw)
- int *regs;
- unsigned char *memory;
- int m, n;
- int endianw;
+macw (int *regs, unsigned char *memory, int n, int m, int endianw)
{
long tempm, tempn;
long prod, macl, sum;
@@ -1430,10 +1374,7 @@ macw (regs, memory, n, m, endianw)
}
static void
-macl (regs, memory, n, m)
- int *regs;
- unsigned char *memory;
- int m, n;
+macl (int *regs, unsigned char *memory, int n, int m)
{
long tempm, tempn;
long macl, mach;
@@ -1499,7 +1440,7 @@ enum {
};
/* Do extended displacement move instructions. */
-void
+static void
do_long_move_insn (int op, int disp12, int m, int n, int *thatlock)
{
int memstalls = 0;
@@ -1566,7 +1507,7 @@ do_long_move_insn (int op, int disp12, int m, int n, int *thatlock)
}
/* Do binary logical bit-manipulation insns. */
-void
+static void
do_blog_insn (int imm, int addr, int binop,
unsigned char *memory, int maskb)
{
@@ -1608,7 +1549,8 @@ do_blog_insn (int imm, int addr, int binop,
break;
}
}
-float
+
+static float
fsca_s (int in, double (*f) (double))
{
double rad = ldexp ((in & 0xffff), -15) * 3.141592653589793238462643383;
@@ -1630,7 +1572,7 @@ fsca_s (int in, double (*f) (double))
return abs (upper - result) >= abs (lower - result) ? upper : lower;
}
-float
+static float
fsrra_s (float in)
{
double result = 1. / sqrt (in);
@@ -1667,10 +1609,8 @@ fsrra_s (float in)
pointed to by RS and RE -- for SETRC, they're not (see docs). */
static struct loop_bounds
-get_loop_bounds_ext (rs, re, memory, mem_end, maskw, endianw)
- int rs, re;
- unsigned char *memory, *mem_end;
- int maskw, endianw;
+get_loop_bounds_ext (int rs, int re, unsigned char *memory,
+ unsigned char *mem_end, int maskw, int endianw)
{
struct loop_bounds loop;
@@ -1684,10 +1624,8 @@ get_loop_bounds_ext (rs, re, memory, mem_end, maskw, endianw)
}
static struct loop_bounds
-get_loop_bounds (rs, re, memory, mem_end, maskw, endianw)
- int rs, re;
- unsigned char *memory, *mem_end;
- int maskw, endianw;
+get_loop_bounds (int rs, int re, unsigned char *memory, unsigned char *mem_end,
+ int maskw, int endianw)
{
struct loop_bounds loop;
@@ -1730,7 +1668,7 @@ static void ppi_insn ();
significantly cut the start-up time when a large simulator memory is
required, because pages are only zeroed on demand. */
#ifdef MAP_ANONYMOUS
-void *
+static void *
mcalloc (size_t nmemb, size_t size)
{
void *page;
@@ -1750,9 +1688,7 @@ mcalloc (size_t nmemb, size_t size)
/* Set the memory size to the power of two provided. */
void
-sim_size (power)
- int power;
-
+sim_size (int power)
{
sim_memory_size = power;
@@ -1778,8 +1714,7 @@ sim_size (power)
}
static void
-init_dsp (abfd)
- struct bfd *abfd;
+init_dsp (struct bfd *abfd)
{
int was_dsp = target_dsp;
unsigned long mach = bfd_get_mach (abfd);
@@ -1872,7 +1807,7 @@ init_dsp (abfd)
}
static void
-init_pointers ()
+init_pointers (void)
{
host_little_endian = 0;
* (char*) &host_little_endian = 1;
@@ -1904,7 +1839,7 @@ init_pointers ()
}
static void
-dump_profile ()
+dump_profile (void)
{
unsigned int minpc;
unsigned int maxpc;
@@ -1925,9 +1860,7 @@ dump_profile ()
}
static void
-gotcall (from, to)
- int from;
- int to;
+gotcall (int from, int to)
{
swapout (from);
swapout (to);
@@ -1937,17 +1870,14 @@ gotcall (from, to)
#define MMASKB ((saved_state.asregs.msize -1) & ~0)
int
-sim_stop (sd)
- SIM_DESC sd;
+sim_stop (SIM_DESC sd)
{
raise_exception (SIGINT);
return 1;
}
void
-sim_resume (sd, step, siggnal)
- SIM_DESC sd;
- int step, siggnal;
+sim_resume (SIM_DESC sd, int step, int siggnal)
{
register unsigned char *insn_ptr;
unsigned char *mem_end;
@@ -2039,7 +1969,8 @@ sim_resume (sd, step, siggnal)
#endif
top:
if (tracing)
- fprintf (stderr, "PC: %08x, insn: %04x\n", PH2T (insn_ptr), iword);
+ fprintf (stderr, "PC: %08lx, insn: %04x\n",
+ (unsigned long) PH2T (insn_ptr), iword);
#include "code.c"
@@ -2125,11 +2056,7 @@ sim_resume (sd, step, siggnal)
}
int
-sim_write (sd, addr, buffer, size)
- SIM_DESC sd;
- SIM_ADDR addr;
- const unsigned char *buffer;
- int size;
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
{
int i;
@@ -2143,11 +2070,7 @@ sim_write (sd, addr, buffer, size)
}
int
-sim_read (sd, addr, buffer, size)
- SIM_DESC sd;
- SIM_ADDR addr;
- unsigned char *buffer;
- int size;
+sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
{
int i;
@@ -2170,11 +2093,7 @@ enum {
};
int
-sim_store_register (sd, rn, memory, length)
- SIM_DESC sd;
- int rn;
- unsigned char *memory;
- int length;
+sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
{
unsigned val;
@@ -2347,11 +2266,7 @@ sim_store_register (sd, rn, memory, length)
}
int
-sim_fetch_register (sd, rn, memory, length)
- SIM_DESC sd;
- int rn;
- unsigned char *memory;
- int length;
+sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
{
int val;
@@ -2522,8 +2437,7 @@ sim_fetch_register (sd, rn, memory, length)
}
int
-sim_trace (sd)
- SIM_DESC sd;
+sim_trace (SIM_DESC sd)
{
tracing = 1;
sim_resume (sd, 0, 0);
@@ -2532,10 +2446,7 @@ sim_trace (sd)
}
void
-sim_stop_reason (sd, reason, sigrc)
- SIM_DESC sd;
- enum sim_stop *reason;
- int *sigrc;
+sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc)
{
/* The SH simulator uses SIGQUIT to indicate that the program has
exited, so we must check for it here and translate it to exit. */
@@ -2552,9 +2463,7 @@ sim_stop_reason (sd, reason, sigrc)
}
void
-sim_info (sd, verbose)
- SIM_DESC sd;
- int verbose;
+sim_info (SIM_DESC sd, int verbose)
{
double timetaken =
(double) saved_state.asregs.ticks / (double) now_persec ();
@@ -2589,25 +2498,19 @@ sim_info (sd, verbose)
}
void
-sim_set_profile (n)
- int n;
+sim_set_profile (int n)
{
saved_state.asregs.profile = n;
}
void
-sim_set_profile_size (n)
- int n;
+sim_set_profile_size (int n)
{
sim_profile_size = n;
}
SIM_DESC
-sim_open (kind, cb, abfd, argv)
- SIM_OPEN_KIND kind;
- host_callback *cb;
- struct bfd *abfd;
- char **argv;
+sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
char **p;
int endian_set = 0;
@@ -2662,8 +2565,7 @@ sim_open (kind, cb, abfd, argv)
}
static void
-parse_and_set_memory_size (str)
- const char *str;
+parse_and_set_memory_size (const char *str)
{
int n;
@@ -2675,19 +2577,13 @@ parse_and_set_memory_size (str)
}
void
-sim_close (sd, quitting)
- SIM_DESC sd;
- int quitting;
+sim_close (SIM_DESC sd, int quitting)
{
/* nothing to do */
}
SIM_RC
-sim_load (sd, prog, abfd, from_tty)
- SIM_DESC sd;
- const char *prog;
- bfd *abfd;
- int from_tty;
+sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
{
extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
bfd *prog_bfd;
@@ -2712,11 +2608,7 @@ sim_load (sd, prog, abfd, from_tty)
}
SIM_RC
-sim_create_inferior (sd, prog_bfd, argv, env)
- SIM_DESC sd;
- struct bfd *prog_bfd;
- char **argv;
- char **env;
+sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, char **argv, char **env)
{
/* Clear the registers. */
memset (&saved_state, 0,
@@ -2737,9 +2629,7 @@ sim_create_inferior (sd, prog_bfd, argv, env)
}
void
-sim_do_command (sd, cmd)
- SIM_DESC sd;
- const char *cmd;
+sim_do_command (SIM_DESC sd, const char *cmd)
{
const char *sms_cmd = "set-memory-size";
int cmdsize;
@@ -2769,8 +2659,7 @@ sim_do_command (sd, cmd)
}
void
-sim_set_callbacks (p)
- host_callback *p;
+sim_set_callbacks (host_callback *p)
{
callback = p;
}
--
2.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 5/5] sim: sh: convert to nrun
2015-03-28 21:46 [PATCH 1/5] sim: sh: use common configure options Mike Frysinger
` (2 preceding siblings ...)
2015-03-28 21:46 ` [PATCH 2/5] sim: sh: clean up gencode Mike Frysinger
@ 2015-03-28 21:55 ` Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2015-03-28 21:55 UTC (permalink / raw)
To: gdb-patches
A lot of cpu state is stored in global variables, as is memory handling.
The sim_size support needs unwinding at some point. But at least this
is an improvement on the status quo.
Committed.
---
sim/sh/ChangeLog | 23 +++++
sim/sh/Makefile.in | 15 +--
sim/sh/interp.c | 278 ++++++++++++++---------------------------------------
sim/sh/sim-main.h | 154 +++++++++++++++++++++++++++++
sim/sh/tconfig.h | 17 ----
5 files changed, 260 insertions(+), 227 deletions(-)
create mode 100644 sim/sh/sim-main.h
delete mode 100644 sim/sh/tconfig.h
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 0ee6dac..8a37e4c 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,5 +1,28 @@
2015-03-28 Mike Frysinger <vapier@gentoo.org>
+ * Makefile.in (SIM_RUN_OBJS, SIM_EXTRA_CFLAGS): Delete.
+ (SIM_OBJS): Change to $(SIM_NEW_COMMON_OBJS).
+ * interp.c: Delete run-sim.h include. Include sim-main.h, sim-base.h,
+ and sim-options.h.
+ (SEXT, SEXT32): Undefine.
+ (sim_write): Delete prototype.
+ (regstacktype, saved_state_type): Move to sim-main.h.
+ (target_little_endian): Replace with CURRENT_TARGET_BYTE_ORDER.
+ (host_little_endian): Replace with CURRENT_HOST_BYTE_ORDER.
+ (sim_kind, myname, tracing, sim_stop, sim_trace, sim_set_profile,
+ sim_set_profile_size, sim_load, sim_set_callbacks,
+ sim_complete_command): Delete.
+ (sim_size): Mark static.
+ (init_pointers): Delete host_little_endian setup.
+ (sim_resume): Delete tracing check.
+ (free_state): New cleanup function.
+ (sim_open): Rewrite to use new common logic.
+ (sim_create_inferior): Call init_dsp.
+ * sim-main.h: New file.
+ * tconfig.h: Delete file.
+
+2015-03-28 Mike Frysinger <vapier@gentoo.org>
+
* gencode.c (ppi_gensim): Convert old style prototype with ppi_insn.
* interp.c: Include ctype.h and run-sim.h.
[HAVE_TIME_H]: Include time.h
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index 0594a6e..ecfb287 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -1,7 +1,7 @@
# Makefile template for Configure for the SH sim library.
# Copyright (C) 1990-2015 Free Software Foundation, Inc.
# Written by Cygnus Support.
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@@ -17,11 +17,14 @@
## COMMON_PRE_CONFIG_FRAG
-# Use the deprecated run frontend until we migrate to nrun.o
-SIM_RUN_OBJS = run.o
-SIM_EXTRA_CFLAGS = -DSIM_USE_DEPRECATED_RUN_FRONTEND
-
-SIM_OBJS = interp.o table.o sim-load.o
+SIM_OBJS = \
+ interp.o \
+ $(SIM_NEW_COMMON_OBJS) \
+ sim-cpu.o \
+ sim-engine.o \
+ sim-hload.o \
+ sim-stop.o \
+ table.o
SIM_EXTRA_LIBS = -lm
SIM_EXTRA_CLEAN = sh-clean
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index adf05ee..13f6e65 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -67,7 +67,10 @@
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/sim-sh.h"
-#include "run-sim.h"
+
+#include "sim-main.h"
+#include "sim-base.h"
+#include "sim-options.h"
/* This file is local - if newlib changes, then so should this. */
#include "syscall.h"
@@ -91,9 +94,11 @@
#define SIGTRAP 5
#endif
-extern unsigned short sh_jump_table[], sh_dsp_table[0x1000], ppi_table[];
+/* TODO: Stop using these names. */
+#undef SEXT
+#undef SEXT32
-int sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size);
+extern unsigned short sh_jump_table[], sh_dsp_table[0x1000], ppi_table[];
#define O_RECOMPILE 85
#define DEFINE_TABLE
@@ -103,108 +108,7 @@ int sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size
for a quit. */
#define POLL_QUIT_INTERVAL 0x60000
-typedef struct
-{
- int regs[20];
-} regstacktype;
-
-typedef union
-{
-
- struct
- {
- int regs[16];
- int pc;
-
- /* System registers. For sh-dsp this also includes A0 / X0 / X1 / Y0 / Y1
- which are located in fregs, i.e. strictly speaking, these are
- out-of-bounds accesses of sregs.i . This wart of the code could be
- fixed by making fregs part of sregs, and including pc too - to avoid
- alignment repercussions - but this would cause very onerous union /
- structure nesting, which would only be managable with anonymous
- unions and structs. */
- union
- {
- struct
- {
- int mach;
- int macl;
- int pr;
- int dummy3, dummy4;
- int fpul; /* A1 for sh-dsp - but only for movs etc. */
- int fpscr; /* dsr for sh-dsp */
- } named;
- int i[7];
- } sregs;
-
- /* sh3e / sh-dsp */
- union fregs_u
- {
- float f[16];
- double d[8];
- int i[16];
- }
- fregs[2];
-
- /* Control registers; on the SH4, ldc / stc is privileged, except when
- accessing gbr. */
- union
- {
- struct
- {
- int sr;
- int gbr;
- int vbr;
- int ssr;
- int spc;
- int mod;
- /* sh-dsp */
- int rs;
- int re;
- /* sh3 */
- int bank[8];
- int dbr; /* debug base register */
- int sgr; /* saved gr15 */
- int ldst; /* load/store flag (boolean) */
- int tbr;
- int ibcr; /* sh2a bank control register */
- int ibnr; /* sh2a bank number register */
- } named;
- int i[16];
- } cregs;
-
- unsigned char *insn_end;
-
- int ticks;
- int stalls;
- int memstalls;
- int cycles;
- int insts;
-
- int prevlock;
- int thislock;
- int exception;
-
- int end_of_registers;
-
- int msize;
-#define PROFILE_FREQ 1
-#define PROFILE_SHIFT 2
- int profile;
- unsigned short *profile_hist;
- unsigned char *memory;
- int xyram_select, xram_start, yram_start;
- unsigned char *xmem;
- unsigned char *ymem;
- unsigned char *xmem_offset;
- unsigned char *ymem_offset;
- unsigned long bfd_mach;
- regstacktype *regstack;
- }
- asregs;
- int asints[40];
-} saved_state_type;
-
+/* TODO: Move into sim_cpu. */
saved_state_type saved_state;
struct loop_bounds { unsigned char *start, *end; };
@@ -212,20 +116,15 @@ struct loop_bounds { unsigned char *start, *end; };
/* These variables are at file scope so that functions other than
sim_resume can use the fetch/store macros */
-static int target_little_endian;
+#define target_little_endian (CURRENT_TARGET_BYTE_ORDER == LITTLE_ENDIAN)
static int global_endianw, endianb;
static int target_dsp;
-static int host_little_endian;
+#define host_little_endian (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN)
static char **prog_argv;
static int maskw = 0;
static int maskl = 0;
-static SIM_OPEN_KIND sim_kind;
-static char *myname;
-static int tracing = 0;
-
-
/* Short hand definitions of the registers */
#define SBIT(x) ((x)&sbit)
@@ -1687,7 +1586,7 @@ mcalloc (size_t nmemb, size_t size)
/* Set the memory size to the power of two provided. */
-void
+static void
sim_size (int power)
{
sim_memory_size = power;
@@ -1809,10 +1708,6 @@ init_dsp (struct bfd *abfd)
static void
init_pointers (void)
{
- host_little_endian = 0;
- * (char*) &host_little_endian = 1;
- host_little_endian &= 1;
-
if (saved_state.asregs.msize != 1 << sim_memory_size)
{
sim_size (sim_memory_size);
@@ -1869,13 +1764,6 @@ gotcall (int from, int to)
#define MMASKB ((saved_state.asregs.msize -1) & ~0)
-int
-sim_stop (SIM_DESC sd)
-{
- raise_exception (SIGINT);
- return 1;
-}
-
void
sim_resume (SIM_DESC sd, int step, int siggnal)
{
@@ -1968,9 +1856,6 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
insts++;
#endif
top:
- if (tracing)
- fprintf (stderr, "PC: %08lx, insn: %04x\n",
- (unsigned long) PH2T (insn_ptr), iword);
#include "code.c"
@@ -2436,15 +2321,6 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
return length;
}
-int
-sim_trace (SIM_DESC sd)
-{
- tracing = 1;
- sim_resume (sd, 0, 0);
- tracing = 0;
- return 1;
-}
-
void
sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc)
{
@@ -2497,23 +2373,19 @@ sim_info (SIM_DESC sd, int verbose)
}
}
-void
-sim_set_profile (int n)
-{
- saved_state.asregs.profile = n;
-}
-
-void
-sim_set_profile_size (int n)
+static void
+free_state (SIM_DESC sd)
{
- sim_profile_size = n;
+ if (STATE_MODULES (sd) != NULL)
+ sim_module_uninstall (sd);
+ sim_cpu_free_all (sd);
+ sim_state_free (sd);
}
SIM_DESC
sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
{
char **p;
- int endian_set = 0;
int i;
union
{
@@ -2523,32 +2395,65 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
}
mem_word;
- sim_kind = kind;
- myname = argv[0];
+ SIM_DESC sd = sim_state_alloc (kind, cb);
+ SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+
callback = cb;
+ /* The cpu data is kept in a separately allocated chunk of memory. */
+ if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+ {
+ free_state (sd);
+ return 0;
+ }
+
+ if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
+ {
+ free_state (sd);
+ return 0;
+ }
+
+ /* getopt will print the error message so we just have to exit if this fails.
+ FIXME: Hmmm... in the case of gdb we need getopt to call
+ print_filtered. */
+ if (sim_parse_args (sd, argv) != SIM_RC_OK)
+ {
+ free_state (sd);
+ return 0;
+ }
+
+ /* Check for/establish the a reference program image. */
+ if (sim_analyze_program (sd,
+ (STATE_PROG_ARGV (sd) != NULL
+ ? *STATE_PROG_ARGV (sd)
+ : NULL), abfd) != SIM_RC_OK)
+ {
+ free_state (sd);
+ return 0;
+ }
+
+ /* Configure/verify the target byte order and other runtime
+ configuration options. */
+ if (sim_config (sd) != SIM_RC_OK)
+ {
+ sim_module_uninstall (sd);
+ return 0;
+ }
+
+ if (sim_post_argv_init (sd) != SIM_RC_OK)
+ {
+ /* Uninstall the modules to avoid memory leaks,
+ file descriptor leaks, etc. */
+ sim_module_uninstall (sd);
+ return 0;
+ }
+
for (p = argv + 1; *p != NULL; ++p)
{
- if (strcmp (*p, "-E") == 0)
- {
- ++p;
- if (*p == NULL)
- {
- /* FIXME: This doesn't use stderr, but then the rest of the
- file doesn't either. */
- callback->printf_filtered (callback, "Missing argument to `-E'.\n");
- return 0;
- }
- target_little_endian = strcmp (*p, "big") != 0;
- endian_set = 1;
- }
- else if (isdigit (**p))
+ if (isdigit (**p))
parse_and_set_memory_size (*p);
}
- if (abfd != NULL && ! endian_set)
- target_little_endian = ! bfd_big_endian (abfd);
-
if (abfd)
init_dsp (abfd);
@@ -2560,8 +2465,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
mem_word.c[i] = i;
endianb = mem_word.i >> (target_little_endian ? 0 : 24) & 0xff;
- /* fudge our descriptor for now */
- return (SIM_DESC) 1;
+ return sd;
}
static void
@@ -2583,31 +2487,6 @@ sim_close (SIM_DESC sd, int quitting)
}
SIM_RC
-sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
-{
- extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
- bfd *prog_bfd;
-
- prog_bfd = sim_load_file (sd, myname, callback, prog, abfd,
- sim_kind == SIM_OPEN_DEBUG,
- 0, sim_write);
-
- /* Set the bfd machine type. */
- if (prog_bfd)
- saved_state.asregs.bfd_mach = bfd_get_mach (prog_bfd);
- else if (abfd)
- saved_state.asregs.bfd_mach = bfd_get_mach (abfd);
- else
- saved_state.asregs.bfd_mach = 0;
-
- if (prog_bfd == NULL)
- return SIM_RC_FAIL;
- if (abfd == NULL)
- bfd_close (prog_bfd);
- return SIM_RC_OK;
-}
-
-SIM_RC
sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, char **argv, char **env)
{
/* Clear the registers. */
@@ -2622,6 +2501,9 @@ sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, char **argv, char **env)
if (prog_bfd != NULL)
saved_state.asregs.bfd_mach = bfd_get_mach (prog_bfd);
+ if (prog_bfd != NULL)
+ init_dsp (prog_bfd);
+
/* Record the program's arguments. */
prog_argv = argv;
@@ -2657,15 +2539,3 @@ sim_do_command (SIM_DESC sd, const char *cmd)
(callback->printf_filtered) (callback, "Error: \"%s\" is not a valid SH simulator command.\n", cmd);
}
}
-
-void
-sim_set_callbacks (host_callback *p)
-{
- callback = p;
-}
-
-char **
-sim_complete_command (SIM_DESC sd, const char *text, const char *word)
-{
- return NULL;
-}
diff --git a/sim/sh/sim-main.h b/sim/sh/sim-main.h
new file mode 100644
index 0000000..e15a26a
--- /dev/null
+++ b/sim/sh/sim-main.h
@@ -0,0 +1,154 @@
+/* Moxie Simulator definition.
+ Copyright (C) 2009-2015 Free Software Foundation, Inc.
+
+This file is part of GDB, the GNU debugger.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it 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 program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SIM_MAIN_H
+#define SIM_MAIN_H
+
+#include "sim-basics.h"
+
+typedef address_word sim_cia;
+
+#define CIA_GET(cpu) saved_state.asregs.pc
+#define CIA_SET(cpu,val) saved_state.asregs.pc = (val)
+
+typedef struct _sim_cpu SIM_CPU;
+
+#include "sim-base.h"
+
+typedef struct
+{
+ int regs[20];
+} regstacktype;
+
+typedef union
+{
+
+ struct
+ {
+ int regs[16];
+ int pc;
+
+ /* System registers. For sh-dsp this also includes A0 / X0 / X1 / Y0 / Y1
+ which are located in fregs, i.e. strictly speaking, these are
+ out-of-bounds accesses of sregs.i . This wart of the code could be
+ fixed by making fregs part of sregs, and including pc too - to avoid
+ alignment repercussions - but this would cause very onerous union /
+ structure nesting, which would only be managable with anonymous
+ unions and structs. */
+ union
+ {
+ struct
+ {
+ int mach;
+ int macl;
+ int pr;
+ int dummy3, dummy4;
+ int fpul; /* A1 for sh-dsp - but only for movs etc. */
+ int fpscr; /* dsr for sh-dsp */
+ } named;
+ int i[7];
+ } sregs;
+
+ /* sh3e / sh-dsp */
+ union fregs_u
+ {
+ float f[16];
+ double d[8];
+ int i[16];
+ }
+ fregs[2];
+
+ /* Control registers; on the SH4, ldc / stc is privileged, except when
+ accessing gbr. */
+ union
+ {
+ struct
+ {
+ int sr;
+ int gbr;
+ int vbr;
+ int ssr;
+ int spc;
+ int mod;
+ /* sh-dsp */
+ int rs;
+ int re;
+ /* sh3 */
+ int bank[8];
+ int dbr; /* debug base register */
+ int sgr; /* saved gr15 */
+ int ldst; /* load/store flag (boolean) */
+ int tbr;
+ int ibcr; /* sh2a bank control register */
+ int ibnr; /* sh2a bank number register */
+ } named;
+ int i[16];
+ } cregs;
+
+ unsigned char *insn_end;
+
+ int ticks;
+ int stalls;
+ int memstalls;
+ int cycles;
+ int insts;
+
+ int prevlock;
+ int thislock;
+ int exception;
+
+ int end_of_registers;
+
+ int msize;
+#define PROFILE_FREQ 1
+#define PROFILE_SHIFT 2
+ int profile;
+ unsigned short *profile_hist;
+ unsigned char *memory;
+ int xyram_select, xram_start, yram_start;
+ unsigned char *xmem;
+ unsigned char *ymem;
+ unsigned char *xmem_offset;
+ unsigned char *ymem_offset;
+ unsigned long bfd_mach;
+ regstacktype *regstack;
+ } asregs;
+ int asints[40];
+} saved_state_type;
+
+/* TODO: Move into sim_cpu. */
+extern saved_state_type saved_state;
+
+struct _sim_cpu {
+
+ sim_cpu_base base;
+};
+
+struct sim_state {
+
+ sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
+
+ sim_state_base base;
+};
+
+#endif
diff --git a/sim/sh/tconfig.h b/sim/sh/tconfig.h
deleted file mode 100644
index c5ec4fa..0000000
--- a/sim/sh/tconfig.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* sh target config file */
-
-/* Define this if the simulator supports profiling.
- See the mips simulator for an example.
- This enables the `-p foo' and `-s bar' options.
- The target is required to provide sim_set_profile{,_size}. */
-/* #define SIM_HAVE_PROFILE */
-
-/* Define this if the simulator uses an instruction cache.
- See the h8/300 simulator for an example.
- This enables the `-c size' option to set the size of the cache.
- The target is required to provide sim_set_simcache_size. */
-/* #define SIM_HAVE_SIMCACHE */
-
-/* Define this if the target cpu is bi-endian
- and the simulator supports it. */
-#define SIM_HAVE_BIENDIAN
--
2.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-28 21:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28 21:46 [PATCH 1/5] sim: sh: use common configure options Mike Frysinger
2015-03-28 21:45 ` [PATCH 3/5] sim: sh: fix broken handling in DSR reg Mike Frysinger
2015-03-28 21:46 ` [PATCH 4/5] sim: sh: clean up some warnings Mike Frysinger
2015-03-28 21:46 ` [PATCH 2/5] sim: sh: clean up gencode Mike Frysinger
2015-03-28 21:55 ` [PATCH 5/5] sim: sh: convert to nrun Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).