[testsuite,patchv2,ppc64] gdb_target_symbol fix for function descriptors [Re: [testsuite patch] [ppc64] +kfail: gdb_target_symbol does not support function descriptors]
Commit Message
On Wed, 06 Jul 2016 10:11:22 +0200, Jan Kratochvil wrote:
> Now the question is how to detect that. I used "powerpc64-*linux*" target
> match in my patch but I guess that is not right. Maybe it could compile first
> something and check if ".somesymbol" exists.
Implemented the compile test.
It works for me on RHEL-7.2 ppc64 and on Fedora 24 x86_64.
OK for check-in?
I see gdb_target_symbol_prefix is by Kevin so Ccing him if he sees it OK even
on those platforms.
Thanks,
Jan
gdb/testsuite/ChangeLog
2016-07-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* lib/gdb.exp (gdb_target_code_symbol_prefix): New.
(gdb_target_symbol): Call it.
Comments
Hi Jan,
On Wed, Jul 6, 2016 at 8:35 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Wed, 06 Jul 2016 10:11:22 +0200, Jan Kratochvil wrote:
>> Now the question is how to detect that. I used "powerpc64-*linux*" target
>> match in my patch but I guess that is not right. Maybe it could compile first
>> something and check if ".somesymbol" exists.
>
> Implemented the compile test.
>
> It works for me on RHEL-7.2 ppc64 and on Fedora 24 x86_64.
>
> OK for check-in?
>
> I see gdb_target_symbol_prefix is by Kevin so Ccing him if he sees it OK even
> on those platforms.
I am not sure what is the best approach of detecting function descriptor, so
I copy Ulrich.
I suspect we should check whether the program is compiled with ELFv1,
in which function descriptor is used. So probably, we need to check
__powerpc64__ and (!defined(_CALL_ELF) || _CALL_ELF != 2) instead.
@@ -5690,11 +5690,48 @@ gdb_caching_proc gdb_target_symbol_prefix {
return $prefix
}
+# gdb_target_code_symbol_prefix compiles a test program and tries to use
+# '.' prefix at a code symbol to test if there are function descriptors.
+# gdb_target_symbol_prefix is not expected to be needed on such targets.
+
+gdb_caching_proc gdb_target_code_symbol_prefix {
+ # Set up and compile a simple test program...
+ set srcc [standard_temp_file main[pid].c]
+ set srcs [standard_temp_file main[pid].s]
+ set exe [standard_temp_file main[pid].x]
+
+ gdb_produce_source $srcc {
+ int main() {
+ return 0;
+ }
+ }
+ gdb_produce_source $srcs {
+ .8byte .main
+ }
+
+ verbose "compiling testfile $srcc $srcs" 2
+ set compile_flags {nodebug nowarnings quiet}
+ set lines [gdb_compile "$srcc $srcs" $exe executable $compile_flags]
+
+ set prefix ""
+
+ if [string match "" $lines] then {
+ verbose "gdb_target_code_symbol_prefix: returning \".\" prefix" 2
+ set prefix "."
+ }
+
+ file delete $srcc
+ file delete $srcs
+ file delete $exe
+
+ return $prefix
+}
+
# gdb_target_symbol returns the provided symbol with the correct prefix
-# prepended. (See gdb_target_symbol_prefix, above.)
+# prepended.
proc gdb_target_symbol { symbol } {
- set prefix [gdb_target_symbol_prefix]
+ set prefix [gdb_target_symbol_prefix][gdb_target_code_symbol_prefix]
return "${prefix}${symbol}"
}