Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.77 diff -u -r1.77 remote.c --- remote.c 2002/02/27 01:18:39 1.77 +++ remote.c 2002/03/10 18:13:05 @@ -55,6 +55,8 @@ #include "gdbcore.h" /* for exec_bfd */ +#define WAIT_FOREVER_FLAG 0 + /* Prototypes for local functions */ static void cleanup_sigint_signal_handler (void *dummy); static void initialize_sigint_signal_handler (void); @@ -1032,7 +1034,7 @@ else sprintf (&buf[2], "%x", th); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (gen) general_thread = th; else @@ -1052,7 +1054,7 @@ else sprintf (buf, "T%08x", tid); putpkt (buf); - getpkt (buf, sizeof (buf), 0); + getpkt (buf, sizeof (buf), WAIT_FOREVER_FLAG); return (buf[0] == 'O' && buf[1] == 'K'); } @@ -1550,7 +1552,7 @@ pack_threadinfo_request (threadinfo_pkt, fieldset, threadid); putpkt (threadinfo_pkt); - getpkt (threadinfo_pkt, (rs->remote_packet_size), 0); + getpkt (threadinfo_pkt, (rs->remote_packet_size), WAIT_FOREVER_FLAG); result = remote_unpack_thread_info_response (threadinfo_pkt + 2, threadid, info); return result; @@ -1630,7 +1632,7 @@ pack_threadlist_request (threadlist_packet, startflag, result_limit, nextthread); putpkt (threadlist_packet); - getpkt (t_response, (rs->remote_packet_size), 0); + getpkt (t_response, (rs->remote_packet_size), WAIT_FOREVER_FLAG); *result_count = parse_threadlist_response (t_response + 2, result_limit, &echo_nextthread, @@ -1740,7 +1742,7 @@ char *buf = alloca (rs->remote_packet_size); putpkt ("qC"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == 'Q' && buf[1] == 'C') return pid_to_ptid (strtol (&buf[2], NULL, 16)); else @@ -1782,7 +1784,7 @@ { putpkt ("qfThreadInfo"); bufp = buf; - getpkt (bufp, (rs->remote_packet_size), 0); + getpkt (bufp, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (bufp[0] != '\0') /* q packet recognized */ { while (*bufp++ == 'm') /* reply contains one or more TID */ @@ -1796,7 +1798,7 @@ while (*bufp++ == ','); /* comma-separated list */ putpkt ("qsThreadInfo"); bufp = buf; - getpkt (bufp, (rs->remote_packet_size), 0); + getpkt (bufp, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } return; /* done */ } @@ -1837,7 +1839,7 @@ { sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid)); putpkt (bufp); - getpkt (bufp, (rs->remote_packet_size), 0); + getpkt (bufp, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (bufp[0] != 0) { n = min (strlen (bufp) / 2, sizeof (display_buf)); @@ -1893,7 +1895,7 @@ /* Now query for status so this looks just like we restarted gdbserver from scratch. */ putpkt ("?"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } /* Clean up connection to a remote debugger. */ @@ -1921,7 +1923,7 @@ putpkt ("qOffsets"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == '\000') return; /* Return silently. Stub doesn't support @@ -2202,7 +2204,7 @@ /* Invite target to request symbol lookups. */ putpkt ("qSymbol::"); - getpkt (reply, (rs->remote_packet_size), 0); + getpkt (reply, (rs->remote_packet_size), WAIT_FOREVER_FLAG); packet_ok (reply, &remote_protocol_qSymbol); while (strncmp (reply, "qSymbol:", 8) == 0) @@ -2218,7 +2220,7 @@ paddr_nz (SYMBOL_VALUE_ADDRESS (sym)), &reply[8]); putpkt (msg); - getpkt (reply, (rs->remote_packet_size), 0); + getpkt (reply, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } } @@ -2304,7 +2306,7 @@ /* Tell the remote that we are using the extended protocol. */ char *buf = alloca (rs->remote_packet_size); putpkt ("!"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } #ifdef SOLIB_CREATE_INFERIOR_HOOK /* FIXME: need a master target_open vector from which all @@ -2418,7 +2420,7 @@ /* Tell the remote that we are using the extended protocol. */ char *buf = alloca (rs->remote_packet_size); putpkt ("!"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } #ifdef SOLIB_CREATE_INFERIOR_HOOK /* FIXME: need a master target_open vector from which all @@ -2601,7 +2603,7 @@ *p++ = 0; putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (packet_ok (buf, &remote_protocol_E) == PACKET_OK) return; @@ -2619,7 +2621,7 @@ *p++ = 0; putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (packet_ok (buf, &remote_protocol_e) == PACKET_OK) return; @@ -2690,7 +2692,7 @@ *p++ = 0; putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (packet_ok (buf, &remote_protocol_E) == PACKET_OK) goto register_event_loop; @@ -2708,7 +2710,7 @@ *p++ = 0; putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (packet_ok (buf, &remote_protocol_e) == PACKET_OK) goto register_event_loop; @@ -3439,7 +3441,7 @@ if (remote_debug) fprintf_unfiltered (gdb_stdlog, "Bad register packet; fetching a new packet\n"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } /* Reply describes registers byte by byte, each byte encoded as two @@ -3695,7 +3697,7 @@ *p = '\0'; putpkt_binary (buf, (int) (p - buf)); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == '\0') { @@ -3837,7 +3839,7 @@ } putpkt_binary (buf, (int) (p - buf)); - getpkt (buf, sizeof_buf, 0); + getpkt (buf, sizeof_buf, WAIT_FOREVER_FLAG); if (buf[0] == 'E') { @@ -3902,7 +3904,7 @@ *p = '\0'; putpkt (buf); - getpkt (buf, sizeof_buf, 0); + getpkt (buf, sizeof_buf, WAIT_FOREVER_FLAG); if (buf[0] == 'E') { @@ -3980,7 +3982,7 @@ data_long = extract_unsigned_integer (data, len); sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == '\0') { /* The stub doesn't support the 't' request. We might want to @@ -4069,7 +4071,7 @@ long sizeof_buf) { putpkt (buf); - getpkt (buf, sizeof_buf, 0); + getpkt (buf, sizeof_buf, WAIT_FOREVER_FLAG); if (buf[0] == 'E') error ("Remote failure reply: %s", buf); @@ -4658,7 +4660,7 @@ sprintf (p, ",%d", bp_size); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_SOFTWARE_BP])) { @@ -4711,7 +4713,7 @@ sprintf (p, ",%d", bp_size); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); return (buf[0] == 'E'); } @@ -4766,7 +4768,7 @@ sprintf (p, ",%x", len); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); switch (packet_ok (buf, &remote_protocol_Z[packet])) { @@ -4802,7 +4804,7 @@ p += hexnumstr (p, (ULONGEST) addr); sprintf (p, ",%x", len); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); switch (packet_ok (buf, &remote_protocol_Z[packet])) { @@ -4840,7 +4842,7 @@ sprintf (p, ",%x", len); putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP])) { @@ -4878,7 +4880,7 @@ sprintf (p, ",%x", len); putpkt(buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP])) { @@ -5011,7 +5013,7 @@ bfd_get_section_contents (exec_bfd, s, sectdata, 0, size); host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == 'E') error ("target memory fault, section %s, range 0x%08x -- 0x%08x", sectname, lma, lma + size); @@ -5102,7 +5104,7 @@ if (i < 0) return i; - getpkt (outbuf, *bufsiz, 0); + getpkt (outbuf, *bufsiz, WAIT_FOREVER_FLAG); return 0; } @@ -5141,7 +5143,7 @@ { /* XXX - see also tracepoint.c:remote_get_noisy_reply() */ buf[0] = '\0'; - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == '\0') error ("Target does not support this command\n"); if (buf[0] == 'O' && buf[1] != 'K') @@ -5182,7 +5184,7 @@ puts_filtered ("\n"); putpkt (args); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); puts_filtered ("received: "); print_packet (buf); puts_filtered ("\n"); @@ -5430,7 +5432,7 @@ error ("Command can only be used when connected to the remote target."); putpkt ("qfProcessInfo"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] == 0) return; /* Silently: target does not support this feature. */ @@ -5441,7 +5443,7 @@ { remote_console_output (&buf[1]); putpkt ("qsProcessInfo"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); } } Index: gdbserver/remote-utils.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v retrieving revision 1.8 diff -u -r1.8 remote-utils.c --- remote-utils.c 2002/02/14 06:21:22 1.8 +++ remote-utils.c 2002/03/10 18:13:05 @@ -47,7 +47,10 @@ void remote_open (char *name) { - int save_fcntl_flags; + int save_fcntl_flags, via_network=0;; + char namebuf[100]; + + snprintf(namebuf, 100, "%s", name); if (!strchr (name, ':')) { @@ -109,6 +112,7 @@ int tmp; struct protoent *protoent; int tmp_desc; + struct hostent *hostent; port_str = strchr (name, ':'); @@ -154,6 +158,21 @@ signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply exits when the remote side dies. */ + + /* Resolve peer's hostname or convert IP address to string. */ + hostent = gethostbyaddr ( (void *)&sockaddr.sin_addr.s_addr, + sizeof (sockaddr.sin_addr.s_addr), AF_INET); + if (hostent) + snprintf(namebuf, 100, "%s", hostent->h_name); + else + { + union { unsigned char ip_c[4]; int ip_i; } ip; + + ip.ip_i = ntohl (sockaddr.sin_addr.s_addr); + snprintf (namebuf, 100, "%u.%u.%u.%u", + ip.ip_c[3], ip.ip_c[2], ip.ip_c[1], ip.ip_c[0]); + } + via_network = 1; } #if defined(F_SETFL) && defined (FASYNC) @@ -164,7 +184,8 @@ #endif #endif disable_async_io (); - fprintf (stderr, "Remote debugging using %s\n", name); + + fprintf (stderr, "Remote debugging %s %s\n", via_network?"from host":"using", namebuf); } void