Bug 22907 - [Regression] gdbserver doesn't work with filename-only binaries
Summary: [Regression] gdbserver doesn't work with filename-only binaries
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.1
: P2 normal
Target Milestone: 8.1.1
Assignee: Sergio Durigan Junior
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-01 17:33 UTC by Sergio Durigan Junior
Modified: 2018-04-02 13:20 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Durigan Junior 2018-03-01 17:33:46 UTC
Simon Marchi 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).
Comment 3 Simon Marchi 2018-03-01 17:56:03 UTC
Thanks a lot for looking into it.
Comment 4 Sourceware Commits 2018-03-02 12:33:28 UTC
The master branch has been updated by Sergio Durigan Junior <sergiodj@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ab818ade016bcd794980438775e15c7a74f054f9

commit ab818ade016bcd794980438775e15c7a74f054f9
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Thu Mar 1 15:11:44 2018 -0500

    Conditionally include "<windows.h>" on common/pathstuff.c (and unbreak build on mingw*)
    
    commit b4987c956dfa44ca9fd8552f63e15f5fa094b2a4
    Author: Sergio Durigan Junior <sergiodj@redhat.com>
    Date:   Fri Feb 9 18:44:59 2018 -0500
    
        Create new common/pathstuff.[ch]
    
    Introduced a regression when compiling for mingw*:
    
      /gdb/common/pathstuff.c: In function 'gdb::unique_xmalloc_ptr<char>
      gdb_realpath(const char*)':
      /gdb/common/pathstuff.c:56:14: error: 'MAX_PATH' was not declared in this scope
           char buf[MAX_PATH];
    		^
      /gdb/common/pathstuff.c:57:5: error: 'DWORD' was not declared in this scope
           DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
           ^
      /gdb/common/pathstuff.c:57:11: error: expected ';' before 'len'
           DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
    	     ^
      /gdb/common/pathstuff.c:63:9: error: 'len' was not declared in this scope
           if (len > 0 && len < MAX_PATH)
    	   ^
      /gdb/common/pathstuff.c:64:54: error: 'buf' was not declared in this scope
    	 return gdb::unique_xmalloc_ptr<char> (xstrdup (buf));
    							^
      make[2]: *** [pathstuff.o] Error 1
    
    The proper fix is to conditionally include "<windows.h>".  This commit
    does that, without introducing any regressions as per tests made by
    our BuildBot.
    
    gdb/ChangeLog:
    2018-03-01  Sergio Durigan Junior  <sergiodj@redhat.com>
    
    	PR gdb/22907
    	* common/pathstuff.c: Conditionally include "<windows.h>".
Comment 5 Sourceware Commits 2018-03-02 12:34:25 UTC
The gdb-8.1-branch branch has been updated by Sergio Durigan Junior <sergiodj@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a74e30b243dec8b38c8c769da04635210f9ef986

commit a74e30b243dec8b38c8c769da04635210f9ef986
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Thu Mar 1 15:11:44 2018 -0500

    Conditionally include "<windows.h>" on common/pathstuff.c (and unbreak build on mingw*)
    
    commit b4987c956dfa44ca9fd8552f63e15f5fa094b2a4
    Author: Sergio Durigan Junior <sergiodj@redhat.com>
    Date:   Fri Feb 9 18:44:59 2018 -0500
    
        Create new common/pathstuff.[ch]
    
    Introduced a regression when compiling for mingw*:
    
      /gdb/common/pathstuff.c: In function 'gdb::unique_xmalloc_ptr<char>
      gdb_realpath(const char*)':
      /gdb/common/pathstuff.c:56:14: error: 'MAX_PATH' was not declared in this scope
           char buf[MAX_PATH];
    		^
      /gdb/common/pathstuff.c:57:5: error: 'DWORD' was not declared in this scope
           DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
           ^
      /gdb/common/pathstuff.c:57:11: error: expected ';' before 'len'
           DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
    	     ^
      /gdb/common/pathstuff.c:63:9: error: 'len' was not declared in this scope
           if (len > 0 && len < MAX_PATH)
    	   ^
      /gdb/common/pathstuff.c:64:54: error: 'buf' was not declared in this scope
    	 return gdb::unique_xmalloc_ptr<char> (xstrdup (buf));
    							^
      make[2]: *** [pathstuff.o] Error 1
    
    The proper fix is to conditionally include "<windows.h>".  This commit
    does that, without introducing any regressions as per tests made by
    our BuildBot.
    
    gdb/ChangeLog:
    2018-03-01  Sergio Durigan Junior  <sergiodj@redhat.com>
    
    	PR gdb/22907
    	* common/pathstuff.c: Conditionally include "<windows.h>".
Comment 6 Joel Brobecker 2018-04-02 13:20:48 UTC
Changed the target milestone to 8.1.1, since the problem is in 8.1 and fixed for 8.1.1.