hanchenye-llvm-project/lldb/tools
Jason Molenda 7e9bd599a2 Add a new "thread-pcs" key-value pair to the T packet response from
debugserver.  thread-pcs has a comma separated list of base 16
addresses - the current pc value for every thread in the process.
It is a partner of the "threads:" key where a list of thread IDs
is given.  The pc values in thread-pcs correspond one-to-one with
the thread IDs in the threads list.

This is a part of performance work.  When lldb is instruction
stepping / fast stepping over a range of addresses for e.g. a "next"
command, and it steps in to another function, lldb will put a
breakpoint on the return address and continue the process.  Before
it calls continue, it calls Thread::SetupForResume on all the
threads, and SetupForResume needs to get the current pc value for
every thread to see if any are at a breakpoint site.

The result is that issuing a "c" continue requires that we send
"read pc register" packets for every thread.

We may do this sequence of step-into-function / continue-to-get-out
many times for a single user-visible "next" or "step" command, and
with highly multithreaded programs, we are sending many extra
packets to get all the thread values.

I looked at including this data in the "jstopinfo" JSON that
we already have in the T packet.  But there are three problems that
would make this increase the size of the T packet significantly.
First, numbers in JSON are base 10.  Second, a proper JSON would
have something like "thread_pcs": { "34224331112":383772734222, ...}
for thread-id 34224331112 and pc 383772734222 - so we're including
a whole extra copy of the thread id in addition to the pc.  Third,
the JSON text is hex-ascii'fied so the size of it is doubled.
In one example, 

threads:585db8,585dc7,585dc8,585dc9,585dca,585dce;thread-pcs:100001400,7fff8badc6de,7fff8badcff6,7fff8badc6de,7fff8badc6de,7fff8badc6de;

The "thread-pcs" adds 86 characters - 136 characters for both 
threads and thread-pcs.  Doing this in JSON would look like

threads={"5791160":4294972416,"5791175":140735536809694,"5791176":140735536812022,"5791177":140735536809694,"5791178":140735536809694,"5791182":140735536809694}

or 160 characters -- or 320 characters once it is hex-asciified.

Given that it's 86 characters vrs 320, I went with the old style
approach.  I've seen real world programs that have up to 60 threads
in them, so this could result in vastly larger packets if it
was all done in the JSON with hex-ascii expansion.

If we had an all-JSON T packet, where we didn't need to hex-ascii
encode anything, that would have been the better approach.  But
we'd already have a list of threads in JSON at that point so
the additional text wouldn't be too bad.

I'm working on finishing the patches to lldb to use this data;
will commit those once I've had a chance to test them more.  But
I wanted to commit the debugserver bits which are more
straightforward.


<rdar://problem/21963031> 

llvm-svn: 255711
2015-12-15 23:47:44 +00:00
..
argdumper Rename argdumper to lldb-argdumper 2015-10-29 05:07:12 +00:00
compact-unwind Fix a variety of typos. 2015-06-18 05:27:05 +00:00
darwin-debug Fix darwin-debug installation in cmake (OS X) 2015-02-06 18:13:10 +00:00
darwin-threads Add support for one API used to detect if a process 2015-11-05 23:04:57 +00:00
debugserver Add a new "thread-pcs" key-value pair to the T packet response from 2015-12-15 23:47:44 +00:00
driver Add more autotools/gmake NetBSD glue 2015-11-15 02:00:09 +00:00
install-headers
lldb-mi Allow variable names to be quoted with -var-list-children 2015-12-07 20:43:52 +00:00
lldb-perf
lldb-server Modify "platform connect" to connect to processes as well 2015-12-08 14:08:19 +00:00
CMakeLists.txt [cmake] Build lldb-server on Darwin, set dep on FreeBSD. 2015-09-17 18:35:33 +00:00
Makefile Add more NetBSD platform glue for lldb 2015-11-07 15:31:54 +00:00