[gdb/testsuite] Compile index-cache.c with -Wl,--build-id

Message ID 20190621152742.GA20230@delia
State New, archived
Headers

Commit Message

Tom de Vries June 21, 2019, 3:27 p.m. UTC
  Hi,

When building gdb using a combined gcc/binutils-gdb build and running
gdb.base/index-cache.exp we get:
...
FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: couldn't get executable build id
FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
...

With "set debug index-cache on" we get:
...
(gdb) file index-cache
Reading symbols from index-cache...
index cache: objfile index-cache has no build id
...

The problem is that the vanilla toolchain does not add a build-id, which is
required for the index-cache functionality.

Fix this by compiling index-cache.c with -Wl,--build-id.

Tested on x86_64-linux.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Compile index-cache.c with -Wl,--build-id

gdb/testsuite/ChangeLog:

2019-06-21  Tom de Vries  <tdevries@suse.de>

	* gdb.base/index-cache.exp: Add additional_flags=-Wl,--build-id.

---
 gdb/testsuite/gdb.base/index-cache.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Pedro Alves June 21, 2019, 3:47 p.m. UTC | #1
On 6/21/19 4:27 PM, Tom de Vries wrote:
> Hi,
> 
> When building gdb using a combined gcc/binutils-gdb build and running
> gdb.base/index-cache.exp we get:
> ...
> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: couldn't get executable build id
> FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
> ...
> 
> With "set debug index-cache on" we get:
> ...
> (gdb) file index-cache
> Reading symbols from index-cache...
> index cache: objfile index-cache has no build id
> ...
> 
> The problem is that the vanilla toolchain does not add a build-id, which is
> required for the index-cache functionality.

What is "vanilla" here?  A non-combined gcc/build-gdb build?
Or is "combined gcc/build-gdb build" irrelevant here, and
"vanilla" means "no-distro-patches build"?  Was the testcase
written on a system with a compiler that defaults to --build-id ?

Thanks,
Pedro Alves
  
Simon Marchi June 21, 2019, 3:52 p.m. UTC | #2
On 2019-06-21 11:47 a.m., Pedro Alves wrote:
> Was the testcase
> written on a system with a compiler that defaults to --build-id ?

Yes, gcc on Ubuntu (which I use) is compiled with --enable-linker-build-id.

I think it's correct to change the test case to not assume the linker generates a build-id by default.

Simon
  
Tom de Vries June 21, 2019, 3:54 p.m. UTC | #3
On 21-06-19 17:47, Pedro Alves wrote:
> On 6/21/19 4:27 PM, Tom de Vries wrote:
>> Hi,
>>
>> When building gdb using a combined gcc/binutils-gdb build and running
>> gdb.base/index-cache.exp we get:
>> ...
>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: couldn't get executable build id
>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
>> ...
>>
>> With "set debug index-cache on" we get:
>> ...
>> (gdb) file index-cache
>> Reading symbols from index-cache...
>> index cache: objfile index-cache has no build id
>> ...
>>
>> The problem is that the vanilla toolchain does not add a build-id, which is
>> required for the index-cache functionality.
> 
> What is "vanilla" here?  A non-combined gcc/build-gdb build?
> Or is "combined gcc/build-gdb build" irrelevant here, and
> "vanilla" means "no-distro-patches build"?

The latter.

Thanks,
- Tom
  
Pedro Alves June 21, 2019, 4:32 p.m. UTC | #4
On 6/21/19 4:54 PM, Tom de Vries wrote:
> On 21-06-19 17:47, Pedro Alves wrote:
>> On 6/21/19 4:27 PM, Tom de Vries wrote:
>>> Hi,
>>>
>>> When building gdb using a combined gcc/binutils-gdb build and running
>>> gdb.base/index-cache.exp we get:
>>> ...
>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: couldn't get executable build id
>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
>>> ...
>>>
>>> With "set debug index-cache on" we get:
>>> ...
>>> (gdb) file index-cache
>>> Reading symbols from index-cache...
>>> index cache: objfile index-cache has no build id
>>> ...
>>>
>>> The problem is that the vanilla toolchain does not add a build-id, which is
>>> required for the index-cache functionality.
>>
>> What is "vanilla" here?  A non-combined gcc/build-gdb build?
>> Or is "combined gcc/build-gdb build" irrelevant here, and
>> "vanilla" means "no-distro-patches build"?
> 
> The latter.

OK.  Please tweak the commit log in that direction then.

The fix LGTM too.

Thanks,
Pedro Alves
  
Tom de Vries June 21, 2019, 4:50 p.m. UTC | #5
On 21-06-19 18:32, Pedro Alves wrote:
> On 6/21/19 4:54 PM, Tom de Vries wrote:
>> On 21-06-19 17:47, Pedro Alves wrote:
>>> On 6/21/19 4:27 PM, Tom de Vries wrote:
>>>> Hi,
>>>>
>>>> When building gdb using a combined gcc/binutils-gdb build and running
>>>> gdb.base/index-cache.exp we get:
>>>> ...
>>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
>>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: couldn't get executable build id
>>>> FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
>>>> ...
>>>>
>>>> With "set debug index-cache on" we get:
>>>> ...
>>>> (gdb) file index-cache
>>>> Reading symbols from index-cache...
>>>> index cache: objfile index-cache has no build id
>>>> ...
>>>>
>>>> The problem is that the vanilla toolchain does not add a build-id, which is
>>>> required for the index-cache functionality.
>>>
>>> What is "vanilla" here?  A non-combined gcc/build-gdb build?
>>> Or is "combined gcc/build-gdb build" irrelevant here, and
>>> "vanilla" means "no-distro-patches build"?
>>
>> The latter.
> 
> OK.  Please tweak the commit log in that direction then.
> 
> The fix LGTM too.

Thanks for the review, I've updated the rationale.

I'll commit in a bit unless there are further comments.

Thanks,
- Tom
  
Sergio Durigan Junior June 25, 2019, 7:06 p.m. UTC | #6
On Friday, June 21 2019, Tom de Vries wrote:

> Thanks for the review, I've updated the rationale.
>
> I'll commit in a bit unless there are further comments.

Hi Tom,

This has caused a testcase regression on x86_64.  It was caught by the
BuildBot:

  https://sourceware.org/ml/gdb-testers/2019-q2/msg06515.html

The failures are:

PASS -> FAIL: gdb.base/index-cache.exp: test_cache_enabled_hit: check index-cache stats
PASS -> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: at least one file was created
PASS -> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache stats
PASS -> FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: expected file is there

Thanks,
  

Patch

diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp
index 075dffe3f5..6f1488e037 100644
--- a/gdb/testsuite/gdb.base/index-cache.exp
+++ b/gdb/testsuite/gdb.base/index-cache.exp
@@ -18,7 +18,8 @@ 
 
 standard_testfile
 
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+	  {additional_flags=-Wl,--build-id}] } {
     return
 }