gdb: throw OPTIMIZED_OUT_ERROR rather than GENERIC_ERROR
[binutils-gdb.git] / sim / bfin / dv-bfin_trace.c
index 99dd1be114302202f6349f9b7cd89b4a0e176b8b..56fad63cd3e7364405f7afe87e2c0aebde157aa1 100644 (file)
@@ -1,6 +1,6 @@
 /* Blackfin Trace (TBUF) model.
 
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+   Copyright (C) 2010-2021 Free Software Foundation, Inc.
    Contributed by Analog Devices, Inc.
 
    This file is part of simulators.
@@ -18,7 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "config.h"
+/* This must come before any other includes.  */
+#include "defs.h"
 
 #include "sim-main.h"
 #include "devices.h"
@@ -80,6 +81,10 @@ bfin_trace_io_write_buffer (struct hw *me, const void *source,
   bu32 mmr_off;
   bu32 value;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, true))
+    return 0;
+
   value = dv_load_4 (source);
   mmr_off = addr - trace->base;
 
@@ -96,7 +101,7 @@ bfin_trace_io_write_buffer (struct hw *me, const void *source,
       break;
     default:
       dv_bfin_mmr_invalid (me, addr, nr_bytes, true);
-      break;
+      return 0;
     }
 
   return nr_bytes;
@@ -110,6 +115,10 @@ bfin_trace_io_read_buffer (struct hw *me, void *dest,
   bu32 mmr_off;
   bu32 value;
 
+  /* Invalid access mode is higher priority than missing register.  */
+  if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false))
+    return 0;
+
   mmr_off = addr - trace->base;
 
   HW_TRACE_READ ();
@@ -123,7 +132,7 @@ bfin_trace_io_read_buffer (struct hw *me, void *dest,
       /* Hardware is limited to 16 entries, so to stay compatible with
          software, limit the value to 16.  For software algorithms that
          keep reading while (TBUFSTAT != 0), they'll get all of it.  */
-      value = MIN (TBUF_LEN (trace), 16);
+      value = min (TBUF_LEN (trace), 16);
       break;
     case mmr_offset(tbuf):
       {
@@ -148,9 +157,8 @@ bfin_trace_io_read_buffer (struct hw *me, void *dest,
        break;
       }
     default:
-      while (1) /* Core MMRs -> exception -> doesn't return.  */
-       dv_bfin_mmr_invalid (me, addr, nr_bytes, false);
-      break;
+      dv_bfin_mmr_invalid (me, addr, nr_bytes, false);
+      return 0;
     }
 
   dv_store_4 (dest, value);
@@ -200,7 +208,8 @@ bfin_trace_finish (struct hw *me)
   attach_bfin_trace_regs (me, trace);
 }
 
-const struct hw_descriptor dv_bfin_trace_descriptor[] = {
+const struct hw_descriptor dv_bfin_trace_descriptor[] =
+{
   {"bfin_trace", bfin_trace_finish,},
   {NULL, NULL},
 };