This is an archive of the discontinued LLVM Phabricator instance.

Remove usages of TimeValue from gdb-remote process plugin
ClosedPublic

Authored by labath on Oct 7 2016, 9:21 PM.

Details

Summary

Most of the changes are very straight-forward, the only tricky part was the
"packet speed-test" function, which is very time-heavy. As the function was
completely untested, I added a quick unit smoke test for it.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 74013.Oct 7 2016, 9:21 PM
labath retitled this revision from to Remove usages of TimeValue from gdb-remote process plugin.
labath updated this object.
labath added reviewers: clayborg, zturner.
labath added a subscriber: lldb-commits.
labath added inline comments.
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
2144 ↗(On Diff #74013)

First function I'd like to stash somewhere.

zturner added inline comments.Oct 8 2016, 8:49 AM
source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
192 ↗(On Diff #74013)

using namespace std is generally frowned upon, but I wonder if we could be more lenient about using namespace std::chrono? Would make a lot of those code easier on the eyes.

193–194 ↗(On Diff #74013)

Why do you need the duration_cast here? Can't you just pass in the result of GetPacketTimeout(), where GetPacketTimeout() is updated to return a std::chrono::duration<int>?

source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
266–267 ↗(On Diff #74013)

Same here. You should just be able to pass the duration straight through, and update ReadPacket to do the cast.

source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
86 ↗(On Diff #74013)

To make this more generic, this could be a std::chrono::duration<int>. If for any reason someone wanted 3.2 seconds, they could then specify it.

labath added inline comments.Oct 8 2016, 9:40 AM
source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
192 ↗(On Diff #74013)

I started using it in some tighter scopes, which are chrono-heavy. I'd be fine with the using directive at file level though.

source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
266–267 ↗(On Diff #74013)

These should go away, when everything is updated to use chrono, but the hierarchy there is multiple levels deep, so I cannot do it in a single pass (ReadPacket just calls WaitForPacketWithTimeoutMicroSecondsNoLock, which would also need to be updated... the real cast should only happen somewhere in the Connection classes, once you actually start issuing system calls).

source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
86 ↗(On Diff #74013)

I don't think that works the way you think it does. If you don't specify the ratio template argument, it will just get defaulted to std::ratio<1>, meaning seconds. To have it generic you'd have to make this a template function, with the ratio as the parameter, but at that point you might as well just choose a type with the highest precision you are willing to accept. So, I could make this take a milli or micro second durations, but I don't think that's necessary for a packet timeout.

clayborg accepted this revision.Oct 10 2016, 12:53 PM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Oct 10 2016, 12:53 PM
labath updated this revision to Diff 76442.Oct 31 2016, 10:26 AM
labath edited edge metadata.

Clean up the code a bit now that I have learned better how to use the chrono library.

This revision was automatically updated to reflect the committed changes.