Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Wu Zhou <woodzltc@cn.ibm.com>
To: drow@false.org
Cc: gdb-patches@sources.redhat.com
Subject: [RFA]: Patch to fix the SEGV error when printing f77 array element
Date: Thu, 09 Jun 2005 11:00:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.63.0506091750410.27702@plinuxt18.cn.ibm.com> (raw)

Daniel, 

I had cleaned up the patch to fix the SEGV error we discussed on gdb@ the
days before and tested it on ppc64 arch with the latest CVS tree.  It 
works ok.  Please review and comment.  Thanks.

2005-06-9  Wu Zhou  <woodzltc@cn.ibm.com>

	* eval.c (evaluate_subexp_standard): Add code to check the target
	type of a TYPE_CODE_PTR value when we encounter a f77 undetermined
	arglist.  If it is TYPE_CODE_ARRAY or TYPE_CODE_STRING, jump to 
	relevant code path, else go on with the original path.

Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.55
diff -c -p -r1.55 eval.c
*** eval.c	26 May 2005 20:48:58 -0000	1.55
--- eval.c	9 Jun 2005 09:23:02 -0000
*************** evaluate_subexp_standard (struct type *e
*** 1254,1260 ****
  	case TYPE_CODE_STRING:
  	  goto op_f77_substr;
  
- 	case TYPE_CODE_PTR:
  	case TYPE_CODE_FUNC:
  	  /* It's a function call. */
  	  /* Allocate arg vector, including space for the function to be
--- 1254,1259 ----
*************** evaluate_subexp_standard (struct type *e
*** 1267,1272 ****
--- 1266,1298 ----
  	  argvec[tem] = 0;	/* signal end of arglist */
  	  goto do_call_it;
  
+ 	case TYPE_CODE_PTR:
+ 	  /* Fortran always passes variables to subroutines as pointer. 
+ 	     So we need to look into its target type to see if it is 
+ 	     array subscript or substring operations.  */
+ 	  switch (TYPE_CODE (TYPE_TARGET_TYPE (type)))
+ 	    {
+ 	    case TYPE_CODE_ARRAY:
+ 	      arg1 = value_ind (arg1);
+ 	      type = check_typedef (value_type (arg1));
+ 	      goto multi_f77_subscript;
+ 
+ 	    case TYPE_CODE_STRING:
+ 	      arg1 = value_ind (arg1);
+ 	      type = check_typedef (value_type (arg1));
+ 	      goto op_f77_substr;
+ 
+ 	    default:
+ 	      /* It's a function call.  */
+ 	      argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 2));
+ 	      argvec[0] = arg1;
+ 	      tem = 1;
+ 	      for (; tem <= nargs; tem++)
+ 		argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+ 	      argvec[tem] = 0;	/* signal end of arglist */
+ 	      goto do_call_it;
+ 	    }
+ 
  	default:
  	  error (_("Cannot perform substring on this type"));
  	}


Cheers
- Wu Zhou


             reply	other threads:[~2005-06-09 11:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-09 11:00 Wu Zhou [this message]
2005-06-09 13:20 ` Daniel Jacobowitz
2005-06-10  7:37   ` Wu Zhou
2005-06-13  2:56     ` Daniel Jacobowitz
2005-06-13  8:10 Wu Zhou

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=Pine.LNX.4.63.0506091750410.27702@plinuxt18.cn.ibm.com \
    --to=woodzltc@cn.ibm.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    /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