HP3000-L Archives

July 1998, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Wed, 8 Jul 1998 14:03:52 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (139 lines)
Hi,

Thank you for your response, it worked.

I wrote a short COBOL program and stepped through COB_OPEN procedure.
It looks like the COBOL file name is at arg0 + $64.

Michael

run prog1;debug

DEBUG/iX C.05.08

DEBUG Intrinsic at: 844.000051d0 ?test
$1 ($1a) nmdebug > use mac1
$3 ($1a) nmdebug > b ?COB_OPEN
added: NM    [1] USER 204.0144e834 ?COB_OPEN
$4 ($1a) nmdebug > c
Break at: NM    [1] USER 204.0144e834 ?COB_OPEN


$d ($1a) nmdebug > dv arg(0)+$64,8,s
VIRT $65d.41638088 "COBFILEA                        "
$e ($1a) nmdebug >abort
:



______________________________ Reply Separator _________________________________
Subject: Re: [HP3000-L] DEBUG QUESTION
Author:  Non-HP-gavin ([log in to unmask]) at HP-SantaClara,uugw1
Date:    7/8/98 10:17 AM


Michael asks:
> Does anybody know how parameters are passed to COBOL file routines?

I'm not familliar with the parameters to the COBOL runtime library
routines, or how the library communicates status back to the caller,
but all calls follow the standard PA-RISC Procedure Calling Conventions
(I'm assuming this is Native Mode of course).

> I need to do set break point at ?COB_OPEN , display file name

You can enter the following macro into debug (or put it into a file
named something like "mymacros" and then type "use mymacros" each time
you enter debug for the first time).

macro arg (argno) {
  IF (argno = 0) then { return arg0 };
  IF (argno = 1) then { return arg1 };
  IF (argno = 2) then { return arg2 };
  IF (argno = 3) then { return arg3 };
  IF (argno > 3) then { return [sp-(4*(argno+9))]};
}

At the point of call, point of entry, or anywhere in between (like the
?stub) you can use this macro to display the standard argument slots.
If the first parameter to COB_OPEN is the filename, then you could do:

> dv arg(0),8,s

To display eight words as a character string starting at the address in
argument slot 0.  You could also use the built in 'arg0' alias for R26
rather than the macro "arg(0)", but the macro has the advantages of
working for values > 3.  If the second parameter is an integer passed
by value, you can say:

> =arg(1),#

To display it in decimal.

Complications to all this are 64bit parameters that will be 64bit
"alligned" within the argument slots (this includes long pointers)
and thus will result in a skipped argument slot if they are an odd
numbered parameter (plus they will be taking up two slots, which
pushes subsequent arguments down farther than you might expect).
This probably does not affect the COBOL runtime though.

> and check status at ?COB_OPEN + $8 and so on.

From the point of exit to the point of return, the functional return
of the procedure (if any) will be in GR28, also known as 'ret0'.
You can see this value with something like "=ret0" or "dv ret0"
depending on whether it is a pointer or not.

Condition codes (CCE, CCL, CCG, CCX) are rarely used in native mode,
but the debugger has a built-in variable "ccode" that will tell you
the current condition code value if you have recently called an
Intrinsic thats sets the condition code.

Again, I don't know how the COBOL runtime returns status.  It might
return a zero/non zero value as the functional return (ret0), or it
may set a global status variable somewhere.  I suspect the latter
is more likely since COBOL generally handles errors internally or
requires you to explicitly check the file status.

There are other complications to the calling convention, but they
are fairly rare.  The above applies to any Native Mode language.

Another handy macro I've always used (which requires the first one)
is:

macro args (numargs) {
  loc oi:u16 = 0;
  while oi < numargs DO {
    w 'Parm #', oi:"dM", '=';
    w arg(oi):"HZF";
    ignore quiet;
    loc temp [arg(oi)];
    if error=0 then {
      w ', [', [arg(oi)]:"HZF", '] ';
      dv arg(oi) 7 s;
    } else {wl};
    loc oi oi + 1;
  }
}

With this you can do something like:

$21 ($6b) nmdebug > args 8
Parm #0=4163a7eb, [00000051] VIRT $2cc.4163a7e8 "...QSOUT   ................."
Parm #1=0000014c, [00004e64] VIRT $a.14c      "..Nd...d..]...f.......)....t"
Parm #2=00000001, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"
Parm #3=00000000, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"
Parm #4=00000000, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"
Parm #5=00000000, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"
Parm #6=00000000, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"
Parm #7=00000000, [020b0104] VIRT $a.0        "......@.3.k4.......p.......#"

Which displays the first (eight in this case) argument slots, showing
you the slot number, the contents of the slot in hex, the value at that
address (assuming it's a pointer), and a dv of the value as an address
of a character string.  The above display shows the parameters to the
first FOPEN call made by QUERYNM.  arg(0) has a pointer to the filename,
arg(1) has foptions, arg(2) has the aoptions, etc.

G.

ATOM RSS1 RSS2