* [RFA]: Patch to fix the SEGV error when printing f77 array element
@ 2005-06-09 11:00 Wu Zhou
2005-06-09 13:20 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Wu Zhou @ 2005-06-09 11:00 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA]: Patch to fix the SEGV error when printing f77 array element
2005-06-09 11:00 [RFA]: Patch to fix the SEGV error when printing f77 array element Wu Zhou
@ 2005-06-09 13:20 ` Daniel Jacobowitz
2005-06-10 7:37 ` Wu Zhou
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-06-09 13:20 UTC (permalink / raw)
To: Wu Zhou; +Cc: gdb-patches
On Thu, Jun 09, 2005 at 06:02:03PM +0800, Wu Zhou wrote:
> 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.
Can you handle TYPE_CODE_PTR before the switch statement, instead?
Also, rather than default, you can probably check that the target type
of the pointer is TYPE_CODE_FUNC.
Do you feel up to adding our first compilable fortran test to the
testsuite?
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA]: Patch to fix the SEGV error when printing f77 array element
2005-06-09 13:20 ` Daniel Jacobowitz
@ 2005-06-10 7:37 ` Wu Zhou
2005-06-13 2:56 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Wu Zhou @ 2005-06-10 7:37 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Thu, 9 Jun 2005, Daniel Jacobowitz wrote:
> On Thu, Jun 09, 2005 at 06:02:03PM +0800, Wu Zhou wrote:
> > 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.
>
> Can you handle TYPE_CODE_PTR before the switch statement, instead?
>
> Also, rather than default, you can probably check that the target type
> of the pointer is TYPE_CODE_FUNC.
Good point. What about the following re-worked patch? Thanks.
2005-06-10 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 array, string or function, work on the target
value instead.
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 10 Jun 2005 07:04:12 -0000
*************** evaluate_subexp_standard (struct type *e
*** 1246,1251 ****
--- 1246,1269 ----
type = check_typedef (value_type (arg1));
code = TYPE_CODE (type);
+ if (code == TYPE_CODE_PTR)
+ {
+ /* Fortran always passes variable to subroutines as pointer.
+ So we need to look into its target type to see if it is
+ array, string or function. If it is, we need to switch
+ to the target value the original one points to. */
+ struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (TYPE_CODE (target_type) == TYPE_CODE_ARRAY
+ || TYPE_CODE (target_type) == TYPE_CODE_STRING
+ || TYPE_CODE (target_type) == TYPE_CODE_FUNC)
+ {
+ arg1 = value_ind (arg1);
+ type = check_typedef (value_type (arg1));
+ code = TYPE_CODE (type);
+ }
+ }
+
switch (code)
{
case TYPE_CODE_ARRAY:
> Do you feel up to adding our first compilable fortran test to the
> testsuite?
Yes, I am thinking of adding a testcase to verify this. But do I need
to keep some principles/tips in mind when adding a new testcase to the
testsuite? As you might know, I didn't do that before. TIA.
Cheers
- Wu Zhou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA]: Patch to fix the SEGV error when printing f77 array element
2005-06-10 7:37 ` Wu Zhou
@ 2005-06-13 2:56 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2005-06-13 2:56 UTC (permalink / raw)
To: Wu Zhou; +Cc: gdb-patches
On Fri, Jun 10, 2005 at 03:22:50PM +0800, Wu Zhou wrote:
> 2005-06-10 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 array, string or function, work on the target
> value instead.
This version is fine. Thanks!
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA]: Patch to fix the SEGV error when printing f77 array element
@ 2005-06-13 8:10 Wu Zhou
0 siblings, 0 replies; 5+ messages in thread
From: Wu Zhou @ 2005-06-13 8:10 UTC (permalink / raw)
To: gdb-patches
Quoting Daniel Jacobowitz <drow@false.org>:
> This version is fine. Thanks!
Commited. Thanks for reviewing this.
Cheers
- Wu Zhou
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-13 8:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-09 11:00 [RFA]: Patch to fix the SEGV error when printing f77 array element Wu Zhou
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox