This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Remote symbol lookup.
- To: "Korbel, Michal" <Michal dot Korbel at intel dot com>
- Subject: Re: Remote symbol lookup.
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Tue, 26 Jun 2001 14:54:22 -0700
- CC: gdb-patches at sources dot redhat dot com
- Organization: Red Hat
- References: <413FBB0BA5AED1119122000083234B1A01C7414A@alpha.igk.intel.com>
"Korbel, Michal" wrote:
>
> Hi Michael
Hi Michal -- by the way, I am Cc:ing the gdb-patches mailing list.
> I use remote symbol lookup feature in gdbserver with multithread support,
> but I was have problem with remote_check_symbols() function. In my opinion
> the msg buffer was not properly set. In source version of remote.c we have:
>
> while (strncmp (reply, "qSymbol:", 8) == 0)
> {
> tmp = &reply[8];
> end = hex2bin (tmp, msg, strlen (tmp) / 2);
> msg[end] = '\0';
> sym = lookup_minimal_symbol (msg, NULL, NULL);
> if (sym == NULL)
> sprintf (msg, "qSymbol::%s", &reply[8]);
> else
> sprintf (msg, "qSymbol:%s:%s",
> paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
> &reply[8]);
> putpkt (msg);
> getpkt (reply, PBUFSIZ, 0);
> }
>
> and after my changes (in red) works better.
>
> while (strncmp (reply, "qSymbol:", 8) == 0)
> {
> tmp = &reply[8];
> sym = lookup_minimal_symbol (tmp, NULL, NULL);
Michal, this change will work only under one assumption:
your remote target (gdbserver) is not hex-encoding the symbol
name. If you check the protocol spec in gdb/doc/gdb.texinfo,
you'll see that this is a bug: the symbol name is meant to be
hex-encoded. That is why the code in remote.c isn't working
for you.
I have a working implementation of the target side code
for linux threads, and we are trying to get it released
onto the sourceware site. I know this would spare you a
lot of work, so I will try as hard as I can to speed up
the process.
> if (sym == NULL)
> sprintf (msg, "qSymbol::%s", tmp);
> else
> sprintf (msg, "qSymbol:%s:%s",
> paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
> tmp);
> putpkt (msg);
> getpkt (reply, PBUFSIZ, 0);
> }
>
> but I suggest try the last version with use "end" to set valid end of
> string:
>
> while (strncmp (reply, "qSymbol:", 8) == 0)
> {
> tmp = &reply[8];
> /* Fix me: We are sure ':' is real end of string ! */
> /* If we are not sure, we need add more check */
> /* We can use max_length of symbol name */
> end = 0;
> while (tmp[end] != ':')
> end++;
> tmp[end] = '\0';
> sym = lookup_minimal_symbol (tmp, NULL, NULL);
> if (sym == NULL)
> sprintf (msg, "qSymbol::%s", tmp);
> else
> sprintf (msg, "qSymbol:%s:%s",
> paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
> tmp);
> putpkt (msg);
> getpkt (reply, PBUFSIZ, 0);
> }
>
> > --------------------------------------------------------------------------
> > ------------
> Michal Korbel - Software engineer
> Intel Technology Poland Sp. z o.o.; ul. Slowackiego 173; 80-298 Gdansk
> tel. +48 58 34-81-726; fax: +48 58 34-81-505; mobile:+48 603-203-142
> ----------------------------------------------------------------------------
> ----------