[RFC] Only compute realpath when basenames_may_differ is set

Message ID CAPmGMvhNHp0EbEKhPA3Pu9S7NF-mp_hk36-Y=doJYwGjyxpbSw@mail.gmail.com
State New, archived
Headers

Commit Message

Jonah Graham Aug. 19, 2019, 7:25 p.m. UTC
  On Fri, 14 Jun 2019 at 10:31, Tom Tromey <tromey@adacore.com> wrote:

> I'm checking this in now.
>
> Tom
>

Hi Tom,

This causes an error with Eclipse CDT's default use case. In CDT the
compile lines are basically "gcc -g -c -o file.o ../file.c" with the pwd
being a directory under the source:

root/
  file.c
  Debug/
    Makefile
    file.o
    program.elf

I have modified the fullname.exp test with a testcase that shows the
failure, see the patch below. Here is also a short trace of a session
showing the problem:

/tmp $ mkdir test && cd test
/tmp/test $ echo 'int main() {}' > testcase.c
/tmp/test $ mkdir build && cd build
/tmp/test/build $ gcc -g ../testcase.c -o testcase
/tmp/test/build $ gdb -q testcase
Reading symbols from testcase...done.
(gdb) b /tmp/test/testcase.c:1
Breakpoint 1 at 0x603: file ../testcase.c, line 1.
(gdb) quit
/tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb -q testcase
Reading symbols from testcase...
(gdb) b /tmp/test/testcase.c:1
No source file named /tmp/test/testcase.c.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) quit
/tmp/test/build $ gdb --version | head -1
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
/tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb --version | head -1
GNU gdb (GDB) 8.3.50.20190819-git

Thanks,
Jonah

---
 gdb/testsuite/gdb.base/fullname.exp | 30 +++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

+    }
+}
+
 # Build the test executable using relative paths not relative to the
directory
 # we'll run GDB from.
  

Comments

Jonah Graham Sept. 12, 2019, 5:47 p.m. UTC | #1
bump.


On Mon, 19 Aug 2019 at 15:25, Jonah Graham <jonah@kichwacoders.com> wrote:

>
> On Fri, 14 Jun 2019 at 10:31, Tom Tromey <tromey@adacore.com> wrote:
>
>> I'm checking this in now.
>>
>> Tom
>>
>
> Hi Tom,
>
> This causes an error with Eclipse CDT's default use case. In CDT the
> compile lines are basically "gcc -g -c -o file.o ../file.c" with the pwd
> being a directory under the source:
>
> root/
>   file.c
>   Debug/
>     Makefile
>     file.o
>     program.elf
>
> I have modified the fullname.exp test with a testcase that shows the
> failure, see the patch below. Here is also a short trace of a session
> showing the problem:
>
> /tmp $ mkdir test && cd test
> /tmp/test $ echo 'int main() {}' > testcase.c
> /tmp/test $ mkdir build && cd build
> /tmp/test/build $ gcc -g ../testcase.c -o testcase
> /tmp/test/build $ gdb -q testcase
> Reading symbols from testcase...done.
> (gdb) b /tmp/test/testcase.c:1
> Breakpoint 1 at 0x603: file ../testcase.c, line 1.
> (gdb) quit
> /tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb -q testcase
> Reading symbols from testcase...
> (gdb) b /tmp/test/testcase.c:1
> No source file named /tmp/test/testcase.c.
> Make breakpoint pending on future shared library load? (y or [n]) n
> (gdb) quit
> /tmp/test/build $ gdb --version | head -1
> GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
> /tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb --version | head -1
> GNU gdb (GDB) 8.3.50.20190819-git
>
> Thanks,
> Jonah
>
> ---
>  gdb/testsuite/gdb.base/fullname.exp | 30 +++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.base/fullname.exp
> b/gdb/testsuite/gdb.base/fullname.exp
> index 07d6245d15..e306400b2b 100644
> --- a/gdb/testsuite/gdb.base/fullname.exp
> +++ b/gdb/testsuite/gdb.base/fullname.exp
> @@ -96,6 +96,36 @@ if { [gdb_breakpoint [standard_output_file
> tmp-${srcfile}]:${line} {no-message}]
>      fail $msg
>  }
>
> +# Build the test executable using a relative path with /../ .
> +file mkdir [standard_output_file ""]/build
> +with_cwd [standard_output_file ""]/build {
> +    if  { [gdb_compile ../tmp-${srcfile} \
> +        "${binfile}" executable {debug}] != "" } {
> +        return -1
> +    }
> +
> +    gdb_exit
> +    gdb_start
> +    gdb_load ${binfile}
> +
> +    set msg "set breakpoint by full path before loading symbols - built
> relative with .."
> +    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
> {no-message}] != 0 } {
> +        pass $msg
> +    } else {
> +        fail $msg
> +    }
> +
> +    gdb_test "break main" \
> +        "Breakpoint.*at.*line.*" "set breakpoint at main - built relative
> with .."
> +
> +    set msg "set breakpoint by full path after loading symbols - built
> relative with .."
> +    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
> {no-message}] != 0 } {
> +        pass $msg
> +    } else {
> +        fail $msg
> +    }
> +}
> +
>  # Build the test executable using relative paths not relative to the
> directory
>  # we'll run GDB from.
>
> --
> 2.22.0
>
  
Jonah Graham Nov. 2, 2019, 5:42 p.m. UTC | #2
On Thu, 12 Sep 2019 at 13:47, Jonah Graham <jonah@kichwacoders.com> wrote:

