[testsuite,patchv3,ppc64] gdb_target_symbol fix for function descriptors [Re: [testsuite patch] [ppc64] +kfail: gdb_target
Commit Message
On Tue, 12 Jul 2016 15:22:49 +0200, Ulrich Weigand wrote:
> See e.g. dw2-unresolved-main.c:
>
> asm (".globl cu_text_start");
> asm ("cu_text_start:");
I wrote those lines...
I just did not want to patch multiple (3) testcases one after another just
because one platform (ppc64).
Now I see I should not do that because:
lib/dwarf.exp:
# asm ("func_start: .globl func_start");
# static void func (void) {}
# asm ("func_end: .globl func_end");
#
# however, this isn't portable, because other compilers, such as clang,
# may not guarantee the order of global asms and function. The code
# becomes:
#
# asm ("func_start: .globl func_start");
# asm ("func_end: .globl func_end");
# static void func (void) {}
#
proc function_range { func src } {
commit 876c4df94765ce9409e867ff035ab2203c9f4a3b
Author: Yao Qi <yao@codesourcery.com>
Date: Fri Nov 14 08:53:08 2014 +0800
DW attribute macro MACRO_AT_func and MACRO_AT_range
So I am providing this patch. On Fedora 24 x86_64 and RHEL-7.2 ppc64 it has
no regressions for gdb.dwarf2/*.exp.
OK for check-in?
Kevin, I hope gdb_target_symbol is not needed in this case but I am not sure.
Thanks,
Jan
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.
Comments
On Wed, 13 Jul 2016 13:51:49 +0200, Ulrich Weigand wrote:
> >From what I can see, it should indeed not be needed: the <func>_label symbols
> are defined by assembler code directly, and therefore gdb_target_symbol does
> not apply, while the compiler-defined symbols like <func> are only accessed
> via GDB commands in function_range (and GDB should already do the right thing
> w.r.t. symbol prefixes).
OK.
> The patch is OK.
Checked in:
e87324746c45b0f2cd179ba59a80b43a435a9369
Thanks,
Jan
@@ -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 {
@@ -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;
}
@@ -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;
}
@@ -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}
}
@@ -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 {
} {