[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2069.0. "step/return debugger issue" by CSC32::J_HENSON (Don't get even, get ahead!) Fri Jan 24 1997 15:32

dec c for openvms Vax V5.3, ovms vax v6.2, dec c alpha v5.5-002, ovms alpha v7.0

A customer is reporting a difference in the way in which Dec C and Vax C
generate code for the debug command step/return.  The attached program
can be used to illustrate the difference.

With Vax C, the step/return command will cause execution to stop at
line 5.  With Dec C (I was not able to test with current version of
Dec C for OpenVMS VAX), it executes the entire program without breaking
on the break.  Although the example provided is rather simplistic, the
customer is reporting the same thing is much larger functions with
multiple return statements.  The Dec C behavior makes debugging
difficult for the customer.

Is this a C or debugger issue?  

Thanks,

Jerry

============================================================================
$create tst_step.c
 main()
 {
   int x = 1;
   if (x)
     return(1);
   else
     return(0);
 }
$cc/noop/deb tst_step
$link/deb tst_step
$run tst_step  !issue the step/return command at beginning of program

T.RTitleUserPersonal
Name
DateLines
2069.1Did they get to the main program first?WIBBIN::NOYCEPulling weeds, pickin' stonesFri Jan 24 1997 16:1539
I tested this with DEC C V5.5-002 and DEBUG T7.1-013 on
OpenVMS Alpha V6.2-1H2, but I think this should hold true
for all Alpha versions ...

Did the user notice this message?
	%DEBUG-I-NOTATMAIN, Type GO to reach MAIN program

In order to construct the argcnt and argptr values, and set
up C signal handling, DEC C builds a "wrapper" main program
around the user's main program.  (Several other languages have
done this for a long time.)  If you follow the directions,
this is what you will see:

DBG> go
break at routine TST_STEP\main
     3:    int x = 1;
DBG> step/ret
stepped on return from TST_STEP\main\%LINE 3 to TST_STEP\main\%LINE 8
     8:  }
DBG> e r0
TST_STEP\main\%R0:      0000000000000001
DBG> g
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG>

Since the "wrapper" routine calls SYS$EXIT instead of returning, this
is what you see if you don't start by saying GO:

DBG> step/ret
break at routine TST_STEP\main
     3:    int x = 1;
DBG> go
%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
DBG>

This is entirely expected.

If there's some other behavior that's upsetting your customer, or if
the versions you listed don't behave as shown here, please let us know.
2069.2DuplicatedDECCXL::WIBECANThat's the way it is, in Engineering!Fri Jan 24 1997 16:4230
Bill, I believe what the customer would like is for the program to stop on the
"return" statement that fires, rather than on the curly brace.  On Alpha, there
is just the one RET and the "return" statements are really branches, so that
may be the reason for the behavior.

Actually, I just tried this on VAX using DEC C, and the behavior is exactly as
described: the program runs to completion with no stop at all.  Here is a
screen dump:

DECCXX$ run b

         OpenVMS VAX DEBUG Version V6.2-000

Language is C, module set to B

DBG> step/return
Is 'Normal successful completion'
DBG>  exit

Under VAX C, the program stops at the "return" statement that fires, so VAX C
wins by both methods.

Looking at the VAX machine code for DEC C and VAX C, I see that DEC C has no
actual RET instruction in the code path; it ends by call SYS$EXIT.  VAX C has
RET instructions in the code path, one for each "return" statement.

I'll log this as a bug.  Am I correct in assuming the customer would prefer the
VAX C behavior on Alpha platforms as well?

						Brian
2069.3Maybe, but...CSC32::J_HENSONDon't get even, get ahead!Fri Jan 24 1997 17:0864
>>      <<< Note 2069.1 by WIBBIN::NOYCE "Pulling weeds, pickin' stones" 
>>                  -< Did they get to the main program first? >-

>>I tested this with DEC C V5.5-002 and DEBUG T7.1-013 on
>>OpenVMS Alpha V6.2-1H2, but I think this should hold true
>>for all Alpha versions ...

>>Did the user notice this message?
>>	%DEBUG-I-NOTATMAIN, Type GO to reach MAIN program

Actually, the user reported this with dec c/vax.  I'm the one who
extended the testing to dec c/alpa.  I did type GO (didn't get
$200, though) and waited until I got to the start of the program
before issuing the step/return command.

I got the same results as you are posting.

What the user wants is the same behavior they got with Vax C.  That's
what they're used to, and what they've come to expect.  If this is an
issue of educating the customer, I can try that.  However, it does seem
reasonable to expect step/return to break on the return statement, and
not wait until the end of the module.  After all, a return is a return,
regardless of how it is implemented.

How about the situation where the multiple returns are in a called function?
When I modified the original code as follows, I got similar results.  I
have attached the debug log to the end of this reply.

Thanks,

Jerry

=============================================================================

 main()
 {
   int sub(int),stat,x=1;
   stat = sub(x);
 }
int sub(int x)
{
   if (x)
     return(1);
   else
     return(0);
 }

---------------------debug.log------------------------------------

g
!break at routine TST_STEP2\main
!     3:    int sub(int),stat,x=1;
se br sub
g
!break at routine TST_STEP2\sub
!     8:    if (x)
step/return
!stepped on return from TST_STEP2\sub\%LINE 8 to TST_STEP2\sub\%LINE 12
!    12:  }
g
!%DEBUG-I-EXITSTATUS, is '%SYSTEM-S-NORMAL, normal successful completion'
exit


2069.4thanksCSC32::J_HENSONDon&#039;t get even, get ahead!Fri Jan 24 1997 17:1718
>> <<< Note 2069.2 by DECCXL::WIBECAN "That's the way it is, in Engineering!" >>>
>>                                -< Duplicated >-

Brian,

Looks like I was entering  reply .3 at the same time your were entering
.2, and I didn't see it until after I made my post.

I'll tell the customer that it is considered a bug, will be fixed in
a future version, and thank him for bringing this to our attention.

The customer did not comment on Dec C/Alpha behavior, so I can't tell
you his opinion on that.  However, it seems reasonable to make it
the same on both architectures.

Thanks,

Jerry
2069.5Brian posted internal bug # 4085WIDTH::MDAVISMark Davis - compiler maniacMon Jan 27 1997 09:530