From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16573 invoked by alias); 16 Mar 2012 12:15:26 -0000 Received: (qmail 16522 invoked by uid 22791); 16 Mar 2012 12:15:09 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_BJ X-Spam-Check-By: sourceware.org Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Mar 2012 12:14:54 +0000 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3V8QbK4WN6z4Kh24 for ; Fri, 16 Mar 2012 13:14:53 +0100 (CET) X-Auth-Info: xZTkHRk9ouvJpd/ViS84jb9b/9eXf33P113v4l9EwGk= Received: from igel.home (ppp-93-104-154-158.dynamic.mnet-online.de [93.104.154.158]) by mail.mnet-online.de (Postfix) with ESMTPA id 3V8QbK1J34z4KK5X for ; Fri, 16 Mar 2012 13:14:53 +0100 (CET) Received: by igel.home (Postfix, from userid 501) id C36A1CA29F; Fri, 16 Mar 2012 13:14:52 +0100 (CET) From: Andreas Schwab To: gdb-patches@sourceware.org Subject: [PATCH] Cast function pointer to expected type X-Yow: .. Now I think I just reached the state of HYPERTENSION that comes JUST BEFORE you see the TOTAL at the SAFEWAY CHECKOUT COUNTER! Date: Fri, 16 Mar 2012 12:15:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-03/txt/msg00603.txt.bz2 The cast is needed to select the correct function call ABI. Andreas. 2012-03-16 Andreas Schwab * linux-fork.c (inferior_call_waitpid): Cast function pointer to expected type. (checkpoint_command): Likewise. diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 028fcbc..ddbfa26 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -29,6 +29,8 @@ #include "linux-fork.h" #include "linux-nat.h" #include "gdbthread.h" +#include "ui-out.h" +#include "valprint.h" #include #include "gdb_wait.h" @@ -431,6 +433,7 @@ inferior_call_waitpid (ptid_t pptid, int pid) struct objfile *waitpid_objf; struct value *waitpid_fn = NULL; struct value *argv[4], *retv; + struct type *type; struct gdbarch *gdbarch = get_current_arch (); struct fork_info *oldfp = NULL, *newfp = NULL; struct cleanup *old_cleanup; @@ -459,6 +462,11 @@ inferior_call_waitpid (ptid_t pptid, int pid) if (!waitpid_fn) goto out; + /* Cast function pointer to expected type. */ + type = lookup_function_type (builtin_type (gdbarch)->builtin_int); + type = lookup_pointer_type (type); + waitpid_fn = value_cast (type, waitpid_fn); + /* Get the argv. */ argv[0] = value_from_longest (builtin_type (gdbarch)->builtin_int, pid); argv[1] = value_from_pointer (builtin_type (gdbarch)->builtin_data_ptr, 0); @@ -650,6 +658,7 @@ checkpoint_command (char *args, int from_tty) struct target_waitstatus last_target_waitstatus; ptid_t last_target_ptid; struct value *fork_fn = NULL, *ret; + struct type *type; struct fork_info *fp; pid_t retpid; struct cleanup *old_chain; @@ -673,13 +682,17 @@ checkpoint_command (char *args, int from_tty) error (_("checkpoint: can't find fork function in inferior.")); gdbarch = get_objfile_arch (fork_objf); - ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); /* Tell linux-nat.c that we're checkpointing this inferior. */ old_chain = make_cleanup_restore_integer (&checkpointing_pid); checkpointing_pid = PIDGET (inferior_ptid); - ret = call_function_by_hand (fork_fn, 0, &ret); + /* Cast function pointer to expected type. */ + type = lookup_function_type (builtin_type (gdbarch)->builtin_int); + type = lookup_pointer_type (type); + fork_fn = value_cast (type, fork_fn); + + ret = call_function_by_hand (fork_fn, 0, NULL); do_cleanups (old_chain); if (!ret) /* Probably can't happen. */ error (_("checkpoint: call_function_by_hand returned null.")); -- 1.7.9.4 -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."