From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26822 invoked by alias); 10 Mar 2002 18:34:10 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 26723 invoked from network); 10 Mar 2002 18:34:08 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by sources.redhat.com with SMTP; 10 Mar 2002 18:34:08 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id F127359D348 for ; Sun, 10 Mar 2002 19:34:07 +0100 (CET) Received: from suse.cz (leviathan.suse.cz [10.20.1.56]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id g2AIY7N27951 for ; Sun, 10 Mar 2002 19:34:07 +0100 X-Authentication-Warning: chimera.suse.cz: Host leviathan.suse.cz [10.20.1.56] claimed to be suse.cz Message-ID: <3C8BA71F.20807@suse.cz> Date: Sun, 10 Mar 2002 10:34:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [RFA] remote debugging patches Content-Type: multipart/mixed; boundary="------------050209060500070602030609" X-SW-Source: 2002-03/txt/msg00140.txt.bz2 This is a multi-part message in MIME format. --------------050209060500070602030609 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Content-length: 720 Hi, Here are two patches for remote debugging. The first one is pretty straightforward and just makes use of the last parameter to getpkt(). The second one changes banner printed after successful connection to gdbserver from "Remote debugging using :1234" to more informational "Remote debugging from host whatever.name.com". When debugging via serial line, nothing changes. Index: ChangeLog * remote.c: Added WAIT_FOREVER_FLAG and changed all calls to getpkt() to respect it. * gdbserver/remote-utils.c (remote_open): After successful connection the remote host name is printed instead of local port number. Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * +420 2 9654 5373 * http://www.suse.cz --------------050209060500070602030609 Content-Type: text/plain; name="gdb-remote.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="gdb-remote.diff" Content-length: 12780 Index: remote.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 @@ =20 #include "gdbcore.h" /* for exec_bfd */ =20 +#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 =3D 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] =3D=3D 'O' && buf[1] =3D=3D 'K'); } =20 @@ -1550,7 +1552,7 @@ =20 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 =3D remote_unpack_thread_info_response (threadinfo_pkt + 2, threa= did, 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); =20 *result_count =3D parse_threadlist_response (t_response + 2, result_limit, &echo_nextthr= ead, @@ -1740,7 +1742,7 @@ char *buf =3D alloca (rs->remote_packet_size); =20 putpkt ("qC"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] =3D=3D 'Q' && buf[1] =3D=3D 'C') return pid_to_ptid (strtol (&buf[2], NULL, 16)); else @@ -1782,7 +1784,7 @@ { putpkt ("qfThreadInfo"); bufp =3D buf; - getpkt (bufp, (rs->remote_packet_size), 0); + getpkt (bufp, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (bufp[0] !=3D '\0') /* q packet recognized */ {=09 while (*bufp++ =3D=3D 'm') /* reply contains one or more TID */ @@ -1796,7 +1798,7 @@ while (*bufp++ =3D=3D ','); /* comma-separated list */ putpkt ("qsThreadInfo"); bufp =3D 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] !=3D 0) { n =3D 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); } =0C /* Clean up connection to a remote debugger. */ @@ -1921,7 +1923,7 @@ =20 putpkt ("qOffsets"); =20 - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (buf[0] =3D=3D '\000') return; /* Return silently. Stub doesn't support @@ -2202,7 +2204,7 @@ /* Invite target to request symbol lookups. */ =20 putpkt ("qSymbol::"); - getpkt (reply, (rs->remote_packet_size), 0); + getpkt (reply, (rs->remote_packet_size), WAIT_FOREVER_FLAG); packet_ok (reply, &remote_protocol_qSymbol); =20 while (strncmp (reply, "qSymbol:", 8) =3D=3D 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); } } =20 @@ -2304,7 +2306,7 @@ /* Tell the remote that we are using the extended protocol. */ char *buf =3D 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=20 @@ -2418,7 +2420,7 @@ /* Tell the remote that we are using the extended protocol. */ char *buf =3D 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=20 @@ -2601,7 +2603,7 @@ *p++ =3D 0; =20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (packet_ok (buf, &remote_protocol_E) =3D=3D PACKET_OK) return; @@ -2619,7 +2621,7 @@ *p++ =3D 0; =20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (packet_ok (buf, &remote_protocol_e) =3D=3D PACKET_OK) return; @@ -2690,7 +2692,7 @@ *p++ =3D 0; =20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (packet_ok (buf, &remote_protocol_E) =3D=3D PACKET_OK) goto register_event_loop; @@ -2708,7 +2710,7 @@ *p++ =3D 0; =20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (packet_ok (buf, &remote_protocol_e) =3D=3D 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); } =20 /* Reply describes registers byte by byte, each byte encoded as two @@ -3695,7 +3697,7 @@ *p =3D '\0'; =09 putpkt_binary (buf, (int) (p - buf)); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 if (buf[0] =3D=3D '\0') { @@ -3837,7 +3839,7 @@ } =20=20=20 putpkt_binary (buf, (int) (p - buf)); - getpkt (buf, sizeof_buf, 0); + getpkt (buf, sizeof_buf, WAIT_FOREVER_FLAG); =20=20=20 if (buf[0] =3D=3D 'E') { @@ -3902,7 +3904,7 @@ *p =3D '\0'; =20 putpkt (buf); - getpkt (buf, sizeof_buf, 0); + getpkt (buf, sizeof_buf, WAIT_FOREVER_FLAG); =20 if (buf[0] =3D=3D 'E') { @@ -3980,7 +3982,7 @@ data_long =3D 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] =3D=3D '\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); =20 if (buf[0] =3D=3D 'E') error ("Remote failure reply: %s", buf); @@ -4658,7 +4660,7 @@ sprintf (p, ",%d", bp_size); =20=20=20=20=20=20=20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_SOFTWARE_BP])) { @@ -4711,7 +4713,7 @@ sprintf (p, ",%d", bp_size); =20=20=20=20=20=20=20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 return (buf[0] =3D=3D 'E'); } @@ -4766,7 +4768,7 @@ sprintf (p, ",%x", len); =20=20=20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 switch (packet_ok (buf, &remote_protocol_Z[packet])) { @@ -4802,7 +4804,7 @@ p +=3D 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); =20 switch (packet_ok (buf, &remote_protocol_Z[packet])) { @@ -4840,7 +4842,7 @@ sprintf (p, ",%x", len); =20 putpkt (buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20 switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP])) { @@ -4878,7 +4880,7 @@ sprintf (p, ",%x", len); =20 putpkt(buf); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); =20=20=20 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 =3D crc32 ((unsigned char *) sectdata, size, 0xffffffff); =20 - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] =3D=3D '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; =20 - getpkt (outbuf, *bufsiz, 0); + getpkt (outbuf, *bufsiz, WAIT_FOREVER_FLAG); =20 return 0; } @@ -5141,7 +5143,7 @@ { /* XXX - see also tracepoint.c:remote_get_noisy_reply() */ buf[0] =3D '\0'; - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] =3D=3D '\0') error ("Target does not support this command\n"); if (buf[0] =3D=3D 'O' && buf[1] !=3D 'K') @@ -5182,7 +5184,7 @@ puts_filtered ("\n"); putpkt (args); =20 - 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."= ); =20 putpkt ("qfProcessInfo"); - getpkt (buf, (rs->remote_packet_size), 0); + getpkt (buf, (rs->remote_packet_size), WAIT_FOREVER_FLAG); if (buf[0] =3D=3D 0) return; /* Silently: target does not support this feature. */ =20 @@ -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); } } =20 Index: gdbserver/remote-utils.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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=3D0;; + char namebuf[100]; +=20=20 + snprintf(namebuf, 100, "%s", name); =20 if (!strchr (name, ':')) { @@ -109,6 +112,7 @@ int tmp; struct protoent *protoent; int tmp_desc; + struct hostent *hostent; =20 port_str =3D strchr (name, ':'); =20 @@ -154,6 +158,21 @@ =20 signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver si= mply exits when the remote side dies. */ + + /* Resolve peer's hostname or convert IP address to string. */ + hostent =3D gethostbyaddr ( (void *)&sockaddr.sin_addr.s_addr,=20 + 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; +=09 + ip.ip_i =3D ntohl (sockaddr.sin_addr.s_addr); + snprintf (namebuf, 100, "%u.%u.%u.%u",=20 + ip.ip_c[3], ip.ip_c[2], ip.ip_c[1], ip.ip_c[0]); + } + via_network =3D 1; } =20 #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":"us= ing", namebuf); } =20 void --------------050209060500070602030609--