> bump.
>
>
> On Mon, 19 Aug 2019 at 15:25, Jonah Graham <jonah@kichwacoders.com> wrote:
>
>>
>> On Fri, 14 Jun 2019 at 10:31, Tom Tromey <tromey@adacore.com> wrote:
>>
>>> I'm checking this in now.
>>>
>>> Tom
>>>
>>
>> Hi Tom,
>>
>> This causes an error with Eclipse CDT's default use case. In CDT the
>> compile lines are basically "gcc -g -c -o file.o ../file.c" with the pwd
>> being a directory under the source:
>>
>> root/
>>   file.c
>>   Debug/
>>     Makefile
>>     file.o
>>     program.elf
>>
>> I have modified the fullname.exp test with a testcase that shows the
>> failure, see the patch below. Here is also a short trace of a session
>> showing the problem:
>>
>> /tmp $ mkdir test && cd test
>> /tmp/test $ echo 'int main() {}' > testcase.c
>> /tmp/test $ mkdir build && cd build
>> /tmp/test/build $ gcc -g ../testcase.c -o testcase
>> /tmp/test/build $ gdb -q testcase
>> Reading symbols from testcase...done.
>> (gdb) b /tmp/test/testcase.c:1
>> Breakpoint 1 at 0x603: file ../testcase.c, line 1.
>> (gdb) quit
>> /tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb -q testcase
>> Reading symbols from testcase...
>> (gdb) b /tmp/test/testcase.c:1
>> No source file named /tmp/test/testcase.c.
>> Make breakpoint pending on future shared library load? (y or [n]) n
>> (gdb) quit
>> /tmp/test/build $ gdb --version | head -1
>> GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
>> /tmp/test/build $ /scratch/gdb/binutils-gdb/gdb/gdb --version | head -1
>> GNU gdb (GDB) 8.3.50.20190819-git
>>
>> Thanks,
>> Jonah
>>
>> ---
>>  gdb/testsuite/gdb.base/fullname.exp | 30 +++++++++++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>>
>> diff --git a/gdb/testsuite/gdb.base/fullname.exp
>> b/gdb/testsuite/gdb.base/fullname.exp
>> index 07d6245d15..e306400b2b 100644
>> --- a/gdb/testsuite/gdb.base/fullname.exp
>> +++ b/gdb/testsuite/gdb.base/fullname.exp
>> @@ -96,6 +96,36 @@ if { [gdb_breakpoint [standard_output_file
>> tmp-${srcfile}]:${line} {no-message}]
>>      fail $msg
>>  }
>>
>> +# Build the test executable using a relative path with /../ .
>> +file mkdir [standard_output_file ""]/build
>> +with_cwd [standard_output_file ""]/build {
>> +    if  { [gdb_compile ../tmp-${srcfile} \
>> +        "${binfile}" executable {debug}] != "" } {
>> +        return -1
>> +    }
>> +
>> +    gdb_exit
>> +    gdb_start
>> +    gdb_load ${binfile}
>> +
>> +    set msg "set breakpoint by full path before loading symbols - built
>> relative with .."
>> +    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
>> {no-message}] != 0 } {
>> +        pass $msg
>> +    } else {
>> +        fail $msg
>> +    }
>> +
>> +    gdb_test "break main" \
>> +        "Breakpoint.*at.*line.*" "set breakpoint at main - built
>> relative with .."
>> +
>> +    set msg "set breakpoint by full path after loading symbols - built
>> relative with .."
>> +    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
>> {no-message}] != 0 } {
>> +        pass $msg
>> +    } else {
>> +        fail $msg
>> +    }
>> +}
>> +
>>  # Build the test executable using relative paths not relative to the
>> directory
>>  # we'll run GDB from.
>>
>> --
>> 2.22.0
>>
>
Tom de Vries has fixed the behaviour as part of PR24687. Can the testcase I
wrote for this case (that best represents CDT's use case) be added to GDB
testsuite. The original email with the testcase that can be added to
gdb.base/fullname.exp is
https://sourceware.org/ml/gdb-patches/2019-08/msg00421.html

Thank you,
Jonah
  

Patch

diff --git a/gdb/testsuite/gdb.base/fullname.exp
b/gdb/testsuite/gdb.base/fullname.exp
index 07d6245d15..e306400b2b 100644
--- a/gdb/testsuite/gdb.base/fullname.exp
+++ b/gdb/testsuite/gdb.base/fullname.exp
@@ -96,6 +96,36 @@  if { [gdb_breakpoint [standard_output_file
tmp-${srcfile}]:${line} {no-message}]
     fail $msg
 }

+# Build the test executable using a relative path with /../ .
+file mkdir [standard_output_file ""]/build
+with_cwd [standard_output_file ""]/build {
+    if  { [gdb_compile ../tmp-${srcfile} \
+        "${binfile}" executable {debug}] != "" } {
+        return -1
+    }
+
+    gdb_exit
+    gdb_start
+    gdb_load ${binfile}
+
+    set msg "set breakpoint by full path before loading symbols - built
relative with .."
+    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
{no-message}] != 0 } {
+        pass $msg
+    } else {
+        fail $msg
+    }
+
+    gdb_test "break main" \
+        "Breakpoint.*at.*line.*" "set breakpoint at main - built relative
with .."
+
+    set msg "set breakpoint by full path after loading symbols - built
relative with .."
+    if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line}
{no-message}] != 0 } {
+        pass $msg
+    } else {
+        fail $msg