Index: coregrind/m_gdbserver/remote-utils.c
===================================================================
--- coregrind/m_gdbserver/remote-utils.c	(revision 13893)
+++ coregrind/m_gdbserver/remote-utils.c	(working copy)
@@ -21,6 +21,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
+#include <unistd.h>
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
@@ -31,6 +32,7 @@
 
 #  if defined(VGO_linux)
 #include <sys/prctl.h>
+#include <unistd.h>
 #  endif
 
 Bool noack_mode;
@@ -226,6 +228,7 @@
 void remote_open (const HChar *name)
 {
    const HChar *user, *host;
+   HChar *hostname_free = NULL;
    int save_fcntl_flags, len;
    VgdbShared vgdbinit = 
       {0, 0, (Addr) VG_(invoke_gdbserver),
@@ -244,6 +247,13 @@
 
    host = VG_(getenv)("HOST");
    if (host == NULL) host = VG_(getenv)("HOSTNAME");
+#if defined(VGO_linux)
+   if (host == NULL) {
+       hostname_free = malloc (256);
+       if (gethostname(hostname_free, 256) == 0)
+           host = hostname_free;
+   }
+#endif
    if (host == NULL) host = "???";
 
    len = strlen(name) + strlen(user) + strlen(host) + 40;
@@ -352,6 +362,8 @@
    remote_desc_pollfdread_activity.fd = remote_desc;
    remote_desc_pollfdread_activity.events = VKI_POLLIN;
    remote_desc_pollfdread_activity.revents = 0;
+   if (hostname_free != NULL)
+       free(hostname_free);
 }
 
 /* sync_gdb_connection wait a time long enough to let the connection
Index: coregrind/vgdb.c
===================================================================
--- coregrind/vgdb.c	(revision 13893)
+++ coregrind/vgdb.c	(working copy)
@@ -516,6 +516,7 @@
 void prepare_fifos_and_shared_mem(int pid)
 {
    const HChar *user, *host;
+   HChar *hostname_free = NULL;
    unsigned len;
 
    user = getenv("LOGNAME");
@@ -524,6 +525,13 @@
 
    host = getenv("HOST");
    if (host == NULL) host = getenv("HOSTNAME");
+   if (host == NULL) {
+       hostname_free = vmalloc(256);
+       if (gethostname(hostname_free, 256) == 0)
+           host = hostname_free;
+       else
+           XERROR(errno, "error gethostname");
+   }
    if (host == NULL) host = "???";
 
    len = strlen(vgdb_prefix) + strlen(user) + strlen(host) + 40;
@@ -541,6 +549,8 @@
           from_gdb_to_pid, to_gdb_from_pid, shared_mem);
 
    map_vgdbshared(shared_mem);
+   if (hostname_free != NULL)
+       free(hostname_free);
 }
 
 /* Convert hex digit A to a number.  */