remote & target_extra_thread_info, use cache w/ qThreadExtraInfo and qP too
The following patch will make "info threads" call target_extra_thread_info more frequently. When I looked at the remote implementation, I noticed that if we're not using qXfer:threads:read, then we'd be increasing the remote protocol traffic. This commit prevents that from happening. Also, it removes a gratuitous local static buffer, which seems good on its own. gdb/ChangeLog: 2018-06-29 Pedro Alves <palves@redhat.com> * remote.c (remote_target::extra_thread_info): Delete 'display_buf' and 'n' locals. from the cache, regardless of packet mechanims is in use. Use cache for qThreadExtra and qP methods too.
This commit is contained in:
parent
cd2bb70994
commit
c76a8ea36c
@ -1,3 +1,10 @@
|
|||||||
|
2018-06-29 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* remote.c (remote_target::extra_thread_info): Delete
|
||||||
|
'display_buf' and 'n' locals. from the cache, regardless of
|
||||||
|
packet mechanims is in use. Use cache for qThreadExtra and qP
|
||||||
|
methods too.
|
||||||
|
|
||||||
2018-06-29 Pedro Alves <palves@redhat.com>
|
2018-06-29 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* blockframe.c (find_pc_sect_containing_function): New function.
|
* blockframe.c (find_pc_sect_containing_function): New function.
|
||||||
|
51
gdb/remote.c
51
gdb/remote.c
@ -3830,12 +3830,9 @@ const char *
|
|||||||
remote_target::extra_thread_info (thread_info *tp)
|
remote_target::extra_thread_info (thread_info *tp)
|
||||||
{
|
{
|
||||||
struct remote_state *rs = get_remote_state ();
|
struct remote_state *rs = get_remote_state ();
|
||||||
int result;
|
|
||||||
int set;
|
int set;
|
||||||
threadref id;
|
threadref id;
|
||||||
struct gdb_ext_thread_info threadinfo;
|
struct gdb_ext_thread_info threadinfo;
|
||||||
static char display_buf[100]; /* arbitrary... */
|
|
||||||
int n = 0; /* position in display_buf */
|
|
||||||
|
|
||||||
if (rs->remote_desc == 0) /* paranoia */
|
if (rs->remote_desc == 0) /* paranoia */
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
@ -3847,15 +3844,18 @@ remote_target::extra_thread_info (thread_info *tp)
|
|||||||
server doesn't know about it. */
|
server doesn't know about it. */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
std::string &extra = get_remote_thread_info (tp)->extra;
|
||||||
|
|
||||||
|
/* If already have cached info, use it. */
|
||||||
|
if (!extra.empty ())
|
||||||
|
return extra.c_str ();
|
||||||
|
|
||||||
if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
|
if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
|
||||||
{
|
{
|
||||||
if (tp->priv != NULL)
|
/* If we're using qXfer:threads:read, then the extra info is
|
||||||
{
|
included in the XML. So if we didn't have anything cached,
|
||||||
const std::string &extra = get_remote_thread_info (tp)->extra;
|
it's because there's really no extra info. */
|
||||||
return !extra.empty () ? extra.c_str () : NULL;
|
return NULL;
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs->use_threadextra_query)
|
if (rs->use_threadextra_query)
|
||||||
@ -3871,10 +3871,9 @@ remote_target::extra_thread_info (thread_info *tp)
|
|||||||
getpkt (&rs->buf, &rs->buf_size, 0);
|
getpkt (&rs->buf, &rs->buf_size, 0);
|
||||||
if (rs->buf[0] != 0)
|
if (rs->buf[0] != 0)
|
||||||
{
|
{
|
||||||
n = std::min (strlen (rs->buf) / 2, sizeof (display_buf));
|
extra.resize (strlen (rs->buf) / 2);
|
||||||
result = hex2bin (rs->buf, (gdb_byte *) display_buf, n);
|
hex2bin (rs->buf, (gdb_byte *) &extra[0], extra.size ());
|
||||||
display_buf [result] = '\0';
|
return extra.c_str ();
|
||||||
return display_buf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3887,22 +3886,20 @@ remote_target::extra_thread_info (thread_info *tp)
|
|||||||
if (threadinfo.active)
|
if (threadinfo.active)
|
||||||
{
|
{
|
||||||
if (*threadinfo.shortname)
|
if (*threadinfo.shortname)
|
||||||
n += xsnprintf (&display_buf[0], sizeof (display_buf) - n,
|
string_appendf (extra, " Name: %s", threadinfo.shortname);
|
||||||
" Name: %s,", threadinfo.shortname);
|
|
||||||
if (*threadinfo.display)
|
if (*threadinfo.display)
|
||||||
n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
|
|
||||||
" State: %s,", threadinfo.display);
|
|
||||||
if (*threadinfo.more_display)
|
|
||||||
n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
|
|
||||||
" Priority: %s", threadinfo.more_display);
|
|
||||||
|
|
||||||
if (n > 0)
|
|
||||||
{
|
{
|
||||||
/* For purely cosmetic reasons, clear up trailing commas. */
|
if (!extra.empty ())
|
||||||
if (',' == display_buf[n-1])
|
extra += ',';
|
||||||
display_buf[n-1] = ' ';
|
string_appendf (extra, " State: %s", threadinfo.display);
|
||||||
return display_buf;
|
|
||||||
}
|
}
|
||||||
|
if (*threadinfo.more_display)
|
||||||
|
{
|
||||||
|
if (!extra.empty ())
|
||||||
|
extra += ',';
|
||||||
|
string_appendf (extra, " Priority: %s", threadinfo.more_display);
|
||||||
|
}
|
||||||
|
return extra.c_str ();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user