Bug 29276 - mips: mips.igen:1453:15: error: conversion from ‘long long unsigned int’ to ‘unsigned_word’
Summary: mips: mips.igen:1453:15: error: conversion from ‘long long unsigned int’ to ‘...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: 12.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://sourceware.org/pipermail/gdb-...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-22 19:02 UTC by HectorOron
Modified: 2022-11-08 07:57 UTC (History)
2 users (show)

See Also:
Host:
Target: mipstx39-rtems6
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description HectorOron 2022-06-22 19:02:46 UTC
When building mipsel simulator, on GDB 12.1, build fails with:

In file included from support.c:25:
/<<PKGBUILDDIR>>/sim/mips/mips.igen: In function ‘do_dmfc1b’:
/<<PKGBUILDDIR>>/sim/mips/sim-main.h:41:25: error: conversion from ‘long long unsigned int’ to ‘unsigned_word’ {aka ‘unsigned int’} changes value from ‘16045693110240459472’ to ‘3134241488’ [-Werror=overflow]
   41 | #define SET64HI(t)      (((uword64)(t))<<32)
      |                         ^
/<<PKGBUILDDIR>>/sim/mips/mips.igen:1453:15: note: in expansion of macro ‘SET64HI’
 1453 |     GPR[rt] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
      |               ^~~~~~~

Full log: https://buildd.debian.org/status/fetch.php?pkg=gdb&arch=mipsel&ver=12.1-1&stamp=1655916813&raw=0

Build was fine on 11.2 release.
Comment 1 Mike Frysinger 2022-10-23 18:29:37 UTC
pretty sure the warning was in there in older versions, the diff with gdb-12 is that we enabled -Werror (since it was building cleanly for the few targets i checked)
Comment 2 Mike Frysinger 2022-10-23 19:44:58 UTC
the code in question is:
:function:::void:do_dmfc1b:int rt, int fs
*mipsIV:
*mipsV:
*mips64:
*mips64r2:
*mips64r6:
*vr4100:
*vr5000:
*r3900:
*micromips64:
{
  if (SizeFGR () == 64)
    GPR[rt] = FGR[fs];
  else if ((fs & 0x1) == 0)
    GPR[rt] = SET64HI (FGR[fs+1]) | FGR[fs];
  else
    GPR[rt] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
  TRACE_ALU_RESULT (GPR[rt]);
}

this was introduced here:
commit 8e394ffc7ab691eafcf276d7ae578454a8c5548f
Author: Andrew Bennett <andrew.bennett@imgtec.com>
Date:   Fri Sep 25 15:52:18 2015 +0100

    [PATCH] Add micromips support to the MIPS simulator
Comment 3 Mike Frysinger 2022-10-23 19:49:51 UTC
the setting of 0xDEADC0DE & 0xBAD0BAD0 looks kind of bogus.  based on other functions in here, like do_dmtc1b, i wonder if it shouldn't be:

-- a/sim/mips/mips.igen
+++ b/sim/mips/mips.igen
@@ -1450,7 +1450,7 @@
   else if ((fs & 0x1) == 0)
     GPR[rt] = SET64HI (FGR[fs+1]) | FGR[fs];
   else
-    GPR[rt] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
+    Unpredictable ();
   TRACE_ALU_RESULT (GPR[rt]);
 }
 

and should we do this for 010001,00001,5.RT,5.FS,00000000000:COP1:64,f::DMFC1a ?

@@ -5782,7 +5782,7 @@
   else if ((FS & 0x1) == 0)
     v = SET64HI (FGR[FS+1]) | FGR[FS];
   else
-    v = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
+    Unpredictable ();
   PENDING_FILL (RT, v);
   TRACE_ALU_RESULT (v);
 }
Comment 4 Mike Frysinger 2022-11-04 00:45:49 UTC
posted a patch to do just that now
https://sourceware.org/pipermail/gdb-patches/2022-November/193376.html
Comment 5 Mike Frysinger 2022-11-08 07:57:22 UTC
landed that patch for GDB 13.  if the original authors prefer something different, feel free to post a follow up.