From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Philippe De Muyter" To: gdb-patches@cygnus.com (gdb-patches@cygnus.com) Subject: function parameters regression Date: Sat, 10 Apr 1999 16:46:00 -0000 Message-id: <199904102346.BAA17978@mail.macqel.be> X-SW-Source: 1999-q2/msg00007.html On m68k-motorola-sysv (COFF), the following tests fail, because of a hp-specific new code in valops.c. Can someone fix that ? For me, testing only `using_gcc' seems too wide. p t_func_values(add,func_val2) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_func_values(add,func_val2) p t_func_values(func_val1,doubleit) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_func_values(func_val1,doubleit) p t_call_add(func_val1,3,4) $48 = 7 (gdb) PASS: gdb.base/callfuncs2.exp: p t_call_add(func_val1,3,4) p t_call_add(add,3,4) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_call_add(add,3,4) Culprit code : /*elz: this code is to handle the case in which the function to be called has a pointer to function as parameter and the corresponding actual argu ment is the address of a function and not a pointer to function variable. In aCC compiled code, the calls through pointers to functions (in the bo dy of the function called by hand) are made via $$dyncall_external which requires some registers setting, this is taken care of if we call via a function pointer variable, but not via a function address. In cc this is not a problem. */ if (using_gcc == 0) if (param_type) /* if this parameter is a pointer to function*/ if (TYPE_CODE (param_type) == TYPE_CODE_PTR) if (TYPE_CODE (param_type->target_type) == TYPE_CODE_FUNC) /* elz: FIXME here should go the test about the compiler used to compile the target. We want to issue the error message only if the compiler used was HP's aCC. If we used HP's cc, then there is no problem and no need to return at this point */ if (using_gcc == 0) /* && compiler == aCC*/ /* go see if the actual parameter is a variable of type pointer to function or just a function */ if (args[i]->lval == not_lval) { char *arg_name; if (find_pc_partial_function((CORE_ADDR)args[i]->aligner.con tents[0], &arg_name, NULL, NULL)) error("\ You cannot use function <%s> as argument. \n\ You must use a pointer to function type variable. Command ignored.", arg_name); } From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Philippe De Muyter" To: gdb-patches@cygnus.com (gdb-patches@cygnus.com) Subject: function parameters regression Date: Sat, 10 Apr 1999 17:40:00 -0000 Message-ID: <199904102346.BAA17978@mail.macqel.be> X-SW-Source: 1999-04/msg00007.html Message-ID: <19990410174000.Y-iQuoc56RqFiUKQ3ChKMwe0SXqq-9JW7jG1SQNI_Fw@z> On m68k-motorola-sysv (COFF), the following tests fail, because of a hp-specific new code in valops.c. Can someone fix that ? For me, testing only `using_gcc' seems too wide. p t_func_values(add,func_val2) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_func_values(add,func_val2) p t_func_values(func_val1,doubleit) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_func_values(func_val1,doubleit) p t_call_add(func_val1,3,4) $48 = 7 (gdb) PASS: gdb.base/callfuncs2.exp: p t_call_add(func_val1,3,4) p t_call_add(add,3,4) You cannot use function as argument. You must use a pointer to function type variable. Command ignored. (gdb) FAIL: gdb.base/callfuncs2.exp: p t_call_add(add,3,4) Culprit code : /*elz: this code is to handle the case in which the function to be called has a pointer to function as parameter and the corresponding actual argu ment is the address of a function and not a pointer to function variable. In aCC compiled code, the calls through pointers to functions (in the bo dy of the function called by hand) are made via $$dyncall_external which requires some registers setting, this is taken care of if we call via a function pointer variable, but not via a function address. In cc this is not a problem. */ if (using_gcc == 0) if (param_type) /* if this parameter is a pointer to function*/ if (TYPE_CODE (param_type) == TYPE_CODE_PTR) if (TYPE_CODE (param_type->target_type) == TYPE_CODE_FUNC) /* elz: FIXME here should go the test about the compiler used to compile the target. We want to issue the error message only if the compiler used was HP's aCC. If we used HP's cc, then there is no problem and no need to return at this point */ if (using_gcc == 0) /* && compiler == aCC*/ /* go see if the actual parameter is a variable of type pointer to function or just a function */ if (args[i]->lval == not_lval) { char *arg_name; if (find_pc_partial_function((CORE_ADDR)args[i]->aligner.con tents[0], &arg_name, NULL, NULL)) error("\ You cannot use function <%s> as argument. \n\ You must use a pointer to function type variable. Command ignored.", arg_name); } >From pb@nexus.co.uk Mon Apr 12 04:35:00 1999 From: Philip Blundell To: gdb-patches@cygnus.com Subject: patch to use strerror in gdbserver Date: Mon, 12 Apr 1999 04:35:00 -0000 Message-id: X-SW-Source: 1999-04/msg00008.html Content-length: 2262 Some of the gdbserver code has trouble on Linux with GNU libc 2.1 because it redeclares sys_errlist in a way that conflicts with the library headers. Since libiberty provides strerror on platforms that don't have it, we might as well make use of it. 1999-04-11 Philip Blundell * gdbserver/utils.c (perror_with_name): Use strerror rather than sys_errlist. Include , don't declare errno directly. * gdbserver/gdbreplay.c (perror_with_name): Likewise. diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/gdbserver/gdbreplay.c gdb/gdbserver/gdbreplay.c --- /home/phil/gdb/clean/gdb-4.17/gdb/gdbserver/gdbreplay.c Sun Apr 11 21:57:15 1999 +++ gdb/gdbserver/gdbreplay.c Sun Apr 11 19:16:26 1999 @@ -27,6 +27,7 @@ #include #include #include +#include /* Sort of a hack... */ #define EOL (EOF - 1) @@ -41,20 +42,15 @@ perror_with_name (string) char *string; { - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - char *err; + char *err = strerror (errno); char *combined; - err = (errno < sys_nerr) ? sys_errlist[errno] : "unknown error"; combined = (char *) alloca (strlen (err) + strlen (string) + 3); strcpy (combined, string); strcat (combined, ": "); strcat (combined, err); - fprintf (stderr, "\n%s.\n", combined); - fflush (stderr); - exit (1); + + error ("%s.", combined); } static void diff -u --recursive --new-file /home/phil/gdb/clean/gdb-4.17/gdb/gdbserver/utils.c gdb/gdbserver/utils.c --- /home/phil/gdb/clean/gdb-4.17/gdb/gdbserver/utils.c Sat Aug 9 05:49:48 1997 +++ gdb/gdbserver/utils.c Sun Apr 11 15:34:56 1999 @@ -20,6 +20,7 @@ #include "server.h" #include #include +#include /* Generally useful subroutines used throughout the program. */ @@ -31,16 +32,8 @@ perror_with_name (string) char *string; { - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - char *err; + char *err = strerror (errno); char *combined; - - if (errno < sys_nerr) - err = sys_errlist[errno]; - else - err = "unknown error"; combined = (char *) alloca (strlen (err) + strlen (string) + 3); strcpy (combined, string);