[ppc64] Fix for function descriptors
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 13 Jul 2016 11:58:19 +0000 (13:58 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 13 Jul 2016 11:58:19 +0000 (13:58 +0200)
Marin Cermak has found various testcases (or one of them) of GDB FAIL on
ppc64.

https://sourceware.org/bugzilla/show_bug.cgi?id=20328

.o contained only the function descriptor address.

The DWARF as produced by Tcl Dwarf::assemble:
 <1><27>: Abbrev Number: 4 (DW_TAG_subprogram)
    <28>   DW_AT_name        : main
    <2d>   DW_AT_external    : 1
    <2e>   DW_AT_low_pc      : 0x1001ff98
    <36>   DW_AT_high_pc     : 0x1002ff98
 <2><3e>: Abbrev Number: 5 (DW_TAG_lexical_block)

Runtime info:
$2 = {<text variable, no debug info>} 0x10000674 <.main>
$3 = {void ()} 0x1001ff98 <main>

On Tue, 12 Jul 2016 15:22:49 +0200, Ulrich Weigand wrote:
Well, most of the gdb.dwarf2 test cases simply use explicitly placed labels
for the DW_AT_low_pc / DW_AT_high_pc attributes.

See e.g. dw2-unresolved-main.c:

asm (".globl cu_text_start");
asm ("cu_text_start:");

On Wed, 13 Jul 2016 10:54:00 +0200, Jan Kratochvil wrote:
Now I see I should not do that because:

lib/dwarf.exp:
proc function_range { func src } {

So I am providing this patch.

gdb/testsuite/ChangeLog
2016-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.dwarf2/atomic-type.exp: Use function_range for low_pc and high_pc.
* gdb.dwarf2/atomic.c (f): Rename f_end_lbl to f_label.
* gdb.dwarf2/dw2-bad-mips-linkage-name.c (f): Rename f_end_lbl to
f_label.
(g): Rename g_end_lbl to g_label.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Use function_range for
low_pc and high_pc.
* gdb.dwarf2/dw2-lexical-block-bare.exp: Likewise.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/atomic-type.exp
gdb/testsuite/gdb.dwarf2/atomic.c
gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.c
gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp

index 851487f77096ad525a76eb582f38dd452fb7de90..7ab1228a7d6875aec40c03710c0aa884ba7656bf 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.dwarf2/atomic-type.exp: Use function_range for low_pc and high_pc.
+       * gdb.dwarf2/atomic.c (f): Rename f_end_lbl to f_label.
+       * gdb.dwarf2/dw2-bad-mips-linkage-name.c (f): Rename f_end_lbl to
+       f_label.
+       (g): Rename g_end_lbl to g_label.
+       * gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Use function_range for
+       low_pc and high_pc.
+       * gdb.dwarf2/dw2-lexical-block-bare.exp: Likewise.
+
 2016-07-12  Tom Tromey  <tom@tromey.com>
 
        PR python/19293:
index 7b35cad4f3e58deed9098591044f4cbb0932f292..0addefea2e6d7a89a87e93ad06d28da7ea732863 100644 (file)
@@ -25,6 +25,12 @@ standard_testfile atomic.c atomic-type-dw.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile
+
+    set f_result [function_range f ${srcdir}/${subdir}/${srcfile}]
+    set f_start [lindex $f_result 0]
+    set f_length [lindex $f_result 1]
+
     cu {} {
        DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C11}
@@ -68,8 +74,8 @@ Dwarf::assemble $asm_file {
 
             DW_TAG_subprogram {
                 {name f}
-                {low_pc [gdb_target_symbol f] addr}
-                {high_pc f_end_lbl addr}
+                {low_pc $f_start addr}
+                {high_pc "$f_start + $f_length" addr}
                 {type :$i_l}
             } {
                 DW_TAG_formal_parameter {
index 9a2d37b2be1df4a872106792668584cc9965ea05..ecaa56ce3ff94f63d8a4989f0e275baac8d16a7f 100644 (file)
@@ -28,7 +28,7 @@ main (void)
 int
 f (char *x)
 {
-  asm (".global f_end_lbl\nf_end_lbl:");
+  asm ("f_label: .globl f_label");
   return 0;
 }
 
index eaf1233b23f1ec663f469df6273abf0f29a4450f..5816324bebf8b0aa6ee4c461feee3ea85216a719 100644 (file)
@@ -28,7 +28,7 @@ main (void)
 int
 f (char *x)
 {
-  asm (".global f_end_lbl\nf_end_lbl:");
+  asm ("f_label: .globl f_label");
   return 0;
 }
 
@@ -36,6 +36,6 @@ f (char *x)
 int
 g (char *x)
 {
-  asm (".global g_end_lbl\ng_end_lbl:");
+  asm ("g_label: .globl g_label");
   return 0;
 }
index b1041faf28b9d5d0f3dc9244f2a55ad5a635e1ea..043c1dab29a24f7e1194057b352fdc25cb771a06 100644 (file)
@@ -26,6 +26,16 @@ standard_testfile dw2-bad-mips-linkage-name.c dw2-bad-mips-linkage-name.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile
+
+    set f_result [function_range f ${srcdir}/${subdir}/${srcfile}]
+    set f_start [lindex $f_result 0]
+    set f_length [lindex $f_result 1]
+
+    set g_result [function_range g ${srcdir}/${subdir}/${srcfile}]
+    set g_start [lindex $g_result 0]
+    set g_length [lindex $g_result 1]
+
     cu {} {
        DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C}
@@ -42,15 +52,15 @@ Dwarf::assemble $asm_file {
            }
             DW_TAG_subprogram {
                 {name f}
-                {low_pc [gdb_target_symbol f] addr}
-                {high_pc f_end_lbl addr}
+                {low_pc $f_start addr}
+                {high_pc "$f_start + $f_length" addr}
                 {type :$b_l}
                {DW_AT_MIPS_linkage_name _Z1fv}
            }
             DW_TAG_subprogram {
                 {name g}
-                {low_pc [gdb_target_symbol g] addr}
-                {high_pc g_end_lbl addr}
+                {low_pc $g_start addr}
+                {high_pc "$g_start + $g_length" addr}
                 {type :$b_l}
                {DW_AT_MIPS_linkage_name 42 DW_FORM_data1}
            }
index 3f9411e8b4e619b726ff2968260a15b67b896894..d09f56b75ea1ed13225e9bc3d3eb73479b8904e6 100644 (file)
@@ -24,10 +24,16 @@ standard_testfile .S main.c
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile]
 Dwarf::assemble $asm_file {
+    global srcdir subdir srcfile2
+
+    set main_result [function_range main ${srcdir}/${subdir}/${srcfile2}]
+    set main_start [lindex $main_result 0]
+    set main_length [lindex $main_result 1]
+
     cu {} {
        compile_unit {
-           {low_pc [gdb_target_symbol main] DW_FORM_addr}
-           {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
+           {low_pc $main_start addr}
+           {high_pc "$main_start + $main_length" addr}
        } {
            declare_labels integer_label
 
@@ -40,8 +46,8 @@ Dwarf::assemble $asm_file {
            DW_TAG_subprogram {
                {name main}
                {DW_AT_external 1 flag}
-               {low_pc [gdb_target_symbol main] DW_FORM_addr}
-               {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
+               {low_pc $main_start addr}
+               {high_pc "$main_start + $main_length" addr}
            } {
                DW_TAG_lexical_block {
                } {