diff options
author | Andy Wingo <wingo@igalia.com> | 2015-03-26 19:41:15 +0100 |
---|---|---|
committer | Andy Wingo <wingo@igalia.com> | 2015-03-26 19:41:54 +0100 |
commit | ff908ebf8612a737d9e168eca0604ff6c97556bc (patch) | |
tree | 5decbc2e9890ad4b60c7d8e7b940fef9ba29e4ef /gdb/testsuite/gdb.dwarf2 | |
parent | f30d5c78faa5979fb933038923e5270b7728f96f (diff) | |
download | gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.zip gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.tar.gz gdb-ff908ebf8612a737d9e168eca0604ff6c97556bc.tar.bz2 |
Properly intern constants into psymtab
Variables with a DW_AT_const_value but without a DW_AT_location were not
getting added to the partial symbol table. They are added to the full
symbol table, however, when the compilation unit's psymtabs are
expanded.
Before:
(gdb) p one
No symbol "one" in current context.
(gdb) mt flush-symbol-cache
(gdb) mt expand one.c
(gdb) p one
$1 = 1
After:
(gdb) p one
$1 = 1
To the user it's pretty strange, as depending on whether tab completion
has forced expansion of all CUs or not the lookup might succeed, or not
if the failure was already added to the symbol cache.
This commit simply makes sure to add constants to the partial symbol
tables.
gdb/testsuite/ChangeLog:
PR symtab/18148
* gdb.dwarf2/dw2-intercu.S (one, two): Add variables that have a
const_value but not a location.
* gdb.dwarf2/dw2-intercu.exp: Add tests that constants without
location defined in non-main CUs are visible.
gdb/ChangeLog:
PR symtab/18148
* dwarf2read.c (struct partial_die_info): Add has_const_value
member.
(add_partial_symbol): Don't punt on symbols that have const_value
attributes.
(read_partial_die): Detect DW_AT_const_value.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-intercu.S | 79 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-intercu.exp | 5 |
2 files changed, 84 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-intercu.S b/gdb/testsuite/gdb.dwarf2/dw2-intercu.S index b155e0b..c033e4d 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-intercu.S +++ b/gdb/testsuite/gdb.dwarf2/dw2-intercu.S @@ -64,6 +64,24 @@ func_cu1: .byte 1 /* DW_AT_frame_base: length */ .byte 0x55 /* DW_AT_frame_base: DW_OP_reg5 */ + /* This type is named "int1" and not "int" to ensure it is unique, + and thus we can easily ensure we expand this CU and not some + other CU with "int". */ +.Ltype_int1_in_cu1: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "int1\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + +.Ltype_const_int1_in_cu1: + .uleb128 4 /* Abbrev: DW_TAG_const_type */ + .4byte .Ltype_int1_in_cu1-.Lcu1_begin /* DW_AT_type */ + + .uleb128 5 /* Abbrev: DW_TAG_variable */ + .ascii "one\0" /* DW_AT_name */ + .4byte .Ltype_const_int1_in_cu1-.Lcu1_begin /* DW_AT_type */ + .byte 1 /* DW_AT_const_value */ + .byte 0 /* End of children of CU */ .Lcu1_end: @@ -92,6 +110,15 @@ func_cu1: .byte 4 /* DW_AT_byte_size */ .byte 5 /* DW_AT_encoding */ +.Ltype_const_int2_in_cu2: + .uleb128 3 /* Abbrev: DW_TAG_const_type */ + .4byte .Ltype_int2_in_cu2-.Lcu2_begin /* DW_AT_type */ + + .uleb128 4 /* Abbrev: DW_TAG_variable */ + .ascii "two\0" /* DW_AT_name */ + .4byte .Ltype_const_int2_in_cu2-.Lcu2_begin /* DW_AT_type */ + .byte 2 /* DW_AT_const_value */ + .byte 0 /* End of children of CU */ .Lcu2_end: @@ -139,6 +166,38 @@ func_cu1: .byte 0x0 /* Terminator */ .byte 0x0 /* Terminator */ + .uleb128 3 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 4 /* Abbrev code */ + .uleb128 0x26 /* DW_TAG_const_type */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 5 /* Abbrev code */ + .uleb128 0x34 /* DW_TAG_variable */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .uleb128 0x1c /* DW_AT_const_value */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ .byte 0x0 /* Terminator */ @@ -167,6 +226,26 @@ func_cu1: .byte 0x0 /* Terminator */ .byte 0x0 /* Terminator */ + .uleb128 3 /* Abbrev code */ + .uleb128 0x26 /* DW_TAG_const_type */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 4 /* Abbrev code */ + .uleb128 0x34 /* DW_TAG_variable */ + .byte 0x0 /* DW_children_no */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .uleb128 0x1c /* DW_AT_const_value */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ .byte 0x0 /* Terminator */ diff --git a/gdb/testsuite/gdb.dwarf2/dw2-intercu.exp b/gdb/testsuite/gdb.dwarf2/dw2-intercu.exp index 8de99c5..eba791b 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-intercu.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-intercu.exp @@ -42,3 +42,8 @@ gdb_test_no_output "set listsize 1" gdb_test "list func_cu1" "4\[ \t\]+File 1 Line 4" gdb_test "ptype func_cu1" "type = int2 \\(\\)" + +gdb_test "p one" "= 1" +gdb_test "p two" "= 2" +gdb_test "ptype one" "type = const int1" +gdb_test "ptype two" "type = const int2" |