From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Molenda To: Jim Kingdon Cc: gdb-patches@sourceware.cygnus.com Subject: Re: Problem with "next" in main on sparc Date: Mon, 08 Nov 1999 16:28:00 -0000 Message-id: <19991108162820.A8447@cygnus.com> References: <199911011938.OAA32716@devserv.devel.redhat.com> X-SW-Source: 1999-q4/msg00210.html On Mon, Nov 01, 1999 at 02:38:31PM -0500, Jim Kingdon wrote: > Here is a bug in which GDB gets in an infinite loop. I am sorry I took so long to reply. I resolved to look into this before I sent out this week's snapshot. I tried reproducing it on a SPARC Solaris box with gcc and I didn't have the problem described. AFAIK we don't have a SPARC RH box locally so I can't test that. The GCC I was using is not one of the FSF releasese, it is similar to the GCC working sources around February or March. Maybe you show me the end bit of try.s if you compile "gcc -S -g try.c" on your side? I'm getting this here: main: .stabn 68,0,3,.LM1-main .LM1: !#PROLOGUE# 0 save %sp, -112, %sp !#PROLOGUE# 1 .stabn 68,0,4,.LM2-main .LM2: sethi %hi(foo), %o1 or %o1, %lo(foo), %o0 mov 2, %o1 st %o1, [%o0] .stabn 68,0,5,.LM3-main .LM3: .LL2: ret restore .LLfe1: .size main,.LLfe1-main .LLscope0: Which GDB (current development version) handles correctly: ; ./gdb -q a.out (gdb) b main Breakpoint 1 at 0x10704: file try.c, line 4. (gdb) run Starting program: /horton/jsm/comp-tools/i-sparc/bin/a.out Breakpoint 1, main () at try.c:4 4 foo = 2; (gdb) n 5 } (gdb) 0x105fc in .nope () (gdb) Single stepping until exit from function .nope, which has no line number information. Program exited with code 01. (gdb) Jason >From guo@cup.hp.com Tue Nov 09 10:00:00 1999 From: Jimmy Guo To: gdb-patches@sourceware.cygnus.com Subject: (patch) hpjyg16: valarith.c Date: Tue, 09 Nov 1999 10:00:00 -0000 Message-id: X-SW-Source: 1999-q4/msg00211.html Content-length: 6524 This patch adds support for exponentiation, and (in)equality of boolean / string. ChangeLog: 1999-11-09 Jimmy Guo * valarith.c (value_binop): Add support for exponentiation, equal, not equal. (my_strcmp): New function. (value_equal,value_less): Add string equality comparison support. Index: gdb/valarith.c /opt/gnu/bin/diff -r -c -N /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/valarith.c gdb/valarith.c *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/valarith.c Mon Nov 8 16:02:14 1999 --- gdb/valarith.c Mon Nov 8 16:07:05 1999 *************** *** 28,33 **** --- 28,34 ---- #include "language.h" #include "demangle.h" #include "gdb_string.h" + #include /* Define whether or not the C operator '/' truncates towards zero for differently signed operands (truncation direction is undefined in C). */ *************** *** 573,579 **** value_concat (arg1, arg2) value_ptr arg1, arg2; { ! register value_ptr inval1, inval2, outval; int inval1len, inval2len; int count, idx; char *ptr; --- 574,580 ---- value_concat (arg1, arg2) value_ptr arg1, arg2; { ! register value_ptr inval1, inval2, outval = NULL; int inval1len, inval2len; int count, idx; char *ptr; *************** *** 738,744 **** /* FIXME-if-picky-about-floating-accuracy: Should be doing this in target format. real.c in GCC probably has the necessary code. */ ! DOUBLEST v1, v2, v; v1 = value_as_double (arg1); v2 = value_as_double (arg2); switch (op) --- 739,745 ---- /* FIXME-if-picky-about-floating-accuracy: Should be doing this in target format. real.c in GCC probably has the necessary code. */ ! DOUBLEST v1, v2, v = 0; v1 = value_as_double (arg1); v2 = value_as_double (arg2); switch (op) *************** *** 759,764 **** --- 760,771 ---- v = v1 / v2; break; + case BINOP_EXP: + v = pow (v1, v2); + if (errno) + error ("Cannot perform exponentiation: %s", strerror (errno)); + break; + default: error ("Integer-only operation on floating point number."); } *************** *** 779,785 **** && TYPE_CODE (type2) == TYPE_CODE_BOOL) { ! LONGEST v1, v2, v; v1 = value_as_long (arg1); v2 = value_as_long (arg2); --- 786,792 ---- && TYPE_CODE (type2) == TYPE_CODE_BOOL) { ! LONGEST v1, v2, v = 0; v1 = value_as_long (arg1); v2 = value_as_long (arg2); *************** *** 795,800 **** --- 802,815 ---- case BINOP_BITWISE_XOR: v = v1 ^ v2; + break; + + case BINOP_EQUAL: + v = v1 == v2; + break; + + case BINOP_NOTEQUAL: + v = v1 != v2; break; default: *************** *** 855,861 **** if (unsigned_operation) { ! ULONGEST v1, v2, v; v1 = (ULONGEST) value_as_long (arg1); v2 = (ULONGEST) value_as_long (arg2); --- 870,876 ---- if (unsigned_operation) { ! ULONGEST v1, v2, v = 0; v1 = (ULONGEST) value_as_long (arg1); v2 = (ULONGEST) value_as_long (arg2); *************** *** 884,889 **** --- 899,910 ---- v = v1 / v2; break; + case BINOP_EXP: + v = pow (v1, v2); + if (errno) + error ("Cannot perform exponentiation: %s", strerror (errno)); + break; + case BINOP_REM: v = v1 % v2; break; *************** *** 949,954 **** --- 970,979 ---- v = v1 == v2; break; + case BINOP_NOTEQUAL: + v = v1 != v2; + break; + case BINOP_LESS: v = v1 < v2; break; *************** *** 976,982 **** } else { ! LONGEST v1, v2, v; v1 = value_as_long (arg1); v2 = value_as_long (arg2); --- 1001,1007 ---- } else { ! LONGEST v1, v2, v = 0; v1 = value_as_long (arg1); v2 = value_as_long (arg2); *************** *** 996,1001 **** --- 1021,1032 ---- case BINOP_DIV: v = v1 / v2; + break; + + case BINOP_EXP: + v = pow (v1, v2); + if (errno) + error ("Cannot perform exponentiation: %s", strerror (errno)); break; case BINOP_REM: *************** *** 1125,1130 **** --- 1156,1192 ---- return len < 0; } + /* Perform a comparison on two string values (whose content are not + necessarily null terminated) based on their length */ + + static int + my_strcmp (arg1, arg2) + register value_ptr arg1, arg2; + { + int len1 = TYPE_LENGTH (VALUE_TYPE (arg1)); + int len2 = TYPE_LENGTH (VALUE_TYPE (arg2)); + char *s1 = VALUE_CONTENTS (arg1); + char *s2 = VALUE_CONTENTS (arg2); + int i, len = len1 < len2 ? len1 : len2; + + for (i = 0; i < len; i++) + { + if (s1[i] < s2[i]) + return -1; + else if (s1[i] > s2[i]) + return 1; + else + continue; + } + + if (len1 < len2) + return -1; + else if (len1 > len2) + return 1; + else + return 0; + } + /* Simulate the C operator == by returning a 1 iff ARG1 and ARG2 have equal contents. */ *************** *** 1175,1180 **** --- 1237,1246 ---- } return len < 0; } + else if (code1 == TYPE_CODE_STRING && code2 == TYPE_CODE_STRING) + { + return my_strcmp (arg1, arg2) == 0; + } else { error ("Invalid type combination in equality test."); *************** *** 1217,1223 **** return value_as_pointer (arg1) < (CORE_ADDR) value_as_long (arg2); else if (code2 == TYPE_CODE_PTR && (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL)) return (CORE_ADDR) value_as_long (arg1) < value_as_pointer (arg2); ! else { error ("Invalid type combination in ordering comparison."); --- 1283,1290 ---- return value_as_pointer (arg1) < (CORE_ADDR) value_as_long (arg2); else if (code2 == TYPE_CODE_PTR && (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL)) return (CORE_ADDR) value_as_long (arg1) < value_as_pointer (arg2); ! else if (code1 == TYPE_CODE_STRING && code2 == TYPE_CODE_STRING) ! return my_strcmp (arg1, arg2) < 0; else { error ("Invalid type combination in ordering comparison.");