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

did you try the dwarftoss command instead?

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

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

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/

[ ]

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/

Thanks everyone for answering my question. I realized the answer myself,

but was not able to cancell the article.

Thanks again,

Christopher Lusardi

1. My I's are coming up i's. (lower case)

2. Fortran MEX: How to copy a matlab cell array into a fortran string array

3. Fastest way to copy from a one dimension byte array to two dimension int array

4. How to build 2 dimension array by extracting the data from original 3 dimension array?

5. Parallelize an existing Fortran code and generate parallel Fortran code using Maple?

6. Input given from Index array type doesnt match for "case structure" ??

7. Computing the actual size of an array given dimensions and element type.

8. Computing the actual size of an array given dimensions and element type.

9. count all dimension object on a given layer

10. Fortran to C to Fortran Arrays

11. Combining Single Dimension to Multi Dimension Array

12. Array transfer - 1 dimension v. 2 dimension

13. number of dimensions in a multi-dimension array

14. passing structured arrays between matlab and fortran codes using mex files

5 post • Page:**1** of **1**