sim: watch: fix pc watchpoints on little endian host systems
authorMike Frysinger <vapier@gentoo.org>
Wed, 13 Jan 2021 06:21:22 +0000 (01:21 -0500)
committerMike Frysinger <vapier@gentoo.org>
Wed, 13 Jan 2021 10:52:51 +0000 (05:52 -0500)
My change 1ac72f0659d64d6a14da862242db0d841d2878d0 ("sim: convert to
bfd_endian") subtly broke the watchpoint module on little endian host
systems.  The old code used 0 to mean "whatever the host endian is",
and while that was changed to use BFD_ENDIAN_UNKNOWN, this caller was
missed.  Since its API used an int instead of an enum, the coercion
from 0 to the BFD endian enum was silently missed, and 0 happens to
be BFD_ENDIAN_BIG.

Instead of restoring the old logic by passing in BFD_ENDIAN_UNKNOWN,
we know the right host endian at compile time, so use that directly.

sim/common/ChangeLog
sim/common/sim-events.c
sim/common/sim-events.h
sim/common/sim-watch.c

index 608a0859ce895935c6b401722e5fcecea0814704..539bab687d46ad58c283d52bdbaff5d2c8814e22 100644 (file)
@@ -1,3 +1,12 @@
+2021-01-13  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-events.c (sim_events_watch_sim): Change byte_order type to
+       enum bfd_endian.
+       (sim_events_watch_core): Likewise.
+       * sim-events.h (sim_events_watch_sim, sim_events_watch_core): Likewise.
+       * sim-watch.c (schedule_watchpoint): Change 0 to HOST_BYTE_ORDER in
+       call to sim_events_watch_sim.
+
 2021-01-12  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-profile.h [!WITH_PROFILE]: Rewrite to use #error.
index db05cafe13e77270906aed40cb5f9b3cbe363086..6dd0474d91ace9a341eafe80e15a943b2ea4b730 100644 (file)
@@ -613,7 +613,7 @@ sim_event *
 sim_events_watch_sim (SIM_DESC sd,
                      void *host_addr,
                      int nr_bytes,
-                     int byte_order,
+                     enum bfd_endian byte_order,
                      int is_within,
                      unsigned64 lb,
                      unsigned64 ub,
@@ -692,7 +692,7 @@ sim_events_watch_core (SIM_DESC sd,
                       address_word core_addr,
                       unsigned core_map,
                       int nr_bytes,
-                      int byte_order,
+                      enum bfd_endian byte_order,
                       int is_within,
                       unsigned64 lb,
                       unsigned64 ub,
index ecd7c592a94c56ff7a45c1fd6fd445c7cfa52e1e..823fd8c946c07decd6c4b1d89310b17da53abbb8 100644 (file)
@@ -161,7 +161,7 @@ extern sim_event *sim_events_watch_sim
 (SIM_DESC sd,
  void *host_addr,
  int nr_bytes,
int byte_order,
enum bfd_endian byte_order,
  int is_within,
  unsigned64 lb,
  unsigned64 ub,
@@ -182,7 +182,7 @@ extern sim_event *sim_events_watch_core
  address_word core_addr,
  unsigned map,
  int nr_bytes,
int byte_order,
enum bfd_endian byte_order,
  int is_within,
  unsigned64 lb,
  unsigned64 ub,
index bbd5be434bea69aab6a54ced2c5bc1c8821db5f5..d69d42cb9540bbb45ef26282cd58bedf08e9f57f 100644 (file)
@@ -173,7 +173,7 @@ schedule_watchpoint (SIM_DESC sd,
       point->event = sim_events_watch_sim (sd,
                                           watch->pc,
                                           watch->sizeof_pc,
-                                          0/* host-endian */,
+                                          HOST_BYTE_ORDER,
                                           point->is_within,
                                           point->arg0, point->arg1,
                                           /* PC in arg0..arg1 */