dwarfdump -i on Fortran object code doesn't give me array dimensions

dwarfdump -i on Fortran object code doesn't give me array dimensions

Post by clusardi2 » Sat, 20 Dec 2003 04:50:26


Hello,

I have been trying to get complete variable information from Fortran 77
object code. The command dwarfdump -i will only give me the number of elements
in the arrays. I'm looking for the dimension of the arrays. Is it 1, 2, 3, etc.

The command "nm" didn't seem to help either.

Thank you,
Christopher Lusardi
 
 
 

dwarfdump -i on Fortran object code doesn't give me array dimensions

Post by SkyWrite » Sat, 20 Dec 2003 06:52:54


did you try the dwarftoss command instead?

 
 
 

dwarfdump -i on Fortran object code doesn't give me array dimensions

Post by roberso » Sat, 20 Dec 2003 07:52:53

n article < XXXX@XXXXX.COM >,
Christopher M. Lusardi < XXXX@XXXXX.COM > wrote:
: I have been trying to get complete variable information from Fortran 77
:object code. The command dwarfdump -i will only give me the number of elements
:in the arrays. I'm looking for the dimension of the arrays. Is it 1, 2, 3, etc.

: The command "nm" didn't seem to help either.

Fortran 77 doesn't have dynamic dimensioning, so Fortran 77 itself
does not *know* what the dimensions are.

That having been said, it appears that dwarfdump can give you the
information, provided that you have compiled with debugging.

I don't know the most efficient way of doing this (or any programmatic
way), but for a test program what I found was this:

Look through the dwarfdump output down to the section .debug_static_vars

.debug_static_vars
static-var baba die 598, cu-die 454, off-in-cu 155, cu 443

Reference that last number, the cu 443, up to the section .debug_info
to find the COMPILE_UNIT with the same number:

COMPILE_UNIT<header overall offset = 443>:

Go down in that section to find the line with the second <value> (the
offset) matching the off-in-cu number:

<2>< 155> DW_TAG_variable
DW_AT_decl_file 1
DW_AT_decl_line 2
DW_AT_decl_column 16
DW_AT_name baba
DW_AT_type <134>
DW_AT_location DW_OP_fbreg -24000000

Continue copying the next few elements that are until you get to
another line that starts with the same hierarchy number; ie.,
since this line starts with <2>, copy the immediately following
subsections that start with <3>:

<3>< 146> DW_TAG_subrange_type
DW_AT_upper_bound 100
<3>< 148> DW_TAG_subrange_type
DW_AT_upper_bound 200
<3>< 151> DW_TAG_subrange_type
DW_AT_upper_bound 300


Those are the array dimensions in the order I declared them in Fortran.

To see more information about the array, look through that current
COMPILE_UNIT to find a subsection whose second element starts with
the number corresponding to the DW_AT_type of the variable; i.e., <134>
in this case:

<2>< 134> DW_TAG_array_type
DW_AT_decl_file 1
DW_AT_decl_line 2
DW_AT_decl_column 16
DW_AT_type <187>
DW_AT_byte_size 24000000

That last line gives the total size of the array in bytes. To see the
base type, look through the COMPILE_UNIT further to find the entry
whose second element matches the DW_AT_type, i.e., <187> in this case:

<1>< 187> DW_TAG_base_type
DW_AT_name INTEGER*4
DW_AT_encoding DW_ATE_signed
DW_AT_byte_size 4


I do not immediately see any simple way of finding out how many
dimensions the array has -- nothing with a value of 3 and nothing
useful with a value of 2 (i.e., last dimension number). Count the <3>'s
I guess.
--
Before responding, take into account the possibility that the Universe
was created just an instant a
 
 
 

dwarfdump -i on Fortran object code doesn't give me array dimensions

Post by dave » Sat, 20 Dec 2003 08:48:11

In article <brtb45$lv0$ XXXX@XXXXX.COM >,


[ ]


Walter is exactly right.

Dwarf2 spec, sec 5.4:

"Each array dimension is described by a debugging information
entry with either the tag DW_TAG_subrange_type or the tag
DW_TAG_enumeration type. These entries are children of the array
type entry and are ordered to reflect the appearance of the
dimensions to the source program (i.e., leftmost dimension
first, next to leftmost second, and so on)."

So you have to count the children of the DW_TAG_array_type
properly to know the number of dimensions.


Regards,
David B. Anderson davea at sgi dot com http://www.yqcomputer.com/
 
 
 

dwarfdump -i on Fortran object code doesn't give me array dimensions

Post by clusardi2 » Sat, 20 Dec 2003 22:00:19


Thanks everyone for answering my question. I realized the answer myself,
but was not able to cancell the article.

Thanks again,
Christopher Lusardi