From mboxrd@z Thu Jan 1 00:00:00 1970 From: Elena Zannoni To: Michael Snyder Cc: Elena Zannoni , Jim Wilson , gdb-patches@sourceware.cygnus.com Subject: Re: gdb patch for 64-bit enum values on 64-bit hosts (ia64-linux) Date: Thu, 15 Jun 2000 20:05:00 -0000 Message-id: <14665.39254.833715.946551@kwikemart.cygnus.com> References: <200006090053.RAA14301@ada.cygnus.com.cygnus.com> <14664.971.753679.67153@kwikemart.cygnus.com> <394828E5.6AFC@cygnus.com> X-SW-Source: 2000-06/msg00186.html Michael Snyder writes: > Elena Zannoni wrote: > > > > Jim Wilson writes: > > > > Jim, any chance you could turn the tests into a gdb testfile? > > Elena, > > I thought I would take a stab at it. Seemed like it might > belong in exprs.exp. I noticed that exprs.exp seems kind of > unfinished -- it sets up as if to do some enum tests, but > doesn't actually do them! So I added some, including some > for long enums. See below. You approve? If they pass, yes :-) > > Unfortunately I don't have Jim's compiler patch, so I can't > test my tests. Jim, can you test them for me? > Anybody tried? Elena > 2000-06-14 Michael Snyder > > * gdb.base/exprs.exp: Add tests for enum expressions. > * gdb.base/exprs.c: Ditto. > Index: exprs.c > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/gdb.base/exprs.c,v > retrieving revision 1.1.1.2 > diff -p -r1.1.1.2 exprs.c > *** exprs.c 1999/06/28 16:03:11 1.1.1.2 > --- exprs.c 2000/06/15 00:52:29 > *************** union tu_link { > *** 183,189 **** > --- 183,202 ---- > > enum colors {red, green, blue} color; > enum cars {chevy, ford, porsche} clunker; > + enum neg_colors {cyan = -3, magenta = -2, yellow = -1, black = 0} pigment; > > + enum long_colors { > + mauve = 0x1000000000000000L, > + puce = 0x1000000000000001L, > + teal = 0x1000000000000002L > + } shade; > + > + enum neg_long_colors { > + orange = -3L, > + purple = -2L, > + brown = -1L, > + white = 0L > + } hue; > > void dummy() > { > *************** void dummy() > *** 246,251 **** > --- 259,267 ---- > > color = red; > clunker = porsche; > + pigment = magenta; > + shade = puce; > + hue = purple; > > u_link.next = s_link; > > Index: exprs.exp > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/gdb.base/exprs.exp,v > retrieving revision 1.1.1.2 > diff -p -r1.1.1.2 exprs.exp > *** exprs.exp 1999/06/28 16:03:12 1.1.1.2 > --- exprs.exp 2000/06/15 00:52:29 > *************** proc test_expr { args } { > *** 60,65 **** > --- 60,66 ---- > } > set last_ent [expr [llength $args] - 1]; > set testname [lindex $args $last_ent]; > + # FIXME: this test does NOT detect failure of the assignment (setup). > if [gdb_test [lindex $args 0] "" "$testname (setup)"] { > gdb_suppress_tests; > } > *************** test_expr "set variable v_unsigned_long= > *** 215,217 **** > --- 216,386 ---- > test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long != 0" "\\$\[0-9\]* = $true" "print v_unsigned_long != (unsigned long)~0" "\\$\[0-9\]* = $false" "print unsigned long != (~0)" > test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long < 0" "\\$\[0-9\]* = $false" "print v_unsigned_long < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned long < (~0)" > test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long > 0" "\\$\[0-9\]* = $true" "print v_unsigned_long > 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned long > (~0)" > + # > + # test expressions with "enum color" types > + # > + test_expr "set variable color=green" \ > + "print color == red" "\\$\[0-9\]* = $false" \ > + "print color == green" "\\$\[0-9\]* = $true" \ > + "print color == blue" "\\$\[0-9\]* = $false" \ > + "print color == enum" > + test_expr "set variable color=1" \ > + "print color == 0" "\\$\[0-9\]* = $false" \ > + "print color == 1" "\\$\[0-9\]* = $true" \ > + "print color == 2" "\\$\[0-9\]* = $false" \ > + "print color == int" > + test_expr "set variable color=green" \ > + "print color != red" "\\$\[0-9\]* = $true" \ > + "print color != green" "\\$\[0-9\]* = $false" \ > + "print color != blue" "\\$\[0-9\]* = $true" \ > + "print color != enum" > + test_expr "set variable color=1" \ > + "print color != 0" "\\$\[0-9\]* = $true" \ > + "print color != 1" "\\$\[0-9\]* = $false" \ > + "print color != 2" "\\$\[0-9\]* = $true" \ > + "print color != int" > + test_expr "set variable color=green" \ > + "print color > red" "\\$\[0-9\]* = $true" \ > + "print color > green" "\\$\[0-9\]* = $false" \ > + "print color > blue" "\\$\[0-9\]* = $false" \ > + "print color > enum" > + test_expr "set variable color=1" \ > + "print color > 0" "\\$\[0-9\]* = $true" \ > + "print color > 1" "\\$\[0-9\]* = $false" \ > + "print color > 2" "\\$\[0-9\]* = $false" \ > + "print color > int" > + test_expr "set variable color=green" \ > + "print color < red" "\\$\[0-9\]* = $false" \ > + "print color < green" "\\$\[0-9\]* = $false" \ > + "print color < blue" "\\$\[0-9\]* = $true" \ > + "print color < enum" > + test_expr "set variable color=1" \ > + "print color < 0" "\\$\[0-9\]* = $false" \ > + "print color < 1" "\\$\[0-9\]* = $false" \ > + "print color < 2" "\\$\[0-9\]* = $true" \ > + "print color < int" > + # make enum a minus > + test_expr "set variable pigment=magenta" \ > + "print pigment == cyan" "\\$\[0-9\]* = $false" \ > + "print pigment == magenta" "\\$\[0-9\]* = $true" \ > + "print pigment == black" "\\$\[0-9\]* = $false" \ > + "print pigment == enum" > + test_expr "set variable pigment=-2" \ > + "print pigment == -3" "\\$\[0-9\]* = $false" \ > + "print pigment == -2" "\\$\[0-9\]* = $true" \ > + "print pigment == 0" "\\$\[0-9\]* = $false" \ > + "print pigment == int" > + test_expr "set variable pigment=magenta" \ > + "print pigment != cyan" "\\$\[0-9\]* = $true" \ > + "print pigment != magenta" "\\$\[0-9\]* = $false" \ > + "print pigment != black" "\\$\[0-9\]* = $true" \ > + "print pigment != enum" > + test_expr "set variable pigment=-2" \ > + "print pigment != -3" "\\$\[0-9\]* = $true" \ > + "print pigment != -2" "\\$\[0-9\]* = $false" \ > + "print pigment != 0" "\\$\[0-9\]* = $true" \ > + "print pigment != int" > + test_expr "set variable pigment=magenta" \ > + "print pigment > cyan" "\\$\[0-9\]* = $true" \ > + "print pigment > magenta" "\\$\[0-9\]* = $false" \ > + "print pigment > black" "\\$\[0-9\]* = $false" \ > + "print pigment > enum" > + test_expr "set variable pigment=-2" \ > + "print pigment > -3" "\\$\[0-9\]* = $true" \ > + "print pigment > -2" "\\$\[0-9\]* = $false" \ > + "print pigment > 0" "\\$\[0-9\]* = $false" \ > + "print pigment > int" > + test_expr "set variable pigment=magenta" \ > + "print pigment < cyan" "\\$\[0-9\]* = $false" \ > + "print pigment < magenta" "\\$\[0-9\]* = $false" \ > + "print pigment < black" "\\$\[0-9\]* = $true" \ > + "print pigment < enum" > + test_expr "set variable pigment=-2" \ > + "print pigment < -3" "\\$\[0-9\]* = $false" \ > + "print pigment < -2" "\\$\[0-9\]* = $false" \ > + "print pigment < 0" "\\$\[0-9\]* = $true" \ > + "print pigment < int" > + # > + # test expressions with "long enum" types > + # > + test_expr "set variable shade=puce" \ > + "print shade == mauve" "\\$\[0-9\]* = $false" \ > + "print shade == puce" "\\$\[0-9\]* = $true" \ > + "print shade == teal" "\\$\[0-9\]* = $false" \ > + "print shade == enum" > + test_expr "set variable shade=0x1000000000000001L" \ > + "print shade == 0x1000000000000000L" "\\$\[0-9\]* = $false" \ > + "print shade == 0x1000000000000001L" "\\$\[0-9\]* = $true" \ > + "print shade == 0x1000000000000002L" "\\$\[0-9\]* = $false" \ > + "print shade == int" > + test_expr "set variable shade=puce" \ > + "print shade != mauve" "\\$\[0-9\]* = $true" \ > + "print shade != puce" "\\$\[0-9\]* = $false" \ > + "print shade != teal" "\\$\[0-9\]* = $true" \ > + "print shade != enum" > + test_expr "set variable shade=0x1000000000000001L" \ > + "print shade != 0x1000000000000000L" "\\$\[0-9\]* = $true" \ > + "print shade != 0x1000000000000001L" "\\$\[0-9\]* = $false" \ > + "print shade != 0x1000000000000002L" "\\$\[0-9\]* = $true" \ > + "print shade != int" > + test_expr "set variable shade=puce" \ > + "print shade > mauve" "\\$\[0-9\]* = $true" \ > + "print shade > puce" "\\$\[0-9\]* = $false" \ > + "print shade > teal" "\\$\[0-9\]* = $false" \ > + "print shade > enum" > + test_expr "set variable shade=0x1000000000000001L" \ > + "print shade > 0x1000000000000000L" "\\$\[0-9\]* = $true" \ > + "print shade > 0x1000000000000001L" "\\$\[0-9\]* = $false" \ > + "print shade > 0x1000000000000002L" "\\$\[0-9\]* = $false" \ > + "print shade > int" > + test_expr "set variable shade=puce" \ > + "print shade < mauve" "\\$\[0-9\]* = $false" \ > + "print shade < puce" "\\$\[0-9\]* = $false" \ > + "print shade < teal" "\\$\[0-9\]* = $true" \ > + "print shade < enum" > + test_expr "set variable shade=0x1000000000000001L" \ > + "print shade < 0x1000000000000000L" "\\$\[0-9\]* = $false" \ > + "print shade < 0x1000000000000001L" "\\$\[0-9\]* = $false" \ > + "print shade < 0x1000000000000002L" "\\$\[0-9\]* = $true" \ > + "print shade < int" > + # make enum a minus > + test_expr "set variable hue=purple" \ > + "print hue == orange" "\\$\[0-9\]* = $false" \ > + "print hue == purple" "\\$\[0-9\]* = $true" \ > + "print hue == white" "\\$\[0-9\]* = $false" \ > + "print hue == enum" > + test_expr "set variable hue=-2L" \ > + "print hue == -3" "\\$\[0-9\]* = $false" \ > + "print hue == -2" "\\$\[0-9\]* = $true" \ > + "print hue == 0" "\\$\[0-9\]* = $false" \ > + "print hue == int" > + test_expr "set variable hue=purple" \ > + "print hue != orange" "\\$\[0-9\]* = $true" \ > + "print hue != purple" "\\$\[0-9\]* = $false" \ > + "print hue != white" "\\$\[0-9\]* = $true" \ > + "print hue != enum" > + test_expr "set variable hue=-2L" \ > + "print hue != -3L" "\\$\[0-9\]* = $true" \ > + "print hue != -2L" "\\$\[0-9\]* = $false" \ > + "print hue != 0L" "\\$\[0-9\]* = $true" \ > + "print hue != int" > + test_expr "set variable hue=purple" \ > + "print hue > orange" "\\$\[0-9\]* = $true" \ > + "print hue > purple" "\\$\[0-9\]* = $false" \ > + "print hue > white" "\\$\[0-9\]* = $false" \ > + "print hue > enum" > + test_expr "set variable hue=-2L" \ > + "print hue > -3L" "\\$\[0-9\]* = $true" \ > + "print hue > -2L" "\\$\[0-9\]* = $false" \ > + "print hue > 0L" "\\$\[0-9\]* = $false" \ > + "print hue > int" > + test_expr "set variable hue=purple" \ > + "print hue < orange" "\\$\[0-9\]* = $false" \ > + "print hue < purple" "\\$\[0-9\]* = $false" \ > + "print hue < white" "\\$\[0-9\]* = $true" \ > + "print hue < enum" > + test_expr "set variable hue=-2L" \ > + "print hue < -3L" "\\$\[0-9\]* = $false" \ > + "print hue < -2L" "\\$\[0-9\]* = $false" \ > + "print hue < 0L" "\\$\[0-9\]* = $true" \ > + "print hue < int" >From kazu@hxi.com Thu Jun 15 21:32:00 2000 From: Kazu Hirata To: gdb-patches@sourceware.cygnus.com Subject: [patch] sim/h8300/compile.c Date: Thu, 15 Jun 2000 21:32:00 -0000 Message-id: <9415.961129944.0@NO-ID-FOUND.mhonarc.org> X-SW-Source: 2000-06/msg00187.html Content-length: 2450 Hi, Attached is a patch for sim/h8300/compile.c. It fixes a bug that causes the following insns to be incorrectly distinguished. 0b 50 inc.w #1,r0 0b d0 inc.w #2,r0 0b 70 inc.l #1,er0 0b f0 inc.l #2,er0 0b 00 adds #1,er0 0b 80 adds #2,er0 0b 90 adds #4,er0 The register operands have nothing to do with the bug. As you can see from the above, the third nibble is very important to distinguish adds from inc.[wl]. When the opcode interpreter looks at each nibble, "looking_for" has "DBIT" in case of inc.[wl] and "KBIT" in case of adds. Here is what the first half of the patch does. When you're looking for "DBIT", you can distinguish inc.w from inc.l by looking at the lower three bits of the third nibble. Since the only possible third nibbles when looking for "DBIT" are 5 and 7, the third nibbles for adds (0, 8, and 9) get rejected. That is why I am ANDing with 7 instead of 5. Here is what the second half of the patch does. Now, when looking for "KBIT", the only possible third nibbles are 0, 8, and 9. All other values must be rejected. Thus, I have "default: goto fail;". The same story applies to dec.w, dec.l, and subs. The only difference is that the first nibble is 1 instead of 0. Just read the above replacing inc with dec and adds with subs. Thanks, Kazu Hirata ===File ~/gnu/gdb/ChangeLog-compile.c======================= 2000-06-15 Kazu Hirata * compile.c (decode): Distinguish inc/dec.[wl] and adds/subs correctly. ============================================================ ===File ~/gnu/gdb/compile.patch============================= Index: compile.c =================================================================== RCS file: /cvs/src/src/sim/h8300/compile.c,v retrieving revision 1.3 diff -u -r1.3 compile.c --- compile.c 2000/06/13 20:32:01 1.3 +++ compile.c 2000/06/16 03:57:35 @@ -220,7 +220,10 @@ if (looking_for & DBIT) { - if ((looking_for & 5) != (thisnib & 5)) + /* Exclude adds/subs by looking at bit 0 and 2, and + make sure the operand size, either w or l, + matches by looking at bit 1. */ + if ((looking_for & 7) != (thisnib & 7)) goto fail; abs = (thisnib & 0x8) ? 2 : 1; @@ -293,6 +296,8 @@ case 0: abs = 1; break; + default: + goto fail; } } else if (looking_for & L_8) ============================================================