This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 2/2] Make gdbserver work with filename-only binaries


On Tuesday, February 27 2018, I wrote:

> Simon mentioned on IRC that, after the startup-with-shell feature has
> been implemented on gdbserver, it is not possible to specify a
> filename-only binary, like:
>
>   $ gdbserver :1234 a.out
>   /bin/bash: line 0: exec: a.out: not found
>   During startup program exited with code 127.
>   Exiting
>
> This happens on systems where the current directory "." is not listed
> in the PATH environment variable.  Although including "." in the PATH
> variable is a possible workaround, this can be considered a regression
> because before startup-with-shell it was possible to use only the
> filename (due to reason that gdbserver used "exec*" directly).
>
> The idea of the patch is to verify if the program path provided by the
> user (or by the remote protocol) contains a directory separator
> character.  If it doesn't, it means we're dealing with a filename-only
> binary, so we call "gdb_abspath" to properly expand it and transform
> it into a full path.  Otherwise, we leave the program path untouched.
> This mimicks the behaviour seen on GDB (look at "openp" and
> "attach_inferior", for example).
>
> I am also submitting a testcase which exercises the scenario described
> above.  This test requires gdbserver to be executed in a different CWD
> than the original, so I also created a helper function, "with_cwd" (on
> testsuite/lib/gdb.exp), which takes care of cd'ing into and out of the
> specified dir.

This part is still giving me a few headaches.  I've just noticed that
two builders reported the new test as FAIL.  When I run it here, I can't
reproduce it, which makes me wonder that it's racy.  I don't know if the
culprit is the new "with_cwd" logic or not.  Curiously, both builders
reporting the failure are running on s390x
(Debian-s390x-native-extended-gdbserver-m64 and RHEL-s390x-m64).

Here's an excerpt of report from one of them,
Debian-s390x-native-extended-gdbserver-m64:

----------------
(gdb) file /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath/abspath
Reading symbols from /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath/abspath...done.
(gdb) set remote exec-file /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath/abspath
(gdb) set remote exec-file /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath/abspath
(gdb) disconnect
Ending remote debugging.
(gdb) PASS: gdb.server/abspath.exp: disconnect
Switching to directory /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath (saved CWD: /home/dje/debian-jessie-s390x-1/debian
-s390x-native-extended-gdbserver/build/gdb/testsuite).
spawn /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/../gdbserver/gdbserver --once :2347 abspath
Can't bind address: Address already in use.
Exiting
Port 2347 is already in use.
spawn /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/../gdbserver/gdbserver --once :2348 abspath
Process /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/outputs/gdb.server/abspath/abspath created; pid = 21406
Listening on port 2348
target extended-remote localhost:2348
Remote debugging using localhost:2348
Reading /lib/ld64.so.1 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld64.so.1 from remote target...
Reading symbols from target:/lib/ld64.so.1...Reading /lib/ld-2.19.so from remote target...
Reading /lib/.debug/ld-2.19.so from remote target...
(no debugging symbols found)...done.
0x000003fffdfd9280 in ?? () from target:/lib/ld64.so.1
Protocol error: qXfer:btrace-conf (read-btrace-conf) conflicting enabled responses.
(gdb) break main
Breakpoint 1 at 0x800005bc: file /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.server/normal.c, line 23.
(gdb) continue
The program is not being run.
(gdb) FAIL: gdb.server/abspath.exp: continue to main (the program is no longer running)
Switching back to /home/dje/debian-jessie-s390x-1/debian-s390x-native-extended-gdbserver/build/gdb/testsuite.
----------------

They're both running the testsuite in parallel mode (-j8), but when I
run it locally in parallel I can't reproduce (even when I run in a
loop).

Anyway, I'll try to find out why this happens.  I don't see how changing
the CWD in a test could impact its results, so I'm guessing there's
something else at play here.

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]