Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: brobecker@adacore.com (Joel Brobecker)
Cc: gdb-patches@sourceware.org
Subject: Re: [commit/powerpc] crash trying to allocate memory in inferior
Date: Wed, 26 Oct 2011 17:31:00 -0000	[thread overview]
Message-ID: <201110261724.p9QHOke8022453@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <1319475191-2379-1-git-send-email-brobecker@adacore.com> from "Joel Brobecker" at Oct 24, 2011 09:53:11 AM

Joel Brobeker wrote:

>         * ppc-sysv-tdep.c (do_ppc_sysv_return_value): Do not check
>         FUNC_TYPE's calling convention if FUNC_TYPE is not a function.

Huh, I had just been testing a different patch for the same problem ...

Since this patch is a bit more general (it also fixes the 64-bit case,
and actually handles pointers to OpenCL functions), I've checked it
in anyway.

Tested on powerpc64-linux.

Bye,
Ulrich


ChangeLog:

	* ppc-sysv-tdep.c (ppc_sysv_use_opencl_abi): New function.
	(ppc_sysv_abi_push_dummy_call): Use it.
	(do_ppc_sysv_return_value): Likewise.
	(ppc64_sysv_abi_push_dummy_call): Likewise.
	(ppc64_sysv_abi_return_value): Likewise.


Index: gdb/ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.64
diff -u -p -r1.64 ppc-sysv-tdep.c
--- gdb/ppc-sysv-tdep.c	24 Oct 2011 16:51:36 -0000	1.64
+++ gdb/ppc-sysv-tdep.c	26 Oct 2011 16:12:56 -0000
@@ -32,6 +32,22 @@
 #include "infcall.h"
 #include "dwarf2.h"
 
+
+/* Check whether FTPYE is a (pointer to) function type that should use
+   the OpenCL vector ABI.  */
+
+static int
+ppc_sysv_use_opencl_abi (struct type *ftype)
+{
+  ftype = check_typedef (ftype);
+
+  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
+    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
+
+  return (TYPE_CODE (ftype) == TYPE_CODE_FUNC
+	  && TYPE_CALLING_CONVENTION (ftype) == DW_CC_GDB_IBM_OpenCL);
+}
+
 /* Pass the arguments in either registers, or in the stack.  Using the
    ppc sysv ABI, the first eight words of the argument list (that might
    be less than eight parameters if some parameters occupy more than one
@@ -51,8 +67,7 @@ ppc_sysv_abi_push_dummy_call (struct gdb
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct type *ftype;
-  int opencl_abi = 0;
+  int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
   ULONGEST saved_sp;
   int argspace = 0;		/* 0 is an initial wrong guess.  */
   int write_pass;
@@ -62,13 +77,6 @@ ppc_sysv_abi_push_dummy_call (struct gdb
   regcache_cooked_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch),
 				 &saved_sp);
 
-  ftype = check_typedef (value_type (function));
-  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
-    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
-  if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
-      && TYPE_CALLING_CONVENTION (ftype) == DW_CC_GDB_IBM_OpenCL)
-    opencl_abi = 1;
-
   /* Go through the argument list twice.
 
      Pass 1: Figure out how much new stack space is required for
@@ -689,12 +697,7 @@ do_ppc_sysv_return_value (struct gdbarch
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int opencl_abi = 0;
-
-  if (func_type
-      && TYPE_CODE (func_type) == TYPE_CODE_FUNC
-      && TYPE_CALLING_CONVENTION (func_type) == DW_CC_GDB_IBM_OpenCL)
-    opencl_abi = 1;
+  int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0;
 
   gdb_assert (tdep->wordsize == 4);
 
@@ -1115,8 +1118,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
   CORE_ADDR func_addr = find_function_addr (function, NULL);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct type *ftype;
-  int opencl_abi = 0;
+  int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
   ULONGEST back_chain;
   /* See for-loop comment below.  */
   int write_pass;
@@ -1146,13 +1148,6 @@ ppc64_sysv_abi_push_dummy_call (struct g
   regcache_cooked_read_unsigned (regcache, gdbarch_sp_regnum (gdbarch),
 				 &back_chain);
 
-  ftype = check_typedef (value_type (function));
-  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
-    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
-  if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
-      && TYPE_CALLING_CONVENTION (ftype) == DW_CC_GDB_IBM_OpenCL)
-    opencl_abi = 1;
-
   /* Go through the argument list twice.
 
      Pass 1: Compute the function call's stack space and register
@@ -1721,11 +1716,7 @@ ppc64_sysv_abi_return_value (struct gdba
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int opencl_abi = 0;
-
-  if (func_type
-      && TYPE_CALLING_CONVENTION (func_type) == DW_CC_GDB_IBM_OpenCL)
-    opencl_abi = 1;
+  int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0;
 
   /* This function exists to support a calling convention that
      requires floating-point registers.  It shouldn't be used on


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2011-10-26 17:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 17:48 [rfc] Implement support for IBM XL C for OpenCL vector ABI Ulrich Weigand
2011-02-04 16:47 ` Tom Tromey
2011-02-07 19:25   ` Ulrich Weigand
2011-02-07 20:05     ` Tom Tromey
2011-02-08 13:30       ` Ulrich Weigand
2011-02-14 12:59         ` Luis Machado
2011-02-14 12:07           ` Luis Machado
2011-02-14 13:41           ` Yao Qi
2011-10-24 17:09     ` [commit/powerpc] crash trying to allocate memory in inferior Joel Brobecker
2011-10-26 17:31       ` Ulrich Weigand [this message]
2011-10-26 18:16         ` Joel Brobecker
2011-02-13 15:38 ` [rfc] Implement support for IBM XL C for OpenCL vector ABI Mark Kettenis
2011-02-14 13:47   ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201110261724.p9QHOke8022453@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox