Hello,
Excuse me for my English.
I would like to ask you does GDB (GNU gdb 5.0rh-5 Red Hat Linux 7.1) support the possibility of reference from one compile unit to different compile unit?
I have tried to use for it type of reference DW_FORM_ref_addr. I have read in DWARF document (Revision:2.1 Draft 6 (May 15, 2001))
that DW_FORM_ref_addr provides this possibility. Is it correct?
Here is interesting part of the dump of .debug_info section for my test case (after readelf):
Compilation Unit @ 0:
Length: 209
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_comp_dir : /home/sana/bloat
DW_AT_language : 1 (ANSI C)
DW_AT_name : test.c
...
<1><b3>: Abbrev Number: 2 (DW_TAG_base_type)
DW_AT_byte_size : 4
DW_AT_encoding : 4 (float)
DW_AT_name : float
<1><bc>: Abbrev Number: 4 (DW_TAG_variable)
DW_AT_decl_line : 2
DW_AT_decl_column : 8
DW_AT_decl_file : 1
DW_AT_accessibility: 1 (public)
DW_AT_name : var2
DW_AT_type : <#150>
DW_AT_location : 5 byte block: 3 c 95 4 8 (DW_OP_addr: 804950c)
DW_AT_external : 1
Compilation Unit @ d5:
Length: 132
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><e0>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_comp_dir : /home/sana/bloat
DW_AT_language : 1 (ANSI C)
DW_AT_name : test.c
....
<1><150>: Abbrev Number: 2 (DW_TAG_base_type)
DW_AT_byte_size : 8
DW_AT_encoding : 4 (float)
DW_AT_name : double
Here is the result of debug session for my test case:
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) b main
Dwarf Error: Cannot find referent at offset 336.
(gdb)
I have found the next code in file gdb+dejagnu-20010316/gdb/dwarf2read.c:
/* Read a whole compilation unit into a linked list of dies. */
struct die_info *
read_comp_unit (char *info_ptr, bfd *abfd,
const struct comp_unit_head *cu_header)
{
struct die_info *first_die, *last_die, *die;
char *cur_ptr;
int nesting_level;
/* Reset die reference table; we are
building new ones now. */
dwarf2_empty_hash_tables ();
As I understood tags for only one compile unit may be located in die_ref_table at the same time.
That is why result of function follow_die_ref (<#150>) is NULL (I think so). And as result I have the error message from GDB (look above please).
If I change DW_AT_type : <#150> to DW_AT_type : <#b3> (reference in current compile unit) then GDB work without problems.
What do you think about it?
If I am wrong can you advice me please what I should do for reference usage from one compile unit to different compile unit?
Is this feature not implemented in described version of GDB?
May be this feature is implemented in different GDB version? In what versions?
If no are you going to support this feature in future? When?
Thank you.
Good bye.
Svetlana Gvozdeva.