hanchenye-llvm-project/lldb/tools
Pavel Labath 1eff73c324 Introduce chrono to more gdb-remote functions
Summary:
This replaces the usage of raw integers with duration classes in the gdb-remote
packet management functions. The values are still converted back to integers once
they go into the generic Communication class -- that I am leaving to a separate
change.

The changes are mostly straight-forward (*), the only tricky part was
representation of infinite timeouts.

Currently, we use UINT32_MAX to denote infinite timeout. This is not well suited
for duration classes, as they tend to do arithmetic on the values, and the
identity of the MAX value can easily get lost (e.g.
microseconds(seconds(UINT32_MAX)).count() != UINT32_MAX). We cannot use zero to
represent infinity (as Listener classes do) because we already use it to do
non-blocking polling reads. For this reason, I chose to have an explicit value
for infinity.

The way I achieved that is via llvm::Optional, and I think it reads quite
natural. Passing llvm::None as "timeout" means "no timeout", while passing zero
means "poll". The only tricky part is this breaks implicit conversions (seconds
are implicitly convertible to microseconds, but Optional<seconds> cannot be
easily converted into Optional<microseconds>). For this reason I added a special
class Timeout, inheriting from Optional, and enabling the necessary conversions
one would normally expect.

(*) The other tricky part was GDBRemoteCommunication::PopPacketFromQueue, which
was needlessly complicated. I've simplified it, but that one is only used in
non-stop mode, and so is untested.

Reviewers: clayborg, zturner, jingham

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D26971

llvm-svn: 287864
2016-11-24 10:54:49 +00:00
..
argdumper Don't allow direct access to StreamString's internal buffer. 2016-11-16 21:15:24 +00:00
compact-unwind *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
darwin-debug [CMake] Rename lldb-launcher to darwin-debug 2016-10-27 22:51:41 +00:00
darwin-threads *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
debugserver Add the ability for the task port to change when a process execs. 2016-09-28 21:07:34 +00:00
driver Fixup r284466 - try to unbreak NetBSD 2016-10-18 10:46:45 +00:00
install-headers add back an Xcode-specific Makefile for header installation 2016-01-28 22:34:36 +00:00
lldb-mi Link lldb-mi only to the llvm components it uses 2016-11-03 10:52:17 +00:00
lldb-perf *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldb-server Introduce chrono to more gdb-remote functions 2016-11-24 10:54:49 +00:00
CMakeLists.txt